/// <summary>
        /// Synchronizes the records.
        /// </summary>
        private void SyncRecords()
        {
            if (!RecordList.Any(c1 => c1.IsCheckBoxChecked))
            {
                NotificationHelper.ShowMessage("Please select records to sync", Utilities.GetResourceValue("CaptionWarning"));
                return;
            }

            StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");

            ThreadHelper.RunBackGround(delegate
            {
                int?entityId = RecordList.FirstOrDefault(c1 => c1.IsCheckBoxChecked)?.EntityId;
                if (!entityId.HasValue)
                {
                    NotificationHelper.ShowMessage("Entity not found", Utilities.GetResourceValue("CaptionWarning"));
                    return;
                }

                IList <long> processRecords = RecordList.Where(c1 => c1.IsCheckBoxChecked & (c1.StatusId == (int)MessageStatus.Error))
                                              .Select(c1 => c1.CloudMessageId).ToList();

                if (processRecords.Any())
                {
                    Connector.Base.Services.Inbound.MessageReceiveService.ReceiveRecords(processRecords, entityId.Value);
                }

                IList <DataModel> sendRecords = RecordList.Where(c1 => c1.IsCheckBoxChecked & (c1.StatusId == (int)MessageStatus.RequestProcessed))
                                                .Select(c1 => new DataModel
                {
                    CloudMessageId = c1.CloudMessageId,
                    SourceId       = c1.EcommerceId,
                    TargetId       = c1.ErpId,
                    Reference      = c1.Reference,
                    Result         = true,
                }).ToList();
                if (sendRecords.Any())
                {
                    Connector.Base.Services.Inbound.MessageReceiveService.SendResponses(sendRecords, entityId.Value);
                }
                Application.Current.Dispatcher.Invoke(LoadReport);
                StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
            });
        }
Ejemplo n.º 2
0
        private void SyncRecords()
        {
            if (!RecordList.Any(c1 => c1.IsCheckBoxChecked))
            {
                NotificationHelper.ShowMessage("Please select records to sync", Utilities.GetResourceValue("CaptionWarning"));
                return;
            }

            StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");

            ThreadHelper.RunBackGround(delegate
            {
                int?entityId = RecordList.FirstOrDefault(c1 => c1.IsCheckBoxChecked)?.EntityId;
                if (!entityId.HasValue)
                {
                    NotificationHelper.ShowMessage("Entity not found", Utilities.GetResourceValue("CaptionWarning"));
                    return;
                }

                IList <long> processRecords = RecordList.Where(c1 => c1.IsCheckBoxChecked & (c1.StatusId == (int)MessageStatus.Error || c1.StatusId == (int)MessageStatus.TransferPending))
                                              .Select(c1 => c1.MessageId).ToList();

                if (processRecords.Any())
                {
                    Connector.Base.Services.Outbound.MessageSendService.SyncRecords(processRecords, entityId.Value);
                }

                IList <MessageModel> getResponse = RecordList.Where(c1 => c1.IsCheckBoxChecked & (c1.StatusId == (int)MessageStatus.RequestTransferred))
                                                   .Select(c1 => new MessageModel
                {
                    CloudMessageId = c1.CloudMessageId,
                    LocalMessageId = c1.MessageId,
                    SyncCounter    = c1.SyncCounter + 1,
                    MessageStatus  = (MessageStatus)c1.StatusId
                }).ToList();
                if (getResponse.Any())
                {
                    Connector.Base.Services.Outbound.ResponseReceiveService.PullResponse(getResponse, entityId.Value);
                }
                Application.Current.Dispatcher.Invoke(LoadReport);
                StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
            });
        }