示例#1
0
        public void InitForm()
        {
            try
            {
                dataManager = new DSManager(jmsServer, jmsUser, jmsPassword, cacheUpdateTimerInterval, msgFilter, msgFilter);
                dataManager.IncMessageCounter += new EventHandler(OnIncMessageCounter);

                dataSet = new DataSet();

                SummaryData summaryDataTemplate = new SummaryData();
                IList<SummaryData> summaryList;
                summaryList = dataManager.DaoManager.CreateObjList<SummaryData>(summaryDataTemplate);
                string filterText = "";  //G
                summaryDataTable = CollectionHelper.ConvertTo<SummaryData>(summaryList, filterText);
                summaryDataTable.PrimaryKey = new DataColumn[] { summaryDataTable.Columns["Id"] };

                dataSet.Tables.Add(summaryDataTable);

                dataManager.RegisterDataSet(ref dataSet);
                dataManager.RegisterGridControl(ref gridMain);
                dataManager.StartListening();

                gridMain.DataSource = dataSet.Tables["SummaryData"];
                gridMain.ForceInitialize();

            }
            catch (Exception error)
            {
                MessageBox.Show("Error:" + error.Message);
            }
        }
示例#2
0
        private void rfrmMain_Load(object sender, EventArgs e)
        {
            initSkinsMenu();
            ReadAppSettings();
            ReadUserSettings();

            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.Skins.SkinManager.EnableMdiFormSkins();

            string errorMessageText = String.Empty;

            try // get the user companies setup.
            {
                //Israel 12/4/14 - Static and local both necessary
                errorMessageText = "The error occurred while assigning internal access settings for the user: "******"BookingCoSn", typeof(string)));
                seCptyLkupTbl.PrimaryKey = new DataColumn[] { seCptyLkupTbl.Columns["BookingCoSn"] };

                errorMessageText = "The error occurred while reading the companies using MSSql connection string: " + sqlConnectionStr;
                GetCompanies();
                //if (seCptyLkupTbl.Rows.Count <= 0)
                //{
                //    XtraMessageBox.Show("rfrmMain_Load[1]: There are no trades for which this user has been granted access. Please contact Help Desk.",
                //    "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //    Environment.ExitCode = -1;
                //    System.Windows.Forms.Application.Exit();
                //}
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while getting the company list from the database." + Environment.NewLine +
                    errorMessageText + Environment.NewLine +
                    "Error CNF-002 in " + FORM_NAME + ".rfrmMain_Load(): " + ex.Message,
                    MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Environment.ExitCode = -1;
                //System.Windows.Forms.Application.Exit();
            }

            try
            {
                Program.splashForm.ShowLoadProgress("Loading Initial Data...");

                string msgFilter = ""; // GetMessageFilterString("W");
                string inbFilter = ""; // GetInbMessageFilterString("W");

                errorMessageText = "The error occurred while attempting to get the user permission data from the Web Service at: " +
                    Properties.Settings.Default.ExtSvcAPIBaseUrl;
                ConfirmMgrAPIDal confirmMgrAPIDal = new ConfirmMgrAPIDal(Properties.Settings.Default.ExtSvcAPIBaseUrl,
                    Properties.Settings.Default.ExtSvcAPIUserName, Properties.Settings.Default.ExtSvcAPIPassword);
                v_PermKeyList = confirmMgrAPIDal.GetPermissionKeys(p_UserId, out v_IsSuperUser);

                errorMessageText = "The error occurred while reading the user permission settings returned from the Web Service at: " +
                    Properties.Settings.Default.ExtSvcAPIBaseUrl;

                //Israel 11/20/2015 -- Implement Permission key override from command line.
                if (v_IsPermKeyOverride)
                {
                    v_IsSuperUser = false;
                    v_PermKeyList = v_PermKeyOverrideList;
                }

                if (!v_IsSuperUser && v_PermKeyList.Count > 0)
                    v_PermKeyDBInClauseStr = confirmMgrAPIDal.GetPermissionKeyDBInClause(v_PermKeyList);

                if (!v_IsSuperUser && v_PermKeyDBInClauseStr == "")
                {
                    errorMessageText = String.Empty;
                    XtraMessageBox.Show("No access rights have been granted for User: "******".",
                        "Main Form Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    Environment.ExitCode = -2;
                    System.Windows.Forms.Application.Exit();
                }

                //Israel -- Testing stubs
                //v_IsSuperUser = false;
                //v_PermKeyList.Clear();
                //v_PermKeyList.Add("1438");
                //v_PermKeyDBInClauseStr = confirmMgrAPIDal.GetPermissionKeyDBInClause(v_PermKeyList);
                //Israel -- Testing stubs

                errorMessageText = "The error occurred while connecting to the update Message Server at: " + Properties.Settings.Default.MessageServer;
                dataManager = new DSManager(Properties.Settings.Default.MessageServer, // + HORNETQ_PROPS,
                            Properties.Settings.Default.MessageUser,
                            Properties.Settings.Default.MessagePassword,
                            Properties.Settings.Default.UpdateFromCacheTimerIntervalSecs,
                            msgFilter, inbFilter, v_PermKeyList, v_IsSuperUser);

                webServiceFilter = msgFilter;
                inbServiceFilter = inbFilter;
                dataManager.IncMessageCounter += new EventHandler(OnIncMessageCounter);
                dataManager.ResetMessageCounter += new EventHandler(OnResetMessageCounter);
                dataManager.BeginGridUpdates += new EventHandler(OnBeginGridUpdates);
                dataManager.EndGridUpdates += new EventHandler(OnEndGridUpdates);

                dataSet = new DataSet();
                errorMessageText = "The error occurred while loading the current workflow and base data from the database.";
                LoadInitialData();

                errorMessageText = "The error occurred while accessing the current workflow data just loaded from the database.";
                dataSet.Tables.Add(summaryDataTable);
                dataSet.Tables.Add(rqmtDataTable);
                dataSet.Tables.Add(confirmDataTable);
            }
            catch (Exception ex)
            {
                string innerException = ErrorMsgDump(ex);
                //SaveTextToFile(innerException, tempDir + "\\StartupException.log");
                SaveTextToFile(innerException, Path.Combine(appTempDir, "StartupException.log"));

                XtraMessageBox.Show("An error occurred while loading trade and related data." + Environment.NewLine +
                    errorMessageText + Environment.NewLine +
                                "Error CNF-003 in " + FORM_NAME + ".rfrmMain_Load(): " + ex.Message,
                    MAIN_FORM_STOP_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Environment.ExitCode = -2;
                System.Windows.Forms.Application.Exit();
            }

            try
            {
                barStaticDBName.Caption = v_Server + @":" + v_Database;
            }

            catch (Exception ex)
            {
                string innerException = ErrorMsgDump(ex);
                SaveTextToFile(innerException, Path.Combine(appTempDir, "StartupException.log"));
                Environment.ExitCode = -3;
                System.Windows.Forms.Application.Exit();
            }
            try
            {
                errorMessageText = "The error occurred while attempting to start the update message listeners.";
                dataManager.RegisterDataSet(ref dataSet);
                dataManager.RegisterGridControl(ref gridMain);
                dataManager.RegisterGridControl(ref gridRqmt);
                dataManager.RegisterGridControl(ref gridConfirm);
                Program.splashForm.ShowLoadProgress("Starting message listeners...");
                dataManager.StartListening();
            }
            catch (Exception except)
            {
                XtraMessageBox.Show("Failed to establish Update Message Server connection. " + Environment.NewLine +
                    errorMessageText + Environment.NewLine +
                                "Error CNF-004 in " + FORM_NAME + ".rfrmMain_Load(): " + except.Message,
                    MAIN_FORM_STOP_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Environment.ExitCode = -2;
                System.Windows.Forms.Application.Exit();
            }
            try
            {
                //Israel 14-11-10 -- Replace windows user id logon with the toolbar name.
                //windowsUserId = Sempra.Ops.Utils.GetUserName();
                barStaticUserId.Caption = toolbarOrWindowsUserId.ToLower();

                errorMessageText = "The error occurred while initializing the Summary data grid.";
                gridMain.DataSource = dataSet.Tables["SummaryData"];
                gridMain.ForceInitialize();

                errorMessageText = "The error occurred while initializing the Requirement data grid.";
                gridRqmt.DataSource = dataSet.Tables["RqmtData"];
                gridRqmt.ForceInitialize();

                errorMessageText = "The error occurred while initializing the Confirm data grid.";
                gridConfirm.DataSource = dataSet.Tables["TradeRqmtConfirm"];
                gridConfirm.ForceInitialize();

                errorMessageText = "The error occurred while initializing the Audit grid.";
                createAuditDataTable();
                auditForm.gridAudit.DataSource = this.dataSet.Tables["AuditDataTable"];
                auditForm.gridAudit.ForceInitialize();
                auditForm.settingsDir = this.appSettingsDir;

                //Israel 9/21/2015
                barBrowserStdBtns.Visible = false;
                barBrowserAddressBar.Visible = false;

                errorMessageText = "The error occurred while initializing the Xmit Result grid.";
                createXmitResultDataTable();
                xmitResultStatusLogForm.gridXmitResult.DataSource = this.dataSet.Tables["XmitResultTable"];
                xmitResultStatusLogForm.gridXmitResult.ForceInitialize();
                xmitResultStatusLogForm.settingsDir = this.appSettingsDir;

                templateListForm.settingsDir = this.appSettingsDir;

                errorMessageText = "The error occurred while initializing the Trade Data Change grid.";
                createTradeDataChangeTable();
                tradeDataChangesForm.gridTradeDataChanges.DataSource = this.dataSet.Tables["TradeDataChangeTable"];
                tradeDataChangesForm.gridTradeDataChanges.ForceInitialize();

                gridViewSummary.OptionsDetail.ShowDetailTabs = false;

                SetStdFiltersTableView();

                //Setup user access rights
                errorMessageText = "The error occurred while setting up the user role code access rights.";
                userRoleView = new System.Data.DataTable();
                userRoleView.Columns.Add(new DataColumn("RoleCode", typeof(string)));
                userRoleView.PrimaryKey = new DataColumn[] { userRoleView.Columns["RoleCode"] };
                CallGetUserRoles();
                SetUserAccess();
                ApplyUserAccess();
                if (!isHasAccess)
                {
                    XtraMessageBox.Show("User: "******" has not been granted access.",
                       "Main Form Stop Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    Environment.ExitCode = -4;
                    System.Windows.Forms.Application.Exit();
                }

                //Setup User filters
                errorMessageText = "The error occurred while setting up the internal user filter settings.";
                CreateUserFiltersView();
                CallGetUserFilters();
                luedUserFilter.Properties.DataSource = userFiltersView.DefaultView;
                luedUserFilter.Properties.DisplayMember = "Descr";
                luedUserFilter.Properties.ValueMember = "Id";


                errorMessageText = "The error occurred while reading the FilterSettings > MostRecentUserDefined value in the user settings file stored at: " + appSettingsDir + ".";
                //Can't be in ReadUserSettings because of table creation order.
                try
                {
                    Sempra.Ops.IniFile iniFile = new Sempra.Ops.IniFile(FileNameUtils.GetUserIniFileName(appSettingsDir));
                    int filterIndex = iniFile.ReadValue("FilterSettings", "MostRecentUserDefined", NO_FILTER_VAL);
                    if (filterIndex > NO_FILTER_VAL)
                    {
                        ApplyGridFilterByUserFilterIndex(filterIndex);
                        luedUserFilter.EditValue = filterIndex;
                    }
                }
#pragma warning disable 0168
                //Disable warning...
                catch (Exception excep) { }
#pragma warning restore 0168

                errorMessageText = "The error occurred while initializing the Add Requirements data entry form.";
                addRqmtForm.InitForm();

                errorMessageText = "The error occurred while initializing the Edit Requirements data entry form.";
                editRqmtForm.rqmtStatusView = this.rqmtStatusView;
                editRqmtForm.settingsDir = this.appSettingsDir;
                editRqmtForm.InitForm();
                editRqmtForm.SetSecurityAccess(isSecondCheckCreateCxl, isSubmitQueuedEFETTrades, isForceFinalApprove);

                for (int i = 0; i < frmEditRqmt.RQMT_ARRAY_MAX; i++)
                    editRqmtForm.RqmtInitialStatus[i] = GetRqmtData(editRqmtForm.RQMT_CODES[i], "InitialStatus");

                //InitUserPrefDataLoad();

                errorMessageText = "The error occurred while initializing the internal list of Confirm Editor-controlled statuses.";
                noEditSempraRqmtStatus = new ArrayList();
                noEditSempraRqmtStatus.Add("NEW");
                noEditSempraRqmtStatus.Add("PREP");
                noEditSempraRqmtStatus.Add("EXT_REVIEW");
                noEditSempraRqmtStatus.Add("TRADER");
                noEditSempraRqmtStatus.Add("MGR");
                noEditSempraRqmtStatus.Add("OK_TO_SEND");

                //webbrowserEcm.StatusTextChanged += new EventHandler(WebBrowser_StatusTextChanged);
                //webbrowserEcm.CanGoBackChanged += new EventHandler(WebBrowser_CanGoBackChanged);
                //webbrowserEcm.CanGoForwardChanged += new EventHandler(WebBrowser_CanGoForwardChanged);

                //webbrowserOcc.StatusTextChanged += new EventHandler(WebBrowser_StatusTextChanged);
                //webbrowserOcc.CanGoBackChanged += new EventHandler(WebBrowser_CanGoBackChanged);
                //webbrowserOcc.CanGoForwardChanged += new EventHandler(WebBrowser_CanGoForwardChanged);

                //webbrowserAtc.StatusTextChanged += new EventHandler(WebBrowser_StatusTextChanged);
                //webbrowserAtc.CanGoBackChanged += new EventHandler(WebBrowser_CanGoBackChanged);
                //webbrowserAtc.CanGoForwardChanged += new EventHandler(WebBrowser_CanGoForwardChanged);

                //webbrowserEpm.StatusTextChanged += new EventHandler(WebBrowser_StatusTextChanged);
                //webbrowserEpm.CanGoBackChanged += new EventHandler(WebBrowser_CanGoBackChanged);
                //webbrowserEpm.CanGoForwardChanged += new EventHandler(WebBrowser_CanGoForwardChanged);

                //Uri siteUri = new Uri(Properties.Settings.Default.EConfirmUrl);
                //webbrowserEConfirm.Url = siteUri;

                //webbrowserEConfirm.Navigate(Properties.Settings.Default.EConfirmUrl);
                //webbrowserEcm.Navigate(Properties.Settings.Default.EcmUrl);

                //barEditFA.Refresh();
                //initComplete = true;
            }
            catch (Exception except)
            {
                XtraMessageBox.Show("An error occurred while applying security settings." + Environment.NewLine +
                    errorMessageText + Environment.NewLine +
                                "Error CNF-005 in " + FORM_NAME + ".rfrmMain_Load(): " + except.Message,
                   MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Application.Exit(); 
            }

            // init inbound panel
            try
            {
                InitInboundPanel();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while setting up the Inbound Documents panel." + Environment.NewLine +
                                "Error CNF-006 in " + FORM_NAME + ".rfrmMain_Load(): " + ex.Message,
                   MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // INIT AXPNL
            try
            {
                InitAXPanel();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("An error occurred while setting up the Applicaton Extender panel." + Environment.NewLine +
                                "Error CNF-007 in " + FORM_NAME + ".rfrmMain_Load(): " + ex.Message,
                   MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                barEditFA.Refresh();

                //Triggering ChangedFocusRow fires the event that filters associated docs
                if (gridViewSummary.RowCount > 1)
                {
                    gridViewSummary.FocusedRowHandle = 1;
                    gridViewSummary.FocusedRowHandle = 0;
                }

                initComplete = true;
            }
            catch (Exception except)
            {
                XtraMessageBox.Show("An error occurred while focusing the Main Grid to the first row." + Environment.NewLine +
                                "Error CNF-008 in " + FORM_NAME + ".rfrmMain_Load(): " + except.Message,
                   MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Program.splashForm.Close();
                myTimer.Start(); //Israel 12/15/2008 - Red X
            }
        }