Пример #1
0
        private string GetLambda(ParaEntity para)
        {
            string pre   = "[" + para.OffSet + ":";
            string value = string.Empty;

            switch (para.Operator)
            {
            case OperatorTypeEnum.Equal:
            case OperatorTypeEnum.ExcelCell:
            case OperatorTypeEnum.Current:
                value = GetValue(para, "=");
                break;

            case OperatorTypeEnum.GreaterEqual:
                value = GetValue(para, ">=");
                break;

            case OperatorTypeEnum.GreaterThan:
                value = GetValue(para, ">");
                break;

            case OperatorTypeEnum.LessEqual:
                value = GetValue(para, "<=");
                break;

            case OperatorTypeEnum.LessThan:
                value = GetValue(para, "<");
                break;

            case OperatorTypeEnum.NotEqual:
                value = GetValue(para, "!=");
                break;

            case OperatorTypeEnum.In:
                value = GetValue(para, "in");
                break;

            case OperatorTypeEnum.Between:
                value = GetValue(para, "Between");
                break;

            case OperatorTypeEnum.Like:
                value = GetValue(para, "like");
                break;
            }

            if (value != string.Empty)
            {
                value += "]";
                return(pre += value);
            }
            return(string.Empty);
        }
Пример #2
0
        private static void OperParaProName(int existCount, ParaEntity para, DependencyObject sub, IMetadataContainer mc, IQueryProjectContainer srv) {
            string name = para.Name;
            string extendFix = string.Empty;
            if (existCount > 0) {
                extendFix = "X" + (existCount + 1);  //后续以X+流水
                name = name + extendFix;
            }
            int index = name.IndexOf(".");
            if (index > -1) {
                para.PropertyName = name.Replace('.', '_');  //带上表明前缀 以防止有相同的属性名参数但是表明不一样(a.Status,b.Status),导致后续跟进参数注册属性会报错,不能注册相同的参数
            } else {   //可能存在查询单一表情况,不带别名的
                para.PropertyName = name;
            }
            para.SecondPropertyName = para.PropertyName + "2";
            if (para.ControlType == ControlTypeEnum.PickList) {
                para.PickListTypeName = sub["CONTROL_CODE"].ToStringExtension();
                if (para.PickListTypeName != string.Empty) {
                    var pick = mc.GetPickListTypeElement(para.PickListTypeName);
                    if (pick != null) {
                        //para.Tip = pick.DisplayName; //20170829 mark by shenbao for P001-170829002
                        LocalizableString localStr = new LocalizableString(pick.DisplayName); //20170829 add by shenbao for P001-170829002
                        para.Tip = localStr[System.Globalization.CultureInfo.CurrentUICulture.ThreeLetterWindowsLanguageName]; //20170829 add by shenbao for P001-170829002
                    }
                }
            } else if (para.ControlType == ControlTypeEnum.SelectControl) {
                para.QueryProjectId = sub["CONTROL_CODE"].ToStringExtension();
                QueryProject qp = srv.QueryProjects.FirstOrDefault(c => c.Id == para.QueryProjectId) as QueryProject;
                string idColumn = string.Empty;
                if (qp != null) {
                    idColumn = qp.ContextDataColumn;
                    para.Tip = qp.DisplayName;
                } else {
                    idColumn = "KEY_FIELD_ID";  //理论上永远不会走到这里,除非FINCTION_INFO没有配置开窗编号,或者这个编号是错误的
                }
                para.TargetEntityPirmaryKeyID = idColumn;
                if (index >= 0) {
                    para.PropertyName = name.Substring(0, index) + "_" + idColumn + extendFix;  //如果是开窗类型,则需要重新设置PropertyName,为ID字段
                } else {
                    para.PropertyName = idColumn + extendFix;
                }
                para.SecondPropertyName = para.PropertyName + "2";

            }
        }
