private void processImportAuthorizationFile(string fileFullPath) { string expiresDate = ""; if (IsNotExpired(fileFullPath, ref expiresDate)) { try { //拷贝授权文件到特定目录下,然后设置全局的有效标志,以便程序其它地方判断 var authorizationDir = App.LocalRPAStudioDir + @"\Authorization"; if (!System.IO.Directory.Exists(authorizationDir)) { System.IO.Directory.CreateDirectory(authorizationDir); } var sourcePath = fileFullPath; var targetPath = authorizationDir + @"\license.authorization"; System.IO.File.Copy(sourcePath, targetPath, true); LoadRegisterInfo(); AutoCloseMessageBoxService.Show(m_view, "授权成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception) { AutoCloseMessageBoxService.Show(m_view, "授权文件操作失败,请检查!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } } else { AutoCloseMessageBoxService.Show(m_view, "授权文件非法!", "错误", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Stop() { if (m_app != null) { try { m_app.Terminate("执行由用户主动停止", new TimeSpan(0, 0, 0, 30)); } catch (Exception err) { Logger.Debug(err, logger); AutoCloseMessageBoxService.Show(App.Current.MainWindow, "停止调试发生异常!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } }
private void WorkflowApplicationExecutionCompleted(WorkflowApplicationCompletedEventArgs obj) { if (obj.TerminationException != null) { if (!string.IsNullOrEmpty(obj.TerminationException.Message)) { HasException = true; Common.RunInUI(() => { SharedObject.Instance.Output(SharedObject.enOutputType.Error, obj.TerminationException.ToString());//TODO WJF 标题名先不输出,只输出详情 AutoCloseMessageBoxService.Show(App.Current.MainWindow, obj.TerminationException.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error); }); } } Messenger.Default.Send(this, "EndRun"); Logger.Debug(string.Format("结束执行工作流文件 {0}", m_xamlPath), logger); }
/// <summary> /// 开始执行运行流程 /// </summary> public void Run() { HasException = false; Activity workflow = ActivityXamlServices.Load(m_xamlPath); var result = ActivityValidationServices.Validate(workflow); if (result.Errors.Count == 0) { Logger.Debug(string.Format("开始执行工作流文件 {0} ……", m_xamlPath), logger); Messenger.Default.Send(this, "BeginRun"); if (m_app != null) { m_app.Terminate(""); } m_app = new WorkflowApplication(workflow); m_app.Extensions.Add(new LogToOutputWindowTextWriter()); if (workflow is DynamicActivity) { var wr = new WorkflowRuntime(); wr.RootActivity = workflow; m_app.Extensions.Add(wr); } m_app.OnUnhandledException = WorkflowApplicationOnUnhandledException; m_app.Completed = WorkflowApplicationExecutionCompleted; m_app.Run(); } else { AutoCloseMessageBoxService.Show(App.Current.MainWindow, "工作流校验错误,请检查参数配置", "错误", MessageBoxButton.OK, MessageBoxImage.Warning); } }