Пример #1
0
        public override void ExecuteExtention(CustomisationExporterRequest request,
                                              CustomisationExporterResponse response,
                                              ServiceRequestController controller)
        {
            response.Folder = request.SaveToFolder.FolderPath;
            controller.LogLiteral("Loading Metadata");

            ProcessForEntities(request, response, controller.Controller);

            if ((request.Fields || request.FieldOptionSets) && request.IncludeAllRecordTypes)
            {
                controller.UpdateProgress(0, 1, "Loading All Fields.....");
                Service.LoadFieldsForAllEntities();
            }
            if ((request.Fields || request.Relationships) && request.IncludeAllRecordTypes)
            {
                controller.UpdateProgress(0, 1, "Loading All Relationships.....");
                Service.LoadRelationshipsForAllEntities();
            }
            ProcessForFields(request, response, controller.Controller);

            ProcessForRelationships(request, response, controller.Controller);
            ProcessForOptionSets(request, response, controller.Controller);

            response.Folder = request.SaveToFolder.FolderPath;

            if (request.Format == CustomisationExporterRequest.FileFormat.Xlsx)
            {
                var excelFileName = "Customisation Export " + DateTime.Now.ToFileTime() + ".xlsx";
                ExcelUtility.CreateXlsx(request.SaveToFolder.FolderPath, excelFileName, response.GetListsToOutput());
                response.ExcelFileName = excelFileName;
            }
            else
            {
                foreach (var item in response.GetListsToOutput())
                {
                    var csvName = item.Key + " " + DateTime.Now.ToFileTime() + ".csv";
                    CsvUtility.CreateCsv(request.SaveToFolder.FolderPath, csvName, item.Value);
                }
            }

            response.Message = "The Export is Complete";
        }