So. I am trying to trigger a second report style after I fire one off so it is automated. I have code going that gets the task into the Active Tasks queue, but it does not want to actually fire off, it just stays with a status of Queued. Any idea how to successfully kick off this task?
Heres my code:
var param = ds.ProcessPaymentParam.FirstOrDefault();
if (param == null) return;
// Only fire for the print style - prevents loop if ECM style is ever run manually
if (param.ReportStyleNum != 1006) return;
// Create ECM task
var newTask = new Ice.Tables.SysTask();
newTask.Company = callContextClient.CurrentCompany;
newTask.RunProcedure = "Erp.Internal.AP.ProcessPayment.dll";
newTask.TaskDescription = "AP Check ECM Filing";
newTask.TaskType = "Report";
newTask.TaskStatus = "Queued";
newTask.SubmitUser = callContextClient.CurrentUserId;
//newTask.StartedOn = System.DateTime.UtcNow;
Db.Add(newTask);
Db.Validate(newTask);
var printTask = Db.SysTask
.Where(t => t.Company == callContextClient.CurrentCompany
&& t.RunProcedure == "Erp.Internal.AP.ProcessPayment.dll"
&& t.SysTaskNum != newTask.SysTaskNum)
.OrderByDescending(t => t.SysTaskNum)
.FirstOrDefault();
if (printTask != null)
{
newTask.AgentID = printTask.AgentID;
newTask.AgentSchedNum = printTask.AgentSchedNum;
Db.Validate(newTask);
}
Action<string, string, int, bool, decimal> addParam = (name, ch, integer, logical, dec) => {
var p = new Ice.Tables.SysTaskParam();
p.SysTaskNum = newTask.SysTaskNum;
p.ParamName = name;
p.ParamCharacter = ch;
p.ParamInteger = integer;
p.ParamLogical = logical;
p.ParamDecimal = dec;
Db.Add(p);
};
addParam("ReportID", "ApCheck", 0, false, 0m);
addParam("ReportStyleNum", "", 1002, false, 0m);
addParam("GroupID", param.GroupID, 0, false, 0m);
addParam("BankAcctID", param.BankAcctID, 0, false, 0m);
addParam("Cur-Comp", callContextClient.CurrentCompany, 0, false, 0m);
addParam("DCD-UserID", callContextClient.CurrentUserId, 0, false, 0m);
addParam("Cur-Plant", callContextClient.CurrentPlant, 0, false, 0m);
addParam("CUR-LangID", "enu", 0, false, 0m);
addParam("AutoAction", "", 0, false, 0m);
addParam("SSRSEnableRouting", "", 0, true, 0m);
addParam("FormsToGenerate", param.FormsToGenerate, 0, false, 0m);
addParam("FormsToPrint", "C", 0, false, 0m);
addParam("SSRSRenderFormat", "PDF", 0, false, 0m);
addParam("CheckPrinting", "", 0, true, 0m);
addParam("SortBy", param.SortBy, 0, false, 0m);
addParam("RptFileType", "XML", 0, false, 0m);
addParam("ReportParameterDataSetId", "ProcessPayment", 0, false, 0m);
addParam("ReportParameterDataSetSystemCode", "Erp", 0, false, 0m);
addParam("ReportCultureCode", param.ReportCultureCode,0, false, 0m);
addParam("ReportCurrencyCode", param.ReportCurrencyCode,0, false, 0m);
Db.Validate();