protected override GetMobileBusinessDefinedRD ProcessRequest(DTO.Base.APIRequest <GetMobileBusinessDefinedRP> pRequest) { var pageResult = new MobileBussinessDefinedBLL(CurrentUserInfo).PagedQueryByEntity( new MobileBussinessDefinedEntity { MobileModuleID = Guid.Parse(pRequest.Parameters.MobileModuleID) }, new[] { new OrderBy { FieldName = "ListOrder", Direction = OrderByDirections.Asc } }, pRequest.Parameters.Page, pRequest.Parameters.PageSize); var result = new GetMobileBusinessDefinedRD(); result.TotalRow = pageResult.RowCount; result.Items = pageResult.Entities.Select(it => new MobileBunessDefinedSubInfo { MobileBunessDefinedID = it.MobileBussinessDefinedID.ToString(), ColumnDesc = it.ColumnDesc, ColumnName = it.ColumnName, ControlType = it.ControlType.HasValue ? it.ControlType.Value : 0, CorrelationValue = it.CorrelationValue, ListOrder = it.EditOrder.HasValue ? it.EditOrder.Value : 0 }).ToArray(); return(result); }
protected override FormSaveRD ProcessRequest(DTO.Base.APIRequest <FormSaveRP> pRequest) { var items = pRequest.Parameters.Items ?? new MobileBunessDefinedSubInfo[0]; var mobileModuleID = Guid.Parse(pRequest.Parameters.MobileModuleID); var bll = new MobileBussinessDefinedBLL(CurrentUserInfo); var entities = bll.QueryByEntity( new MobileBussinessDefinedEntity { MobileModuleID = mobileModuleID }, null); //1.add var addEntities = items.Where(it => string.IsNullOrEmpty(it.MobileBunessDefinedID)) .Select(it => new MobileBussinessDefinedEntity { MobileBussinessDefinedID = Guid.NewGuid(), MobileModuleID = mobileModuleID, ColumnName = it.ColumnName, ColumnDesc = it.ColumnDesc, ControlType = it.ControlType, CorrelationValue = it.CorrelationValue, CustomerID = CurrentUserInfo.ClientID } ).ToArray(); //2.update delete var updateEntities = new List <MobileBussinessDefinedEntity>(); var deleteEntities = new List <MobileBussinessDefinedEntity>(); foreach (var e in entities) { var item = items.FirstOrDefault( it => it.MobileBunessDefinedID.ToLower() == e.MobileBussinessDefinedID.ToString().ToLower()); if (item != null) { e.ColumnName = item.ColumnName; e.ColumnDesc = item.ColumnDesc; e.ControlType = item.ControlType; e.CorrelationValue = item.CorrelationValue; updateEntities.Add(e); } else { deleteEntities.Add(e); } } bll.EditMobileBussinessDefined(addEntities, updateEntities.ToArray(), deleteEntities.ToArray()); return(new FormSaveRD { IsSuccess = true }); }
protected override GetRegisterFormItemsRD ProcessRequest(DTO.Base.APIRequest <GetRegisterFormItemsRP> pRequest) { GetRegisterFormItemsRD rd = new GetRegisterFormItemsRD(); string eventCode = pRequest.Parameters.EventCode; string customerId = this.CurrentUserInfo.ClientID; MobileBussinessDefinedBLL bll = new MobileBussinessDefinedBLL(this.CurrentUserInfo); var ds = bll.GetPagesInfo(eventCode, customerId); var temp = ds.Tables[0].AsEnumerable().OrderBy(t => t["DisplayIndex"]).Select(t => new PageInfo() { ID = t["ID"].ToString(), Blocks = ds.Tables[1].AsEnumerable().OrderBy(b => b["DisplayIndex"]).Where(b => b["PageId"].ToString() == t["ID"].ToString()).Select(b => new BlockInfo { ID = b["ID"].ToString(), PageID = b["PageId"].ToString(), DisplayIndex = b["DisplayIndex"] as int?,// == null ? default(int?) : (int?)b["DisplayIndex"], PropertyDefineInfos = ds.Tables[2].AsEnumerable().OrderBy(c => c["DisplayIndex"]).Where(c => c["BlockId"].ToString() == b["ID"].ToString()).Select(c => new PropertyDefineInfo { ID = c["MobileBussinessDefinedID"].ToString(), BlockID = c["BlockId"].ToString(), Title = c["Title"].ToString(), DisplayIndex = c["DisplayIndex"] as int?,//== null ? default(int?) : (int?)c["DisplayIndex"], ControlInfo = ds.Tables[3].AsEnumerable().Where(d => d["MobileBussinessDefinedID"].ToString() == c["MobileBussinessDefinedID"].ToString()).Select(d => new ControlInfo { ControlType = d["ControlType"] as int?, // == null ? default(int?) : (int?)d["ControlType"], ColumnDesc = d["ColumnDesc"].ToString(), DisplayType = d["DisplayType"] as int?, // == null ? default(int?) : (int?)(d["DisplayType"]), ColumnDescEn = d["ColumnDescEn"].ToString(), IsMustDo = d["IsMustDo"].ToString(), OptionValues = ds.Tables[4].AsEnumerable().Where(e => e["MobileBussinessDefinedID"].ToString() == d["MobileBussinessDefinedID"].ToString()).OrderBy(e => e["OptionValue"]).Select(e => new KeyValueInfo { Key = e["OptionValue"].ToString(), Value = e["OptionText"].ToString() }).ToArray(), }).First(), }).ToArray(), }).ToArray(), DisplayIndex = Convert.ToInt32(t["DisplayIndex"]) }); rd.Pages = temp.OrderBy(t => t.DisplayIndex).ToArray(); return(rd); }
protected override GetMobileBusinessDefinedRD ProcessRequest(DTO.Base.APIRequest <GetMobileBusinessDefinedRP> pRequest) { var mobilePageBlockID = new MobileBussinessDefinedBLL(CurrentUserInfo).GetMobilePageBlockIDByMobileModuleID(pRequest.Parameters.MobileModuleID); if (string.IsNullOrEmpty(mobilePageBlockID)) { //return new GetMobileBusinessDefinedRD //{ // Msg = "表单没有分页区块" //}; throw new Exception("表单没有分页区块"); } var pageResult = new MobileBussinessDefinedBLL(CurrentUserInfo).PagedQueryByEntity( new MobileBussinessDefinedEntity { MobilePageBlockID = Guid.Parse(mobilePageBlockID) }, new[] { new OrderBy { FieldName = "EditOrder", Direction = OrderByDirections.Asc } }, pRequest.Parameters.PageSize, pRequest.Parameters.Page); var result = new GetMobileBusinessDefinedRD(); result.TotalRow = pageResult.RowCount; result.Items = pageResult.Entities.Select(it => new MobileBunessDefinedSubInfo { //MobileBunessDefinedID = it.MobileBussinessDefinedID.ToString(), ColumnDesc = it.ColumnDesc, ColumnName = it.ColumnName, ControlType = it.ControlType.HasValue ? it.ControlType.Value : 0, //CorrelationValue = it.CorrelationValue, ListOrder = it.EditOrder.HasValue ? it.EditOrder.Value : 0, IsMustDo = it.IsMustDo.HasValue? it.IsMustDo.Value: 0 }).ToArray(); return(result); }
protected override SetRegisterFormItemsRD ProcessRequest(DTO.Base.APIRequest <SetRegisterFormItemsRP> pRequest) { //var validFlag = pRequest.Parameters.ValidFlag; //#region 需要验证 //#region 根据userid、phone分别查询vip表,如果存在两条记录,且两条记录不相同,进行合并,以userid为主 ////如果一条都不存在,新增一条vip信息 ////如果两条记录相同,继续 //#endregion //#region 根据表单数据,更新vip表 //#endregion //#endregion //#region 不需要验证 //#region 根据userid 取vip,如果有记录更新,没有记录,反之新增 //#endregion //#endregion SetRegisterFormItemsRD rd = new SetRegisterFormItemsRD(); var itemlist = pRequest.Parameters.ItemList; //var objectId = pRequest.Parameters.ObjectId; //if (string.IsNullOrEmpty(objectId) || objectId == "") //{ // throw new APIException("参数【ObjectId】不能为空") { ErrorCode = 121 }; //} MobileBussinessDefinedBLL bll = new MobileBussinessDefinedBLL(this.CurrentUserInfo); var vipBll = new VipBLL(CurrentUserInfo); var vip = vipBll.GetByID(pRequest.UserID); if (itemlist == null) { return(rd); } if (vip != null) { string sql = ""; foreach (var item in itemlist) { if (Convert.ToBoolean(item.IsMustDo) && string.IsNullOrEmpty(item.Value)) { throw new APIException("必填字段不能为空") { ErrorCode = ERROR_ColumnValue_IsMustDo }; } sql += bll.GetColumnName(item.ID) + "='" + item.Value + "',"; } var tableName = "vip"; ////根据objectid获取表明 //var tableName = bll.GetTableNameByObjectId(objectId, pRequest.CustomerID); //if (tableName == "" || string.IsNullOrEmpty(tableName)) //{ // throw new APIException("无效的ObjectId") { ErrorCode = 122 }; //} //根据表更新字段 // bll.UpdateDynamicColumnValue(sql.Trim(','), "003e30e7121741beb749a230eebecfe0"); //注册时只需输入手机号,兼容处理 sql = sql.Trim(','); if (sql != "") { bll.UpdateDynamicColumnValue(sql, pRequest.UserID, tableName); } } else { throw new APIException("用户ID无效") { ErrorCode = 121 }; } return(rd); }