public async Task <JsonDocument> GetReports([FromBody] Grid grid) { Dictionary <string, object> dict = new Dictionary <string, object>(); //var permission = await new BitrixController().PermissionToWorkgroup(authUser.bx_access_token,workgroupName); //if (!permission) return throwError("თქვენ არ გაქვთ ამ ოპერაციის განხორციელების უფლება"); string credentials = ""; if (authUser.user1C == null || String.IsNullOrEmpty(authUser.user1C.username)) { return(throwError("თქვენ არ გაქვთ ამ ოპერაციის განხორციელების უფლება")); } if (!string.IsNullOrEmpty(authUser.user1C.username)) { credentials = authUser.user1C.username; } if (!string.IsNullOrEmpty(authUser.user1C.password)) { credentials = ":" + authUser.user1C.password; } string base64Cred = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials)); var httpManager = new HttpClientManager(); httpManager.http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64Cred); var clientsList = await httpManager.GetAndDeserialize <List <dsClient> >("http://188.93.95.179:8081/" + authUser.user1C.username + "/hs/Exchange/Clients"); //var http = new HttpClient(); //HttpResponseMessage balances = await http.GetAsync("http://188.93.95.179:8081/demo/hs/Exchange/ClientsBalances?Client="); //var balancesStr = balances.Content.ReadAsStringAsync().Result; //var balancesList = JsonSerializer.Deserialize<List<dsBalance>>(balancesStr); if (clientsList == null || clientsList[0].uid == null) { return(Success(dict)); } var balancesList = await httpManager.GetAndDeserialize <List <dsBalance> >("http://188.93.95.179:8081/" + authUser.user1C.username + "/hs/Exchange/ClientsBalances"); var list = from b in balancesList join c in clientsList on b.Client equals c.uid into joined from c in joined select new { FullName = c.FullName, c.uid, b.ClientBalanceCur, b.ClientBalanceEq }; dict.Add("Count", list.Count <dynamic>()); dict.Add("Rows", list); return(Success(dict)); }
public async Task<BitrixNotifications> GetBxNotifications(string access_token) { var http = new HttpClientManager(); var bx = new BXManager(); var notifs = await http.GetAndDeserialize<BitrixNotifications>(bx.bxRestUrl + "im.counters.get?auth=" + access_token,"result=>TYPE"); return notifs; }
public async Task<bool> PermissionToWorkgroup(string accessToken, string workgroupName) { var bx = new BXManager(); var httpManager = new HttpClientManager(); var bxWorkgroups = await httpManager.GetAndDeserialize<List<BitrixWorkgroup>>(bx.bxRestUrl + "sonet_group.get?auth=" + accessToken + "&FILTER[NAME]=" + workgroupName, "result"); //var http = new HttpClient(); //HttpResponseMessage response = await http.GetAsync(bx.bxRestUrl + "sonet_group.get?auth=" + accessToken + "&FILTER[NAME]=" + workgroupName); //var json = JsonDocument.Parse(response.Content.ReadAsStringAsync().Result); //var bxWorkgroups = JsonSerializer.Deserialize<List<BitrixWorkgroup>>(Convert.ToString(json.RootElement.GetProperty("result"))); if (bxWorkgroups.Count > 0) return true; return false; }