public void LogMessage(string message, IEntity referencedObject = null) { var logActivity = new LogActivity { Name = "Log", }; logActivity.Save( ); ToDelete.Add(logActivity.Id); var nextActivity = ( LogActivityImplementation )logActivity.As <WfActivity>( ).CreateWindowsActivity( ); var inputs = new Dictionary <string, object> { { "Message", message }, { "Object", referencedObject } }; using (new WorkflowRunContext { RunTriggersInCurrentThread = true }) { RunActivity(nextActivity, inputs); } }
public ActionResult IndexExport(int month, int year, string ticketSubject) { try { DateTime startDate = new DateTime(year, month, 1); DateTime endDate = startDate.AddMonths(1).AddSeconds(-1); TicketInfoList list = TicketInfoList.GetReportByDate(startDate, endDate, ticketSubject); var file = CreateFile(list, month, year, ticketSubject); if (file != null) { return(new FileContentResult(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = "My Excel File.xlsx" }); } } catch (Exception ex) { LogActivity log = LogActivity.NewLogActivity(); log.ControllerName = "ExportController"; log.ActionName = "IndexExport"; log.LogData = Newtonsoft.Json.JsonConvert.SerializeObject(ex.StackTrace); log.CreatedBy = User.Identity.Name; log.CreatedDate = DateTime.Now; log = log.Save(); } return(View()); }
public void TestRun( ) { var wf = new Workflow { Name = "Wf" }; wf.AddDefaultExitPoint( ); var l1 = new LogActivity { Name = "l1" }.Cast <WfActivity>( ); var l2 = new LogActivity { Name = "12" }.Cast <WfActivity>( ); // wf.FirstActivity = l1; //wf.ContainedActivities.Add(l1); wf.ContainedActivities.Add(l2); ActivityTestHelper.AddFirstActivityWithMapping(wf, l1, null); ActivityTestHelper.AddExpressionToActivityArgument(wf, l1, "Message", "'Message 1'", false); ActivityTestHelper.AddTransition(wf, l1, l2); ActivityTestHelper.AddExpressionToActivityArgument(wf, l2, "Message", "'Message 2'", false); ActivityTestHelper.AddTermination(wf, l2, l2.GetDefaultExitPoint(), CreateDefaultExitPoint()); wf.Save( ); ActivityImplementationBase nextActivity = wf.Cast <WfActivity>( ).CreateWindowsActivity( ); l1.Save( ); l2.Save( ); ToDelete.Add(wf.Id); ToDelete.Add(l1.Id); ToDelete.Add(l2.Id); var run = (RunWorkflow(wf)); Assert.AreEqual(WorkflowRunState_Enumeration.WorkflowRunCompleted, run.WorkflowRunStatus_Enum, "Finished without errors"); // run using service }
public ActionResult Index(ViewModel.Ticket m) { string errorMessage = string.Empty; try { foreach (var item in m.Solution) { if (item.UpdateDate == DateTime.MinValue) { item.UpdateDate = DateTime.Now; } } using (DatabaseManager ctx = new DatabaseManager(true)) { if (string.IsNullOrEmpty(m.TicketNo)) { m.TicketNo = TicketNo.Create(User.Identity.Name, "TICKET"); } Ticket obj = ViewModel.Ticket.ConvertToTicketBusiness(m); obj.Requester = m.Requester.Email; obj.TicketStatus = TicketStatus.Open.ToString(); obj.Escalation = User.Identity.Name; obj.CreatedBy = User.Identity.Name; obj.CreatedDate = DateTime.Now; obj.UpdatedBy = obj.CreatedBy; obj.UpdatedDate = obj.CreatedDate; string updatecommand = "Created";//GetUpdateCommand(m, obj); var objHistory = SaveTicketHistory(obj, updatecommand); if (m.isClosed) { obj.TicketStatus = TicketStatus.Closed.ToString(); objHistory.TicketStatus = TicketStatus.Closed.ToString(); } if (obj.IsValid && objHistory.IsValid) { obj = obj.Save(); objHistory = objHistory.Save(); } else { System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (var item in obj.GetBrokenRules()) { sb.AppendLine(item.Description); } foreach (var item in objHistory.GetBrokenRules()) { sb.AppendLine(item.Description); } errorMessage = sb.ToString(); } Customer cust = ViewModel.Ticket.ConvertToCustomerBusiness(m.Requester); if (string.IsNullOrEmpty(cust.CreatedBy)) { cust.CreatedBy = User.Identity.Name; cust.CreatedDate = DateTime.Now; } cust.UpdatedBy = User.Identity.Name; cust.UpdatedDate = DateTime.Now; if (cust.IsValid) { cust = cust.Save(); } else { System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (var item in cust.GetBrokenRules()) { sb.AppendLine(item.Description); } errorMessage = errorMessage + "---" + sb.ToString(); } if (string.IsNullOrEmpty(errorMessage)) { ctx.SaveChanges(); ViewBag.SuccessMsg = "Success"; } else { throw new Exception("Terjadi kesalahan!"); } } } catch (Exception ex) { errorMessage = ex.Message + "---" + errorMessage; ViewBag.ErrorMsg = errorMessage; LogActivity log = LogActivity.NewLogActivity(); log.ControllerName = "Ticketing"; log.ActionName = "Index"; log.LogData = Newtonsoft.Json.JsonConvert.SerializeObject(errorMessage); log.CreatedBy = User.Identity.Name; log.CreatedDate = DateTime.Now; log = log.Save(); return(View(m)); } return(RedirectToAction("IndexInbox", "Inbox")); }