Beispiel #1
0
        /// <summary>
        /// Offlines the request did fail with error.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="context">The context.</param>
        /// <param name="error">The error.</param>
        public void OfflineRequestDidFailWithError(UPOfflineRecordRequest request, object context, Exception error)
        {
            this.waitForSave = false;
            this.EnableActionItemsDisableActionItems(this.LeftNavigationBarItems, this.RightNaviagtionBarItems);

            Page           page = (Page)this.TopLevelElement;
            UPMStringField errorMessageField = new UPMStringField(StringIdentifier.IdentifierWithStringId("errorField"))
            {
                StringValue = LocalizedString.TextErrorCouldNotBeSaved
            };

            UPMStringField detailErrorMessageField = new UPMStringField(StringIdentifier.IdentifierWithStringId("detailErrorField"))
            {
                StringValue = LocalizedString.Localize(LocalizationKeys.TextGroupErrors, LocalizationKeys.KeyErrorsCouldNotBeSavedDetailMessage)
            };

            UPMErrorStatus errorStatus = new UPMErrorStatus(StringIdentifier.IdentifierWithStringId("error"))
            {
                MessageField       = errorMessageField,
                DetailMessageField = detailErrorMessageField
            };

            page.Status = errorStatus;
            this.InformAboutDidFailTopLevelElement(page);
        }
Beispiel #2
0
        /// <summary>
        /// Updateds the element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>
        /// The <see cref="UPMElement" />.
        /// </returns>
        public override UPMElement UpdatedElement(UPMElement element)
        {
            UPMSyncConflictsPage page = new UPMSyncConflictsPage(StringIdentifier.IdentifierWithStringId("SyncConflictsPage"));

            page.SyncConflictEmail = ConfigurationUnitStore.DefaultStore.ConfigValue("Sync.ConflictEmailAddress");
            IOfflineStorage offlineStorage  = UPOfflineStorage.DefaultStorage;
            var             offlineRequests = this.ShowAllOfflineRequests ? offlineStorage.OfflineRequests : offlineStorage.ConflictRequests;

            if (offlineRequests == null || offlineRequests.Count == 0)
            {
                this.AddNoConflictsFoundPage(page);
                return(page);
            }

            foreach (UPOfflineRequest request in offlineRequests)
            {
                IIdentifier identifier;
                if (!string.IsNullOrEmpty(request.IdentifyingRecordIdentification))
                {
                    identifier = new RecordIdentifier(request.IdentifyingRecordIdentification);
                }
                else
                {
                    identifier = StringIdentifier.IdentifierWithStringId($"request_{request.RequestNr}");
                }

                UPMSyncConflictWithContext syncConflict = new UPMSyncConflictWithContext(identifier);
                request.LoadFromOfflineStorage();
                syncConflict.OfflineRequest = request;
                syncConflict.CanBeFixed     = request.FixableByUser;
                syncConflict.CanBeReported  = !string.IsNullOrEmpty(page.SyncConflictEmail) && syncConflict.OfflineRequest.HasXml;
                if (!string.IsNullOrEmpty(request.ImageName))
                {
                    //SyncConflict.Icon = UIImage.ImageNamed(request.ImageName);    // CRM-5007
                }

                UPMStringField titleLineField = new UPMStringField(null);
                titleLineField.StringValue = request.TitleLine;
                syncConflict.MainField     = titleLineField;
                string detailsLine = request.DetailsLine;
                if (!string.IsNullOrEmpty(detailsLine))
                {
                    UPMStringField detailsLineField = new UPMStringField(null);
                    detailsLineField.StringValue = detailsLine;
                    syncConflict.DetailField     = detailsLineField;
                }

                if (!this.ShowAllOfflineRequests)
                {
                    UPMErrorStatus error = UPMErrorStatus.ErrorStatusWithMessageDetails(request.Error, request.Response);
                    syncConflict.AddStatus(error);
                }

                List <UPOfflineRequest> dependingRequests = request.DependentRequests;
                if (dependingRequests != null)
                {
                    foreach (UPOfflineRequest dependentRequest in dependingRequests)
                    {
                        string        description = $"{dependentRequest.TitleLine}-{dependentRequest.DetailsLine}";
                        UPMWarnStatus warning     = UPMWarnStatus.WarnStatusWithMessageDetails(description, null);
                        syncConflict.AddStatus(warning);
                    }
                }

                page.AddSyncConflict(syncConflict);
            }

            if (this.oldNumberOfConflicts >= 0 && this.oldNumberOfConflicts != offlineRequests.Count)
            {
                Messenger.Default.Send(SyncManagerMessage.Create(SyncManagerMessageKey.NumberOfConflictsChanged));
            }

            this.oldNumberOfConflicts = offlineRequests.Count;
            return(page);
        }
