Пример #1
0
        private void filePathValidate(string value)
        {
            IsFilePathCorrect = true;
            if (string.IsNullOrEmpty(value))
            {
                IsFilePathCorrect = false;
                // 位置不能为空
                FilePathValidatedWrongTip = ResxIF.GetString("PathCannotBeEmpty");
            }
            else
            {
                if (!Directory.Exists(value))
                {
                    IsFilePathCorrect = false;
                    // 指定的位置不存在
                    FilePathValidatedWrongTip = ResxIF.GetString("ThePathDoesNotExist");
                }
            }

            //判断是否是在项目目录中的子目录里
            if (!value.IsSubPathOf(ProjectPath))
            {
                IsFilePathCorrect = false;
                // 指定的位置必须是项目所在目录或其子目录中
                FilePathValidatedWrongTip = ResxIF.GetString("NotInSubDirectory");
            }

            CreateFileCommand.RaiseCanExecuteChanged();
        }
Пример #2
0
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Common.RunInUI(() =>
            {
                try
                {
                    var exception = e.ExceptionObject as Exception;
                    if (exception != null)
                    {
                        Logger.Error("非UI线程全局异常", logger);
                        Logger.Error(exception, logger);
                        //MessageBox.Show("程序运行过程中出现了异常,请联系软件开发商!");
                        MessageBox.Show(ResxIF.GetString("Error_CallDeveloper"));
                    }

                    if (exception is System.OutOfMemoryException)
                    {
                        Environment.Exit(0);//内存不足直接退出,不然会持续弹窗
                    }
                }
                catch (Exception ex)
                {
                    Logger.Fatal("不可恢复的非UI线程全局异常", logger);
                    Logger.Fatal(ex, logger);
                    //MessageBox.Show("程序运行过程中出现了严重错误,即将退出,请联系软件开发商!");
                    MessageBox.Show(ResxIF.GetString("Error_Critical_Exit"));
                    Environment.Exit(0);
                }
            });
        }
