Example #1
0
        protected override void GetItem(string path)
        {
            string[] pathArray = ChunkPath(path);
            if (pathArray.Length == 0)
            {
                // Do nothing
            }
            else
            {
                string   drpAlias      = pathArray[0];
                string[] remainingPath = pathArray.Skip(1).ToArray();

                DRP_Client myDRPClient = new DRP_Client(drpURLHash[drpAlias]);
                if (!myDRPClient.Open().GetAwaiter().GetResult())
                {
                    return;
                }

                //Console.WriteLine("Connected to DRP Broker, sending pathCmd");
                JObject returnedData = myDRPClient.SendCmd_Async("DRP", "pathCmd", new Dictionary <string, object>()
                {
                    { "method", "cliGetPath" }, { "pathList", remainingPath }, { "listOnly", false }
                }).GetAwaiter().GetResult();

                if (returnedData != null && returnedData["pathItem"] != null)
                {
                    string returnJSONString;
                    string itemType = returnedData["pathItem"].GetType().ToString();
                    object returnObj;
                    if (itemType.Equals("Newtonsoft.Json.Linq.JValue"))
                    {
                        returnObj        = returnedData["pathItem"].Value <string>();
                        returnJSONString = returnedData["pathItem"].Value <string>();
                    }
                    else
                    {
                        returnObj        = returnedData["pathItem"];
                        returnJSONString = returnedData["pathItem"].ToString();
                    }
                    if (returnObj != null)
                    {
                        WriteItemObject(returnJSONString, this.ProviderInfo + "::" + path, false);
                    }
                    else
                    {
                        Console.WriteLine("Returned value is null!");
                    }
                }

                //WriteItemObject(returnedData, this.ProviderInfo + "::" + path, true);

                myDRPClient.CloseSession();
            }
        }
Example #2
0
        protected override void GetChildItems(string path, bool recurse)
        {
            string[] pathArray = ChunkPath(path);
            if (pathArray.Length == 0)
            {
                // Return base Objects
                DataTable returnTable = new DataTable();
                returnTable.Columns.Add(new DataColumn("Alias", typeof(string)));
                returnTable.Columns.Add(new DataColumn("URL", typeof(string)));
                returnTable.Columns.Add(new DataColumn("User", typeof(string)));
                returnTable.Columns.Add(new DataColumn("ProxyAddress", typeof(string)));
                //returnTable.Columns.Add(new DataColumn("ProxyUser", typeof(string)));

                foreach (string key in drpURLHash.Keys)
                {
                    DataRow newRow = returnTable.NewRow();
                    newRow.SetField("Alias", key);
                    newRow.SetField("URL", drpURLHash[key].URL);
                    newRow.SetField("User", drpURLHash[key].User);
                    newRow.SetField("ProxyAddress", drpURLHash[key].ProxyAddress);
                    //newRow.SetField("ProxyUser", drpURLHash[key].ProxyUser);
                    returnTable.Rows.Add(newRow);
                }

                if (returnTable != null)
                {
                    WriteItemObject(returnTable, this.ProviderInfo + "::" + path, true);
                }
            }
            else
            {
                string   drpAlias      = pathArray[0];
                string[] remainingPath = pathArray.Skip(1).ToArray();

                DRP_Client myDRPClient = new DRP_Client(drpURLHash[drpAlias]);
                if (!myDRPClient.Open().GetAwaiter().GetResult())
                {
                    return;
                }

                //Console.WriteLine("Connected to DRP Broker, sending pathCmd");
                JObject returnedData = myDRPClient.SendCmd_Async("DRP", "pathCmd", new Dictionary <string, object>()
                {
                    { "method", "cliGetPath" }, { "pathList", remainingPath }, { "listOnly", true }
                }).GetAwaiter().GetResult();

                if (returnedData != null && returnedData.ContainsKey("pathItemList"))
                {
                    // Return base Objects
                    DataTable returnTable = null;

                    foreach (JObject objData in (JArray)returnedData["pathItemList"])
                    {
                        var fields = new List <Field>();

                        // Create table if null
                        if (returnTable == null)
                        {
                            returnTable = ReturnTable(objData);
                        }

                        DataRow newRow = returnTable.NewRow();
                        foreach (JProperty thisProperty in objData.Properties())
                        {
                            newRow.SetField(thisProperty.Name, thisProperty.Value.ToString());
                        }
                        returnTable.Rows.Add(newRow);
                    }

                    if (returnTable != null)
                    {
                        WriteItemObject(returnTable, this.ProviderInfo + "::" + path, true);
                    }
                }

                myDRPClient.CloseSession();
            }
        }