Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            TableFieldMapping model = new TableFieldMapping();

            model = bll.ConvertRequestToModel <TableFieldMapping>(model);
            TableFieldMapping oModel = bll.GetByKey <TableFieldMapping>("AutoId", model.AutoId.ToString());

            oModel.MappingName    = model.MappingName;
            oModel.FieldType      = model.FieldType;
            oModel.FormatValiFunc = model.FormatValiFunc;
            oModel.FieldIsNull    = model.FieldIsNull;
            oModel.IsShowInList   = model.IsShowInList;
            oModel.IsReadOnly     = model.IsReadOnly;
            oModel.Options        = model.Options;
            oModel.ForeignkeyId   = model.ForeignkeyId;
            bool result = false;

            result = bll.Update(oModel);
            if (!result)
            {
                apiResp.msg  = "编辑失败";
                apiResp.code = (int)APIErrCode.OperateFail;
                bll.ContextResponse(context, apiResp);
                return;
            }
            apiResp.status = true;
            apiResp.msg    = "编辑完成";
            apiResp.code   = (int)APIErrCode.IsSuccess;

            bll.ContextResponse(context, apiResp);
        }
Esempio n. 2
0
        /// <summary>
        /// 添加预约字段
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string FieldAdd(HttpContext context)
        {
            string field         = context.Request["Field"];
            string fieldShowName = context.Request["FieldShowName"];
            string isNull        = context.Request["IsNull"];
            string sort          = context.Request["Sort"];
            string fieldType     = context.Request["FieldType"];
            string options       = context.Request["Options"];
            string isMultiline   = context.Request["IsMultiline"];

            TableFieldMapping model = new TableFieldMapping();

            model.TableName    = "ZCJ_WXMallOrderInfo";
            model.WebSiteOwner = bllMall.WebsiteOwner;
            model.Field        = field;
            model.MappingName  = fieldShowName;
            model.FieldType    = fieldType;
            model.Options      = options;
            model.IsMultiline  = int.Parse(isMultiline);

            if (!string.IsNullOrEmpty(isNull))
            {
                model.FieldIsNull = int.Parse(isNull);
            }
            if (!string.IsNullOrEmpty(sort))
            {
                model.Sort = int.Parse(sort);
            }
            if (bllMall.Add(model))
            {
                apiResp.status = true;
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Esempio n. 3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string FieldUpdate(HttpContext context)
        {
            string            field         = context.Request["Field"];
            string            fieldShowName = context.Request["FieldShowName"];
            string            autoId        = context.Request["AutoId"];
            string            isNull        = context.Request["IsNull"];
            string            sort          = context.Request["Sort"];
            string            fieldType     = context.Request["FieldType"];
            string            options       = context.Request["Options"];
            string            isMultiline   = context.Request["IsMultiline"];
            TableFieldMapping model         = bllMall.Get <TableFieldMapping>(string.Format("AutoId={0}", autoId));

            model.Field       = field;
            model.MappingName = fieldShowName;
            model.FieldType   = fieldType;
            model.Options     = options;
            model.IsMultiline = int.Parse(isMultiline);
            if (!string.IsNullOrEmpty(isNull))
            {
                model.FieldIsNull = int.Parse(isNull);
            }
            if (!string.IsNullOrEmpty(sort))
            {
                model.Sort = int.Parse(sort);
            }
            if (bllMall.Update(model))
            {
                apiResp.status = true;
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Esempio n. 4
0
        public bool GetTableFieldIsShow(bool defShow, string field, List <TableFieldMapping> tbFieldList)
        {
            TableFieldMapping tbField = tbFieldList.FirstOrDefault(p => p.Field == field);

            if (tbField == null)
            {
                return(defShow);
            }
            return(tbField.IsShowInList == 1);
        }
Esempio n. 5
0
        public string GetTableFieldName(string defName, string field, List <TableFieldMapping> tbFieldList)
        {
            TableFieldMapping tbField = tbFieldList.FirstOrDefault(p => p.Field == field);

            if (tbField == null)
            {
                return(defName);
            }
            return(tbField.MappingName);
        }
Esempio n. 6
0
        public string GetTableFieldName(string defName, string websiteOwner, string tableName, string field, string mappingType = "0")
        {
            TableFieldMapping tbField = Get <TableFieldMapping>(GetWhereParamString(websiteOwner, tableName, null, field, false, mappingType));

            if (tbField == null)
            {
                return(defName);
            }
            return(tbField.MappingName);
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            config = bll.GetCompanyWebsiteConfig();

            toolBars = bllCompanyWebSite.GetToolBarList(int.MaxValue, 1, bllCompanyWebSite.WebsiteOwner, null, null, false)
                       .OrderBy(p => p.KeyType).Select(p => p.KeyType).Distinct().ToList();
            slides = bllSlide.GetCurrWebsiteAllTypeList();

            #region 会员标准字段
            List <TableFieldMapping> baseFieldList = bllTableFieldMap.GetTableFieldMap(null, "ZCJ_UserInfo");
            List <TableFieldMapping> webFieldList  = bllTableFieldMap.GetTableFieldMap(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, true);
            foreach (var item in baseFieldList)
            {
                if (fieldList.Exists(p => p.Value == item.Field))
                {
                    continue;
                }
                TableFieldMapping nWebFieldItem = webFieldList.FirstOrDefault(p => p.Field == item.Field);
                fieldList.Add(new ListItem
                {
                    Value    = item.Field,
                    Text     = nWebFieldItem == null ? item.MappingName : nWebFieldItem.MappingName,
                    Selected = nWebFieldItem != null && nWebFieldItem.IsDelete == 0 ? true:false
                });
            }
            List <string> baseFieldStringList = baseFieldList.Select(p => p.Field).ToList();
            foreach (var item in webFieldList.Where(p => !baseFieldStringList.Contains(p.Field)))
            {
                if (fieldList.Exists(p => p.Value == item.Field))
                {
                    continue;
                }
                fieldList.Add(new ListItem
                {
                    Value    = item.Field,
                    Text     = item.MappingName,
                    Selected = item.IsDelete == 0 ? true : false
                });
            }
            #endregion 会员标准字段

            currentWebsiteInfo = bll.GetWebsiteInfoModelFromDataBase();

            List <CompanyWebsite_ToolBar> dataList = bll.GetColList <CompanyWebsite_ToolBar>(int.MaxValue, 1, string.Format(" WebsiteOwner = '{0}'", bll.WebsiteOwner), "AutoID,KeyType,BaseID");
            ArticleGroups = dataList.OrderBy(p => p.KeyType).Select(p => p.KeyType).Distinct().ToList();

            if (!string.IsNullOrEmpty(config.LoginConfigJson))
            {
                JTokenLogin = JToken.Parse(config.LoginConfigJson);
            }
        }
Esempio n. 8
0
        public void ProcessRequest(HttpContext context)
        {
            string   code            = context.Request["code"];
            string   Phone           = context.Request["Phone"];
            UserInfo CurrentUserInfo = bllUser.GetCurrentUserInfo();


            #region 检查是否已登录
            if (CurrentUserInfo != null)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "本功能仅供新用户使用";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            #endregion
            #region 检查是否微信服务号
            if (context.Session["currWXOpenId"] == null)
            {
                apiResp.code = (int)APIErrCode.UserIsNotLogin;
                apiResp.msg  = "本功能仅供微信服务号使用";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            #endregion
            string wxOpenId = context.Session["currWXOpenId"].ToString();
            CurrentUserInfo = bllUser.GetUserInfoByOpenId(wxOpenId);
            if (CurrentUserInfo != null)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "OpenId已被绑定";
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            #region 判断手机格式
            if (!MyRegex.PhoneNumLogicJudge(Phone))
            {
                apiResp.code = (int)APIErrCode.PhoneFormatError;
                apiResp.msg  = "手机格式错误";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            #endregion
            #region 判断手机是否已被使用
            UserInfo model = bllUser.GetUserInfoByPhone(Phone);
            if (model != null)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "手机号码已被其他账号使用,请联系管理员";
                bllSms.ContextResponse(context, apiResp);
                return;
            }
            #endregion
            #region 判断验证码是否正确
            SmsVerificationCode sms = bllSms.GetLastSmsVerificationCode(Phone);
            if (sms == null || sms.VerificationCode != code)
            {
                apiResp.code = (int)APIErrCode.CheckCodeErr;
                apiResp.msg  = "验证码错误";
                bllSms.ContextResponse(context, apiResp);
                return;
            }
            #endregion

            List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, "0", null);
            List <string>            defFields     = new List <string>()
            {
                "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone"
            };

            #region 账号检查 未登录时检查已有账号
            CurrentUserInfo = bllUser.GetUserInfoByAllPhone(Phone);
            if (CurrentUserInfo != null)
            {
                List <string> tempFields = new List <string>()
                {
                    "Phone1", "Phone2", "Phone3"
                };
                List <GetCompleteField.ResultField> resultList = new List <GetCompleteField.ResultField>();
                #region 取姓名
                TableFieldMapping AcountTrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName"));

                if (AcountTrueNameField == null)
                {
                    resultList.Add(new GetCompleteField.ResultField {
                        field = "TrueName", field_name = "姓名", type = "txt", no_null = 1, value = CurrentUserInfo.TrueName, read_only = 0
                    });
                }
                else
                {
                    resultList.Add(new GetCompleteField.ResultField {
                        field = "TrueName", field_name = AcountTrueNameField.MappingName, type = "txt", no_null = AcountTrueNameField.FieldIsNull, value = CurrentUserInfo.TrueName, read_only = AcountTrueNameField.IsReadOnly
                    });
                }
                #endregion
                #region 取手机
                if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone1))
                {
                    TableFieldMapping AcountPhone1Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone1"));
                    if (AcountPhone1Field == null)
                    {
                        resultList.Add(new GetCompleteField.ResultField {
                            field = "TrueName", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone1, read_only = 0
                        });
                    }
                    else
                    {
                        resultList.Add(new GetCompleteField.ResultField {
                            field = "TrueName", field_name = AcountPhone1Field.MappingName, type = "txt", no_null = AcountPhone1Field.FieldIsNull, value = CurrentUserInfo.Phone1, read_only = AcountPhone1Field.IsReadOnly
                        });
                    }
                }
                if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone2))
                {
                    TableFieldMapping AcountPhone2Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone2"));
                    if (AcountPhone2Field == null)
                    {
                        resultList.Add(new GetCompleteField.ResultField {
                            field = "Phone2", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone2, read_only = 0
                        });
                    }
                    else
                    {
                        resultList.Add(new GetCompleteField.ResultField {
                            field = "Phone2", field_name = AcountPhone2Field.MappingName, type = "txt", no_null = AcountPhone2Field.FieldIsNull, value = CurrentUserInfo.Phone2, read_only = AcountPhone2Field.IsReadOnly
                        });
                    }
                }
                if (!string.IsNullOrWhiteSpace(CurrentUserInfo.Phone3))
                {
                    TableFieldMapping AcountPhone3Field = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone3"));
                    if (AcountPhone3Field == null)
                    {
                        resultList.Add(new GetCompleteField.ResultField {
                            field = "Phone3", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone3, read_only = 0
                        });
                    }
                    else
                    {
                        resultList.Add(new GetCompleteField.ResultField {
                            field = "Phone3", field_name = AcountPhone3Field.MappingName, type = "txt", no_null = AcountPhone3Field.FieldIsNull, value = CurrentUserInfo.Phone3, read_only = AcountPhone3Field.IsReadOnly
                        });
                    }
                }
                #endregion
                #region 取其他信息
                JObject tCurUser = JObject.FromObject(CurrentUserInfo);
                foreach (var item in listFieldList.Where(p => !defFields.Contains(p.Field) && !tempFields.Contains(p.Field)))
                {
                    if (tCurUser[item.Field] == null)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(tCurUser[item.Field].ToString()))
                    {
                        continue;
                    }
                    string FieldType = string.IsNullOrWhiteSpace(item.FieldType) ? "txt" : item.FieldType;
                    resultList.Add(new GetCompleteField.ResultField {
                        field = item.Field, field_name = item.MappingName, type = FieldType, no_null = item.FieldIsNull, value = tCurUser[item.Field].ToString(), read_only = item.IsReadOnly
                    });
                }
                #endregion

                apiResp.code   = (int)APIErrCode.HaveHistoryAcount;
                apiResp.msg    = "注册手机已存在账号";
                apiResp.result = new
                {
                    have_acount = true,
                    id          = CurrentUserInfo.AutoID,
                    info_list   = resultList
                };
                bllSms.ContextResponse(context, apiResp);
                return;
            }
            else
            {
                CurrentUserInfo = new UserInfo();
                string guidString = Guid.NewGuid().ToString();
                CurrentUserInfo.UserID        = string.Format("WXUser{0}", guidString); //Guid
                CurrentUserInfo.Password      = guidString.Substring(0, 8);             //Guid
                CurrentUserInfo.WXHeadimgurl  = string.Format("http://{0}", context.Request.Url.Authority) + "/img/persion.png";
                CurrentUserInfo.WebsiteOwner  = bllUser.WebsiteOwner;
                CurrentUserInfo.UserType      = 2;
                CurrentUserInfo.WXOpenId      = wxOpenId;
                CurrentUserInfo.Regtime       = DateTime.Now;
                CurrentUserInfo.LastLoginDate = DateTime.Now;
            }
            #endregion


            //string oldPhone = CurrentUserInfo.Phone;
            CurrentUserInfo = bllTableFieldMap.ConvertRequestToModel <UserInfo>(CurrentUserInfo);
            //if(CurrentUserInfo.IsPhoneVerify == 1) CurrentUserInfo.Phone = oldPhone;

            #region 默认信息检查 姓名
            TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName"));
            if ((TrueNameField == null || TrueNameField.FieldIsNull == 1) && string.IsNullOrWhiteSpace(CurrentUserInfo.TrueName))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "请完善姓名";
                bllTableFieldMap.ContextResponse(context, apiResp);
                return;
            }
            #endregion

            JObject jtCurUser = JObject.FromObject(CurrentUserInfo);
            foreach (var item in listFieldList.Where(p => p.FieldIsNull == 1 && !defFields.Contains(p.Field)).OrderBy(p => p.Sort))
            {
                if (jtCurUser[item.Field] == null)
                {
                    continue;
                }
                if (string.IsNullOrWhiteSpace(jtCurUser[item.Field].ToString()))
                {
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "请完善" + item.MappingName;
                    bllTableFieldMap.ContextResponse(context, apiResp);
                    return;
                }
                if (!string.IsNullOrWhiteSpace(item.FormatValiFunc))
                {
                    #region 检查数据格式
                    //检查数据格式
                    if (item.FormatValiFunc == "number")
                    {
                        if (!MyRegex.IsNumber(jtCurUser[item.Field].ToString()))
                        {
                            apiResp.code = (int)APIErrCode.OperateFail;
                            apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                            bllTableFieldMap.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    if (item.FormatValiFunc == "phone")//email检查
                    {
                        if (!MyRegex.PhoneNumLogicJudge(jtCurUser[item.Field].ToString()))
                        {
                            apiResp.code = (int)APIErrCode.OperateFail;
                            apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                            bllTableFieldMap.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    if (item.FormatValiFunc == "email")//email检查
                    {
                        if (!MyRegex.EmailLogicJudge(jtCurUser[item.Field].ToString()))
                        {
                            apiResp.code = (int)APIErrCode.OperateFail;
                            apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                            bllTableFieldMap.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    if (item.FormatValiFunc == "url")                                                                                                             //url检查
                    {
                        System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址
                        System.Text.RegularExpressions.Match match  = regUrl.Match(jtCurUser[item.Field].ToString());
                        if (!match.Success)
                        {
                            apiResp.code = (int)APIErrCode.OperateFail;
                            apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                            bllTableFieldMap.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    #endregion
                }
            }
            CurrentUserInfo.IsPhoneVerify = 1;
            CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig();
            if (nWebsiteConfig.MemberStandard == 2)
            {
                if (CurrentUserInfo.AccessLevel < 1)
                {
                    CurrentUserInfo.AccessLevel     = 1;
                    CurrentUserInfo.MemberStartTime = DateTime.Now;
                }
                //CurrentUserInfo.MemberApplyStatus = 9;
            }
            else if (nWebsiteConfig.MemberStandard == 3)
            {
                CurrentUserInfo.MemberApplyStatus = 1;
                CurrentUserInfo.MemberApplyTime   = DateTime.Now;
            }
            if (bllUser.Add(CurrentUserInfo))
            {
                apiResp.status = true;
                apiResp.code   = (int)APIErrCode.IsSuccess;
                apiResp.msg    = "提交完成";

                context.Session[ZentCloud.Common.SessionKey.UserID]     = CurrentUserInfo.UserID;
                context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态
            }
            else
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "提交失败";
            }
            bllUser.ContextResponse(context, apiResp);
        }
Esempio n. 9
0
        public void ProcessRequest(HttpContext context)
        {
            string             mapping_type = context.Request["mapping_type"];
            List <ResultField> resultList   = new List <ResultField>();

            //获取当前用户信息 未登录时实例化UserInfo
            UserInfo CurrentUserInfo = bllTableFieldMap.GetCurrentUserInfo();

            if (CurrentUserInfo == null)
            {
                CurrentUserInfo = new UserInfo();
            }

            List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, mapping_type, null);

            mapping_type = listFieldList.Count > 0 ? listFieldList[0].MappingType.ToString() : mapping_type;

            List <string> DefFields = new List <string>()
            {
                "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone", "Avatar"
            };

            #region 照片
            TableFieldMapping AvatarField = listFieldList.FirstOrDefault(p => p.Field.Equals("Avatar"));
            if (AvatarField != null)
            {
                resultList.Add(new ResultField {
                    field = "Avatar", field_name = AvatarField.MappingName, type = AvatarField.FieldType, no_null = AvatarField.FieldIsNull, value = CurrentUserInfo.Avatar, read_only = AvatarField.IsReadOnly
                });
            }
            #endregion
            #region 姓名
            TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName"));
            if (TrueNameField == null)
            {
                resultList.Add(new ResultField {
                    field = "TrueName", field_name = "姓名", type = "txt", no_null = 1, value = CurrentUserInfo.TrueName, read_only = 0
                });
            }
            else
            {
                resultList.Add(new ResultField {
                    field = "TrueName", field_name = TrueNameField.MappingName, type = "txt", no_null = TrueNameField.FieldIsNull, value = CurrentUserInfo.TrueName, read_only = TrueNameField.IsReadOnly
                });
            }
            #endregion
            #region 手机
            TableFieldMapping PhoneField = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone"));
            if (PhoneField == null)
            {
                //curUser.IsPhoneVerify
                resultList.Add(new ResultField {
                    field = "Phone", field_name = "手机", type = "txt", no_null = 1, value = CurrentUserInfo.Phone, read_only = 0
                });
            }
            else
            {
                resultList.Add(new ResultField {
                    field = "Phone", field_name = PhoneField.MappingName, type = "txt", no_null = PhoneField.FieldIsNull, value = CurrentUserInfo.Phone, read_only = PhoneField.IsReadOnly
                });
            }
            #endregion
            JObject          jtCurUser     = JObject.FromObject(CurrentUserInfo);
            List <JProperty> listPropertys = jtCurUser.Properties().ToList();
            foreach (var item in listFieldList.Where(p => !DefFields.Contains(p.Field)).OrderBy(p => p.Sort))
            {
                if (!listPropertys.Exists(p => p.Name.Equals(item.Field)))
                {
                    continue;
                }
                string FieldType = string.IsNullOrWhiteSpace(item.FieldType) ? "txt" : item.FieldType;
                resultList.Add(new ResultField {
                    field = item.Field, field_name = item.MappingName, type = FieldType, no_null = item.FieldIsNull, value = jtCurUser[item.Field].ToString(), read_only = item.IsReadOnly
                });
            }
            apiResp.result = new
            {
                can_edit     = resultList.Where(p => p.read_only == 0).Count() > 0,
                field_list   = resultList,
                mapping_type = mapping_type,
                id           = CurrentUserInfo.AutoID
            };
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.msg    = "查询完成";
            bllTableFieldMap.ContextResponse(context, apiResp);
        }
Esempio n. 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserInfo curUser = bllUser.GetCurrentUserInfo();

            if (curUser != null)
            {
                //this.Response.Redirect("/Error/CommonMsg.aspx?msg=" + HttpUtility.UrlEncode("本功能仅供新用户使用"));
                this.Response.Redirect("/customize/comeoncloud/Index.aspx?key=MallHome");
                return;
            }
            curUser = new UserInfo();
            CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig();

            memberStandardDescription = nWebsiteConfig.MemberStandardDescription;
            pageName = "会员注册";

            List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, "0", null);
            List <string>            DefFields     = new List <string>()
            {
                "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone", "Avatar"
            };

            #region 照片
            TableFieldMapping AvatarField = listFieldList.FirstOrDefault(p => p.Field.Equals("Avatar"));
            if (AvatarField != null)
            {
                //curUser.IsPhoneVerify
                formField.Add(new TableFieldMapping()
                {
                    Field = "Avatar", MappingName = AvatarField.MappingName, FieldType = AvatarField.FieldType, Disabled = 0, Value = curUser.Avatar, FieldIsNull = AvatarField.FieldIsNull
                });
            }
            #endregion
            #region 姓名
            TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName"));
            if (TrueNameField == null)
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "TrueName", MappingName = "姓名", Disabled = 0, Value = curUser.TrueName, FieldIsNull = 1
                });
            }
            else
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "TrueName", MappingName = TrueNameField.MappingName, Disabled = 0, Value = curUser.TrueName, FieldIsNull = TrueNameField.FieldIsNull
                });
            }
            #endregion
            #region 手机
            TableFieldMapping PhoneField = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone"));
            if (PhoneField == null)
            {
                //curUser.IsPhoneVerify
                formField.Add(new TableFieldMapping()
                {
                    Field = "Phone", MappingName = "手机", Disabled = 0, Value = curUser.Phone, FieldIsNull = 1
                });
            }
            else
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "Phone", MappingName = PhoneField.MappingName, Disabled = 0, Value = curUser.Phone, FieldIsNull = PhoneField.FieldIsNull
                });
            }
            #endregion
            JObject          jtCurUser     = JObject.FromObject(curUser);
            List <JProperty> listPropertys = jtCurUser.Properties().ToList();
            foreach (var item in listFieldList.Where(p => !DefFields.Contains(p.Field)).OrderBy(p => p.Sort))
            {
                if (!listPropertys.Exists(p => p.Name.Equals(item.Field)))
                {
                    continue;
                }
                formField.Add(new TableFieldMapping()
                {
                    Field = item.Field, MappingName = item.MappingName, FieldType = item.FieldType, Disabled = 0, Value = jtCurUser[item.Field].ToString(), FieldIsNull = item.FieldIsNull
                });
            }

            //头部图标引用
            ico_css_file = bllWebSite.GetIcoFilePath();
        }
