Esempio n. 1
0
 private bool CheckUpdateLocation()
 {
     foreach (BL.Configuration.RegisteredCompany company in config.RegisteredCompanies)
     {
         //If there is and update and you are not logging into the Company set as update site then return
         if (company.UpdateSite == true && company.Name != config.RegisteredCompanies[grvCompany.FocusedRowHandle].Name)
         {
             return(BaseAlert.ShowAlert("Wrong Update Site", "You are logging into a site that has a update but is not the default update site.\n" +
                                        "Do you want to continue ?", BaseAlert.Buttons.OkCancel, BaseAlert.Icons.Warning) == System.Windows.Forms.DialogResult.OK);
         }
     }
     return(true);
 }
Esempio n. 2
0
        int SendMail(string strSubject, string strBody, int how)
        {
            MapiMessage msg = new MapiMessage();

            msg.subject  = strSubject;
            msg.noteText = strBody;

            msg.recips = GetRecipients(out msg.recipCount);
            msg.files  = GetAttachments(out msg.fileCount);

            m_lastError = MAPISendMail(new IntPtr(0), new IntPtr(0), msg, how,
                                       0);
            if (m_lastError > 1)
            {
                BaseAlert.ShowAlert("Mail send failure", GetLastError(), BaseAlert.Buttons.Ok, BaseAlert.Icons.Error);
            }

            Cleanup(ref msg);
            return(m_lastError);
        }
