/// <summary>
        /// Uploads the document request did finish with json.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="json">The json.</param>
        public void UploadDocumentRequestDidFinishWithJSON(UploadDocumentServerOperation request, Dictionary <string, object> json)
        {
            List <object> jsonArray = json.Values.ToList();
            string        d1        = jsonArray[0] as string;
            List <object> syncInfos = jsonArray[2] as List <object>;

            UPCRMRecordSync.SyncRecordSetDefinitions(syncInfos);
            ResourceManager resourceManager = SmartbookResourceManager.DefaultResourceManager;
            Uri             url             = ServerSession.CurrentSession.DocumentRequestUrlForRecordIdentification(d1, request.FileName);
            string          localUrl        = resourceManager.LocalPathForResourceAtUrl(url, resourceManager.LocalPathForTransientResources, request.FileName);

            SimpleIoc.Default.GetInstance <IPlatformService>().StorageProvider.SaveFile(localUrl, request.Data);
            this.ReportSuccessfulSync();
            this.OfflineRequestDelegate?.OfflineRequestDidFinishWithResult(this, d1, true, null, json);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes the json response.
        /// </summary>
        /// <param name="json">The json.</param>
        /// <param name="remoteData">The remote data.</param>
        public override void ProcessJsonResponse(Dictionary <string, object> json, RemoteData remoteData)
        {
            object statusInfo = json.ValueOrDefault("StatusInfo");

            if (statusInfo != null)
            {
                this.ProcessErrorWithRemoteData(this.ErrorFromStatusInfo(statusInfo), remoteData);
                return;
            }

            List <string> changedRecords = null;
            List <string> messages       = json.ValueOrDefault("Messages") as List <string>;

            List <Dictionary <string, object> > changedRecordsFromServer = json.ValueOrDefault("ChangedRecords") as List <Dictionary <string, object> >;

            if (changedRecordsFromServer?.Count > 0)
            {
                changedRecords = new List <string>(changedRecordsFromServer.Count);
                foreach (Dictionary <string, object> record in changedRecordsFromServer)
                {
                    string recordIdentification;
                    object recordPart = record["RecordId"];
                    if (recordPart is long)
                    {
                        recordIdentification = StringExtensions.InfoAreaIdNumberRecordId((string)record["InfoAreaId"], (long)recordPart);
                    }
                    else
                    {
                        recordIdentification = StringExtensions.InfoAreaIdRecordId((string)record["InfoAreaId"], recordPart.ToString());
                    }

                    changedRecords.Add(recordIdentification);
                }
            }

            List <object> changedRecordData = json.ValueOrDefault("ChangedRecordsData") as List <object>;

            UPCRMRecordSync.SyncRecordSetDefinitions(changedRecordData);
            UPExecuteWorkflowResult executeWorkflowResult = new UPExecuteWorkflowResult(changedRecords, messages);

            this.TheDelegate.ExecuteWorkflowRequestDidFinishWithResult(this, executeWorkflowResult);
        }