Exemple #1
0
        private void SendMail(BenQGuru.eMES.Domain.Alert.Alert alert)
        {
            BenQGuru.eMES.Web.Helper.ESmtpMail mail = this.GetNewMail();

            //收件人
            BenQGuru.eMES.BaseSetting.UserFacade userfacade = new BenQGuru.eMES.BaseSetting.UserFacade(DataProvider);

            int recipientCount = 0;

            foreach (ListItem li in this.lstUser.Items)
            {
                if (li.Value != null && li.Value != string.Empty)
                {
                    BenQGuru.eMES.Domain.BaseSetting.User user = userfacade.GetUser(li.Value) as BenQGuru.eMES.Domain.BaseSetting.User;
                    if (user != null && user.UserEmail != null && user.UserEmail != string.Empty && user.UserEmail.IndexOf("@") != -1)
                    {
                        mail.AddRecipient(user.UserName, user.UserEmail);
                        recipientCount++;
                    }
                }
            }

            if (recipientCount > 0)
            {
                mail.Body = alert.AlertMsg;

                if (!mail.Send())
                {
                    BenQGuru.eMES.Common.ExceptionManager.Raise(this.GetType(), mail.ErrorMessage);
                }
            }
        }
Exemple #2
0
        private void LoadData()
        {
            BenQGuru.eMES.Domain.Alert.Alert alert = (BenQGuru.eMES.Domain.Alert.Alert) this._alertFacade.GetAlert(this._alertID);
            if (alert != null)
            {
                this.drpAlertLevel.SelectedValue = alert.AlertLevel;
                this.txtAlertMsg.Text            = alert.AlertMsg;
                this.txtDesc.Text          = alert.Description;
                this.chbMailNotify.Checked = (alert.MailNotify == "Y");

//				//load 用户
//				if(this.chbMailNotify.Checked)
//				{
                object[] objs = _alertFacade.QueryAlertManualNotifier(alert.AlertID);
                if (objs != null)
                {
                    foreach (object obj in objs)
                    {
                        BenQGuru.eMES.Domain.Alert.AlertManualNotifier notifier = obj as BenQGuru.eMES.Domain.Alert.AlertManualNotifier;
                        if (notifier == null)
                        {
                            continue;
                        }

                        BenQGuru.eMES.Domain.BaseSetting.User user = _userfacade.GetUser(notifier.UserCode) as BenQGuru.eMES.Domain.BaseSetting.User;
                        if (user != null && user.UserEmail != null)
                        {
                            this.lstUser.Items.Add(new ListItem(user.UserCode + "(" + user.UserEmail + ")", user.UserCode));
                        }
                    }
                }
                //}
            }
        }
Exemple #3
0
        private void SaveData()
        {
            try
            {
                DataProvider.BeginTransaction();

                BenQGuru.eMES.Domain.Alert.Alert alert = this._alertFacade.GetAlert(this._alertID) as BenQGuru.eMES.Domain.Alert.Alert;
                if (alert != null)
                {
                    alert.AlertLevel   = this.drpAlertLevel.SelectedValue;
                    alert.AlertStatus  = this.drpAlertStatus.SelectedValue;
                    alert.Description  = this.txtDesc.Text;
                    alert.MaintainUser = this.GetUserCode();
                    alert.MaintainDate = FormatHelper.TODateInt(DateTime.Now.ToShortDateString());
                    alert.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                    _alertFacade.UpdateAlert(alert);

                    //写处理记录表
                    BenQGuru.eMES.Domain.Alert.AlertHandleLog log = this._alertFacade.CreateNewAlertHandleLog();
                    log.AlertID     = alert.AlertID;
                    log.AlertLevel  = alert.AlertLevel;
                    log.AlertStatus = alert.AlertStatus;
                    log.HandleUser  = alert.MaintainUser;
                    log.HandleDate  = alert.MaintainDate;
                    log.HandleTime  = alert.MaintainTime;
                    log.HandleMsg   = alert.Description;
                    log.HandleSeq   = _alertFacade.GetNextHandleSeq(alert.AlertID);

                    BenQGuru.eMES.BaseSetting.UserFacade  userfacade = new BenQGuru.eMES.BaseSetting.UserFacade(DataProvider);
                    BenQGuru.eMES.Domain.BaseSetting.User user       = userfacade.GetUser(log.HandleUser) as BenQGuru.eMES.Domain.BaseSetting.User;
                    if (user != null)
                    {
                        log.UserEmail = user.UserEmail;
                    }

                    _alertFacade.AddAlertHandleLog(log);
                }

                DataProvider.CommitTransaction();
            }
            catch (System.Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                throw ex;
            }
        }
