Example #1
0
 /// <summary>
 /// 根据角色Id获取菜单信息
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public string[] GetMenuInfoList(string id)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(id))
         {
             throw new Exception("角色Id不能为空!");
         }
         DataTable dt = _sql.Query("SELECT MenuInfoId FROM MenuInRole WITH(Nolock) WHERE IsDeleted = 0 AND RoleInfoId = @id", new Dictionary <string, object> {
             { "@id", id }
         });
         if (dt != null && dt.Rows.Count > 0)
         {
             string ids = string.Empty;
             foreach (DataRow row in dt.Rows)
             {
                 ids += Cast.ConToString(row["MenuInfoId"]) + ",";
             }
             return(ids.Substring(0, ids.Length - 1).Split(','));
         }
         else
         {
             return(new string[] { });
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         throw ex;
     }
 }
Example #2
0
 /// <summary>
 /// 根据角色Id获取角色编辑信息
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public RoleInfoEditModel GetRoleInfoById(string id)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(id))
         {
             throw new Exception("角色Id不能为空!");
         }
         RoleInfoEditModel result = new RoleInfoEditModel();
         DataTable         dt     = _sql.Query("SELECT RoleName,RoleCode FROM RoleInfo WHERE IsDeleted = 0 AND RoleInfoId = @id", new Dictionary <string, object> {
             { "@id", id }
         });
         if (dt != null && dt.Rows.Count > 0)
         {
             result.RoleInfoId = id;
             result.RoleName   = Cast.ConToString(dt.Rows[0]["RoleName"]);
             result.RoleCode   = Cast.ConToString(dt.Rows[0]["RoleCode"]);
         }
         return(result);
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         throw ex;
     }
 }
Example #3
0
        /// <summary>
        /// 发送消息给特定用户
        /// </summary>
        /// <param name="sendaccount"></param>
        /// <param name="sendname"></param>
        /// <param name="receiveid"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task SendMessageToUser(string sendaccount, string sendname, string receiveid, string message)
        {
            string cacheKey = Constants.Redis_Chat_Prefix + receiveid.ToUpper();
            string userid   = Cast.ConToString(CacheHelper.Get(cacheKey));

            if (string.IsNullOrEmpty(userid))
            {
                throw new Exception("接收用户不在线,请稍后!");
            }
            await Clients.User(userid).SendAsync("UserReceiveMessage", sendaccount, sendname, message);
        }
Example #4
0
 /// <summary>
 /// 获取系统参数值
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public string GetSystemParamValue(string name)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(name))
         {
             return("");
         }
         DataTable dt = _sql.Query("SELECT ParamValue FROM SystemParam WHERE ParamName = @name", new Dictionary <string, object> {
             { "@name", name }
         });
         if (dt == null || dt.Rows.Count == 0)
         {
             return("");
         }
         return(Cast.ConToString(dt.Rows[0]["ParamValue"]));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #5
0
 /// <summary>
 /// 打包附件下载
 /// </summary>
 /// <param name="ids"></param>
 /// <returns></returns>
 public byte[] DownloadZip(string[] ids)
 {
     try
     {
         if (ids == null || ids.Length == 0)
         {
             throw new Exception("请选择待下载附件!");
         }
         string sql      = "SELECT FilePath,FileName FROM Attachment WHERE AttachmentId IN ($condition$)";
         string conditon = "";
         Dictionary <string, object> paramList = new Dictionary <string, object>();
         int count = 1;
         foreach (string id in ids)
         {
             conditon += "@id" + count + ",";
             paramList.Add("@id" + count, id);
             count++;
         }
         sql = sql.Replace("$condition$", conditon.Remove(conditon.Length - 1));
         DataTable dt = _sql.Query(sql, paramList);
         Dictionary <string, string> list = new Dictionary <string, string>();
         if (dt != null && dt.Rows.Count > 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 list.Add(Cast.ConToString(row["FilePath"]), Cast.ConToString(row["FileName"]));
             }
         }
         return(FileHelper.ZipFile(list));
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         throw ex;
     }
 }
