Esempio n. 1
0
        public List <SAPDataProvider> GetDocumentDataproviders(SAPDocument doc)
        {
            List <SAPDataProvider> DPList = new List <SAPDataProvider>();
            string      send        = string.Empty;
            XmlDocument XmlResponse = new XmlDocument();

            webAPIconnect.Send("GET", "/biprws/raylight/v1/documents/" + doc.SI_ID + "/dataproviders", send, "application/xml", "application/xml");
            XmlResponse.LoadXml(webAPIconnect.responseContent);

            XmlNodeList elemList = XmlResponse.GetElementsByTagName("dataprovider");

            if (elemList.Count > 0)
            {
                foreach (XmlNode node in elemList)
                {
                    SAPDataProvider dp        = new SAPDataProvider();
                    XmlNodeList     childList = node.ChildNodes;
                    foreach (XmlNode child in childList)
                    {
                        switch (child.Name)
                        {
                        case "id":
                            dp.ID = child.InnerText;
                            break;

                        case "name":
                            dp.Name = child.InnerText;
                            break;

                        case "dataSourceId":
                            dp.DataSourceId = child.InnerText;
                            break;

                        case "dataSourceType":
                            dp.DataSourceType = child.InnerText;
                            break;

                        default:
                            break;
                        }
                    }
                    if (!dp.DataSourceType.Equals("unv") && !dp.DataSourceType.Equals("unx"))
                    {
                        if (dp.DataSourceType.Equals("fhsql"))
                        {
                            dp.sql = GetFHSQL(doc.SI_ID, dp.ID);
                        }
                        dp.DataSourceName = GetConnectionName(dp.DataSourceId);
                    }

                    DPList.Add(dp);
                }
            }
            return(DPList);
        }
Esempio n. 2
0
        public SAPDocument GetDocument(string DocumentId)
        {
            SAPDocument doc         = new SAPDocument();
            string      connName    = string.Empty;
            string      send        = string.Empty;
            XmlDocument XmlResponse = new XmlDocument();

            try
            {
                webAPIconnect.Send("GET", "/biprws/raylight/v1/documents/" + DocumentId, send, "application/xml", "application/xml");
                XmlResponse.LoadXml(webAPIconnect.responseContent);

                XmlNode     document   = XmlResponse.GetElementsByTagName("document").Item(0);
                XmlNodeList properties = document.ChildNodes;
                foreach (XmlNode child in properties)
                {
                    switch (child.Name)
                    {
                    case "id":
                        doc.SI_ID = child.InnerText;
                        break;

                    case "name":
                        doc.SI_NAME = child.InnerText;
                        break;

                    case "path":
                        doc.SI_PATH = child.InnerText;
                        break;

                    case "updated":
                        doc.SI_UPDATE_TS = child.InnerText;
                        break;

                    default:
                        break;
                    }
                }
                doc.DataProviderList = GetDocumentDataproviders(doc);
                doc.ParameterList    = GetDocumentParameters(doc.SI_ID);
                doc.ReportList       = GetDocumentReports(doc.SI_ID);
                return(doc);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.Flush();
                return(null);
            }
        }
