protected static void sendProgress(int runed, PowerpointLoadInfo item) { String text = "Presentation : " + System.IO.Path.GetFileNameWithoutExtension(item.filePath) + " - Slide " + (item.slideIndex + 1) + " "; TransformationTreeRunInfo runInfo = new TransformationTreeRunInfo(); runInfo.errorMessage = text; runInfo.runedCount = stop ? LoopCount : runed; runInfo.totalCount = LoopCount; runInfo.runEnded = runInfo.runedCount == runInfo.totalCount; if (RunHandler != null) { System.Windows.Application.Current.Dispatcher.Invoke(() => RunHandler(runInfo), System.Windows.Threading.DispatcherPriority.Background); } }
public TransformationTreeRunInfo deserializeRunInfo(String json) { try { System.Web.Script.Serialization.JavaScriptSerializer Serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); Serializer.MaxJsonLength = int.MaxValue; TransformationTreeRunInfo runInfo = Serializer.Deserialize <TransformationTreeRunInfo>(json); return(runInfo); } catch (Exception e) { logger.Debug("Fail to deserialize runInfo!", e); } return(null); }
private void updateRunProgress(TransformationTreeRunInfo info) { if (info == null || info.runEnded == true) { GetCombineTransformationTreeService().TransformationTreeService.RunHandler -= updateRunProgress; GetCombineTransformationTreeService().TransformationTreeService.PowerpointHandler -= loadPowerpoint; Mask(false, RunMessageUtil.getMaskEndedText()); Service.FileService.SaveCurrentFile(); ApplicationManager.MainWindow.treeDetails.Visibility = Visibility.Hidden; ApplicationManager.MainWindow.ProgressBarTreeContent.Maximum = 0; ApplicationManager.MainWindow.ProgressBarTreeContent.Value = 0; ApplicationManager.MainWindow.statusTextBlockTreeContent.Content = ""; } else { int rate = info.totalCount != 0 ? (Int32)(info.runedCount * 100 / info.totalCount) : 0; if (rate > 100) { rate = 100; } ApplicationManager.MainWindow.ProgressBarTree.Maximum = info.totalCount; ApplicationManager.MainWindow.ProgressBarTree.Value = info.runedCount; ApplicationManager.MainWindow.statusTextBlockTree.Content = "" + rate + " % " + " (" + info.runedCount + " / " + info.totalCount + ")"; if (info.currentTreeRunInfo != null) { rate = info.currentTreeRunInfo.runedCount != 0 ? (Int32)(info.currentTreeRunInfo.runedCount * 100 / info.currentTreeRunInfo.totalCount) : 0; if (rate > 100) { rate = 100; } if (info.currentTreeRunInfo.runedCount != 0) { ApplicationManager.MainWindow.treeDetails.Visibility = Visibility.Visible; ApplicationManager.MainWindow.ProgressBarTreeContent.Maximum = info.currentTreeRunInfo.totalCount; ApplicationManager.MainWindow.ProgressBarTreeContent.Value = info.currentTreeRunInfo.runedCount; ApplicationManager.MainWindow.statusTextBlockTreeContent.Content = "" + info.currentTreeRunInfo.item + " : " + rate + " %" + " (" + info.currentTreeRunInfo.runedCount + " / " + info.currentTreeRunInfo.totalCount + ")"; } } } }
private void updateRunProgress(TransformationTreeRunInfo info) { if (info == null || info.runEnded == true) { Service.RunHandler -= updateRunProgress; Mask(false, getMaskEndedText()); Service.FileService.SaveCurrentFile(); loadTransformationTreesDialog.treeDetails.Visibility = Visibility.Hidden; loadTransformationTreesDialog.ProgressBarTreeContent.Maximum = 0; loadTransformationTreesDialog.ProgressBarTreeContent.Value = 0; loadTransformationTreesDialog.statusTextBlockTreeContent.Content = ""; loadTransformationTreesDialog.DisplayDatas(Service.getTransformationTreeBrowserDatas()); } else { int rate = info.totalCount != 0 ? (Int32)(info.runedCount * 100 / info.totalCount) : 0; if (rate > 100) { rate = 100; } loadTransformationTreesDialog.ProgressBarTree.Maximum = info.totalCount; loadTransformationTreesDialog.ProgressBarTree.Value = info.runedCount; loadTransformationTreesDialog.statusTextBlockTree.Content = "" + rate + " % " + " (" + info.runedCount + " / " + info.totalCount + ")"; if (info.currentTreeRunInfo != null) { rate = info.currentTreeRunInfo.runedCount != 0 ? (Int32)(info.currentTreeRunInfo.runedCount * 100 / info.currentTreeRunInfo.totalCount) : 0; if (rate > 100) { rate = 100; } if (info.currentTreeRunInfo.runedCount != 0) { loadTransformationTreesDialog.treeDetails.Visibility = Visibility.Visible; loadTransformationTreesDialog.ProgressBarTreeContent.Maximum = info.currentTreeRunInfo.totalCount; loadTransformationTreesDialog.ProgressBarTreeContent.Value = info.currentTreeRunInfo.runedCount; loadTransformationTreesDialog.statusTextBlockTreeContent.Content = "" + info.currentTreeRunInfo.item + " : " + rate + " %"; } } } }
private void updatePowerpointLoadProgress(TransformationTreeRunInfo info) { if (info == null || info.runEnded == true) { PowerpointLoader.RunHandler -= updatePowerpointLoadProgress; ApplicationManager.MainWindow.PowerpointProgressBarPanel.Visibility = Visibility.Hidden; } else { ApplicationManager.MainWindow.PowerpointProgressBarPanel.Visibility = Visibility.Visible; int rate = info.totalCount != 0 ? (Int32)(info.runedCount * 100 / info.totalCount) : 0; if (rate > 100) { rate = 100; } ApplicationManager.MainWindow.PowerpointProgressBar.Maximum = info.totalCount; ApplicationManager.MainWindow.PowerpointProgressBar.Value = info.runedCount; ApplicationManager.MainWindow.PowerpointProgressBarLabel.Content = info.errorMessage + " [" + rate + " %]"; } }
private void updateRunProgress(TransformationTreeRunInfo info) { if (info == null || info.runEnded == true) { GetTransformationTreeService().RunHandler -= updateRunProgress; GetTransformationTreeService().PowerpointHandler -= loadPowerpoint; Mask(false); } else { int rate = info.totalCount != 0 ? (Int32)(info.runedCount * 100 / info.totalCount) : 0; if (rate > 100) { rate = 100; } ApplicationManager.MainWindow.ProgressBarTree.Maximum = info.totalCount; ApplicationManager.MainWindow.ProgressBarTree.Value = info.runedCount; ApplicationManager.MainWindow.statusTextBlockTree.Content = "Tree running: " + rate + " %" + " (" + info.runedCount + "/" + info.totalCount + ")"; } }
public void Run(List <int> stringOids, bool isRunAllMode = false) { System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); serializer.MaxJsonLength = int.MaxValue; string socketHeader = "/run/" + (isRunAllMode ? "all/" : ""); Socket socket = buildSocket(SocketResourcePath + socketHeader); socket.OnMessage += (sender, e) => { PowerpointLoadInfo pptLoadInfo = deserializePowerpointLoadInfo(e.Data); if (pptLoadInfo != null && pptLoadInfo.action != null) { if (PowerpointHandler != null) { System.Windows.Application.Current.Dispatcher.Invoke(() => PowerpointHandler(pptLoadInfo)); } return; } LoopUserDialogTemplateData LoopTemplate = deserializeLoopTemplateData(e.Data); if (LoopTemplate != null) { System.Windows.Application.Current.Dispatcher.Invoke(() => { ProcessPopup dialog = new ProcessPopup(); dialog.Display(LoopTemplate); dialog.ShowDialog(); LoopTemplate = dialog.LoopUserTemplateData; string json = serializer.Serialize(LoopTemplate); socket.Send(json); }); return; } TransformationTreeRunInfo runInfo = deserializeRunInfo(e.Data); if (runInfo != null) { if (RunHandler != null) { System.Windows.Application.Current.Dispatcher.Invoke(() => RunHandler(runInfo)); } if (runInfo.runEnded) { socket.Close(CloseStatusCode.Normal); runSocket = null; } return; } }; socket.OnOpen += (sender, e) => { logger.Debug("Socket opened"); }; socket.OnError += (sender, e) => { logger.Debug("Socket error : " + e.Message); }; socket.OnClose += (sender, e) => { logger.Debug("Socket closed : " + e.Reason); runSocket = null; }; socket.Connect(); runSocket = socket; string text = serializer.Serialize(stringOids); socket.Send(text); }