Esempio n. 11
0
        public void ProcessRequest(HttpContext context)
        {
            string code  = context.Request["code"];
            string Phone = context.Request["Phone"];

            string wxOpenId;

            UserInfo CurrentUserInfo = bllUser.GetCurrentUserInfo();

            #region 判断手机格式
            if (!MyRegex.PhoneNumLogicJudge(Phone))
            {
                apiResp.code = (int)APIErrCode.PhoneFormatError;
                apiResp.msg  = "手机格式错误";
                bllTableFieldMap.ContextResponse(context, apiResp);
                return;
            }
            #endregion

            #region 判断验证码是否正确
            SmsVerificationCode sms = bllSms.GetLastSmsVerificationCode(Phone);
            if (sms == null || sms.VerificationCode != code)
            {
                apiResp.code = (int)APIErrCode.CheckCodeErr;
                apiResp.msg  = "验证码错误";
                bllSms.ContextResponse(context, apiResp);
                return;
            }
            #endregion

            #region 账号检查 未登录时检查已有账号
            if (CurrentUserInfo == null)
            {
                if (context.Session["currWXOpenId"] == null)
                {
                    apiResp.code = (int)APIErrCode.UserIsNotLogin;
                    apiResp.msg  = "请先登录";
                    bllSms.ContextResponse(context, apiResp);
                    return;
                }
                wxOpenId = context.Session["currWXOpenId"].ToString();
                UserInfo curUser = bllUser.GetUserInfoByOpenId(wxOpenId);
                if (curUser != null)
                {
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "微信已绑定有账号";
                    bllSms.ContextResponse(context, apiResp);
                    return;
                }
                curUser = bllUser.GetUserInfoByAllPhone(Phone);
                if (curUser != null)
                {
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "微信已绑定有账号";
                    bllSms.ContextResponse(context, apiResp);
                    return;
                }
            }
            #endregion

            #region 判断手机是否已被使用
            UserInfo model = bllUser.GetUserInfoByPhone(Phone);
            if (model != null)
            {
                if (model.UserID != CurrentUserInfo.UserID)
                {
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "手机号码已被其他账号使用,请联系管理员";
                    bllSms.ContextResponse(context, apiResp);
                    return;
                }
            }
            #endregion

            //string oldPhone = CurrentUserInfo.Phone;
            CurrentUserInfo = bllTableFieldMap.ConvertRequestToModel <UserInfo>(CurrentUserInfo);
            //if(CurrentUserInfo.IsPhoneVerify == 1) CurrentUserInfo.Phone = oldPhone;

            List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByTableName(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo");

            List <string> DefFields = new List <string>()
            {
                "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone"
            };

            #region 默认信息检查 姓名
            TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName"));
            if ((TrueNameField == null || TrueNameField.FieldIsNull == 1) && string.IsNullOrWhiteSpace(CurrentUserInfo.TrueName))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "请完善姓名";
                bllTableFieldMap.ContextResponse(context, apiResp);
                return;
            }
            #endregion

            JObject          jtCurUser     = JObject.FromObject(CurrentUserInfo);
            List <JProperty> listPropertys = jtCurUser.Properties().ToList();
            foreach (var item in listFieldList.Where(p => p.FieldIsNull == 1 && !DefFields.Contains(p.Field)).OrderBy(p => p.Sort))
            {
                if (!listPropertys.Exists(p => p.Name.Equals(item.Field)))
                {
                    continue;
                }
                if (string.IsNullOrWhiteSpace(jtCurUser[item.Field].ToString()))
                {
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "请完善" + item.MappingName;
                    bllTableFieldMap.ContextResponse(context, apiResp);
                    return;
                }
                if (!string.IsNullOrWhiteSpace(item.FormatValiFunc))
                {
                    #region 检查数据格式
                    //检查数据格式
                    if (item.FormatValiFunc == "number")
                    {
                        if (!MyRegex.IsNumber(jtCurUser[item.Field].ToString()))
                        {
                            apiResp.code = (int)APIErrCode.OperateFail;
                            apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                            bllTableFieldMap.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    if (item.FormatValiFunc == "phone")//email检查
                    {
                        if (!MyRegex.PhoneNumLogicJudge(jtCurUser[item.Field].ToString()))
                        {
                            apiResp.code = (int)APIErrCode.OperateFail;
                            apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                            bllTableFieldMap.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    if (item.FormatValiFunc == "email")//email检查
                    {
                        if (!MyRegex.EmailLogicJudge(jtCurUser[item.Field].ToString()))
                        {
                            apiResp.code = (int)APIErrCode.OperateFail;
                            apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                            bllTableFieldMap.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    if (item.FormatValiFunc == "url")                                                                                                             //url检查
                    {
                        System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址
                        System.Text.RegularExpressions.Match match  = regUrl.Match(jtCurUser[item.Field].ToString());
                        if (!match.Success)
                        {
                            apiResp.code = (int)APIErrCode.OperateFail;
                            apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                            bllTableFieldMap.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    #endregion
                }
            }
            CurrentUserInfo.IsPhoneVerify = 1;
            CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig();
            if (nWebsiteConfig.MemberStandard == 2)
            {
                if (CurrentUserInfo.AccessLevel < 1)
                {
                    CurrentUserInfo.AccessLevel     = 1;
                    CurrentUserInfo.MemberStartTime = DateTime.Now;
                }
                //CurrentUserInfo.MemberApplyStatus = 9;
            }
            else if (nWebsiteConfig.MemberStandard == 3)
            {
                CurrentUserInfo.MemberApplyStatus = 1;
                CurrentUserInfo.MemberApplyTime   = DateTime.Now;
            }
            if (bllUser.Update(CurrentUserInfo))
            {
                apiResp.status = true;
                apiResp.code   = (int)APIErrCode.IsSuccess;
                apiResp.msg    = "提交完成";
            }
            else
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "提交失败";
            }
            bllUser.ContextResponse(context, apiResp);
        }
Esempio n. 12
0
        public void ProcessRequest(HttpContext context)
        {
            string ids            = context.Request["ids"];
            string mapping_type   = context.Request["mapping_type"];
            string t_mapping_type = context.Request["t_mapping_type"];
            int    tMappingType   = int.Parse(t_mapping_type);
            string table_name     = context.Request["table_name"];

            if (mapping_type == t_mapping_type)
            {
                apiResp.msg  = "不能复制到本身类型";
                apiResp.code = (int)APIErrCode.OperateFail;
                bll.ContextResponse(context, apiResp);
                return;
            }

            List <string> sIdList = ids.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).ToList();

            if (sIdList.Count == 0)
            {
                apiResp.msg  = "请选择字段";
                apiResp.code = (int)APIErrCode.OperateFail;
                bll.ContextResponse(context, apiResp);
                return;
            }
            //根据ID查出数据
            List <TableFieldMapping> sList = bll.GetTableFieldMap(bll.WebsiteOwner, table_name, null, null, true, mapping_type);

            sList = sList.Where(p => ids.Contains(p.AutoId.ToString())).ToList();
            List <string> sFieldList = sList.Select(p => p.Field).Distinct().ToList();

            if (sList.Count == 0)
            {
                apiResp.msg  = "字段未找到!";
                apiResp.code = (int)APIErrCode.OperateFail;
                bll.ContextResponse(context, apiResp);
                return;
            }

            //查出目标类型已有字段
            List <TableFieldMapping> mList = bll.GetTableFieldMap(bll.WebsiteOwner, table_name, null, null, true, t_mapping_type);
            //查出已有字段
            List <TableFieldMapping> hList      = mList.Where(p => sFieldList.Contains(p.Field) && p.IsDelete == 0).ToList();
            List <TableFieldMapping> dList      = mList.Where(p => sFieldList.Contains(p.Field) && p.IsDelete == 1).ToList();
            List <string>            hFieldList = new List <string>();
            List <string>            dFieldList = new List <string>();

            if (hList.Count > 0)
            {
                hFieldList = hList.Select(p => p.Field).Distinct().ToList();
            }
            if (dList.Count > 0)
            {
                dFieldList = dList.Select(p => p.Field).Distinct().ToList();
            }

            //排除已有字段
            List <TableFieldMapping> cList = sList.Where(p => !hFieldList.Contains(p.Field) && !dFieldList.Contains(p.Field)).ToList();

            if (cList.Count == 0 && dList.Count == 0)
            {
                apiResp.msg  = "要复制的字段目标类型已全部存在!";
                apiResp.code = (int)APIErrCode.OperateFail;
                bll.ContextResponse(context, apiResp);
                return;
            }

            foreach (TableFieldMapping item in dList)
            {
                TableFieldMapping citem = sList.FirstOrDefault(p => p.Field == item.Field);
                item.MappingName    = citem.MappingName;
                item.FieldIsNull    = citem.FieldIsNull;
                item.FieldType      = citem.FieldType;
                item.FormatValiFunc = citem.FormatValiFunc;
                item.IsShowInList   = citem.IsShowInList;
                item.IsReadOnly     = citem.IsReadOnly;
                item.IsDelete       = citem.IsDelete;
                item.ForeignkeyId   = citem.ForeignkeyId;
                item.Sort           = citem.Sort;
                bll.Update(item);
            }
            foreach (TableFieldMapping item in cList)
            {
                item.MappingType = tMappingType;
                bll.Add(item);
            }

            if (hFieldList.Count > 0)
            {
                apiResp.msg = "[" + ZentCloud.Common.MyStringHelper.ListToStr(hFieldList, "", ",") + "]已存在,其他复制完成";
            }
            else
            {
                apiResp.msg = "复制完成";
            }
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bll.ContextResponse(context, apiResp);
        }
Esempio n. 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMapByTableName(bllUser.WebsiteOwner, "ZCJ_UserInfo");
            List <string>            DefFields     = new List <string>()
            {
                "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone", "Avatar"
            };

            #region 照片
            AvatarField = listFieldList.FirstOrDefault(p => p.Field.Equals("Avatar"));
            #endregion
            #region 姓名
            TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName"));
            if (TrueNameField == null)
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "TrueName", MappingName = "姓名"
                });
            }
            else
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "TrueName", MappingName = TrueNameField.MappingName
                });
            }
            #endregion
            #region 手机
            TableFieldMapping PhoneField = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone"));
            if (PhoneField == null)
            {
                //curUser.IsPhoneVerify
                formField.Add(new TableFieldMapping()
                {
                    Field = "Phone", MappingName = "手机"
                });
            }
            else
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "Phone", MappingName = PhoneField.MappingName
                });
            }
            #endregion
            //#region 公司
            //TableFieldMapping CompanyField = listFieldList.FirstOrDefault(p => p.Field.Equals("Company"));
            //if (CompanyField == null)
            //{
            //    formField.Add(new TableFieldMapping() { Field = "Company", MappingName = "公司"});
            //}
            //else
            //{
            //    formField.Add(new TableFieldMapping() { Field = "Company", MappingName = CompanyField.MappingName });
            //}
            //#endregion
            //#region 职位
            //TableFieldMapping PostionField = listFieldList.FirstOrDefault(p => p.Field.Equals("Postion"));
            //if (PostionField == null)
            //{
            //    formField.Add(new TableFieldMapping() { Field = "Postion", MappingName = "职位" });
            //}
            //else
            //{
            //    formField.Add(new TableFieldMapping() { Field = "Postion", MappingName = PostionField.MappingName});
            //}
            //#endregion
            listFieldList = listFieldList.Where(p => !DefFields.Contains(p.Field)).OrderBy(p => p.Sort).ToList();
            JObject          jtCurUser     = JObject.FromObject(new UserInfo());
            List <JProperty> listPropertys = jtCurUser.Properties().ToList();
            foreach (var item in listFieldList.Where(p => !DefFields.Contains(p.Field)).OrderBy(p => p.Sort))
            {
                if (!listPropertys.Exists(p => p.Name.Equals(item.Field)))
                {
                    continue;
                }
                formField.Add(new TableFieldMapping()
                {
                    Field = item.Field, MappingName = item.MappingName
                });
            }
        }
