protected override void LoadDialogExtention()
        {
            //okay lets load the spreadsheet
            //and if there are any error display them
            //else continue
            var dictionary = ImportExcelService.LoadMappingDictionary(Request);

            var importService = new SpreadsheetImportService(XrmRecordService);
            var parseResponse = importService.ParseIntoEntities(dictionary);

            if (parseResponse.ResponseItems.Any())
            {
                AddObjectToUi(parseResponse
                              , cancelAction: Controller.Close
                              , nextAction: () =>
                {
                    RemoveObjectFromUi(parseResponse);
                    StartNextAction();
                }
                              , nextActionLabel: "Import"
                              , backAction: () =>
                {
                    RemoveObjectFromUi(parseResponse);
                    MoveBackToPrevious();
                });
            }
            else
            {
                StartNextAction();
            }
        }
Exemplo n.º 2
0
        public override void ExecuteExtention(ImportExcelRequest request, ImportExcelResponse response,
                                              ServiceRequestController controller)
        {
            var dictionary    = LoadMappingDictionary(request);
            var importService = new SpreadsheetImportService(XrmRecordService);
            var responseItems = importService.DoImport(dictionary, request.MaskEmails, request.MatchRecordsByName, request.UpdateOnly, controller);

            response.LoadSpreadsheetImport(responseItems);
        }
Exemplo n.º 3
0
        public override void ExecuteExtention(ImportCsvsRequest request, ImportCsvsResponse response, ServiceRequestController controller)
        {
            var dictionary = LoadMappingDictionary(request);

            var importService = new SpreadsheetImportService(XrmRecordService);
            var responseItem  = importService.DoImport(dictionary, request.MaskEmails, request.MatchByName, request.UpdateOnly, controller, useAmericanDates: request.DateFormat == DateFormat.American);

            response.LoadSpreadsheetImport(responseItem);
        }
Exemplo n.º 4
0
        public override void ExecuteExtention(ImportCsvsRequest request, ImportCsvsResponse response, ServiceRequestController controller)
        {
            controller.Controller.UpdateProgress(0, 1, "Loading Records For Import");
            var dictionary = LoadMappingDictionary(request);

            var importService = new SpreadsheetImportService(XrmRecordService);
            var responseItem  = importService.DoImport(dictionary, request.MaskEmails, request.MatchByName, request.UpdateOnly, controller, useAmericanDates: request.DateFormat == DateFormat.American);

            response.Connection = XrmRecordService.XrmRecordConfiguration;
            response.LoadSpreadsheetImport(responseItem);
            response.Message = "The Import Process Has Completed";
        }
        public override void ExecuteExtention(ImportExcelRequest request, ImportExcelResponse response,
                                              ServiceRequestController controller)
        {
            controller.Controller.UpdateProgress(0, 1, "Loading Records For Import");
            var dictionary    = LoadMappingDictionary(request, controller.Controller);
            var importService = new SpreadsheetImportService(XrmRecordService);
            var responseItems = importService.DoImport(dictionary, request.MaskEmails, request.MatchRecordsByName, request.UpdateOnly, controller, executeMultipleSetSize: request.ExecuteMultipleSetSize, targetCacheLimit: request.TargetCacheLimit);

            response.Connection = XrmRecordService.XrmRecordConfiguration;
            response.LoadSpreadsheetImport(responseItems);
            response.Message = "The Import Process Has Completed";
        }
Exemplo n.º 6
0
        public override void ExecuteExtention(ImportSqlRequest request, ImportSqlResponse response,
                                              ServiceRequestController controller)
        {
            Exception tempEx = null;;

            try
            {
                controller.Controller.UpdateProgress(0, 1, "Loading Records For Import");
                var dictionary    = LoadMappingDictionary(request);
                var importService = new SpreadsheetImportService(XrmRecordService);
                var responseItems = importService.DoImport(dictionary, request.MaskEmails, request.MatchRecordsByName, request.UpdateOnly, controller);
                response.LoadSpreadsheetImport(responseItems);
            }
            catch (Exception ex)
            {
                tempEx = ex;
                throw;
            }
            finally
            {
                if (request.SendNotificationAtCompletion &&
                    (!request.OnlySendNotificationIfError ||
                     tempEx != null || response.HasResponseItemError))
                {
                    try
                    {
                        //todo place the html generator somewhere appropriate
                        var htmlGenerator = new HtmlEmailGenerator();
                        //okay lets try create an email with the summary
                        //plus perhaps a log of the errors

                        if (tempEx != null)
                        {
                            htmlGenerator.AppendParagraph(tempEx.XrmDisplayString());
                        }

                        htmlGenerator.WriteObject(response);

                        var subject = $"Sql Import '{request.Name ?? "No Name"}'";
                        if (tempEx != null)
                        {
                            subject = subject + " Fatal Error";
                        }
                        else if (response.HasResponseItemError)
                        {
                            subject = subject + " Completed With Errors";
                        }
                        else
                        {
                            subject = subject + " Completed";
                        }



                        XrmRecordService.SendEmail(request.SendNotificationFromQueue, request.SendNotificationToQueue
                                                   , subject.Left(XrmRecordService.GetMaxLength(Fields.email_.subject, Entities.email))
                                                   , htmlGenerator.GetContent());
                    }
                    catch (Exception ex)
                    {
                        response.AddResponseItem(new ImportSqlResponseItem(new DataImportResponseItem("Error Sending Notification Email", ex)));
                    }
                }
            }
        }