示例#1
0
        /// <summary>
        /// Determines whether [is empty value] [the specified value].
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool IsEmptyValue(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(true);
            }

            if (string.IsNullOrEmpty(this.FieldType))
            {
                return(false);
            }

            switch (this.FieldType[0])
            {
            case 'L':
            case 'S':
            case 'N':
            case 'K':
            case 'X':
                if (value == "0")
                {
                    var crmField = new UPCRMField(this.FieldId, this.InfoAreaId);
                    return(crmField.IsEmptyValue("0"));
                }

                return(false);

            default:
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMLinkReaderLinkContext"/> class.
        /// </summary>
        /// <param name="linkInfo">
        /// The link info.
        /// </param>
        /// <param name="linkReader">
        /// The link reader.
        /// </param>
        public UPCRMLinkReaderLinkContext(UPCRMLinkInfo linkInfo, UPCRMLinkReader linkReader)
        {
            this.LinkInfo = linkInfo;
            if (this.LinkInfo.IsGeneric)
            {
            }
            else if (this.LinkInfo.UseLinkFields)
            {
                List <UPCRMField> linkFields = new List <UPCRMField>();
                foreach (UPCRMLinkInfoField linkInfoField in this.LinkInfo.LinkFieldArray)
                {
                    if (linkInfoField.FieldId >= 0)
                    {
                        linkFields.Add(UPCRMField.FieldWithFieldIdInfoAreaId(linkInfoField.FieldId, linkReader.InfoAreaId));
                    }
                }

                this.FieldLinkFields = linkFields;
            }
            else
            {
                this.LinkField = UPCRMLinkField.FieldWithLinkInfoAreaIdLinkIdInfoAreaId(
                    this.LinkInfo.TargetInfoAreaId,
                    this.LinkInfo.LinkId,
                    linkReader.InfoAreaId);
            }
        }
示例#3
0
        /// <summary>
        /// Determines whether [is equal to field] [the specified field].
        /// </summary>
        /// <param name="field">
        /// The field.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool IsEqualToField(UPCRMField field)
        {
            if (field.FieldId != this.FieldId || (field.LinkId != this.LinkId && (field.LinkId > 0 || this.LinkId > 0)) ||
                field.InfoAreaId != this.InfoAreaId)
            {
                return(false);
            }

            if (field.ParentLink == this.ParentLink)
            {
                return(true);
            }

            if (field.ParentLink == null || this.ParentLink == null)
            {
                return(false);
            }

            if (field.ParentLink.Key == this.ParentLink.Key)
            {
                return(true);
            }

            return(false);
        }
示例#4
0
        /// <summary>
        /// The server query.
        /// </summary>
        /// <returns>
        /// The <see cref="UPContainerMetaInfo"/>.
        /// </returns>
        public UPContainerMetaInfo ServerQuery()
        {
            List <UPCRMField> serverLinkFields = new List <UPCRMField>();

            foreach (UPCRMLinkReaderLinkContext context in this.linkContexts)
            {
                serverLinkFields.Add(
                    UPCRMField.FieldWithFieldIdInfoAreaIdLinkId(
                        0,
                        context.LinkInfo.TargetInfoAreaId,
                        context.LinkInfo.LinkId));
            }

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(serverLinkFields, this.InfoAreaId);

            crmQuery.SetLinkRecordIdentification(this.SourceRecordIdentification, -1);
            return(crmQuery);
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMFieldInfo" /> class.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="dataStore">The data store.</param>
        /// <returns>UPCRMFieldInfo</returns>
        public static UPCRMFieldInfo Create(UPCRMField field, ICRMDataStore dataStore)
        {
            if (field == null || dataStore == null)
            {
                return(null);
            }

            var tableInfo = dataStore.DatabaseInstance?.GetTableInfoByInfoArea(field.InfoAreaId);

            var fieldInfo = tableInfo?.GetFieldInfo(field.FieldId);

            if (fieldInfo == null)
            {
                return(null);
            }

            return(new UPCRMFieldInfo
            {
                InfoAreaId = field.InfoAreaId,
                FieldId = field.FieldId,
                fieldInfo = fieldInfo
            });
        }
        /// <summary>
        /// Reads the rep with identifier.
        /// </summary>
        /// <param name="repId">The rep identifier.</param>
        /// <returns></returns>
        public UPCRMRep ReadRepWithId(string repId)
        {
            if (string.IsNullOrEmpty(repId))
            {
                return(null);
            }

            if (this.missingRepDictionary == null)
            {
                this.missingRepDictionary = new Dictionary <string, UPCRMRep>();
            }
            else
            {
                var returnRep = this.missingRepDictionary.ValueOrDefault(repId);
                if (returnRep != null)
                {
                    return(returnRep);
                }

                if (this.emptyRepDictionary.ValueOrDefault(repId) != null)
                {
                    return(null);
                }
            }

            var          configStore      = ConfigurationUnitStore.DefaultStore;
            var          repSearchAndList = configStore.SearchAndListByName("IDSystem");
            FieldControl fieldControl     = null;

            if (repSearchAndList != null)
            {
                fieldControl = configStore.FieldControlByNameFromGroup("List", "IDSystem");
            }

            if (fieldControl?.Fields == null ||
                fieldControl.Fields.Count == 0)
            {
                return(null);
            }

            UPCRMField vField        = fieldControl.Fields[0].Field;
            var        fromCondition = new UPInfoAreaConditionLeaf(fieldControl.InfoAreaId, vField.FieldId, "=", repId);
            var        metaInfo      = new UPContainerMetaInfo(fieldControl);

            metaInfo.RootInfoAreaMetaInfo.AddCondition(fromCondition);
            UPCRMResult result = metaInfo.Find();
            int         count  = result.RowCount;

            if (count > 0)
            {
                lock (this.missingRepDictionary)
                {
                    for (var i = 0; i < count; i++)
                    {
                        var row = result.ResultRowAtIndex(i);
                        var rep = new UPCRMRep(
                            row.RawValueAtIndex(0),
                            row.RawValueAtIndex(2),
                            row.RawValueAtIndex(1),
                            row.RootRecordId,
                            this.RepTypeFromStringRepTypeId(row.RawValueAtIndex(3)));

                        this.missingRepDictionary[rep.RepId] = rep;
                    }

                    foreach (var rep in this.repArray)
                    {
                        if (string.IsNullOrEmpty(rep.RepOrgGroupId))
                        {
                            continue;
                        }

                        var parentRep = this.missingRepDictionary.ValueOrDefault(rep.RepOrgGroupId);
                        parentRep?.AddChildRep(rep);
                    }
                }

                return(this.missingRepDictionary.ValueOrDefault(repId));
            }

            if (this.emptyRepDictionary == null)
            {
                this.emptyRepDictionary = new Dictionary <string, string>();
            }

            this.emptyRepDictionary[repId] = repId;
            return(null);
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPCRMFieldInfo" /> class.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>UPCRMFieldInfo</returns>
 public static UPCRMFieldInfo Create(UPCRMField field)
 {
     return(Create(field, UPCRMDataStore.DefaultStore));
 }