Esempio n. 14
0
 /// <summary>
 /// 添加字段类型映射
 /// </summary>
 /// <param name="tableFieldMap">实体</param>
 /// <param name="fieldType">字段类型枚举</param>
 /// <returns></returns>
 public bool AddTableFieldMap(TableFieldMapping tableFieldMap, EnumTableFieldType fieldType)
 {
     tableFieldMap.FieldType = ((int)fieldType).ToString();
     return(Add(tableFieldMap));
 }
Esempio n. 15
0
 /// <summary>
 /// 添加字段类型映射
 /// </summary>
 /// <param name="tableFieldMap">实体</param>
 /// <returns></returns>
 public bool AddTableFieldMap(TableFieldMapping tableFieldMap)
 {
     return(Add(tableFieldMap));
 }
Esempio n. 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            referrer = this.Request["referrer"];
            UserInfo curUser = bllUser.GetCurrentUserInfo();

            if (curUser == null)
            {
                curUser = new UserInfo();
            }
            CompanyWebsite_Config nWebsiteConfig = bllWebSite.GetCompanyWebsiteConfig();

            memberStandardDescription = nWebsiteConfig.MemberStandardDescription;
            if (nWebsiteConfig.MemberStandard == 1)
            {
                this.Response.Redirect("PhoneVerify.aspx?referrer=" + HttpUtility.UrlEncode(referrer));
                return;
            }
            pageName = "完善资料";
            if (nWebsiteConfig.MemberStandard == 3)
            {
                pageName = "会员注册";
                referrer = "/Error/IsInApply.htm";
                if (curUser.MemberApplyStatus == 1)
                {
                    this.Response.Redirect("/Error/IsInApply.htm");
                    return;
                }
            }

            List <TableFieldMapping> listFieldList = bllTableFieldMap.GetTableFieldMap(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo");
            List <string>            DefFields     = new List <string>()
            {
                "AutoID", "UserID", "Password", "UserType", "TrueName", "Phone", "Avatar"
            };

            #region 照片
            TableFieldMapping AvatarField = listFieldList.FirstOrDefault(p => p.Field.Equals("Avatar"));
            if (AvatarField != null)
            {
                //curUser.IsPhoneVerify
                formField.Add(new TableFieldMapping()
                {
                    Field = "Avatar", MappingName = AvatarField.MappingName, FieldType = AvatarField.FieldType, Disabled = 0, Value = curUser.Avatar, FieldIsNull = AvatarField.FieldIsNull
                });
            }
            #endregion
            #region 姓名
            TableFieldMapping TrueNameField = listFieldList.FirstOrDefault(p => p.Field.Equals("TrueName"));
            if (TrueNameField == null)
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "TrueName", MappingName = "姓名", Disabled = 0, Value = curUser.TrueName, FieldIsNull = 1
                });
            }
            else
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "TrueName", MappingName = TrueNameField.MappingName, Disabled = 0, Value = curUser.TrueName, FieldIsNull = TrueNameField.FieldIsNull
                });
            }
            #endregion
            #region 手机
            TableFieldMapping PhoneField = listFieldList.FirstOrDefault(p => p.Field.Equals("Phone"));
            if (PhoneField == null)
            {
                //curUser.IsPhoneVerify
                formField.Add(new TableFieldMapping()
                {
                    Field = "Phone", MappingName = "手机", Disabled = 0, Value = curUser.Phone, FieldIsNull = 1
                });
            }
            else
            {
                formField.Add(new TableFieldMapping()
                {
                    Field = "Phone", MappingName = PhoneField.MappingName, Disabled = 0, Value = curUser.Phone, FieldIsNull = PhoneField.FieldIsNull
                });
            }
            #endregion
            //#region 公司
            //TableFieldMapping CompanyField = listFieldList.FirstOrDefault(p => p.Field.Equals("Company"));
            //if (CompanyField != null)
            //{
            //    formField.Add(new TableFieldMapping() { Field = "Company", MappingName = CompanyField.MappingName, Disabled = 0, Value = curUser.Company, FieldIsNull = CompanyField.FieldIsNull });
            //}
            //#endregion
            //#region 职位
            //TableFieldMapping PostionField = listFieldList.FirstOrDefault(p => p.Field.Equals("Postion"));
            //if (PostionField != null)
            //{
            //    formField.Add(new TableFieldMapping() { Field = "Postion", MappingName = PostionField.MappingName, Disabled = 0, Value = curUser.Postion, FieldIsNull = PostionField.FieldIsNull });
            //}
            //#endregion
            JObject          jtCurUser     = JObject.FromObject(curUser);
            List <JProperty> listPropertys = jtCurUser.Properties().ToList();
            foreach (var item in listFieldList.Where(p => !DefFields.Contains(p.Field)).OrderBy(p => p.Sort))
            {
                if (!listPropertys.Exists(p => p.Name.Equals(item.Field)))
                {
                    continue;
                }
                formField.Add(new TableFieldMapping()
                {
                    Field = item.Field, MappingName = item.MappingName, FieldType = item.FieldType, Disabled = 0, Value = jtCurUser[item.Field].ToString(), FieldIsNull = item.FieldIsNull
                });
            }

            //头部图标引用
            ico_css_file = bllWebSite.GetIcoFilePath();
        }
