public bool Start(string schedule_code) { if (string.IsNullOrEmpty(schedule_code)) { return false; } try { MailModel mailModel = new MailModel(); mailModel.MysqlConnectionString = mySqlConnectionString; string GroupCode = string.Empty; string MailTitle = string.Empty; string MailBody = string.Empty; bool IsSeparate = false; bool IsDisplyName = true; //獲取該排程參數 List<ScheduleConfigQuery> store_config = new List<ScheduleConfigQuery>(); ScheduleConfigQuery query_config = new ScheduleConfigQuery(); query_config.schedule_code = schedule_code; _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString); store_config = _secheduleServiceMgr.GetScheduleConfig(query_config); #region mailhelp賦值 foreach (ScheduleConfigQuery item in store_config) { if (item.parameterCode.Equals("MailFromAddress")) { mailModel.MailFromAddress = item.value; } else if (item.parameterCode.Equals("MailHost")) { mailModel.MailHost = item.value; } else if (item.parameterCode.Equals("MailPort")) { mailModel.MailPort = item.value; } else if (item.parameterCode.Equals("MailFromUser")) { mailModel.MailFromUser = item.value; } else if (item.parameterCode.Equals("EmailPassWord")) { mailModel.MailFormPwd = item.value; } else if (item.parameterCode.Equals("GroupCode")) { GroupCode = item.value; } else if (item.parameterCode.Equals("MailTitle")) { MailTitle = item.value; } else if (item.parameterCode.Equals("MailTitle")) { MailTitle = item.value; } else if (item.parameterCode.Equals("MailBody")) { MailBody = item.value; } else if (item.parameterCode.Equals("IsSeparate")) { if (item.value.ToString().Trim().ToLower() == "false") { IsSeparate = false; } else if (item.value.ToString().Trim().ToLower() == "true") { IsSeparate = true; } } else if (item.parameterCode.Equals("IsDisplyName")) { if (item.value.ToString().Trim().ToLower() == "false") { IsDisplyName = false; } else if (item.value.ToString().Trim().ToLower() == "true") { IsDisplyName = true; } } } #endregion ///獲取用戶登陸信息 /// int totalCount = 0; List<ManageLoginQuery> list = new List<ManageLoginQuery>(); ManageLoginMgr _managelogionMgr = new ManageLoginMgr(mySqlConnectionString); ManageLoginQuery query = new ManageLoginQuery(); query.Start = Convert.ToInt32("0"); query.Limit = Convert.ToInt32("999"); query.login_start = CommonFunction.GetPHPTime(DateTime.Now.AddHours(-1).ToString()); query.login_end = CommonFunction.GetPHPTime(DateTime.Now.ToString()); DataTable _dt = new DataTable(); DataRow dr; _dt.Columns.Add("登入編號", typeof(string)); _dt.Columns.Add("登入人名稱", typeof(string)); _dt.Columns.Add("登入時間", typeof(string)); _dt.Columns.Add("來源IP", typeof(string)); list = _managelogionMgr.GetManageLoginList(query, out totalCount); foreach (var item in list) { dr = _dt.NewRow(); dr["登入編號"] = item.loginID.ToString(); dr["登入人名稱"] = item.user_name.ToString(); dr["登入時間"] = CommonFunction.DateTimeToString(item.login_createtime); dr["來源IP"] = item.login_ipfrom.ToString(); _dt.Rows.Add(dr); } if (_dt.Rows.Count > 0) { MailBody = GetHtmlByDataTable(_dt); ///////////////// _secheduleServiceMgr.SendMail(mailModel, GroupCode, MailTitle, MailBody, IsSeparate, IsDisplyName); } } catch (Exception ex) { throw new Exception("UserLoginLogMgr-->Start-->" + ex.Message); } return true; }
public bool Start(string schedule_code) { string json = string.Empty; if (string.IsNullOrEmpty(schedule_code)) { return false; } try { MailModel mailModel = new MailModel(); mailModel.MysqlConnectionString = mySqlConnectionString; string GroupCode = string.Empty; string MailTitle = string.Empty; int HourNum = 0; List<ScheduleConfigQuery> store_config = new List<ScheduleConfigQuery>(); ScheduleConfigQuery query_config = new ScheduleConfigQuery(); query_config.schedule_code = schedule_code; _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString); store_config = _secheduleServiceMgr.GetScheduleConfig(query_config); foreach (ScheduleConfigQuery item in store_config) { if (item.parameterCode.Equals("MailFromAddress")) { mailModel.MailFromAddress = item.value; } else if (item.parameterCode.Equals("MailHost")) { mailModel.MailHost = item.value; } else if (item.parameterCode.Equals("MailPort")) { mailModel.MailPort = item.value; } else if (item.parameterCode.Equals("MailFromUser")) { mailModel.MailFromUser = item.value; } else if (item.parameterCode.Equals("EmailPassWord")) { mailModel.MailFormPwd = item.value; } else if (item.parameterCode.Equals("GroupCode")) { GroupCode = item.value; } else if (item.parameterCode.Equals("MailTitle")) { MailTitle = item.value; } else if (item.parameterCode.Equals("HourNum")) { HourNum = int.Parse(item.value); } } string MailBody = string.Empty; //獲取history修改中的itemid string items=string.Empty; if (HourNum > 0) { items = GetHistoryItemid(HourNum); } else { items = "ALL"; } DataTable _dt = GetDataTable(items); DataTable _newdt = new DataTable(); _newdt.Columns.Add("商品名稱", typeof(String)); _newdt.Columns.Add("商品編號", typeof(String)); _newdt.Columns.Add("商品細項編號", typeof(String)); _newdt.Columns.Add("商品規格", typeof(String)); _newdt.Columns.Add("異常原因", typeof(String)); _newdt.Columns.Add("item_money", typeof(String)); _newdt.Columns.Add("item_cost", typeof(String)); _newdt.Columns.Add("event_money", typeof(String)); _newdt.Columns.Add("event_cost", typeof(String)); _newdt.Columns.Add("event_start", typeof(String)); _newdt.Columns.Add("event_end", typeof(String)); // for (int i = 0; i < _dt.Rows.Count; i++) { DataRow newRow = _newdt.NewRow(); newRow[0] = _dt.Rows[i]["product_name"]; newRow[1] = _dt.Rows[i]["product_id"]; newRow[2] = _dt.Rows[i]["item_id"]; newRow[3] = _dt.Rows[i]["prod_sz"]; int item_money = _dt.Rows[i]["item_money"] == DBNull.Value ? 0 : Convert.ToInt32(_dt.Rows[i]["item_money"]); int item_cost = _dt.Rows[i]["item_cost"] == DBNull.Value ? 0 : Convert.ToInt32(_dt.Rows[i]["item_cost"]); int event_money = _dt.Rows[i]["event_money"] == DBNull.Value ? 0 : Convert.ToInt32(_dt.Rows[i]["event_money"]); int event_cost = _dt.Rows[i]["event_cost"] == DBNull.Value ? 0 : Convert.ToInt32(_dt.Rows[i]["event_cost"]); int event_start = _dt.Rows[i]["event_start"] == DBNull.Value ? 0 : Convert.ToInt32(_dt.Rows[i]["event_start"]); int event_end = _dt.Rows[i]["event_end"] == DBNull.Value ? 0 : Convert.ToInt32(_dt.Rows[i]["event_end"]); newRow[5] = item_money; newRow[6] = item_cost; newRow[7] = event_money; newRow[8] = event_cost; newRow[9] = event_start; newRow[10] = event_end; if(item_money==0) { newRow[4] = "商品價格為零"; } else if(item_money>item_cost) { newRow[4] = "商品價格大於成本價"; } else if(event_money==0 && event_end > CommonFunction.GetPHPTime()) { newRow[4] = "商品活動價格為零"; } else if(event_money>event_cost && event_end > CommonFunction.GetPHPTime()) { newRow[4] = "商品活動價格大於商品活動成本價格"; } _newdt.Rows.Add(newRow); } if (_newdt.Rows.Count > 0) { MailBody = GetHtmlByDataTable(_newdt); ///////////////// _secheduleServiceMgr.SendMail(mailModel, GroupCode, MailTitle, MailBody, false, true); } } catch (Exception ex) { throw new Exception("CheckProductPriceMgr-->Start-->" + ex.Message); } return true; }