Example #6
0
 /// <summary>
 /// 处理Job
 /// </summary>
 /// <param name="jobId"></param>
 /// <param name="operate"></param>
 /// <returns></returns>
 public string HandleJobAsync(string jobId, string operate)
 {
     try
     {
         JobInfo         job   = _sql.Search <JobInfo>(jobId);
         QuartzEditModel model = new QuartzEditModel();
         model.JobGroup = job.JobGroup;
         model.JobName  = job.JobName;
         model.JobDesc  = job.JobDesc;
         model.Cron     = job.Cron;
         model.CronDesc = job.CronDesc;
         model.JobClass = job.JobClass;
         DataTable dt = _sql.Query(@"SELECT t.TRIGGER_STATE 
                                     FROM QRTZ_TRIGGERS t WITH(NOLOCK)
                                     WHERE t.JOB_GROUP = @group AND t.JOB_NAME = @name", new Dictionary <string, object> {
             { "@group", job.JobGroup }, { "@name", job.JobName }
         });
         if ((dt == null || dt.Rows.Count == 0) && operate != Constants.JobStart)
         {
             throw new Exception("当前处理的JOB不存在!");
         }
         if (operate == Constants.JobPause)
         {
             if (Cast.ConToString(dt.Rows[0]["TRIGGER_STATE"]) != Constants.TriggerStateWaitting)
             {
                 throw new Exception("当前Job状态无法暂停!");
             }
             job.JobStatus = Constants.JobStatusPause;
         }
         else if (operate == Constants.JobResume)
         {
             if (Cast.ConToString(dt.Rows[0]["TRIGGER_STATE"]) != Constants.TriggerStatePaused)
             {
                 throw new Exception("当前Job状态无法恢复!");
             }
             job.JobStatus = Constants.JobStatusRunning;
         }
         else if (operate == Constants.JobExcute)
         {
             if (Cast.ConToString(dt.Rows[0]["TRIGGER_STATE"]) != Constants.TriggerStatePaused)
             {
                 throw new Exception("请暂停后再执行Job!");
             }
         }
         else if (operate == Constants.JobStop)
         {
             job.JobStatus = Constants.JobStatusStop;
         }
         else if (operate == Constants.JobStart)
         {
             job.JobStatus = Constants.JobStatusRunning;
         }
         quartz.HandleJobAsync(operate, _config.Job_Assembly, model);
         _sql.OpenDb();
         _sql.Update(job);
         return(job.JobStatus);
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         throw new Exception(ex.Message);
     }
     finally
     {
         _sql.CloseDb();
     }
 }