Esempio n. 17
0
File: Add.ashx.cs Progetto: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            TableFieldMapping model = new TableFieldMapping();

            model = bll.ConvertRequestToModel <TableFieldMapping>(model);
            if (string.IsNullOrWhiteSpace(model.WebSiteOwner))
            {
                model.WebSiteOwner = bll.WebsiteOwner;
            }

            if (string.IsNullOrWhiteSpace(model.TableName))
            {
                apiResp.msg  = "表名不能为空";
                apiResp.code = (int)APIErrCode.OperateFail;
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (string.IsNullOrWhiteSpace(model.Field))
            {
                apiResp.msg  = "字段不能为空";
                apiResp.code = (int)APIErrCode.OperateFail;
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (!bll.ExistsTableField(model.TableName, model.Field))
            {
                apiResp.msg  = "字段不存在";
                apiResp.code = (int)APIErrCode.OperateFail;
                bll.ContextResponse(context, apiResp);
                return;
            }
            //所增字段,是否存在删除的记录
            List <TableFieldMapping> oldList = bll.GetTableFieldMap(bll.WebsiteOwner, model.TableName, model.ForeignkeyId, model.Field, true, model.MappingType.ToString(), colName: "AutoId,Sort,IsDelete");

            if (oldList.Count > 0)
            {
                if (oldList.Where(p => p.IsDelete == 0).Count() > 0)
                {
                    apiResp.msg  = "字段重复";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                else
                {
                    model.AutoId = oldList[0].AutoId;
                    model.Sort   = oldList[0].Sort;
                }
            }
            else
            {
                //检查最大排序
                oldList = bll.GetTableFieldMap(bll.WebsiteOwner, model.TableName, null, null, true, model.MappingType.ToString(), colName: "AutoId,Sort");
                if (oldList.Count == 0)
                {
                    model.Sort = 1;
                }
                else
                {
                    model.Sort = oldList.Max(p => p.Sort) + 1;
                }
            }

            if (model.AutoId > 0)
            {
                if (bll.Update(model))
                {
                    apiResp.status = true;
                    apiResp.msg    = "提交完成,原字段存在禁用记录,继承原记录排序";
                    apiResp.code   = (int)APIErrCode.IsSuccess;
                }
                else
                {
                    apiResp.msg  = "提交失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                }
            }
            else
            {
                if (bll.Add(model))
                {
                    apiResp.status = true;
                    apiResp.msg    = "新增完成";
                    apiResp.code   = (int)APIErrCode.IsSuccess;
                }
                else
                {
                    apiResp.msg  = "新增失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                }
            }
            bll.ContextResponse(context, apiResp);
        }
Esempio n. 18
0
        public void ProcessRequest(HttpContext context)
        {
            List <TableFieldMapping> formField = bllTableFieldMap.GetTableFieldMapByWebsite(bllTableFieldMap.WebsiteOwner, "ZCJ_UserInfo", null, null, context.Request["mapping_type"]);

            formField = formField.Where(p => p.IsReadOnly == 0 && p.IsDelete == 0 && p.Field != "AutoID").ToList();

            if (formField.Count == 0)
            {
                apiResp.msg  = "没有可编辑字段";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllTableFieldMap.ContextResponse(context, apiResp);
                return;
            }

            List <string> limitFields = new List <string>()
            {
                "UserID", "Phone", "WXOpenId"
            };

            #region 默认信息检查 姓名
            string autoID = context.Request["AutoID"];
            if (string.IsNullOrWhiteSpace(autoID) || autoID == "0")
            {
                apiResp.msg  = "用户未找到";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllTableFieldMap.ContextResponse(context, apiResp);
                return;
            }
            UserInfo curUser = bllTableFieldMap.GetByKey <UserInfo>("AutoID", autoID);
            if (curUser == null)
            {
                apiResp.msg  = "用户未找到";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllTableFieldMap.ContextResponse(context, apiResp);
                return;
            }
            #endregion

            List <string> pms = new List <string>();

            #region 构造修改字段
            TableFieldMapping userIDField = formField.FirstOrDefault(p => p.Field.Equals("UserID"));
            if (userIDField != null)
            {
                string val = context.Request[userIDField.Field];
                if (!string.IsNullOrWhiteSpace(val))
                {
                    List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("UserID='{0}' And AutoID != {1} ", val, autoID), "AutoID,UserID");
                    if (oUserList.Count > 0)
                    {
                        apiResp.msg  = "账号已被使用";
                        apiResp.code = (int)APIErrCode.OperateFail;
                        bllTableFieldMap.ContextResponse(context, apiResp);
                        return;
                    }
                    pms.Add(string.Format("{0}='{1}'", userIDField.Field, val));
                }
            }

            TableFieldMapping phoneField = formField.FirstOrDefault(p => p.Field.Equals("Phone"));
            if (phoneField != null)
            {
                string val = context.Request[phoneField.Field];
                if (!string.IsNullOrWhiteSpace(val))
                {
                    List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("Phone='{0}' And WebsiteOwner='{2}' And AutoID != {1} And IsSubAccount!='1'", val, autoID, bllTableFieldMap.WebsiteOwner), "AutoID,Phone");
                    if (oUserList.Count > 0)
                    {
                        apiResp.msg  = "手机号已被使用";
                        apiResp.code = (int)APIErrCode.OperateFail;
                        bllTableFieldMap.ContextResponse(context, apiResp);
                        return;
                    }
                    pms.Add(string.Format("{0}='{1}'", phoneField.Field, val));
                }
            }

            TableFieldMapping wXOpenIdField = formField.FirstOrDefault(p => p.Field.Equals("WXOpenId"));
            if (wXOpenIdField != null)
            {
                string val = context.Request[wXOpenIdField.Field];
                if (!string.IsNullOrWhiteSpace(val))
                {
                    List <UserInfo> oUserList = bllTableFieldMap.GetColList <UserInfo>(int.MaxValue, 1, string.Format("WXOpenId='{0}' And WebsiteOwner='{2}' And AutoID != {1} ", val, autoID, bllTableFieldMap.WebsiteOwner), "AutoID,Phone");
                    if (oUserList.Count > 0)
                    {
                        apiResp.msg  = "WXOpenId已被使用";
                        apiResp.code = (int)APIErrCode.OperateFail;
                        bllTableFieldMap.ContextResponse(context, apiResp);
                        return;
                    }
                    pms.Add(string.Format("{0}='{1}'", wXOpenIdField.Field, val));
                }
            }


            foreach (TableFieldMapping item in formField.Where(p => !limitFields.Contains(p.Field)))
            {
                string val = context.Request[item.Field];
                if (string.IsNullOrWhiteSpace(val) && item.FieldIsNull == 1)
                {
                    apiResp.msg  = item.MappingName + "不能为空";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllTableFieldMap.ContextResponse(context, apiResp);
                    return;
                }

                if (string.IsNullOrWhiteSpace(val))
                {
                    pms.Add(string.Format("{0}=Null", item.Field));
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(item.FormatValiFunc))
                    {
                        #region 检查数据格式
                        //检查数据格式
                        if (item.FormatValiFunc == "number")
                        {
                            if (!MyRegex.IsNumber(val))
                            {
                                apiResp.code = (int)APIErrCode.OperateFail;
                                apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                                bllTableFieldMap.ContextResponse(context, apiResp);
                                return;
                            }
                        }
                        if (item.FormatValiFunc == "phone")//email检查
                        {
                            if (!MyRegex.PhoneNumLogicJudge(val))
                            {
                                apiResp.code = (int)APIErrCode.OperateFail;
                                apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                                bllTableFieldMap.ContextResponse(context, apiResp);
                                return;
                            }
                        }
                        if (item.FormatValiFunc == "email")//email检查
                        {
                            if (!MyRegex.EmailLogicJudge(val))
                            {
                                apiResp.code = (int)APIErrCode.OperateFail;
                                apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                                bllTableFieldMap.ContextResponse(context, apiResp);
                                return;
                            }
                        }
                        if (item.FormatValiFunc == "url")                                                                                                             //url检查
                        {
                            System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址
                            System.Text.RegularExpressions.Match match  = regUrl.Match(val);
                            if (!match.Success)
                            {
                                apiResp.code = (int)APIErrCode.OperateFail;
                                apiResp.msg  = string.Format("{0}格式不正确", item.MappingName);
                                bllTableFieldMap.ContextResponse(context, apiResp);
                                return;
                            }
                        }
                        #endregion
                    }
                    pms.Add(string.Format("{0}='{1}'", item.Field, val));
                }
            }
            #endregion

            if (bllTableFieldMap.Update(new UserInfo(),
                                        ZentCloud.Common.MyStringHelper.ListToStr(pms, "", ","),
                                        string.Format("AutoID={0}", autoID)) > 0)
            {
                apiResp.status = true;
                apiResp.msg    = "编辑完成";
                apiResp.code   = (int)APIErrCode.IsSuccess;
                bllUser.AddUserScoreDetail(curUser.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.UpdateMyInfo), bllUser.WebsiteOwner, null, null);


                //
                TableFieldMapping tagNameField = formField.FirstOrDefault(p => p.Field.Equals("TagName"));
                if (tagNameField != null && context.Request["TagName"] != null)
                {
                    foreach (var tag in context.Request["TagName"].Split(','))
                    {
                        if (bllUser.GetCount <ZentCloud.BLLJIMP.Model.MemberTag>(string.Format(" WebsiteOwner='{0}' And TagName='{1}' And TagType='Member'", bllUser.WebsiteOwner, tag)) == 0)
                        {
                            ZentCloud.BLLJIMP.Model.MemberTag model = new BLLJIMP.Model.MemberTag();
                            model.CreateTime   = DateTime.Now;
                            model.WebsiteOwner = bllUser.WebsiteOwner;
                            model.TagType      = "Member";
                            model.TagName      = tag;
                            model.Creator      = currentUserInfo.UserID;
                            if (!bllUser.Add(model))
                            {
                                apiResp.msg  = "新增标签失败";
                                apiResp.code = (int)APIErrCode.OperateFail;
                                bllTableFieldMap.ContextResponse(context, apiResp);
                            }
                        }
                    }
                }
                //
            }
            else
            {
                apiResp.msg  = "编辑失败";
                apiResp.code = (int)APIErrCode.OperateFail;
            }
            bllTableFieldMap.ContextResponse(context, apiResp);
        }