Beispiel #3
0
        /// <summary>
        /// Handles the page error details.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="details">The details.</param>
        /// <returns></returns>
        public virtual bool HandlePageErrorDetails(string message, string details)
        {
            var errorStatus = UPMErrorStatus.ErrorStatusWithMessageDetails(message, details);

            return(this.ShowStatus(errorStatus));
        }
Beispiel #4
0
        /// <inheritdoc/>
        public override void ViewWillAppear()
        {
            base.ViewWillAppear();
            if (this.SearchPage.AvailableFilters.Count < 1)
            {
                this.SearchPage.Status = UPMErrorStatus.ErrorStatusWithMessageDetails(string.Empty, LocalizedString.TextErrorConfiguration);
                return;
            }

            string configValue = this.ViewReference.ContextValueForKey("AdditionalParameters");
            Dictionary <string, object> additionalParametersDictionary = null;

            if (this.LocationMode == UPMLocationModeType.Manual)
            {
                return;
            }
            else
            {
                this.LocationMode = UPMLocationModeType.Auto;
            }

            if (configValue?.Length > 0)
            {
                additionalParametersDictionary = configValue.JsonDictionaryFromString();
            }

            if (this.copyFieldsDictionary?.Count > 0)
            {
                if (additionalParametersDictionary?.Count > 0)
                {
                    var dict = new Dictionary <string, object>(additionalParametersDictionary);
                    foreach (var key in this.copyFieldsDictionary.Keys)
                    {
                        dict.Add(key, this.copyFieldsDictionary[key]);
                    }

                    additionalParametersDictionary = dict;
                }
                else
                {
                    additionalParametersDictionary = this.copyFieldsDictionary;
                }
            }

            if (additionalParametersDictionary?.Count > 0)
            {
                string gpsY = additionalParametersDictionary.ValueOrDefault("GpsY") as string;
                string gpsX = additionalParametersDictionary.ValueOrDefault("GpsX") as string;
                if ((gpsX != null && gpsX != "0") && (gpsY != null && gpsY != "0"))
                {
                    this.initialTarget = new Location(gpsX.ToDouble(), gpsY.ToDouble());
                    if (this.LocationMode != UPMLocationModeType.Manual)
                    {
                        this.LocationMode = UPMLocationModeType.Initial;
                    }
                }
                else
                {
                    string gpsCountry = additionalParametersDictionary.ValueOrDefault("GpsCountry") as string;
                    string gpsCity    = additionalParametersDictionary.ValueOrDefault("GpsCity") as string;
                    string gpsStreet  = additionalParametersDictionary.ValueOrDefault("GpsStreet") as string;
                    string address    = null;
                    if (gpsStreet != null)
                    {
                        address = gpsStreet;
                    }

                    if (gpsCity != null)
                    {
                        if (address != null)
                        {
                            address = $"{address},{gpsCity}";
                        }
                        else
                        {
                            address = gpsCity;
                        }
                    }

                    if (gpsCountry != null)
                    {
                        if (address != null)
                        {
                            address = $"{address}, {gpsCountry}";
                        }
                        else
                        {
                            address = gpsCountry;
                        }
                    }

                    if (address != null)
                    {
                        this.LocationMode = UPMLocationModeType.Initial;
                    }

                    this.LocationMode = UPMLocationModeType.Auto;
                    this.StartAutoLocation();
                }
            }

            if (this.LocationMode == UPMLocationModeType.Auto || this.LocationMode == UPMLocationModeType.Initial)
            {
                this.StartAutoLocation();
            }
        }
        /// <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);
        }