Example #1
0
        //-------------------------------------------
        //Method : GetDocument
        //-------------------------------------------
        /// <summary>
        /// GetDocument
        /// </summary>
        internal void GetDocument()
        {
            DocumentDetails     = null;
            IsSuccessful        = false;
            DocumentServiceType = DocumentServiceType.NONE;


            //check for Input
            if (!ValidateInput())
            {
                IsSuccessful = false;
                return;
            }


            try
            {
                if (DocumentServiceType == DocumentServiceType.NONE)
                {
                    ErrorMessage = "Invalid Document Service Type";
                }
                else
                {
                    //process document request
                    ProcessDocument.Start(DocumentServiceType, this);
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Example #2
0
        //-----------------------------------------------------------------------------------------------
        //Method : Start
        //-----------------------------------------------------------------------------------------------
        /// <summary>
        /// Start
        /// </summary>
        /// <param name="p_documentServiceType"></param>
        /// <param name="p_document"></param>
        internal static void Start(DocumentServiceType p_documentServiceType,
                                   Document p_document)
        {
            DocumentService documentService = null;

            try
            {
                if (p_documentServiceType == DocumentServiceType.REST_SERVICE_1P)
                {
                    DocumentumApiService documentApiService = CreateDocumentumApiService(p_document.ObjectId);
                    p_document.IsSuccessful = documentApiService.GetDocumentDetails();
                    documentService         = documentApiService;
                    documentApiService      = null;
                }
                else if (p_documentServiceType == DocumentServiceType.WCF_SERVICE_6P)
                {
                    DocumentumService documentumService = CreateDocumentumService(p_document.Region,
                                                                                  p_document.BusinessSegment,
                                                                                  p_document.BusinessUnit,
                                                                                  p_document.Client,
                                                                                  p_document.DocType,
                                                                                  p_document.RefNo);

                    p_document.IsSuccessful = documentumService.GetDocumentDetails();
                    documentService         = documentumService;
                    documentumService       = null;
                }

                if (p_document.IsSuccessful)
                {
                    p_document.DocumentDetails = new Models.DocumentDetails();
                    p_document.DocumentDetails.DocumentName     = documentService.DocumentName;
                    p_document.DocumentDetails.DocumentByteData = documentService.DocumentByteData;
                    p_document.DocumentDetails.DocumentType     = documentService.DocumentType;
                }
                else
                {
                    p_document.ErrorMessage = documentService.ErrorMessage;
                }
            }
            catch (Exception ex)
            {
                p_document.ErrorMessage = ex.Message;
            }
            finally
            {
                documentService = null;
            }
        }
Example #3
0
        //-----------------------------------------------------------------
        // METHOD : ValidateInput
        //-----------------------------------------------------------------
        /// <summary>
        /// ValidateInput
        /// </summary>
        /// <returns></returns>
        private bool ValidateInput()
        {
            bool isValid = true;

            StringBuilder sbError = new StringBuilder();

            if (!string.IsNullOrEmpty(ObjectId))
            {
                DocumentServiceType = DocumentServiceType.REST_SERVICE_1P;
                return(isValid);
            }// if (!string.IsNullOrEmpty(ObjectId))
            else
            {
                if (string.IsNullOrEmpty(Region))
                {
                    isValid = false;
                    //sbError.AppendLine("Region parameter is required");
                }
                if (string.IsNullOrEmpty(BusinessSegment))
                {
                    isValid = false;
                    //sbError.AppendLine("BusinessSegment parameter is required");
                }
                if (string.IsNullOrEmpty(BusinessUnit))
                {
                    isValid = false;
                    //sbError.AppendLine("BusinessUnit parameter is required");
                }
                if (string.IsNullOrEmpty(Client))
                {
                    isValid = false;
                    //sbError.AppendLine("Client parameter is required");
                }
                if (string.IsNullOrEmpty(DocType))
                {
                    isValid = false;
                    //sbError.AppendLine("DocType parameter is required");
                }
                if (string.IsNullOrEmpty(RefNo))
                {
                    isValid = false;
                    //sbError.AppendLine("RefNo parameter is required");
                }


                if (!isValid)
                {
                    sbError.AppendLine("Either Region,BusinessSegment,BusinessUnit,Client,DocType,RefNo parameters are required");
                    sbError.AppendLine("or ObjectId parameter is required");
                }
                else
                {
                    DocumentServiceType = DocumentServiceType.WCF_SERVICE_6P;
                }
            }//else  if (!string.IsNullOrEmpty(ObjectId))

            if (!isValid)
            {
                ErrorMessage = sbError.ToString();
                Logger.Error(ErrorMessage);
            }


            return(isValid);
        }