- adventureworks.specialoffer.zip
- AdventureWorks.SpecialOffer.Console
- AdventureWorks.SpecialOffer.ExcelEngine
- Template
- Special_Offer_Central_200712_Template.xls
- Template.xls
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using AdventureWorks.SpecialOffer.ExcelEngine;
namespace AdventureWorks.SpecialOffer.Console
{
class Program
{
[STAThread]
static void Main(string[] args)
{
RunSchedul(args);
}
private static void RunSchedul(string[] args)
{
try
{
string method = "TP";
string branchID = "";
string sDate = "";
string action = "";
string filePath = "";
for (int i = 0; i < args.Length; i++)
{
switch (args[i].ToUpper())
{
case "/METHOD":
method = args[i + 1].ToUpper();
break;
case "/BRANCH":
branchID = args[i + 1].ToUpper();
break;
case "/DATE":
sDate = args[i + 1].ToUpper();
break;
case "/ACTION":
action = args[i + 1].ToUpper();
break;
case "/FILEPATH":
filePath = args[i + 1].ToUpper();
break;
}
}
switch (method)
{
case "TP":
GenAllAPReport("PLAN", branchID, sDate, action, filePath);
break;
default:
break;
}
}
catch (Exception ex)
{
// log exception
System.Console.Write(ex.Message);
}
}
#region 生成大区活动计划报表模板
private static void GenAllAPReport(string templateType, string branchID, string sDate, string action, string filePath)
{
string returnVal = "";
if (filePath == "")
filePath = GetTempatePath();
DateTime date = DateTime.Today;
if (sDate != "")
date = DateTime.Parse(sDate);
if (action == "")
{
System.Console.WriteLine("Start to generate template");
ExcelWrapper ew = new ExcelWrapper();
ew.CallGenerateTemplate(templateType, branchID, filePath, date);
returnVal = ew.ReturnValue;
System.Console.WriteLine("Generate template successfully");
}
else
{
if (System.IO.File.Exists(filePath))
{
System.Console.WriteLine("Start to import template");
ExcelWrapper ew = new ExcelWrapper();
ew.CallImportTemplate(templateType, branchID, filePath, date);
returnVal = ew.ReturnValue;
System.Console.WriteLine("Import template successfully");
}
else
{
System.Console.WriteLine("The specified file does not exists");
}
}
}
private static string GetTempatePath()
{
string templatePath = ConfigurationSettings.AppSettings["TemplateConfigPath"].ToString().Trim();
if (templatePath == "")
{
templatePath = @"C:\Windows\Temp\";
}
else
{
if (!templatePath.EndsWith(@"\"))
{
templatePath = templatePath + @"\";
}
if (!System.IO.Directory.Exists(templatePath))
System.IO.Directory.CreateDirectory(templatePath);
}
return templatePath;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.