private void RunPublishTask(List <CombinePublish> list) { LoggingInfo log = new LoggingInfo(); log.LoggWebThread(LoggingInfo.ActionId.IDEEnd, project.ProjectName); if ((!MainClass.Workspace.SignApp)) { TaskList tlpublish = new TaskList(); tlpublish.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>(); PublishTask pt = new PublishTask(); pt.ParentWindow = this; pt.Initialize(list); tlpublish.TasksList.Add(pt); MainClass.MainWindow.RunTaskList(tlpublish, true); } else { if (MainClass.User == null) { LoginRegisterDialog ld = new LoginRegisterDialog(this); int res = ld.Run(); if (res == (int)Gtk.ResponseType.Cancel) { ld.Destroy(); return; } ld.Destroy(); } TaskList tl = new TaskList(); tl.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>(); SignPublishTask ct = new SignPublishTask(); ct.Initialize(list); ct.ParentWindow = this; tl.TasksList.Add(ct); MainClass.MainWindow.RunTaskList(tl, false); } }
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); }
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(); } }
public static void Main(string[] args) { //foreach(string str in args) // Logger.Log("arg ->{0}",str); Application.Init(); Logger.Log(Languages.Translate("start_app")); ExceptionManager.UnhandledException += delegate(UnhandledExceptionArgs argsum) { StringBuilder sb = new StringBuilder(); Exception ex = (Exception)argsum.ExceptionObject; sb.AppendLine(ex.Message); sb.AppendLine(ex.StackTrace); Logger.Error(ex.Message); Logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); if (ex.InnerException != null) { Logger.Error(ex.InnerException.Message); Logger.Error(ex.InnerException.StackTrace); Logger.Error(ex.InnerException.Source); Console.WriteLine(ex.InnerException.Message); Console.WriteLine(ex.InnerException.StackTrace); Console.WriteLine(ex.InnerException.Source); sb.AppendLine(ex.InnerException.Message); sb.AppendLine(ex.InnerException.StackTrace); sb.AppendLine(ex.InnerException.Source); } ErrorDialog ed = new ErrorDialog(); ed.ErrorMessage = sb.ToString(); ed.Run(); ed.Destroy(); argsum.ExitApplication = true; }; Gdk.Global.InitCheck(ref args); if (Platform.IsWindows) { string themePath = Paths.DefaultTheme; if (System.IO.File.Exists(themePath)) { Gtk.Rc.AddDefaultFile(themePath); Gtk.Rc.Parse(themePath); } } mainWindow = new MainWindow(args); MainWindow.Show(); if ((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))) { LoginRegisterDialog ld = new LoginRegisterDialog(null); ld.Run(); ld.Destroy(); } else { LoggingInfo log = new LoggingInfo(); log.LoggWebThread(LoggingInfo.ActionId.IDEStart); } if (!String.IsNullOrEmpty(Paths.TempDir)) { Application.Run(); } }
public Project CreateProject(string filename, string projectName, string projectLocation, string projectDir, string aplicationFile, string skin, string theme) { Project p = FindProject(filename); if (p == null) { p = new Project(); if (!System.IO.File.Exists(filename)) { string projectWorkingDir = System.IO.Path.Combine(projectLocation, projectDir); if (!System.IO.File.Exists(aplicationFile)) { AppFile appFile = new AppFile(aplicationFile, projectName); //, projectDir); appFile.Uses = "core ui uix uix-skin media sqlite net game2d crypto box2d graphics sensor"; appFile.Main = "main.ms"; appFile.Author = "Generated by Moscrif-Ide"; appFile.Title = projectName; appFile.Copyright = " "; appFile.Version = "1.0"; appFile.Orientation = "portrait"; try{ appFile.Save(); } catch (Exception ex) { throw new Exception(MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile) + "\n" + ex.Message); /*MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error); * ms.ShowDialog(); * return null;*/ } } string mainFile = System.IO.Path.Combine(projectWorkingDir, "main.ms"); try { Directory.CreateDirectory(projectWorkingDir); using (StreamWriter file = new StreamWriter(mainFile)) { file.Write("// TODO: Add your code here."); file.Close(); file.Dispose(); } //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "core")); //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "ui")); } catch { } p = new Project(filename); //p.ProjectDir = GetRelativePath(projectWorkingDir); //p.ProjectName = projectName; p.AppFilePath = GetRelativePath(aplicationFile); p.StartFile = GetRelativePath(mainFile); p.NewSkin = true; p.GenerateDevices(skin, theme); SaveProject(p); Projects.Add(p); ProjectsFile.Add(GetRelativePath(filename)); LoggingInfo log = new LoggingInfo(); log.LoggWebThread(LoggingInfo.ActionId.IDENewProject, p.ProjectName); return(p); } else { throw new Exception(MainClass.Languages.Translate("project_is_exist", filename)); /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_exist",filename), "", Gtk.MessageType.Error); * md.ShowDialog(); * return null;*/ } } else { throw new Exception(MainClass.Languages.Translate("project_is_opened", p.ProjectName)); /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened",p.ProjectName), null, Gtk.MessageType.Error); * md.ShowDialog(); * return null;*/ } }