Exemplo n.º 1
0
        private DataTable BuildCVTaxonomy(string partnerRole)
        {
            TaxonomyService taxonomyService = new TaxonomyService();

            taxonomyService.SetConnectionInfo(base.taxonomyUrl, base.userId, base.userPassword, base.timeOut);

            WSUserInfo wsUserInfo = new WSUserInfo();

            wsUserInfo.userId   = base.userId;
            wsUserInfo.portalId = base.portalId;

            OracleUtil objOraUtil = new OracleUtil();

            wsUserInfo.disclosureLevels = objOraUtil.GetDisclosurelevel(partnerRole);

            WSCVRequest cvRequest = new WSCVRequest();

            cvRequest.taxoId = base.component_root_oid;           //COMPONENT_ROOT_OID;
            cvRequest.locale = DEFAULT_LANGUAGECODE;              // Release 8.7 Enhancement
            WSCVNode[] nodes = null;
            try
            {
                nodes = taxonomyService.retrieveCV(wsUserInfo, cvRequest);
            }
            catch (SoapException ex)
            {
                throw new TaxonomyException(3, TaxonomyException.ERROR_TYPE.INFORMATION, "Error While Retrieving Taxonomy", ex.Message, ex);
            }
            catch (System.Net.WebException ex)
            {
                throw new TaxonomyException(2, TaxonomyException.ERROR_TYPE.WARNING, "Error Connecting To Webservices", ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new TaxonomyException(1, TaxonomyException.ERROR_TYPE.WARNING, "Unexpected Error While Retrieving Taxonomy", ex.Message, ex);
            }

            if (nodes == null || nodes.Length == 0)
            {
                throw new TaxonomyException(4, TaxonomyException.ERROR_TYPE.INFORMATION, "Taxonomy Not Available For Given OID", "OID Node Is Empty");
            }

            DataTable retTaxonomy = CreateTaxonomyTable();

            for (int iCnt = 0; iCnt < nodes.Length; iCnt++)
            {
                DataRow row = retTaxonomy.NewRow();
                row["OID"]         = nodes[iCnt].oid;
                row["ParentID"]    = nodes[iCnt].parents[0];
                row["Description"] = nodes[iCnt].displayName;
                retTaxonomy.Rows.Add(row);
            }
            //sorting & storing...
            DataView dvSortedTaxonomy = new DataView(retTaxonomy);

            dvSortedTaxonomy.Sort = "Description";
            DataTable dtSortedTaxonomy = CreateTaxonomyTable();

            for (int iCnt = 0; iCnt < dvSortedTaxonomy.Count; iCnt++)
            {
                DataRow row = dtSortedTaxonomy.NewRow();
                row["OID"]         = dvSortedTaxonomy[iCnt]["OID"];
                row["ParentID"]    = dvSortedTaxonomy[iCnt]["ParentID"];
                row["Description"] = dvSortedTaxonomy[iCnt]["Description"];
                dtSortedTaxonomy.Rows.Add(row);
            }


            DateTime d          = DateTime.Now;
            DateTime d1         = new DateTime(d.Year, d.Month, d.Day, base.expiration_hrs, base.expiration_min, base.expiration_sec);
            long     expiration = (d1.Ticks - d.Ticks);

            if (expiration < 0)
            {
                expiration = TimeSpan.TicksPerDay + expiration;
            }
            expiration = expiration / TimeSpan.TicksPerSecond;
            int absoluteExpiration = Convert.ToInt32(expiration);
            int noSliding          = Cache.NoSlidingExpiration.Seconds;

            chTaxonomy.Insert("CSN_KM_TAXONOMY", "Taxonomy_CV", dtSortedTaxonomy, null, absoluteExpiration, noSliding);

            return(dtSortedTaxonomy);
        }
Exemplo n.º 2
0
        /// <summary>
        /// methods, which implement the computations and actions that can be
        /// performed by the class
        /// </summary>
        #region "### Public Methods  ###"

        public DataTable SearchDocuments(string partnerRole, string openTextValue, int productOid, int osOid, int componentOid, int[] docTypes, DateTime releaseDate, ref string searchID, string searchLanguage)
        {
            if ((openTextValue == null || openTextValue.Trim() == "") && (productOid == -1 || productOid == 0))
            {
                throw new SearchException(16, SearchException.ERROR_TYPE.INFORMATION, "Please Specify Alteast One Search Criteria : Key Value (or) Taxonomy Id");
            }

            if (docTypes == null || docTypes.Length == 0)
            {
                throw new SearchException(15, SearchException.ERROR_TYPE.INFORMATION, "Please Specify Atleast One Document Type To Search");
            }

            try
            {
                OracleUtil objOraUtil = new OracleUtil();
                // Release 8.7 Enhancement
                int[]  disclosureLevels = objOraUtil.GetDisclosurelevel(partnerRole);
                int [] odsDocTypeIDs    = null;

                HP.Csn.Business.KM.Services.SearchService.WSUserInfo wsUserInfo = new HP.Csn.Business.KM.Services.SearchService.WSUserInfo();
                wsUserInfo.userId           = base.userId;
                wsUserInfo.portalId         = base.portalId;
                wsUserInfo.disclosureLevels = disclosureLevels;

                // Temp fix : Send disclosure levels to entitlements as expected by CSR
                if (disclosureLevels != null)
                {
                    string [] tempDisclosureLevels = new string[disclosureLevels.Length];
                    for (int i = 0; i < disclosureLevels.Length; i++)
                    {
                        tempDisclosureLevels[i] = disclosureLevels[i].ToString();
                    }

                    // Temp fix
                    wsUserInfo.entitlements = tempDisclosureLevels;
                }

                WSSearchRequest wsSearchRequest = new WSSearchRequest();
                wsSearchRequest.query          = openTextValue.Trim();
                wsSearchRequest.searchCriteria = 0;
                wsSearchRequest.maxResults     = base.max_results;
                wsSearchRequest.resultsPerPage = base.results_per_page;

                if (searchLanguage == null && searchLanguage == "")
                {
                    searchLanguage = DEFAULT_LANGUAGE;
                }

                if (searchLanguage != null && searchLanguage != "")
                {
                    wsSearchRequest.searchLanguages = new string[] { searchLanguage }
                }
                ;

                if (docTypes.Length > 0)
                {
                    odsDocTypeIDs = new int[docTypes.Length];


                    OracleUtil obj1 = new OracleUtil();
                    odsDocTypeIDs = obj1.GetOdsDocumentTypes(docTypes);
                }
                wsSearchRequest.docTypes = odsDocTypeIDs;



                if (searchID != null && searchID != "")
                {
                    wsSearchRequest.searchId = searchID;
                }

                WSMetaDataQuery[] tempMdqs = new WSMetaDataQuery[3];                 // Maximun Metadata Query supported is 3
                int countMdq = 0;
                //start
                //By Ajit: to filter Original systems from the query while pulling the data from different systems.
                //e.g. -> string[] s = { "389", "391", "392", "2429", "2288", "2291", "2454" };
                string[] OriginalSystems = base.GetKmOriginalSystem();
                if (OriginalSystems != null)
                {
                    if (OriginalSystems.Length > 0)
                    {
                        WSMetaDataQuery SystemMdq = new WSMetaDataQuery();
                        SystemMdq.name       = "original_system"; //Parameter to filter system
                        SystemMdq.type       = 1;                 // 0 = text, 1 = taxo, 2 = date
                        SystemMdq.values     = OriginalSystems;   //array of systems to filter
                        tempMdqs[countMdq++] = SystemMdq;         //Making array of Parameter to webservice
                    }
                }
                //end

                // 1. Component metadata search
                if (componentOid != -1 && componentOid != 0)
                {
                    WSMetaDataQuery componentMdq = new WSMetaDataQuery();
                    componentMdq.name    = "main_component";
                    componentMdq.values  = new string[] { "" + componentOid };
                    tempMdqs[countMdq++] = componentMdq;
                }

                // 2. Content Update Date metadata search
                if (releaseDate.CompareTo(new DateTime(0)) != 0)
                {
                    WSMetaDataQuery dateMdq = new WSMetaDataQuery();
                    dateMdq.name         = "content_update_date";
                    dateMdq.values       = new string[] { releaseDate.ToString(), DateTime.Now.ToString() };
                    tempMdqs[countMdq++] = dateMdq;
                }

                // 3. OID metadata search for Product & OS search
                string[] pathOids = new string[2];
                int      countOid = 0;

                if (productOid != -1 && productOid != 0)
                {
                    pathOids[countOid++] = "" + productOid;
                }

                if (osOid != -1 && osOid != 0)
                {
                    pathOids[countOid++] = "" + osOid;
                }

                if (countOid != 0)
                {
                    WSMetaDataQuery oidMdq = new WSMetaDataQuery();
                    oidMdq.name = "path_oids";
                    if (countOid == 2)
                    {
                        oidMdq.values = pathOids;
                    }
                    else
                    {
                        oidMdq.values = new string[] { pathOids[0] }
                    };
                    tempMdqs[countMdq++] = oidMdq;
                }

                // copying tempMdqs to metaDataQuerys upto countMdq
                //Adding For Filter By Document_sataus-13.11-Start
                string[] WorkFlowStatuses = objOraUtil.workflowstate();
                if (WorkFlowStatuses != null)
                {
                    WSMetaDataQuery metaDataQuerysPublished = new WSMetaDataQuery();
                    metaDataQuerysPublished.name   = "workflow_state";
                    metaDataQuerysPublished.values = WorkFlowStatuses;
                    tempMdqs[countMdq++]           = metaDataQuerysPublished;
                }
                //Adding For Filter By Document_sataus-13.11-End

                WSMetaDataQuery[] metaDataQuerys = null;
                if (countMdq != 0)
                {
                    metaDataQuerys = new WSMetaDataQuery[countMdq];
                    for (int iCnt = 0; iCnt < countMdq; iCnt++)
                    {
                        metaDataQuerys[iCnt] = tempMdqs[iCnt];
                    }
                }

                WSSearchResults wsSearchResults = null;

                SearchService searchService = new SearchService();
                searchService.SetConnectionInfo(base.searchUrl, base.userId, base.userPassword, base.timeOut);

                wsSearchResults = searchService.search(wsUserInfo, wsSearchRequest, metaDataQuerys);

                if (wsSearchResults == null)
                {
                    throw new SearchException(13, SearchException.ERROR_TYPE.INFORMATION, "No Documents Found For Given Search Criteria");
                }

                WSSearchResult[] wsResult = wsSearchResults.results;
                if (wsResult == null || wsResult.Length == 0)
                {
                    throw new SearchException(14, SearchException.ERROR_TYPE.INFORMATION, "No Documents Found For Given Search Criteria");
                }

                searchID = wsSearchRequest.searchId;

                DataTable dtSearchResults = new DataTable();
                dtSearchResults.Columns.Add("DocID");
                dtSearchResults.Columns.Add("Title");
                dtSearchResults.Columns.Add("DocType");
                dtSearchResults.Columns.Add("Size");
                dtSearchResults.Columns.Add("Disclosurelvl");
                dtSearchResults.Columns.Add("LastUpdate", typeof(DateTime));

                for (int iCnt = 0; iCnt < wsResult.Length; iCnt++)
                {
                    DataRow row = dtSearchResults.NewRow();
                    row["DocID"] = wsResult[iCnt].docId;
                    string size    = wsResult[iCnt].docSize.ToString();
                    Int32  DocSize = Convert.ToInt32(size) / 1000;
                    size = "  (" + DocSize + "K)";
                    string title = System.Text.Encoding.UTF8.GetString(wsResult[iCnt].title);
                    row["Title"]         = title + size;
                    row["DocType"]       = wsResult[iCnt].docType.ToString();
                    row["Size"]          = wsResult[iCnt].docSize;
                    row["Disclosurelvl"] = wsResult[iCnt].disclosureLevel.ToString();
                    row["LastUpdate"]    = wsResult[iCnt].contentUpdateDate;

                    dtSearchResults.Rows.Add(row);
                }
                return(dtSearchResults);
            }


            catch (SoapException ex)
            {
                throw new SearchException(12, SearchException.ERROR_TYPE.INFORMATION, "Error While Searching for Documents. ERROR :" + ex.Message, ex);
            }
            catch (WebException ex)
            {
                throw new SearchException(11, SearchException.ERROR_TYPE.WARNING, "Error Connecting to Webservices. ERROR :" + ex.Message, ex);
            }
            catch (SearchException ex)
            {
                //Catching and throwing zero results found exception
                throw ex;
            }
            catch (Exception ex)
            {
                throw new SearchException(10, SearchException.ERROR_TYPE.WARNING, "Unexpected Error While Accessing Webservices. ERROR :" + ex.Message, ex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// methods, which implement the computations and actions that can be
        /// performed by the class
        /// </summary>
        #region "### Private Methods  ###"

        private DataTable BuildTaxonomy(int oid, int level, string partnerRole)
        {
            TaxonomyService taxonomyService = new TaxonomyService();

            taxonomyService.SetConnectionInfo(base.taxonomyUrl, base.userId, base.userPassword, base.timeOut);

            WSUserInfo wsUserInfo = new WSUserInfo();

            wsUserInfo.userId   = base.userId;
            wsUserInfo.portalId = base.portalId;

            OracleUtil objOraUtil = new OracleUtil();

            // Release 8.7 Enhancement
            wsUserInfo.disclosureLevels = objOraUtil.GetDisclosurelevel(partnerRole);

            WSPMRequest pmRequest = new WSPMRequest();

            pmRequest.oid    = oid;
            pmRequest.locale = DEFAULT_LANGUAGECODE;

            WSPMNode[] nodes = null;
            try
            {
                nodes = taxonomyService.retrievePMSubtree(wsUserInfo, pmRequest);
            }
            catch (SoapException ex)
            {
                throw new TaxonomyException(3, TaxonomyException.ERROR_TYPE.INFORMATION, "Error While Retrieving Taxonomy", ex.Message, ex);
            }
            catch (System.Net.WebException ex)
            {
                throw new TaxonomyException(2, TaxonomyException.ERROR_TYPE.WARNING, "Error Connecting To Webservices", ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new TaxonomyException(1, TaxonomyException.ERROR_TYPE.WARNING, "Unexpected Error While Retrieving Taxonomy", ex.Message, ex);
            }

            if (nodes == null || nodes.Length == 0)
            {
                throw new TaxonomyException(4, TaxonomyException.ERROR_TYPE.INFORMATION, "Taxonomy Not Available For Given OID", "OID Node Is Empty");
            }

            DataTable retTaxonomy = CreateTaxonomyTable();

            for (int iCnt = 0; iCnt < nodes.Length; iCnt++)
            {
                if (nodes[iCnt].level == level)
                {
                    DataRow row = retTaxonomy.NewRow();
                    row["OID"]         = nodes[iCnt].oid;
                    row["ParentID"]    = oid;
                    row["Description"] = nodes[iCnt].displayName;
                    retTaxonomy.Rows.Add(row);
                }
            }
            // Sort taxonomy on description column
            DataView  dvSortedTaxonomy = new DataView(retTaxonomy, null, "Description", DataViewRowState.CurrentRows);
            DataTable dtSortedTaxonomy = CreateTaxonomyTable();

            for (int iCnt = 0; iCnt < dvSortedTaxonomy.Count; iCnt++)
            {
                DataRow row = dtSortedTaxonomy.NewRow();
                row["OID"]         = dvSortedTaxonomy[iCnt]["OID"];
                row["ParentID"]    = dvSortedTaxonomy[iCnt]["ParentID"];
                row["Description"] = dvSortedTaxonomy[iCnt]["Description"];
                dtSortedTaxonomy.Rows.Add(row);
            }

            if (oid == 0)
            {
                DateTime d          = DateTime.Now;
                DateTime d1         = new DateTime(d.Year, d.Month, d.Day, base.expiration_hrs, base.expiration_min, base.expiration_sec);
                long     expiration = (d1.Ticks - d.Ticks);
                if (expiration < 0)
                {
                    expiration = TimeSpan.TicksPerDay + expiration;
                }
                expiration = expiration / TimeSpan.TicksPerSecond;
                int absoluteExpiration = Convert.ToInt32(expiration);
                int noSliding          = Cache.NoSlidingExpiration.Seconds;

                chTaxonomy.Insert("CSN_KM_TAXONOMY", "Taxonomy_" + oid, dtSortedTaxonomy, null, absoluteExpiration, noSliding);
            }
            else
            {
                CacheDependency cDep = new CacheDependency(null, new string[] { "CSN_KM_TAXONOMY" + ":" + "Taxonomy_0" });
                chTaxonomy.Insert("CSN_KM_TAXONOMY", "Taxonomy_" + oid, dtSortedTaxonomy, cDep);
            }

            return(dtSortedTaxonomy);
        }