コード例 #1
0
ファイル: MfVault.cs プロジェクト: weijx-xa/test
        private SearchConditions GetSearchPropValues(SelectedFiles files, SelectedFile file,
                                                     List <MfClassPropDef> selProps, List <string> addedValues, TraceSource log)
        {
            var scs    = new SearchConditions();
            var values = files.GetProps(file);

            for (var i = 0; i < values.Count; i++)
            {
                var vv = values[i];
                if (i == 0)
                {
                    var dotIndex = vv.LastIndexOf('.');
                    vv = vv.Substring(0, dotIndex);
                }
                //if (selProps[i].Required)
                {
                    var def = selProps[i].Def;
                    var sc  = new SearchCondition {
                        ConditionType = MFConditionType.MFConditionTypeEqual
                    };
                    sc.Expression.DataPropertyValuePropertyDef = def;
                    if (!String.IsNullOrEmpty(vv))
                    {
                        var mfVal = GetValue(selProps[i].PropDef, vv, log);
                        sc.TypedValue.SetValue((MFDataType)selProps[i].DataType, mfVal);
                    }
                    else
                    {
                        sc.TypedValue.SetValueToNULL((MFDataType)selProps[i].DataType);
                    }

                    scs.Add(-1, sc);
                }
            }
            var diff = selProps.Count - values.Count;

            if (diff > 0)
            {
                if (addedValues.Count < diff)
                {
                    addedValues =
                        addedValues.Concat(Enumerable.Range(1, diff - addedValues.Count).Select(c => String.Empty))
                        .ToList();
                }
                for (var i = 0; i < diff; i++)
                {
                    var selProp = selProps[values.Count + i];
                    var def     = selProp.Def;
                    var sc      = new SearchCondition {
                        ConditionType = MFConditionType.MFConditionTypeEqual
                    };
                    sc.Expression.DataPropertyValuePropertyDef = def;
                    var vv = addedValues[i];
                    if (!String.IsNullOrEmpty(vv))
                    {
                        var mfVal = GetValue(selProp.PropDef, vv, log);
                        sc.TypedValue.SetValue((MFDataType)selProp.DataType, mfVal);
                    }
                    else
                    {
                        sc.TypedValue.SetValueToNULL((MFDataType)selProp.DataType);
                    }
                    scs.Add(-1, sc);
                }
            }
            return(scs);
        }
コード例 #2
0
ファイル: MfVault.cs プロジェクト: weijx-xa/test
        private PropertyValues GetCreationPropValues(int classId, SelectedFiles files, SelectedFile file,
                                                     List <MfClassPropDef> selProps, List <string> addedPropValues, TraceSource log)
        {
            var pvs = new PropertyValues();

            var classPV = new PropertyValue {
                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass
            };

            classPV.TypedValue.SetValue(MFDataType.MFDatatypeLookup, classId);
            pvs.Add(-1, classPV);

            var values = files.GetProps(file);

            for (var i = 0; i < values.Count; i++)
            {
                var vv = values[i];
                if (i == 0)
                {
                    var dotIndex = vv.LastIndexOf('.');
                    vv = vv.Substring(0, dotIndex);
                }
                var v = GetValue(selProps[i].PropDef, vv, log);
                if (v != null)
                {
                    var pv = new PropertyValue {
                        PropertyDef = selProps[i].Def
                    };
                    pv.TypedValue.SetValue((MFDataType)selProps[i].DataType, v);
                    pvs.Add(-1, pv);
                }
            }
            var diff = selProps.Count - values.Count;

            if (diff > 0)
            {
                for (var i = 0; i < diff; i++)
                {
                    var p  = selProps[i + values.Count];
                    var vv = addedPropValues[i];
                    var v  = GetValue(p.PropDef, vv, log);
                    if (v != null)
                    {
                        var pv = new PropertyValue {
                            PropertyDef = p.Def
                        };
                        pv.TypedValue.SetValue((MFDataType)p.DataType, v);
                        pvs.Add(-1, pv);
                    }
                    else if (p.Required)
                    {
                    }
                    //var pv = new PropertyValue {PropertyDef = p.Def};
                    //if (String.IsNullOrEmpty(v))
                    //{
                    //    pv.TypedValue.SetValueToNULL(MFDataType.MFDatatypeText);
                    //}
                    //else
                    //{
                    //    pv.TypedValue.SetValue(MFDataType.MFDatatypeText, v);
                    //}
                    //pvs.Add(-1, pv);
                }
            }
            return(pvs);
        }