示例#1
0
        protected override void Compile(SingleChoiceActionExecuteEventArgs e)
        {
            var ca             = (CompileAction)e.SelectedChoiceActionItem.Data;
            var compile        = ca == CompileAction.开始暂停 || ca == CompileAction.编译 || ca == CompileAction.编译运行;
            var run            = ca != CompileAction.编译;
            var compileSuccess = true;

            if (compile)
            {
                var outputFullPath = Path.Combine(CurrentProject.ProjectPath, CurrentProject.Name, CurrentProject.Name + ".dll");
                var os             = Application.CreateObjectSpace();
                var workspace      = SmartIDEWorkspace.GetIDE(os, CurrentProject);
                var rst            = workspace.Compile(outputFullPath);
                if (rst != null)
                {
                    if (!rst.Success)
                    {
                        var solution = new Solution();
                        solution.Code = new CsharpCode("", null);
                        solution.Code.ShowSolutionFiles = true;
                        solution.Code.Workspace         = workspace;
                        solution.Code.Diagnostics       = rst.Diagnostics.ToList();
                        var view = Application.CreateDetailView(os, solution);
                        e.ShowViewParameters.CreatedView  = view;
                        e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
                        compileSuccess = false;
                    }
                    else
                    {
                        Application.ShowViewStrategy.ShowMessage("编译通过!");
                    }
                }
            }

            if (run && compileSuccess)
            {
                var msg = new MessageOptions();
                msg.Message    = "准备启动客户端:" + CurrentProject.WinStartupFile;
                msg.OkDelegate = () =>
                {
                    var fi = new FileInfo(CurrentProject.WinStartupFile);
                    Process.Start(fi.DirectoryName);
                };
                Application.ShowViewStrategy.ShowMessage(msg);
                var para = "";
                if (ca == CompileAction.开始暂停)
                {
                    para = " -debug";
                }
                var pc = Process.Start(CurrentProject.WinStartupFile, para);
                pc.Exited += (s, evt) =>
                {
                    Application.ShowViewStrategy.ShowMessage("退出代码:" + pc.ExitCode);
                };
            }
        }
示例#2
0
        private void Compile(SimpleActionExecuteEventArgs e, bool showCode)
        {
            var os        = Application.CreateObjectSpace();
            var workspace = SmartIDEWorkspace.GetIDE(os);
            var rst       = workspace.Compile();

            if (rst != null)
            {
                if (!rst.Success || showCode)
                {
                    var solution = new Solution();
                    solution.Code = new SYS.Logic.CsharpCode("", null);
                    solution.Code.ShowSolutionFiles = true;
                    solution.Code.Workspace         = workspace;
                    solution.Code.Diagnostics       = rst.Diagnostics.ToList();
                    var view = Application.CreateDetailView(os, solution);
                    e.ShowViewParameters.CreatedView  = view;
                    e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
                }
                else
                {
                    var runtimeModule = os.FindObject <BusinessModule>(new BinaryOperator("ModuleName", "RuntimeModule.dll"));
                    if (runtimeModule == null)
                    {
                        runtimeModule             = os.CreateObject <BusinessModule>();
                        runtimeModule.Description = "用户定义的模块";
                    }

                    using (var stream = File.OpenRead(AdmiralEnvironment.UserDefineBusinessTempFile.FullName))
                    {
                        runtimeModule.File = new DevExpress.Persistent.BaseImpl.FileData(runtimeModule.Session);
                        runtimeModule.File.LoadFromStream(AdmiralEnvironment.UserDefineBusinessTempFile.Name, stream);
                        runtimeModule.Save();
                        os.CommitChanges();
                    }


                    var moduleInfo = os.FindObject <ModuleInfo>(new BinaryOperator("Name", "RuntimeModule"));
                    if (moduleInfo != null)
                    {
                        os.Delete(moduleInfo);
                        os.CommitChanges();
                    }
                    var restart = Application as IRestartApplication;
                    if (restart != null)
                    {
                        restart.RestartApplication();
                    }
                }
            }
        }
        private void simpleAction1_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            var ide = new SmartIDEWorkspace(this.ObjectSpace);

            ide.Compile();
        }