Пример #3
0
        private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            Common.RunInUI(() =>
            {
                try
                {
                    Logger.Error("UI线程全局异常", logger);
                    Logger.Error(e.Exception, logger);
                    e.Handled = true;
                    //MessageBox.Show("程序运行过程中出现了异常,请联系软件开发商!");
                    MessageBox.Show(ResxIF.GetString("Error_CallDeveloper"));

                    if (e.Exception is System.OutOfMemoryException)
                    {
                        Environment.Exit(0);//内存不足直接退出,不然会持续弹窗
                    }
                }
                catch (Exception ex)
                {
                    Logger.Fatal("不可恢复的UI线程全局异常", logger);
                    Logger.Fatal(ex, logger);
                    //MessageBox.Show("程序运行过程中出现了严重错误,即将退出,请联系软件开发商!");
                    MessageBox.Show(ResxIF.GetString("Error_Critical_Exit"));
                    Environment.Exit(0);
                }
            });
        }
        private void doInstallUpgradePackage(string upgradePackageFilePath)
        {
            //弹窗提示用户是否现在立刻更新程序
            var ret = MessageBox.Show(App.Current.MainWindow, "升级包已经下载好,是否现在更新?", ResxIF.GetString("ConfirmText"), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);

            if (ret == MessageBoxResult.Yes)
            {
                bool isDocumentNeedSave = false;
                foreach (var doc in ViewModelLocator.Instance.Dock.Documents)
                {
                    if (doc.IsDirty)
                    {
                        isDocumentNeedSave = true;
                        break;
                    }
                }

                if (isDocumentNeedSave)
                {
                    MessageBox.Show(App.Current.MainWindow, "您有文档修改但未保存,请保存文档后再升级", ResxIF.GetString("PronptText"), MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    Common.ShellExecute(upgradePackageFilePath);
                }
            }
            else if (ret == MessageBoxResult.No)
            {
            }
        }
Пример #5
0
        private void dstNameValidate(string value)
        {
            IsDstNameCorrect = true;

            if (string.IsNullOrEmpty(value))
            {
                IsDstNameCorrect = false;
                // 名称不能为空
                DstNameValidatedWrongTip = ResxIF.GetString("NameIsRequired");
            }
            else
            {
                if (value.Contains(@"\") || value.Contains(@"/"))
                {
                    IsDstNameCorrect = false;
                    // 名称不能有非法字符
                    DstNameValidatedWrongTip = ResxIF.GetString("NameHasIlligalCharacter");
                }
                else
                {
                    System.IO.FileInfo fi = null;
                    try
                    {
                        fi = new System.IO.FileInfo(value);
                    }
                    catch (ArgumentException) { }
                    catch (System.IO.PathTooLongException) { }
                    catch (NotSupportedException) { }
                    if (ReferenceEquals(fi, null))
                    {
                        // file name is not valid
                        IsDstNameCorrect         = false;
                        DstNameValidatedWrongTip = ResxIF.GetString("NameHasIlligalCharacter");
                    }
                    else
                    {
                        // file name is valid... May check for existence by calling fi.Exists.
                    }
                }
            }

            var dstFullPath = Dir + @"\" + DstName;

            if (Directory.Exists(dstFullPath))
            {
                IsDstNameCorrect = false;
                // 相同名字的目录已存在
                DstNameValidatedWrongTip = ResxIF.GetString("SameNameDirectoryAlreadyExists");
            }
            else if (File.Exists(dstFullPath))
            {
                IsDstNameCorrect = false;
                // 相同名字的文件已存在
                DstNameValidatedWrongTip = ResxIF.GetString("SameNameFileAlreadyExists");
            }


            OkCommand.RaiseCanExecuteChanged();
        }
Пример #6
0
 private void BeginRun(DebuggerManager obj)
 {
     m_layoutAnchorable          = new LayoutAnchorable();
     m_layoutAnchorable.CanClose = false;
     m_layoutAnchorable.CanHide  = false;
     m_layoutAnchorable.Title    = ResxIF.GetString("VariableTracking"); // 变量跟踪
     m_layoutAnchorable.IsActive = true;
     m_layoutAnchorable.Content  = new LocalsContent();
     m_view.m_leftLayoutAnchorablePane.Children.Add(m_layoutAnchorable);
 }
Пример #7
0
        /// <summary>
        /// 开始执行工作流时触发
        /// </summary>
        /// <param name="obj">对象</param>
        private void BeginRun(RunManager obj)
        {
            //流程运行开始……
            SharedObject.Instance.Output(SharedObject.enOutputType.Trace, ResxIF.GetString("TheProcessStarted"));

            //不应该更新状态为START,不然和用户自己设置的标识冲突了
            //Task.Run(async()=> {
            //    await ControlServerService.UpdateRunStatus(obj.m_packageItem.Name, obj.m_packageItem.Version, ControlServerService.enProcessStatus.Start);
            //});


            if (FFmpegService != null)
            {
                FFmpegService.StopCaptureScreen();
                FFmpegService = null;
            }

            if (ViewModelLocator.Instance.UserPreferences.IsEnableScreenRecorder)
            {
                //屏幕录像开始……
                SharedObject.Instance.Output(SharedObject.enOutputType.Trace, ResxIF.GetString("ScreenRecordingStarted"));
                var screenRecorderFilePath = App.LocalRPAStudioDir + @"\ScreenRecorder\" + obj.m_packageItem.Name + @"(" + DateTime.Now.ToString(ResxIF.GetString("YYYYMMDD")) + ").mp4";
                FFmpegService = new FFmpegService(screenRecorderFilePath, ViewModelLocator.Instance.UserPreferences.FPS, ViewModelLocator.Instance.UserPreferences.Quality);//默认存到%localappdata%下RPASTUDIO下的ScreenRecorder目录下

                Task.Run(() =>
                {
                    FFmpegService.StartCaptureScreen();
                });

                //等待屏幕录像ffmpeg进程启动
                int wait_count = 0;
                while (!FFmpegService.IsRunning())
                {
                    wait_count++;
                    Thread.Sleep(300);
                    if (wait_count == 10)
                    {
                        break;
                    }
                }
            }


            Common.RunInUI(() => {
                m_view.Hide();

                obj.m_packageItem.IsRunning = true;

                IsWorkflowRunning      = true;
                WorkflowRunningName    = obj.m_packageItem.Name;
                WorkflowRunningToolTip = obj.m_packageItem.ToolTip;
                WorkflowRunningStatus  = ResxIF.GetString("RunningText"); //正在运行
            });
        }
 public void DoAuthorizationCheck()
 {
     //授权检测
     if (!IsNotExpired())
     {
         // 软件未通过授权检测,请注册产品!
         var tip = ResxIF.GetString("TheSoftwareFailedAuthorizationTest");
         Logger.Debug(tip, logger);
         MessageBox.Show(tip, ResxIF.GetString("PronptText"), MessageBoxButton.OK, MessageBoxImage.Error);
         Environment.Exit(0);
         return;
     }
 }
        private void OnDownloadFinished(HttpDownloadFile obj)
        {
            Common.RunInUI(() => {
                if (obj.IsDownloadSuccess)
                {
                    var fileMd5 = Common.GetMD5HashFromFile(obj.SaveFilePath);
                    if (m_autoUpgradePackpageMd5.ToLower() == fileMd5.ToLower())
                    {
                        //文件MD5校验一致,说明包下载成功且未被破坏,提示用户安装
                        var saveDir = Path.GetDirectoryName(obj.SaveFilePath);

                        var originFileName = Common.GetFileNameFromUrl(obj.Url);

                        var finishedFilePath = saveDir + @"\" + originFileName;

                        if (File.Exists(finishedFilePath))
                        {
                            File.Delete(finishedFilePath);
                        }

                        File.Move(obj.SaveFilePath, finishedFilePath);

                        if (!File.Exists(finishedFilePath))
                        {
                            //重命名失败
                            Logger.Error(string.Format("重命名{0}到{1}失败", obj.SaveFilePath, finishedFilePath), logger);

                            MessageBox.Show(App.Current.MainWindow, "升级包重命名操作出现异常,请检查!", ResxIF.GetString("ErrorText"), MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                        else
                        {
                            doInstallUpgradePackage(finishedFilePath);
                        }
                    }
                    else
                    {
                        //安装包下载出现问题(可能安装包之前残留的断点数据不对,删除这个文件),提示用户重试
                        if (File.Exists(obj.SaveFilePath))
                        {
                            File.Delete(obj.SaveFilePath);
                        }

                        MessageBox.Show(App.Current.MainWindow, "升级包MD5校验不一致,请重试!", ResxIF.GetString("ErrorText"), MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else
                {
                    MessageBox.Show(App.Current.MainWindow, "下载过程中出现异常,请检查并重试!", ResxIF.GetString("ErrorText"), MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            });
        }
Пример #10
0
        private void fileNameValidate(string value)
        {
            IsFileNameCorrect = true;

            if (string.IsNullOrEmpty(value))
            {
                IsFileNameCorrect = false;
                // 名称不能为空
                FileNameValidatedWrongTip = ResxIF.GetString("NameIsRequired");
            }
            else
            {
                if (value.Contains(@"\") || value.Contains(@"/"))
                {
                    IsFileNameCorrect = false;
                    // 名称不能有非法字符
                    FileNameValidatedWrongTip = ResxIF.GetString("NameHasIlligalCharacter");
                }
                else
                {
                    System.IO.FileInfo fi = null;
                    try
                    {
                        fi = new System.IO.FileInfo(value);
                    }
                    catch (ArgumentException) { }
                    catch (System.IO.PathTooLongException) { }
                    catch (NotSupportedException) { }
                    if (ReferenceEquals(fi, null))
                    {
                        // file name is not valid
                        IsFileNameCorrect         = false;
                        FileNameValidatedWrongTip = ResxIF.GetString("NameHasIlligalCharacter");
                    }
                    else
                    {
                        // file name is valid... May check for existence by calling fi.Exists.
                    }
                }
            }

            if (File.Exists(FilePath + @"\" + FileName + @".xaml"))
            {
                IsFileNameCorrect = false;
                // 指定的文件已存在
                FileNameValidatedWrongTip = ResxIF.GetString("TheFileAlreadyExists");
            }

            CreateFileCommand.RaiseCanExecuteChanged();
        }
Пример #11
0
 public void Stop()
 {
     if (m_app != null)
     {
         try
         {
             m_app.Unload();
             m_app.Terminate("执行已取消", new TimeSpan(0, 0, 0, 30));
         }
         catch (Exception)
         {
             MessageBox.Show(App.Current.MainWindow, "停止调试发生异常!", ResxIF.GetString("PronptText"), MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
 }
Пример #12
0
 public void Stop()
 {
     if (m_app != null)
     {
         try
         {
             Continue(enOperate.Stop);                                                           //防止有事件卡住未往下走导致无法正常停止
             m_app.Terminate(ResxIF.GetString("ExecutionCancelled"), new TimeSpan(0, 0, 0, 30)); // 执行已取消
         }
         catch (Exception)
         {
             // 停止调试发生异常!
             MessageBox.Show(App.Current.MainWindow, ResxIF.GetString("ExceptionOccurredWhileDebugging"), ResxIF.GetString("PronptText"), MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
 }
Пример #13
0
        public bool DoCloseDocument()
        {
            if (IsDebugging)
            {
                // 当前文档正在被调试,确定终止调试并关闭\"{0}\"吗?
                var ret = MessageBox.Show(App.Current.MainWindow, string.Format(ResxIF.GetString("MB_CloseWhileDebugging"), XamlPath), ResxIF.GetString("ConfirmText"), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);
                if (ret == MessageBoxResult.Yes)
                {
                    ViewModelLocator.Instance.Main.StopWorkflowCommand.Execute(null);
                }
                else if (ret == MessageBoxResult.No)
                {
                    return(false);
                }
            }

            //当前文档窗口关闭
            bool isClose = true;

            if (IsDirty)
            {
                //var ret = MessageBox.Show(App.Current.MainWindow, string.Format("文件有修改,需要保存文件\"{0}\"吗?", XamlPath), "询问", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Yes);
                var ret = MessageBox.Show(App.Current.MainWindow, string.Format(ResxIF.GetString("Message_SaveConfirm"), XamlPath), ResxIF.GetString("ConfirmText"), MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Yes);

                if (ret == MessageBoxResult.Yes)
                {
                    SaveDocument();
                }
                else if (ret == MessageBoxResult.No)
                {
                }
                else
                {
                    isClose = false;
                }
            }

            if (isClose)
            {
                Messenger.Default.Send(this, "Close");
                Messenger.Default.Unregister(this);//取消注册
            }

            return(isClose);
        }
Пример #14
0
        /// <summary>
        /// 开始执行调试流程
        /// </summary>
        public void Debug()
        {
            //授权检测
            ViewModelLocator.Instance.SplashScreen.DoAuthorizationCheck();

            Activity workflow = ActivityXamlServices.Load(m_xamlPath);

            var result = ActivityValidationServices.Validate(workflow);

            if (result.Errors.Count == 0)
            {
                Messenger.Default.Send(this, "BeginRun");

                m_wfElementToSourceLocationMap = UpdateSourceLocationMappingInDebuggerService();
                m_activityIdToWfElementMap     = BuildActivityIdToWfElementMap(m_wfElementToSourceLocationMap);

                if (m_app != null)
                {
                    m_app.Terminate("");
                }

                m_app = new WorkflowApplication(workflow);
                m_app.OnUnhandledException = WorkflowApplicationOnUnhandledException;
                m_app.Completed            = WorkflowApplicationExecutionCompleted;

                m_simTracker = generateTracker();
                m_app.Extensions.Add(m_simTracker);
                m_app.Extensions.Add(new LogToOutputWindowTextWriter());

                if (workflow is DynamicActivity)
                {
                    var wr = new WorkflowRuntime();
                    wr.RootActivity = workflow;
                    m_app.Extensions.Add(wr);
                }

                m_app.Run();
            }
            else
            {
                // 工作流校验错误,请检查参数配置
                MessageBox.Show(App.Current.MainWindow, ResxIF.GetString("WorkflowCheckError"), ResxIF.GetString("ErrorText"), MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Пример #15
0
        private void InitDependencies(ProjectTreeItem projectItem)
        {
            var dependRootItem = new ProjectTreeItem(this);

            dependRootItem.IsDependRoot = true;
            dependRootItem.IsExpanded   = true;
            //dependRootItem.Name = "依赖包";
            dependRootItem.Name = ResxIF.GetString("DependencyText");
            dependRootItem.Icon = "pack://application:,,,/Resources/Image/Project/dependencies.png";
            projectItem.Children.Add(dependRootItem);

            string json     = File.ReadAllText(CurrentProjectJsonFile);
            var    json_cfg = Newtonsoft.Json.JsonConvert.DeserializeObject <ProjectJsonConfig>(json);

            foreach (JProperty jp in (JToken)json_cfg.dependencies)
            {
                var ver_range = VersionRange.Parse((string)jp.Value);

                string ver_desc = "";

                //目前只考虑等于和大于等于两种情况
                if (ver_range.MinVersion == ver_range.MaxVersion)
                {
                    ver_desc = $" = {ver_range.MinVersion}";
                }
                else
                {
                    if (ver_range.MinVersion != null && ver_range.IsMinInclusive)
                    {
                        ver_desc = $" >= {ver_range.MinVersion}";
                    }
                }

                var desc = jp.Name + ver_desc;

                var dependItem = new ProjectTreeItem(this);
                dependItem.IsDependItem = true;
                dependItem.Name         = desc;
                dependItem.Icon         = "pack://application:,,,/Resources/Image/Project/depend-item.png";
                dependRootItem.Children.Add(dependItem);
            }
        }
Пример #16
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Instance = this;

            DispatcherHelper.Initialize();

#if DEBUG
            AllocConsole();
#else
            Console.SetOut(new LogToOutputWindowTextWriter());
#endif


            Current.DispatcherUnhandledException       += App_OnDispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            clearDynamicActivityGeneratorDll();

            initDirs();

            bool createdNew = false;
            instanceMutex = new Mutex(true, "{BCC9EF66-8C2D-44FD-A30F-11ECBD34D993}", out createdNew);
            if (createdNew)
            {
#if ENABLE_AUTHORIZATION_CHECK
                Logger.Debug("RPAStudio启动(带授权检测版本)……", logger);
#else
                Logger.Debug("RPAStudio启动(无授权检测版本)……", logger);
#endif

                UiElement.Init();
            }
            else
            {
                //MessageBox.Show("该程序已经运行,不能重复运行!");
                MessageBox.Show(ResxIF.GetString("Error_AlreadyRunning"));
                Environment.Exit(0);
            }
        }
Пример #17
0
        private void projectPathValidate(string value)
        {
            IsProjectPathCorrect = true;
            if (string.IsNullOrEmpty(value))
            {
                IsProjectPathCorrect = false;
                // 位置不能为空
                ProjectPathValidatedWrongTip = ResxIF.GetString("PathCannotBeEmpty");
            }
            else
            {
                if (!Directory.Exists(value))
                {
                    IsProjectPathCorrect = false;
                    // 指定的位置不存在
                    ProjectPathValidatedWrongTip = ResxIF.GetString("ThePathDoesNotExist");
                }
            }

            CreateProjectCommand.RaiseCanExecuteChanged();
        }
Пример #18
0
        private void EndRun(RunManager obj)
        {
            SharedObject.Instance.Output(SharedObject.enOutputType.Trace, ResxIF.GetString("EndProcessRun")); //流程运行结束

            Task.Run(async() =>
            {
                if (obj.HasException)
                {
                    await ControlServerService.UpdateRunStatus(obj.m_packageItem.Name, obj.m_packageItem.Version, ControlServerService.enProcessStatus.Exception);
                }
                else
                {
                    await ControlServerService.UpdateRunStatus(obj.m_packageItem.Name, obj.m_packageItem.Version, ControlServerService.enProcessStatus.Stop);
                }
            });

            if (ViewModelLocator.Instance.UserPreferences.IsEnableScreenRecorder)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Trace, ResxIF.GetString("EndScreenRecording")); //屏幕录像结束
                FFmpegService.StopCaptureScreen();
                FFmpegService = null;
            }

            Common.RunInUI(() => {
                m_view.Show();
                m_view.Activate();

                obj.m_packageItem.IsRunning = false;

                //由于有可能列表已经刷新,所以需要重置IsRunning状态,为了方便,全部重置
                foreach (var pkg in PackageItems)
                {
                    pkg.IsRunning = false;
                }

                IsWorkflowRunning     = false;
                WorkflowRunningName   = "";
                WorkflowRunningStatus = "";
            });
        }
Пример #19
0
        private bool MoveDirToDir(ProjectTreeItem sourceItem, ProjectTreeItem targetItem)
        {
            var srcPath = sourceItem.Path;
            var dstPath = targetItem.Path;

            var dstPathCombine = System.IO.Path.Combine(dstPath, sourceItem.Name);

            if (System.IO.Directory.Exists(dstPathCombine))
            {
                // 目标目录有重名目录,无法移动目录
                MessageBox.Show(App.Current.MainWindow, ResxIF.GetString("msgDirectoryAlredyExists"), ResxIF.GetString("msgWarning"), MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                System.IO.Directory.Move(srcPath, dstPathCombine);

                //遍历目录所有文件
                foreach (var file in System.IO.Directory.GetFiles(dstPathCombine, "*.*"))
                {
                    var relativeFile = Common.MakeRelativePath(dstPathCombine, file);
                    var srcFile      = System.IO.Path.Combine(srcPath, relativeFile);

                    foreach (var doc in ViewModelLocator.Instance.Dock.Documents)
                    {
                        if (doc.XamlPath.EqualsIgnoreCase(srcFile))
                        {
                            doc.XamlPath = file;
                            break;
                        }
                    }
                }
                //刷新工程树视图

                ViewModelLocator.Instance.Project.RefreshCommand.Execute(null);

                return(true);
            }
            return(false);
        }
Пример #20
0
        private void Upgrade(ref string schemaVersion, string newSchemaVersion)
        {
            if (schemaVersion == newSchemaVersion)
            {
                return;
            }

            Version currentVersion = new Version(schemaVersion);
            Version latestVersion  = new Version(newSchemaVersion);

            if (currentVersion < new Version("2.0.0.0"))
            {
                //提示用户不再支持老版本项目,后期考虑再自动升级项目并备份老项目
                //TODO WJF 旧项目如何升级
                // 当前程序不再支持V2.0版本以下的旧版本项目!
                var err = ResxIF.GetString("NotSupportBelowV2");
                MessageBox.Show(err);
                throw new Exception(err);
            }

            Upgrade(ref schemaVersion, initial_schema_version);
        }
Пример #21
0
        private bool MoveFileToDir(ProjectTreeItem sourceItem, ProjectTreeItem targetItem)
        {
            var srcFile = sourceItem.Path;
            var dstPath = targetItem.Path;

            //拷贝源文件到目录路径中去,若源文件所对应的旧有路径已经在设计器中打开,则需要更新设计器中对应的路径
            var dstFile = System.IO.Path.Combine(dstPath, sourceItem.Name);

            if (System.IO.File.Exists(dstFile))
            {
                // 目标目录有重名文件,无法移动文件
                MessageBox.Show(App.Current.MainWindow, ResxIF.GetString("msgFileAlredyExists"), ResxIF.GetString("msgWarning"), MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else
            {
                System.IO.File.Move(srcFile, dstFile);
                sourceItem.Path = dstFile;//更新VM
                foreach (var doc in ViewModelLocator.Instance.Dock.Documents)
                {
                    if (doc.XamlPath.EqualsIgnoreCase(srcFile))
                    {
                        doc.XamlPath = dstFile;
                        break;
                    }
                }

                if (sourceItem.IsMain)
                {
                    //如果是主文件,则移动过去后还是主文件
                    sourceItem.SetAsMainCommand.Execute(null);
                }

                return(true);
            }

            return(false);
        }
Пример #22
0
        private void OpenProject(MessengerObjects.ProjectOpen msg)
        {
            //根据project.json信息打开项目

            string json_file = msg.ProjectJsonFile;

            if (json_file == CurrentProjectJsonFile)
            {
                //当前项目早已经打开,只需要做一些必要操作即可
                if (!string.IsNullOrEmpty(msg.DefaultOpenXamlFile))
                {
                    //打开特定文档
                    var item = GetProjectTreeItemByFullPath(msg.DefaultOpenXamlFile);
                    if (item != null)
                    {
                        item.OpenXamlCommand.Execute(null);
                    }
                }

                //关闭起始页
                ViewModelLocator.Instance.Main.IsOpenStartScreen   = false;
                ViewModelLocator.Instance.Main.IsBackButtonVisible = true;

                return;
            }

            ViewModelLocator.Instance.Output.ClearAllCommand.Execute(null);//打开新项目前清空旧项目的输出日志内容

            ViewModelLocator.Instance.Main.IsStartContentBusy = true;

            Task.Run(async() => {
                try
                {
                    CurrentProjectJsonFile = json_file;

                    ProcessProjectJsonConfig();//提前进行旧版本判断

                    //加载项目依赖项
                    await LoadDependencies();

                    //调整最近项目顺序
                    if (msg.Sender is RecentProjectItem)
                    {
                        (msg.Sender as RecentProjectItem).RecentProjectsReorder();
                    }

                    ProjectSettingsDataManager.ResetInstance();
                    ProjectSettingsDataManager.Instance.Load(Path.GetDirectoryName(msg.ProjectJsonFile));

                    initProject(false);

                    var state_changed_msg         = new MessengerObjects.ProjectStateChanged();
                    state_changed_msg.ProjectPath = Path.GetDirectoryName(CurrentProjectJsonFile);
                    state_changed_msg.ProjectName = ProjectName;
                    Messenger.Default.Send(state_changed_msg);

                    Common.RunInUI(() => {
                        //清空组件树历史条目
                        ViewModelLocator.Instance.Activities.ItemRecent.Children.Clear();

                        ProjectItems = new ObservableCollection <ProjectTreeItem>(ProjectItemsTemp);

                        if (string.IsNullOrEmpty(msg.DefaultOpenXamlFile))
                        {
                            //自动打开Main文档
                            if (MainProjectTreeItem != null)
                            {
                                MainProjectTreeItem.OpenXamlCommand.Execute(null);
                            }
                        }
                        else
                        {
                            //打开特定文档
                            var item = GetProjectTreeItemByFullPath(msg.DefaultOpenXamlFile);
                            if (item != null)
                            {
                                item.OpenXamlCommand.Execute(null);
                            }
                        }

                        //关闭起始页
                        ViewModelLocator.Instance.Main.IsOpenStartScreen   = false;
                        ViewModelLocator.Instance.Main.IsBackButtonVisible = true;
                    });
                }
                catch (Exception err)
                {
                    Logger.Error(err, logger);
                    CurrentProjectJsonFile = "";
                    Common.RunInUI(() => {
                        MessageBox.Show(App.Current.MainWindow, ResxIF.GetString("ProjectOpenError"), ResxIF.GetString("ErrorText"), MessageBoxButton.OK, MessageBoxImage.Warning);;
                    });
                }finally
                {
                    ViewModelLocator.Instance.Main.IsStartContentBusy = false;
                }
            });
        }
Пример #23
0
 private void WorkflowApplicationExecutionCompleted(WorkflowApplicationCompletedEventArgs obj)
 {
     if (obj.TerminationException != null)
     {
         if (!string.IsNullOrEmpty(obj.TerminationException.Message))
         {
             Common.RunInUI(() => {
                 // 运行时执行错误
                 SharedObject.Instance.Output(SharedObject.enOutputType.Error, ResxIF.GetString("RuntimeError"), obj.TerminationException.ToString());
                 MessageBox.Show(App.Current.MainWindow, obj.TerminationException.Message, ResxIF.GetString("RuntimeError"), MessageBoxButton.OK, MessageBoxImage.Error);
             });
         }
     }
     Messenger.Default.Send(this, "EndRun");
 }
Пример #24
0
 private void LogToOutputWindow(SharedObject.enOutputType type, string msg, string msgDetails)
 {
     Log(type, msg);
     //活动日志:type={0},msg={1},msgDetails={2}
     Logger.Debug(string.Format(ResxIF.GetString("ActivityLog"), type, msg, msgDetails), logger);
 }
Пример #25
0
        public void RefreshAllPackages()
        {
            PackageItems.Clear();

            var repo    = PackageRepositoryFactory.Default.CreateRepository(PackagesDir);
            var pkgList = repo.GetPackages();

            var pkgSet = new SortedSet <string>();

            foreach (var pkg in pkgList)
            {
                //通过set去重
                pkgSet.Add(pkg.Id);
            }

            Dictionary <string, IPackage> installedPkgDict = new Dictionary <string, IPackage>();

            var packageManager = new PackageManager(repo, InstalledPackagesDir);

            foreach (IPackage pkg in packageManager.LocalRepository.GetPackages())
            {
                installedPkgDict[pkg.Id] = pkg;
            }

            foreach (var name in pkgSet)
            {
                var item = new PackageItem();
                item.Name = name;

                var version = repo.FindPackagesById(name).Max(p => p.Version);
                item.Version = version.ToString();

                var pkgNameList = repo.FindPackagesById(name);
                foreach (var i in pkgNameList)
                {
                    item.VersionList.Add(i.Version.ToString());
                }

                bool isNeedUpdate = false;
                if (installedPkgDict.ContainsKey(item.Name))
                {
                    var installedVer = installedPkgDict[item.Name].Version;
                    if (version > installedVer)
                    {
                        isNeedUpdate = true;
                    }
                }
                else
                {
                    isNeedUpdate = true;
                }
                item.IsNeedUpdate = isNeedUpdate;

                var pkg = repo.FindPackage(name, version);
                item.Package = pkg;
                var    publishedTime = pkg.Published.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
                string toolTip       = ResxIF.GetString("PackageToolTip"); //"名称:{0}\r\n版本:{1}\r\n发布说明:{2}\r\n项目描述:{3}\r\n发布时间:{4}"
                item.ToolTip = string.Format(toolTip, item.Name, item.Version, pkg.ReleaseNotes, pkg.Description, (publishedTime == null ? "未知" : publishedTime));

                if (IsWorkflowRunning && item.Name == WorkflowRunningName)
                {
                    item.IsRunning = true;//如果当前该包工程已经在运行,则要设置IsRunning
                }

                PackageItems.Add(item);
            }


            doSearch();
        }
Пример #26
0
        private void WorkflowApplicationExecutionCompleted(WorkflowApplicationCompletedEventArgs obj)
        {
            if (obj.TerminationException != null)
            {
                if (!string.IsNullOrEmpty(obj.TerminationException.Message))
                {
                    Common.RunInUI(() =>
                    {
                        // 调试时执行错误
                        SharedObject.Instance.Output(SharedObject.enOutputType.Error, ResxIF.GetString("ErrorWhileDebugging"), obj.TerminationException.ToString());
                        MessageBox.Show(App.Current.MainWindow, obj.TerminationException.Message, ResxIF.GetString("ErrorWhileDebugging"), MessageBoxButton.OK, MessageBoxImage.Error);
                    });
                }
            }

            Messenger.Default.Send(this, "EndRun");
            m_mainView.Dispatcher.Invoke(DispatcherPriority.Render
                                         , (Action)(() =>
            {
                m_workflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation(m_xamlPath, 1, 1, 1, 10);
            }));
        }
Пример #27
0
        private UnhandledExceptionAction WorkflowApplicationOnUnhandledException(WorkflowApplicationUnhandledExceptionEventArgs e)
        {
            var name = e.ExceptionSource.DisplayName;

            // {0} 执行时出现异常
            SharedObject.Instance.Output(SharedObject.enOutputType.Error, string.Format(ResxIF.GetString("ExceptionOccurredMessage"), name), e.UnhandledException.ToString());

            return(UnhandledExceptionAction.Terminate);
        }