Example #7
0
        /// <summary>
        /// 获取角色信息List
        /// </summary>
        /// <returns></returns>
        public UserListData GetUserList(List <SearchCondition> searchList, int pageIndex, int pageSize, string orderBy)
        {
            try
            {
                UserListData result = new UserListData();

                #region 初始化数据
                string sqlString = @"SELECT DISTINCT
                                            u.UserInfoId,
                                            u.Name    AS UserName,
                                            u.Account AS UserAccount,
                                            u.Email   AS UserEmail,
                                            CASE
                                              WHEN u.IsDeleted = 0 THEN '可用'
                                              ELSE '禁用'
                                            END       UserStatus
                                     FROM   UserInfo u
                                            LEFT JOIN UserInRole r
                                                   ON u.UserInfoId = r.UserInfoId
                                            LEFT JOIN RoleInfo uir
                                                   ON r.RoleInfoId = uir.RoleInfoId
                                     WHERE  1 = 1 
                                     ";
                Dictionary <string, object> paramList = new Dictionary <string, object>();
                #endregion

                #region 条件过滤
                if (searchList != null && searchList.Count > 0)
                {
                    searchList.ForEach(s =>
                    {
                        switch (s.Type)
                        {
                        case Constants.COMMON_SEARCHCONDITIONTYPE_EQUAL:
                            sqlString += string.Concat(" AND ", s.Table, s.Key, " = @", s.Key);
                            paramList.Add(string.Concat("@", s.Key), s.Value);
                            break;

                        case Constants.COMMON_SEARCHCONDITIONTYPE_LIKE:
                            sqlString += string.Concat(" AND ", s.Table, s.Key, " like @", s.Key);
                            paramList.Add(string.Concat("@", s.Key), s.Value + "%");
                            break;

                        case Constants.COMMON_SEARCHCONDITIONTYPE_RANGE:
                            if (s.Key.ToLower().Contains("after"))
                            {
                                sqlString += string.Concat(" AND ", s.Table, s.Key.Replace("after", ""), " >= @", s.Key);
                                paramList.Add(string.Concat("@", s.Key), Cast.ConToDateTime(s.Value).ToString("yyyy-MM-dd HH:mm:ss"));
                            }
                            else if (s.Key.ToLower().Contains("before"))
                            {
                                sqlString += string.Concat(" AND ", s.Table, s.Key.Replace("before", ""), " <= @", s.Key);
                                paramList.Add(string.Concat("@", s.Key), Cast.ConToDateTime(s.Value).AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"));
                            }
                            else
                            {
                                throw new Exception("调用的参数错误,无法认定区间起始:" + s.Value);
                            }
                            break;

                        case Constants.COMMON_SEARCHCONDITIONTYPE_CUSTOMER:
                            break;
                        }
                    });
                }
                #endregion

                #region 查询数据
                DataTable dtResult    = null;
                int       recordCount = 0;
                if (pageSize > 0 && pageIndex > 0)
                {
                    dtResult = _sql.Query(sqlString, paramList, orderBy, pageSize, pageIndex, out recordCount);
                }
                else
                {
                    sqlString += orderBy;
                    dtResult   = _sql.Query(sqlString, paramList);
                }
                #endregion

                #region 构建结果
                if (dtResult != null && dtResult.Rows.Count > 0)
                {
                    if (pageSize > 0 && pageIndex > 0)
                    {
                        result.RecordCount = recordCount;
                        result.RecordList  = dtResult.ToModelList <UserListModel>();
                        result.RecordList.ForEach(item =>
                        {
                            item.UserRoles  = GetUserRolesByUserId(item.UserInfoId);
                            DataTable dtLog = _sql.Query("SELECT TOP 1 LoginOn, ClientIp FROM tbl_loginlog WHERE UserInfoId = @userId Order By LoginOn DESC", new Dictionary <string, object> {
                                { "@userId", item.UserInfoId }
                            });
                            if (dtLog != null && dtLog.Rows.Count > 0)
                            {
                                item.LoginOn       = Cast.ConToDateTimeString(dtLog.Rows[0]["LoginOn"]);
                                item.LoginClientIp = Cast.ConToString(dtLog.Rows[0]["ClientIp"]);
                            }
                            try
                            {
                                item.LoginStatus = CacheHelper.Exists(Constants.Redis_Chat_Prefix + item.UserInfoId.ToUpper()) ? "在线" : "离线";
                            }
                            catch (Exception)
                            {
                                item.LoginStatus = "未知";
                            }
                        });
                    }
                    else
                    {
                        result.ExportBuffString = ExcelHelper.DownloadExcel(dtResult);
                        result.RecordCount      = dtResult.Rows.Count;
                    }
                }
                #endregion

                return(result);
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                throw ex;
            }
        }
Example #8
0
 /// <summary>
 /// 创建或更新菜单信息
 /// </summary>
 /// <param name="info">菜单编辑信息</param>
 /// <returns></returns>
 public string CreateOrUpdateMenuInfo(MenuInfoEditModel info)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(info.MenuName))
         {
             throw new Exception("菜单名称不能为空!");
         }
         if (string.IsNullOrWhiteSpace(info.MenuCode))
         {
             throw new Exception("菜单编码不能为空!");
         }
         if (string.IsNullOrWhiteSpace(info.MenuPath))
         {
             throw new Exception("菜单路径不能为空!");
         }
         if (Cast.ConToInt(info.MenuSeq) == 0)
         {
             throw new Exception("菜单排序不能为空!");
         }
         _sql.OpenDb();
         string   result = string.Empty;
         MenuInfo main   = new MenuInfo();
         info.FillTableWithModel <MenuInfo>(main);
         if (!string.IsNullOrEmpty(info.MenuInfoId))
         {
             if (main.MenuInfoId == main.PMenuId)
             {
                 throw new Exception("上级菜单不能为当前菜单!");
             }
             _sql.Update(main);
             result = Constants.UpdateSuccessMssg;
         }
         else
         {
             DataTable dt = _sql.Query("SELECT MenuName FROM MenuInfo WHERE IsDeleted = 0 AND MenuCode = @code", new Dictionary <string, object> {
                 { "@code", info.MenuCode }
             });
             if (dt != null && dt.Rows.Count > 0)
             {
                 throw new Exception(string.Format("当前菜单【{0}:{1}】已存在!", info.MenuCode, Cast.ConToString(dt.Rows[0]["MenuName"])));
             }
             _sql.Create(main);
             result = Constants.CreateSuccessMssg;
         }
         return(result);
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         throw ex;
     }
     finally
     {
         _sql.CloseDb();
     }
 }
