Exemple #1
0
        public void CleaAllAllocation()
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            serializer.MaxJsonLength = int.MaxValue;
            Socket socket = buildSocket(ClearAllSocketResourcePath);

            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); };

            socket.OnMessage += (sender, e) =>
            {
                AllocationRunInfo runInfo = deserializeRunInfo(e.Data);
                if (runInfo != null)
                {
                    if (this.ClearAllocationTableHandler != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(() => ClearAllocationTableHandler(runInfo));
                    }
                    if (runInfo.runEnded)
                    {
                        socket.Close(CloseStatusCode.Normal);
                    }
                    return;
                }
            };

            socket.Connect();
            socket.Send("Clear all allocatins");
        }
        /// <summary>
        /// Demande au serveur d'exécuter toutes les allocations.
        /// </summary>
        /// <returns></returns>
        public virtual AllocationRunInfo RunTables(System.Collections.IList tables)
        {
            try
            {
                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                var request = new RestRequest(ResourcePath + "/run_tables", Method.POST);

                request.RequestFormat    = DataFormat.Json;
                serializer.MaxJsonLength = int.MaxValue;
                string json = serializer.Serialize(tables);
                request.AddParameter("application/json", json, ParameterType.RequestBody);
                var response = RestClient.ExecuteTaskAsync(request);
                try
                {
                    AllocationRunInfo info = RestSharp.SimpleJson.DeserializeObject <AllocationRunInfo>(response.Result.Content);
                    return(info);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                throw new BcephalException("Unable to run tables", e);
            }
        }
        /// <summary>
        /// Demande au serveur d'exécuter le rapport
        /// </summary>
        /// <param name="oid"> L'identifiant de la table</param>
        /// <returns>La table</returns>
        ///


        public virtual void Run(StructuredReportRunData data)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            serializer.MaxJsonLength = int.MaxValue;
            Socket socket = buildSocket(SocketResourcePath + "/structured/run/");

            socket.OnMessage += (sender, e) =>
            {
                AllocationRunInfo 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);
                    }
                    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); };

            socket.Connect();
            string text = serializer.Serialize(data);

            socket.Send(text);
        }
        public void RunTable(int oid)
        {
            CreateAndShowDialog();
            AllocationRunInfo runInfo = Service.RunAll(oid);

            allocationRunDialog.RunInfo = runInfo;
            CreateAndStartDispatcherTimer();
        }
        protected virtual void OnTimerTick(object sender, EventArgs e)
        {
            AllocationRunInfo runInfo = Service.GetRunInfo(allocationRunDialog.RunInfo.currentPage);

            allocationRunDialog.UpdateGrid(runInfo);
            if (runInfo == null || runInfo.runEnded == true)
            {
                runTimer.Stop();
                allocationRunDialog.CloseButton.IsEnabled   = true;
                ApplicationManager.Instance.AllocationCount = this.Service.FileService.GetAllocationCount();
                Service.FileService.SaveCurrentFile();
            }
        }
 public AllocationRunInfo deserializeRunInfo(String json)
 {
     try
     {
         System.Web.Script.Serialization.JavaScriptSerializer Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
         Serializer.MaxJsonLength = int.MaxValue;
         AllocationRunInfo runInfo = Serializer.Deserialize <AllocationRunInfo>(json);
         //if (runInfo == null || runInfo.runedCellCount == 0) return null;
         return(runInfo);
     }
     catch (Exception e)
     {
         logger.Debug("Fail to deserialize runInfo!", e);
     }
     return(null);
 }
        private void updateRunProgress(AllocationRunInfo runInfo)
        {
            if (runInfo == null || runInfo.runEnded == true)
            {
                this.ApplicationManager.AllocationCount = this.Service.FileService.GetAllocationCount();
                Service.RunAllocationTableHandler      -= updateRunProgress;
                Service.FileService.SaveCurrentFile();
                Kernel.Util.MessageDisplayer.DisplayInfo("Load Tables", "Load Tables ended!");
                Mask(false);
                ApplicationManager.MainWindow.treeDetails.Visibility             = Visibility.Hidden;
                ApplicationManager.MainWindow.ProgressBarTreeContent.Maximum     = 0;
                ApplicationManager.MainWindow.ProgressBarTreeContent.Value       = 0;
                ApplicationManager.MainWindow.statusTextBlockTreeContent.Content = "";
            }
            else
            {
                int rate = runInfo.totalCellCount != 0 ? (Int32)(runInfo.runedCellCount * 100 / runInfo.totalCellCount) : 0;
                if (rate > 100)
                {
                    rate = 100;
                }
                ApplicationManager.MainWindow.ProgressBarTree.Maximum     = runInfo.totalCellCount;
                ApplicationManager.MainWindow.ProgressBarTree.Value       = runInfo.runedCellCount;
                ApplicationManager.MainWindow.statusTextBlockTree.Content = "Tables loading: " + rate + " %"
                                                                            + " (" + runInfo.runedCellCount + "/" + runInfo.totalCellCount + ")";

                if (runInfo.currentInfo != null)
                {
                    rate = runInfo.currentInfo.totalCellCount != 0 ? (Int32)(runInfo.currentInfo.runedCellCount * 100 / runInfo.currentInfo.totalCellCount) : 0;
                    if (rate > 100)
                    {
                        rate = 100;
                    }

                    if (runInfo.currentInfo.runedCellCount != 0)
                    {
                        ApplicationManager.MainWindow.treeDetails.Visibility             = Visibility.Visible;
                        ApplicationManager.MainWindow.ProgressBarTreeContent.Maximum     = runInfo.currentInfo.totalCellCount;
                        ApplicationManager.MainWindow.ProgressBarTreeContent.Value       = runInfo.currentInfo.runedCellCount;
                        ApplicationManager.MainWindow.statusTextBlockTreeContent.Content = runInfo.currentInfo.tableName + ": " + rate + " %"
                                                                                           + " (" + runInfo.currentInfo.runedCellCount + "/" + runInfo.currentInfo.totalCellCount + ")";
                    }
                }
            }
        }
