Esempio n. 1
0
        public bool Save()
        {
            //appFile.Orientation = cbOrientation.ActiveText;
            try{
                FillAppFile();
                appFile.Save();
            } catch (Exception ex) {
                MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error);
                ms.ShowDialog();
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        private Project ImportProject(string appPath, string projectName, string newLibs, string newOrientation)
        {
            //TreeIter ti =  AddMessage("Create Project ","....",null);
            if (entrPage2PrjName.Text == prjDefaultName)
            {
                MainClass.Settings.ProjectCount = MainClass.Settings.ProjectCount + 1;
            }

            string oldName = System.IO.Path.GetFileNameWithoutExtension(appPath);

            if (String.IsNullOrEmpty(MainClass.Workspace.FilePath))
            {
                return(null);
            }

            string destinationDir = System.IO.Path.GetDirectoryName(appPath);             // aka workspace from
            string projectDir     = System.IO.Path.Combine(destinationDir, oldName);      // aka project dir from

            string mspPath = System.IO.Path.Combine(destinationDir, oldName + ".msp");

            if (!File.Exists(appPath) || !File.Exists(mspPath))
            {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"), MainClass.Languages.Translate("invalid_zip"), null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("invalid_zip"));
                return(null);
            }
            if (!System.IO.Directory.Exists(projectDir))
            {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"), MainClass.Languages.Translate("invalid_project"), null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("invalid_project"));
                return(null);
            }

            string newApp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, projectName + ".app");
            string newMsp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, projectName + ".msp");

            if (File.Exists(newApp) || File.Exists(newMsp))
            {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"), MainClass.Languages.Translate("project_exist"), null);

                //UpdateMessage(ti,1,MainClass.Languages.Translate("project_exist"));
                return(null);
            }

            FileInfo     fi = new FileInfo(appPath);
            FileTemplate ft = new FileTemplate(fi, false);

            atrApplication.Value = projectName;
            ft.Attributes.Add(atrApplication);

            string contentApp = FileTemplateUtilities.Apply(ft.Content, ft.GetAttributesAsDictionary());

            string contentMsp = "";

            if (System.IO.File.Exists(mspPath))
            {
                try {
                    using (StreamReader file = new StreamReader(mspPath)) {
                        string text = file.ReadToEnd();
                        contentMsp = text;
                    }
                } catch {
                }
            }
            contentMsp = Regex.Replace(contentMsp, oldName, System.IO.Path.GetFileNameWithoutExtension(newApp));

            Project prj = null;

            try {
                FileUtility.CreateFile(newApp, contentApp);
                AppFile app = null;
                if (!String.IsNullOrEmpty(newLibs))
                {
                    app             = new AppFile(newApp);
                    app.Uses        = newLibs;
                    app.Orientation = newOrientation;
                    app.Save();
                }

                FileUtility.CreateFile(newMsp, contentMsp);

                string newPrjDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, projectName);

                TreeIter ti = AddMessage(MainClass.Languages.Translate("wizzard_copying"), "....", null);

                MainClass.Tools.CopyDirectory(projectDir, newPrjDir, true, true);
                //string[] dirNew = System.IO.Directory.GetDirectories(newPrjDir,"*.*",SearchOption.AllDirectories);

                string[] filesNew = System.IO.Directory.GetFiles(newPrjDir, "*.ms", SearchOption.AllDirectories);
                foreach (string file in filesNew)
                {
                    FileInfo     fiNew = new FileInfo(file);
                    FileTemplate ftNew = new FileTemplate(fiNew, false);
                    atrApplication.Value = projectName;
                    ftNew.Attributes.Add(atrApplication);

                    string contentNew = FileTemplateUtilities.Apply(ftNew.Content, ftNew.GetAttributesAsDictionary());

                    try{
                        using (StreamWriter fileSW = new StreamWriter(file)) {
                            fileSW.Write(contentNew);
                            fileSW.Close();
                            fileSW.Dispose();
                        }
                    }catch (Exception ex) {
                        Tool.Logger.Error(ex.Message);
                        continue;
                    }
                }
                UpdateMessage(ti, 1, "OK");

                prj = MainClass.Workspace.OpenProject(newMsp, false, true);               //Project.OpenProject(newMsp,false,true);

                LoggingInfo log = new LoggingInfo();
                log.LoggWebThread(LoggingInfo.ActionId.IDENewProject, prj.ProjectName);
            } catch {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"), MainClass.Languages.Translate("error_creating_project"), null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("error_creating_project"));
                return(null);
            }
            AddMessage(MainClass.Languages.Translate("wizzard_create_project"), "OK", null);
            //UpdateMessage(ti,1,"OK");
            return(prj);
        }
