コード例 #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);
        }
コード例 #2
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);
        }