private void SetValue(CodeActivityContext context)
        {
            this.localSourceTable = InputTable.Get(context);

            this.localNullValue = NullValue.Get(context);

            if (this.localSourceTable == null)
            {
                throw new Exception("Input table is null");
            }

            this.localGroupbyColumn = GroupbyColumns.Get(context);

            this.localAggregateColumn = AggregateColumn.Get(context);

            this.localAggregateBy = AggregateBy.ToString();

            if (AggregateType.ToString() == "Integer")
            {
                this.localAggregateColumnType = System.Type.GetType("System.Int64");
            }
            else
            {
                this.localAggregateColumnType = System.Type.GetType("System." + AggregateType.ToString());
            }
        }
Beispiel #2
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                table        = InputTable.Get(context);
                strCondition = Select.Get(context);

                if (table != null && table.Rows.Count > 0 && !string.IsNullOrEmpty(strCondition))
                {
                    filterRows = table.Select(strCondition).ToList();

                    if (filterRows != null && filterRows.Count > 0)
                    {
                        for (int intRow = 0; intRow < filterRows.Count; intRow++)
                        {
                            table.Rows.Remove(filterRows[intRow]);
                        }
                    }
                }

                Result.Set(context, table);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public bool SaveReport()
        {
            if (this.ReportEditorController == null)
            {
                return(true);
            }
            foreach (ReportEditorItem page in this.ReportEditorController.getEditor().getAllPages())
            {
                if (page.EditedObject != null)
                {
                    Parameter parameter = new Parameter(page.EditedObject.name);
                    parameter.setTransformationTree(1);
                    InputTable table = this.ReportEditorController.GetInputTableService().parametrizeTable(parameter);
                }
            }
            this.ReportEditorController.GetInputTableService().SaveTableHandler += UpdateSaveInfo;
            Boolean isModify = this.ReportEditorController.IsModify;

            if (isModify)
            {
                this.ReportEditorController.Save();
            }
            else if (SaveEndedEventHandler != null)
            {
                SaveEndedEventHandler(true);
            }
            return(true);
        }
