internal bool UpdateAccount(SMS.Model.EnterpriseUser user, string type) { try { SMS.Model.EnterpriseUser account = GetAccount(user.AccountCode); if (account == null) { return(false); } bool ok = true; if (type == "info") { ok = DAL.EnterpriseUser.UpdateAccontInfo(user); } if (type == "set") { ok = DAL.EnterpriseUser.UpdateAccountSetting(user); } if (ok) { account = user; CacheManager <SMS.Model.EnterpriseUser> .Instance.Set(account.AccountCode, account); } return(ok); } catch (Exception ex) { } return(false); }
/// <summary> /// 更新短信设置 /// </summary> /// <param name="user"></param> /// <returns></returns> internal bool UpdateAccountSMS(SMS.Model.EnterpriseUser user) { try { var rc = SMSProxy.GetPretreatmentService().GetChannel(user.Channel); if (rc.Success) { Channel c = rc.Value; user.SMSType = c.SMSType; } else { return(false); } bool ok = DAL.EnterpriseUser.UpdateAccountSMS(user); if (ok) { SMS.Model.EnterpriseUser account = GetAccountFromDB(user.AccountCode); CacheManager <SMS.Model.EnterpriseUser> .Instance.Set(account.AccountCode, account); } return(ok); } catch (Exception ex) { } return(false); }
/// <summary> /// 增加一条数据 /// </summary> static bool AddUserSetting(MySqlTransaction myTran, SMS.Model.EnterpriseUser model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into plat_EnterpriseUser("); strSql.Append("AccountID,AccountPassword,Priority,Audit,SPNumber,IsEnable,RegisterDate,AccountCode,IsAgent,ParentAccountCode,SecretKey,AppPassword,IsOpen)"); strSql.Append(" values ("); strSql.Append("@AccountID,@AccountPassword,@Priority,@Audit,@SPNumber,@IsEnable,@RegisterDate,@AccountCode,@IsAgent,@ParentAccountCode,@SecretKey,@AppPassword,@IsOpen)"); MySqlParameter[] parameters = { new MySqlParameter("@AccountID", MySqlDbType.VarChar, 64), new MySqlParameter("@AccountPassword", MySqlDbType.VarChar, 64), new MySqlParameter("@Priority", MySqlDbType.Int32, 5), new MySqlParameter("@Audit", MySqlDbType.Int32, 5), new MySqlParameter("@SPNumber", MySqlDbType.VarChar, 48), new MySqlParameter("@IsEnable", MySqlDbType.Int32, 5), new MySqlParameter("@RegisterDate", MySqlDbType.DateTime), new MySqlParameter("@AccountCode", MySqlDbType.VarChar, 64), new MySqlParameter("@IsAgent", MySqlDbType.Int32, 5), new MySqlParameter("@ParentAccountCode", MySqlDbType.VarChar, 64), new MySqlParameter("@SecretKey", MySqlDbType.VarChar, 16), new MySqlParameter("@AppPassword", MySqlDbType.VarChar, 64), new MySqlParameter("@IsOpen", MySqlDbType.Int32, 5) }; parameters[0].Value = model.AccountID; parameters[1].Value = model.Password; parameters[2].Value = (ushort)model.Priority; parameters[3].Value = (ushort)model.Audit; parameters[4].Value = model.SPNumber; parameters[5].Value = model.Enabled == true ? 1 : 0; parameters[6].Value = model.RegisterDate; parameters[7].Value = model.AccountCode; parameters[8].Value = model.IsAgent == true ? 1 : 0; parameters[9].Value = model.ParentAccountCode; parameters[10].Value = model.SecretKey; parameters[11].Value = model.AppPassword; parameters[12].Value = model.IsOpen == true ? 1 : 0; int rows = 0; if (myTran == null) { rows = DBUtility.MySqlHelper.ExecuteNonQuery(strSql.ToString(), parameters); } else { rows = DBUtility.MySqlHelper.ExecuteNonQuery(myTran, strSql.ToString(), parameters); } if (rows > 0) { return(true); } else { return(false); } }
static bool AddSMSSetting(IDbTransaction myTran, SMS.Model.EnterpriseUser user) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into plat_SMSSetting("); strSql.Append("AccountCode,StatusReport,FilterType,Channel,Signature,SMSType)"); strSql.Append(" values ("); strSql.Append("@AccountCode,@StatusReport,@FilterType,@Channel,@Signature,@SMSType)"); DBHelper.Instance.Execute(strSql.ToString(), user, myTran); return(true); }
static bool AddInfo(IDbTransaction myTran, SMS.Model.EnterpriseUser model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into plat_EnterpriseInformation("); strSql.Append("AccountCode,Name,Contact,Telephone,Province,City,Address)"); strSql.Append(" values ("); strSql.Append("@AccountCode,@Name,@Contact,@Phone,@Province,@City,@Address)"); DBHelper.Instance.Execute(strSql.ToString(), model, myTran); return(true); }
/// <summary> /// 增加一条数据 /// </summary> static bool AddUserSetting(IDbTransaction myTran, SMS.Model.EnterpriseUser model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into plat_EnterpriseUser("); strSql.Append("AccountID,AccountPassword,Priority,Audit,SPNumber,IsEnable,RegisterDate,AccountCode,IsAgent,ParentAccountCode,SecretKey,AppPassword,IsOpen)"); strSql.Append(" values ("); strSql.Append("@AccountID,@Password,@Priority,@Audit,@SPNumber,@Enabled,@RegisterDate,@AccountCode,@IsAgent,@ParentAccountCode,@SecretKey,@AppPassword,@IsOpen)"); DBHelper.Instance.Execute(strSql.ToString(), model, myTran); return(true); }
public static bool UpdateAccountSMS(SMS.Model.EnterpriseUser user) { StringBuilder strSql = new StringBuilder(); strSql.Append("update plat_SMSSetting set "); strSql.Append("StatusReport=@StatusReport,"); strSql.Append("SMSLevel=@SMSLevel,"); strSql.Append("FilterType=@FilterType,"); strSql.Append("SMSType=@SMSType,"); strSql.Append("Signature=@Signature,"); strSql.Append("Channel=@Channel"); strSql.Append(" where AccountCode=@AccountCode"); MySqlParameter[] parameters = { new MySqlParameter("@AccountCode", MySqlDbType.VarChar, 64), new MySqlParameter("@StatusReport", MySqlDbType.Int32, 5), new MySqlParameter("@SMSLevel", MySqlDbType.Int32, 5), new MySqlParameter("@FilterType", MySqlDbType.Int32, 5), new MySqlParameter("@SMSType", MySqlDbType.Int32, 5), new MySqlParameter("@Channel", MySqlDbType.VarChar, 64), new MySqlParameter("@Signature", MySqlDbType.VarChar, 128) }; parameters[0].Value = user.AccountCode; parameters[1].Value = user.StatusReport; parameters[2].Value = user.SMSLevel; parameters[3].Value = user.FilterType; parameters[4].Value = user.SMSType; parameters[5].Value = user.Channel; if (!string.IsNullOrEmpty(user.Signature)) { if (!user.Signature.StartsWith("【")) { user.Signature = "【" + user.Signature + "】"; } } parameters[6].Value = user.Signature; int rows = DBUtility.MySqlHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获取用户 /// </summary> /// <param name="account"></param> /// <returns></returns> internal SMS.Model.EnterpriseUser GetAccount(string account) { SMS.Model.EnterpriseUser a = CacheManager <SMS.Model.EnterpriseUser> .Instance.Get(account); if (a == null) { a = GetAccountFromDB(account); if (a != null) { CacheManager <SMS.Model.EnterpriseUser> .Instance.Set(a.AccountCode, a); } } return(a); }
public static bool UpdateAccontInfo(SMS.Model.EnterpriseUser user) { StringBuilder strSql = new StringBuilder(); strSql.Append("update plat_EnterpriseInformation set "); strSql.Append("Name=@Name,"); strSql.Append("Contact=@Contact,"); strSql.Append("Telephone=@Phone,"); strSql.Append("Province=@Province,"); strSql.Append("City=@City,"); strSql.Append("Address=@Address"); strSql.Append(" where AccountCode=@AccountCode "); DBHelper.Instance.Execute(strSql.ToString(), user); return(true); }
/// <summary> /// 添加企业 /// </summary> /// <param name="user"></param> /// <returns></returns> public SMS.Model.RPCResult ISMPAddEnterprise(SMS.Model.EnterpriseUser user) { try { if (user.AccountCode == "-1") { return(new SMS.Model.RPCResult(false, "已存在此企业帐号")); } SMS.Model.EnterpriseUser a = AccountServer.Instance.GetAccount(user.AccountCode); if (a != null) { return(new SMS.Model.RPCResult(false, "已存在此企业帐号")); } if (string.IsNullOrEmpty(user.Signature)) { return(new SMS.Model.RPCResult(false, "企业签名不能为空")); } SMS.Model.Account account = new SMS.Model.Account(); account.AccountID = ""; account.SMSNumber = 0; if (!string.IsNullOrWhiteSpace(user.AccountID)) { account.AccountID = user.AccountID; } SMS.Model.RPCResult <Guid> r = SMSProxy.GetSMSService().CreateAccount(account); if (!r.Success) { return(new SMS.Model.RPCResult(false, r.Message)); } user.AccountID = r.Value.ToString(); user.Signature = "【" + user.Signature + "】"; user.Channel = user.Channel == "-1-" ? "" : user.Channel; user.SecretKey = ""; user.AppPassword = DESEncrypt.Encrypt(user.Password, user.AccountID); user.Password = DESEncrypt.Encrypt(user.Password); bool ok = AccountServer.Instance.CreateAccount(user); if (ok) { return(new SMS.Model.RPCResult(true, "创建成功")); } return(new SMS.Model.RPCResult(false, "创建失败")); } catch { return(new SMS.Model.RPCResult(false, "创建失败")); } }
/// <summary> /// 密钥修改 /// </summary> /// <param name="accountCode"></param> /// <param name="pass"></param> /// <param name="secretKey"></param> /// <returns></returns> public bool UpdateAccountSecretKey(string accountCode, string pass, string secretKey) { SMS.Model.EnterpriseUser account = GetAccount(accountCode); if (account == null) { return(false); } bool ok = DAL.EnterpriseUser.UpdateSecretKey(accountCode, secretKey, pass); if (ok) { account.AppPassword = pass; account.SecretKey = secretKey; CacheManager <SMS.Model.EnterpriseUser> .Instance.Set(account.AccountCode, account); } return(ok); }
public static bool UpdateAccountSetting(SMS.Model.EnterpriseUser user) { StringBuilder strSql = new StringBuilder(); strSql.Append("update plat_EnterpriseUser set "); strSql.Append("Priority=@Priority,"); strSql.Append("Audit=@Audit,"); strSql.Append("SPNumber=@SPNumber,"); strSql.Append("IsEnable=@Enabled,"); strSql.Append("IsAgent=@IsAgent,"); strSql.Append("IsOpen=@IsOpen,"); strSql.Append("ParentAccountCode=@ParentAccountCode"); strSql.Append(" where AccountCode=@AccountCode "); DBHelper.Instance.Execute(strSql.ToString(), user); return(true); }
public static bool Add(SMS.Model.EnterpriseUser user) { var myTran = DBHelper.Instance.GetDBAdapter().BeginTransaction(); if (AddInfo(myTran, user)) { if (AddUserSetting(myTran, user)) { if (AddSMSSetting(myTran, user)) { myTran.Commit(); return(true); } } } myTran.Rollback(); return(false); }
public static bool Add(SMS.Model.EnterpriseUser user) { MySqlTransaction myTran = DBUtility.MySqlHelper.CreateTransaction(); if (AddInfo(myTran, user)) { if (AddUserSetting(myTran, user)) { if (AddSMSSetting(myTran, user)) { myTran.Commit(); return(true); } } } myTran.Rollback(); return(false); }
static bool AddSMSSetting(MySqlTransaction myTran, SMS.Model.EnterpriseUser user) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into plat_SMSSetting("); strSql.Append("AccountCode,StatusReport,SMSLevel,FilterType,Channel,Signature,SMSType)"); strSql.Append(" values ("); strSql.Append("@AccountCode,@StatusReport,@SMSLevel,@FilterType,@Channel,@Signature,@SMSType)"); MySqlParameter[] parameters = { new MySqlParameter("@AccountCode", MySqlDbType.VarChar, 64), new MySqlParameter("@StatusReport", MySqlDbType.Int32, 5), new MySqlParameter("@SMSLevel", MySqlDbType.Int32, 5), new MySqlParameter("@FilterType", MySqlDbType.Int32, 5), new MySqlParameter("@Channel", MySqlDbType.VarChar, 64), new MySqlParameter("@Signature", MySqlDbType.VarChar, 128), new MySqlParameter("@SMSType", MySqlDbType.Int32, 5) }; parameters[0].Value = user.AccountCode; parameters[1].Value = user.StatusReport; parameters[2].Value = user.SMSLevel; parameters[3].Value = user.FilterType; parameters[4].Value = user.Channel; parameters[5].Value = user.Signature; parameters[6].Value = user.SMSType; int rows = 0; if (myTran == null) { rows = DBUtility.MySqlHelper.ExecuteNonQuery(strSql.ToString(), parameters); } else { rows = DBUtility.MySqlHelper.ExecuteNonQuery(myTran, strSql.ToString(), parameters); } if (rows > 0) { return(true); } else { return(false); } }
public static bool UpdateAccountSetting(SMS.Model.EnterpriseUser user) { StringBuilder strSql = new StringBuilder(); strSql.Append("update plat_EnterpriseUser set "); strSql.Append("Priority=@Priority,"); strSql.Append("Audit=@Audit,"); strSql.Append("SPNumber=@SPNumber,"); strSql.Append("IsEnable=@IsEnable,"); strSql.Append("IsAgent=@IsAgent,"); strSql.Append("IsOpen=@IsOpen,"); strSql.Append("ParentAccountCode=@ParentAccountCode"); strSql.Append(" where AccountCode=@AccountCode "); MySqlParameter[] parameters = { new MySqlParameter("@AccountCode", MySqlDbType.VarChar, 64), new MySqlParameter("@Priority", MySqlDbType.Int32, 5), new MySqlParameter("@Audit", MySqlDbType.Int32, 5), new MySqlParameter("@SPNumber", MySqlDbType.VarChar, 48), new MySqlParameter("@IsEnable", MySqlDbType.Int32, 5), new MySqlParameter("@IsOpen", MySqlDbType.Int32, 5), new MySqlParameter("@IsAgent", MySqlDbType.Int32, 5), new MySqlParameter("@ParentAccountCode", MySqlDbType.VarChar, 64) }; parameters[0].Value = user.AccountCode; parameters[1].Value = (ushort)user.Priority; parameters[2].Value = (ushort)user.Audit; parameters[3].Value = user.SPNumber; parameters[4].Value = user.Enabled == true ? 1 : 0; parameters[5].Value = user.IsOpen == true ? 1 : 0; parameters[6].Value = user.IsAgent == true ? 1 : 0; parameters[7].Value = user.ParentAccountCode; int rows = DBUtility.MySqlHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
static bool AddInfo(MySqlTransaction myTran, SMS.Model.EnterpriseUser model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into plat_EnterpriseInformation("); strSql.Append("AccountCode,Name,Contact,Telephone,Province,City,Address)"); strSql.Append(" values ("); strSql.Append("@AccountCode,@Name,@Contact,@Telephone,@Province,@City,@Address)"); MySqlParameter[] parameters = { new MySqlParameter("@AccountCode", MySqlDbType.VarChar, 64), new MySqlParameter("@Name", MySqlDbType.VarChar, 128), new MySqlParameter("@Contact", MySqlDbType.VarChar, 32), new MySqlParameter("@Telephone", MySqlDbType.VarChar, 32), new MySqlParameter("@Province", MySqlDbType.VarChar, 16), new MySqlParameter("@City", MySqlDbType.VarChar, 16), new MySqlParameter("@Address", MySqlDbType.VarChar, 256) }; parameters[0].Value = model.AccountCode; parameters[1].Value = model.Name; parameters[2].Value = model.Contact; parameters[3].Value = model.Phone; parameters[4].Value = model.Province; parameters[5].Value = model.City; parameters[6].Value = model.Address; int rows = 0; if (myTran == null) { rows = DBUtility.MySqlHelper.ExecuteNonQuery(strSql.ToString(), parameters); } else { rows = DBUtility.MySqlHelper.ExecuteNonQuery(myTran, strSql.ToString(), parameters); } if (rows > 0) { return(true); } else { return(false); } }
public static bool UpdateAccontInfo(SMS.Model.EnterpriseUser user) { StringBuilder strSql = new StringBuilder(); strSql.Append("update plat_EnterpriseInformation set "); strSql.Append("Name=@Name,"); strSql.Append("Contact=@Contact,"); strSql.Append("Telephone=@Telephone,"); strSql.Append("Province=@Province,"); strSql.Append("City=@City,"); strSql.Append("Address=@Address"); strSql.Append(" where AccountCode=@AccountCode "); MySqlParameter[] parameters = { new MySqlParameter("@Name", MySqlDbType.VarChar, 128), new MySqlParameter("@Contact", MySqlDbType.VarChar, 32), new MySqlParameter("@Telephone", MySqlDbType.VarChar, 32), new MySqlParameter("@Province", MySqlDbType.VarChar, 16), new MySqlParameter("@City", MySqlDbType.VarChar, 16), new MySqlParameter("@Address", MySqlDbType.VarChar, 256), new MySqlParameter("@AccountCode", MySqlDbType.VarChar, 64) }; parameters[0].Value = user.Name; parameters[1].Value = user.Contact; parameters[2].Value = user.Phone; parameters[3].Value = user.Province; parameters[4].Value = user.City; parameters[5].Value = user.Address; parameters[6].Value = user.AccountCode; int rows = DBUtility.MySqlHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获取不能进行管理的企业用户(未审核和审核不通过的企业) /// </summary> /// <returns></returns> internal List <SMS.Model.EnterpriseUser> GetUnableManageEnterprise() { List <SMS.Model.EnterpriseUser> list = new List <SMS.Model.EnterpriseUser>(); try { foreach (var v in dic) { SMS.Model.EnterpriseUser a = CacheManager <SMS.Model.EnterpriseUser> .Instance.Get(v.Key); if (a != null) { list.Add(a); } } } catch { } return(list); }
/// <summary> /// 创建用户 /// </summary> /// <param name="account"></param> /// <returns></returns> internal bool CreateAccount(SMS.Model.EnterpriseUser account) { //数据库操作 bool ok = false; try { ok = DAL.EnterpriseUser.Add(account); } catch (Exception ex) { return(false); } if (ok) { if (!string.IsNullOrEmpty(account.Signature)) { account.Signature = account.Signature.Substring(1, account.Signature.Length - 2); } CacheManager <SMS.Model.EnterpriseUser> .Instance.Set(account.AccountCode, account); } return(ok); }
/// <summary> /// 企业修改密码 /// </summary> /// <param name="account"></param> /// <param name="count"></param> /// <returns></returns> public bool ChangePass(string accountCode, string pass) { try { SMS.Model.EnterpriseUser account = GetAccount(accountCode); if (account == null) { return(false); } string appPass = DESEncrypt.Encrypt(pass, string.IsNullOrEmpty(account.SecretKey) ? account.AccountID : account.SecretKey); bool ok = DAL.EnterpriseUser.ChangePass(accountCode, DESEncrypt.Encrypt(pass), appPass); if (ok) { account.Password = DESEncrypt.Encrypt(pass); account.AppPassword = appPass; CacheManager <SMS.Model.EnterpriseUser> .Instance.Set(account.AccountCode, account); } return(ok); } catch (Exception ex) { } return(false); }
public static bool UpdateAccountSMS(SMS.Model.EnterpriseUser user) { StringBuilder strSql = new StringBuilder(); strSql.Append("update plat_SMSSetting set "); strSql.Append("StatusReport=@StatusReport,"); strSql.Append("FilterType=@FilterType,"); strSql.Append("SMSType=@SMSType,"); strSql.Append("Signature=@Signature,"); strSql.Append("Channel=@Channel"); strSql.Append(" where AccountCode=@AccountCode"); if (!string.IsNullOrEmpty(user.Signature)) { if (!user.Signature.StartsWith("【")) { user.Signature = "【" + user.Signature + "】"; } } DBHelper.Instance.Execute(strSql.ToString(), user); return(true); }
public ActionResult SaleSubmit(SMS.Model.EnterpriseUser eu) { try { var sr = new SMS.Model.RPCResult(false, ""); string enterpriseCode = Request["EnterpriseCode"]; string enterpriseAccountID = Request["EnterpriseAccountID"]; string agentAccountID = Request["AgentAccountID"]; string Description = "企业新开充值"; eu.AccountCode = enterpriseCode; eu.AccountID = enterpriseAccountID; eu.Name = ""; eu.IsAgent = false; eu.IsOpen = false; eu.FilterType = (ushort)FilterType.Replace; eu.Audit = AccountAuditType.Audit; eu.SMSType = Util.SMSType; eu.StatusReport = StatusReportType.Disable; eu.Enabled = true; eu.RegisterDate = DateTime.Now; eu.Password = Util.GeneratePassword(8); //随机生成8位密码。 eu.Channel = Util.DefaultChannel; eu.ParentAccountCode = "-1"; //无上级企业 string spNumber = Util.GenSpNumber(); //随机算法生成 var entlist = Util.SMSProxy.ISMPGetAllEnterprise().Value; //检验号码是否可用 while (true) { if (entlist.Any(e => e.SPNumber == spNumber)) { spNumber = Util.GenSpNumber();//重新生成 } else { break; } } eu.SPNumber = spNumber; //检查企业是否已存在 if (!entlist.Any(e => e.AccountCode == eu.AccountCode)) { //不存在,注册企业,不审核 sr = Util.SMSProxy.ISMPAddEnterprise(eu); if (sr.Success) { try { //添加默认通讯录分组 bool resultAddContactGroup = PhoneAndGroupDB.GroupAdd(enterpriseCode, "0", "未分组"); } catch (Exception ex) { Log4Logger.Error(ex); } //ISMP 订单 string url = Util.ISMPHost + "/CallBack/OpenProduct_CallBack?"; url += "Id=" + System.Web.HttpUtility.UrlEncode(System.Guid.NewGuid().ToString()) + "&EnterpriseAccountId=" + System.Web.HttpUtility.UrlEncode(enterpriseAccountID) + "&ProductId=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductId) + "&Description=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductName + "订单"); string result = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(result, new { success = true, message = string.Empty }); if (!o.success) { //需要通知运维进行处理或再次尝试 Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "短信中开通企业成功,回调ISMP添加订单失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,添加订单失败原因【" + o.message + "】", "开通失败", CurrentUser); return(GetActionResult(new RPC_Result(false, "添加短信订单失败,请联系客服"))); } else { Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "短信中开通企业成功", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "开通产品", CurrentUser); } } else { return(GetActionResult(sr)); } } else { return(GetActionResult(new RPC_Result(false, "该企业已开通短信产品,不能重复开通!"))); } var smsNumber = int.Parse(string.IsNullOrWhiteSpace(Request["smsNumber"]) ? "0" : Request["smsNumber"]); //开通同时给企业充值 if (smsNumber > 0) { ChargeRecord cr = new ChargeRecord(); cr.ChargeFlag = 0; cr.Money = smsNumber * Util.SMSRate; cr.SMSCount = smsNumber; cr.ThenRate = Convert.ToDecimal(Util.SMSRate); cr.OperatorAccount = CurrentUser.LoginName; cr.PrepaidAccount = enterpriseCode; cr.PrepaidTime = DateTime.Now; cr.PrepaidType = 1; //ISMP 扣费 string url = Util.ISMPHost + "/CallBack/DeductForProduct?"; url += "DeductAccountId=" + System.Web.HttpUtility.UrlEncode(agentAccountID) + "&RechargeAccountId=" + System.Web.HttpUtility.UrlEncode(enterpriseAccountID) + "&Money=" + System.Web.HttpUtility.UrlEncode(Convert.ToString(cr.Money)) + "&Description=" + System.Web.HttpUtility.UrlEncode(Description) + "&ProductPayType=" + System.Web.HttpUtility.UrlEncode("短信充值") + "&ApplyAccountId=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorAccountId) + "&ApplyName=" + System.Web.HttpUtility.UrlEncode(CurrentUser.OperatorName) + "&Type=" + System.Web.HttpUtility.UrlEncode("21") + "&ProductId=" + System.Web.HttpUtility.UrlEncode(Util.SMSProductId); string result = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(result, new { success = true, message = string.Empty }); if (o.success) { var r = Util.SMSProxy.AccountPrepaid(cr); if (r.Success) { Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "开通完成,充值短信【" + smsNumber + "】条。", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "短信充值", CurrentUser); return(GetActionResult(new RPC_Result(true, "开通完成,充值短信【" + smsNumber + "】条。"))); } else { //此处应记录日志和错误,并及时通知 //此处扣费成功但充值失败。 Util.SendSystemLogToISMP(Util.SMSProductName + "充值", "开通且扣费成功,充值失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,充值失败原因【" + r.Message + "】", "短信充值失败", CurrentUser); return(GetActionResult(new RPC_Result(false, "开通且扣费成功,充值失败,请联系客服"))); } } else { Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "注册完成,扣费失败", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】,金额【" + cr.Money + "】,扣费失败原因【" + o.message + "】", "开通", CurrentUser); return(GetActionResult(new RPC_Result(false, "注册完成,扣费失败,失败原因【" + o.message + "】"))); } } else { Util.SendSystemLogToISMP(Util.SMSProductName + "开通", "开通完成,充值短信【" + smsNumber + "】条", "企业AccountID【" + eu.AccountID + "】,企业登录名【" + eu.AccountCode + "】", "开通", CurrentUser); return(GetActionResult(new RPC_Result(true, "开通完成,充值短信【" + smsNumber + "】条。"))); } //return GetActionResult(sr); } catch (Exception ex) { Log4Logger.Error(ex); return(GetActionResult(new RPC_Result(true, "操作异常"))); } }
/// <summary> /// 得到一个对象实体 /// </summary> static SMS.Model.EnterpriseUser DataRowToModel(DataRow row) { SMS.Model.EnterpriseUser user = new SMS.Model.EnterpriseUser(); if (row != null) { if (row["Name"] != null) { user.Name = row["Name"].ToString(); } if (row["Contact"] != null) { user.Contact = row["Contact"].ToString(); } if (row["Telephone"] != null) { user.Phone = row["Telephone"].ToString(); } if (row["Province"] != null) { user.Province = row["Province"].ToString(); } if (row["City"] != null) { user.City = row["City"].ToString(); } if (row["Address"] != null) { user.Address = row["Address"].ToString(); } if (row["AccountID"] != null) { user.AccountID = row["AccountID"].ToString(); } if (row["Code"] != null) { user.AccountCode = row["Code"].ToString(); } if (row["AccountPassword"] != null) { user.Password = row["AccountPassword"].ToString(); } if (row["Priority"] != null && row["Priority"].ToString() != "") { user.Priority = int.Parse(row["Priority"].ToString()); } if (row["Audit"] != null && row["Audit"].ToString() != "") { user.Audit = (SMS.Model.AccountAuditType)((ushort)row["Audit"]); } if (row["SPNumber"] != null) { user.SPNumber = row["SPNumber"].ToString(); } if (row["IsEnable"] != null && row["IsEnable"].ToString() != "") { user.Enabled = (ushort)row["IsEnable"] == 1 ? true : false; } if (row["RegisterDate"] != null && row["RegisterDate"].ToString() != "") { user.RegisterDate = DateTime.Parse(row["RegisterDate"].ToString()); } if (row["IsAgent"] != null && row["IsAgent"].ToString() != "") { user.IsAgent = (ushort)row["IsAgent"] == 1 ? true : false; } if (row["ParentAccountCode"] != null) { user.ParentAccountCode = row["ParentAccountCode"].ToString(); } if (row["SecretKey"] != null) { user.SecretKey = row["SecretKey"].ToString(); } if (row["IsOpen"] != null && row["IsOpen"].ToString() != "") { user.IsOpen = (ushort)row["IsOpen"] == 1 ? true : false; } if (row["AppPassword"] != null) { user.AppPassword = row["AppPassword"].ToString(); } DataTable dt = GetSMSSetting(user.AccountCode); if (dt != null) { DataRow dr = dt.Rows[0]; if (dr["StatusReport"] != null && dr["StatusReport"].ToString() != "") { user.StatusReport = (StatusReportType)(ushort)dr["StatusReport"]; } if (dr["FilterType"] != null && dr["FilterType"].ToString() != "") { user.FilterType = (ushort)dr["FilterType"]; } if (dr["Channel"] != null) { user.Channel = dr["Channel"].ToString(); } if (dr["Signature"] != null && dr["Signature"].ToString() != "") { user.Signature = dr["Signature"].ToString(); } if (dr["SMSType"] != null && dr["SMSType"].ToString() != "") { user.SMSType = (SMSType)(int)dr["SMSType"]; } } } return(user); }