Esempio n. 3
0
        private void RunPublishTask(List <CombinePublish> list)
        {
            LoggingInfo log = new LoggingInfo();

            log.LoggWebThread(LoggingInfo.ActionId.IDEPublish, project.ProjectName);

            int selectTyp = (int)ddbTypPublish.CurrentItem;

            if ((selectTyp == 0) || (!MainClass.Workspace.SignApp))
            {
                tlpublish           = new TaskList();
                tlpublish.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>();

                string selectRemote = (string)ddbTypRemote.CurrentItem;
                Console.WriteLine("selectRemote-" + selectRemote);
                if (selectRemote != "0")
                {
                    AppFile appF = MainClass.Workspace.ActualProject.AppFile;
                    appF.Remote_Console = selectRemote + ":" + MainClass.Settings.SocetServerPort;
                    appF.Save();
                    Console.WriteLine("MainClass.Workspace.ActualProject.AppFile.Remote_Console-" + MainClass.Workspace.ActualProject.AppFile.Remote_Console);
                }
                else
                {
                    AppFile appF = MainClass.Workspace.ActualProject.AppFile;
                    appF.Remote_Console = "";
                    appF.Save();
                }

                PublishAsynchronTask pt = new PublishAsynchronTask();
                pt.ParentWindow  = this;
                pt.EndTaskWrite += MainClass.MainWindow.EndTaskWritte;

                pt.EndTaskWrite += delegate(object sender, string name, string status, List <TaskMessage> errors) {
                    runningPublish  = false;
                    btnCancel.Label = "_Close";
                    if (selectRemote != "0")
                    {
                        AppFile appF = MainClass.Workspace.ActualProject.AppFile;
                        appF.Remote_Console = "";
                        appF.Save();
                    }
                };

                pt.ErrorWrite += MainClass.MainWindow.ErrorTaskWritte;
                pt.LogWrite   += MainClass.MainWindow.LogTaskWritte;
                pt.WriteStep  += delegate(object sender, StepEventArgs e) {
                    storeOutput.AppendValues(e.Message1, e.Message2, null, e.IsError);

                    if (status != 1)
                    {
                        status = e.Status;
                    }
                    while (Gtk.Application.EventsPending())
                    {
                        Gtk.Application.RunIteration();
                    }
                };
                pt.Initialize(list);

                tlpublish.TasksList.Add(pt);

                secondTaskThread              = new Thread(new ThreadStart(tlpublish.ExecuteTaskOnlineWrite));
                secondTaskThread.Name         = "Publish Second Task";
                secondTaskThread.IsBackground = true;
                runningPublish  = true;
                btnCancel.Label = "_Cancel";
                secondTaskThread.Start();
            }
            else
            {
                tlpublish           = new TaskList();
                tlpublish.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>();

                SignPublishAsynchronTask pt = new SignPublishAsynchronTask();
                pt.ParentWindow  = this;
                pt.EndTaskWrite += MainClass.MainWindow.EndTaskWritte;
                pt.EndTaskWrite += delegate(object sender, string name, string status, List <TaskMessage> errors) {
                    runningPublish  = false;
                    btnCancel.Label = "_Close";
                };
                pt.ErrorWrite += MainClass.MainWindow.ErrorTaskWritte;
                pt.LogWrite   += MainClass.MainWindow.LogTaskWritte;
                pt.WriteStep  += delegate(object sender, StepEventArgs e) {
                    storeOutput.AppendValues(e.Message1, e.Message2, null, e.IsError);
                    if (status != 1)
                    {
                        status = e.Status;
                    }
                    while (Gtk.Application.EventsPending())
                    {
                        Gtk.Application.RunIteration();
                    }
                };
                pt.Initialize(list);

                tlpublish.TasksList.Add(pt);

                secondTaskThread              = new Thread(new ThreadStart(tlpublish.ExecuteTaskOnlineWrite));
                secondTaskThread.Name         = "Publish Second Task";
                secondTaskThread.IsBackground = true;
                runningPublish  = true;
                btnCancel.Label = "_Cancel";
                secondTaskThread.Start();
            }
        }