Beispiel #1
0
        public static void ShowWarning(string title, string warningText, Control owner)
        {
            if (owner == null || owner.IsDisposed || owner.Disposing)
            {
                var frmMain = MainProcess.GetMainForm();
                if (frmMain != null && !frmMain.IsDisposed && !frmMain.Disposing)
                {
                    ShowWarning(title, warningText, frmMain);
                }
                else
                {
                    EventLog.WriteEntry("IMSS.Client", warningText, EventLogEntryType.Warning);
                }
                return;
            }

            if (owner.InvokeRequired)
            {
                owner.Invoke(new ShowWarningInvoker(ShowWarning), title, warningText, owner);
                return;
            }

            if (!owner.InvokeRequired)
            {
                var frmDialog = new frmInfo
                {
                    Text        = title,
                    pictureBox1 = { Image = Properties.Resources.Warning },
                    lbErrorInfo = { Text = warningText }
                };
                frmDialog.ShowDialog(owner);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Cập nhật giao diện sau khi Store được thực thi
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CurrentThread_DoUpdateGUI(object sender, EventArgs e)
        {
            try
            {
                if (m_LastException != null)
                {
                    StatusLed.Glyph = ThemeUtils.Image16.Images[Language.Icon];
                }

                var rf = new RowFormattable(m_LastResultRow);
                if (m_LastResultRow.Table.Columns.Contains(AlertInfo.CountField) &&
                    m_LastResultRow[AlertInfo.CountField] != DBNull.Value)
                {
                    var newAlertCount = int.Parse(rf.Row[AlertInfo.CountField].ToString());

                    if (LastAlertCount != newAlertCount)
                    {
                        alertCtrlMain.Show(
                            MainProcess.GetMainForm(),
                            Language.Title,
                            string.Format(Language.Content, rf),
                            ThemeUtils.Image16.Images[Language.Icon]
                            );

                        LastAlertCount = newAlertCount;
                    }
                }

                StatusLed.Caption = string.Format(Language.Status, rf);
            }
            catch
            {
            }
        }
        private void ucModulePreview_Click(object sender, EventArgs e)
        {
            if (ModuleForm != null && !ModuleForm.IsDisposed)
            {
                try
                {
                    ModuleForm.ShowInTaskbar = false;
                    ModuleForm.Show(MainProcess.GetMainForm());
                    ModuleForm.WindowState = FormWindowState.Normal;
                }
                catch
                {
                }
                finally
                {
                    ModuleForm.ucModule.ucPreview = null;
                }
            }

            MainProcess.RemoveModulePreview(this);
        }
Beispiel #4
0
        protected override void InitializeModuleData()
        {
            base.InitializeModuleData();
            CurrentThread = new WorkerThread(delegate
            {
                while (!CurrentThread.AbortRequest)
                {
                    try
                    {
                        using (var ctrlSA = new SAController())
                        {
                            DataContainer alertContainer;
                            ctrlSA.ExecuteAlert(out alertContainer, ModuleInfo.ModuleID, ModuleInfo.SubModule);

                            var rows = alertContainer.DataTable.Rows;

                            if (rows.Count > 0)
                            {
                                m_LastResultRow = alertContainer.DataTable.Rows[0];
                            }
                        }
                    }
                    catch (FaultException ex)
                    {
                        m_LastException = ex;
                    }
                    catch (Exception ex)
                    {
                        m_LastException = ErrorUtils.CreateErrorWithSubMessage(ERR_SYSTEM.ERR_SYSTEM_UNKNOWN, ex.Message);
                    }

                    CurrentThread.ExecuteUpdateGUI();
                    Thread.Sleep(AlertInfo.SleepTime);
                }
            }, MainProcess.GetMainForm());
            CurrentThread.DoUpdateGUI += CurrentThread_DoUpdateGUI;
            CurrentThread.Start();
        }
Beispiel #5
0
        public static void ShowError(string title, FaultException ex, Control owner)
        {
            if (ex.Code.Name == ERR_SYSTEM.ERR_SYSTEM_MODULE_SINGLE_INSTANCE.ToString())
            {
                return;
            }

            if (App.Environment.ClientInfo.SessionKey != null)
            {
                if (int.Parse(ex.Code.Name) == ERR_SYSTEM.ERR_SYSTEM_SESSION_TERMINATED_BY_ADMIN ||
                    int.Parse(ex.Code.Name) == ERR_SYSTEM.ERR_SYSTEM_SESSION_NOT_EXISTS_OR_DUPLICATE ||
                    int.Parse(ex.Code.Name) == ERR_SYSTEM.ERR_SYSTEM_SESSION_TERMINATED_BY_SELF)
                {
                    MainProcess.LogoutFromSystem(false);

                    App.Environment.ClientInfo.UserName   = null;
                    App.Environment.ClientInfo.SessionKey = null;

                    MainProcess.ShowLogin();
                    return;
                }
            }

            if (owner == null || owner.IsDisposed || owner.Disposing)
            {
                var frmMain = MainProcess.GetMainForm();
                if (frmMain != null && !frmMain.IsDisposed && !frmMain.Disposing)
                {
                    ShowError(title, ex, frmMain);
                }
                else
                {
                    EventLog.WriteEntry(
                        "IMSS.Client",
                        string.Format("{0}\r\n{1}", ex.ToMessage(), ex.Reason),
                        EventLogEntryType.Error);
                }
                return;
            }

            if (owner.InvokeRequired)
            {
                owner.Invoke(new ShowErrorInfoInvoker(ShowError), title, ex, owner);
                return;
            }

            if (!owner.InvokeRequired)
            {
                var frmDialog = new frmInfo
                {
                    Text        = title,
                    lbErrorInfo =
                    {
                        Text = string.Format("<b>{0}</b>\r\n{1}", ex.ToMessage(), ex.Reason)
                    }
                };
                if (ex.Code.Name == "101")
                {
                    try
                    {
                        File.AppendAllText("LastErrors.log", string.Format("{0}\r\n-------------\r\n", ex.Reason));
                    }
                    catch
                    {
                    }
                }

                frmDialog.ShowDialog(owner);
            }
        }