public override void ExecuteExtention(TextSearchRequest request, TextSearchResponse response,
                                              LogController controller)
        {
            controller.UpdateProgress(0, 1, "Loading Text Search");
            var document     = DocumentWriter.NewDocument();
            var firstSection = document.AddSection();
            var nextSection  = document.AddSection();
            var container    = new TextSearchContainer(request, response, controller, nextSection);

            ProcessRecordsContainedInName(container);
            ProcessRecordsReferencingTheWord(container);
            ProcessEntireRecordExtracts(container);
            //insert title/summary
            firstSection.AddTitle("Text Search");
            var table = firstSection.Add2ColumnTable();

            table.AddFieldToTable("Execution Time", DateTime.Now.ToString(StringFormats.DateTimeFormat));
            table.AddFieldToTable("Search Text", request.SearchText);
            firstSection.AddTableOfContents(container.Bookmarks);

            //save document
            container.Controller.TurnOffLevel2();
            container.Controller.UpdateProgress(1, 2, "Creating Document");
            var folder   = container.Request.SaveToFolder;
            var fileName = string.Format("Record Extract - {0} - {1}", "TextSearch",
                                         DateTime.Now.ToString("yyyyMMddHHmmss"));

            fileName = document.Save(folder, fileName, container.Request.DocumentFormat);
            container.Response.Folder   = container.Request.SaveToFolder.FolderPath;
            container.Response.FileName = fileName;
        }
        public override void ExecuteExtention(TextSearchRequest request, TextSearchResponse response,
                                              ServiceRequestController controller)
        {
            controller.UpdateProgress(0, 1, "Loading Text Search");
            var document     = DocumentWriter.NewDocument();
            var firstSection = document.AddSection();
            var nextSection  = document.AddSection();

            var container = new TextSearchContainer(request, response, controller.Controller, nextSection);

            ProcessRecordsReferencingTheWord(container);

            //insert title/summary
            firstSection.AddTitle("Text Search");
            var table = firstSection.Add2ColumnTable();

            table.AddFieldToTable("Execution Time", DateTime.Now.ToString(StringFormats.DateTimeFormat));
            table.AddFieldToTable("Search Operator", request.Operator.ToString());
            table.AddFieldToTable("Search Terms", string.Join(", ", request.SearchTerms.Select(s => "\"" + s.Text + "\"")));
            firstSection.AddTableOfContents(container.Bookmarks);

            //save document
            container.Controller.TurnOffLevel2();
            container.Controller.UpdateProgress(1, 2, "Creating Document");
            var folder   = container.Request.SaveToFolder;
            var fileName = string.Format("Record Extract - {0} - {1}", "TextSearch",
                                         DateTime.Now.ToString("yyyyMMddHHmmss"));

            if (container.Request.GenerateDocument)
            {
                fileName = document.Save(folder, fileName, container.Request.DocumentFormat);
                container.Response.Folder   = container.Request.SaveToFolder.FolderPath;
                container.Response.FileName = fileName;
            }
            container.Response.GenerateSummaryItems(Service);
            if (!container.Response.Summary.Any())
            {
                container.Response.Message = "No Matches Were Found For The Search Criteria";
            }
        }
示例#3
0
        public override void ExecuteExtention(RecordExtractRequest request, RecordExtractResponse response,
                                              ServiceRequestController controller)
        {
            var document                 = DocumentWriter.NewDocument();
            var firstSection             = document.AddSection();
            var nextSection              = document.AddSection();
            var extractToDocumentRequest = new RecordExtractToDocumentRequest(request.RecordLookup, nextSection,
                                                                              controller.Controller, request.DetailOfRelatedRecords
                                                                              , request.RecordTypesOnlyDisplayName.Where(r => r.RecordType != null).Select(r => r.RecordType.Key).ToArray()
                                                                              , request.FieldsToExclude, request.RecordTypesToExclude.Where(r => r.RecordType != null).Select(r => r.RecordType.Key).ToArray()
                                                                              , request.IncludeCreatedByAndOn, request.IncludeModifiedByAndOn, request.IncludeCrmOwner, request.IncludeState, request.IncludeStatus, request.StripHtmlTags, request.CustomHtmlFields);
            var extractResponse = ExtractRecordToDocument(extractToDocumentRequest);

            response.AddResponseItems(extractResponse.ResponseItems);
            //insert title/summary
            firstSection.AddTitle("Record Extract");
            var table = firstSection.Add2ColumnTable();

            table.AddFieldToTable("Execution Time", DateTime.Now.ToString(StringFormats.DateTimeFormat));
            table.AddFieldToTable("Record Type", Service.GetDisplayName(request.RecordLookup.RecordType));
            table.AddFieldToTable("Record Name",
                                  extractResponse.Record.GetStringField(Service.GetPrimaryField(request.RecordLookup.RecordType)));
            firstSection.AddTableOfContents(extractResponse.Bookmarks);
            //save document
            controller.UpdateProgress(1, 2, "Creating Document");
            var folder = request.SaveToFolder;
            var recordToExtractname =
                extractResponse.Record.GetStringField(Service.GetPrimaryField(request.RecordLookup.RecordType));
            var fileName = string.Format("Record Extract - {0} - {1}", recordToExtractname,
                                         DateTime.Now.ToString("yyyyMMddHHmmss"));

            fileName = document.Save(folder, fileName, request.DocumentFormat);

            response.Folder   = request.SaveToFolder.FolderPath;
            response.FileName = fileName;
            response.Message  = "The Document Has Been Generated";
        }