public async Task <IOrderedEnumerable <Event> > GetEvents(string triggerId, uint?limit, EventSortField sortBy, Select selectHosts, Select selectTriggers) { ParamsRequestBody <GetEventsParams> requestBody = RequestBodyBuilder.Build(new GetEventsParams { TriggerId = triggerId, Limit = limit, SortBy = new[] { sortBy.ToDescriptionString() }, Order = SortOrderField.Desc.ToDescriptionString(), Filter = new Filter { Value = new[] { 0, 1 }, Object = new[] { 0 } }, SelectHosts = selectHosts == Select.None ? Query.None : Query.Extend, SelectTriggers = selectTriggers == Select.None ? Query.None : Query.Extend, Output = new Query { Value = QueryValues.Extend } }); ResultResponseBody <IEnumerable <GetEventsResult> > responceBody = await WebChannel.GetResponseAsync <ParamsRequestBody <GetEventsParams>, ResultResponseBody <IEnumerable <GetEventsResult> > >(requestBody); if (responceBody.Error != null) { throw new WebServiceException(responceBody.Error.Code, responceBody.Error.Message); } // Where(t => t.Object == 0) use only triggers return(responceBody.Result.Where(t => t.Object == 0).Select(t => t.ToEvent()).Where(e => e != null).OrderByDescending(e => e.Time)); }
public async Task Logout(WebChannel channel, HttpClient client) { if (m_WrappedProvider.LogoutIsSupported) { await m_WrappedProvider.Logout(client.BaseAddress, client).ConfigureAwait(false); } }
public async Task <string> LoginAsync(string userName, string password) { if (userName == null) { throw new ArgumentNullException("userName"); } if (password == null) { throw new ArgumentNullException("password"); } var loginParams = new LoginParams { Login = userName, Password = password }; ParamsRequestBody <LoginParams> loginRequestBody = RequestBodyBuilder.Build(loginParams); ResultResponseBody <string> loginResponseBody = await WebChannel.GetResponseAsync <ParamsRequestBody <LoginParams>, ResultResponseBody <string> >(loginRequestBody); if (loginResponseBody.Error != null) { throw new AuthorizationException(loginResponseBody.Error.Code, loginResponseBody.Error.Message); } return(loginResponseBody.Result); }
public async Task <IList <Graph> > GetGraphsAsync(string groupId, string hostId) { ParamsRequestBody <GetGraphsParams> requestBody = RequestBodyBuilder.Build(new GetGraphsParams { GroupId = groupId, HostId = hostId, Output = new Query { Params = new List <string> { "name" } } }); ResultResponseBody <IList <GetGraphsResult> > responceBody = await WebChannel.GetResponseAsync <ParamsRequestBody <GetGraphsParams>, ResultResponseBody <IList <GetGraphsResult> > >(requestBody); if (responceBody.Error != null) { throw new WebServiceException(responceBody.Error.Code, responceBody.Error.Message); } return(responceBody.Result.Select(t => t.ToGraph()).Where(g => g != null).ToList()); }
public async Task <IEnumerable <Host> > GetHostsAsync(string hostGroupId, HostSortField[] sortFields, string[] hostIds = null) { ParamsRequestBody <GetHostsParams> requestBody = RequestBodyBuilder.Build(new GetHostsParams() { GroupId = hostGroupId, SortBy = sortFields != null ? sortFields.Select(sortField => sortField.ToDescriptionString()).ToArray() : null, Output = new Query { Params = new List <string> { "name" } }, HostIds = hostIds }); ResultResponseBody <IEnumerable <GetHostsResult> > responceBody = await WebChannel.GetResponseAsync <ParamsRequestBody <GetHostsParams>, ResultResponseBody <IEnumerable <GetHostsResult> > >(requestBody); if (responceBody.Error != null) { throw new WebServiceException(responceBody.Error.Code, responceBody.Error.Message); } return(responceBody.Result.Select(t => t.ToHost()).Where(h => h != null).ToList()); }
public async Task <IEnumerable <HostGroup> > GetHostGroups(HostGroupsSortField[] sortFields, uint?limit) { ParamsRequestBody <GetHostGroupsParams> getHostGroupsRequestBody = RequestBodyBuilder.Build(new GetHostGroupsParams { SortBy = sortFields != null ? sortFields.Select(sortField => sortField.ToDescriptionString()).ToArray() : null, Limit = limit, MonitoredHosts = true, Output = new Query { Params = new List <string> { "name" } } }); ResultResponseBody <IEnumerable <GetHostGroupsResult> > getHostGroupsResponseBody = await WebChannel.GetResponseAsync <ParamsRequestBody <GetHostGroupsParams>, ResultResponseBody <IEnumerable <GetHostGroupsResult> > > (getHostGroupsRequestBody); if (getHostGroupsResponseBody.Error != null) { throw new WebServiceException(getHostGroupsResponseBody.Error.Code, getHostGroupsResponseBody.Error.Message); } return(getHostGroupsResponseBody.Result.Select(hostGroupResult => hostGroupResult.ToHostGroup()).Where(h => h != null).ToList()); }
public PromotionBaseInfo() { WebChannel = new WebChannel(); ProductCondition = new PSProductCondition(); CustomerCondition = new PSCustomerCondition(); OrderCondition = new PSOrderCondition(); UsingFrequencyCondition = new PSActivityFrequencyCondition(); }
/// <summary> /// Check client-server connection. /// </summary> /// <param name="channel">Channel to check his cnnection.</param> private void SetServiceStatus(WebChannel channel) { if (channel.IsConnected()) { Active = "Active"; } else { Active = "Not Active"; } }
public async Task <byte[]> GetGraphImageAsync(string graphId, uint height, uint width, DateTime stime, TimeSpan period) { if (period < MinPeriod) { period = MinPeriod; } var uriFormat = string.Concat(WebConfiguration.ServerUri, _serviceConfiguration.GraphPathFormat); var uri = string.Format(uriFormat, graphId, width, height, stime.ToUnixTicks(), (int)period.TotalSeconds); return(await WebChannel.Download(uri)); }
/// <summary> /// Remove handler on server side. /// </summary> /// <param name="handler">Handler to remove.</param> /// <param name="channel">Web channel for requests.</param> public void RemoveHandler(string handler, WebChannel channel) { if (handler != null && handler != "") { if (channel.IsConnected()) { CommandMessage req = new CommandMessage((int)CommandEnum.CloseCommand, new string[] { handler }); channel.Write(req); CommandMessage answer = channel.Read(); DirectoryHandlers.Remove(handler); } } }
public async Task <bool> LogoutAsync() { ParamsRequestBody <LogoutParams> logoutRequestBody = RequestBodyBuilder.Build(new LogoutParams()); ResultResponseBody <bool> logoutResponseBody = await WebChannel.GetResponseAsync <ParamsRequestBody <LogoutParams>, ResultResponseBody <bool> >(logoutRequestBody); if (logoutResponseBody.Error != null) { throw new WebServiceException(logoutResponseBody.Error.Code, logoutResponseBody.Error.Message); } return(logoutResponseBody.Result); }
/// <summary> /// Set all students. /// </summary> /// <param name="channel">Web channel for requesting config data.</param> private void SetStudents(WebChannel channel) { Students = new List <Student>(); if (channel.IsConnected()) { string rootPath = HttpContext.Current.Server.MapPath(@"\students.txt"); string[] lines = File.ReadAllLines(rootPath); foreach (string line in lines) { // Every line is deserialized by json. Student student = JsonConvert.DeserializeObject <Student>(line); Students.Add(student); } } }
/// <summary> /// Filter all logs by type. /// </summary> /// <param name="type">Type filter with.</param> /// <param name="channel">Web channel for requesting data.</param> public void FilterLogsByType(string type, WebChannel channel) { SetLogs(channel); // Type empty ignore. if (type != "") { List <Log> temp_logs = new List <Log>(); foreach (Log m in ServiceLogs) { if (m.Type.CompareTo(type) == 0) { temp_logs.Add(m); } } ServiceLogs = temp_logs; } }
/// <summary> /// Set number of photos in OutputDir. /// </summary> /// <param name="channel">Web channel for request.</param> private void SetNumberOfPhotos(WebChannel channel) { NumberOfPhotos = ""; if (channel.IsConnected()) { try { // Get all physical path of thumbnails directory. String rootPath = HttpContext.Current.Server.MapPath(@"\OutputDir\Thumbnails"); // Get number of thumbnails. NumberOfPhotos = Directory.GetFiles(rootPath, "*", SearchOption.AllDirectories).Length.ToString(); } catch (Exception e) { Console.WriteLine(e.Message); } } }
/// <summary> /// Set logs via server request. /// </summary> /// <param name="channel">Web channel for request.</param> public void SetLogs(WebChannel channel) { ServiceLogs = new List <Log>(); if (channel.IsConnected()) { CommandMessage req = new CommandMessage((int)CommandEnum.LogCommand); channel.Write(req); CommandMessage answer = channel.Read(); // Iterate over every two arguments. First for message and second for type. for (int i = 0; i < answer.Args.Length; i += 2) { string m = answer.Args[i]; string t = MessageRecievedEventArgs.GetTypeEnum(Int32.Parse(answer.Args[i + 1])).ToString(); Log log = new Log(t, m); // Adds a single log to an observables logs list. ServiceLogs.Add(log); } } }
/// <summary> /// Set config data via server request. /// </summary> /// <param name="channel">Web channel for requests.</param> public void SetConfigData(WebChannel channel) { DirectoryHandlers = new List <string>(); OutputDir = SourceName = LogName = ThumbnailSize = ""; if (channel.IsConnected()) { CommandMessage req = new CommandMessage((int)CommandEnum.GetConfigCommand); channel.Write(req); CommandMessage answer = channel.Read(); OutputDir = answer.Args[0]; SourceName = answer.Args[1]; LogName = answer.Args[2]; ThumbnailSize = answer.Args[3]; for (int i = 4; i < answer.Args.Length; i++) { DirectoryHandlers.Add(answer.Args[i]); } } }
/// <summary> /// Remove image and thumbnail from pc. /// </summary> /// <param name="iPath"> Image path. </param> /// <param name="tPath"> Thumbnail path. </param> /// <param name="channel">Web channel.</param> public void RemoveImage(string iPath, string tPath, WebChannel channel) { if (channel.IsConnected()) { // Get full path to image. string imagePath = HttpContext.Current.Server.MapPath(iPath); // Get full path to thumbnail. string thumbnailPath = HttpContext.Current.Server.MapPath(tPath); try { File.Delete(imagePath); File.Delete(thumbnailPath); } catch (Exception e) { Console.WriteLine(e.Message); } } }
/// <summary> /// Set all OutputDir photos. /// </summary> /// <param name="channel"> Web channel for requests. </param> public void SetServicePhotos(WebChannel channel) { ThumbnailPhotos = new List <Photo>(); if (channel.IsConnected()) { try { // Get full physical path of outputdir. string outputDirPath = HttpContext.Current.Server.MapPath(@"\OutputDir"); // Concat 'thumbnails'. string thumbnailsPath = outputDirPath + @"\Thumbnails"; // Start crawling all the photos. StartCrawlingAllPhotos(thumbnailsPath); } catch (Exception e) { Console.WriteLine(e.Message); } } }
private int m_VendorSysNo; //商家编号 public CountdownInfoVM() { StatusVisibility = false; m_IsTodaySpecials = false; m_IsSecondKill = false; m_IsCountDownAreaShow = false; m_IsHomePageShow = false; m_IsC1Show = false; m_IsC2Show = false; m_Is24hNotice = false; m_IsShowPriceInNotice = false; m_IsLimitedQty = true; m_IsEndIfNoQty = false; m_IsReservedQty = false; m_IsEmailNotify = false; m_IsCommitAudit = false; m_IsAuditPassed = false; m_IsReservedQty = false; AffectedStockList = new ObservableCollection <StockQtySettingVM>(); m_CountDownPoint = "0"; m_Channel = new WebChannel(); }
public async Task <IList <Item> > GetItemsAsync(string groupId, string hostId) { var requestBody = RequestBodyBuilder.Build(new GetDataParams { GroupId = groupId, HostId = hostId, Output = Query.Extend, ExpandDescription = true, Monitored = true, SortField = "description" }); var responceBody = await WebChannel.GetResponseAsync <ParamsRequestBody <GetDataParams>, ResultResponseBody <IList <GetDataResult> > >(requestBody); if (responceBody.Error != null) { throw new WebServiceException(responceBody.Error.Code, responceBody.Error.Message); } return(responceBody.Result.Select(t => t.ToItem()).Where(g => g != null).ToList()); }
/// <summary> /// Configuration function for DotNetToJScript and Unit Tests /// </summary> /// <param name="url"></param> public void Configure(string url) { BeaconChannel = new BeaconChannel(); ServerChannel = new WebChannel(url); UrlEndpoint = url; }
public HomeController() { channel = new WebChannel(); }
public async Task <IEnumerable <Trigger> > GetTriggers(string hostId, uint?limit, TriggersSortField[] sortFields, Select selectHosts, IList <string> triggerIds = null) { ParamsRequestBody <GetTriggersParams> requestBody = RequestBodyBuilder.Build(new GetTriggersParams() { TriggerIds = triggerIds, HostId = hostId, Limit = limit, ActiveOnly = true, SelectHosts = selectHosts == Select.None ? Query.None : Query.Extend, SortBy = sortFields != null ? sortFields.Select(field => field.ToDescriptionString()).ToArray() : null, ExpandDescription = true, Output = new Query { Params = new List <string> { "description", "priority", "value" } } }); ResultResponseBody <IEnumerable <GetTriggersResult> > responceBody = await WebChannel.GetResponseAsync <ParamsRequestBody <GetTriggersParams>, ResultResponseBody <IEnumerable <GetTriggersResult> > >(requestBody); if (responceBody.Error != null) { throw new WebServiceException(responceBody.Error.Code, responceBody.Error.Message); } return(responceBody.Result.Select(t => t.ToTrigger()).Where(t => t != null).ToList()); }
public WebMgr(string url) { this.url = url; webchannel = new WebChannel(); callBackLiseners = new Dictionary <uint, Action <byte[]> >(); }
/// <summary> /// Set all main window data. /// </summary> /// <param name="channel">Web channel for requests.</param> public void SetData(WebChannel channel) { SetServiceStatus(channel); SetStudents(channel); SetNumberOfPhotos(channel); }
public SOBaseInfoVM() { Merchant = new Merchant(); CustomerChannel = new WebChannel(); CompanyCode = CPApplication.Current.CompanyCode; }
public void PreProcessRequest(WebChannel channel, HttpClient client, HttpRequestMessage request, string resourceUrl, bool requestSupportsAuthentication) { m_WrappedProvider.PreProcessRequest(client.BaseAddress, client, resourceUrl, requestSupportsAuthentication); }
public async Task Login(WebChannel channel, HttpClient client) { await m_WrappedProvider.Login(client.BaseAddress, client).ConfigureAwait(false); }