Exemple #8
0
 private void updateClearProgress(AllocationRunInfo runInfo)
 {
     if (runInfo == null || runInfo.runEnded == true)
     {
         GetTransformationTreeService().ClearTreeHandler -= updateClearProgress;
         this.ApplicationManager.AllocationCount          = this.Service.FileService.GetAllocationCount();
         Service.FileService.SaveCurrentFile();
         Mask(false);
     }
     else
     {
         int rate = runInfo.totalCellCount != 0 ? (Int32)(runInfo.runedCellCount * 100 / runInfo.totalCellCount) : 0;
         if (rate > 100)
         {
             rate = 100;
         }
         ApplicationManager.MainWindow.ProgressBarTree.Maximum     = runInfo.totalCellCount;
         ApplicationManager.MainWindow.ProgressBarTree.Value       = runInfo.runedCellCount;
         ApplicationManager.MainWindow.statusTextBlockTree.Content = "" + rate + " %";
     }
 }
 /// <summary>
 /// Demande au serveur d'exécuter toutes les allocations.
 /// </summary>
 /// <returns></returns>
 public virtual AllocationRunInfo RunAll()
 {
     try
     {
         var request  = new RestRequest(ResourcePath + "/run_all", Method.POST);
         var response = RestClient.ExecuteTaskAsync(request);
         try
         {
             AllocationRunInfo info = RestSharp.SimpleJson.DeserializeObject <AllocationRunInfo>(response.Result.Content);
             return(info);
         }
         catch (Exception)
         {
             return(null);
         }
     }
     catch (Exception e)
     {
         throw new BcephalException("Unable to run all allocations", e);
     }
 }
 /// <summary>
 /// Demande au serveur d'exécuter l'allocation de toutes les cellules de la table..
 /// </summary>
 /// <param name="oid"> L'identifiant de la table</param>
 /// <returns>La table</returns>
 public virtual AllocationRunInfo RunAll(int oid)
 {
     try
     {
         var request = new RestRequest(ResourcePath + "/runall/" + oid, Method.POST);
         request.DateFormat = "dd/MM/yyyy";
         var response = RestClient.ExecuteTaskAsync(request);
         try
         {
             AllocationRunInfo info = RestSharp.SimpleJson.DeserializeObject <AllocationRunInfo>(response.Result.Content);
             return(info);
         }
         catch (Exception)
         {
             return(null);
         }
     }
     catch (Exception e)
     {
         throw new BcephalException("Unable to Return Input table identified by: " + oid, e);
     }
 }
        private void updateRunProgress(AllocationRunInfo info)
        {
            StructuredReportEditorItem page = (StructuredReportEditorItem)getStructuredReportEditor().getActivePage();

            if (info == null || info.runEnded == true)
            {
                GetStructuredReportService().RunHandler -= updateRunProgress;
                page.IsModify = true;
                nextRunData = null;
                OnChange();
                Mask(false);
            }
            else
            {
                int rate = info.totalCellCount != 0 ? (Int32)(info.runedCellCount * 100 / info.totalCellCount) : 0;
                if (rate > 100) rate = 100;

                ApplicationManager.MainWindow.LoadingProgressBar.Maximum = info.totalCellCount;
                ApplicationManager.MainWindow.LoadingProgressBar.Value = info.runedCellCount;
                ApplicationManager.MainWindow.LoadingLabel.Content = "" + rate + " %";
            }
        }
