Beispiel #1
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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Searches the operation did finish with result.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="result">The result.</param>
        public override void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            if (this.crmQuery != null)
            {
                int count         = result.RowCount;
                int infoAreaCount = result.MetaInfo.NumberOfResultInfoAreaMetaInfos();

                for (int i = 0; i < count; i++)
                {
                    UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(i);

                    for (int j = 1; j < infoAreaCount; j++)
                    {
                        string linkRecordIdentification = resultRow.RecordIdentificationAtIndex(j);
                        if (linkRecordIdentification?.Length > 6)
                        {
                            UPCRMLinkParticipant linkParticipant = new UPCRMLinkParticipant(resultRow, j);
                            this.AddLinkParticipant(linkParticipant);

                            if (!string.IsNullOrEmpty(this.ProtectedLinkRecordIdentification) && this.ProtectedLinkRecordIdentification == linkParticipant.LinkRecordIdentification)
                            {
                                linkParticipant.MayNotBeDeleted = true;
                            }

                            break;
                        }
                        else
                        {
                            UPContainerInfoAreaMetaInfo iaMeta      = result.MetaInfo.ResultInfoAreaMetaInfoAtIndex(j);
                            UPCRMLinkReader             _linkReader = new UPCRMLinkReader(resultRow.RootRecordIdentification, iaMeta.InfoAreaIdWithLink, null);
                            string linkRecordId = _linkReader.RequestLinkRecordOffline();

                            if (!string.IsNullOrEmpty(linkRecordId) && UPCRMDataStore.DefaultStore.RecordExistsOffline(linkRecordId))
                            {
                                UPCRMLinkParticipant linkParticipant = new UPCRMLinkParticipant(resultRow, linkRecordId);
                                this.AddLinkParticipant(linkParticipant);
                                break;
                            }
                        }
                    }
                }

                this.Finished(null);
            }
            else
            {
                base.SearchOperationDidFinishWithResult(operation, result);
            }
        }