Esempio n. 3
0
        /// <summary>
        /// Checks if Code exists.
        /// </summary>
        /// <returns>Boolean values indicating weather conditions have been met.</returns>
        /// <remarks>Created: Werner Scheffer 23/05/2012</remarks>
        private bool IsCodeValid()
        {
            try
            {
                bool isValid = true;
                isValid = !DataContext.EntitySecurityContext.SEC_Role.Any(n => n.Id != ((DB.SEC_Role)BindingSource.DataSource).Id && n.Code == ((DB.SEC_Role)BindingSource.DataSource).Code);
                if (!isValid)
                {
                    BaseAlert.ShowAlert("Invalid Code", "The code you have entered already exists enter another Code.", BaseAlert.Buttons.Ok, BaseAlert.Icons.Error);
                }

                return(isValid);
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                if (BaseAlert.ShowAlert("Remove Company Connection", "You are about to permanently remove the selected Company Connection.\nAre you certain you wish to continue?", BaseAlert.Buttons.OkCancel, BaseAlert.Icons.Warning) == System.Windows.Forms.DialogResult.OK)
                {
                    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    BL.Configuration.CompleteDistributionConfig section = config.GetSection("CompleteDistributionConfig") as BL.Configuration.CompleteDistributionConfig;

                    section.RegisteredCompanies.RemoveCompany(SelectedCompanyName);
                    config.Save(ConfigurationSaveMode.Modified);

                    // Refresh Connection list
                    Application.Restart();
                }
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
        }
Esempio n. 5
0
        public QueryAlertRuleResult QueryAlertRule(AccessControl AccessInformation, AlertRuleQueryCondition QueryCondition)
        {
            QueryAlertRuleResult Result = new QueryAlertRuleResult();
            string estr = "";
            bool ret = true;
            while (ret)
            {
                ret = GetAccessControlInformation(AccessInformation);
                if (!ret)
                {
                    estr = "";
                    break;
                }

                ret = GetAlertRuleQueryCondition(QueryCondition);
                if (!ret)
                {
                    estr = "";
                    break;
                }
                break;
            }

            if (ret)
            {
                string strServer = "localhost";
                string strUser = "******";

                if (AccessInformation.LimitServer)
                {
                    strServer = AccessInformation.SVDBServer;
                }

                if (AccessInformation.LimitUser)
                {
                    strUser = AccessInformation.UserID;
                }
                if (this.iniFile == null)
                {
                    this.iniFile = new IniFileDaoImpl();
                }
                IDictionary<string, NameValueCollection> sectionlists = this.iniFile.GetIniFile("alert.ini");
                BaseAlert[] baseAlerts = new BaseAlert[sectionlists.Count];
                int i = 0;
                foreach (string key in sectionlists.Keys)
                {
                    baseAlerts[i] = GetIniBaseAlertInfo(key, sectionlists);
                    i = i + 1;
                }
                Result.ResponseData = baseAlerts;
            }

            Result.ErrorInformation = estr;
            Result.QueryAlertRuleOK = ret;

            return Result;
        }
Esempio n. 6
0
        public DeleteAlertResult DeleteAlert(AccessControl AccessInformation, BaseAlert AlertInformation)
        {
            DeleteAlertResult Result = new DeleteAlertResult();
            string estr = "";
            bool ret = true;
            string strServer = "";
            string strUser = "";

            while (ret)
            {

                ret = GetAccessControlInformation(AccessInformation);
                if (!ret)
                {
                    estr = keytext[ErrorInfo.AccessControlError.ToString()];
                }

                strServer = "localhost";
                strUser = "******";

                if (AccessInformation.LimitServer)
                {
                    strServer = AccessInformation.SVDBServer;
                }

                if (AccessInformation.LimitUser)
                {
                    strUser = AccessInformation.UserID;
                }
                if (this.iniFile == null)
                {
                    this.iniFile = new IniFileDaoImpl();
                }
                this.iniFile.DeleteIniFileBySection("alert.ini", AlertInformation.ID);

                if (queue == null)
                {
                    this.queue = new QueueDaoImpl();
                }
                //send message to service
                bool meseagebool = this.queue.PushStringMessage("SiteView70-Alert", "IniChange", "alert.ini," + AlertInformation.ID + ",DELETE");

                if (!meseagebool)
                {
                    estr = keytext[ErrorInfo.PushMessageError.ToString()];
                }

                break;
            }
            Result.ErrorInformation = estr;
            Result.DeleteAlertOK = ret;
            return Result;
        }
Esempio n. 7
0
        /// <summary>
        /// ����BaseAlert��Ϣ
        /// </summary>
        /// <param name="alertInfo"></param>
        /// <param name="estr"></param>
        /// <returns></returns>
        bool SetIniBaseAlertInfo(AccessControl AccessInformation, BaseAlert alertInfo, string estr)
        {
            bool ret = true;

            while (ret)
            {

                string strTemp;

                string strAlertIndex = alertInfo.ID;

                string strServer = "localhost";
                string strUser = "******";

                if (AccessInformation.LimitServer)
                {
                    strServer = AccessInformation.SVDBServer;
                }

                if (AccessInformation.LimitUser)
                {
                    strUser = AccessInformation.UserID;
                }

                if (string.IsNullOrEmpty(strAlertIndex))
                {
                    ret = false;
                    estr = keytext[ErrorInfo.AlertIDError.ToString()];
                    break;
                }

                if (this.iniFile == null)
                {
                    this.iniFile = new IniFileDaoImpl();
                }

                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "nIndex", alertInfo.ID);
                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertTarget", alertInfo.Target);
                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertName", alertInfo.Name);

                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertType", alertInfo.Type.ToString());

                if (alertInfo.Category == AlertCategory.Normal)
                {
                    strTemp = "����";
                }
                else if (alertInfo.Category == AlertCategory.Danger)
                {
                    strTemp = "��";
                }
                else if (alertInfo.Category == AlertCategory.Error)
                {
                    strTemp = "����";
                }
                else
                {
                    //�����֧�߲�����·��AlertCategoryError
                    ret = false;
                    estr = keytext[ErrorInfo.AlertCategoryError.ToString()];
                    break;
                }
                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertCategory", strTemp);
                this.iniFile.WriteIniFileInt("alert.ini", strAlertIndex, "AlertCond", alertInfo.Times.GetHashCode());

                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlwaysTimes", "1");
                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "OnlyTimes", "1");
                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SelTimes1", "2");
                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SelTimes2", "3");

                if (alertInfo.Times == AlertTimes.Always)
                {

                    if (!IsAlphaNumber(alertInfo.Always))
                    {//AlertAlwaysError AlertOnlyError
                        ret = false;
                        estr = keytext[ErrorInfo.AlertAlwaysError.ToString()];
                        break;
                    }
                    this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlwaysTimes", alertInfo.Always);

                }
                else if (alertInfo.Times == AlertTimes.Only)
                {

                    if (!IsAlphaNumber(alertInfo.Only))
                    {
                        ret = false;
                        estr = keytext[ErrorInfo.AlertOnlyError.ToString()];
                        break;
                    }
                    this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlwaysTimes", alertInfo.Only);
                }
                else
                {

                    if (!IsAlphaNumber(alertInfo.Select1))
                    {//
                        ret = false;
                        estr = keytext[ErrorInfo.AlertSelect1Error.ToString()];
                        break;
                    }
                    this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SelTimes1", alertInfo.Select1);

                    if (!IsAlphaNumber(alertInfo.Select2))
                    {
                        ret = false;
                        estr = keytext[ErrorInfo.AlertSelect2Error.ToString()];
                        break;
                    }
                    this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SelTimes2", alertInfo.Select2);
                }

                if (alertInfo.State == AlertState.Enable)
                {
                    strTemp = "Enable";
                }
                else
                {
                    strTemp = "��ֹ";
                }
                this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertState", strTemp);

                break;
            }

            return ret;
        }
