private void RetrieveConfiguration() { try { SafeCrossCallBackDelegate safeCrossCallBackDelegate = null; if (pnlBody_Right.InvokeRequired) safeCrossCallBackDelegate = RetrieveConfiguration; if (pnlBody_Right.InvokeRequired) Invoke(safeCrossCallBackDelegate); else { Thread.Sleep(100); //Loading Service pgbService.Value += 15; _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService(); pgbService.Value += 15; _saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService(); pgbService.Value += 15; _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService(); pgbService.Value += 15; _customerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService(); pgbService.Value += 15; _supplierService = ServiceFactory.GenerateServiceInstance().GenerateSupplierService(); pgbService.Value += 15; _expenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService(); pgbService.Value += 10; _userService = ServiceFactory.GenerateServiceInstance().GenerateUserService(); //Connecting to database pgbGlobalConfig.Value += 50; _commonService.InitializeGlobalConfiguration(); pgbGlobalConfig.Value += 50; //Initializing workspace pgbInitialization.Value += 30; _commonService.InitializeWorkSpace(); pgbInitialization.Value += 30; if (AppContext.Counter == null) { const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ"; var detailMsg = Resources.MsgCounterNotInitialize; using (var frmMessageBox = new FrmExtendedMessageBox()) { frmMessageBox.BriefMsgStr = briefMsg; frmMessageBox.DetailMsgStr = detailMsg; frmMessageBox.IsCanceledOnly = true; frmMessageBox.ShowDialog(this); Close(); return; } } pgbInitialization.Value += 40; //Loading configuration pgbCustomizedConfig.Value += 80; Visible = false; using (var frmLogIn = new FrmLogIn()) { frmLogIn.UserService = _userService; if (frmLogIn.ShowDialog(this) == DialogResult.OK) { Visible = true; var frmMain = new FrmMain(); ApplicationContext.MainForm = frmMain; frmMain.CommonService = _commonService; frmMain.SaleOrderService = _saleOrderService; frmMain.ProductService = _productService; frmMain.CustomerService = _customerService; frmMain.SupplierService = _supplierService; frmMain.ExpenseService = _expenseService; frmMain.UserService = _userService; _commonService.InitializeCustomizedConfiguration(frmLogIn.User); pgbCustomizedConfig.Value += 20; _commonService.InsertOperationLog( AppContext.User.UserId, int.Parse(Resources.OperationLogIn)); frmMain.Show(); Close(); } else ApplicationContext.ExitThread(); } } } catch (Exception exception) { const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ"; var detailMsg = Resources.MsgConnectionLost; using (var frmMessageBox = new FrmExtendedMessageBox()) { frmMessageBox.BriefMsgStr = briefMsg; frmMessageBox.DetailMsgStr = detailMsg; frmMessageBox.IsCanceledOnly = true; frmMessageBox.ShowDialog(this); Close(); } } }
private void RetrieveConfiguration() { try { SafeCrossCallBackDelegate safeCrossCallBackDelegate = null; if (pnlBody_Right.InvokeRequired) { safeCrossCallBackDelegate = RetrieveConfiguration; } if (pnlBody_Right.InvokeRequired) { Invoke(safeCrossCallBackDelegate); } else { Thread.Sleep(100); //Loading Service pgbService.Value += 15; _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService(); pgbService.Value += 15; _saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService(); pgbService.Value += 15; _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService(); pgbService.Value += 15; _customerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService(); pgbService.Value += 15; _supplierService = ServiceFactory.GenerateServiceInstance().GenerateSupplierService(); pgbService.Value += 15; _expenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService(); pgbService.Value += 10; _userService = ServiceFactory.GenerateServiceInstance().GenerateUserService(); //Connecting to database pgbGlobalConfig.Value += 50; _commonService.InitializeGlobalConfiguration(); pgbGlobalConfig.Value += 50; //Initializing workspace pgbInitialization.Value += 30; _commonService.InitializeWorkSpace(); pgbInitialization.Value += 30; if (AppContext.Counter == null) { const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ"; var detailMsg = Resources.MsgCounterNotInitialize; using (var frmMessageBox = new FrmExtendedMessageBox()) { frmMessageBox.BriefMsgStr = briefMsg; frmMessageBox.DetailMsgStr = detailMsg; frmMessageBox.IsCanceledOnly = true; frmMessageBox.ShowDialog(this); Close(); return; } } pgbInitialization.Value += 40; //Loading configuration pgbCustomizedConfig.Value += 80; Visible = false; using (var frmLogIn = new FrmLogIn()) { frmLogIn.UserService = _userService; if (frmLogIn.ShowDialog(this) == DialogResult.OK) { Visible = true; var frmMain = new FrmMain(); ApplicationContext.MainForm = frmMain; frmMain.CommonService = _commonService; frmMain.SaleOrderService = _saleOrderService; frmMain.ProductService = _productService; frmMain.CustomerService = _customerService; frmMain.SupplierService = _supplierService; frmMain.ExpenseService = _expenseService; frmMain.UserService = _userService; _commonService.InitializeCustomizedConfiguration(frmLogIn.User); pgbCustomizedConfig.Value += 20; _commonService.InsertOperationLog( AppContext.User.UserId, int.Parse(Resources.OperationLogIn)); frmMain.Show(); Close(); } else { ApplicationContext.ExitThread(); } } } } catch (Exception exception) { const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ"; var detailMsg = Resources.MsgConnectionLost; using (var frmMessageBox = new FrmExtendedMessageBox()) { frmMessageBox.BriefMsgStr = briefMsg; frmMessageBox.DetailMsgStr = detailMsg; frmMessageBox.IsCanceledOnly = true; frmMessageBox.ShowDialog(this); Close(); } } }