コード例 #1
0
        /// <summary>
        /// Print the document
        /// </summary>
        /// <param name="jobId"></param>
        /// <param name="request"></param>
        /// <param name="document"></param>
        /// <param name="separatorSheet"></param>
        /// <param name="errorCode"></param>
        /// <returns></returns>
        private bool PrintDocumentSet(string jobId, BulkPrintServiceRequestBEO request, DocumentResult document,
                                      string separatorSheet, out string errorCode)
        {
            var toReturn   = false;
            var title      = string.Empty;
            var fieldValue = string.Empty;
            var binaryType = NativeSetBinaryType;
            var sb         = new StringBuilder(string.Empty);

            //Get the binary types for the images
            switch (request.BulkPrintOptions.ImageType.ImageType)
            {
            case DocumentImageTypeBEO.Native:
                binaryType = NativeSetBinaryType;
                break;

            case DocumentImageTypeBEO.ImageSet:
                binaryType = ImageSetBinaryType;
                break;

            case DocumentImageTypeBEO.ProductionSet:
                binaryType = ProductionSetBinaryType;
                break;
            }
            //Get the document binary
            var documentData = DocumentBO.GetDocumentBinaryData(long.Parse(request.DataSet.MatterId),
                                                                request.BulkPrintOptions.ImageType.
                                                                ImageIdentifier.CollectionId,
                                                                document.DocumentID, binaryType,
                                                                string.Empty);

            #region Assertion

            documentData.ShouldNotBe(null);
            documentData.DocumentBinary.ShouldNotBe(null);

            #endregion

            var isFileExists = documentData.DocumentBinary.FileList.Count > 0;
            errorCode = string.Empty;
            foreach (var fileInfo in documentData.DocumentBinary.FileList)
            {
                if (!File.Exists(fileInfo.Path))
                {
                    isFileExists = false;
                    break;
                }
            }
            m_UserDetails = UserBO.GetUserUsingGuid(request.RequestedBy.UserId);
            userContext   = CreateUserContext(request.RequestedBy.UserId);
            EVHttpContext.CurrentContext = userContext;
            //Construct Query string
            if (!isFileExists)
            {
                errorCode = "Bulk print Invalid file";
                toReturn  = true;
            }
            else
            {
                fieldValue = document.DocumentControlNumber;
                if (document.Fields != null && document.Fields.Any())
                {
                    fieldValue = document.DocumentControlNumber;
                    title      = Constants.TitleNotAvailable;
                    foreach (var field in document.Fields)
                    {
                        if (field == null)
                        {
                            continue;
                        }
                        if (field.DataTypeId == Constants.TitleFieldType)
                        {
                            title = !string.IsNullOrEmpty(field.Value) ? fieldValue.Trim() : title;
                        }
                        if (String.IsNullOrEmpty(field.Name))
                        {
                            continue;
                        }
                        if (field.Name.Equals(_mBootParameters.FieldName))
                        {
                            fieldValue = !string.IsNullOrEmpty(field.Value) ? field.Value.Trim() : fieldValue;
                        }
                    }
                }
                var specialChars = new List <string> {
                    "<", ">", ":", "\"", "\\", "|", "?", "*", "."
                };
                if (specialChars.Exists(x => fieldValue.Contains(x)))
                {
                    // Log documents with special characters or empty values...
                    toReturn  = false;
                    errorCode = "Special characters in the field value and hence cannot be printed";
                }
                else
                {
                    ConstructQueryString(jobId, document, title, separatorSheet, sb, documentData, fieldValue);
                    try
                    {
                        toReturn = CreatePostWebRequestForCreatingPdf(jobId, sb.ToString());
                    }
                    catch (WebException webException)
                    {
                        webException.Trace().Swallow();
                    }
                    catch (Exception ex)
                    {
                        ex.Trace().Swallow();
                        errorCode = "Error in Conversion and hence cannot be printed";
                    }
                }
            }
            return(toReturn);
        }