Beispiel #4
0
        public InputTable getInputTableByName(string inputTableName, ObservableCollection <Kernel.Domain.Browser.InputTableBrowserData> listeCurrent)
        {
            if (listeCurrent != null && listeCurrent.Count > 0)
            {
                listeCurrent.ToList().AddRange(this.liste);
            }
            else
            {
                listeCurrent = this.liste;
            }

            InputTable table = new InputTable();

            foreach (object obj in listeCurrent)
            {
                if (obj is InputTable)
                {
                    table.name = ((InputTable)obj).name;
                    table.oid  = ((InputTable)obj).oid;
                }
                else if (obj is InputTableBrowserData)
                {
                    table.name = ((InputTableBrowserData)obj).name;
                    table.oid  = ((InputTableBrowserData)obj).oid;
                }
                if (table.name.ToUpper() == inputTableName.ToUpper())
                {
                    return(table);
                }
            }
            return(null);
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="table"></param>
        public void displayTable(InputTable table, bool isNoAllocation = false, bool readOnly = false)
        {
            if (table == null)
            {
                return;
            }
            thowEvent                           = false;
            nameTextBox.Text                    = table.name;
            groupField.Group                    = table.group;
            activeCheckBox.IsChecked            = table.active;
            templateCheckBox.IsChecked          = table.template;
            visibleInShortcutCheckBox.IsChecked = table.visibleInShortcut;

            if (reportPeriodPanel != null)
            {
                this.reportPeriodPanel.DisplayPeriod(table.period, true, readOnly);
            }
            else
            {
                periodPanel.DisplayPeriod(table.period, true, readOnly);
            }

            filterScopePanel.DisplayScope(table.correctFilter(), isNoAllocation, readOnly);
            thowEvent = true;
        }
        /// <summary>
        /// For table parametrization
        /// </summary>
        /// <param name="tableName">Table that contains the cellproperty</param>
        /// <param name="range">the cellproperties range</param>
        /// <param name="cellparams">the cell params {Measure, Target,Tag,Period}</param>
        /// <returns>true=> cells well parametrized ; false => no parametrization done.</returns>
        public InputTable parametrizeTable(Kernel.Domain.Parameter parameter)
        {
            try
            {
                if (parameter == null)
                {
                    return(null);
                }
                var request = new RestRequest(ResourcePath + "/parametrize/table/", Method.POST);
                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

                request.RequestFormat    = DataFormat.Json;
                serializer.MaxJsonLength = int.MaxValue;

                string json = serializer.Serialize(parameter);
                request.AddParameter("application/json", json, ParameterType.RequestBody);

                var          response    = RestClient.ExecuteTaskAsync(request);
                RestResponse queryResult = (RestResponse)response.Result;

                bool valid = ValidateResponse(queryResult);
                System.Web.Script.Serialization.JavaScriptSerializer Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

                Serializer.MaxJsonLength = int.MaxValue;
                InputTable result = Serializer.Deserialize <InputTable>(queryResult.Content);
                return(result);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
                throw new BcephalException("Unable to parametrize cell ", e);
            }
        }
        public virtual bool renameTable(String newName, InputTable table)
        {
            try
            {
                var request = new RestRequest(ResourcePath + "/rename/table/" + newName, Method.POST);

                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                serializer.MaxJsonLength = int.MaxValue;

                string json = serializer.Serialize(table);
                request.AddParameter("application/json", json, ParameterType.RequestBody);

                var response = RestClient.ExecuteTaskAsync(request);
                try
                {
                    bool result = RestSharp.SimpleJson.DeserializeObject <bool>(response.Result.Content);
                    return(result);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                throw new BcephalException("Unable to close table : " + newName, e);
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                tempTable = InputTable.Get(context);
                tempPath  = FilePath.Get(context);

                string[] words = tempPath.Split('/');

                if (words.Length <= 1)
                {
                    tempPath = Path.Combine(Environment.CurrentDirectory, tempPath);
                }

                if (string.IsNullOrEmpty(tempTable.TableName))
                {
                    tempTable.TableName = "Table1";
                }

                tempTable.WriteXml(tempPath, WriteMode);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #9
0
 public void Given_I_added_contacts(InputTable <Contact> contacts)
 {
     foreach (var contact in contacts)
     {
         AddContact(contact);
     }
 }
Beispiel #10
0
        /// <summary>
        /// Retourne un inputTable à partir de son nom
        /// </summary>
        /// <param name="inputTableName">Le nom de l'inputTable</param>
        /// <returns>L'inputTable renvoyé</returns>
        public InputTable getInputTableByName(string inputTableName)
        {
            if (inputTableName == null)
            {
                return(null);
            }
            InputTable table = new InputTable();

            foreach (object obj in this.liste)
            {
                if (obj is InputTable)
                {
                    table.name = ((InputTable)obj).name;
                    table.oid  = ((InputTable)obj).oid;
                }
                else if (obj is InputTableBrowserData)
                {
                    table.name = ((InputTableBrowserData)obj).name;
                    table.oid  = ((InputTableBrowserData)obj).oid;
                }
                if (table.name.ToUpper() == inputTableName.ToUpper())
                {
                    return(table);
                }
            }
            return(null);
        }
Beispiel #11
0
 public void AddInputTableIfNatExist(InputTable inputTable)
 {
     if (getInputTableByName(inputTable.name) != null)
     {
         return;
     }
     AddInputTable(inputTable);
 }
Beispiel #12
0
 /// <summary>
 /// Methode de selection du treeview qui renvoit l'élément selectionné
 /// et cet élément un inputTable est transmis au InputTableTreeview
 /// par l'évènement OnClick
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnTreeNodeClick(object sender, MouseButtonEventArgs e)
 {
     if (InputTableTree.SelectedItem != null && InputTableTree.SelectedItem is InputTableBrowserData && SelectionChanged != null)
     {
         InputTable table = new InputTable();
         table.name = ((InputTableBrowserData)InputTableTree.SelectedItem).name;
         table.oid  = ((InputTableBrowserData)InputTableTree.SelectedItem).oid;
         SelectionChanged(table);
         e.Handled = true;
     }
 }
Beispiel #13
0
 /// <summary>
 /// Retire un inputTable de la liste
 /// </summary>
 /// <param name="inputTable">L'inputTable à modifier</param>
 public void RemoveInputTable(InputTable inputTable)
 {
     foreach (InputTableBrowserData data in this.liste)
     {
         if (data.name == inputTable.name)
         {
             this.liste.Remove(data);
             this.cvs.DeferRefresh();
             return;
         }
     }
 }
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                this.tempTable = InputTable.Get(context);

                XmlDocument xmldoc = this.GetXmlDocument();

                Document.Set(context, xmldoc);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #15
0
        /// <summary>
        /// Rajoute une inputTable
        /// </summary>
        /// <param name="inputTable">L'inputTable à modifier</param>
        public void AddInputTable(InputTable inputTable)
        {
            InputTableBrowserData data = new InputTableBrowserData();

            if (inputTable.oid.HasValue)
            {
                data.oid = inputTable.oid.Value;
            }
            data.name = inputTable.name;
            if (inputTable.group != null)
            {
                data.group = inputTable.group.name;
            }
            this.liste.Add(data);
            this.cvs.DeferRefresh();
        }
Beispiel #16
0
        protected override void Execute(CodeActivityContext context)
        {
            DataTable inputTable = InputTable.Get(context);
            String    suffix     = Suffix.Get(context);

            this.contextGlobal = context;
            //Create the empty form

            Form form = new Form();

            form.FormClosing += new FormClosingEventHandler(Form_Closing);

            //Check if suffix is set
            if (suffix == null || suffix == "")
            {
                form.Text = "Data viewer";
            }
            else
            {
                form.Text = "Data viewer: " + suffix;
            }

            form.Controls.Add(myDataGridView);
            myDataGridView.Dock       = DockStyle.Fill;
            myDataGridView.DataSource = inputTable;

            //We make every column NotSortable
            foreach (DataGridViewColumn column in myDataGridView.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            form.WindowState = FormWindowState.Maximized;
            if (ShowAsDialog.Expression == null || ShowAsDialog.Get(context))
            {
                form.ShowDialog();
            }
            else
            {
                form.Show();
            }

            form.WindowState = FormWindowState.Maximized;
            form.BringToFront();
            form.Focus();
        }
Beispiel #17
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                this.localDataTable  = InputTable.Get(context);
                this.localColumnName = ColumnName.Get(context);
                this.localSelect     = Select.Get(context);

                this.DoCount();

                Result.Set(context, this.localOutPut);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="table"></param>
 public void fillTable(InputTable table)
 {
     if (table == null)
     {
         return;
     }
     table.name = nameTextBox.Text;
     if (groupField.Group == null)
     {
         groupField.Group = new BGroup();
     }
     groupField.Group.subjectType = Kernel.Domain.SubjectType.INPUT_TABLE.label;
     table.group             = groupField.Group;
     table.active            = activeCheckBox.IsChecked.Value;
     table.template          = templateCheckBox.IsChecked.Value;
     table.visibleInShortcut = visibleInShortcutCheckBox.IsChecked.Value;
     table.period            = periodPanel.Period;
 }
Beispiel #19
0
 public InputTable deserializeInputTable(String json)
 {
     try
     {
         System.Web.Script.Serialization.JavaScriptSerializer Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
         Serializer.MaxJsonLength = int.MaxValue;
         InputTable table = Serializer.Deserialize <InputTable>(json);
         if (table == null || table.oid == null || !table.oid.HasValue)
         {
             return(null);
         }
         return(table);
     }
     catch (Exception e)
     {
         logger.Debug("Fail to deserialize InputTable!", e);
     }
     return(null);
 }
Beispiel #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="page"></param>
        /// <param name="design"></param>
        /// <param name="currentRange"></param>
        /// <param name="_periodicity"></param>
        /// <param name="showHeader"></param>
        public void apply(InputTableEditorItem page, Design design, Range currentRange, Periodicity periodicity, InputTableEditorController.canShowHeader showHeader)
        {
            DateTime time = DateTime.Now;

            this.cellsDictionary = new Dictionary <string, CellProperty>(0);
            this.design          = design;
            this.page            = page;
            this.table           = page.EditedObject;
            this.periodicity     = periodicity;
            this.sheetName       = currentRange.Sheet.Name;
            System.Windows.Point coord = GetCellsCoord(design);

            DateTime time1 = DateTime.Now;

            BuildColunms(currentRange, coord, showHeader.columns);
            var duration = (DateTime.Now - time1).TotalSeconds;

            Console.Out.WriteLine("BuildColunms : " + duration);

            time1 = DateTime.Now;
            BuildRows(currentRange, coord, showHeader.lines);
            duration = (DateTime.Now - time1).TotalSeconds;
            Console.Out.WriteLine("BuildRows : " + duration);

            BuildCentralPart(currentRange, showHeader.central);

            time1 = DateTime.Now;
            BuildTotals(currentRange, coord, showHeader.columns, showHeader.lines);
            duration = (DateTime.Now - time1).TotalSeconds;
            Console.Out.WriteLine("BuildRows : " + duration);

            time1 = DateTime.Now;
            table.cellPropertyListChangeHandler.AddNew(this.cellsDictionary.Values);
            duration = (DateTime.Now - time1).TotalSeconds;
            Console.Out.WriteLine("Add Cells : " + duration);

            duration = (DateTime.Now - time).TotalSeconds;
            Console.Out.WriteLine("Get Cells : " + getCellDuration + " secondes");
            Console.Out.WriteLine("Total     : " + duration + " secondes");
        }
Beispiel #21
0
        private void InsertReportWithoutCopy(InputTable report)
        {
            if (report == null)
            {
                return;
            }
            PresentationEditorItem page = (PresentationEditorItem)getPresentationEditor().getActivePage();

            if (page == null)
            {
                return;
            }
            string reportFilePath = GetPresentationService().FileService.FileTransferService.downloadTable(report.name + EdrawOffice.EXCEL_EXT);

            if (reportFilePath == null)
            {
                return;
            }
            reportFilePath += report.excelFileName;
            page.getPresentationForm().SlideView.AddOrUpdateExcelShape(reportFilePath, (report).oid.Value);
            OnChange();
        }
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                table        = InputTable.Get(context);
                localRowList = RowCollection.Get(context);

                if (table != null && localRowList != null && localRowList.Count > 0)
                {
                    for (int introw = 0; introw < localRowList.Count; introw++)
                    {
                        table.Rows.Add(localRowList[introw].ItemArray);
                    }
                }

                Result.Set(context, table);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #23
0
        public ImportViewModel()
        {
            loadUserCurrentLogin();
            LoadImportData();

            ListProduct            = new List <ProductTable> (DataProvider.Ins.Entities.ProductTable);
            CreateNewImportCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            }, (p) =>
            {
                InputTable newInput = new InputTable();
                newInput.DateInput  = DateTime.Now;
                newInput.ID_User    = ID_CurrentUser;
                if (newInput == null)
                {
                    return;
                }

                DataProvider.Ins.Entities.InputTable.Add(newInput);
                DataProvider.Ins.Entities.SaveChanges();

                IsActiveSnackBar = true;
                Message          = "Thêm Mới Phiếu Nhập Thành Công!";

                LoadImportData();

                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 3000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            LoadEditCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { LoadDialogAccountEdit(); });

            AddCommand = new RelayCommand <object>((p) =>
            {
                if (Amount == 0 || InputPrice == 0 || string.IsNullOrEmpty(Status))
                {
                    return(false);
                }


                var Product = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Product == SelectedProduct.ID && x.ID_Input == SelectedItemInput.input.ID);

                if (Product.Count() != 0 || Product == null)
                {
                    return(false);
                }

                return(true);
            },
                                                   (p) =>
            {
                InputDetailTable detailItem = new InputDetailTable();
                detailItem.ID_Input         = SelectedItemInput.input.ID;
                detailItem.ID_Product       = SelectedProduct.ID;
                detailItem.PriceInput       = InputPrice;
                detailItem.Status           = Status;
                detailItem.Amount           = Amount;
                detailItem.TotalPrice       = Amount * InputPrice;
                DataProvider.Ins.Entities.InputDetailTable.Add(detailItem);
                DataProvider.Ins.Entities.SaveChanges();

                ListInputDetail = new List <ImportDetailModel>();
                var List        = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                foreach (var item in List)
                {
                    ImportDetailModel detail = new ImportDetailModel();
                    ProductTable product     = new ProductTable();
                    product            = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.InputDetail = item;
                    detail.Product     = product;
                    ListInputDetail.Add(detail);
                }

                SelectedItemInputDetail = null;
                InputPrice      = 0;
                Status          = null;
                Amount          = 0;
                SelectedProduct = null;

                IsActiveSnackBar          = true;
                Message                   = "Thêm Mới Chi Tiết Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            EditCommand = new RelayCommand <object>((p) =>
            {
                if (Amount == 0 || InputPrice == 0 || string.IsNullOrEmpty(Status) || SelectedProduct == null)
                {
                    return(false);
                }

                var Product = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID != SelectedItemInputDetail.Product.ID && x.ID_Product == SelectedProduct.ID && x.ID_Input == SelectedItemInput.input.ID);

                if (Product.Count() != 0 || Product == null)
                {
                    return(false);
                }

                return(true);
            },
                                                    (p) =>
            {
                InputDetailTable detailItem = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID == SelectedItemInputDetail.InputDetail.ID).FirstOrDefault();
                detailItem.ID_Product       = SelectedProduct.ID;
                detailItem.PriceInput       = InputPrice;
                detailItem.Status           = Status;
                detailItem.Amount           = Amount;
                detailItem.TotalPrice       = Amount * InputPrice;
                DataProvider.Ins.Entities.SaveChanges();

                ListInputDetail = new List <ImportDetailModel>();
                var List        = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                foreach (var item in List)
                {
                    ImportDetailModel detail = new ImportDetailModel();
                    ProductTable product     = new ProductTable();
                    product            = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.InputDetail = item;
                    detail.Product     = product;
                    ListInputDetail.Add(detail);
                }

                SelectedItemInputDetail = null;
                InputPrice      = 0;
                Status          = null;
                Amount          = 0;
                SelectedProduct = null;

                IsActiveSnackBar          = true;
                Message                   = "Sửa Chi Tiết Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            DeleteCommand = new RelayCommand <object>((p) =>
            {
                if (Amount == 0 || InputPrice == 0 || string.IsNullOrEmpty(Status) || SelectedProduct == null)
                {
                    return(false);
                }

                return(true);
            }, (p) =>
            {
                DeleteNotificationMessage msg = new DeleteNotificationMessage();
                Message = "Xóa Thông Tin Có Thể Dẫn Đến Sai Lệch Dữ Liệu! Bạn Chắc Chắn Chứ?";
                DialogHost.Show(msg, "ImportDialog");
            });

            DeleteConfirmCommand = new RelayCommand <object>((p) =>
            {
                if (Amount == 0 || InputPrice == 0 || string.IsNullOrEmpty(Status) || SelectedProduct == null)
                {
                    return(false);
                }

                return(true);
            }, (p) =>
            {
                InputDetailTable detailItem = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID == SelectedItemInputDetail.InputDetail.ID).FirstOrDefault();
                DataProvider.Ins.Entities.InputDetailTable.Remove(detailItem);
                DataProvider.Ins.Entities.SaveChanges();

                ListInputDetail = new List <ImportDetailModel>();
                var List        = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                foreach (var item in List)
                {
                    ImportDetailModel detail = new ImportDetailModel();
                    ProductTable product     = new ProductTable();
                    product            = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.InputDetail = item;
                    detail.Product     = product;
                    ListInputDetail.Add(detail);
                }
                DialogHost.CloseDialogCommand.Execute(null, null);

                SelectedItemInputDetail = null;
                InputPrice      = 0;
                Status          = null;
                Amount          = 0;
                SelectedProduct = null;

                IsActiveSnackBar          = true;
                Message                   = "Xóa Chi Tiết Thành Công!";
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            DeleteImportCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            }, (p) =>
            {
                var List = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                if (List.Count() != 0)
                {
                    ErrorNotificationMessage msg = new ErrorNotificationMessage();
                    Message = "Phiếu Nhập Này Đang Có Chi Tiết! Bạn Vui Lòng Xóa Bỏ Các Thông Tin Liên Quan!";
                    DialogHost.Show(msg, "ImportDialog");
                    return;
                }

                DataProvider.Ins.Entities.InputTable.Remove(SelectedItemInput.input);
                DataProvider.Ins.Entities.SaveChanges();

                SelectedItemInput       = null;
                SelectedItemInputDetail = null;
                InputPrice      = 0;
                Status          = null;
                Amount          = 0;
                SelectedProduct = null;

                IsActiveSnackBar = true;
                Message          = "Xóa Phiếu Nhập Thành Công!";

                LoadImportData();

                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Interval            = 5000;
                timer.Enabled             = true;
                timer.Elapsed            += ShowSnackBar;
                timer.Start();
            });

            SearchCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            },
                                                      (p) =>
            {
                if (SearchTermInput == null)
                {
                    return;
                }


                var ListInput             = DataProvider.Ins.Entities.InputTable;
                List <ImportModel> Result = new List <ImportModel>();
                foreach (var item in ListInput)
                {
                    ImportModel import = new ImportModel();
                    import.input       = item;
                    import.User        = DataProvider.Ins.Entities.UserTable.Where(x => x.ID == item.ID_User).FirstOrDefault();
                    Result.Add(import);
                }

                ListImport = new List <ImportModel>(Result.Where(
                                                        x => x.input.DateInput.ToString().ToLower().Contains(SearchTermInput) ||
                                                        x.User.DisplayName.ToLower().Contains(SearchTermInput)
                                                        ));
            });

            SearchDetailCommand = new RelayCommand <object>((p) =>
            {
                return(true);
            },
                                                            (p) =>
            {
                if (SearchTermInputDetail == null || SelectedItemInput == null)
                {
                    return;
                }
                List <ImportDetailModel> Result = new List <ImportDetailModel>();

                var List = DataProvider.Ins.Entities.InputDetailTable.Where(x => x.ID_Input == SelectedItemInput.input.ID);
                foreach (var item in List)
                {
                    ImportDetailModel detail = new ImportDetailModel();
                    ProductTable product     = new ProductTable();
                    product            = DataProvider.Ins.Entities.ProductTable.Where(x => x.ID == item.ID_Product).FirstOrDefault();
                    detail.InputDetail = item;
                    detail.Product     = product;
                    Result.Add(detail);
                }
                ListInputDetail = new List <ImportDetailModel>(Result.Where(
                                                                   x => x.Product.DisplayName.ToLower().Contains(SearchTermInputDetail) ||
                                                                   x.InputDetail.Amount.ToString().ToLower().Contains(SearchTermInputDetail) || x.InputDetail.PriceInput.ToString().ToLower().Contains(SearchTermInputDetail) ||
                                                                   x.InputDetail.Status.Contains(SearchTermInputDetail)
                                                                   ));
            });
        }
