public virtual void AddDataLogs(TDto dto, string actionType)
        {
            try
            {
                if (this.GenericService.GetOnDataLogs())
                {
                    SmartLogDTO.OnDataLogs = true;
                }
                else
                {
                    return;                                                                         // DO NOTHING
                }
                if (dto.EditedDate == null || ((DateTime)dto.EditedDate).Year == 1)
                {
                    dto.EditedDate = DateTime.Now;
                }

                List <string>       entityPropertyNames = typeof(TEntity).GetProperties().Select(s => s.Name).ToList();
                List <PropertyInfo> propertyInfos       = typeof(TDto).GetProperties().OrderBy(o => o.Name).ToList();
                foreach (PropertyInfo propertyInfo in propertyInfos)
                {
                    if (SmartLogDTO.CheckProperty(propertyInfo.PropertyType.Name, propertyInfo.Name))
                    {
                        if (!SmartLogDTO.OptionalNames.Contains(propertyInfo.Name) || entityPropertyNames.Contains(propertyInfo.Name))
                        {
                            this.GenericService.AddDataLogs(dto.GetID(), null, dto.EditedDate, dto.NMVNTaskID.ToString(), actionType, typeof(TDto).Name.Replace("DTO", ""), propertyInfo.Name, (propertyInfo.GetValue(dto) != null ? propertyInfo.GetValue(dto).ToString() : null));
                        }
                    }
                }
            }
            catch (Exception ex) { }
        }
        public override void AddViewDetailDataLogs(TDto dto, string actionType)
        {
            try
            {
                base.AddViewDetailDataLogs(dto, actionType);
                if (!SmartLogDTO.OnDataLogs)
                {
                    return;                         // DO NOTHING: IMPORTANT: SmartLogDTO.OnDataLogs WILL BE CHECKED AND SET EVERY TIME CALL AddDataLogs. TO: SHOULD CALL AddDataLogs BEFORE CALL AddViewDetailDataLogs
                }
                List <string>       entityPropertyNames = typeof(TEntityDetail).GetProperties().Select(s => s.Name).ToList();
                List <PropertyInfo> propertyInfos       = typeof(TDtoDetail).GetProperties().OrderBy(o => o.Name).ToList();

                List <string> entityViewDetailPropertyNames = typeof(TEntityViewDetail).GetProperties().Select(s => s.Name).ToList(); //JUST ADD PROPERTIES RETURNED BY TEntityViewDetail

                if (dto.GetDetails() != null && dto.GetDetails().Count > 0)
                {
                    dto.GetDetails().Each(detailDTO =>
                    {
                        foreach (PropertyInfo propertyInfo in propertyInfos)
                        {
                            if (SmartLogDTO.CheckProperty(propertyInfo.PropertyType.Name, propertyInfo.Name))
                            {
                                if ((!SmartLogDTO.OptionalNames.Contains(propertyInfo.Name) || entityPropertyNames.Contains(propertyInfo.Name)) && entityViewDetailPropertyNames.Contains(propertyInfo.Name))
                                {
                                    this.genericWithViewDetailService.AddDataLogs(dto.GetID(), detailDTO.GetID(), dto.EditedDate, dto.NMVNTaskID.ToString(), actionType, typeof(TDtoDetail).Name.Replace("DTO", ""), propertyInfo.Name, (propertyInfo.GetValue(detailDTO) != null ? propertyInfo.GetValue(detailDTO).ToString() : null));
                                }
                            }
                        }
                    });
                }
            }
            catch (Exception ex) { throw ex; }
        }
