Пример #1
0
 /// <summary>
 /// Offlines the request did finish with result.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="data">The data.</param>
 /// <param name="online">if set to <c>true</c> [online].</param>
 /// <param name="_context">The context.</param>
 /// <param name="result">The result.</param>
 public override void OfflineRequestDidFinishWithResult(UPOfflineRequest request, object data, bool online, object _context, Dictionary <string, object> result)
 {
     this.uploadDocumentRequest = null;
     this.Row.Error             = null;
     this.SerialEntry.HandlePhotoUploadedContext(this.Row, this.Context);
     this.Finished();
 }
        private void PerformUploadReportPdf(int viewTag, object sender)
        {
            this.disable85106 = true;
            byte[]        data = this.CreatePdfData(viewTag);
            string        recordIdentification = this.RecordIdentification;
            int           fieldId = -1;
            ViewReference documentUploadViewReference = this.DetermineDocumentUploadViewReference();

            if (documentUploadViewReference != null)
            {
                recordIdentification = documentUploadViewReference.ContextValueForKey("RecordId");
                if (string.IsNullOrEmpty(recordIdentification))
                {
                    recordIdentification = this.RecordIdentification;
                }

                string parentLinkString = documentUploadViewReference.ContextValueForKey("ParentLink");
                if (!string.IsNullOrEmpty(parentLinkString))
                {
                    UPCRMLinkReader _linkReader = new UPCRMLinkReader(recordIdentification, parentLinkString, null);
                    recordIdentification = _linkReader.RequestLinkRecordOffline();
                }

                fieldId = this.DetermineFieldIdDocumentUploadViewReference(fieldId, documentUploadViewReference);
            }

            this.approveActionDelegate = sender;
            this.reportFileName        = this.CalcReportFileName();
            this.uploadDocumentRequest = new UPOfflineUploadDocumentRequest(data, -1, this.reportFileName, "application/pdf", recordIdentification, fieldId);
            this.uploadDocumentRequest.StartRequest(UPOfflineRequestMode.OnlineConfirm, this);
        }