Esempio n. 8
0
        /// <summary>
        /// ���û�����Ϣ
        /// </summary>
        /// <param name="AlertIndex"></param>
        /// <param name="sectionlists"></param>
        /// <returns></returns>
        private BaseAlert GetIniBaseAlertInfo(string AlertIndex, IDictionary<string, NameValueCollection> sectionlists)
        {
            BaseAlert baseAlert = new BaseAlert();
            baseAlert.ID = AlertIndex;
            baseAlert.Name = string.IsNullOrEmpty(sectionlists[AlertIndex]["AlertName"]) ? "" : sectionlists[AlertIndex]["AlertName"];
            baseAlert.Only = string.IsNullOrEmpty(sectionlists[AlertIndex]["OnlyTimes"]) ? "" : sectionlists[AlertIndex]["OnlyTimes"];
            baseAlert.Select1 = string.IsNullOrEmpty(sectionlists[AlertIndex]["SelTimes1"]) ? "" : sectionlists[AlertIndex]["SelTimes1"];
            baseAlert.Select2 = string.IsNullOrEmpty(sectionlists[AlertIndex]["SelTimes2"]) ? "" : sectionlists[AlertIndex]["SelTimes2"];
            if (string.IsNullOrEmpty(sectionlists[AlertIndex]["AlertState"]))
            {
                baseAlert.State = AlertState.Enable;
            }
            else
            {
                baseAlert.State = sectionlists[AlertIndex]["AlertState"].ToLower() == "enable" ? AlertState.Enable : AlertState.Disable;
            }
            baseAlert.Target = string.IsNullOrEmpty(sectionlists[AlertIndex]["AlertTarget"]) ? "" : sectionlists[AlertIndex]["AlertTarget"];
            string times = "";
            if (string.IsNullOrEmpty(sectionlists[AlertIndex]["AlertCond"]))
            {
                times = "1";
            }
            else
            {
                times = sectionlists[AlertIndex]["AlertCond"];
            }
            switch (times)
            {
                case "1":
                    baseAlert.Times = AlertTimes.Always;
                    break;
                case "2":
                    baseAlert.Times = AlertTimes.Only;
                    break;
                case "3":
                    baseAlert.Times = AlertTimes.Select;
                    break;
            }

            string stye = "EmailAlert";
            if (string.IsNullOrEmpty(sectionlists[AlertIndex]["AlertType"]))
            {
                stye = "EmailAlert";
            }
            else
            {
                stye = sectionlists[AlertIndex]["AlertType"];
            }
            switch (stye)
            {
                case "EmailAlert":
                    baseAlert.Type = AlertType.EmailAlert;
                    break;
                case "SmsAlert":
                    baseAlert.Type = AlertType.SmsAlert;
                    break;
                case "ScriptAlert":
                    baseAlert.Type = AlertType.ScriptAlert;
                    break;
                case "SoundAlert":
                    baseAlert.Type = AlertType.SoundAlert;
                    break;

            }

            baseAlert.Always = string.IsNullOrEmpty(sectionlists[AlertIndex]["AlwaysTimes"]) ? "" : sectionlists[AlertIndex]["AlwaysTimes"];
            string category = "";
            if (string.IsNullOrEmpty(sectionlists[AlertIndex]["AlertCategory"]))
            {
                category = "����";
            }
            else
            {
                category = sectionlists[AlertIndex]["AlertCategory"];
            }
            switch (category)
            {
                case "����":
                    baseAlert.Category = AlertCategory.Normal;
                    break;
                case "��":
                    baseAlert.Category = AlertCategory.Danger;
                    break;
                case "����":
                    baseAlert.Category = AlertCategory.Error;
                    break;
            }
            return baseAlert;
        }