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; }
public IPrintingServiceProvider CreatePrintingServiceProvider() { Configuration config = _config.GetProviderConfiguration(ProviderType.Printer); IRestClient client = new JSONClient(config.BaseUrl, config.Authenticator); var provider = new PrintingServiceProvider(client); return(provider); }
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()); } }
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); }
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); }
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); }
public string ChemIdToMol(int chemID) { JSONClient client = new JSONClient(); var compounds = client.GetRecordsAsCompounds(new List <int>() { chemID }); return(compounds.First().Mol); }
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); } }
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); }
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); }
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); } }
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); }
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); }
public NetworkExporter(JSONClient client) { this.client = client; }
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); }