Exemple #12
0
        private void updateRunProgress(AllocationRunInfo info)
        {
            ReportEditorItem page = (ReportEditorItem)getInputTableEditor().getActivePage();

            if (info != null)
            {
                throwSheetWritting = false;
                page.getInputTableForm().SpreadSheet.ThrowEvent = false;
                foreach (CellAllocationRunInfoBrowserData data in info.infos)
                {
                    page.getReportForm().SpreadSheet.SetValueAt(data.row, data.column,
                                                                data.sheet, data.loadedAmount);
                }
                page.getInputTableForm().SpreadSheet.ThrowEvent = true;
                throwSheetWritting = true;
            }

            if (info == null || info.runEnded == true)
            {
                GetReportService().RunAllocationTableHandler -= updateRunProgress;
                page.IsModify     = true;
                nextRunActionData = null;
                OnChange();
                Mask(false);
            }
            else
            {
                int rate = info.totalCellCount != 0 ? (Int32)(info.runedCellCount * 100 / info.totalCellCount) : 0;
                if (rate > 100)
                {
                    rate = 100;
                }

                ApplicationManager.MainWindow.LoadingProgressBar.Maximum = info.totalCellCount;
                ApplicationManager.MainWindow.LoadingProgressBar.Value   = info.runedCellCount;
                ApplicationManager.MainWindow.LoadingLabel.Content       = "Running Report : " + rate + " %" + " (" + info.runedCellCount + "/" + info.totalCellCount + ")";
            }
        }
Exemple #13
0
 public void UpdateGrid(AllocationRunInfo info)
 {
     if (RunInfo == null)
     {
         RunInfo = info;
         return;
     }
     if (info == null)
     {
         return;
     }
     //if (info.runEnded) return;
     RunInfo.errorMessage   = info.errorMessage;
     RunInfo.isError        = info.isError;
     RunInfo.runedCellCount = info.runedCellCount;
     RunInfo.runEnded       = info.runEnded;
     RunInfo.totalCellCount = info.totalCellCount;
     //List<CellAllocationRunInfoBrowserData> infos = new List<CellAllocationRunInfoBrowserData>(RunInfo.infos);
     //infos.AddRange(info.infos);
     //RunInfo.infos = infos;
     UpdateGrid();
     UpdatePagination();
 }
        private void updateRunProgress(AllocationRunInfo info)
        {
            InputGridEditorItem page = (InputGridEditorItem)getInputGridEditor().getActivePage();

            if (info == null || info.runEnded == true)
            {
                page.IsModify = true;
                OnChange();
                Mask(false);
            }
            else
            {
                int rate = info.totalCellCount != 0 ? (Int32)(info.runedCellCount * 100 / info.totalCellCount) : 0;
                if (rate > 100)
                {
                    rate = 100;
                }

                ApplicationManager.MainWindow.LoadingProgressBar.Maximum = info.totalCellCount;
                ApplicationManager.MainWindow.LoadingProgressBar.Value   = info.runedCellCount;
                ApplicationManager.MainWindow.LoadingLabel.Content       = "" + rate + " %";
            }
        }
        private void updateProgressBar(AllocationRunInfo runInfo)
        {
            if (runInfo == null || runInfo.runEnded == true)
            {
                runTimer.Stop();

                this.ApplicationManager.MainWindow.StatusBarLabel2.Content = "";
                this.ApplicationManager.MainWindow.SetPogressBar2Visible(false);
                Kernel.Util.MessageDisplayer.DisplayInfo("Clear grid/table", "Clear grid/table ended!");
                this.ApplicationManager.AllocationCount = this.Service.FileService.GetAllocationCount();
                Service.FileService.SaveCurrentFile();
            }
            else
            {
                int rate = runInfo.totalCellCount != 0 ? (Int32)(runInfo.runedCellCount * 100 / runInfo.totalCellCount) : 0;
                if (rate > 100)
                {
                    rate = 100;
                }
                this.ApplicationManager.MainWindow.StatusBarLabel2.Content = rate == 100 ? "Clear grid/table ended!" : "Clear grid/table...";
                this.ApplicationManager.MainWindow.UpdatePogressBar2(runInfo.runedCellCount, runInfo.totalCellCount, "" + rate + " %");
            }
        }
 private void updateClearAllocationProgress(AllocationRunInfo runInfo)
 {
     if (runInfo == null || runInfo.runEnded == true)
     {
         Service.ClearAllocationTableHandler    -= updateClearAllocationProgress;
         this.ApplicationManager.AllocationCount = this.Service.FileService.GetAllocationCount();
         Service.FileService.SaveCurrentFile();
         Kernel.Util.MessageDisplayer.DisplayInfo("Clear allocation", "Clear allocation ended!");
         runWindow.DisplayDatas(this.Service);
         Mask(false);
     }
     else
     {
         int rate = runInfo.totalCellCount != 0 ? (Int32)(runInfo.runedCellCount * 100 / runInfo.totalCellCount) : 0;
         if (rate > 100)
         {
             rate = 100;
         }
         ApplicationManager.MainWindow.LoadingProgressBar.Maximum = runInfo.totalCellCount;
         ApplicationManager.MainWindow.LoadingProgressBar.Value   = runInfo.runedCellCount;
         ApplicationManager.MainWindow.LoadingLabel.Content       = "Grids/Tables clearing: " + rate + " %"
                                                                    + " (" + runInfo.runedCellCount + "/" + runInfo.totalCellCount + ")";
     }
 }
Exemple #17
0
 private void closeButton_Click(object sender, RoutedEventArgs e)
 {
     runInfo = null;
     this.Close();
 }
        protected virtual void OnClearTimerTick(object sender, EventArgs e)
        {
            AllocationRunInfo runInfo = Service.GetClearInfo();

            updateProgressBar(runInfo);
        }