Esempio n. 3
0
        private void buttonLoginExit_Click(object sender, EventArgs e)
        {
            try
            {
                if (sender.Equals(this.buttonExit))
                {
                    this.DialogResult = DialogResult.Cancel; return;
                }

                if (this.comboUserID.SelectedIndex >= 0)
                {
                    ActiveUser activeUser = this.comboUserID.SelectedItem as ActiveUser;
                    if (activeUser != null)
                    {
                        ContextAttributes.LocalIPAddress = this.GetLocalIPAddress();
                        ContextAttributes.User           = new UserInformation(activeUser.UserID, activeUser.OrganizationalUnitID, activeUser.LocationID, activeUser.LocationName, activeUser.UserName, activeUser.SecurityIdentifier, activeUser.FullyQualifiedUserName, activeUser.IsDatabaseAdmin, new DateTime());

                        if (this.comboFillingLineID.Visible && (this.comboFillingLineID.SelectedIndex < 0 || this.comboComportName.SelectedIndex < 0))
                        {
                            throw new System.ArgumentException("Vui lòng chọn chuyền sản xuất (NOF1, NOF2, NOF...), và chọn đúng cổng COM để chạy phần mềm");                                                                                                                            // || (this.comboFillingLineID.Enabled && (GlobalVariables.ProductionLine)this.comboFillingLineID.SelectedValue == GlobalVariables.ProductionLine.SERVER)
                        }
                        if (this.comboFillingLineID.Visible)
                        {
                            GlobalVariables.FillingLineID   = (GlobalVariables.FillingLine) this.comboFillingLineID.SelectedValue;
                            GlobalVariables.FillingLineCode = ((FillingLineBase)this.comboFillingLineID.SelectedItem).Code;
                            GlobalVariables.FillingLineName = ((FillingLineBase)this.comboFillingLineID.SelectedItem).Name;
                        }
                        else
                        {
                            GlobalVariables.FillingLineID = GlobalVariables.FillingLine.None;
                        }

                        if (GlobalVariables.FillingLineID == GlobalVariables.FillingLine.Drum)
                        {
                            TotalBase.Enums.GlobalEnums.GlobalDrumWithDigit = this.checkGlobalDrumWithDigit.Checked;
                        }

                        GlobalVariables.ComportName = (string)this.comboComportName.SelectedValue;

                        CommonConfigs.AddUpdateAppSetting("ConfigID", (GlobalVariables.ConfigID).ToString());
                        CommonConfigs.AddUpdateAppSetting("ComportName", GlobalVariables.ComportName);

                        if (CommonConfigs.ReadSetting("ReportServerUrl") == "")
                        {
                            CommonConfigs.AddUpdateAppSetting("ReportServerUrl", GlobalVariables.ReportServerUrl);                                                     //INIT NEW Setting IN CONFIG FILE
                        }
                        GlobalVariables.ReportServerUrl = CommonConfigs.ReadSetting("ReportServerUrl");

                        this.VersionValidate();

                        #region EMPTY DATABASE
                        if (false && this.checkEmptyData.Checked)
                        {
                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     WarehouseAdjustmentDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('WarehouseAdjustmentDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     WarehouseAdjustments", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('WarehouseAdjustments', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsIssueTransferDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssueTransferDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsIssueDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssueDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsIssues", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsIssues', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     TransferOrderDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('TransferOrderDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     TransferOrders", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('TransferOrders', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     DeliveryAdviceDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('DeliveryAdviceDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     DeliveryAdvices", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('DeliveryAdvices', RESEED, 0)", new ObjectParameter[] { });


                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     SalesOrderDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('SalesOrderDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     SalesOrders", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('SalesOrders', RESEED, 0)", new ObjectParameter[] { });



                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsReceiptDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsReceiptDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     GoodsReceipts", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('GoodsReceipts', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     PickupDetails", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('PickupDetails', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Pickups", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Pickups', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Packs", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Packs', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Cartons", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Cartons', RESEED, 0)", new ObjectParameter[] { });

                            this.baseRepository.ExecuteStoreCommand("DELETE FROM     Pallets", new ObjectParameter[] { });
                            this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Pallets', RESEED, 0)", new ObjectParameter[] { });

                            //this.baseRepository.ExecuteStoreCommand("DELETE FROM     Batches", new ObjectParameter[] { });
                            //this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Batches', RESEED, 0)", new ObjectParameter[] { });

                            //this.baseRepository.ExecuteStoreCommand("DELETE FROM     Commodities", new ObjectParameter[] { });
                            //this.baseRepository.ExecuteStoreCommand("DBCC CHECKIDENT ('Commodities', RESEED, 0)", new ObjectParameter[] { });
                        }
                        #endregion

                        if (this.baseRepository.AutoUpdates(sender.Equals(this.buttonLoginRestore)))
                        {
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            CustomMsgBox.Show(this, "The program on this computer must be updated to the latest version." + "\r\n" + "\r\n" + "Contact your administrator for more information.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            this.buttonDownload_Click(this.buttonDownload, new EventArgs());
                        }



                        SmartLogDTO.Init();
                    }
                }
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);

                this.DialogResult = DialogResult.None;
            }
        }