public IEnumerable <Server> List([FromBody] dynamic request) { var httpService = new HttpComunicationService(); if (HttpContext.ExistsSessionKey(request.sessionKey as string) && HttpContext.IsSessionKeyValid(request.sessionKey as string)) { var account = HttpContext.GetAccount(request.sessinKey as string).Deserialize <Account>(); var _req = new ApiHttpRequest <Dictionary <string, object> > { data = request.data as Dictionary <string, object> }; var response = httpService .Post <ApiHttpResponse <HttpDataList <Server> > >(webApiUrl + "Servers/List", account.Username, account.Password, false, _req); if (response.operationResult.Code == HttpUtilities.Enumerators.ResultCode.KO) { throw new AngularException(response.operationResult.Message, response.operationResult.Stack); } return(response.data.result); } else { return(null); } }
public OperationResult Update([FromBody] dynamic request) { var httpService = new HttpComunicationService(); if (HttpContext.ExistsSessionKey(request.sessionKey as string) && HttpContext.IsSessionKeyValid(request.sessionKey as string)) { var account = HttpContext.GetAccount(request.sessinKey as string).Deserialize <Account>(); var _req = new ApiHttpRequest <Server> { data = request.data as Server }; var response = httpService .Post <ApiHttpResponse <HttpDataList <Server> > >(webApiUrl + "Servers/Update?ServerID=", account.Username, account.Password, false, _req); return(response.operationResult); } else { return(null); } }
public IEnumerable <Call> List([FromBody] dynamic request) { var httpService = new HttpComunicationService(); if (HttpContext.Current.ExistsSessionKey((string)request.sessionKey, (string)request.accountID) && HttpContext.Current.IsSessionKeyValid((string)request.sessionKey, (string)request.accountID)) { var account = HttpContext.Current.GetAccount((string)request.sessionKey).Deserialize <Account>(); var _req = new ApiHttpRequest <Dictionary <string, object> > { data = ((JObject)request.data) != null ? ((JObject)request.data).ToObject <Dictionary <string, object> >() : new Dictionary <string, object>() }; var response = httpService .Post <ApiHttpResponse <HttpDataList <Call> > >(webApiUrl + "Calls/List", account.Username, account.Password, false, _req); if (response.operationResult.Code == HttpUtilities.Enumerators.ResultCode.KO) { throw new AngularException(response.operationResult.Message, response.operationResult.Stack); } return(response.data.result.OrderByDescending(x => x.StartedAt)); } else { return(null); } }
public HttpResponseMessage Login(Account account) { var response = new ApiHttpResponse <LoginInfo>(); try { var httpService = new HttpComunicationService(); var wsResponse = httpService.Post <ApiHttpResponse <HttpDataSingle <Account> > >(webApiUrl + "AccountsVerification/exists", "", "", false, account ); if (wsResponse.operationResult.Code == HttpUtilities.Enumerators.ResultCode.OK) { response.data = new LoginInfo { Account = wsResponse.data.result, SessionKey = HttpContext.Current.GetSessionKey(wsResponse.data.result) }; response.Complete(HttpUtilities.Enumerators.ResultCode.OK); } else { throw new AngularException(response.operationResult.Message, response.operationResult.Stack); } } catch (Exception ex) { response.Fault(ex); } return(Request.CreateResponse(response.Code, response)); }
public CallPerHourResponse ErrorPerHour([FromUri] string sessionKey, [FromUri] string accountID) { var response = new CallPerHourResponse(); var httpService = new HttpComunicationService(); if (HttpContext.Current.ExistsSessionKey(sessionKey, accountID) && HttpContext.Current.IsSessionKeyValid(sessionKey, accountID)) { var account = HttpContext.Current.GetAccount(sessionKey).Deserialize <Account>(); var _req = new ApiHttpRequest <Dictionary <string, object> > { data = new Dictionary <string, object>() }; var _resCalls = httpService .Post <ApiHttpResponse <HttpDataList <Call> > >(webApiUrl + "calls/List", account.Username, account.Password, false, _req); if (_resCalls.operationResult.Code == HttpUtilities.Enumerators.ResultCode.KO) { throw new AngularException(_resCalls.operationResult.Message, _resCalls.operationResult.Stack); } response.data = (from call in _resCalls.data.result where call.Error != null && call.StartedAt >= DateTime.Today group call by call.StartedAt.Hour into cals select new CallPerHour { calls = cals.Count(), hour = cals.Key }).ToList(); return(response); } else { return(null); } }
public LoginInfo Login([FromBody] Account account) { var httpService = new HttpComunicationService(); var response = httpService.Post <ApiHttpResponse <HttpDataSingle <Account> > >("", account.Username, account.Password, false, account ); if (response.operationResult.Code == HttpUtilities.Enumerators.ResultCode.OK) { return(new LoginInfo { Account = response.data.result, SessionKey = HttpContext.GetSessionKey(response.data.result) }); } else { throw new AngularException(response.operationResult.Message, response.operationResult.Stack); } }
public Models.Last20CallResponse Last20Call([FromUri] string sessionKey, string accountID) { Last20CallResponse response = new Last20CallResponse(); var httpService = new HttpComunicationService(); if (HttpContext.Current.ExistsSessionKey((string)sessionKey, (string)accountID) && HttpContext.Current.IsSessionKeyValid((string)sessionKey, (string)accountID)) { var account = HttpContext.Current.GetAccount((string)sessionKey).Deserialize <Account>(); var _req = new ApiHttpRequest <DbFiltersCollection> { data = new DbFiltersCollection { new DbTop { Number = 10 }, new DbFilter { PropertyName = "StartedAt", Sign = CompareSign.GreaterEquals, Value = DateTime.Now.SetMidnight() } } }; var _resCalls = httpService .Post <ApiHttpResponse <HttpDataList <Call> > >(webApiUrl + "calls/List", account.Username, account.Password, false, _req); if (_resCalls.operationResult.Code == HttpUtilities.Enumerators.ResultCode.KO) { throw new AngularException(_resCalls.operationResult.Message, _resCalls.operationResult.Stack); } _req = new ApiHttpRequest <DbFiltersCollection> { data = new DbFiltersCollection { new DbTop { Number = 10 }, new DbFilter { PropertyName = "StartedAt", Sign = CompareSign.GreaterEquals, Value = DateTime.Now.SetMidnight() }, new DbFilter { PropertyName = "Error", Sign = CompareSign.NotEquals, Value = null } } }; var _errorCalls = httpService .Post <ApiHttpResponse <HttpDataList <Call> > >(webApiUrl + "calls/List", account.Username, account.Password, false, _req); if (_resCalls.operationResult.Code == HttpUtilities.Enumerators.ResultCode.KO) { throw new AngularException(_resCalls.operationResult.Message, _resCalls.operationResult.Stack); } response.Last10Calls = _resCalls.data.result.OrderByDescending(x => x.StartedAt); //.Take(10).ToList(); response.Last10ErrorsCalls = _resCalls.data.result.OrderByDescending(x => x.StartedAt); //.Where(x => x.Error != null).Take(10).ToList(); return(response); } else { return(null); } }