Пример #3
0
        private string GetValue(ParaEntity para, string oper) {
            string value = string.Empty;
            bool strFlag = (para.ParaTypeFlag == ParaTypeEnum.String || para.ParaTypeFlag == ParaTypeEnum.DateTime || para.ParaTypeFlag == ParaTypeEnum.Date);
            if (oper == "in") {
                foreach (ValueEntity item in para.ParaValueList) {
                    if (Maths.IsEmpty(item.Value))
                        continue;
                    if (strFlag) {
                        string tmpValue = ReOperValue(item.Value.ToStringExtension());
                        if (value == string.Empty)
                            value = "'" + tmpValue + "'";
                        else
                            value += "," + "'" + tmpValue + "'";
                    } else {
                        if (value == string.Empty)
                            value = item.Value.ToStringExtension();
                        else
                            value += "," + item.Value;
                    }
                }

                if (value != string.Empty) {
                    value = para.Name + " in (" + value + ")";
                }
            } else if (oper == "Between") {
                if (Maths.IsNotEmpty(para.ParaValueList[0].Value) && Maths.IsNotEmpty(para.ParaValueList[1].Value)) {
                    object tmpValue1 = para.ParaValueList[0].Value;
                    object tmpValue2 = para.ParaValueList[1].Value;
                    if (para.ControlType == ControlTypeEnum.SelectControl) {
                        tmpValue1 = para.ParaValueList[0].ReturnValue;
                        tmpValue2 = para.ParaValueList[1].ReturnValue;
                    }
                    //if (para.ParaTypeFlag == ParaTypeEnum.Date || para.ParaTypeFlag == ParaTypeEnum.DateTime) {
                    //    tmpValue1 = tmpValue1.ToDate().ToString("yyyy-MM-dd");
                    //    tmpValue2 = tmpValue2.ToDate().ToString("yyyy-MM-dd");
                    //}
                    if (strFlag) {
                        tmpValue1 = ReOperValue(tmpValue1.ToStringExtension());
                        tmpValue2 = ReOperValue(tmpValue2.ToStringExtension());
                        value = para.Name + ">='" + tmpValue1 + "' and " + para.Name + " <= '" + tmpValue2 + "'";
                    } else {
                        value = para.Name + ">=" + tmpValue1 + " and " + para.Name + " <= " + tmpValue2;
                    }
                }
            } else {
                if (Maths.IsNotEmpty(para.ParaValueList[0].Value)) {
                    object tmpValue = para.ParaValueList[0].Value;
                    if (para.ControlType == ControlTypeEnum.SelectControl) {
                        tmpValue = para.ParaValueList[0].ReturnValue;  //如果是开窗,则取固定的返回值ReturnValue
                    }
                    //if (para.ParaTypeFlag == ParaTypeEnum.Date || para.ParaTypeFlag == ParaTypeEnum.DateTime) {
                    //    tmpValue = tmpValue.ToDate().ToString("yyyy-MM-dd");
                    //}
                    if (oper == "like") {
                        tmpValue = ReOperValue(tmpValue.ToStringExtension());
                        value = para.Name + " " + oper + " '%" + tmpValue + "%'";
                    } else {
                        if (strFlag) {
                            if (para.Operator == OperatorTypeEnum.ExcelCell) {
                                value = para.Name + oper + @"'""&" + tmpValue + @"&""'";
                            } else {
                                tmpValue = ReOperValue(tmpValue.ToStringExtension());
                                value = para.Name + oper + "'" + tmpValue + "'";
                            }

                        } else {
                            value = para.Name + oper + tmpValue;
                        }
                    }
                }
            }

            return value;
        }
Пример #4
0
        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;
        }
