/// <summary> /// The start. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Start() { this.linkContexts = this.LinkReaderContextsForParentLinkString(this.ParentLinkString); this.queryWithLinkRecord = false; if (this.linkContexts.Count == 1) { UPCRMLinkReaderLinkContext context = this.linkContexts[0]; if (context.LinkInfo.IsGeneric) { this.crmQuery = this.QueryForLinkLinkRecord(context.LinkInfo, this.SourceRecordIdentification); this.queryWithLinkRecord = true; } } if (!this.queryWithLinkRecord) { foreach (UPCRMLinkReaderLinkContext context in this.linkContexts) { if (context.LinkInfo.LinkId <= 0 && context.LinkInfo.TargetInfoAreaId.Equals(this.InfoAreaId)) { this.DestinationRecordIdentification = this.SourceRecordIdentification; this.TheDelegate?.LinkReaderDidFinishWithResult(this, this.SourceRecordIdentification); return(true); } } this.crmQuery = this.ClientQuery(); } if (this.RequestOption == UPRequestOption.FastestAvailable || this.RequestOption == UPRequestOption.Offline) { UPCRMResult result = this.crmQuery.Find(); if (result.RowCount > 0) { UPContainerMetaInfo crmQuery = this.crmQuery; this.JustCall(crmQuery); this.crmQuery = null; this.HandleResultClient(result, true); return(true); } } if (this.RequestOption != UPRequestOption.Offline) { if (!this.queryWithLinkRecord) { this.crmQuery = this.ServerQuery(); } this.crmQuery.Find(this); return(true); } return(false); }
/// <summary> /// The link reader contexts for parent link string. /// </summary> /// <param name="parentLinkString"> /// The parent link string. /// </param> /// <returns> /// The <see cref="List"/>. /// </returns> public List <UPCRMLinkReaderLinkContext> LinkReaderContextsForParentLinkString(string parentLinkString) { List <UPCRMLinkReaderLinkContext> linkReaderContext = new List <UPCRMLinkReaderLinkContext>(); if (parentLinkString != null) { string[] infoAreaIds = parentLinkString.Split(';'); foreach (string linkString in infoAreaIds) { UPCRMLinkInfo linkInfo = this.LinkInfoFromParentLinkString(linkString); if (linkInfo != null) { UPCRMLinkReaderLinkContext context = new UPCRMLinkReaderLinkContext(linkInfo, this); linkReaderContext.Add(context); } } } return(linkReaderContext.Count > 0 ? linkReaderContext : null); }
/// <summary> /// The request link record offline. /// </summary> /// <returns> /// The <see cref="string"/>. /// </returns> public string RequestLinkRecordOffline() { this.linkContexts = this.LinkReaderContextsForParentLinkString(this.ParentLinkString); if (this.linkContexts == null || this.linkContexts.Count == 0) { return(null); } if (this.linkContexts.Count == 1) { UPCRMLinkReaderLinkContext context = this.linkContexts[0]; if (context.LinkInfo.IsGeneric) { UPContainerMetaInfo crmQuery = this.QueryForLinkLinkRecord(context.LinkInfo, this.SourceRecordIdentification); UPCRMResult result = crmQuery.Find(); if (result.RowCount > 0) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(0); return(row.RootRecordIdentification); } return(null); } } UPContainerMetaInfo crmQuery2 = this.ClientQuery(); UPCRMResult result2 = crmQuery2.Find(); if (result2.RowCount == 0) { return(null); } UPCRMResultRow row2 = (UPCRMResultRow)result2.ResultRowAtIndex(0); return(this.RecordIdentificationFromResultRow(row2)); }