Пример #3
0
        /// <summary>
        /// Starts this instance.
        /// </summary>
        public override void Start()
        {
            UPSERow row = this.Row;

            if (row.PhotoData != null)
            {
                string recordIdentification = row.SerialEntryRecordIdentification;
                if (!string.IsNullOrEmpty(recordIdentification))
                {
                    string fileName = row.FileNamePattern.StringByReplacingOccurrencesOfParameterWithIndexWithString(0, recordIdentification);
                    fileName = fileName.StringByReplacingOccurrencesOfParameterWithIndexWithString(1, DateTime.UtcNow.ToString("yyyyMMdd"));

                    this.uploadDocumentRequest = new UPOfflineUploadDocumentRequest(row.PhotoData, -1, fileName, "image/jpeg", recordIdentification, -1);
                    this.uploadDocumentRequest.StartRequest(UPOfflineRequestMode.OnlineConfirm, this);
                }
                else
                {
                    this.Finished();
                }
            }
            else
            {
                this.Finished();
            }
        }
        /// <summary>
        /// Uploads the file.
        /// </summary>
        /// <param name="file">The file.</param>
        public void UploadFile(UPMInboxFile file)
        {
            this.uploadingFile = file;
            byte[] data     = null; //NSData.DataWithContentsOfURL(file.URL);
            string fileName = file.Name;

            foreach (UPEditFieldContext changedField in this.editFieldContexts.Values)
            {
                if (changedField.FieldConfig.Function == "Filename" && !string.IsNullOrEmpty(changedField.Value))
                {
                    fileName = changedField.Value;
                    // New filename has no extension. Add original extension
                    //if (fileName.PathExtension().Length == 0)
                    //{
                    //    fileName = $"{fileName}.{file.Path.PathExtension()}";
                    //}

                    break;
                }
            }

            this.docUploadRequest = new UPOfflineUploadDocumentRequest(data, -1, fileName, file.MimeTye, this.recordIdentification, -1);
            List <UPCRMRecord> docUploadRecords = this.docUploadRequest.CreateOfflineRecords();
            string             d1RecordId       = docUploadRecords[0].RecordId;
            string             d3RecordId       = docUploadRecords[1].RecordId;
            UPCRMRecord        d1Record         = new UPCRMRecord(d1RecordId, "Update");
            UPCRMRecord        d3Record         = new UPCRMRecord(d3RecordId, "Update");

            this.editRecordRequest = new UPOfflineEditRecordRequest(UPOfflineRequestMode.OnlineConfirm, this.ViewReference);
            foreach (UPEditFieldContext changedField in this.editFieldContexts.Values)
            {
                UPCRMRecord record = changedField.FieldConfig.InfoAreaId == "D1" ? d1Record : d3Record;
                if (changedField.FieldConfig.Function == "Filename")
                {
                    continue;
                }

                UPCRMFieldValue fieldValue = record.NewValueFieldId(changedField.Value, changedField.FieldId);
                if (!string.IsNullOrEmpty(changedField.DateOriginalValue))
                {
                    fieldValue.DateOriginalValue = changedField.DateOriginalValue;
                }
                else if (!string.IsNullOrEmpty(changedField.TimeOriginalValue))
                {
                    fieldValue.TimeOriginalValue = changedField.TimeOriginalValue;
                }
            }

            this.editRecordRequest.TitleLine   = "FieldUploadFields";
            this.editRecordRequest.DetailsLine = "";
            this.multiRequest = new UPOfflineMultiRequest(this);
            this.multiRequest.AddRequest(this.docUploadRequest);
            this.multiRequest.AddRequest(this.editRecordRequest);
            this.multiRequest.Start();
        }
 /// <summary>
 /// Offlines the request data context did fail with error.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="data">The data.</param>
 /// <param name="context">The context.</param>
 /// <param name="error">The error.</param>
 public void OfflineRequestDidFailWithError(UPOfflineRequest request, object data, object context, Exception error)
 {
     this.uploadDocumentRequest = null;
     this.buttonRequest         = null;
     this.SerialEntryApproved   = UPMSerialEntryState.Unknown;
     this.HandlePageErrorDetails(error.Message, error.StackTrace);
     this.SetShouldWaitForPendingChangesWithoutPageUpdate(false, true);
     this.ForcePageUpdate(new List <IIdentifier> {
         this.Page.Identifier
     });
 }
        /// <summary>
        /// Offlines the request data online context did finish with result.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="data">The data.</param>
        /// <param name="online">if set to <c>true</c> [online].</param>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        public override void OfflineRequestDidFinishWithResult(UPOfflineRequest request, object data, bool online,
                                                               object context, Dictionary <string, object> result)
        {
            if (request != this.uploadDocumentRequest)
            {
                if (!string.IsNullOrEmpty(this.RecordIdentification))
                {
                    List <IIdentifier> changes = new List <IIdentifier> {
                        new RecordIdentifier(this.RecordIdentification)
                    };
                    UPChangeManager.CurrentChangeManager.RegisterChanges(changes);
                }

                List <UPCRMRecord> records = (List <UPCRMRecord>)data;
                this.FillUploadRequestsForRecord(records[0]);
            }

            if (this.uploadDocumentRequests?.Count > 0)
            {
                if (request != this.uploadDocumentRequest)
                {
                    this.uploadDocumentRequest = this.uploadDocumentRequests[0];
                    this.uploadDocumentRequests.Remove(this.uploadDocumentRequest);
                    bool requestAccepted = this.uploadDocumentRequest.StartRequest(UPOfflineRequestMode.OnlineConfirm, this);
                    if (requestAccepted)
                    {
                        return;
                    }
                }
                else
                {
                    this.uploadDocumentRequest = this.uploadDocumentRequests[0];
                    bool requestAccepted = this.uploadDocumentRequest.StartRequest(UPOfflineRequestMode.OnlineConfirm, this);
                    if (requestAccepted)
                    {
                        return;
                    }
                }
            }

            if (this.pendingExecutionViewReference != null)
            {
                ViewReference viewReference = this.pendingExecutionViewReference;
                this.pendingExecutionViewReference = null;
                this.Organizer.Status = null;
                this.ContinueWithAction(viewReference);
                return;
            }

            this.ModelControllerDelegate.PopToPreviousContentViewController();
            this.OfflineRequest = null;
        }
