/// <summary> /// Files the name for document. /// </summary> /// <param name="urlCache"> /// The URL cache. /// </param> /// <returns> /// file name /// </returns> public string FileNameForDocument(UPSyncDocumentDownloadUrlCache urlCache) { UPCRMResultRow row; if (urlCache != null) { var fieldGroupCache = urlCache.FieldGroupUrlCacheForFieldGroup(this.FieldGroupName); row = fieldGroupCache.RowForRecordIdentification(this.RecordIdentification); } else { FieldControl fieldControl = ConfigurationUnitStore.DefaultStore.FieldControlByNameFromGroup("List", this.FieldGroupName); if (fieldControl == null) { return(null); } var crmQuery = new UPContainerMetaInfo(fieldControl); var result = crmQuery.ReadRecord(this.RecordIdentification); if (result.RowCount == 0) { return(null); } row = (UPCRMResultRow)result.ResultRowAtIndex(0); } // FUNCTION NAME "Title" return(row.ValueAtIndex(1)); }
private void UpdatePage(UPContainerMetaInfo containerMetaInfo) { if (this.RequestOption != UPRequestOption.Offline) { // read record asynchronously online Operation operation; if (string.IsNullOrWhiteSpace(this.LinkRecordIdentification)) { operation = containerMetaInfo.ReadRecord(this.recordId, UPRequestOption.Online, this); } else { containerMetaInfo.DisableVirtualLinks = true; containerMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId); operation = containerMetaInfo.Find(UPRequestOption.Online, this); } if (operation == null) { this.UpdatePageWithResult(null); } } else { this.UpdatePageWithResult(null); } }
/// <summary> /// Loads the source record record identifier. /// </summary> /// <param name="_fieldControl">The field control.</param> /// <param name="recordId">The record identifier.</param> public void LoadSourceRecordRecordId(FieldControl _fieldControl, string recordId) { UPContainerMetaInfo query = new UPContainerMetaInfo(_fieldControl); UPMSearchPage searchPage = this.searchPageModelController.SearchPage; query.ReadRecord(recordId, searchPage.SearchType == SearchPageSearchType.OfflineSearch ? UPRequestOption.Offline : UPRequestOption.Online, this); }
private void LoadRecordForFieldGroup(string fieldGroup) { this.LoadConfigFieldControlForFieldGroup(fieldGroup); this.fieldFunctions = this.fieldControl.FunctionNames(); if (this.fieldFunctions != null) { UPContainerMetaInfo container = this.LoadContainer(); container.ReadRecord(this.Record, UPRequestOption.BestAvailable, this); } else { this.OpenUrl(this.replacedUrl); } }
private UPCRMResult GetResultFromContainerMetaInfo(IConfigurationUnitStore configStore) { UPCRMResult result = null; var containerMetaInfo = new UPContainerMetaInfo(this.detailsControl) { ReplaceCaseSensitiveCharacters = configStore.ConfigValueIsSet("Search.ReplaceCaseSensitiveCharacters") }; // read record synchronously offline if (this.RequestOption == UPRequestOption.Default || this.RequestOption == UPRequestOption.FastestAvailable || this.RequestOption == UPRequestOption.Offline) { if (string.IsNullOrWhiteSpace(this.LinkRecordIdentification)) { result = containerMetaInfo.ReadRecord( StringExtensions.InfoAreaIdRecordId(this.infoAreaId, this.recordId)); } else { containerMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId); containerMetaInfo.DisableVirtualLinks = true; result = containerMetaInfo.Find(); if (result.RowCount >= 1) { this.recordId = result.ResultRowAtIndex(0).RootRecordId; } } } if (result == null || result.RowCount < 1) { this.UpdatePage(containerMetaInfo); } else { var resultRow = result.ResultRowAtIndex(0) as UPCRMResultRow; this.ApplySubTitleFromResultRow(resultRow); this.FillPageWithResultRow( this.Page, resultRow, (resultRow?.IsServerResponse ?? true) ? UPRequestOption.Online : UPRequestOption.Offline); } return(result); }
/// <summary> /// Searches the operation did fail with error. /// </summary> /// <param name="operation"> /// The operation. /// </param> /// <param name="error"> /// The error. /// </param> public override void SearchOperationDidFailWithError(Operation operation, Exception error) { if (this.RequestOption == UPRequestOption.BestAvailable && error.IsConnectionOfflineError()) { var containerMetaInfo = new UPContainerMetaInfo(this.detailsControl); var result = containerMetaInfo.ReadRecord(recordId); if (result.RowCount > 0) { this.UpdatePageWithResult(result); } else { this.ShowError(error); } } else { this.ShowReadError(error); } }
/// <summary> /// Updates the page. /// </summary> /// <param name="page">The page.</param> /// <returns></returns> protected override UPMCircleOfInfluencePage UpdatePage(UPMCircleOfInfluencePage page) { if (this.rootNodeFieldControl == null) { this.InformAboutDidFailTopLevelElement(page); return(page); } // Load Root Node if (page.Invalid || page.RootNode.Invalid) { UPContainerMetaInfo query = new UPContainerMetaInfo(this.rootNodeFieldControl); if (this.ExpandSettings != null) { Dictionary <string, UPCRMField> alternateExpandFields = this.ExpandSettings.FieldsForAlternateExpands(true); List <UPCRMField> additionalFields = alternateExpandFields?.Values.Where(field => query.ContainsField(field) == null).ToList(); if (additionalFields?.Count > 0) { query.AddCrmFields(additionalFields); } this.expandChecker = this.ExpandSettings.ExpandCheckerForCrmQuery(query); } Operation operation = query.ReadRecord(this.RootRecordIdentification, this.RequestOption, this); if (operation == null && this.RequestOption == UPRequestOption.Online) { // Offline UPMWatermarkStatus offlineStatus = UPMWatermarkStatus.WatermarkStatus(); page.Status = offlineStatus; this.InformAboutDidChangeTopLevelElement(page, page, null, null); } } return(page); }
/// <summary> /// Sources the field result row for link. /// </summary> /// <param name="link">The link.</param> /// <returns></returns> List <string> SourceFieldResultRowForLink(UPCRMLink link) { UPCRMTableInfo sourceTableInfo = this.dataStore.TableInfoForInfoArea(link.InfoAreaId); UPCRMLinkInfo linkInfo = this.tableInfo.LinkInfoForTargetInfoAreaIdLinkId(link.InfoAreaId, link.LinkId); bool noFields = true; if (sourceTableInfo == null || linkInfo?.LinkFieldArray == null) { return(null); } List <UPCRMFieldSetterField> fieldMap = new List <UPCRMFieldSetterField>(linkInfo.LinkFieldArray.Count); foreach (UPCRMLinkInfoField field in linkInfo.LinkFieldArray) { UPCRMFieldInfo fieldInfo = sourceTableInfo.FieldInfoForFieldId(field.TargetFieldId); if (fieldInfo != null) { fieldMap.Add(new UPCRMFieldSetterSourceField(field.TargetFieldId)); noFields = false; } else { UPCRMFieldSetterSourceLink sourceLink = null; List <UPCRMLinkInfo> allLinks = sourceTableInfo.LinksWithField(); foreach (UPCRMLinkInfo currentLinkInfo in allLinks) { foreach (UPCRMLinkInfoField linkInfoField in currentLinkInfo.LinkFieldArray) { if (linkInfoField.FieldId == field.TargetFieldId) { UPCRMTableInfo parentTableInfo = this.dataStore.TableInfoForInfoArea(currentLinkInfo.TargetInfoAreaId); UPCRMLinkInfo parentIdentLink = parentTableInfo.IdentLink; if (parentIdentLink != null) { if (parentIdentLink.FirstField.TargetFieldId == linkInfoField.TargetFieldId) { sourceLink = new UPCRMFieldSetterSourceLink(currentLinkInfo.TargetInfoAreaId, currentLinkInfo.LinkId, 0); break; } if (parentIdentLink.SecondField.TargetFieldId == linkInfoField.TargetFieldId) { sourceLink = new UPCRMFieldSetterSourceLink(currentLinkInfo.TargetInfoAreaId, currentLinkInfo.LinkId, 1); break; } } } } if (sourceLink != null) { break; } } if (sourceLink != null) { fieldMap.Add(sourceLink); noFields = false; } else { fieldMap.Add(new UPCRMFieldSetterField()); } } } if (noFields) { return(null); } List <UPCRMField> queryFields = new List <UPCRMField>(); int resultPosition = 0; foreach (UPCRMFieldSetterField fieldSetterField in fieldMap) { if (fieldSetterField.IsField) { queryFields.Add(fieldSetterField.FieldWithInfoAreaId(link.InfoAreaId)); fieldSetterField.ResultPosition = resultPosition++; } } foreach (UPCRMFieldSetterField fieldSetterField in fieldMap) { if (fieldSetterField.IsLink) { queryFields.Add(fieldSetterField.FieldWithInfoAreaId(link.InfoAreaId)); fieldSetterField.ResultPosition = resultPosition++; } } UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(queryFields, linkInfo.TargetInfoAreaId); UPCRMResult result = crmQuery.ReadRecord(link.RecordIdentification); if (result != null && result.RowCount == 1) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(0); List <string> resultArray = new List <string>(fieldMap.Count); foreach (UPCRMFieldSetterField field in fieldMap) { if (field.IsField) { resultArray.Add(row.RawValueAtIndex(field.ResultPosition)); } else if (field.IsLink) { string recordId = row.RawValueAtIndex(field.ResultPosition); if (string.IsNullOrEmpty(recordId)) { resultArray.Add(string.Empty); } else if (recordId.StartsWith("new") && recordId.Length == 15) { long offlineLnr = (Convert.ToInt64(recordId.Substring(3, 8), 16) << 16) + Convert.ToInt64(recordId.Substring(11, 4), 16); if (this.offlineStationNumber > 0 && offlineLnr > 0) { if (((UPCRMFieldSetterSourceLink)field).FieldIndex == 0) { resultArray.Add(this.offlineStationNumber.ToString()); } else { resultArray.Add(offlineLnr.ToString()); } } } else if (((UPCRMFieldSetterSourceLink)field).FieldIndex == 0) { resultArray.Add(recordId.StatNoFromRecordIdString()); } else { resultArray.Add(recordId.RecordNoFromRecordIdString()); } } else { resultArray.Add(string.Empty); } } return(resultArray); } return(null); }
/// <summary> /// Starts the download. /// </summary> /// <returns>downloaded file counf</returns> public int StartDownload() { var fieldControl = ConfigurationUnitStore.DefaultStore.FieldControlByNameFromGroup( "List", this.FieldGroupName); if (fieldControl == null) { return(0); } var crmQuery = new UPContainerMetaInfo(fieldControl); var result = crmQuery.ReadRecord(this.RecordIdentification); if (result.RowCount == 0) { return(0); } var resourceManager = SmartbookResourceManager.DefaultResourceManager; var currentSession = ServerSession.CurrentSession; var row = result.ResultRowAtIndex(0); if (this.DocumentFromFields) { var count = 0; foreach (var tab in fieldControl.Tabs) { foreach (var field in tab.Fields) { string value = row.ValueAtIndex(field.TabIndependentFieldIndex); if (string.IsNullOrEmpty(value)) { continue; } ++count; var docData = this.DocumentManager.DocumentForKey(value); if (docData != null) { resourceManager.QueueLowPriorityDownloadForResourceAtUrl( currentSession.DocumentRequestUrlForRecordIdentification(this.RecordIdentification, docData.Title), docData.ServerUpdateDate); } else { resourceManager.QueueLowPriorityDownloadForResourceAtUrl(currentSession.DocumentRequestUrlForDocumentKey(value), null); } } } return(count); } var documentInfoAreaManager = new DocumentInfoAreaManager(fieldControl.InfoAreaId, fieldControl, null); var documentData = documentInfoAreaManager.DocumentDataForResultRow(row as UPCRMResultRow); resourceManager.QueueLowPriorityDownloadForResourceAtUrl( currentSession.DocumentRequestUrlForRecordIdentification(this.RecordIdentification, documentData.Title), documentData.ServerUpdateDate); return(1); }
/// <summary> /// Downloads the ur ls for document. /// </summary> /// <param name="urlCache">The URL cache.</param> /// <returns></returns> public List <Uri> DownloadUrlsForDocument(UPSyncDocumentDownloadUrlCache urlCache) { if (this.downloadUrLsIntitialized) { return(this.downloadUrls); } this.downloadUrLsIntitialized = true; UPCRMResultRow row; FieldControl fieldControl; if (urlCache != null) { var fieldGroupCache = urlCache.FieldGroupUrlCacheForFieldGroup(this.FieldGroupName); fieldControl = fieldGroupCache.FieldControl; row = fieldGroupCache.RowForRecordIdentification(this.RecordIdentification); } else { fieldControl = ConfigurationUnitStore.DefaultStore.FieldControlByNameFromGroup("List", this.FieldGroupName); if (fieldControl == null) { return(null); } var crmQuery = new UPContainerMetaInfo(fieldControl); var result = crmQuery.ReadRecord(this.RecordIdentification); if (result.RowCount == 0) { return(null); } row = (UPCRMResultRow)result.ResultRowAtIndex(0); } if (this.DocumentFromFields) { var documentDownloadURLs = new List <Uri>(); foreach (var tab in fieldControl.Tabs) { foreach (var field in tab.Fields) { string value = row.ValueAtIndex(field.TabIndependentFieldIndex); if (!string.IsNullOrEmpty(value)) { var documentData = this.DocumentManager.DocumentForKey(value); Uri downloadURL = documentData != null? ServerSession.CurrentSession.DocumentRequestUrlForRecordIdentification(documentData.RecordIdentification, documentData.Title) : ServerSession.CurrentSession.DocumentRequestUrlForDocumentKey(value); if (SmartbookResourceManager.DefaultResourceManager.ResourceForUrl(downloadURL, null) == null) { documentDownloadURLs.Add(downloadURL); } } } } this.downloadUrls = documentDownloadURLs; return(documentDownloadURLs); } Uri downloadUrl = ServerSession.CurrentSession.DocumentRequestUrlForRecordIdentification(this.RecordIdentification, row.ValueAtIndex(1)); if (SmartbookResourceManager.DefaultResourceManager.ResourceForUrl(downloadUrl, null) == null) { this.downloadUrls = new List <Uri> { downloadUrl }; return(this.downloadUrls); } return(null); }
private UPMSearchPage UpdatePage(UPMSearchPage searchPage) { UPMSearchPage newPage = this.CreatePageInstance(); this.BuildPageDetails(newPage); if (searchPage.Invalid) { this.pendingRecords.Clear(); this.rows.Clear(); this.historyManager = HistoryManager.DefaultHistoryManager; this.configStore = ConfigurationUnitStore.DefaultStore; if (this.historyManager.HistoryEntries.Count == 0) { return(newPage); } foreach (HistoryEntry entry in this.historyManager.HistoryEntries) { string recordIdent = entry.RecordIdentification; SearchAndList searchConfiguration = this.configStore.SearchAndListByName(recordIdent.InfoAreaId()); FieldControl listFieldControl = this.configStore.FieldControlByNameFromGroup("List", searchConfiguration.FieldGroupName); UPContainerMetaInfo containerMetaInfo = new UPContainerMetaInfo(listFieldControl); if (entry.OnlineData) { if (ServerSession.CurrentSession.ConnectedToServer) { this.pendingRecords.Add(recordIdent); this.resCount++; containerMetaInfo.ReadRecord(recordIdent, UPRequestOption.Online, this); } else { UPMResultRow row = new UPMResultRow(new RecordIdentifier(recordIdent)); UPMStringField stringField = new UPMStringField(StringIdentifier.IdentifierWithStringId(recordIdent)); stringField.FieldValue = LocalizedString.TextOfflineNotAvailable; row.Fields = new List <UPMField> { stringField }; row.OnlineData = true; //row.StatusIndicatorIcon = UIImage.UpXXImageNamed("crmpad-List-Cloud"); // CRM-5007 InfoArea infoAreaConfig = this.configStore.InfoAreaConfigById(recordIdent.InfoAreaId()); string imageName = infoAreaConfig.ImageName; if (!string.IsNullOrEmpty(imageName)) { //row.Icon = UIImage.UpImageWithFileName(imageName); // CRM-5007 } this.rows.Add(row); } } else { this.resCount++; this.pendingRecords.Add(recordIdent); containerMetaInfo.ReadRecord(recordIdent, UPRequestOption.Offline, this); } } newPage.Invalid = false; this.TopLevelElement = newPage; this.ApplyLoadingStatusOnPage(newPage); return(newPage); } UPMResultSection section = (UPMResultSection)this.Page.Children[0]; this.ResortRowListAddToPage(section.Children, newPage); this.TopLevelElement = newPage; return(newPage); }
/// <summary> /// Updates the page with result. /// </summary> /// <param name="result"> /// The result. /// </param> public void UpdatePageWithResult(UPCRMResult result) { if (result == null) { return; } var oldPage = this.Page; var newPage = (MDetailPage)this.InstantiatePage(); newPage.LabelText = oldPage.LabelText; newPage.Invalid = false; newPage.Status = null; if (result.RowCount == 0) { if (this.RequestOption == UPRequestOption.BestAvailable) { var containerMetaInfo = new UPContainerMetaInfo(this.detailsControl) { ReplaceCaseSensitiveCharacters = ConfigurationUnitStore.DefaultStore.ConfigValueIsSet( "Search.ReplaceCaseSensitiveCharacters") }; if (string.IsNullOrWhiteSpace(this.LinkRecordIdentification)) { result = containerMetaInfo.ReadRecord(this.infoAreaId.InfoAreaIdRecordId(this.recordId)); } else { containerMetaInfo.SetLinkRecordIdentification(this.LinkRecordIdentification, this.LinkId); result = containerMetaInfo.Find(); } if (result.RowCount == 0) { var errorStatus = UPMErrorStatus.ErrorStatusWithMessageDetails("Loading error", null); newPage.Status = errorStatus; newPage.Invalid = true; this.TopLevelElement = newPage; this.InformAboutDidFailTopLevelElement(this.Page); return; } } else { var errorStatus = UPMErrorStatus.ErrorStatusWithMessageDetails("Loading error", null); newPage.Status = errorStatus; newPage.Invalid = true; this.TopLevelElement = newPage; this.InformAboutDidFailTopLevelElement(this.Page); return; } } var resultRow = result.ResultRowAtIndex(0) as UPCRMResultRow; this.FillPageWithResultRow( newPage, resultRow, resultRow.IsServerResponse ? UPRequestOption.Online : UPRequestOption.Offline); this.ApplySubTitleFromResultRow(resultRow); this.TopLevelElement = newPage; this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null); }