Example #9
0
        /// <summary>
        /// 导入角色
        /// </summary>
        /// <param name="importData"></param>
        /// <returns></returns>
        public string UploadRole(DataTable importData)
        {
            try
            {
                StringBuilder sbResult = new StringBuilder();

                #region Excel数据验证
                if (importData == null || importData.Rows.Count == 0)
                {
                    throw new Exception("请维护导入数据!");
                }
                if (!importData.Columns.Contains("角色编码"))
                {
                    throw new Exception("请维护列【角色编码】!");
                }
                if (!importData.Columns.Contains("角色名称"))
                {
                    throw new Exception("请维护列【角色名称】!");
                }
                #endregion

                #region 初始化数据
                _sql.OpenDb();
                int index          = 2;                     // 导入数据的行数(数据从excel中第二行读取)
                int totalCount     = importData.Rows.Count; // 待导入的数据量
                int createCount    = 0;                     // 成功创建数据量
                int updateCount    = 0;                     // 成功更新数据量
                int unoperateCount = 0;                     // 未操作数据量
                // 导入开始...
                sbResult.Append("导入开始 \n");
                // totalCount条数据等待导入
                sbResult.Append(totalCount + "条数据等待导入 \n");
                #endregion

                #region BulkCopy测试
                //List<RoleInfo> list = new List<RoleInfo>();
                //foreach (DataRow row in importData.Rows)
                //{
                //    RoleInfo role = new RoleInfo();
                //    role.RoleInfoId = Guid.NewGuid();
                //    role.RoleCode = Cast.ConToString(row["RoleCode"]);
                //    role.RoleName = Cast.ConToString(row["RoleName"]);
                //    role.CreatedOn = DateTimeUtils.NowBeijing();
                //    role.ModifiedOn = DateTimeUtils.NowBeijing();
                //    role.CreatedBy = _identity.UserAccount;
                //    role.ModifiedBy = _identity.UserAccount;
                //    //_sql.Create(role);
                //    list.Add(role);
                //}
                //_sql.BulkCopy(RoleInfo.TableName, list.FillDataTable<RoleInfo>());
                #endregion

                #region 数据导入
                foreach (DataRow row in importData.Rows)
                {
                    if (string.IsNullOrWhiteSpace(Cast.ConToString(row["角色编码"])))
                    {
                        sbResult.AppendFormat("第{0}行数据角色编码为空! \n", index);
                        unoperateCount++;
                        index++;
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(Cast.ConToString(row["角色名称"])))
                    {
                        sbResult.AppendFormat("第{0}行数据角色名称为空! \n", index);
                        unoperateCount++;
                        index++;
                        continue;
                    }
                    RoleInfo role = new RoleInfo();
                    role.RoleCode = Cast.ConToString(row["角色编码"]);
                    role.RoleName = Cast.ConToString(row["角色名称"]);
                    DataTable dtrole = _sql.Query("SELECT RoleInfoId FROM RoleInfo WHERE IsDeleted = 0 AND RoleCode = @code", new Dictionary <string, object> {
                        { "@code", Cast.ConToString(row["角色编码"]) }
                    });
                    if (dtrole != null && dtrole.Rows.Count > 0)
                    {
                        role.RoleInfoId = new Guid(Cast.ConToString(dtrole.Rows[0]["RoleInfoId"]));
                        _sql.Update(role);
                        updateCount++;
                    }
                    else
                    {
                        _sql.Create(role);
                        createCount++;
                    }
                }
                sbResult.AppendFormat("成功创建{0}条记录 \n", createCount);
                sbResult.AppendFormat("成功更新{0}条记录 \n", updateCount);
                sbResult.AppendFormat("未操作{0}条记录 \n", unoperateCount);
                #endregion

                return(sbResult.ToString());
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                throw ex;
            }
            finally
            {
                _sql.CloseDb();
            }
        }
Example #10
0
 /// <summary>
 /// 创建或更新角色信息
 /// </summary>
 /// <param name="info">角色编辑信息</param>
 /// <returns></returns>
 public string CreateOrUpdateRoleInfo(RoleInfoEditModel info)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(info.RoleName))
         {
             throw new Exception("角色名称不能为空!");
         }
         if (string.IsNullOrWhiteSpace(info.RoleCode))
         {
             throw new Exception("角色编码不能为空!");
         }
         _sql.OpenDb();
         string   result   = string.Empty;
         RoleInfo roleInfo = new RoleInfo();
         info.FillTableWithModel <RoleInfo>(roleInfo);
         if (!string.IsNullOrEmpty(info.RoleInfoId))
         {
             _sql.Update(roleInfo);
             result = Constants.UpdateSuccessMssg;
         }
         else
         {
             DataTable dt = _sql.Query("SELECT RoleName FROM RoleInfo WHERE IsDeleted = 0 AND RoleCode = @code", new Dictionary <string, object> {
                 { "@code", info.RoleCode }
             });
             if (dt != null && dt.Rows.Count > 0)
             {
                 throw new Exception(string.Format("当前角色【{0}:{1}】已存在!", info.RoleCode, Cast.ConToString(dt.Rows[0]["RoleName"])));
             }
             _sql.Create(roleInfo);
             result = Constants.CreateSuccessMssg;
         }
         return(result);
     }
     catch (Exception ex)
     {
         _log.Error(ex);
         throw ex;
     }
     finally
     {
         _sql.CloseDb();
     }
 }