Esempio n. 3
0
        //It is better to use the Infostore solution with Serializers for the response XML...
        // Working for 4.1 and above
        public SAPDocumentList GetDocumentListInfostore(string FolderId)
        {
            Debug.WriteLine("In GetDocumentListInfostore  for folder:" + FolderId);
            Debug.Flush();
            SAPDocumentList docList     = new SAPDocumentList();
            string          send        = string.Empty;
            string          recv        = string.Empty;
            XmlDocument     XmlResponse = new XmlDocument();

            try
            {
                Debug.WriteLine("Try...");
                Debug.Flush();
                webAPIconnect.Send("GET", "/biprws/infostore/" + FolderId + "/children?pageSize=200", send, "application/xml", "application/xml");
                TextReader    reader              = new StringReader(webAPIconnect.responseContent);
                XmlSerializer serializer          = new XmlSerializer(typeof(feed));
                feed          deserializedEntries = serializer.Deserialize(reader) as feed;
                if (deserializedEntries.entry == null)
                {
                    Debug.WriteLine("Null deserialized Entries");
                    Debug.Flush();
                }
                else
                {
                    Debug.WriteLine("Deserialized Entries:" + deserializedEntries.entry.Length);
                    Debug.Flush();
                    foreach (var entry in deserializedEntries.entry)
                    {
                        SAPDocument doc         = new SAPDocument();
                        string      cuid        = string.Empty;
                        string      name        = string.Empty;
                        string      description = string.Empty;
                        string      id          = string.Empty;
                        string      type        = string.Empty;

                        foreach (var attr in entry.content.attrs)
                        {
                            switch (attr.name)
                            {
                            case "type":
                                type = attr.Value;
                                break;

                            case "name":
                                name = attr.Value;
                                break;

                            case "description":
                                description = attr.Value;
                                break;

                            case "id":
                                id = attr.Value;
                                break;

                            case "cuid":
                                cuid = attr.Value;
                                break;

                            default:
                                break;
                            }
                        }

                        if (type.Equals("Webi"))
                        {
                            docList.entries.Add(GetDocument(id));
                            Debug.WriteLine("Doc ID:" + id);
                            Debug.Flush();
                        }
                        else if (type.Equals("Folder"))
                        {
                            SAPDocumentList docListInner = GetDocumentListInfostore(id);
                            Debug.WriteLine("Folder ID:" + id);
                            Debug.WriteLine("Inner list size:" + docListInner.entries.Count.ToString());
                            Debug.Flush();
                            docList.entries.AddRange(docListInner.entries);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error in document fetch from Infostore:" + e.StackTrace);
                Debug.WriteLine("Response:" + webAPIconnect.responseContent);
                Debug.WriteLine(e.Message);
                Debug.Flush();
            }
            return(docList);
        }
Esempio n. 4
0
        public List <SAPDataProvider> GetDataproviders(SAPDocument doc)
        {
            List <SAPDataProvider> DPList = new List <SAPDataProvider>();
            string      send        = string.Empty;
            XmlDocument XmlResponse = new XmlDocument();

            Debug.WriteLine("/biprws/raylight/v1/documents/" + doc.SI_ID + "/dataproviders");
            Debug.Flush();
            webAPIconnect.Send("GET", "/biprws/raylight/v1/documents/" + doc.SI_ID + "/dataproviders", send, "application/xml", "application/xml");
            XmlResponse.LoadXml(webAPIconnect.responseContent);
            Debug.WriteLine(webAPIconnect.responseContent);
            Debug.Flush();
            XmlNodeList elemList = XmlResponse.GetElementsByTagName("id");

            if (elemList.Count > 0)
            {
                foreach (XmlNode node in elemList)
                {
                    SAPDataProvider dp = new SAPDataProvider();

                    string DpId = node.InnerText;
                    Debug.WriteLine("In GetDataProvider " + DpId + " for Document:" + doc.SI_NAME);
                    Debug.Flush();
                    try
                    {
                        Debug.WriteLine("/biprws/raylight/v1/documents/" + doc.SI_ID + "/dataproviders/" + DpId);
                        webAPIconnect.Send("GET", "/biprws/raylight/v1/documents/" + doc.SI_ID + "/dataproviders/" + DpId, send, "application/xml", "application/xml");
                        TextReader    reader       = new StringReader(webAPIconnect.responseContent);
                        XmlSerializer serializer   = new XmlSerializer(typeof(dataprovider));
                        dataprovider  dpSerialized = serializer.Deserialize(reader) as dataprovider;
                        if (dpSerialized == null)
                        {
                            Debug.WriteLine("Null dataprovider");
                            Debug.Flush();
                        }
                        else
                        {
                            dp.ID             = dpSerialized.id;
                            dp.Name           = dpSerialized.name;
                            dp.DataSourceId   = dpSerialized.dataSourceId.ToString();
                            dp.DataSourceType = dpSerialized.dataSourceType;
                            if (dpSerialized.properties != null)
                            {
                                foreach (var property in dpSerialized.properties)
                                {
                                    switch (property.key)
                                    {
                                    case "sql":
                                        dp.sql = property.Value;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                        }

                        if (dpSerialized.dataSourceType.Equals("fhsql"))
                        {
                            try
                            {
                                dp.DataSourceName = GetConnectionName(dp.DataSourceId);
                            }
                            catch (Exception e)
                            {
                                Debug.WriteLine("Error in doc name:" + doc.SI_NAME);
                                Debug.WriteLine(e.StackTrace);
                                Debug.Flush();
                            }
                        }
                        else
                        {
                            dp.DataSourceName = "No Connection name";
                        }
                        DPList.Add(dp);
                    }
                    catch (Exception exc)
                    {
                        Debug.WriteLine("Error in doc name:" + doc.SI_NAME);
                        Debug.WriteLine(exc.StackTrace);
                        Debug.Flush();
                        dp.DataSourceName = "No Connection name";
                    }
                }
            }
            return(DPList);
        }