public void ProcessRequest(HttpContext context) { string componentId = context.Request["component_id"]; if (string.IsNullOrEmpty(componentId)) { apiResp.msg = "component_id 为必填项,请检查"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } BLLJIMP.Model.Component model = bll.Get <BLLJIMP.Model.Component>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bll.WebsiteOwner, componentId)); if (model == null) { apiResp.msg = "没有找到组件"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } apiResp.status = true; apiResp.result = new { component_id = model.AutoId, component_key = model.ComponentKey, component_name = model.ComponentName, component_model_id = model.ComponentModelId, child_component_ids = model.ChildComponentIds, component_config = model.ComponentConfig, decription = model.Decription, is_oauth = model.IsWXSeniorOAuth, access_level = model.AccessLevel }; bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string componentId = context.Request["component_id"]; if (string.IsNullOrEmpty(componentId)) { apiResp.msg = "component_id 为必填项,请检查"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } BLLJIMP.Model.Component model = bll.Get <BLLJIMP.Model.Component>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bll.WebsiteOwner, componentId)); if (model == null) { apiResp.msg = "没有找到组件"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } apiResp.status = true; if (!string.IsNullOrWhiteSpace(model.ComponentConfig)) { apiResp.result = JToken.Parse(model.ComponentConfig); //apiResp.result = ZentCloud.Common.JSONHelper.ObjectToJson(model.ComponentConfig); } bll.ContextResponse(context, apiResp); }
private void GetInitComponent() { //组件 string id = this.Request["id"]; ComponentTemplate componentTemplate = bll.GetByKey <ComponentTemplate>("AutoId", id); if (componentTemplate == null) { this.Response.Write("模板未找到"); this.Response.End(); return; } template = JsonConvert.SerializeObject(componentTemplate); //页面 BLLJIMP.Model.Component nComponent = new BLLJIMP.Model.Component(); //组件库 ComponentModel componentModel = bll.GetByKey <ComponentModel>("AutoId", componentTemplate.ComponentModelId.ToString()); if (componentModel != null) { nComponent.ComponentModelId = componentTemplate.ComponentModelId; List <ComponentModelField> componentModelFields = bll.GetListByKey <ComponentModelField>("ComponentModelKey", componentModel.ComponentModelKey) .OrderBy(p => p.ComponentFieldSort).ToList(); dynamic cModel = new { component_model_id = componentModel.AutoId, component_model_key = componentModel.ComponentModelKey, component_model_name = componentModel.ComponentModelName, component_model_fields = (from p in componentModelFields.Where(p => p.ComponentFieldType >= 4 && p.ComponentFieldType != 8 && limitControls.Contains(p.ComponentField)) select new { component_field_id = p.AutoId, component_field = p.ComponentField, component_field_name = p.ComponentFieldName, component_field_type = p.ComponentFieldType, component_field_data_value = p.ComponentFieldDataValue, disabled = false }) }; component_model = JsonConvert.SerializeObject(cModel); } else { nComponent.ComponentModelId = 0; } nComponent.ComponentName = componentTemplate.Name; nComponent.ComponentConfig = componentTemplate.Config; nComponent.ComponentTemplateId = componentTemplate.AutoId; component = JsonConvert.SerializeObject(nComponent); }
public void ProcessRequest(HttpContext context) { string componentId = context.Request["component_id"]; if (string.IsNullOrEmpty(componentId)) { apiResp.msg = "component_id 为必填项,请检查"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } BLLJIMP.Model.Component model = bll.Get <BLLJIMP.Model.Component>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bll.WebsiteOwner, componentId)); if (model == null) { apiResp.msg = "没有找到"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(model.ComponentKey)) { apiResp.msg = "禁止删除"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } if (bll.Delete(new BLLJIMP.Model.Component(), string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bll.WebsiteOwner, componentId)) > 0) { apiResp.status = true; apiResp.msg = "ok"; } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "删除出错"; } bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string componentId = context.Request["component_id"]; BLLJIMP.Model.Component model = bll.Get <BLLJIMP.Model.Component>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bll.WebsiteOwner, componentId)); model.AutoId = 0; model.ComponentName = model.ComponentName + "--复制"; model.ComponentKey = null; if (!string.IsNullOrWhiteSpace(model.ComponentKey)) { model.ComponentKey = ""; } if (bll.Add(model)) { apiResp.status = true; apiResp.msg = "ok"; } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "复制出错"; } bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { var cgid = context.Request["cgid"]; var key = context.Request["key"]; var property = context.Request["property"]; var key_type = context.Request["key_type"]; //参数检查 if ((string.IsNullOrWhiteSpace(cgid) && string.IsNullOrWhiteSpace(key)) || string.IsNullOrWhiteSpace(property)) { apiResp.msg = "参数错误"; apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; bll.ContextResponse(context, apiResp); return; } //查询组件 BLLJIMP.Model.Component model = new BLLJIMP.Model.Component(); if (!string.IsNullOrWhiteSpace(key)) { model = bll.GetComponentByKey(key, bll.WebsiteOwner); } else { model = bll.Get <BLLJIMP.Model.Component>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bll.WebsiteOwner, cgid)); } if (model == null) { apiResp.msg = "组件不存在"; apiResp.code = (int)APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } //加载具体配置 JObject jobject = JObject.Parse(model.ComponentConfig); if (jobject[property] == null) { apiResp.msg = "属性不存在"; apiResp.code = (int)APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } List <string> PropertyList = new List <string>() { "slide_list", "foottool_list", "tab_list", "button_list", "nav_list", "headtool_list" }; for (int i = 0; i < PropertyList.Count; i++) { if (property.StartsWith(PropertyList[i])) { if (model.ComponentModelId > 10 && (property.StartsWith("foottool_list") || property.StartsWith("tab_list"))) { customize.comeoncloud.Index ComponentIndex = new customize.comeoncloud.Index(); JToken childJObject = jobject[property]; if (childJObject.Type == JTokenType.String) { JProperty nPro = new JProperty(property, childJObject); JToken nObject = new JObject(); ComponentIndex.GetChildConfig(nPro, ref nObject); jobject[property] = new JObject(); jobject[property]["list"] = nObject; } else { JProperty nPro = new JProperty(property, childJObject["key_type"]); JToken nObject = new JObject(); ComponentIndex.GetChildConfig(nPro, ref nObject); jobject[property]["list"] = nObject; } break; } else { customize.comeoncloud.Index ComponentIndex = new customize.comeoncloud.Index(); JToken childJObject = jobject[property]; JProperty propertyKey = jobject.Properties().FirstOrDefault(p => p.Name == property); if (!string.IsNullOrWhiteSpace(key_type)) { propertyKey.Value = key_type; } ComponentIndex.GetChildConfig(propertyKey, ref childJObject); jobject[property] = childJObject; break; } } } if (property.StartsWith("navs") && jobject[property].Type == JTokenType.Array) { JArray childJArray = JArray.FromObject(jobject[property]); bool hasGetData = false; foreach (JObject nJArray in childJArray) { List <JProperty> listNavProperty = nJArray.Properties().Where(p => p.Name.StartsWith("nav_list")).ToList(); foreach (JProperty cproperty in listNavProperty) { if (cproperty.Value.Type == JTokenType.String) { JToken childJObject = nJArray[cproperty.Name]; customize.comeoncloud.Index ComponentIndex = new customize.comeoncloud.Index(); ComponentIndex.GetChildConfig(cproperty, ref childJObject); nJArray[cproperty.Name] = childJObject; hasGetData = true; } } } if (hasGetData) { jobject[property] = childJArray; } } if (property.StartsWith("slides") && jobject[property].Type == JTokenType.Array) { JArray childJArray = JArray.FromObject(jobject[property]); bool hasGetData = false; foreach (JObject nJArray in childJArray) { List <JProperty> listNavProperty = nJArray.Properties().Where(p => p.Name.StartsWith("slide_list")).ToList(); foreach (JProperty cproperty in listNavProperty) { if (cproperty.Value.Type == JTokenType.String) { JToken childJObject = nJArray[cproperty.Name]; customize.comeoncloud.Index ComponentIndex = new customize.comeoncloud.Index(); ComponentIndex.GetChildConfig(cproperty, ref childJObject); nJArray[cproperty.Name] = childJObject; hasGetData = true; } } } if (hasGetData) { jobject[property] = childJArray; } } apiResp.result = jobject[property]; apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { RequestModel requestModel = new RequestModel(); try { requestModel = bll.ConvertRequestToModel <RequestModel>(requestModel); } catch (Exception ex) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = ex.Message; bll.ContextResponse(context, apiResp); return; } if (requestModel.component_id <= 0) { apiResp.msg = "请传入页面id"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrEmpty(requestModel.component_name)) { apiResp.msg = "请输入页面名称"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } if (requestModel.component_model_id == 0) { apiResp.msg = "请选择模板"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } BLLJIMP.Model.Component model = bll.Get <BLLJIMP.Model.Component>(string.Format(" WebsiteOwner='{0}' AND AutoId={1}", bll.WebsiteOwner, requestModel.component_id)); if (!string.IsNullOrWhiteSpace(requestModel.component_key)) { var oComp = bll.GetComponentByKey(requestModel.component_key, bll.WebsiteOwner); if (oComp != null && oComp.AutoId != model.AutoId) { apiResp.msg = "标识已被使用"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } } model.AutoId = requestModel.component_id; model.ComponentKey = requestModel.component_key; model.ChildComponentIds = requestModel.child_component_ids; model.Decription = requestModel.decription; int old_model_id = model.ComponentModelId; model.ComponentModelId = requestModel.component_model_id; model.ComponentTemplateId = requestModel.component_template_id; model.ComponentName = requestModel.component_name; model.IsWXSeniorOAuth = requestModel.is_oauth; model.AccessLevel = requestModel.access_level; model.IsInitData = requestModel.is_init_data; if (old_model_id != requestModel.component_model_id) { ComponentModel componentModel = bll.GetByKey <ComponentModel>("AutoId", requestModel.component_model_id.ToString()); if (componentModel == null) { apiResp.msg = "新组件库未找到"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } model.ComponentType = componentModel.ComponentModelType; //if (model.ComponentType != "page") model.WebsiteOwner = "Common"; } model.ComponentConfig = requestModel.component_config; if (bll.Update(model)) { //更新幻灯片 if (!string.IsNullOrWhiteSpace(requestModel.slides)) { Add.UpdateSlide(requestModel.slides); } //更新导航 if (!string.IsNullOrWhiteSpace(requestModel.toolbars)) { Add.UpdateToolbar(requestModel.toolbars); } apiResp.result = new { component_id = model.AutoId }; apiResp.status = true; apiResp.msg = "修改完成"; } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "修改页面出错"; } bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { RequestModel requestModel = new RequestModel(); try { requestModel = bll.ConvertRequestToModel <RequestModel>(requestModel); } catch (Exception ex) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; //apiResp.msg = ex.Message; apiResp.msg = "json格式错误,请检查。"; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrEmpty(requestModel.component_name)) { apiResp.msg = "请输入页面名称"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } if (requestModel.component_model_id == 0) { apiResp.msg = "请选择模板"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(requestModel.component_key)) { if (bll.GetComponentByKey(requestModel.component_key, bll.WebsiteOwner) != null) { apiResp.msg = "标识已被使用"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } } BLLJIMP.Model.Component model = new BLLJIMP.Model.Component(); model.WebsiteOwner = bll.WebsiteOwner; model.ComponentKey = requestModel.component_key; model.ChildComponentIds = requestModel.child_component_ids; model.Decription = requestModel.decription; model.ComponentModelId = requestModel.component_model_id; model.ComponentTemplateId = requestModel.component_template_id; ComponentModel componentModel = bll.GetByKey <ComponentModel>("AutoId", requestModel.component_model_id.ToString()); if (componentModel == null) { apiResp.msg = "模板未找到"; apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } model.ComponentType = componentModel.ComponentModelType; //if (model.ComponentType != "page") model.WebsiteOwner = "Common"; model.ComponentName = requestModel.component_name; model.IsWXSeniorOAuth = requestModel.is_oauth; model.ComponentConfig = requestModel.component_config; model.AccessLevel = requestModel.access_level; model.IsInitData = requestModel.is_init_data; if (bll.Add(model)) { //更新幻灯片 if (!string.IsNullOrWhiteSpace(requestModel.slides)) { UpdateSlide(requestModel.slides); } //更新导航 if (!string.IsNullOrWhiteSpace(requestModel.toolbars)) { UpdateToolbar(requestModel.toolbars); } BLLJIMP.Model.Component nModel = bll.GetNewComponent(bll.WebsiteOwner); apiResp.result = new { component_id = nModel.AutoId }; apiResp.status = true; apiResp.msg = "添加完成"; } else { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "添加页面出错"; } bll.ContextResponse(context, apiResp); }
private void GetInitComponent() { //组件 string key = this.Request["key"]; string component_id = this.Request["component_id"]; backlist = this.Request["backlist"]; BLLJIMP.Model.Component nComponent = new BLLJIMP.Model.Component(); if (!string.IsNullOrWhiteSpace(key)) { nComponent = bll.GetComponentByKey(key, bll.WebsiteOwner); if (nComponent == null) { nComponent = new BLLJIMP.Model.Component() { ComponentKey = key }; nComponent.IsInitData = 1; component = JsonConvert.SerializeObject(nComponent); return; } } else if (!string.IsNullOrWhiteSpace(component_id)) { if (component_id == "0") { nComponent.IsInitData = 1; component = JsonConvert.SerializeObject(nComponent); return; } nComponent = bll.GetByKey <BLLJIMP.Model.Component>("AutoId", component_id, true); if (nComponent == null) { this.Response.Write("页面未找到"); this.Response.End(); return; } } component = JsonConvert.SerializeObject(nComponent); if (nComponent.ComponentModelId == 0) { return; } //模板 if (nComponent.ComponentTemplateId > 0) { ComponentTemplate componentTemplate = bll.GetByKey <ComponentTemplate>("AutoId", nComponent.ComponentTemplateId.ToString()); if (componentTemplate != null) { template = JsonConvert.SerializeObject(componentTemplate); } } //组件库 ComponentModel componentModel = bll.GetByKey <ComponentModel>("AutoId", nComponent.ComponentModelId.ToString()); if (componentModel == null) { return; } List <ComponentModelField> componentModelFields = bll.GetListByKey <ComponentModelField>("ComponentModelKey", componentModel.ComponentModelKey) .OrderBy(p => p.ComponentFieldSort).ToList(); dynamic cModel = new { component_model_id = componentModel.AutoId, component_model_key = componentModel.ComponentModelKey, component_model_name = componentModel.ComponentModelName, component_model_fields = (from p in componentModelFields.Where(p => p.ComponentFieldType >= 4 && p.ComponentFieldType != 8 && limitControls.Contains(p.ComponentField)) select new { component_field_id = p.AutoId, component_field = p.ComponentField, component_field_name = p.ComponentFieldName, component_field_type = p.ComponentFieldType, component_field_data_value = p.ComponentFieldDataValue, disabled = false }) }; component_model = JsonConvert.SerializeObject(cModel); }
protected void Page_Load(object sender, EventArgs e) { List <long> groupids = bllPms.GetPmsGroupIDByUser(bll.WebsiteOwner); if (groupids.Count > 0) { webpms_groups = Common.MyStringHelper.ListToStr(groupids, "", ","); } string key = this.Request["key"]; BLLJIMP.Model.Component nComponent = bll.GetComponentByKey(key, bll.WebsiteOwner); if (nComponent == null) { Common.WebMessageBox.Show(this, "组件未找到"); return; } keyname = bll.GetComponentNameByKey(key); ComponentModel componentModel = bll.GetByKey <ComponentModel>("AutoId", nComponent.ComponentModelId.ToString()); if (componentModel == null) { Common.WebMessageBox.Show(this, "模板未找到"); return; } List <ComponentModelField> componentModelFields = bll.GetListByKey <ComponentModelField>("ComponentModelKey", componentModel.ComponentModelKey) .OrderBy(p => p.ComponentFieldSort).ToList(); dynamic cModel = new { component_model_id = componentModel.AutoId, component_model_name = componentModel.ComponentModelName, component_model_type = componentModel.ComponentModelType, component_model_link_url = componentModel.ComponentModelLinkUrl, component_model_html_url = componentModel.ComponentModelHtmlUrl, component_model_fields = (from p in componentModelFields select new { component_field_id = p.AutoId, component_field = p.ComponentField, component_field_name = p.ComponentFieldName, component_field_type = p.ComponentFieldType, component_field_data_type = p.ComponentFieldType, component_field_data_value = p.ComponentFieldDataValue }) }; component = JsonConvert.SerializeObject(nComponent); component_model = JsonConvert.SerializeObject(cModel); //读取广告 StringBuilder sbWhere = new StringBuilder(string.Format(" WebSiteOwner='{0}'", bll.WebsiteOwner)); var slideData = bll.GetColList <BLLJIMP.Model.Slide>(int.MaxValue, 1, sbWhere.ToString(), "AutoID,Type"); dynamic result = slideData.Select(p => p.Type).Distinct().OrderBy(p => p); slides = JsonConvert.SerializeObject(result); //读取组件 sbWhere = new StringBuilder(); sbWhere.AppendFormat(" WebsiteOwner='{0}'", bll.WebsiteOwner); sbWhere.AppendFormat(" AND ComponentType != 'page' "); var componentList = bll.GetColList <BLLJIMP.Model.Component>(int.MaxValue, 1, sbWhere.ToString(), "AutoId,ComponentName,ComponentType"); result = from p in componentList select new { component_id = p.AutoId, component_name = p.ComponentName, component_type = p.ComponentType }; common_components = JsonConvert.SerializeObject(result); //读取底部工具栏 sbWhere = new StringBuilder(); sbWhere.AppendFormat(" WebsiteOwner='{0}' OR WebsiteOwner Is Null ", bll.WebsiteOwner); List <CompanyWebsite_ToolBar> dataList = bll.GetColList <CompanyWebsite_ToolBar>(int.MaxValue, 1, sbWhere.ToString(), "AutoID,KeyType,UseType"); result = (from p in dataList select new { key_type = p.KeyType, use_type = p.UseType }).Distinct(); toolbars = JsonConvert.SerializeObject(result); int total = 0; //读取商品分类 List <BLLJIMP.Model.WXMallCategory> mallCateList = bllMall.GetCategoryList(1, int.MaxValue, null, out total); result = (from p in mallCateList select new { cate_id = p.AutoID, cate_name = p.CategoryName }).Distinct(); mall_cates = JsonConvert.SerializeObject(result); //读取商品标签 List <BLLJIMP.Model.MemberTag> tagList = bllTag.GetTags(bllTag.WebsiteOwner, null, 1, int.MaxValue, out total, "Mall"); result = tagList.OrderBy(p => p.TagName).Select(p => p.TagName).Distinct(); mall_tags = JsonConvert.SerializeObject(result); List <ArticleCategory> artCateList = bllArticleCategory.GetCateList(out total, "Article", null, bllArticleCategory.WebsiteOwner, int.MaxValue, 1); List <ListItem> artCateItemList = new List <ListItem>(); if (artCateList.Count > 0) { artCateItemList = bllMyCategories.GetCateListItem(bllMyCategories.GetCommCateModelList("AutoID", "PreID", "CategoryName", artCateList), 0); } result = (from p in artCateItemList select new { cate_id = p.Value, cate_name = p.Text }).Distinct(); art_cates = JsonConvert.SerializeObject(result); List <ArticleCategory> actCateList = bllArticleCategory.GetCateList(out total, "Activity", null, bllArticleCategory.WebsiteOwner, int.MaxValue, 1); List <ListItem> actCateItemList = new List <ListItem>(); if (actCateList.Count > 0) { actCateItemList = bllMyCategories.GetCateListItem(bllMyCategories.GetCommCateModelList("AutoID", "PreID", "CategoryName", actCateList), 0); } result = (from p in actCateItemList select new { cate_id = p.Value, cate_name = p.Text }).Distinct(); act_cates = JsonConvert.SerializeObject(result); WebsiteInfo model = bllWeisite.GetWebsiteInfo(); if (model != null && !string.IsNullOrEmpty(model.WeiXinBindDomain)) { strDomain = model.WeiXinBindDomain; } }