Beispiel #1
0
        public bool CheckKMPresentationService(string docId, ref int size, ref string errorMsg)
        {
            size = -1;
            WSDocument wsDocument = null;

            try
            {
                HP.Csn.Business.KM.Services.PresentationService.WSUserInfo wsUserInfo = new HP.Csn.Business.KM.Services.PresentationService.WSUserInfo();
                wsUserInfo.userId   = base.userId;
                wsUserInfo.portalId = base.portalId;

                WSCPRequest wsCPRequest = new WSCPRequest();
                wsCPRequest.docId  = docId;
                wsCPRequest.locale = DEFAULT_LANGUAGECODE;

                PresentationService presentationService = new PresentationService();
                presentationService.SetConnectionInfo(base.presentationUrl, base.userId, base.userPassword, base.timeOut);

                wsDocument = presentationService.retrieveDocument(wsUserInfo, wsCPRequest);
            }
            catch (SoapException ex)
            {
                errorMsg = "Error While Retrieving Document. ERROR : (" + ex.Message + ")";
                return(false);
            }
            catch (WebException ex)
            {
                errorMsg = "Error Connecting To Webservices. ERROR : (" + ex.Message + ")";
                return(false);
            }
            catch (Exception ex)
            {
                errorMsg = "Unexpected Error While Accessing Webservices. ERROR : (" + ex.Message + ")";
                return(false);
            }


            if (wsDocument == null)
            {
                errorMsg = "Unable To Retrieve Document " + docId;
            }

            if (wsDocument.payload.Length == 0)
            {
                size     = 0;
                errorMsg = "Error While Retrieving Document. Payload Is Empty";
            }
            else
            {
                size = wsDocument.payload.Length;
            }

            return(true);
        }
Beispiel #2
0
        public byte[] RetrieveDocument(string DocumentID, ref string mimeType, string Language)
        {
            if (DocumentID == null || DocumentID == "")
            {
                throw new DocumentSearchException(21, DocumentSearchException.ERROR_TYPE.INFORMATION, "Please Specify The Document Id To Search.");
            }

            try
            {
                HP.Csn.Business.KM.Services.PresentationService.WSUserInfo wsUserInfo = new HP.Csn.Business.KM.Services.PresentationService.WSUserInfo();
                wsUserInfo.userId   = base.userId;
                wsUserInfo.portalId = base.portalId;

                // Disclosure levels supported by CSN
                // Get from database in future
                int[] disclosureLevel = new int[4] {
                    1, 3, 5, 7
                };
                wsUserInfo.disclosureLevels = disclosureLevel;

                // Temp fix : Send disclosure levels to entitlements as expected by CSR
                string[] tempDisclosureLevels = new string[4] {
                    "1", "3", "5", "7"
                };
                wsUserInfo.entitlements = tempDisclosureLevels;

                WSCPRequest wsCPRequest = new WSCPRequest();
                wsCPRequest.docId = DocumentID;
                // Release 8.7 Enhancement
                if (Language != null && Language != "")
                {
                    wsCPRequest.locale = Language;
                }
                else
                {
                    wsCPRequest.locale = DEFAULT_LANGUAGE;
                }

                WSDocument wsDocument = null;

                PresentationService presentationService = new PresentationService();
                presentationService.SetConnectionInfo(base.presentationUrl, base.userId, base.userPassword, base.timeOut);

                wsDocument = presentationService.retrieveDocument(wsUserInfo, wsCPRequest);

                //Sachin Added for 13.11 Release-Start
                string      strMetaData       = wsDocument.metaData;
                string      strDocumentStatus = string.Empty;
                XmlDocument objXmlMetaData    = new XmlDocument();
                XmlNode     objXmlNode;
                XmlNodeList objXmlNodeList;
                objXmlMetaData.LoadXml(strMetaData);
                objXmlNodeList = objXmlMetaData.GetElementsByTagName("document_status");

                if (objXmlNodeList.Count > 0)
                {
                    objXmlNode        = objXmlNodeList.Item(0);
                    strDocumentStatus = objXmlNode.InnerText;
                }
                OracleUtil objOraUtil       = new OracleUtil();
                string[]   WorkFlowStatuses = objOraUtil.workflowstate();
                if (WorkFlowStatuses != null)
                {
                    bool bFindStatus = false;
                    for (int i = 0; i <= WorkFlowStatuses.Length - 1; i++)
                    {
                        if (strDocumentStatus == WorkFlowStatuses[i].ToString())
                        {
                            bFindStatus = true;
                        }
                    }
                    if (bFindStatus == false)
                    {
                        throw new DocumentSearchException(23, DocumentSearchException.ERROR_TYPE.INFORMATION, "No records found for this document number." + DocumentID);
                    }
                }
                //Sachin Added for 13.11 Release-End


                if (wsDocument == null)
                {
                    throw new DocumentSearchException(23, DocumentSearchException.ERROR_TYPE.INFORMATION, "Unable To Retrieve Document " + DocumentID);
                }

                if (wsDocument.payload.Length == 0)
                {
                    throw new DocumentSearchException(24, DocumentSearchException.ERROR_TYPE.INFORMATION, "Error While Retrieving Document. Payload Is Empty");
                }

                mimeType = wsDocument.mimetype;

                return(wsDocument.payload);
            }
            catch (SoapException ex)
            {
                throw new DocumentSearchException(25, DocumentSearchException.ERROR_TYPE.INFORMATION, "Error While Retrieving Document. ERROR :" + ex.Message, ex);
            }
            catch (WebException ex)
            {
                throw new DocumentSearchException(26, DocumentSearchException.ERROR_TYPE.WARNING, "Error Connecting To Web Service. ERROR :" + ex.Message, ex);
            }
            catch (DocumentSearchException ex)
            {
                //Catching and throwing document search exception when payload size is 0
                throw ex;
            }
            catch (Exception ex)
            {
                throw new DocumentSearchException(27, DocumentSearchException.ERROR_TYPE.WARNING, "Unexpected Error While Accessing Web Service. ERROR :" + ex.Message, ex);
            }
        }