Example #11
0
        protected override async void JobRun()
        {
            try
            {
                string resp = await HttpHelper.GetAsync("https://webapi.sporttery.cn/gateway/lottery/getHistoryPageListV1.qry?gameNo=85&provinceId=0&pageSize=1&isVerify=1&pageNo=1&termLimits=1");

                log.Info("********************************************");
                log.Info(resp);
                if (string.IsNullOrEmpty(resp))
                {
                    throw new Exception("读取彩票接口失败!");
                }
                Root result = JsonConvert.DeserializeObject <Root>(resp);

                if (result.success == "false" || result.value == null || result.value.list == null || result.value.list.Count == 0)
                {
                    throw new Exception("获取中奖号码失败:" + result.errorMessage);
                }
                string[] nicecode     = result.value.list[0].lotteryDrawResult.Split(' ');
                string[] nicecode_pre = new string[5];
                nicecode_pre[0] = nicecode[0];
                nicecode_pre[1] = nicecode[1];
                nicecode_pre[2] = nicecode[2];
                nicecode_pre[3] = nicecode[3];
                nicecode_pre[4] = nicecode[4];
                string[] nicecode_suf = new string[2];
                nicecode_suf[0] = nicecode[5];
                nicecode_suf[1] = nicecode[6];

                string currentStage = result.value.list[0].lotteryDrawNum;

                string    sqlString = @"SELECT ui.Email,
                                            di.Type,
                                            di.DreamCode,
                                            di.StartStage,
                                            di.EndStage,
                                            di.UserInfoId
                                     FROM   DreamInfo di WITH(nolock)
                                            INNER JOIN UserInfo ui WITH(nolock)
                                              ON di.UserInfoId = ui.UserInfoId
                                     WHERE  di.IsDeleted = 0
                                            AND di.Type = @type--大乐透
                                            AND di.StartStage <= @stage
                                            AND di.EndStage >= @stage 
                                     ";
                DataTable dt        = sql.Query(sqlString, new Dictionary <string, object> {
                    { "@type", DreamInfoEnum.Type.DLT.GetHashCode() }, { "@stage", currentStage }
                });
                if (dt == null || dt.Rows.Count == 0)
                {
                    JobResult.Append("暂未查询到待开奖大乐透!");
                    return;
                }
                sql.OpenDb();
                sql.Execute("INSERT INTO tbl_wincode(Type, Period, Code) VALUES('大乐透', @p, @code)", new Dictionary <string, object> {
                    { "@p", currentStage }, { "@code", string.Join(' ', nicecode) }
                });
                foreach (DataRow row in dt.Rows)
                {
                    string email = Cast.ConToString(row["Email"]);
                    if (string.IsNullOrEmpty(email))
                    {
                        continue;
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("【{0}】期大乐透中奖号码:{1}", currentStage, string.Join(' ', nicecode));
                    sb.AppendLine();
                    sb.AppendFormat("【{1}】--【{2}】期 你的圆梦号码:{0}", Cast.ConToString(row["DreamCode"]), Cast.ConToString(row["StartStage"]), Cast.ConToString(row["EndStage"]));
                    sb.AppendLine();
                    string[] dreamcode     = Cast.ConToString(row["DreamCode"]).Split(' ');
                    string[] dreamcode_pre = new string[5];
                    dreamcode_pre[0] = dreamcode[0];
                    dreamcode_pre[1] = dreamcode[1];
                    dreamcode_pre[2] = dreamcode[2];
                    dreamcode_pre[3] = dreamcode[3];
                    dreamcode_pre[4] = dreamcode[4];
                    string[] dreamcode_suf = new string[2];
                    dreamcode_suf[0] = dreamcode[5];
                    dreamcode_suf[1] = dreamcode[6];
                    string[] same_pre  = nicecode_pre.Intersect(dreamcode_pre).OrderBy(item => item).ToArray();
                    string[] same_suf  = nicecode_suf.Intersect(dreamcode_suf).OrderBy(item => item).ToArray();
                    int      count_pre = same_pre.Length;
                    int      count_suf = same_suf.Length;
                    if (count_pre > 0)
                    {
                        sb.AppendFormat("前区相同号码:{0}", string.Join(' ', same_pre));
                    }
                    else
                    {
                        sb.AppendFormat("前区相同号码:nonono");
                    }
                    sb.AppendLine();
                    if (count_suf > 0)
                    {
                        sb.AppendFormat("后区相同号码:{0}", string.Join(' ', same_suf));
                    }
                    else
                    {
                        sb.AppendFormat("后区相同号码:nonono");
                    }
                    sb.AppendLine();
                    /// 一等奖:投注号码与当期开奖号码全部相同(顺序不限,下同),即中奖;
                    if (count_pre == 5 && count_suf == 2)
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "10000000";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得一等奖,从此走上人生巅峰,请登录中国体彩官网 http://www.lottery.gov.cn 获取奖金信息!");
                    }
                    /// 二等奖:投注号码与当期开奖号码中的五个前区号码及任意一个后区号码相同,即中奖;
                    else if (count_pre == 5 && count_suf == 1)
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "5000000";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得二等奖,西藏心灵之旅可以来一波,请登录中国体彩官网 http://www.lottery.gov.cn 获取奖金信息!");
                    }
                    /// 三等奖:投注号码与当期开奖号码中的五个前区号码相同,即中奖;
                    else if (count_pre == 5 && count_suf == 0)
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "10000";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得三等奖,奖金10000元,可以买台电脑打LOL了!");
                    }
                    /// 四等奖:投注号码与当期开奖号码中的任意四个前区号码及两个后区号码相同,即中奖;
                    else if (count_pre == 4 && count_suf == 2)
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "3000";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得四等奖,奖金3000元,Oppo Reno Ace了解一下!");
                    }
                    /// 五等奖:投注号码与当期开奖号码中的任意四个前区号码及任意一个后区号码相同,即中奖;
                    else if (count_pre == 4 && count_suf == 1)
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "300";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得五等奖,奖金300元,买支口红给女朋友吧....没有?就算了!");
                    }
                    /// 六等奖:投注号码与当期开奖号码中的任意三个前区号码及两个后区号码相同,即中奖;
                    else if (count_pre == 3 && count_suf == 2)
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "200";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得六等奖,奖金200元,楼下网吧充值200送500!");
                    }
                    /// 七等奖:投注号码与当期开奖号码中的任意四个前区号码相同,即中奖;
                    else if (count_pre == 4 && count_suf == 0)
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "100";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得七等奖,奖金100元,该干嘛干嘛吧!");
                    }
                    /// 八等奖:投注号码与当期开奖号码中的任意三个前区号码及任意一个后区号码相同,或者任意两个前区号码及两个后区号码相同,即中奖;
                    else if ((count_pre == 3 && count_suf == 1) || (count_pre == 2 && count_suf == 2))
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "15";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得八等奖,奖金15元,给自己点个黄焖鸡吧!");
                    }
                    /// 九等奖:投注号码与当期开奖号码中的任意三个前区号码相同,或者任意一个前区号码及两个后区号码相同,
                    /// 或者任意两个前区号码及任意一个后区号码相同,或者两个后区号码相同,即中奖。
                    else if ((count_pre == 3 && count_suf == 0) || (count_pre == 1 && count_suf == 2) || (count_pre == 2 && count_suf == 1) || (count_pre == 0 && count_suf == 2))
                    {
                        DreamRecord record = new DreamRecord();
                        record.UserInfoId  = Guid.Parse(Cast.ConToString(row["UserInfoId"]));
                        record.DreamType   = Cast.ConToString(row["Type"]);
                        record.DreamStage  = currentStage;
                        record.DreamNumber = Cast.ConToString(row["DreamCode"]);
                        record.DreamAmount = "5";
                        sql.Create(record);
                        sb.AppendFormat("恭喜你中得九等奖,奖金5元,建议加一元再买三张!");
                    }
                    else
                    {
                        sb.Append("别看了,这期你没中奖!");
                    }
                    EmailHelper.SendEmailByQQ(email, "圆梦大使带你走上人生巅峰", sb.ToString());
                    JobResult.Append("成功通知:" + email + ";");
                    JobResult.AppendLine();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            finally
            {
                sql.CloseDb();
            }
        }