protected void OnButtonOkClicked(object sender, EventArgs e) { if((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))){ this.Respond(Gtk.ResponseType.Ok); } lblStatus.LabelProp = "Sending..."; buttonOk.Sensitive = false; while (Gtk.Application.EventsPending ()) Gtk.Application.RunIteration (); string logFile =System.IO.Path.Combine(MainClass.Paths.SettingDir,"moscrif-ide.log"); Tool.Logger.Close(); LoggingInfo log = new LoggingInfo(); log.LoggWebFile (LoggingInfo.ActionId.IDECrush,logFile,LoginYesWrite,LoginNoWrite); //this.Respond(Gtk.ResponseType.Ok); //string log2 ="C:/moscrif-ide.log"; //string text = ""; /*try{ File.Copy(log,log2); } catch{ } this.Respond(Gtk.ResponseType.Ok);*/ /*using (StreamReader sr = new StreamReader(log)){ text = sr.ReadToEnd(); }*/ //throw new System.NotImplementedException (); }
protected void OnButtonOkClicked(object sender, EventArgs e) { string feedText = ""; switch (notb.Page){ case 0: feedText = feedbackIssue.GetData(); break; case 1: feedText = feedbackQuestion.GetData(); break; case 2: feedText = feedbackSuggestion.GetData(); break; } Console.WriteLine(feedText); if(MainClass.Settings.Account == null) Console.WriteLine("Account IS NULL"); if(String.IsNullOrEmpty(MainClass.Settings.Account.Token)) Console.WriteLine("Token IS NULL"); if((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_login_f1"),"", Gtk.MessageType.Error,this); md.ShowDialog(); Console.WriteLine("IS NULL"); return ; } buttonOk.Sensitive = false; if(string.IsNullOrEmpty(feedText)){ return; } lblStatus.LabelProp = "Sending..."; while (Gtk.Application.EventsPending ()) Gtk.Application.RunIteration (); LoggingInfo log = new LoggingInfo(); log.SendFeedback (feedText,LoginYesWrite,LoginNoWrite); //this.Respond(Gtk.ResponseType.Ok); }
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 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;*/ } }
public bool InicializeQuit() { LoggingInfo log = new LoggingInfo(); log.LoggWebThread(LoggingInfo.ActionId.IDEEnd); if( !CloseActualWorkspace()){ return false; } MainClass.Settings.SaveSettings(); if (this.EditorNotebook.NPages > 0) return true; MainClass.TaskServices.Stop(); if(Directory.Exists(MainClass.Paths.TempDir)){ try{ Directory.Delete(MainClass.Paths.TempDir,true); } catch{ Logger.Error("CANNOT DELETE TEMP DIR."); } } Moscrif.IDE.Tool.Logger.LogDebugInfo(String.Format("application.exi-{0}",DateTime.Now)); Console.WriteLine(String.Format("application.exit-{0}",DateTime.Now)); return true; }
public void ImportProject(string destinationFile, bool isZipFile) { if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){ NewWorkspaceDialog nwd = new NewWorkspaceDialog(false); int result = nwd.Run(); if (result == (int)ResponseType.Ok) { string workspaceName = nwd.WorkspaceName; string workspaceOutput = nwd.WorkspaceOutput; string workspaceRoot =nwd.WorkspaceRoot; bool copyLibs = nwd.CopyLibs; string workspaceFile = System.IO.Path.Combine(workspaceRoot, workspaceName + ".msw"); MainClass.MainWindow.CreateWorkspace(workspaceFile,workspaceName,workspaceOutput,workspaceRoot,copyLibs); } else { nwd.Destroy(); return ; } nwd.Destroy(); } if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)) return ; string fileName = System.IO.Path.GetFileNameWithoutExtension(destinationFile); string destinationDir = System.IO.Path.GetDirectoryName(destinationFile); // aka workspace from string projectDir = System.IO.Path.Combine(destinationDir,fileName); // aka project dir from if(isZipFile){ string tempDir = System.IO.Path.Combine(MainClass.Paths.TempDir,fileName); MainClass.Tools.UnzipFile(destinationFile,tempDir); destinationDir =tempDir; string[] fis1 = System.IO.Directory.GetFiles(destinationDir,"*.app",SearchOption.TopDirectoryOnly); if ((fis1 == null) || (fis1.Length<1)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_zip"), "", Gtk.MessageType.Error); md.ShowDialog(); return ; } fileName = System.IO.Path.GetFileNameWithoutExtension(fis1[0]); projectDir = System.IO.Path.Combine(destinationDir,fileName); } string[] fis = System.IO.Directory.GetFiles(destinationDir,fileName+".app",SearchOption.TopDirectoryOnly); string[] fisMsp = System.IO.Directory.GetFiles(destinationDir,fileName+".msp",SearchOption.TopDirectoryOnly); if ((fis == null) || (fis.Length<1)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_zip"), "", Gtk.MessageType.Error); md.ShowDialog(); return; } if(!System.IO.Directory.Exists(projectDir)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_project"), "", Gtk.MessageType.Error); md.ShowDialog(); return ; } string fileExistApp = System.IO.Path.GetFileNameWithoutExtension(fis[0]); string[] fiExist = Directory.GetFiles(MainClass.Workspace.RootDirectory,"*.app",SearchOption.TopDirectoryOnly); if((fiExist != null) || (fiExist.Length>0)){ List<string> existApp = new List<string>(fiExist); int findIndex = existApp.FindIndex(x=> System.IO.Path.GetFileNameWithoutExtension(x) == fileExistApp); if(findIndex>-1){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_exist"), "", Gtk.MessageType.Error); md.ShowDialog(); return ; } } string newApp = System.IO.Path.GetFileName(fis[0]); newApp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newApp); if(isZipFile){ // zkopirujem vsetko co bolo v zipe MainClass.Tools.CopyDirectory(destinationDir,MainClass.Workspace.RootDirectory,false,true); } else { // zkopirujem len veci k projektu app,msp a dir System.IO.File.Copy(fis[0],newApp); if( (fis != null) && (fisMsp.Length >0) && ( !string.IsNullOrEmpty(fisMsp[0]) )){ string newMsp = System.IO.Path.GetFileName(fisMsp[0]); newMsp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newMsp); System.IO.File.Copy(fisMsp[0],newMsp); } string newPrjDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,fileName); MainClass.Tools.CopyDirectory(projectDir,newPrjDir,true,true); } if (!System.IO.File.Exists(newApp) ){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("import_failed"), "", Gtk.MessageType.Error); md.ShowDialog(); //fc.Destroy(); return; } AppFile appFile= new AppFile(newApp); if( (fisMsp.Length <1) || ( string.IsNullOrEmpty(fisMsp[0]) )){ ConvertAppToProject(appFile); } else { string newMsp = System.IO.Path.GetFileName(fisMsp[0]); newMsp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newMsp); OpenProject(newMsp,true); } LoggingInfo log = new LoggingInfo(); log.LoggWebThread(LoggingInfo.ActionId.IDEImportProject,appFile.Name); SetActualProject(newApp); WorkspaceTree.SetSelectedFile(newApp); }
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(); } }
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); } }