protected void btnStop_Click(object sender, EventArgs e) { try { WorkflowRuntime workflowRuntime = (WorkflowRuntime)Application["WokflowRuntime"]; WorkflowInstance instance = workflowRuntime.GetWorkflow(new Guid(Application["LeaveBalanceWF"].ToString())); instance.Resume(); objLeaveBalanceService = (LeaveBalanceService)workflowRuntime.GetService(typeof(LeaveBalanceService)); objLeaveBalanceService.RaiseStopEvent(instance.InstanceId); Application["LeaveBalanceWF"] = ""; btnStart.Enabled = true; btnStop.Enabled = false; btnOnDemandLeaveBalance.Enabled = false; } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { Application["LeaveBalanceWF"] = ""; FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "LeaveApplicationForm.aspx.cs", "StartWorkflow", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
protected void Application_Start() { objFileLog.WriteLine(LogType.Info, "App start", "Global.asax", "App_Start", string.Empty); XmlConfigurator.Configure(); log.Info("Vibrant Web Application started."); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new RazorViewEngine()); AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); //timer.AutoReset = true; //timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); //timer.Enabled = true; var SEM = new SEMController(); SEM.SetTimerValue(); //Resource Allocation Auto mail var resource = new ResourceController(); // resource.SetTimerValue(); var travel = new TravelController(); travel.SetTimerValue(); //Confirmation Process Auto mail var Confirmation = new ConfirmationProcessController(); Confirmation.SetTimerValue(); Application["LeaveBalanceWF"] = ""; Application["AttendanceWF"] = ""; Application["LeaveUpLoadWF"] = ""; Application["WokflowRuntime"] = ""; var workflowRuntime = Application["WokflowRuntime"] as WorkflowRuntime; if (workflowRuntime == null) { workflowRuntime = new WorkflowRuntime(); workflowRuntime.WorkflowIdled += workflowRuntime_WorkflowIdled; workflowRuntime.WorkflowLoaded += workflowRuntime_WorkflowLoaded; workflowRuntime.WorkflowUnloaded += workflowRuntime_WorkflowUnloaded; workflowRuntime.WorkflowPersisted += workflowRuntime_WorkflowPersisted; workflowRuntime.WorkflowCompleted += delegate { }; workflowRuntime.WorkflowTerminated += delegate(object sender1, WorkflowTerminatedEventArgs e1) { Debug.WriteLine(e1.Exception.Message); }; // Add the Persistance Service //WorkflowPersistenceService workflowPersistanceService = new SqlWorkflowPersistenceService(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); //workflowRuntime.AddService(workflowPersistanceService); WorkflowSchedulerService workflowSchedulerService = new DefaultWorkflowSchedulerService(); workflowRuntime.AddService(workflowSchedulerService); //System.Workflow.Runtime.Hosting. SqlTrackingService trackingService = new SqlTrackingService(connectionString2); //System.Workflow.Runtime.Tracking.SqlTrackingService workflowTrackingService = new System.Workflow.Runtime.Tracking.SqlTrackingService(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); //workflowRuntime.AddService(workflowTrackingService); // Add the External Data Exchange Service var dataExchangeService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataExchangeService); LeaveBalanceService objLeaveBalanceService; LeaveDetailsService objLeaveDetailsService; OutOfOfficeService objOutOfOfficeService; CompensationService objCompensationService; SignInSignOutService objSignInSignOutService; AttendanceCheckerService objAttendanceCheckerService; LeaveUploadService objLeaveUploadService; // Add a new instance of the LeaveBalanceService to the External Data Exchange Service objLeaveBalanceService = new LeaveBalanceService(); objLeaveDetailsService = new LeaveDetailsService(); objOutOfOfficeService = new OutOfOfficeService(); objCompensationService = new CompensationService(); objSignInSignOutService = new SignInSignOutService(); objAttendanceCheckerService = new AttendanceCheckerService(); objLeaveUploadService = new LeaveUploadService(); //Adding our services to ExternalDataExchangeService dataExchangeService.AddService(objLeaveBalanceService); dataExchangeService.AddService(objLeaveDetailsService); dataExchangeService.AddService(objOutOfOfficeService); dataExchangeService.AddService(objCompensationService); dataExchangeService.AddService(objSignInSignOutService); dataExchangeService.AddService(objAttendanceCheckerService); dataExchangeService.AddService(objLeaveUploadService); // Start the Workflow services //workflowRuntime.UnloadOnIdle = true; workflowRuntime.StartRuntime(); Application["WokflowRuntime"] = workflowRuntime; //System.Web.HttpContext.Current.Cache["WokflowRuntime"]=workflowRuntime; //System.Web.HttpContext.Current.Cache["WokflowRuntime"]=workflowRuntime; objFileLog.WriteLine(LogType.Info, "App start finished", "Global.asax", "App_Start", string.Empty); } }