Пример #7
0
 /// <summary>
 /// Offlines the request did fail with error.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="data">The data.</param>
 /// <param name="_context">The context.</param>
 /// <param name="error">The error.</param>
 public override void OfflineRequestDidFailWithError(UPOfflineRequest request, object data, object _context, Exception error)
 {
     this.uploadDocumentRequest = null;
     base.OfflineRequestDidFailWithError(request, data, _context, error);
 }
        /// <summary>
        /// Offlines the request data online context did finish with result.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="data">The data.</param>
        /// <param name="online">if set to <c>true</c> [online].</param>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        public void OfflineRequestDidFinishWithResult(UPOfflineRequest request, object data, bool online, object context, Dictionary <string, object> result)
        {
            if (this.uploadDocumentRequest != null)
            {
                this.uploadDocumentRequest = null;
                if (this.disable85106)
                {
                    this.ApproveAction.PerformAction(this.approveActionDelegate);
                }

                this.pageBuilt = false;
                if (this.ParentOrganizerModelController is DetailOrganizerModelController)
                {
                    ((DetailOrganizerModelController)this.ParentOrganizerModelController).RefreshAfterDocumentUploaded(this.RecordIdentification);
                }

                if (!this.disable85106)
                {
                    this.ShouldWaitForPendingChanges = true;
                }
            }
            else
            {
                this.buttonRequest       = null;
                this.pageBuilt           = false;
                this.SerialEntryApproved = UPMSerialEntryState.Approved;
                if (!this.disable85106)
                {
                    this.ShouldWaitForPendingChanges = false;
                }
                else
                {
                    List <UPCRMRecord> records = (List <UPCRMRecord>)data;
                    if (records.Count > 0)
                    {
                        UPCRMRecord      record           = records[0];
                        RecordIdentifier recordIdentifier = new RecordIdentifier(record.RecordIdentification);
                        UPChangeManager.CurrentChangeManager.RegisterChanges(new List <IIdentifier> {
                            recordIdentifier
                        });
                        if (this.ParentOrganizerModelController is DetailOrganizerModelController)
                        {
                            List <IIdentifier> changes = UPChangeManager.CurrentChangeManager.ChangesToApplyForCurrentViewController();
                            if (this.sendByEmailFilter != null)
                            {
                                this.unreportedRecordChanges = changes;
                            }
                            else
                            {
                                this.ParentOrganizerModelController.ProcessChanges(changes);
                            }
                        }
                    }

                    if (this.sendByEmailFilter != null)
                    {
                        UPContainerMetaInfo _emailFilterQuery = new UPContainerMetaInfo(new List <UPCRMField>(), this.sendByEmailFilter.InfoAreaId);
                        this.emailFilterQuery = _emailFilterQuery;
                        _emailFilterQuery.ApplyFilter(this.sendByEmailFilter);
                        _emailFilterQuery.SetLinkRecordIdentification(this.RecordIdentification);
                        _emailFilterQuery.Find(UPRequestOption.FastestAvailable, this);
                    }
                    else
                    {
                        this.SetShouldWaitForPendingChangesWithoutPageUpdate(false, true);
                    }
                }
            }
        }
        private void ContinueUploadReportPdf()
        {
            string        recordIdentification = this.RecordIdentification;
            int           fieldId = -1;
            ViewReference documentUploadViewReference = this.DetermineDocumentUploadViewReference();

            if (documentUploadViewReference != null)
            {
                if (this.parentLinkReader != null)
                {
                    recordIdentification  = this.parentLinkRecordIdentification;
                    this.parentLinkReader = null;
                }
                else
                {
                    recordIdentification = documentUploadViewReference.ContextValueForKey("RecordId");
                    if (string.IsNullOrEmpty(recordIdentification))
                    {
                        recordIdentification = this.RecordIdentification;
                    }

                    string parentLinkString = documentUploadViewReference.ContextValueForKey("ParentLink");
                    if (!string.IsNullOrEmpty(parentLinkString))
                    {
                        this.parentLinkReader = new UPCRMLinkReader(recordIdentification, parentLinkString, this);
                        if (this.parentLinkReader.Start())
                        {
                            return;
                        }

                        recordIdentification = this.parentLinkReader.RequestLinkRecordOffline();
                    }
                }

                fieldId = this.DetermineFieldIdDocumentUploadViewReference(fieldId, documentUploadViewReference);
            }

            this.reportFileName        = this.CalcReportFileName();
            this.uploadDocumentRequest = new UPOfflineUploadDocumentRequest(this.pdfData, -1, this.reportFileName, "application/pdf", recordIdentification, fieldId);
            this.multiRequest          = new UPOfflineMultiRequest(this);
            this.multiRequest.AddRequest(this.uploadDocumentRequest);
            recordIdentification = this.buttonViewReference.ContextValueForKey("RecordId");
            string         filterName = this.buttonViewReference.ContextValueForKey("TemplateFilter");
            UPConfigFilter filter     = ConfigurationUnitStore.DefaultStore.FilterByName(filterName);

            filter = filter.FilterByApplyingValueDictionaryDefaults(this.FieldValueDictionary, true);
            if (!string.IsNullOrEmpty(recordIdentification) && filter != null)
            {
                UPCRMRecord        record          = new UPCRMRecord(recordIdentification);
                List <UPCRMRecord> combinedRecords = new List <UPCRMRecord> {
                    record
                };
                List <UPCRMRecord> childRecords = record.ApplyValuesFromTemplateFilter(filter, false);
                foreach (UPCRMRecord childRecord in childRecords)
                {
                    if (childRecord.Mode == "ParentUpdate")
                    {
                        if (this.templateFilterLinkRecords == null)
                        {
                            this.templateFilterLinkRecords = new List <UPCRMRecord> {
                                childRecord
                            };
                        }
                        else
                        {
                            this.templateFilterLinkRecords.Add(childRecord);
                        }
                    }
                    else
                    {
                        combinedRecords.Add(childRecord);
                    }
                }

                if (this.templateFilterLinkRecords.Count > 0)
                {
                    this.recordsToSave = combinedRecords;
                    this.ContinueWithLinkRecords(this.templateFilterLinkRecords);
                    return;
                }

                this.PerformUploadReportPdfWithRecords(combinedRecords);
            }
            else
            {
                this.PerformUploadReportPdfWithRecords(null);
            }
        }