Exemple #4
0
        private void LoadData()
        {
            BenQGuru.eMES.Domain.Alert.Alert alert = this._alertFacade.GetAlert(this._alertID) as BenQGuru.eMES.Domain.Alert.Alert;
            if (alert != null)
            {
                this.txtAlertType.Text = _alertConst.GetName(alert.AlertType);
                this.txtAlertItem.Text = _alertConst.GetName(alert.AlertItem);
                if (this.txtAlertItem.Text != null && this.txtAlertItem.Text != string.Empty)
                {
                    this.lblAlertEdit.Text = this.lblAlertEdit.Text + txtAlertItem.Text;
                }
                else
                {
                    this.lblAlertEdit.Text = this.lblAlertEdit.Text + "项值";
                }

                this.txtAlertItemValue.Text = alert.ItemCode;
                this.txtAlertDate.Text      = FormatHelper.ToDateString(alert.AlertDate);
                this.txtAlertTime.Text      = FormatHelper.ToTimeString(alert.AlertTime);
                this.txtAlertValue.Text     = alert.AlertValue.ToString();

                this.txtSendUser.Text = alert.SendUser;
                if (alert.AlertStatus != null && alert.AlertStatus != string.Empty)
                {
                    this.drpAlertStatus.SelectedValue = alert.AlertStatus;
                }

                if (alert.AlertLevel != null && alert.AlertLevel != string.Empty)
                {
                    this.drpAlertLevel.SelectedValue = alert.AlertLevel;
                }

                this.txtAlertMsg.Text = alert.AlertMsg;
                this.txtDesc.Text     = alert.Description;
            }
        }
Exemple #5
0
        private void SaveData()
        {
            try
            {
                DataProvider.BeginTransaction();

                BenQGuru.eMES.Domain.Alert.Alert alert = null;
                if (_actionType == "add")
                {
                    alert = _alertFacade.CreateNewAlert();
                    //alert.AlertID = _alertFacade.GetNextAlertID();
                    alert.ItemCode    = string.Empty;
                    alert.AlertItem   = string.Empty;
                    alert.AlertStatus = BenQGuru.eMES.AlertModel.AlertStatus_Old.Unhandled;
                    alert.AlertType   = BenQGuru.eMES.AlertModel.AlertType_Old.Manual;
                }
                else
                {
                    alert = (BenQGuru.eMES.Domain.Alert.Alert)_alertFacade.GetAlert(this._alertID);
                }

                alert.MaintainDate = BenQGuru.eMES.Web.Helper.FormatHelper.TODateInt(DateTime.Now);
                alert.MaintainUser = this.GetUserCode();
                alert.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                alert.SendUser     = alert.MaintainUser;
                alert.AlertDate    = alert.MaintainDate;
                alert.AlertTime    = alert.MaintainTime;

                alert.AlertLevel  = this.drpAlertLevel.SelectedValue;
                alert.AlertMsg    = this.txtAlertMsg.Text;
                alert.Description = this.txtDesc.Text;
                alert.MailNotify  = this.chbMailNotify.Checked?"Y":"N";
                alert.AlertValue  = 0;

                if (this._actionType == "add")
                {
                    _alertFacade.AddAlert(alert);
                }
                else
                {
                    _alertFacade.UpdateAlert(alert);
                }

                //增加接收人
                //if(alert != null)
                //{
                object[] objs = _alertFacade.QueryAlertManualNotifier(alert.AlertID);
                if (objs != null)
                {
                    foreach (object obj in objs)
                    {
                        BenQGuru.eMES.Domain.Alert.AlertManualNotifier an = obj as BenQGuru.eMES.Domain.Alert.AlertManualNotifier;
                        if (an != null)
                        {
                            _alertFacade.DeleteAlertManualNotifier(an);
                        }
                    }
                }
                //}

                //if(this.chbMailNotify.Checked)
                //{
                for (int i = 0; i < this.lstUser.Items.Count; i++)
                {
                    if (this.lstUser.Items[i].Value != string.Empty)
                    {
                        BenQGuru.eMES.Domain.Alert.AlertManualNotifier an = new BenQGuru.eMES.Domain.Alert.AlertManualNotifier();
                        an.AlertID  = Convert.ToInt32(alert.AlertID);
                        an.UserCode = this.lstUser.Items[i].Value;
                        _alertFacade.AddAlertManualNotifier(an);
                    }
                }
                //}

                if (this.chbMailNotify.Checked)
                {
                    this.SendMail(alert);
                }

                DataProvider.CommitTransaction();
            }
            catch (System.Exception ex)
            {
                DataProvider.RollbackTransaction();
                throw ex;
            }
        }
