/// <summary> /// 初始化 /// </summary> /// <param name="labelName">标签名称</param> /// <param name="labelConfig">配置信息</param> /// <param name="docMaster">文档主类</param> /// <param name="structureID">构件ID</param> public TextLabel(string labelName, JToken labelConfig, DocMaster docMaster, decimal structureID) { this.IsInput = false; this.LabelName = labelName; this.docMaster = docMaster; this.structureID = structureID; JObject config = (JObject)labelConfig["Config"]; string formatString = string.Empty; string formatType = string.Empty; GetDataMethod = (GetDataMethod)Enum.Parse(typeof(GetDataMethod), config["GetDataMethod"].Value <string>()); this.Value = string.Empty; if (GetDataMethod == GetDataMethod.Const || GetDataMethod == GetDataMethod.Formula) { this.InnerValue = this.ConfigValue = config["Value"].Value <string>(); this.dataSource = null; this.FieldName = string.Empty; this.FormatInfo = null; } else if (GetDataMethod == GetDataMethod.Source) { this.DataSourceName = config["DataSourceName"].Value <string>(); this.dataSource = docMaster.DocTemplateType.DataSourceList.FirstOrDefault(t => t.DataSourceName == this.DataSourceName); this.FieldName = config["FieldName"].Value <string>(); this.FilterFieldName = config["FilterFieldName"].Value <string>(); this.FilterOperation = config["FilterOperation"].Value <string>(); this.FilterValue = config["FilterValue"].Value <string>(); } else if (GetDataMethod == GetDataMethod.Dynamic) { this.formType = config["FormType"].Value <int>(); this.fieldID = config["FieldID"].Value <string>(); } else if (GetDataMethod == GetDataMethod.MultiSource) { this.tableID = config["TableID"].Value <string>(); this.fieldID = config["FieldID"].Value <string>(); } if (config["FormatInfo"] != null) { FormatInfo = new FormatInfo(config["FormatInfo"], docMaster.DocTemplateType); } // 控件配置 if (labelConfig["Relate"] != null) { string relate = labelConfig["Relate"].ToString(); if (!string.IsNullOrEmpty(relate)) { this.Relate = JsonTools.JsonToObject2 <List <RelateItem> >(relate); } } this.DocControl = this.CreateControl(labelName, labelConfig, docMaster.DocTemplateType); }
public FormViewModel GetFormDataByObjectId(int ObjectId, int FormType) { FormViewModel formInstance = new FormViewModel(); FormLabelDTO label = new FormLabelDTO(); Dictionary <string, object> dsDic = new Dictionary <string, object>(); dsDic.Add("i_object_id", ObjectId); dsDic.Add("i_form_type", FormType); using (BaseDB db = new RedasDBHelper()) { IList <FormViewModel> InstanceList = db.ExecuteListProc <FormViewModel>("pkg_forminstance.sp_get_formDataByObj", dsDic); if (InstanceList != null && InstanceList.Count > 0) { formInstance = InstanceList[0]; //formInstance.LABLELIST = JsonTools.JsonToObject2<List<FormLabelDTO>>(formInstance.CONTENTS).OrderBy(l => l.SORT).ToList(); formInstance.LABLELIST = JsonTools.JsonToObject2 <DFormViewModel>(formInstance.CONTENTS).FormLabels .Where(l => l.IsSelected == true) .OrderBy(l => l.SORT).ToList(); List <LabelDataDTO> lstData = new List <LabelDataDTO>(); if (!string.IsNullOrEmpty(formInstance.FORMDATA)) { lstData = JsonTools.JsonToObject2 <List <LabelDataDTO> >(formInstance.FORMDATA); } foreach (LabelDataDTO c in lstData) { decimal id = 0; decimal.TryParse(c.NAME, out id); if (id > 0) { label = formInstance.LABLELIST.SingleOrDefault(l => l.FORM_LABEL_ID == Convert.ToDecimal(c.NAME)); if (label == null) { continue; } label.CONTENT = c.VALUE; //label.CONTENT =label.FIELD_TYPE == "DATE"?Convert.ToDateTime(c.VALUE): c.VALUE; } } } } return(formInstance); }
private string GetValue(decimal objectID, string tableID, string fieldID, decimal structureID, string labelName, Dictionary <string, string> parame) { var configList = JArray.Parse(sourceConfig); string value = string.Empty; var lstFormLabel = GetFormLabelList(fieldID); //获得楼盘code 楼栋code 房号code //var formView = new FormLogic().GetFormDataByObjectId(Convert.ToInt32(objectID), 1); //List<Redas.Entities.Ompd.FormLabelDTO> lstLabel = formView.LABLELIST.ToList(); ////查询对应的楼盘,楼栋,房号的code //string conCode = lstLabel.Single(l => l.LABEL_NAME == "CONSTRUCTION_CODE").CONTENT; //string buildingCode = lstLabel.Single(l => l.LABEL_NAME == "BUILDING_CODE").CONTENT; //string houseCode = lstLabel.Single(l => l.LABEL_NAME == "HOUSE_CODE").CONTENT; string conCode = parame["ConstructionCode"]; string buildingCode = parame["BuildingCode"]; string houseCode = parame["HouseCode"]; string unitCode = parame["UnitCode"]; string objectType = parame["ObjectType"]; bool isGetEstimate = Convert.ToBoolean(parame["IsGetEstimate"]); foreach (var o in configList) { int type = o.Value <int>("Type"); switch (type) { case 0: { //根据objectCode, tableID, fieldID value = GetBasicData(objectID, fieldID, conCode, buildingCode, houseCode, unitCode, objectType); } break; case 1: //询价 Dictionary <int, JArray> lstEstForm = GetDynamicFormData(objectID, 1); if (lstEstForm.Count() > 0) { JArray array = (JArray)lstEstForm[1]; foreach (var info in lstFormLabel) { var item = array.FirstOrDefault(it => it["NAME"].Value <string>().Equals(info.SELECTVALUE.ToString())); if (item != null) { value = item["VALUE"].Value <string>(); break; } } } break; case 2: //预估函 if (isGetEstimate) // 需要查询预估函 { T_INSTANCE_DOCUMENT instanceInfo = GetInstanceDocumentGetByObject(objectID, EntrustItem.Estimate); if (instanceInfo != null && instanceInfo.MANUAL_EDITING_RETURN != "") { List <_EditReturnModel> lstEditModel = JsonTools.JsonToObject2 <List <_EditReturnModel> >(instanceInfo.MANUAL_EDITING_RETURN); _EditReturnModel labelInfo = lstEditModel.Find(delegate(_EditReturnModel p) { //return p.ID == structureID && p.LabelName == labelName; return(p.LabelName == labelName); }); if (labelInfo == null) { continue; } else { value = labelInfo.Value; } } } break; case 3: Dictionary <int, JArray> lstReportForm = GetDynamicFormData(objectID, 2); if (lstReportForm.Count() > 0) { JArray array = (JArray)lstReportForm[2]; foreach (var info in lstFormLabel) { var item = array.FirstOrDefault(it => it["NAME"].Value <string>().Equals(info.SELECTVALUE.ToString())); if (item != null) { value = item["VALUE"].Value <string>(); break; } } } break; default: value = GetAddInfoItemValue(objectID, tableID, fieldID); break; } //if (!string.IsNullOrEmpty(value)) // break; if (value != string.Empty) { break; } } return(value); }