private static int GetTheSameCount(FunctionEntity entity, string propertyName) { int count = 0; string tmpString = propertyName; if (propertyName.EndsWith("_ID")) { tmpString = propertyName.Substring(0, propertyName.Length - 3); } else if (propertyName.EndsWith("_CODE") || propertyName.EndsWith("_NAME")) { tmpString = propertyName.Substring(0, propertyName.Length - 5); } Regex regValidate = new Regex(@"^" + tmpString + @"X?\d{0,}$"); foreach (var para in entity.ParaList) { tmpString = para.PropertyName; if (para.PropertyName.Contains("_ID")) { tmpString = para.PropertyName.Replace("_ID", ""); } else if (para.PropertyName.Contains("_CODE")) { tmpString = para.PropertyName.Replace("_CODE", ""); } else if (para.PropertyName.Contains("_NAME")) { tmpString = para.PropertyName.Replace("_NAME", ""); } if (regValidate.IsMatch(tmpString)) { count++; } } return(count); }
public static List<FunctionEntity> CreateViewEntity(DependencyObjectCollection collFunc,ServiceComponent service) { var group = collFunc.GroupBy(c => new { FUNCTION_INFO_NAME = c["FUNCTION_INFO_NAME"].ToStringExtension(), FUNCTION_INFO_DISPLAY_NAME = c["FUNCTION_INFO_DISPLAY_NAME"].ToStringExtension(), FUNCTION_INFO_CLASS = c["FUNCTION_INFO_CLASS"].ToStringExtension(), FUNCTION_INFO_CLASS_NAME = c["FUNCTION_INFO_CLASS_NAME"].ToStringExtension(), FUNCTION_EXPLAIN = c["FUNCTION_EXPLAIN"].ToStringExtension() }); List<FunctionEntity> list = new List<FunctionEntity>(); IQueryProjectContainer srv = service.GetService<IQueryProjectContainer>("TFL"); IMetadataContainer mc = service.GetService<IMetadataContainer>(); Regex regNum = new Regex("^[0-9]"); //参数不能以数字开头的校验 foreach (var item in group) { FunctionEntity entity = new FunctionEntity() { Name = item.Key.FUNCTION_INFO_NAME, DisplayName = item.Key.FUNCTION_INFO_DISPLAY_NAME, Description = item.Key.FUNCTION_EXPLAIN, Category = item.Key.FUNCTION_INFO_CLASS_NAME }; foreach (var sub in item) { if (Maths.IsEmpty(sub["FUNCTION_INFO_D_ID"])) //没有参数 continue; if(regNum.IsMatch(sub["PARAMETER_CODE"].ToStringExtension())) //参数不能以数字开头 continue; ParaEntity para = new ParaEntity(); para.Name = sub["PARAMETER_CODE"].ToStringExtension(); para.DisplayName = sub["PARAMETER_NAME"].ToStringExtension(); para.OffSet = sub["PLACEHOLDER"].ToStringExtension(); int index = para.Name.IndexOf("."); if (index > -1) { para.PropertyName = para.Name.Replace('.', '_'); //带上表明前缀 以防止有相同的属性名参数但是表明不一样(a.Status,b.Status),导致后续跟进参数注册属性会报错,不能注册相同的参数 } else { //可能存在查询单一表情况,不带别名的 para.PropertyName = para.Name; } para.SecondPropertyName = para.PropertyName + "2"; para.ControlType = (ControlTypeEnum)sub["CONTROL_TYPE"].ToInt32(); //控件类型 1.录入框 2.开窗 3.下拉框 4.日期框 para.ParaTypeFlag = (ParaTypeEnum)sub["PARAMETER_VALUE_TYPE"].ToInt32(); //参数值类型 1.String 2.Integer 3.Double 4.Boolean 5.Date 6.DateTime if (Maths.IsNotEmpty(sub["ORGANIZATION_TYPE"].ToStringExtension())) { para.OrgType = (OrgnizationType)(Enum.Parse(typeof(OrgnizationType), sub["ORGANIZATION_TYPE"].ToStringExtension())); //组织类型 1.公司 2.销售域 3.采购域 4.服务域 5.工厂 6.部门 7.工作中心 } else { para.OrgType = OrgnizationType.Empty; } para.QueryTypeKey = sub["WINDOW_TYPEKEY"].ToStringExtension(); //开窗typekey OperParaProName(0, para, sub, mc, srv); int count = GetTheSameCount(entity, para.PropertyName); if (count > 0) { OperParaProName(count, para, sub, mc, srv); } para.ConditionName = "Condition_" + para.PropertyName; para.Conditions = sub["CONDITIONS"].ToStringExtension(); if ((para.ControlType == ControlTypeEnum.SelectControl && para.OrgType == OrgnizationType.COMPANY)) {//组织类型为公司的开窗参数才需要添加当前条件项 if (Maths.IsNotEmpty(para.Conditions)) { para.Conditions = para.Conditions.Insert(0, "Current;"); } else { para.Conditions = "Current"; } } if ((para.ParaTypeFlag == ParaTypeEnum.String && para.ControlType == ControlTypeEnum.Input)) {//录入框类的string类型,要添加引用单元格条件项 if (Maths.IsNotEmpty(para.Conditions)) { para.Conditions += ";ExcelCell"; } else { para.Conditions = "ExcelCell"; } } string[] conditions = para.Conditions.Split(';'); if (conditions.Length > 0 && Maths.IsNotEmpty(conditions[0])) { para.Operator = GetConditionCompareEnumValue(conditions[0]); } ParaEntity tmpP = entity.ParaList.FirstOrDefault(c => c.PropertyName == para.PropertyName); if (tmpP == null) { //不能有相同的参数 entity.ParaList.Add(para); } } list.Add(entity); } return list; }
public static List <FunctionEntity> CreateViewEntity(DependencyObjectCollection collFunc) { var group = collFunc.GroupBy(c => new { FUNCTION_INFO_NAME = c["FUNCTION_INFO_NAME"].ToStringExtension(), FUNCTION_INFO_CLASS = c["FUNCTION_INFO_CLASS"].ToStringExtension(), FUNCTION_INFO_DESC = c["FUNCTION_INFO_DESC"].ToStringExtension(), FUNCTION_INFO_CLASS_NAME = c["FUNCTION_INFO_CLASS_NAME"].ToStringExtension() }); foreach (var item in group) { List <FunctionEntity> list = new List <FunctionEntity>(); FunctionEntity entity = new FunctionEntity() { Name = "TestFunc1", DisplayName = "测试函数1", Description = "测试函数1", Category = "销售" }; entity.ParaList.Add(new ParaEntity() { Name = "a.DOC_ID", OffSet = "@a", PropertyName = "DOC_ID", SecondPropertyName = "DOC_ID2", ControlType = ControlTypeEnum.SelectControl, ParaTypeFlag = ParaTypeEnum.String, OrgType = OrgnizationType.Company, ConditionName = "Condition_DOC_ID", DisplayName = "单据类型", QueryProjectId = "QPD_001", QueryTypeKey = "TFL", Tip = "查询单据性质" }); entity.ParaList.Add(new ParaEntity() { Name = "a.ApproveStatus", PropertyName = "ApproveStatus", SecondPropertyName = "ApproveStatus2", OffSet = "@a", ControlType = ControlTypeEnum.PickList, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_ApproveStatus", PickListTypeName = "BusinessApproveStatus", DisplayName = "状态" }); entity.ParaList.Add(new ParaEntity() { Name = "b.DOC_DATE", PropertyName = "DOC_DATE", SecondPropertyName = "DOC_DATE2", OffSet = "@b", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.DataTime, ConditionName = "Condition_DOC_DATE", DisplayName = "单据日期" }); entity.ParaList.Add(new ParaEntity() { Name = "b.QTY", PropertyName = "QTY", SecondPropertyName = "QTY2", OffSet = "@b", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.Decimal, ConditionName = "Condition_QTY", DisplayName = "数量" }); entity.ParaList.Add(new ParaEntity() { Name = "c.IsMoLot", PropertyName = "IsMoLot", SecondPropertyName = "IsMoLot2", OffSet = "@c", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.Boolean, ConditionName = "Condition_IsMoLot", DisplayName = "批工单" }); entity.ParaList.Add(new ParaEntity() { Name = "c.Year", PropertyName = "Year", SecondPropertyName = "Year2", OffSet = "@c", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_Year", DisplayName = "期间" }); list.Add(entity); entity = new FunctionEntity() { Name = "TestFunc2", DisplayName = "测试函数2", Description = "测试函数1", Category = "销售" }; entity.ParaList.Add(new ParaEntity() { Name = "a.DOC_ID", PropertyName = "DOC_ID", SecondPropertyName = "DOC_ID2", OffSet = "@a", ControlType = ControlTypeEnum.SelectControl, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_DOC_ID", DisplayName = "单据类型", QueryProjectId = "QPD_001", QueryTypeKey = "TFL", Tip = "查询单据性质" }); entity.ParaList.Add(new ParaEntity() { Name = "a.ApproveStatus", PropertyName = "ApproveStatus", SecondPropertyName = "ApproveStatus2", OffSet = "@a", ControlType = ControlTypeEnum.PickList, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_ApproveStatus", PickListTypeName = "BusinessApproveStatus", DisplayName = "状态" }); entity.ParaList.Add(new ParaEntity() { Name = "b.DOC_DATE", PropertyName = "DOC_DATE", SecondPropertyName = "DOC_DATE2", OffSet = "@b", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.DataTime, ConditionName = "Condition_DOC_DATE", DisplayName = "发货日期" }); list.Add(entity); entity = new FunctionEntity() { Name = "TestFunc3", DisplayName = "测试函数3", Description = "测试函数1", Category = "销售" }; entity.ParaList.Add(new ParaEntity() { Name = "a.DOC_ID", PropertyName = "DOC_ID", SecondPropertyName = "DOC_ID2", OffSet = "@a", ControlType = ControlTypeEnum.SelectControl, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_DOC_ID", DisplayName = "单据类型", QueryProjectId = "QPD_001", QueryTypeKey = "TFL", Tip = "查询单据性质" }); entity.ParaList.Add(new ParaEntity() { Name = "a.ApproveStatus", PropertyName = "ApproveStatus", SecondPropertyName = "ApproveStatus2", OffSet = "@a", ControlType = ControlTypeEnum.PickList, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_ApproveStatus", PickListTypeName = "BusinessApproveStatus", DisplayName = "状态" }); entity.ParaList.Add(new ParaEntity() { Name = "a.DOC_DATE", PropertyName = "DOC_DATE", SecondPropertyName = "DOC_DATE2", OffSet = "@a", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.Decimal, ConditionName = "Condition_DOC_DATE", DisplayName = "单据日期" }); entity.ParaList.Add(new ParaEntity() { Name = "a.QTY", PropertyName = "QTY", SecondPropertyName = "QTY2", OffSet = "@a", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.Decimal, ConditionName = "Condition_QTY", DisplayName = "数量" }); list.Add(entity); entity = new FunctionEntity() { Name = "TestFunc1", DisplayName = "测试函数1", Description = "测试函数1", Category = "采购" }; entity.ParaList.Add(new ParaEntity() { Name = "a.DOC_ID", OffSet = "@a", PropertyName = "DOC_ID", SecondPropertyName = "DOC_ID2", ControlType = ControlTypeEnum.SelectControl, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_DOC_ID", DisplayName = "单据类型", QueryProjectId = "QPD_001", QueryTypeKey = "TFL", Tip = "查询单据性质" }); entity.ParaList.Add(new ParaEntity() { Name = "a.ApproveStatus", PropertyName = "ApproveStatus", SecondPropertyName = "ApproveStatus2", OffSet = "@a", ControlType = ControlTypeEnum.PickList, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_ApproveStatus", PickListTypeName = "BusinessApproveStatus", DisplayName = "状态" }); entity.ParaList.Add(new ParaEntity() { Name = "b.DOC_DATE", PropertyName = "DOC_DATE", SecondPropertyName = "DOC_DATE2", OffSet = "@b", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.DataTime, ConditionName = "Condition_DOC_DATE", DisplayName = "单据日期" }); entity.ParaList.Add(new ParaEntity() { Name = "b.QTY", PropertyName = "QTY", SecondPropertyName = "QTY2", OffSet = "@b", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.Decimal, ConditionName = "Condition_QTY", DisplayName = "数量" }); entity.ParaList.Add(new ParaEntity() { Name = "c.IsMoLot", PropertyName = "IsMoLot", SecondPropertyName = "IsMoLot2", OffSet = "@c", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.Boolean, ConditionName = "Condition_IsMoLot", DisplayName = "批工单" }); list.Add(entity); entity = new FunctionEntity() { Name = "TestFunc2", DisplayName = "测试函数2", Description = "测试函数1", Category = "采购" }; entity.ParaList.Add(new ParaEntity() { Name = "a.DOC_ID", PropertyName = "DOC_ID", SecondPropertyName = "DOC_ID2", OffSet = "@a", ControlType = ControlTypeEnum.SelectControl, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_DOC_ID", DisplayName = "单据类型", QueryProjectId = "QPD_001", QueryTypeKey = "TFL", Tip = "查询单据性质" }); entity.ParaList.Add(new ParaEntity() { Name = "a.ApproveStatus", PropertyName = "ApproveStatus", SecondPropertyName = "ApproveStatus2", OffSet = "@a", ControlType = ControlTypeEnum.PickList, ParaTypeFlag = ParaTypeEnum.String, ConditionName = "Condition_ApproveStatus", PickListTypeName = "BusinessApproveStatus", DisplayName = "状态" }); entity.ParaList.Add(new ParaEntity() { Name = "b.DOC_DATE", PropertyName = "DOC_DATE", SecondPropertyName = "DOC_DATE2", OffSet = "@b", ControlType = ControlTypeEnum.Input, ParaTypeFlag = ParaTypeEnum.DataTime, ConditionName = "Condition_DOC_DATE", DisplayName = "发货日期" }); list.Add(entity); } return(list); }