Пример #5
0
        public static DigiwinSelectControl CreateSelectControl(DependencyObject dataSource, string name, string propertyName, ParaEntity para
                                                               , bool isReadOnly, bool visible, bool allowMultiSelect, int tabeIndex)
        {
            DigiwinSelectControl dsc1 = new DigiwinSelectControl();

            ((System.ComponentModel.ISupportInitialize)(dsc1)).BeginInit();
            dsc1.Name        = name;
            dsc1.SelectStyle = SelectStyle.TwoInOneOpen;
            dsc1.ReadOnly    = isReadOnly;
            dsc1.Visible     = visible;
            dsc1.AllowInput  = false;
            dsc1.AllowOpenWindowInOpenState = false;
            BindingSource bs          = new BindingSource();
            string        hiddenText  = propertyName.Replace("_ID", "_CODE");
            string        displayText = propertyName.Replace("_ID", "_NAME");

            if (dataSource != null)
            {
                bs.DataSource = dataSource.DefaultView;

                dsc1.DataBindings.Add(new Binding("Value", bs, propertyName, true, DataSourceUpdateMode.OnPropertyChanged, Maths.GuidDefaultValue()));
                dsc1.DataBindings.Add(new Binding("HiddenText", bs, hiddenText, true, DataSourceUpdateMode.OnPropertyChanged));
                dsc1.DataBindings.Add(new Binding("DisplayText", bs, displayText, true, DataSourceUpdateMode.OnPropertyChanged));
            }

            GeneralWindowOpener generalWindowOpener = new GeneralWindowOpener();

            generalWindowOpener.Description = null;
            generalWindowOpener.InexactQuery.QueryProjectId = null;
            generalWindowOpener.InexactQuery.QueryTypeKey   = null;
            generalWindowOpener.InexactQuery.ReturnField    = null;
            generalWindowOpener.Name            = null;
            generalWindowOpener.OpenCondition   = null;
            generalWindowOpener.OpenFailMessage = null;
            generalWindowOpener.RelatedType     = RelatedType.BindingField;
            generalWindowOpener.MultiSelect     = allowMultiSelect;
            //if (propertyVM.OpeningPatameters.Count > 0) {
            //    foreach (OpeningParameter parameter in propertyVM.OpeningPatameters) {
            //        generalWindowOpener.OpeningParameters.Add(parameter);
            //    }
            //}

            ReturnExpression returnExpression1 = new ReturnExpression();
            ReturnExpression returnExpression2 = new ReturnExpression();
            ReturnExpression returnExpression3 = new ReturnExpression();
            ReturnExpression returnExpression4 = new ReturnExpression();

            generalWindowOpener.QueryProjectId = para.QueryProjectId;
            generalWindowOpener.QueryTypeKey   = para.QueryTypeKey;

            returnExpression1.Left  = "ActiveObject." + propertyName;
            returnExpression1.Name  = "ActiveObject." + para.PropertyName;
            returnExpression1.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID;

            returnExpression2.Left  = "ActiveObject." + hiddenText;
            returnExpression2.Name  = "ActiveObject." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_CODE");
            returnExpression2.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_CODE");

            returnExpression3.Left  = "ActiveObject." + displayText;
            returnExpression3.Name  = "ActiveObject." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_NAME");
            returnExpression3.Right = "SelectedObjects[0]." + para.TargetEntityPirmaryKeyID.Replace("_ID", "_NAME");

            returnExpression4.Left  = "ActiveObject." + propertyName + "_RETURN_VALUE";
            returnExpression4.Name  = "ActiveObject." + para.PropertyName + "_RETURN_VALUE";
            returnExpression4.Right = "SelectedObjects[0].RETURN_VALUE";

            generalWindowOpener.ReturnExpressions.Add(returnExpression1);
            generalWindowOpener.ReturnExpressions.Add(returnExpression2);
            generalWindowOpener.ReturnExpressions.Add(returnExpression3);
            generalWindowOpener.ReturnExpressions.Add(returnExpression4);

            generalWindowOpener.ReturnField = para.TargetEntityPirmaryKeyID;
            generalWindowOpener.Shortcut    = System.Windows.Forms.Keys.F2;
            generalWindowOpener.Tip         = para.Tip;
            dsc1.WindowOpeners.Add(generalWindowOpener);
            ((System.ComponentModel.ISupportInitialize)(dsc1)).EndInit();

            return(dsc1);
        }