Exemplo n.º 1
0
        private string AddRechargePrice(HttpContext context)
        {
            string           dataValue             = context.Request["DataValue"];
            string           orderNum              = context.Request["OrderNum"];
            KeyVauleDataInfo rechargePriceKeyValue = new KeyVauleDataInfo("RechargePrice", bllkeyValueData.GetGUID(TransacType.CommAdd), dataValue
                                                                          , bllkeyValueData.WebsiteOwner, null, currentUserInfo.UserID, orderNum);

            if (bllkeyValueData.Add(rechargePriceKeyValue))
            {
                resp.Status = 1;
                resp.Msg    = "新增成功";
            }
            else
            {
                resp.Status = -1;
                resp.Msg    = "新增失败";
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 提交数据字典
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string PutKeyValue(HttpContext context)
        {
            string autoId       = context.Request["AutoId"];
            string key          = context.Request["key"];
            string dataName     = context.Request["dataName"];
            string type         = context.Request["type"];
            string preKey       = context.Request["preKey"];
            string value        = context.Request["value"];
            string websiteowner = context.Request["websiteowner"];

            KeyVauleDataInfo keyValue = new KeyVauleDataInfo();
            bool             isAdd    = false;

            if (string.IsNullOrWhiteSpace(autoId) || autoId == "0")
            {
                if (string.IsNullOrWhiteSpace(websiteowner))
                {
                    keyValue.WebsiteOwner = bllKeyValueData.WebsiteOwner;
                }
                else
                {
                    keyValue.WebsiteOwner = websiteowner;
                }
                keyValue.Creater    = currentUserInfo.UserID;
                keyValue.CreateTime = DateTime.Now;
                isAdd = true;
                if (string.IsNullOrWhiteSpace(key))
                {
                    keyValue.DataKey = Guid.NewGuid().ToString("N").ToUpper();
                }
            }
            else
            {
                keyValue = bllKeyValueData.GetByKey <KeyVauleDataInfo>("AutoId", autoId);
                if (!string.IsNullOrWhiteSpace(key))
                {
                    keyValue.DataKey = key;
                }
            }

            keyValue.DataName  = dataName;
            keyValue.DataType  = type;
            keyValue.DataValue = value;
            if (!string.IsNullOrWhiteSpace(preKey))
            {
                keyValue.PreKey = preKey;
            }
            bool r = false;

            if (isAdd)
            {
                r = bllKeyValueData.Add(keyValue);
            }
            else
            {
                r = bllKeyValueData.Update(keyValue);
            }
            if (r)
            {
                resp.Status = 1;
                if (keyValue.DataType == "WeixinKindeditor")
                {
                    Comm.StaticData.InitKeyValueData();
                }
                resp.Msg = "提交完成";
            }
            else
            {
                resp.Msg = "提交失败";
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 提交模板数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string PostWXTempmsg(HttpContext context)
        {
            int autoId = Convert.ToInt32(context.Request["AutoId"]);
            KeyVauleDataInfo keyValue = new KeyVauleDataInfo();

            if (autoId > 0)
            {
                keyValue = bllKeyValueData.GetKeyData(autoId);
                if (keyValue == null)
                {
                    resp.errmsg = "原模板没有找到";
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
                if (keyValue.WebsiteOwner != bllKeyValueData.WebsiteOwner)
                {
                    resp.errmsg = "原模板不是本站模板";
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
            }
            else
            {
                keyValue.Creater      = currentUserInfo.UserID;
                keyValue.WebsiteOwner = bllKeyValueData.WebsiteOwner;
                keyValue.CreateTime   = DateTime.Now;
                keyValue.PreKey       = "0";
                keyValue.DataType     = EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsg);
            }

            string oldKey = keyValue.DataKey;

            keyValue = bllKeyValueData.ConvertRequestToModel <KeyVauleDataInfo>(keyValue);
            //微信模板Id变化则清除以前的字段数据
            if (!string.IsNullOrWhiteSpace(oldKey) && oldKey != keyValue.DataKey)
            {
                bllKeyValueData.DeleteDataVaule(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), null, oldKey, bllKeyValueData.WebsiteOwner);
            }

            string keyFieldsJson = context.Request["KeyFields"];
            List <KeyVauleDataInfo> newFieldList = Common.JSONHelper.JsonToModel <List <KeyVauleDataInfo> >(keyFieldsJson);//jSON 反序列化

            for (int i = 0; i < newFieldList.Count; i++)
            {
                newFieldList[i].DataType = EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData);
            }
            List <KeyVauleDataInfo> oldFieldList = bllKeyValueData.GetKeyVauleDataInfoList(EnumStringHelper.ToString(KeyVauleDataType.WXTmplmsgData), keyValue.DataKey
                                                                                           , bllKeyValueData.WebsiteOwner);


            List <KeyVauleDataInfo> deleteFieldList = new List <KeyVauleDataInfo>();
            List <KeyVauleDataInfo> editFieldList   = new List <KeyVauleDataInfo>();
            List <KeyVauleDataInfo> addFieldList    = new List <KeyVauleDataInfo>();

            foreach (KeyVauleDataInfo item in oldFieldList)
            {
                KeyVauleDataInfo temp = newFieldList.FirstOrDefault(p => p.DataType == item.DataType && p.DataKey == item.DataKey);
                if (temp == null)
                {
                    deleteFieldList.Add(item);
                }
                else
                {
                    item.DataValue = temp.DataValue;
                    item.OrderBy   = temp.OrderBy;
                    editFieldList.Add(item);
                }
            }

            foreach (KeyVauleDataInfo item in newFieldList)
            {
                if (!oldFieldList.Exists(p => p.DataType == item.DataType && p.DataKey == item.DataKey))
                {
                    item.Creater      = currentUserInfo.UserID;
                    item.WebsiteOwner = bllKeyValueData.WebsiteOwner;
                    item.CreateTime   = DateTime.Now;
                    item.PreKey       = keyValue.DataKey;
                    addFieldList.Add(item);
                }
            }

            if (deleteFieldList.Count > 0)
            {
                string delIds = Common.MyStringHelper.ListToStr(deleteFieldList.Select(p => p.AutoId).ToList(), "", ",");
                bllKeyValueData.DeleteDataVaule(delIds);
            }

            BLLTransaction tran = new BLLTransaction();//事务

            try
            {
                if (keyValue.AutoId == 0)
                {
                    if (!bllKeyValueData.Add(keyValue, tran))
                    {
                        resp.errmsg = "添加模板失败";
                        tran.Rollback();
                        return(Common.JSONHelper.ObjectToJson(resp));
                    }
                }
                else
                {
                    if (!bllKeyValueData.Update(keyValue, tran))
                    {
                        resp.errmsg = "修改模板失败";
                        tran.Rollback();
                        return(Common.JSONHelper.ObjectToJson(resp));
                    }
                }

                foreach (KeyVauleDataInfo item in editFieldList)//添加问题表
                {
                    if (!bllKeyValueData.Update(item, tran))
                    {
                        resp.errmsg = "模板字段修改失败";
                        tran.Rollback();
                        return(Common.JSONHelper.ObjectToJson(resp));
                    }
                }
                foreach (KeyVauleDataInfo item in addFieldList)//添加问题表
                {
                    if (!bllKeyValueData.Add(item, tran))
                    {
                        resp.errmsg = "模板字段添加失败";
                        tran.Rollback();
                        return(Common.JSONHelper.ObjectToJson(resp));
                    }
                }
                tran.Commit();
                resp.isSuccess = true;
            }
            catch (Exception ex)
            {
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = "提交失败," + ex.Message;
                tran.Rollback();
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }