Ejemplo n.º 1
0
        public NetworkImporter(string server_addrs, string userName, string password, string sessionid)
        {
            User user = new User(userName, password, sessionid);

            client            = new JSONClient(server_addrs, user);
            jss               = new JavaScriptSerializer();
            jss.MaxJsonLength = int.MaxValue;
        }
Ejemplo n.º 2
0
        public IPrintingServiceProvider CreatePrintingServiceProvider()
        {
            Configuration config   = _config.GetProviderConfiguration(ProviderType.Printer);
            IRestClient   client   = new JSONClient(config.BaseUrl, config.Authenticator);
            var           provider = new PrintingServiceProvider(client);

            return(provider);
        }
Ejemplo n.º 3
0
 public static IPAddress DiscoverBridgeIP()
 {
     try {
         var bridgeInfo = JSONClient.RequestBroker() as JArray;
         return(IPAddress.Parse(((JObject)bridgeInfo[0])["internalipaddress"].Value <string>()));
     } catch (Exception e) {
         throw new Exception(e.ToString());
     }
 }
Ejemplo n.º 4
0
        public IMessageServiceProvider CreateMessageServiceProvider()
        {
            Configuration config = _config.GetProviderConfiguration(ProviderType.Message);
            IRestClient   client = new JSONClient(config.BaseUrl, config.Authenticator);

            client.PreAuthenticate = true;
            var provider = new MessageServiceProvider(client);

            return(provider);
        }
Ejemplo n.º 5
0
        public ISessionServiceProvider CreateSessionServiceProvider()
        {
            Configuration config = _config.GetProviderConfiguration(ProviderType.Session);
            IRestClient   client = new JSONClient(config.BaseUrl, config.Authenticator);

            client.PreAuthenticate = true;
            var provider = new SessionServiceProvider(client, MemoryCache.Default);

            return(provider);
        }
Ejemplo n.º 6
0
        public ITrustRelationRequestServiceProvider CreateTrustRelationRequestServiceProvider()
        {
            Configuration config = _config.GetProviderConfiguration(ProviderType.TrustRelation);
            IRestClient   client = new JSONClient(config.BaseUrl, config.Authenticator);

            client.PreAuthenticate = true;
            var provider = new TrustRelationRequestServiceProvider(client);

            return(provider);
        }
Ejemplo n.º 7
0
        public string ChemIdToMol(int chemID)
        {
            JSONClient client    = new JSONClient();
            var        compounds = client.GetRecordsAsCompounds(new List <int>()
            {
                chemID
            });

            return(compounds.First().Mol);
        }
Ejemplo n.º 8
0
        public static void TurnOnOffLights(List <string> LightList, bool NewState)
        {
            dynamic data = new ExpandoObject();

            data.on = NewState;
            foreach (string LightName in LightList)
            {
                string ApiCall = "/api/" + Settings.Username + "/lights/" + GetAddedLightID(LightName) + "/state";
                MessageBox.Show(ApiCall);
                JArray response = JSONClient.Request(HttpMethod.Put, ApiCall, data);
            }
        }
Ejemplo n.º 9
0
        public static List <string> GetColorableLights()
        {
            List <string> LightList = new List <string>();
            JToken        blah      = JToken.Parse(JSONClient.Request(HttpMethod.Get, "/api/" + Settings.Username + "/lights").ToString());
            JObject       obj       = JObject.Parse(blah.ToString());

            foreach (var pair in obj)
            {
                if (obj[pair.Key]["type"].ToString() == "Extended color light")
                {
                    LightList.Add(obj[pair.Key]["name"].ToString());
                }
            }
            return(LightList);
        }
Ejemplo n.º 10
0
        public static string GetAddedLightID(string LightName)
        {
            List <string> LightList = new List <string>();
            JToken        blah      = JToken.Parse(JSONClient.Request(HttpMethod.Get, "/api/" + Settings.Username + "/lights").ToString());
            JObject       obj       = JObject.Parse(blah.ToString());
            string        lName     = "";

            foreach (var pair in obj)
            {
                if (obj[pair.Key]["name"].ToString() == LightName)
                {
                    lName = pair.Key.ToString();
                }
            }
            return(lName);
        }
Ejemplo n.º 11
0
        private static bool RegisterNewUser()
        {
            dynamic data = new ExpandoObject();

            data.devicetype = AppID;
            JArray response = JSONClient.Request(HttpMethod.Post, "/api", data);

            try {
                if (response[0]["success"]["username"] != null)
                {
                    Settings.Username = response[0]["success"]["username"].ToString();
                    return(true);
                }
                return(false);
            } catch {
                return(false);
            }
        }
Ejemplo n.º 12
0
        public static async Task <JSONClient> ToJSONAsync(this Client client, IUnitOfWork uiOfWork)
        {
            var status = (await uiOfWork.AbonementStatuses.GetAsync(client.AbonementStatusId)).Name;


            JSONClient jsonClient = new JSONClient()
            {
                Id                  = client.Id,
                Name                = client.Name,
                Family              = client.Family,
                LastName            = client.LastName,
                DateOfBirdth        = client.DateOfBirdth,
                AbonementNumber     = client.AbonementNumber,
                AbonementActionTime = client.AbonementActionTime,
                AbonementType       = (await uiOfWork.AbonementTypes.GetAsync(client.AbonementTypeId)).Name,
                AbonementStatus     = (await uiOfWork.AbonementStatuses.GetAsync(client.AbonementStatusId)).Name,
                IsAсtive            = String.Equals(status, "Активен"),
                IsFreeze            = String.Equals(status, "Заморожен"),
                AbonementEndTime    = client.AbonementDateOfActivate.AddDays(client.AbonementActionTime.Day).AddHours(client.AbonementActionTime.Hour).AddMonths(client.AbonementActionTime.Month)
            };

            return(jsonClient);
        }
Ejemplo n.º 13
0
        public string GetMol()
        {
            N2SResult  res    = new N2SResult();
            JSONClient client = new JSONClient();

            var mol          = "";
            var currentValue = records[keys[this.currentIndex]];


            var chemID   = currentValue["chemspiderid"];
            var inChIKey = currentValue["stdinchikey"];
            var name     = keys[this.currentIndex];

            if (chemID != null)
            {
                mol = this.ChemIdToMol(Int32.Parse(chemID.ToString()));
            }
            else if (inChIKey != null)
            {
                res = client.ConvertTo(new ConvertOptions()
                {
                    Direction = ConvertOptions.EDirection.InChiKey2ID, Text = inChIKey.ToString()
                });
                mol = ChemIdToMol(Int32.Parse(res.mol));
            }
            else
            {
                res = client.ConvertTo(new ConvertOptions()
                {
                    Direction = ConvertOptions.EDirection.Name2Mol, Text = name
                });
                mol = res.mol;
            }

            return(mol);
        }
Ejemplo n.º 14
0
 public NetworkExporter(JSONClient client)
 {
     this.client = client;
 }
Ejemplo n.º 15
0
        public NetworkExporter(string server_addrs, string userName, string password, string sessionid = null)
        {
            User user = new User(userName, password, sessionid);

            client = new JSONClient(server_addrs, user);
        }