public OperationResult <bool> ExhibitionEmail_Insert(ExhibitionEmailEntity entity) { SqlTransaction trans = null; string sql = string.Empty; sql += " INSERT INTO M_Exhibition_BookList_Customer_Rel(ExhibitionID,CustomerID,CustomerToken,CustomerEmail,CreateTime,SendTypeID,SendTime,CustomerName) "; sql += " VALUES(@ExhibitionID,@CustomerID,@CustomerToken,@CustomerEmail,@CreateTime,@SendTypeID,@SendTime,@CustomerName)"; SqlParameter[] prms = { new SqlParameter("@ExhibitionID", SqlDbType.Int), new SqlParameter("@CustomerID", SqlDbType.Int), new SqlParameter("@CustomerToken", SqlDbType.NVarChar, 64), new SqlParameter("@CustomerEmail", SqlDbType.NVarChar, 64), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@SendTypeID", SqlDbType.Int), new SqlParameter("@SendTime", SqlDbType.DateTime), new SqlParameter("@CustomerName", SqlDbType.NVarChar, 64) }; prms[0].Value = entity.ExhibitionID; prms[1].Value = entity.CustomerID; prms[2].Value = entity.CustomerToken; prms[3].Value = entity.CustomerEmail; prms[4].Value = entity.CreateTime; prms[5].Value = entity.SendTypeID; prms[6].Value = entity.SendTime; prms[7].Value = entity.CustomerName; try { using (SqlConnection conn = new SqlConnection(SQlHelper.MyConnectStr)) { conn.Open(); trans = conn.BeginTransaction(); SQlHelper.ExecuteScalar(trans, CommandType.Text, sql, prms); trans.Commit(); return(new OperationResult <bool>(OperationResultType.Success, "数据完成查询", true)); } } catch (Exception ex) { if (trans != null) { try { trans.Rollback(); } catch (Exception tranex) { LogUtil.WriteLog(tranex); } } return(new OperationResult <bool>(OperationResultType.Error, ex.Message, false)); } }
public ExhibitionModule() : base("/Exhibition") { #region 设置展场根据时间展示 Get["/ActivityTime"] = _ => { BCtrl_Exhibition exhibition = new BCtrl_Exhibition(); bool isPush = exhibition.IsPublished(); return(JsonObj <JsonMessageBase <bool> > .ToJson(new JsonMessageBase <bool>() { Status = 1, Msg = "数据传输完成!!", Value = isPush })); //return JsonObj<JsonMessageBase<bool>>.ToJson(new JsonMessageBase<bool>() { Status = 1, Msg = "数据传输完成!!", Value = true }); }; #endregion #region 获取是否是版本审核 Get["/CheckState"] = _ => { try { BCtrl_Common commonobj = new BCtrl_Common(); dynamic data = FecthQueryData(); string verCode = data.VerCode; //string verCode = "1"; bool isCheck = commonobj.IsVersionCheck(verCode); return(JsonObj <JsonMessageBase <bool> > .ToJson(new JsonMessageBase <bool>() { Status = 1, Msg = "Data transfer Complete!!", Value = isCheck })); } catch (Exception ex) { LogUtil.WriteLog(ex); return(JsonObj <JsonMessageBase> .ToJson(new JsonMessageBase() { Status = 0, Msg = "Failed to connect to the server,Try again later." })); } }; #endregion #region 发送邮件 Get["/SendEmail"] = _ => { dynamic data = FecthQueryData(); ExhibitionEmailEntity entity = new ExhibitionEmailEntity(); string eID = data.Eid; //展场ID string cID = data.UserID; //用户ID string cName = data.NickName; //用户名 string email = data.Email; //email int exhibitionID = 0; int customerID = 0; int.TryParse(eID, out exhibitionID); int.TryParse(cID, out customerID); entity.ExhibitionID = exhibitionID; entity.CustomerID = customerID.ToString(); entity.CustomerName = cName; entity.CustomerEmail = email; entity.CreateTime = DateTime.Now; entity.SendTypeID = 0; //展场邮件时间设定 DateTime?sendTime = DateTime.Parse("2016-01-07 08:20:00"); if (entity.CustomerName == null || string.IsNullOrEmpty(entity.CustomerName)) { entity.CustomerName = "开卷日历大客户"; } if (entity.CreateTime < sendTime) // 测试 求反 { entity.SendTime = sendTime; BCtrl_ExhibitionEmail.Instance.ExhibitionEmail_Insert(entity); } else { entity.SendTime = entity.CreateTime; SendEmailEntity sendEntity = new SendEmailEntity(); BCtrl_UserMail bllMail = new BCtrl_UserMail(); List <CompanyEmailAccountEntity> mailList = bllMail.QueryCoEmailAccountList(); Random rd = new Random(); if (mailList == null || mailList.Count == 0) { return(JsonObj <JsonMessageBase <bool> > .ToJson(new JsonMessageBase <bool>() { Status = 0, Msg = "邮箱服务器地址库为空!!", Value = false })); } //随机找出一个服务器地址 int num = rd.Next(0, mailList.Count - 1); #region 发送邮件固定参数 CompanyEmailAccountEntity cea = mailList[num]; sendEntity.FromEmail = cea.EmailName; sendEntity.FromSendName = "开卷网络"; sendEntity.FromPassword = cea.EmailPassword; sendEntity.ToSendName = entity.CustomerName; sendEntity.ToEmail = entity.CustomerEmail; sendEntity.Subject = "2016年北京图书订货会电子书目——由北京开卷收集整理"; sendEntity.Body = "基于2016年图书订货会,这是开卷搜集并整理订货会参展商的电子书目。"; sendEntity.Body += "<span style='font-family: Arial; line-height: 23.8px; color: rgb(255, 255, 255); background-color: rgb(255, 0, 0);'>【此文件大小超过3G,请务必使用电脑进行下载】</span> <br />"; sendEntity.Body += "下载链接: http://pan.baidu.com/s/1bpjF5c "; sendEntity.Body += "密码: ijex <br />"; sendEntity.Body += "开卷日历APP——网络书业人和事。<br />"; sendEntity.Body += "<img src='http://7xkwie.com2.z0.glb.qiniucdn.com/20151201/e3834448-e386-45b8-93cc-01a92744e5e8.jpg' alt='扫一扫' ></img>"; #endregion bool state = SendEmail.Send(sendEntity); if (state) { //单条发送时,发送后改变发送状态 entity.SendTypeID = 1; BCtrl_ExhibitionEmail.Instance.ExhibitionEmail_Insert(entity); } } return(JsonObj <JsonMessageBase <bool> > .ToJson(new JsonMessageBase <bool>() { Status = 1, Msg = "数据传输完成!!", Value = true })); }; #endregion }
public OperationResult <bool> ExhibitionEmail_Insert(ExhibitionEmailEntity entity) { return(dao.ExhibitionEmail_Insert(entity)); }
public SignBookModule() : base("SignBook") { #region 判定是否报到客户 2015/11/12 Get["IsAllow"] = _ => { dynamic data = FecthQueryData(); string customerKey = data.CustomerKey; bool flag = BCtrl_SignBook.Instance.IsAllowCustomerKey(customerKey); if (!flag) { marsLog.InfoFormat("IsAllow 未找到的用户Key:" + customerKey); } return(JsonObj <JsonMessageBase> .ToJson(new JsonMessageBase <string>() { Status = 1, Msg = "客户已签到", Value = flag.ToString() })); }; #endregion #region 返回客户的二维码地址 2015/11/12 Get["GetQRCode"] = _ => { dynamic data = FecthQueryData(); string customerKey = data.CustomerKey; IList <SignBookEntity> entity = BCtrl_SignBook.Instance.SignBook_Get(customerKey); if (entity == null || entity.Count == 0) { return(JsonObj <JsonMessageBase> .ToJson(new JsonMessageBase() { Status = 0, Msg = "数据接收成功,但没有实际改变" })); } string url = System.Configuration.ConfigurationManager.AppSettings["WebRoot"].ToString() + "/SignBook/Details.aspx?sid=" + entity[0].SignID; //string url = "http://www.kjrili.com/SignBook/Details.aspx?sid=" + entity[0].SignID; return(JsonObj <JsonMessageBase> .ToJson(new JsonMessageBase <string>() { Status = 1, Msg = "数据接收成功", Value = url })); }; #endregion #region 发送邮件 Get["/SendEmail"] = _ => { dynamic data = FecthQueryData(); ExhibitionEmailEntity entity = new ExhibitionEmailEntity(); string eID = data.Eid; //展场ID string cID = data.UserID; //用户ID string cName = data.NickName; //用户名 string email = data.Email; //email int exhibitionID = 0; int customerID = 0; int.TryParse(eID, out exhibitionID); int.TryParse(cID, out customerID); entity.ExhibitionID = exhibitionID; entity.CustomerID = customerID.ToString(); entity.CustomerName = cName; entity.CustomerEmail = email; entity.CreateTime = DateTime.Now; entity.SendTypeID = 0; //展场邮件时间设定 DateTime?sendTime = DateTime.Parse("2016-01-07 08:20:00"); if (entity.CustomerName == null || string.IsNullOrEmpty(entity.CustomerName)) { entity.CustomerName = "开卷日历大客户"; } if (entity.CreateTime < sendTime) // 测试 求反 { entity.SendTime = sendTime; BCtrl_ExhibitionEmail.Instance.ExhibitionEmail_Insert(entity); } else { entity.SendTime = entity.CreateTime; SendEmailEntity sendEntity = new SendEmailEntity(); BCtrl_UserMail bllMail = new BCtrl_UserMail(); List <CompanyEmailAccountEntity> mailList = bllMail.QueryCoEmailAccountList(); Random rd = new Random(); if (mailList == null || mailList.Count == 0) { return(JsonObj <JsonMessageBase <bool> > .ToJson(new JsonMessageBase <bool>() { Status = 0, Msg = "邮箱服务器地址库为空!!", Value = false })); } //随机找出一个服务器地址 int num = rd.Next(0, mailList.Count - 1); #region 发送邮件固定参数 CompanyEmailAccountEntity cea = mailList[num]; sendEntity.FromEmail = cea.EmailName; sendEntity.FromSendName = "开卷网络"; sendEntity.FromPassword = cea.EmailPassword; sendEntity.ToSendName = entity.CustomerName; sendEntity.ToEmail = entity.CustomerEmail; sendEntity.Subject = "2016年北京图书订货会电子书目——由北京开卷收集整理"; sendEntity.Body = "基于2016年图书订货会,这是开卷搜集并整理订货会参展商的电子书目。"; sendEntity.Body += "<span style='font-family: Arial; line-height: 23.8px; color: rgb(255, 255, 255); background-color: rgb(255, 0, 0);'>【此文件大小超过3G,请务必使用电脑进行下载】</span> <br />"; sendEntity.Body += "下载链接: http://pan.baidu.com/s/1bpjF5c "; sendEntity.Body += "密码: ijex <br />"; sendEntity.Body += "开卷日历APP——网络书业人和事。<br />"; sendEntity.Body += "<img src='http://7xkwie.com2.z0.glb.qiniucdn.com/20151201/e3834448-e386-45b8-93cc-01a92744e5e8.jpg' alt='扫一扫' ></img>"; #endregion bool state = SendEmail.Send(sendEntity); if (state) { //单条发送时,发送后改变发送状态 entity.SendTypeID = 1; BCtrl_ExhibitionEmail.Instance.ExhibitionEmail_Insert(entity); } } return(JsonObj <JsonMessageBase <bool> > .ToJson(new JsonMessageBase <bool>() { Status = 1, Msg = "数据传输完成!!", Value = true })); }; #endregion }