private TaskMessage GetChild(string[] msg, int indx) { TaskMessage tmChild =new TaskMessage(); if (msg[indx].StartsWith("at")){ indx++; if (indx >= msg.Length) return null; string fname = msg[indx].Replace('/',System.IO.Path.DirectorySeparatorChar); tmChild.File = fname; indx ++; if (indx < msg.Length) { // line tam byt nemusi if (!msg[indx].StartsWith("at")) tmChild.Line = msg[indx]; else indx--; // ak tam line nieje (zacina na at) vratim index vratim index naspet indx++; if (indx >= msg.Length) return tmChild; tmChild.Child =GetChild(msg,indx); } } return tmChild; }
public void WriteTask_II(object sender, string name, string status,TaskMessage error) { List<TaskMessage> list = new List<TaskMessage>(); list.Add(error); WriteTask_II(sender, name, status, list, false); }
private void AppendChild(TreeIter parentIter, TaskMessage tm) { if ( tm != null){ outputModel.AppendValues(parentIter,System.IO.Path.GetFileName(tm.File), tm.Line, tm.Message, tm.File); if (tm.Child != null) AppendChild(parentIter,tm.Child); } /*if ( tm != null){ TreeIter ti = outputModel.AppendValues(parentIter,System.IO.Path.GetFileName(tm.File), tm.Line, tm.Message, tm.File); if (tm.Child != null) AppendChild(ti,tm.Child); }*/ }
void ExitPublish(object sender, EventArgs e) { if(lastMessage.Contains(MainClass.Languages.Translate("publishing_succesful"))){ devicePublishError = false; return; } else{ if (ErrorWrite!=null){ devicePublishError = true; //TaskMessage tm2 = new TaskMessage(lastMessage,"",""); TaskMessage tm =new TaskMessage(lastMessage.Trim(), "","" ); allErrors.AppendLine(lastMessage.Trim()); parentTask.Child = tm; if (ErrorWrite!=null){ ErrorWrite(this,this.Name,StateEnum.ERROR.ToString(),tm); this.stateTask = StateEnum.ERROR; } //ProcessErrorWrite(this,this.Name,this.StateTask.ToString(),tm2); } } }
private TaskMessage GetMessage(string message, string fileDir) { TaskMessage tm =new TaskMessage(); try{ messageError= messageError.Replace("Error:","" ); messageError =messageError.Replace("\t","»"); messageError =messageError.Replace("\n\r",""); messageError =messageError.Replace("\r\n",""); messageError =messageError.Replace("\n",""); messageError =messageError.Replace("\r",""); messageError= messageError.Replace("Compilation failed!","" ); //Console.WriteLine("messageError -> "+ messageError); string[] msg = messageError.Split('»'); //Console.WriteLine("match.Count -> "+ msg.Length); if (msg.Length <3){ //Tool.Logger.Error("message ->"+messageError+"<"); return null; } string error = msg[0]; string filename = msg[1]; string line =msg[2]; if (msg[1].StartsWith("at") ){ if (msg.Length <4){ //Tool.Logger.Error("message ->"+messageError+"<"); return null; } filename = msg[2]; line =msg[3]; } else{ filename = msg[1]; line =msg[2]; } filename = filename.Replace('/',System.IO.Path.DirectorySeparatorChar); if (!String.IsNullOrEmpty(fileDir) ){ filename=System.IO.Path.Combine(fileDir,filename); if(filename.EndsWith (".ms")){ string tmp = System.IO.Path.ChangeExtension(filename, ".msc"); if(File.Exists(tmp)){ try{ File.Delete(tmp); } catch{} } } } //Console.WriteLine("error -> "+ error); //Console.WriteLine("filename -> "+ filename); //Console.WriteLine("line -> "+ line); tm =new TaskMessage(error, filename, line); } catch { } return tm; }
// not use public void OnLogWrite(object sender, string name, string status, TaskMessage error) { if(LogWrite!= null) LogWrite(sender, name,status, error); }
private TaskMessage GetLog(string message) { string originalMessage = message; TaskMessage tm = new TaskMessage(); try{ //Log-I: Log-W: Log-E: message = message.Replace("LOG-I", ""); message = message.Replace("LOG-W", ""); message = message.Replace("LOG-E", ""); message = message.Replace("LOG-M", ""); message = message.Replace("LOG-GC", ""); message = message.Replace("\t", "»"); message = message.Replace("\n\r", ""); message = message.Replace("\r\n", ""); message = message.Replace("\n", ""); message = message.Replace("\r", ""); if (message.Contains("Log-GC:")) { Console.WriteLine("Log-GC: 1"); tm = new TaskMessage(originalMessage, "", ""); if (LogGarbageCollector != null) { Console.WriteLine("Log-GC: 2"); LogGarbageCollector(this, this.Name, this.StateTask.ToString(), tm); } this.stateTask = StateEnum.ERROR; messageError = null; return(tm); } //Console.WriteLine("messageError -> "+ message); string[] msg = message.Split('»'); //Console.WriteLine("match.Count -> "+ msg.Length); if (msg.Length < 3) { //Tool.Logger.Error("message ->"+message+"<"); return(null); } string filename = msg[0]; string line = msg[1]; string error = msg[2]; if (message.Contains("Log-M:")) { tm = new TaskMessage(error, line, filename); if (LogMonitor != null) { LogMonitor(this, this.Name, this.StateTask.ToString(), tm); } this.stateTask = StateEnum.ERROR; messageError = null; return(tm); } filename = filename.Replace('/', System.IO.Path.DirectorySeparatorChar); /*Console.WriteLine("error -> "+ error); * Console.WriteLine("filename -> "+ filename); * Console.WriteLine("line -> "+ line); * Console.WriteLine("this.Name -> "+ this.Name);*/ tm = new TaskMessage(error, filename, line); //this.output.Add(tm); this.stateTask = StateEnum.ERROR; messageError = null; if (filename.Contains("Log-E:")) { //Console.WriteLine("YES LOGE"); if (ErrorWrite != null) { TaskMessage tm2 = new TaskMessage(error, "", ""); //Console.WriteLine("YES ProcessErrorHandler"); ErrorWrite(this, this.Name, this.StateTask.ToString(), tm2); } } //else { if (LogWrite != null) { LogWrite(this, this.Name, this.StateTask.ToString(), tm); } //} } catch { } return(tm); }
public bool ExecuteTask() { if (MainClass.Workspace.ActualProject == null) { SetError(MainClass.Languages.Translate("no_project_selected")); return false; } project = MainClass.Workspace.ActualProject; if (String.IsNullOrEmpty(project.ProjectOutput)){ if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory)){ project.ProjectOutput = MainClass.Workspace.OutputDirectory; } else project.ProjectOutput = project.AbsolutProjectDir; } if(!Directory.Exists(project.OutputMaskToFullPath)){ try{ Directory.CreateDirectory(project.OutputMaskToFullPath); }catch { SetError(MainClass.Languages.Translate("cannot_create_output")); return false; } } stateTask = StateEnum.OK; //################ uvodne kontroly if (MainClass.MainWindow.RunningEmulator) { SetError(MainClass.Languages.Translate("emulator_is_running")); return false; } string cmd = Path.Combine(MainClass.Settings.EmulatorDirectory, "moscrif.exe"); if(MainClass.Platform.IsMac){ //Console.WriteLine("EmulatorDirectory --> {0}",MainClass.Settings.EmulatorDirectory); //cmd = "open";// + MainClass.Settings.EmulatorDirectory, "moscrif.app"); string file = System.IO.Path.Combine( MainClass.Settings.EmulatorDirectory, "Moscrif.app");//.app file = System.IO.Path.Combine(file, "Contents"); file = System.IO.Path.Combine(file, "MacOS"); file = System.IO.Path.Combine(file, "Moscrif"); cmd = file; Tool.Logger.LogDebugInfo(String.Format("command compile MAC ->{0}",cmd),null); } if(MainClass.Platform.IsWindows){ if (!System.IO.File.Exists(cmd)) { SetError(MainClass.Languages.Translate("emulator_not_found")); return false; } } string tempDir = MainClass.Paths.TempPublishDir;//System.IO.Path.Combine(MainClass.Settings.PublishDirectory,"_temp"); if (!Directory.Exists(tempDir)){ try{ Directory.CreateDirectory(tempDir); } catch{ SetError(MainClass.Languages.Translate("cannot_create_temp_f1")); return false; } } if ((listCombinePublish == null) || (listCombinePublish.Count <1)){ SetError(MainClass.Languages.Translate("publish_list_is_empty")); return false; //project.GeneratePublishCombination(); } bool cancelled = false; bool isAndroid = false; foreach(CombinePublish ccc in listCombinePublish){ CombineCondition crPlatform = ccc.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Platform.Id); if(crPlatform != null){ if ((crPlatform.RuleId == (int)DeviceType.Android_1_6)|| (crPlatform.RuleId == (int)DeviceType.Android_2_2)){ Console.WriteLine("ANDROID FOUND"); CheckJava(); } } } if(!isJavaInstaled && isAndroid){ MessageDialogsUrl md = new MessageDialogsUrl(MessageDialogsUrl.DialogButtonType.Ok,MainClass.Languages.Translate("java_missing"), MainClass.Languages.Translate("java_missing_title"),"http://moscrif.com/java-requirement", Gtk.MessageType.Error,ParentWindow); md.ShowDialog(); } project = MainClass.Workspace.ActualProject; if((MainClass.User == null) || (string.IsNullOrEmpty(MainClass.User.Token))){ SetError(MainClass.Languages.Translate("invalid_login")); return false; } //########################## kompilovanie progressDialog = new ProgressDialog(MainClass.Languages.Translate("compiling"),ProgressDialog.CancelButtonType.None,listCombinePublish.Count,ParentWindow);//MainClass.MainWindow //#################### kompilovanie try { List<string> list = new List<string>(); GetComands(project.AbsolutProjectDir, ref list,true); string[] libs = project.AppFile.Libs; foreach (string lib in libs){ if(string.IsNullOrEmpty(lib)) continue; string pathLib = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,lib); GetComands(pathLib, ref list,true); } if (list.Count > 0) { double step = 1 / (list.Count * 1.0); MainClass.MainWindow.ProgressStart(step, MainClass.Languages.Translate("compiling")); progressDialog.Reset(list.Count,MainClass.Languages.Translate("compiling")); } foreach (string f in list) { if (exitCompile) { // chyba koncim MainClass.MainWindow.ProgressEnd(); progressDialog.Destroy(); SetError(MainClass.Languages.Translate("compiling_failed")); return false; } string fileUpdate = FileUtility.AbsoluteToRelativePath(MainClass.Workspace.RootDirectory ,f); if ( project.FilesProperty != null){ FileItem fi = project.FilesProperty.Find(x => x.SystemFilePath == fileUpdate); if (fi != null) { if (fi.IsExcluded) continue; } } string fdir = System.IO.Path.GetDirectoryName(f); string fname = System.IO.Path.GetFileName(f); string args = String.Format("/d \"{0}\" /c {1} /o console", fdir, fname); if(MainClass.Platform.IsMac){ args = String.Format("-d {0} -c {1} -o console", fdir, fname); /*Process []pArry = Process.GetProcesses(); foreach(Process p in pArry) { if(p != null){ try { if(p.ProcessName == "Moscrif"){ p.Kill(); MainClass.MainWindow.RunningEmulator= false; } //string s = p.ProcessName; //s = s.ToLower(); //Console.WriteLine("\t"+s); } catch (Exception ex){ Console.WriteLine(ex.Message); } } }*/ } string a = args; //output.Add(new TaskMessage("args>>" + a)); ProcessService ps = new ProcessService(); MainClass.MainWindow.ProgressStep(); progressDialog.Update(f); ProcessWrapper pw = ps.StartProcess(cmd, a, fdir, ProcessOutputChange, ProcessOutputChange); pw.WaitForExit(); //pw.WaitForOutput(); pw.Exited += delegate(object sender, EventArgs e) { //Console.WriteLine("pw.Exited"); ParseOutput(MainClass.Languages.Translate("exit_compiling"),pw.StartInfo.WorkingDirectory); }; } } catch (Exception ex) { MainClass.MainWindow.ProgressEnd(); progressDialog.Destroy(); SetError(MainClass.Languages.Translate("compiling_failed"),ex.Message); return false; } finally { } if(stateTask != StateEnum.OK){ MainClass.MainWindow.ProgressEnd(); progressDialog.Destroy(); SetError(MainClass.Languages.Translate("compiling_failed")); return false; } //#################### regenerate app file, backup, hash parentTask = new TaskMessage("OK",MainClass.Languages.Translate("compiling"),null); output.Add(parentTask); List<string> filesList = new List<string>(); GetAllFiles(ref filesList,project.AbsolutProjectDir ); progressDialog.Reset(filesList.Count,MainClass.Languages.Translate("generate_app")); string bakAppPath =project.AbsolutAppFilePath+".bak"; string hashAppPath =project.AbsolutAppFilePath+".hash"; if(System.IO.File.Exists(bakAppPath)){ try{ File.Delete(bakAppPath); } catch { progressDialog.Destroy(); SetError(MainClass.Languages.Translate("cannot_create_backup")); return false; } } if(System.IO.File.Exists(hashAppPath)){ try{ File.Delete(hashAppPath); } catch { progressDialog.Destroy(); SetError(MainClass.Languages.Translate("cannot_create_hash")); return false; } } try{ File.Copy(project.AbsolutAppFilePath,bakAppPath); File.Copy(project.AbsolutAppFilePath,hashAppPath); } catch { progressDialog.Destroy(); SetError(MainClass.Languages.Translate("cannot_create_backup")); return false; } using (StreamWriter stream = File.AppendText(hashAppPath)) { stream.WriteLine(); foreach(string file in filesList){ if (System.IO.Path.GetExtension(file)==".ms") continue; string fileUpdate = FileUtility.AbsoluteToRelativePath(project.AbsolutProjectDir,file); fileUpdate = FileUtility.TrimStartingDotCharacter(fileUpdate); fileUpdate = FileUtility.TrimStartingDirectorySeparator(fileUpdate); /* stream.WriteLine("file : {0}",fileUpdate); string fileNameHash = Cryptographer.SHA1HashBase64(fileUpdate); stream.WriteLine("hash : {0}",fileNameHash); */ progressDialog.Update(MainClass.Languages.Translate("create_app")); using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read)) { int size = (int)fs.Length; byte[] data = new byte[size]; fs.Read(data, 0, size); fs.Close(); stream.WriteLine("file: {0}",fileUpdate); stream.WriteLine("hash: {0}", Cryptographer.SHA1HashBase64(data)); } } stream.Flush(); stream.Close(); stream.Dispose(); } //#################### podpisovanie progressDialog.Reset(0,MainClass.Languages.Translate("sign_app_f1")); progressDialog.SetLabel (MainClass.Languages.Translate("sign_app_f1") ); SignApp sa = new SignApp(); string newAppdata = ""; try{ if(!sa.PostFile(hashAppPath,MainClass.User.Token,out newAppdata)){ //timer.Stop(); progressDialog.Destroy(); RestoreBackup(hashAppPath,bakAppPath); //SetError(MainClass.Languages.Translate("expired_licence"),newAppdata); output.Add(new TaskMessage(newAppdata,MainClass.Languages.Translate("expired_licence"),null)); stateTask = StateEnum.ERROR; LicenceExpiredDialog md = new LicenceExpiredDialog(MainClass.Languages.Translate("expired_licence")); md.Run(); md.Destroy(); return false; } if(String.IsNullOrEmpty(newAppdata)){ //timer.Stop(); progressDialog.Destroy(); RestoreBackup(hashAppPath,bakAppPath); SetError(MainClass.Languages.Translate("sign_app_failed")); return false; } using (StreamWriter file = new StreamWriter(project.AbsolutAppFilePath)) { file.Write(newAppdata); file.Flush(); file.Close(); } }catch(Exception ex){ //timer.Stop(); progressDialog.Destroy(); SetError(MainClass.Languages.Translate("sign_app_failed"), ex.Message); //Console.WriteLine(ex.Message); RestoreBackup(hashAppPath,bakAppPath); return false; } //timer.Stop(); parentTask = new TaskMessage("OK",MainClass.Languages.Translate("sign"),null); output.Add(parentTask); //#################### publish //if (listCombinePublish.Count > 0) { //List<CombinePublish> lst =project.CombinePublish.FindAll(x=>x.IsSelected==true); double step2 = 1 / (listCombinePublish.Count * 1.0); MainClass.MainWindow.ProgressStart(step2, MainClass.Languages.Translate("publish")); //progressDialog = new ProgressDialog(MainClass.Languages.Translate("publishing"),ProgressDialog.CancelButtonType.Cancel,listCombinePublish.Count,MainClass.MainWindow); progressDialog.Reset(listCombinePublish.Count,MainClass.Languages.Translate("publishing")); //} foreach(CombinePublish ccc in listCombinePublish){//listCC ){ //if (!ccc.IsSelected) continue; //Console.WriteLine(ccc.ToString()); if (cancelled) break; if(String.IsNullOrEmpty(project.ProjectArtefac) ){ project.ProjectArtefac = System.IO.Path.GetFileNameWithoutExtension(project.RelativeAppFilePath); } string fileName = project.ProjectArtefac; List<ConditionDevice> condList = new List<ConditionDevice>(); foreach(CombineCondition cr in ccc.combineRule){ ConditionDevice cd = new ConditionDevice (cr.ConditionName,cr.RuleName); //condList.Add(new ConditionDevice(cr.ConditionName,cr.RuleName)); if(cr.ConditionId == MainClass.Settings.Resolution.Id){ Rule rl = MainClass.Settings.Resolution.Rules.Find(x=>x.Id == cr.RuleId); if(rl!= null){ cd.Height = rl.Height; cd.Width = rl.Width; } } condList.Add(cd); fileName = fileName.Replace(String.Format("$({0})",cr.ConditionName),cr.RuleName); } parentTask = new TaskMessage(MainClass.Languages.Translate("publishing"),fileName,null); devicePublishError = false; if (progressDialog != null) progressDialog.SetLabel (fileName ); if (Directory.Exists(tempDir)) { try{ DirectoryInfo di = new DirectoryInfo(tempDir); foreach (DirectoryInfo d in di.GetDirectories()){ d.Delete(true); } foreach (FileInfo f in di.GetFiles()){ f.Delete(); } } catch { } } CombineCondition crPlatform = ccc.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Platform.Id); CombineCondition crRsolution = ccc.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Resolution.Id); if (crPlatform == null) { SetError(MainClass.Languages.Translate("platform_not_found", MainClass.Settings.Platform.Name), parentTask); continue; } Device dvc = project.DevicesSettings.Find(x=>x.TargetPlatformId == crPlatform.RuleId); if (dvc == null) { SetError(MainClass.Languages.Translate("device_not_found", crPlatform.ConditionName, crPlatform.RuleName), parentTask); continue; } //if ((crPlatform.RuleId == (int)DeviceType.Android_1_6) && (!isJavaInstaled)){ if (((crPlatform.RuleId == (int)DeviceType.Android_1_6) || (crPlatform.RuleId == (int)DeviceType.Android_2_2)) && (!isJavaInstaled)){ SetError(MainClass.Languages.Translate("java_missing"), parentTask); continue; } string dirPublish = MainClass.Tools.GetPublishDirectory(dvc.Platform.Specific);//System.IO.Path.Combine(MainClass.Settings.PublishDirectory,dvc.Platform.Specific);//crPlatform.RuleName); if (!Directory.Exists(dirPublish)){ SetError(MainClass.Languages.Translate("publish_tool_not_found"), parentTask); continue; } if (String.IsNullOrEmpty(dirPublish)) { SetError(MainClass.Languages.Translate("publish_tool_not_found_f1"), parentTask); continue; } dvc.Application = project.AppFile.Name; if (String.IsNullOrEmpty(project.ProjectOutput)){ if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory)){ project.ProjectOutput = MainClass.Workspace.OutputDirectory; } else project.ProjectOutput = project.AbsolutProjectDir; } dvc.Output_Dir = project.OutputMaskToFullPath; dvc.Temp = tempDir; dvc.Temp = LastSeparator(dvc.Temp); dvc.Publish = LastSeparator(MainClass.Settings.PublishDirectory); dvc.Root = LastSeparator(MainClass.Workspace.RootDirectory); dvc.Output_Dir = LastSeparator(dvc.Output_Dir); dvc.Conditions =condList.ToArray(); List<int> mergeResolutions = new List<int>(); string resolution = crRsolution.RuleName; mergeResolutions.Add(crRsolution.RuleId); // Ak je zaskrtnute Merge All Resolution // Najdem vsetky publishovatelne combinacie danej platformy (napr. vsetky publishovane andrroidy) // a vytiahnem z nich rezolution a spojim do do string odeleneho & if(dvc.Includes.Skin != null){ dvc.Includes.Skin.ResolutionJson = dvc.Includes.Skin.Resolution; if(!String.IsNullOrEmpty(dvc.Includes.Skin.Name)){ if(project.IncludeAllResolution){ resolution = ""; foreach(CombinePublish cp in listCombinePublish){ CombineCondition crPlatform2 = cp.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Platform.Id && x.RuleId== crPlatform.RuleId); if(crPlatform2 != null){ CombineCondition crResolution2 = cp.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Resolution.Id ); if(crResolution2!= null){ resolution =resolution+crResolution2.RuleName+"&"; } } } resolution = resolution.Remove(resolution.Length - 1, 1); ConditionDevice cd = condList.Find(x=>x.Name == MainClass.Settings.Resolution.Name); if(cd != null){ cd.Value = resolution; dvc.Conditions =condList.ToArray(); } } } } List<string> filesForPublish = new List<string>(); foreach(string file in filesList){ //if (System.IO.Path.GetExtension(file)==".msc") continue; if (System.IO.Path.GetExtension(file)==".ms") continue; string checkFile =file; if (System.IO.Path.GetExtension(file)==".msc") checkFile = System.IO.Path.ChangeExtension(file,".ms"); string fileUpdate = FileUtility.AbsoluteToRelativePath(MainClass.Workspace.RootDirectory ,checkFile); if ( project.FilesProperty != null){ // vyhldam property suborov a pozriem ci nemam nejake conditiony nastavene FileItem fi = project.FilesProperty.Find(x => x.SystemFilePath == fileUpdate); if (fi != null) { if (fi.IsExcluded) continue; if(fi.ConditionValues == null)continue; foreach(CombineCondition cr in ccc.combineRule){ ConditionRule conRile = fi.ConditionValues.Find(x=>x.ConditionId == cr.ConditionId); if (conRile != null){ //if ((conRile.RuleId != cr.RuleId)) // subor ma condition daneho typu, ale nastavenu na inu hodnotu //goto nav; int resolutionId = -1; if(conRile.ConditionId == MainClass.Settings.Resolution.Id){ resolutionId=mergeResolutions.FindIndex(x=>x == conRile.RuleId); //continue; } // mam merge resolution a subor patri do niektoreho mergnuteho resolution if((conRile.ConditionId == MainClass.Settings.Resolution.Id) && (resolutionId>-1)){ goto nav1; } // subor ma condition daneho typu, ale nastavenu na inu hodnotu if ((conRile.RuleId != cr.RuleId)){ goto nav; } } } } } nav1: fileUpdate = FileUtility.AbsoluteToRelativePath(project.AbsolutProjectDir,file); fileUpdate = FileUtility.TrimStartingDotCharacter(fileUpdate); fileUpdate = FileUtility.TrimStartingDirectorySeparator(fileUpdate); filesForPublish.Add(fileUpdate); nav:; } dvc.Includes.Files = filesForPublish.ToArray(); dvc.Output_Name = fileName; dvc.PublishPropertisFull = new List<PublishProperty>(); foreach(PublishProperty pp in dvc.PublishPropertisMask){ PublishProperty ppFull = new PublishProperty(pp.PublishName); ppFull.PublishValue = project.ConvertProjectMaskPathToFull(pp.PublishValue); dvc.PublishPropertisFull.Add(ppFull); } /*if(dvc.Includes.Skin != null){ dvc.Includes.Skin.ResolutionJson = dvc.Includes.Skin.Resolution; if(!String.IsNullOrEmpty(dvc.Includes.Skin.Name)){ if(project.IncludeAllResolution){ dvc.Includes.Skin.ResolutionJson = "*"; } } }*/ //dvc.Includes.Files dvc.LogDebug = MainClass.Settings.LogPublish; dvc.ApplicationType = project.ApplicationType; dvc.FacebookAppID = project.FacebookAppID; if(String.IsNullOrEmpty(project.FacebookAppID)) dvc.FacebookAppID =""; string path = System.IO.Path.Combine(dirPublish,"settings.mso");//fileName+".mso"); //dvc.TargetPlatform + "_settings.mso"); string json = dvc.GenerateJson();//GenerateJson(dvc); if(String.IsNullOrEmpty(json)){ SetError(MainClass.Languages.Translate("cannot_generate_mso"),parentTask); continue; } try { using (StreamWriter file = new StreamWriter(path)) { file.Write(json); file.Close(); } } catch { SetError(MainClass.Languages.Translate("cannot_generate_mso"), parentTask); //isPublishError = true; continue; } //var platformRule = MainClass.Settings.Platform.Rules.Find(x => x.Id == dvc.TargetPlatformId); string appFile =dvc.Platform.Specific+ ".app"; /*dvc.TargetPlatform*///platformRule.Specific + ".app"; string fullAppPath = System.IO.Path.Combine(MainClass.Settings.PublishDirectory,appFile); if (!System.IO.File.Exists(fullAppPath) ){ SetError(MainClass.Languages.Translate("publish_tool_not_found_f2"), parentTask); continue; } RunPublishTool(appFile,parentTask); if(MainClass.Platform.IsMac){ ExitPublish(null,null); } if(devicePublishError){ allPublishError = true; parentTask.Message =MainClass.Languages.Translate("publish_error"); //Console.WriteLine(parentTask.Child.Message); output.Add(parentTask); stateTask = StateEnum.ERROR; } else{ parentTask.Message = MainClass.Languages.Translate("publish_successfully_done"); output.Add(parentTask); } /*if (RunPublishTool(appFile,parentTask) ){ parentTask.Message =MainClass.Languages.Translate("publish_successfully_done"); output.Add(parentTask); //output.Add(new TaskMessage(MainClass.Languages.Translate("publish_successfully_done"),dvc.Platform.Specific,null)); } else { parentTask.Message =MainClass.Languages.Translate("publish_error"); Console.WriteLine(parentTask.Child.Message); output.Add(parentTask); stateTask = StateEnum.ERROR; isPublishError = true; //output.Add(new TaskMessage(MainClass.Languages.Translate("publish_error"),dvc.Platform.Specific,null)); }*/ MainClass.MainWindow.ProgressStep(); if (progressDialog != null) cancelled = progressDialog.Update (fileName ); } MainClass.MainWindow.ProgressEnd(); if (progressDialog != null){ progressDialog.Destroy(); } RestoreBackup(hashAppPath,bakAppPath); if(allPublishError){ this.stateTask = StateEnum.ERROR; string s = allErrors.ToString(); if(s.Length > 120){ s = s.Substring(0,120); s= s+ " ... and more."; } ShowError(MainClass.Languages.Translate("publish_error"), s); return false; } else { this.stateTask = StateEnum.OK; ShowInfo(MainClass.Languages.Translate("publish_successfully_done"), ""); if(MainClass.Settings.OpenOutputAfterPublish){ if (!String.IsNullOrEmpty(project.ProjectOutput)){ MainClass.Tools.OpenFolder(project.OutputMaskToFullPath); } } return true; } /*if(this.stateTask == StateEnum.ERROR){ string s = allErrors.ToString(); if(s.Length > 120){ s = s.Substring(0,120); s= s+ " ... and more."; } ShowError(MainClass.Languages.Translate("publish_error"), s); return false; } else { ShowInfo(MainClass.Languages.Translate("publish_successfully_done"), ""); if(MainClass.Settings.OpenOutputAfterPublish){ if (!String.IsNullOrEmpty(project.ProjectOutput)){ MainClass.Tools.OpenFolder(project.OutputMaskToFullPath); } } return true; }*/ }
private void SetChildError(string error,TaskMessage tm) { allErrors.AppendLine(error); tm.Child =new TaskMessage(error); this.stateTask = StateEnum.ERROR; allPublishError = true; }
private TaskMessage GetMessage(string message) { if(String.IsNullOrEmpty(message)) return null; TaskMessage tm =new TaskMessage(); try{ message= message.Replace("Compilation failed!","" ); message =message.Replace("\t","»"); message =message.Replace("\n\r",""); message =message.Replace("\r\n",""); message =message.Replace("\n",""); message =message.Replace("\r",""); string[] msg = message.Split('»'); if (msg.Length <3){ //Tool.Logger.Error("message ->"+message+"<"); return null; } string error = msg[0]; string line =msg[2]; if (msg[1].StartsWith("at") ){ //filename = msg[2]; if (msg.Length <4){ //Tool.Logger.Error("message ->"+message+"<"); return null; } line =msg[3]; } else{ //filename = msg[1]; line =msg[2]; } string filename = pd.Filepath; tm =new TaskMessage(error, filename, line); } catch (Exception ex){ //Tool.Logger.Error("message ->"+message+"<"); Tool.Logger.Error(ex.Message); Tool.Logger.Error(ex.StackTrace); Tool.Logger.Error(ex.Source); //throw ex; return null; } return tm; }
public bool ExecuteTask() { output.Clear(); List<TaskMessage> listOfTask = new List<TaskMessage>(); int filesCount = 0; if(searchPatern.OpenFiles != null ) filesCount +=searchPatern.OpenFiles.Count; if(searchPatern.CloseFiles != null ) filesCount +=searchPatern.CloseFiles.Count; double step = 1 / (filesCount * 1.0); MainClass.MainWindow.ProgressStart(step, MainClass.Languages.Translate("searching")); foreach (string file in searchPatern.OpenFiles){ MainClass.MainWindow.ProgressStepInvoke(); IEditor editor = MainClass.MainWindow.EditorNotebook.FindEditor(file); if(editor!= null){ List<FindResult> table = editor.FindReplaceAll(searchPatern); if(table == null) continue; foreach (FindResult pair in table) { TaskMessage tm =new TaskMessage(pair.Value.ToString(), file, pair.Key.ToString()); listOfTask.Add(tm); } } } foreach (string file in searchPatern.CloseFiles){ MainClass.MainWindow.ProgressStepInvoke(); string replaceExpression = searchPatern.ReplaceExpresion == null ? null : searchPatern.ReplaceExpresion.ToString(); List<FindResult> table = Tool.FileUtility.FindInFile(file, searchPatern.Expresion.ToString(),searchPatern.CaseSensitive,searchPatern.WholeWorlds,replaceExpression); if (table == null) continue; foreach (FindResult pair in table) { TaskMessage tm =new TaskMessage(pair.Value.ToString(), file, pair.Key.ToString()); listOfTask.Add(tm); } } if(EndTaskWrite != null){ EndTaskWrite(this,this.Name,this.StateTask.ToString(),listOfTask); } return true; }
public void GcTaskWritte(object sender, string name, string status, TaskMessage error) { Gtk.Application.Invoke(delegate{ this.LogGarbageCollector.WriteTask_II(sender, name, status, error); garbageColectorLabel.SetLabel(MainClass.Languages.Translate("garbage_collector",this.LogGarbageCollector.CountItem+1)); }); }
public void ErrorTaskWritte(object sender, string name, string status, TaskMessage error) { Gtk.Application.Invoke(delegate{ this.ErrorOutput.WriteTask_II(sender, name, status, error); if (MainClass.Settings.ShowErrorPane) TaskNotebook.CurrentPage = 1; }); }
public void MonitorTaskWritte(object sender, string name, string status, TaskMessage error) { Gtk.Application.Invoke(delegate{ this.LogMonitor.WriteTask_II(sender, name, status, error); }); }
private TaskMessage GetError(string message) { TaskMessage tm =new TaskMessage(); if(String.IsNullOrEmpty(message)) return null; try{ //Console.WriteLine("message_1->"+message+"<-"); //Log-I: Log-W: Log-E: message= message.Replace("Error:","" ); message =message.Replace("\t","»"); message =message.Replace("\n\r",""); message =message.Replace("\r\n",""); message =message.Replace("\n",""); message =message.Replace("\r",""); //Console.WriteLine("messageError -> "+ message); //Console.WriteLine("message_1->"+message+"<-"); string[] msg = message.Split('»'); //Console.WriteLine("match.Count -> "+ msg.Length); if (msg.Length <3){ //Tool.Logger.Error("message ->"+message+"<"); return null; } /*foreach(string m in msg){ Console.WriteLine(m); }*/ //Console.WriteLine("msg.Length ->"+msg.Length); string error = msg[0]; string filename = msg[1]; string line =msg[2]; if (msg[1].StartsWith("at") ){ if (msg.Length <4){ //Tool.Logger.Error("message ->"+message+"<"); return null; } filename = msg[2]; line =msg[3]; //int indx = 4; // spracovanie dalsich vetiev (kazda zacina na at) if (msg.Length >4) tm.Child = GetChild(msg,4); } else{ filename = msg[1]; line =msg[2]; } filename = filename.Replace('/',System.IO.Path.DirectorySeparatorChar); //Console.WriteLine("error -> "+ error); //Console.WriteLine("filename -> "+ filename); //Console.WriteLine("line -> "+ line); //tm =new TaskMessage(error, filename, line); tm.Message = error; tm.Line = line; tm.File = filename; this.output.Add(tm); this.stateTask = StateEnum.ERROR; messageError = null; if (ErrorWrite!=null){ ErrorWrite(this,this.Name,this.StateTask.ToString(),tm); } } catch { } return tm; }
private void SetError(string error,TaskMessage tm) { tm.Message =error; allErrors.AppendLine(error); output.Add(tm); this.stateTask = StateEnum.ERROR; allPublishError = true; }
private TaskMessage GetLog(string message) { TaskMessage tm =new TaskMessage(); try{ //Log-I: Log-W: Log-E: message= message.Replace("LOG-I","" ); message= message.Replace("LOG-W","" ); message= message.Replace("LOG-E","" ); message =message.Replace("\t","»"); message =message.Replace("\n\r",""); message =message.Replace("\r\n",""); message =message.Replace("\n",""); message =message.Replace("\r",""); //Console.WriteLine("messageError -> "+ message); string[] msg = message.Split('»'); //Console.WriteLine("match.Count -> "+ msg.Length); if (msg.Length <3){ //Tool.Logger.Error("message ->"+message+"<"); return null; } string filename= msg[0]; string line= msg[1]; string error=msg[2]; filename = filename.Replace('/',System.IO.Path.DirectorySeparatorChar); //Console.WriteLine("error -> "+ error); //Console.WriteLine("filename -> "+ filename); //Console.WriteLine("line -> "+ line); tm =new TaskMessage(error, filename, line); //this.output.Add(tm); this.stateTask = StateEnum.ERROR; messageError = null; if(filename.Contains("Log-E:")){ //Console.WriteLine("YES LOGE"); if (ErrorWrite!=null){ TaskMessage tm2 = new TaskMessage(error,"",""); Console.WriteLine("YES ProcessErrorWrite"); ErrorWrite(this,this.Name,this.StateTask.ToString(),tm2); } } //else { if (LogWrite!=null){ LogWrite(this,this.Name,this.StateTask.ToString(),tm); } //} } catch { } return tm; }
public bool RunPublishTool(string appFile,TaskMessage parentTask) { //if (MainClass.Settings.ClearConsoleBeforRuning) // MainClass.MainWindow.OutputConsole.Clear(); if(MainClass.MainWindow.RunningEmulator){ //output.Add( new TaskMessage(MainClass.Languages.Translate("emulator_is_running"),null,null)); stateTask = StateEnum.ERROR; parentTask.Child =new TaskMessage(MainClass.Languages.Translate("emulator_is_running"),null,null); return false; } string cmd = Path.Combine(MainClass.Settings.EmulatorDirectory, "moscrif.exe"); if(MainClass.Platform.IsMac){ //Console.WriteLine("EmulatorDirectory --> {0}",MainClass.Settings.EmulatorDirectory); //cmd = "open";// + MainClass.Settings.EmulatorDirectory, "moscrif.app"); string file = System.IO.Path.Combine( MainClass.Settings.EmulatorDirectory, "Moscrif.app");//.app file = System.IO.Path.Combine(file, "Contents"); file = System.IO.Path.Combine(file, "MacOS"); file = System.IO.Path.Combine(file, "Moscrif"); cmd = file; Tool.Logger.LogDebugInfo(String.Format("command MAC ->{0}",cmd),null); } if (MainClass.Platform.IsWindows){ if (!System.IO.File.Exists(cmd)) { SetError(MainClass.Languages.Translate("emulator_not_found")); return false; } } string args = String.Format("/o console /w nowindow /t nowarm /d {0} /f {1}",MainClass.Settings.PublishDirectory+System.IO.Path.DirectorySeparatorChar, appFile); if(MainClass.Platform.IsMac){ args = String.Format("-o console -w nowindow -t nowarm -d {0} -f {1} ", MainClass.Settings.PublishDirectory+System.IO.Path.DirectorySeparatorChar, appFile); } try{ MainClass.MainWindow.RunProcessWait(cmd, args, MainClass.Settings.EmulatorDirectory,ProcessOutputPublishChange,ExitPublish); }catch (Exception ex){ //output.Add(new TaskMessage(ex.Message)); parentTask.Child =new TaskMessage(ex.Message); stateTask = StateEnum.ERROR; //isPublishError = true; return false; } return true; }
public bool ExecuteTask() { string regEx = @"//\s*?{0}\s*:.*|/\*\n?\s*?\n?\s*?{0}\s*:.*\n?\s*?\*/|"; string[] expres = new string[]{"TODO","FIX","FIXME","HACK","HACKME","WARN","WARNING"}; string regExpresion =""; foreach (string str in expres){ regExpresion = regExpresion+String.Format(regEx,str); } regExpresion=regExpresion.Remove(regExpresion.Length-1,1); //Console.WriteLine("regExpresion - > {0}",regExpresion); if(project == null) return false; output.Clear(); List<string> files = new List<string>(); project.GetAllFiles(ref files,project.AbsolutProjectDir,".ms",true); //project.GetAllFiles(ref files,project.AbsolutProjectDir,".ms"); //if(MainClass.MainWindow.EditorNotebook == null) return false; List<string> openFiles = MainClass.MainWindow.EditorNotebook.OpenFiles; foreach (string file in openFiles){ if(System.IO.Path.GetExtension(file)==".ms"){ int indx = files.FindIndex(x=> x== file); if(indx <0){ files.Add(file); } } } List<TaskMessage> listOfTask = new List<TaskMessage>(); foreach (string file in files){ MatchCollection mc = Tool.FileUtility.FindInFileRegEx(file,regExpresion); if (mc == null){ //Console.WriteLine("mc null"); continue; } //MatchCollection mc = Tool.FileUtility.FindInFile(file,@"(//\s*?(TODO)|(FIX)|(FIXME).*)|(/\*\s*?TODO.*\*/)"); for(int i=0; i<mc.Count;i++){ //Console.WriteLine("file {0} --> {1}",file,mc[i].Index); TaskMessage tm =new TaskMessage(mc[i].Value, file, mc[i].Index.ToString()); listOfTask.Add(tm); } } if(EndTaskWrite != null){ EndTaskWrite(this,this.Name,this.StateTask.ToString(),listOfTask); } //MainClass.MainWindow.OutputConsole.WriteText("message"); //ProcessWrapper pw =MainClass.ProcessService.StartProcess("cmd.exe","/c dir *.*", MainClass.Tools.AppPath, ProcessOutputChange, ProcessErrorChange); //MainClass.MainWindow.RunProcess("cmd.exe", "/c dir *.*", MainClass.Tools.TempDir); //Console.WriteLine("teST TASk BEZI"); //stateTask = StateEnum.ERROR; return true; }
private TaskMessage GetError(string message) { TaskMessage tm = new TaskMessage(); if (String.IsNullOrEmpty(message)) { return(null); } try{ //Console.WriteLine("message_1->"+message+"<-"); //Log-I: Log-W: Log-E: message = message.Replace("Error:", ""); message = message.Replace("\t", "»"); message = message.Replace("\n\r", ""); message = message.Replace("\r\n", ""); message = message.Replace("\n", ""); message = message.Replace("\r", ""); //Console.WriteLine("messageError -> "+ message); //Console.WriteLine("message_1->"+message+"<-"); string[] msg = message.Split('»'); //Console.WriteLine("match.Count -> "+ msg.Length); if (msg.Length < 3) { //Tool.Logger.Error("message ->"+message+"<"); return(null); } /*foreach(string m in msg){ * Console.WriteLine(m); * }*/ //Console.WriteLine("msg.Length ->"+msg.Length); string error = msg[0]; string filename = msg[1]; string line = msg[2]; if (msg[1].StartsWith("at")) { if (msg.Length < 4) { //Tool.Logger.Error("message ->"+message+"<"); return(null); } filename = msg[2]; line = msg[3]; //int indx = 4; // spracovanie dalsich vetiev (kazda zacina na at) if (msg.Length > 4) { tm.Child = GetChild(msg, 4); } } else { filename = msg[1]; line = msg[2]; } filename = filename.Replace('/', System.IO.Path.DirectorySeparatorChar); //Console.WriteLine("error -> "+ error); //Console.WriteLine("filename -> "+ filename); //Console.WriteLine("line -> "+ line); //tm =new TaskMessage(error, filename, line); tm.Message = error; tm.Line = line; tm.File = filename; this.output.Add(tm); this.stateTask = StateEnum.ERROR; messageError = null; if (ErrorWrite != null) { ErrorWrite(this, this.Name, this.StateTask.ToString(), tm); } } catch { } return(tm); }