Exemple #6
0
        private void btnConfirm_Click(object sender, System.EventArgs e)
        {
            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

                Messages msg = new Messages();
                if (this.txtAlertMsg.InnerTextBox.Text.Trim() == string.Empty)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, this.txtAlertMsg.Caption + " $Error_Input_Empty"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }

                if (this.txtMOCode.InnerTextBox.Text.Trim() == string.Empty)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, this.txtMOCode.Caption + " $Error_Input_Empty"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    this.txtMOCode.TextFocus(false, true);
                    return;
                }

                //根据工单得到产品代码
                BenQGuru.eMES.MOModel.MOFacade  moFacade = new MOFacade(this.DataProvider);
                BenQGuru.eMES.Domain.MOModel.MO mo       = moFacade.GetMO(this.txtMOCode.InnerTextBox.Text.Trim()) as BenQGuru.eMES.Domain.MOModel.MO;
                string productcode;
                if (mo != null)
                {
                    productcode = mo.ItemCode;
                }
                else
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$ManualAlert_MOCode_Error"));                    //工单号码输入错误
                    ApplicationRun.GetInfoForm().Add(msg);
                    this.txtMOCode.TextFocus(false, true);
                    return;
                }
                try
                {
                    DataProvider.BeginTransaction();

                    BenQGuru.eMES.AlertModel.AlertFacade facade = new BenQGuru.eMES.AlertModel.AlertFacade(DataProvider);
                    BenQGuru.eMES.Domain.Alert.Alert     alert  = facade.CreateNewAlert();

                    alert.ItemCode    = string.Empty;
                    alert.AlertItem   = string.Empty;
                    alert.AlertStatus = BenQGuru.eMES.AlertModel.AlertStatus_Old.Unhandled;
                    alert.AlertType   = BenQGuru.eMES.AlertModel.AlertType_Old.Manual;

                    //Laws Lu,2006/11/13 uniform system collect date
                    DBDateTime dbDateTime;

                    dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);


                    alert.MaintainDate = dbDateTime.DBDate;
                    alert.MaintainUser = ApplicationService.Current().UserCode;
                    alert.MaintainTime = dbDateTime.DBTime;

                    alert.AlertLevel  = this._levelDict[this.cbAlertLevel.ComboBoxData.SelectedItem.ToString()];
                    alert.AlertMsg    = ApplicationService.Current().ResourceCode + ":" + this.txtAlertMsg.InnerTextBox.Text;
                    alert.Description = string.Empty;
                    alert.MailNotify  = "N";
                    alert.AlertValue  = 0;

                    alert.ProductCode = productcode;
                    //单得到产线代码
                    BenQGuru.eMES.BaseSetting.BaseModelFacade baseFacade = new BenQGuru.eMES.BaseSetting.BaseModelFacade(this.DataProvider);
                    Resource res = baseFacade.GetResource(ApplicationService.Current().ResourceCode) as Resource;
                    if (res != null)
                    {
                        alert.SSCode = res.StepSequenceCode;
                    }

                    alert.AlertMsg = this.txtAlertMsg.InnerTextBox.Text + "," +
                                     "产品: " +
                                     alert.ProductCode +
                                     ", 资源: " + ApplicationService.Current().ResourceCode;
                    facade.AddAlert(alert);

                    DataProvider.CommitTransaction();

                    msg.Add(new UserControl.Message(MessageType.Success, "$ManualAlert_Add_Success"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    this.txtAlertMsg.InnerTextBox.Text = string.Empty;

                    //刷新Sample
                    //RefreshSample();
                }
                catch (System.Exception ex)
                {
                    DataProvider.RollbackTransaction();
                    msg.Add(new UserControl.Message(MessageType.Error, ex.Message));
                    ApplicationRun.GetInfoForm().Add(msg);
                }
            }
            finally
            {
                this.Cursor = System.Windows.Forms.Cursors.Default;
                this.CloseConnection();
            }
        }