/// <summary>
        /// Approves the specified dummy.
        /// </summary>
        /// <param name="dummy">The dummy.</param>
        public void Approve(object dummy)
        {
            if (this.disableSigning)
            {
                return;
            }

            string recordIdentification = this.buttonViewReference.ContextValueForKey("RecordId");
            string filterName           = this.buttonViewReference.ContextValueForKey("TemplateFilter");

            if (string.IsNullOrEmpty(recordIdentification))
            {
                this.ParentOrganizerModelController.HandleOrganizerActionError(
                    LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorParameterEmpty, "RecordId"), true);
                return;
            }

            UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName);

            if (filter == null)
            {
                this.HandlePageErrorDetails(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorFilterMissing, filterName));
                return;
            }

            filter = filter.FilterByApplyingValueDictionaryDefaults(this.FieldValueDictionary, true);
            UPCRMRecord record = new UPCRMRecord(recordIdentification);

            record.ApplyValuesFromTemplateFilter(filter);
            UPOfflineEditRecordRequest request = new UPOfflineEditRecordRequest(0);

            this.buttonRequest = request;
            string requestOptionString       = this.buttonViewReference.ContextValueForKey("RequestOption");
            UPOfflineRequestMode requestMode = UPOfflineRequest.RequestModeFromString(requestOptionString, UPOfflineRequestMode.OnlineConfirm);

            if (request.StartRequest(requestMode, new List <UPCRMRecord> {
                record
            }, this) == false)
            {
                this.buttonRequest = null;
            }
            else
            {
                this.ShouldWaitForPendingChanges = true;
            }
        }
        private void PerformUploadReportPdfWithRecords(List <UPCRMRecord> records)
        {
            if (records.Count > 0)
            {
                string requestOptionString             = this.buttonViewReference.ContextValueForKey("RequestOption");
                UPOfflineRequestMode       requestMode = UPOfflineRequest.RequestModeFromString(requestOptionString, UPOfflineRequestMode.OnlineConfirm);
                UPOfflineEditRecordRequest request     = new UPOfflineEditRecordRequest(requestMode, null);
                this.buttonRequest = request;
                foreach (UPCRMRecord record in records)
                {
                    request.AddRecord(record);
                }

                this.multiRequest.AddRequest(request);
            }

            this.multiRequest.Start();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes this instance.
        /// </summary>
        public override void Execute()
        {
            string requestModeString = this.ViewReference.ContextValueForKey("RequestMode");

            if (!ServerSession.CurrentSession.UserChoiceOffline && ServerSession.CurrentSession.ConnectedToServer)
            {
                this.RequestMode = UPOfflineRequest.RequestModeFromString(requestModeString, UPOfflineRequestMode.OnlineOnly);
            }
            else
            {
                this.RequestMode = UPOfflineRequest.RequestModeFromString(requestModeString, UPOfflineRequestMode.Offline);
            }

            this.RecordIdentification = this.ViewReference.ContextValueForKey("RecordId");
            string filterName = this.ViewReference.ContextValueForKey("TemplateFilter");

            if (string.IsNullOrEmpty(this.RecordIdentification))
            {
                this.ModelController.HandleOrganizerActionError(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorParameterEmpty, "RecordId"), true);
                return;
            }

            this.TemplateFilter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName);
            if (this.TemplateFilter == null && string.IsNullOrEmpty(this.ViewReference.ContextValueForKey("LinkRecordId")))
            {
                this.ModelController.HandleOrganizerActionError(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorFilterMissing, filterName), true);
                return;
            }

            if (this.TemplateFilter?.NeedsLocation ?? false)
            {
                SimpleIoc.Default.GetInstance <ILocationService>().GetCurrentLocation(this);
                return;
            }

            this.ContinueTemplateFilterGeoChecked();
        }
Exemplo n.º 4
0
        private void ContinueRecordDoesNotExist()
        {
            string requestModeString         = this.ViewReference.ContextValueForKey("RequestMode");
            UPOfflineRequestMode requestMode = UPOfflineRequest.RequestModeFromString(requestModeString, UPOfflineRequestMode.OnlineOnly);
            string filterName   = this.ViewReference.ContextValueForKey("TemplateFilter");
            string infoAreaId   = this.ViewReference.ContextValueForKey("InfoAreaId");
            string linkIdString = this.ViewReference.ContextValueForKey("LinkId");

            if (string.IsNullOrEmpty(infoAreaId))
            {
                this.ModelController.HandleOrganizerActionError(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorParameterEmpty, "InfoAreaId"), true);
                return;
            }

            int  linkId = -1;
            bool noLink = false;

            if (!string.IsNullOrEmpty(linkIdString))
            {
                if (linkIdString == "NoLink")
                {
                    noLink = true;
                }

                linkId = Convert.ToInt32(linkIdString);
            }

            UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName);

            if (filter == null)
            {
                this.ModelController.HandleOrganizerActionError(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorFilterMissing, filterName), true);
                return;
            }

            filter      = filter.FilterByApplyingValueDictionaryDefaults(this.sourceCopyFields, true);
            this.record = UPCRMRecord.CreateNew(infoAreaId);
            if (!noLink && !string.IsNullOrEmpty(this.LinkRecordIdentification))
            {
                this.record.AddLink(new UPCRMLink(this.LinkRecordIdentification, linkId));
            }

            this.record.ApplyValuesFromTemplateFilter(filter);
            UPOfflineEditRecordRequest request = new UPOfflineEditRecordRequest(0);
            string optionsString = this.ViewReference.ContextValueForKey("Options");

            if (!string.IsNullOrEmpty(optionsString))
            {
                Dictionary <string, object> options = optionsString.JsonDictionaryFromString();
                if (Convert.ToInt32(options["ComputeLinks"]) != 0)
                {
                    request.AlwaysSetImplicitLinks = true;
                }
            }

            List <UPCRMRecord> recordArray = new List <UPCRMRecord> {
                this.record
            };
            string syncParentInfoAreaIdString = this.ViewReference.ContextValueForKey("SyncParentInfoAreaIds");

            if (!string.IsNullOrEmpty(syncParentInfoAreaIdString))
            {
                var syncParentInfoAreaIds = syncParentInfoAreaIdString.Split(',');
                foreach (string syncParentInfoAreaId in syncParentInfoAreaIds)
                {
                    var infoAreaIdParts = syncParentInfoAreaId.Split(':');
                    if (infoAreaIdParts.Length == 1)
                    {
                        recordArray.Add(new UPCRMRecord(syncParentInfoAreaId, new UPCRMLink(this.record, -1)));
                    }
                    else if (infoAreaIdParts.Length > 1)
                    {
                        recordArray.Add(new UPCRMRecord(infoAreaIdParts[0], new UPCRMLink(this.record, Convert.ToInt32(infoAreaIdParts[1]))));
                    }
                }
            }

            if (this.ModelController.SetOfflineRequest(request, true))
            {
                if (request.StartRequest(requestMode, recordArray, this) == false)
                {
                    this.ModelController.SetOfflineRequest(null, true);
                    return;
                }
            }
            else
            {
                this.ModelController.HandleOrganizerActionError(LocalizedString.TextErrorActionNotPossible, LocalizedString.TextErrorActionPending, true);
            }
        }