Beispiel #24
0
        public override Misp.Kernel.Domain.InputTable Save(Misp.Kernel.Domain.InputTable item)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            serializer.MaxJsonLength = int.MaxValue;

            Socket socket = buildSocket(SocketResourcePath + "/Save/");

            socket.OnMessage += (sender, e) =>
            {
                SaveInfo info = deserializeSaveInfo(e.Data);
                if (info != null)
                {
                    if (SaveTableHandler != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(() =>
                        {
                            if (SaveTableHandler != null)
                            {
                                SaveTableHandler(info, null);
                            }
                        }
                                                                             );
                    }
                    if (info.isEnd)
                    {
                        socket.Close(CloseStatusCode.Normal);
                    }
                    return;
                }

                TableSaveIssue issue = deserializeIssue(e.Data);
                if (issue != null)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() =>
                    {
                        ModelModificationDialog dialog = new ModelModificationDialog();
                        dialog.Display(this, issue);
                        dialog.ShowDialog();
                        issue = dialog.tableSaveIssue;
                        if (issue != null && issue.targetItem != null)
                        {
                            issue.targetItem.attribute = null;
                        }
                        string json = serializer.Serialize(issue);
                        socket.Send(json);
                    });
                    return;
                }

                InputTable table = deserializeInputTable(e.Data);
                if (table != null)
                {
                    if (SaveTableHandler != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(() =>
                        {
                            if (SaveTableHandler != null)
                            {
                                SaveTableHandler(null, table);
                            }
                        }
                                                                             );
                    }
                    return;
                }

                logger.Debug("Recieve text : " + e.Data);
            };

            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();
            socket.Send(item.name);

            //item = base.Save(item);
            return(item);
        }