Ejemplo n.º 1
0
        private void btnSendEmail_Click(object sender, EventArgs e)
        {//角色列表
            if (rolesTable.Rows.Count == 0)
            {
                MsgBox.Show(LanguageResource.Language.Tip_PleaseSelectDataFile, LanguageResource.Language.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List <string> rids = new List <string>();

            foreach (DataRow item in rolesTable.Rows)
            {
                object column = item[LanguageResource.Language.Map_RoleNo];
                if (column == null)
                {
                    continue;
                }
                string val = column.ToString().Trim();
                int    rid;
                if (int.TryParse(val, out rid))
                {
                    rids.Add(rid.ToString());
                }
            }
            GSSModel.SendEmailToRole send = new GSSModel.SendEmailToRole();
            send.ReceiveRoles = string.Join(",", rids.ToArray());
            if (string.IsNullOrEmpty(send.ReceiveRoles))
            {
                MsgBox.Show(LanguageResource.Language.Tip_PleaseSetEmailReceiver, LanguageResource.Language.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            BtnSendEmail(send);
        }
Ejemplo n.º 2
0
        private void BtnSendEmail(GSSModel.SendEmailToRole roles)
        {
            roles.Head = rtbEmailHead.Text;
            roles.Body = rtbEmailBody.Text;
            if (cbHavaEquip.Checked)
            {
                int temp;
                temp           = int.Parse(txtEquipID.Text);
                roles.EquipId  = temp;
                temp           = int.Parse(txtEquipSizeOf.Text);
                roles.EquipNum = temp;
            }
            string        id       = cmbBigZone.GetComboBoxSelectValue();//必须选择大区和战区
            bool          lackItem = true;
            StringBuilder sb       = new StringBuilder();

            if (!string.IsNullOrEmpty(id))
            {
                roles.BigZoneId = int.Parse(id);
                id = cmbZone.GetComboBoxSelectValue();
                if (!string.IsNullOrEmpty(id))
                {
                    lackItem     = false;
                    roles.ZoneId = int.Parse(id);
                }
            }
            if (lackItem)
            {
                sb.AppendLine(LanguageResource.Language.Tip_PleaseSelectBigZoneAndZone);
            }
            if (string.IsNullOrEmpty(roles.Head) || string.IsNullOrEmpty(roles.Body))
            {
                sb.AppendLine(LanguageResource.Language.Tip_EmailInfoIsRequired);
            }
            if (!string.IsNullOrEmpty(sb.ToString()))
            {
                MsgBox.Show(sb.ToString(), LanguageResource.Language.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            roles.StartTime = dtpStartTime.Value;
            roles.EndTime   = dtpEndTime.Value;
            if (roles.StartTime > roles.EndTime)
            {
                MsgBox.Show(LanguageResource.Language.Tip_StartTimeShouldLessEndTime, LanguageResource.Language.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //由于导入的角色数据不可控,此处不进行工单建立
            int formId = this.Handle.ToInt32();

            GSSModel.Request.ClientData data = new GSSModel.Request.ClientData()
            {
                FormID = formId, Data = roles
            };
            Client.SendEmail(formId, data);
        }
Ejemplo n.º 3
0
        public static string SetRolesEmail(GSSModel.SendEmailToRole email)
        {
            //读取MySQL匹配的连接串[此处返回错误码]
            string linkName   = string.Format("LKSV_GSS_3_gsdata_db_{0}_{1}", email.BigZoneId, email.ZoneId);
            string error      = string.Empty;
            string connString = QueryMysqlLinkConnString(linkName, ref error);

            if (!string.IsNullOrEmpty(error))
            {
                return(error);
            }
            string filter = FilterDBConnString(connString);

            //查询目前数据库中最大的ID
            DbHelperMySQLP.connectionString = filter;
            //DbHelperMySQLP db = new DbHelperMySQLP(connString);
            string queryIdCmd = "select MAX(mail_id) from maillist_table";

            DbHelperMySQL.connectionString = filter;
            DataSet           ds   = DbHelperMySQL.Query(queryIdCmd);
            DataRowCollection rows = ds.Tables[0].Rows;
            //此处不考虑连接失败的情况
            long id = 1;

            if (rows.Count > 0)
            {
                object obj = rows[0][0];
                string mid = obj == null ? string.Empty : obj.ToString();
                if (!string.IsNullOrEmpty(mid))//该列数据存储不是为null
                {
                    id = long.Parse(mid);
                }
            }
            string[]    rids  = email.ReceiveRoles.Split(',');
            List <byte> item1 = new List <byte>();

            if (email.EquipNum > 0)
            {
                item1.AddRange(BitConverter.GetBytes(email.EquipNum));
                item1.AddRange(BitConverter.GetBytes(email.EquipId));
            }
            StringBuilder sbs = new StringBuilder();

            foreach (byte item in item1)
            {
                string i = item.ToString("X2");
                sbs.Append(i);
            }
            for (int i = 0; i < rids.Length; i++)
            {                                                                  //MySQL 此处提供参数不能使用【底层代码需要进行确认】
                List <byte> checkdata = new List <byte>();
                checkdata.AddRange(BitConverter.GetBytes(0));                  //第一项4字节int
                checkdata.AddRange(BitConverter.GetBytes((byte)0));            //第二项byte
                checkdata.AddRange(BitConverter.GetBytes(0));                  //第三项4字节int
                checkdata.AddRange(BitConverter.GetBytes(int.Parse(rids[i]))); //第四项2字节word
                checkdata.AddRange(BitConverter.GetBytes(0));                  //第五项4字节int
                checkdata.AddRange(BitConverter.GetBytes((byte)3));            //第六项?? mailtype
                checkdata.AddRange(BitConverter.GetBytes((short)0));           //第七项 已读状态 byte[wstate]
                checkdata.AddRange(BitConverter.GetBytes((byte)0));            //第八项 byte
                checkdata.AddRange(BitConverter.GetBytes(0));                  //第九项 byte
                StringBuilder checkDataStr = new StringBuilder();
                foreach (byte item in checkdata)
                {
                    string cd = item.ToString("X2");
                    checkDataStr.Append(cd);
                }
                string cmd = @"insert into maillist_table(Mail_ID,Mail_Title,Mail_Content,Mail_TYPE,Receiver_ID,Sender_ID,Sender_Name,Send_Time,Invalid_Time,State_Modi_Time,Item_Num,item1,checkData)  
                values (" + (id + i + 1) + ",'" + email.Head + "','" + email.Body + "',3," + rids[i] + ",-1,'GSSClient','" + email.StartTime + "','" + email.EndTime + "','"
                             + DateTime.Now + "'," + email.EquipNum + ",{0},0x{1})";
                string equip = sbs.ToString();
                if (string.IsNullOrEmpty(equip))
                {
                    equip = "null";
                }
                else
                {
                    equip = "0x" + equip;
                }
                cmd = string.Format(cmd, equip, checkDataStr.ToString());
                try
                {
                    DbHelperMySQLP.connectionString = filter;
                    int result = DbHelperMySQLP.ExecuteSql(cmd);
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
            return(string.Empty);
        }