public override void SaveDocuments(Share share, Schedulers.Task task) { foreach (var format in Formats) { var response = new Response(); var UNC = share.UNCPath + "." + Enum.GetName(typeof(ContentFormat), format); var formatter = new ProductfeedFormatter(format); if (formatter.saveContent(share.UNCPath)) { response.Code = 201; response.Description = "Created"; response.Detail = UNC + " was saved succesfully"; } else { response.Code = 400; response.Description = "Bad Request"; response.Detail = "There was an error when saving " + UNC; } Responses.Add(response); } }
public void Consume(ReadOnlySequence <byte> buffer) { var responsePart = buffer.ToArray().BytesToText(0, (int)buffer.Length); // Console.WriteLine("RESPONSE: " + responsePart); _responseBuilder.Append(responsePart); if (_responseBuilder.Length >= CurrentExpectedResponseLength) { // assume currentExpectedRequestLength is length of all // requests when multiple are received at one time var combinedResponse = _responseBuilder.ToString(); var combinedLength = combinedResponse.Length; _responseBuilder.Clear(); // reuse var startIndex = 0; var last = false; while (!last) { var request = combinedResponse.Substring(startIndex, CurrentExpectedResponseLength); startIndex += CurrentExpectedResponseLength; Responses.Add(request); last = startIndex == combinedLength; // Console.WriteLine("CONSUMING CLIENT " + request + " : " + _count); UntilConsume.WriteUsing("clientConsume", 1); } } }
public void Submit() { if (ServerCtx.Current is null) { BaseCmd.Error("No Server Context!"); } else if (ServerCtx.Current.Server.AuthResponse is null) { BaseCmd.Error("{0} not connected!", ServerCtx.Current.Id); } else { var cancel = new CancellationTokenSource(); try { var t = ServerCtx.Current.Server.RequestAsync <JsonElement>(Request, cancel); if (Wait(t, cancel)) { Responses.Add(new Response <T1>() { Request = Request, Result = t.Result }); BaseCmd.Success("Responses {0}.", Responses.Count); } } catch (Exception ex) { BaseCmd.Error("Request failed!\n{0}", ex.Message); } } }
public override void SaveDocuments(Share share, Schedulers.Task task) { var dateNow = DateTime.Now.ToString("yyyyMMddTHHmm"); foreach (var format in Formats) { var response = new Response(); var UNC = share.UNCPath + "_" + dateNow; // var UNC = share.UNCPath; var formatter = new EazystockForecastFormatter(format); if (formatter.saveContent(UNC)) { response.Code = 201; response.Description = "Created"; response.Detail = UNC + " was saved succesfully"; } else { response.Code = 400; response.Description = "Bad Request"; response.Detail = "There was an error when saving " + UNC; } Responses.Add(response); } }
public PagesExecuter GetPageDetails(int pageId) { Responses.Add(Connector.GetContent( "API/PersonaBar/Pages/GetPageDetails?pageId=" + pageId)); return(this); }
protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { Requests.Add(request); if (!RequestHandlers.Any()) { return(Task.FromResult <HttpResponseMessage>(null)); } var count = Responses.Count(); if (RequestHandlers.Count() > count) { var response = RequestHandlers.Skip(count).First().Invoke(request); Responses.Add(response); return(Task.FromResult(response)); } if (RepeatLastHandler) { var response = RequestHandlers.Last().Invoke(request); Responses.Add(response); return(Task.FromResult(response)); } Assert.Fail("Not enough handlers defined for this test and RepeatLastHandler set to false."); return(Task.FromResult <HttpResponseMessage>(null)); }
private void Validate() { StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading"); Data.ValidationMessage = string.Empty; Data.IsResultsVisible = false; if (Data.ValidateSqlDetails()) { if (!Data.IsDatabasesVisible) { Data.IsDatabasesVisible = BindDatabases(); OnPropertyChanged("Databases"); Data.SelectedDatabase = "0"; } else if (Data.IsDatabasesVisible) { Data.UpdateConnectionString(); Responses.Clear(); Responses.Add(DiagnosticsService.CheckSqlPermission(Data)); Responses.Add(DiagnosticsService.CheckGPeConnect(Data)); Responses.Add(DiagnosticsService.CheckWebServicesRunning(Data)); Responses.Add(DiagnosticsService.CheckCloudIsRunning(Data)); Responses.Add(DiagnosticsService.CheckSubscription(Data)); //Responses.Add(DiagnosticsService.CheckMagentoIsRunning(Data)); //Responses.Add(DiagnosticsService.CheckMagentoConnectorIsRunning(Data)); Data.IsResultsVisible = true; DiagnosticsService.SaveToDatabase(Responses, validationId); } } StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus"); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IDataService dataService) { _dataService = dataService; AddUrlCommand = new RelayCommand(() => { Urls.Add(URL); URL = string.Empty; MessageBox.Show("URL added"); }); StartRequestsCommand = new RelayCommand(() => { var ds = (_dataService as DataService); ds.SetCallback(observable => { _onNextSubscription = observable.ObserveOn(DispatcherScheduler.Current). Subscribe(resp => Responses.Add(resp), ex => { MessageBox.Show(ex.Message); MessageBox.Show("Completed with error"); Cleanup(); }, () => { MessageBox.Show("Completed"); Cleanup(); }); }); ds.GetData(_urls, null); }); }
public RouteSpecBuilder WithResponse(JSchema schema, HttpStatusCode statusCode = HttpStatusCode.OK, string contentType = "application/json") { var statusCodeNum = (int)statusCode; var response = new RouteSpecResponse(contentType, statusCodeNum.ToString(), schema, new List <string>()); Responses.Add(response); return(this); }
public async Task WriteAsync(T message) { Responses.Add(message); if (OnWriteAsync != null) { await OnWriteAsync(message); } }
public void Get() { var result = _client.Get(); if (result != null) { Responses.Add(result); } }
public GetMockTransport(string queryKey, string label, ConfigurationSetting result, params HttpStatusCode[] statusCodes) : this(queryKey, label, result) { Responses.Clear(); foreach (var statusCode in statusCodes) { Responses.Add(statusCode); } }
public async Task GetAsync() { var result = await _client.GetAsync(); if (result != null) { Responses.Add(result); } }
public GetMockTransport(string queryKey, SettingFilter filter, params HttpStatusCode[] statusCodes) : this(queryKey, filter, result : null) { Responses.Clear(); foreach (var statusCode in statusCodes) { Responses.Add(statusCode); } }
protected virtual int GetAndStoreResponse() { int result = 0; while (_rxData.Count > 0) { char[] buffer; if (_rxData.TryDequeue(out buffer)) { if (_responseDoing == null) { _responseDoing = new GrblResponse(); } _responseDoing.SetContent(new string(buffer)); if (_responseDoing.IsFinished) { if (_requestDoing != null) { if (_requestDoing.IsRequestType(GrblRequestEnum.CurrentStatus)) { if (_responseDoing.IsResponseType(GrblResponseEnum.Status)) { _responseDoing.SetRequest(_requestDoing); _requestDoing.SetResponse(_responseDoing); } else if (_tempRequestDoing != null) { _responseDoing.SetRequest(_tempRequestDoing); _tempRequestDoing.SetResponse(_responseDoing); } } else { _responseDoing.SetRequest(_requestDoing); _requestDoing.SetResponse(_responseDoing); } if (_requestDoing.IsFinished) { RequestsDone.Add(_requestDoing); if (_tempRequestDoing != null && _tempRequestDoing.IsFinished) { RequestsDone.Add(_tempRequestDoing); _tempRequestDoing = null; } _requestDoing = _tempRequestDoing; _tempRequestDoing = null; } } result++; Responses.Add(_responseDoing); _responseDoing = null; } } } return(result); }
public void MergeMeetingTime(Response response) { // if response times are within current times, can be merged if (Start <= response.StartDateTime && response.EndDateTime <= End) { Start = response.StartDateTime; End = response.EndDateTime; Responses.Add(response); } }
public RemoteConnection(GetUsbDeviceHandler getDevice) { getUsbHandler = getDevice; socket.Options.AddSubProtocol("chat"); for (int i = 0; i < 256; i++) { Responses.Add(i, null); } }
public RestRouteMetadata SendsData(int statusCode, string description, object schema = null) { Responses.Add(new ResponseData { StatusCode = statusCode, Description = description, Schema = schema }); return(this); }
private bool ReadResponseAsync() { try { if (_socket == null) { return(false); } var result = _socket.Receive(_socketBuffer); _messageBuffer.Add(_socketBuffer, result); var messages = _messageBuffer.GetMessages(); foreach (var message in messages) { try { var token = message.AsJToken() as dynamic; LogManager.Write("Debugger Response: " + message, LogLevel.Verbose); if (message.Contains("\"type\":\"tabNavigated\"")) { BrowserHasNavigated = message.Contains("\"state\":\"stop\""); continue; } if (message.Contains("document.location.href")) { BrowserHasNavigated = true; } Responses.Add(token); } catch { LogManager.Write("Invalid message! -> " + messages, LogLevel.Fatal); } } return(true); } catch (ObjectDisposedException) { return(false); } catch (SocketException) { return(false); } catch (Exception ex) { LogManager.Write(ex.Message, LogLevel.Fatal); return(false); } }
void SortResponses() { var ordered = (from r in Responses orderby r.Title select r).ToList(); Responses.Clear(); // Foreach since there are no AddRange on ObservableCollections foreach (var r in ordered) { Responses.Add(r); } }
public string Run(string shellCmd) { Called++; Commands.Add(shellCmd); if (!ShellCmdResponses.ContainsKey(shellCmd)) { return(string.Empty); } var response = ShellCmdResponses[shellCmd]; Responses.Add(response); return(response); }
void AddNewMorality(object sender, EventArgs e) { var moralityToAdd = ((ComboBoxItem)ToAdd.SelectedItem).Name; if (moralityToAdd == null) { return; } int newMoralityNumber = 1; // Set it to one in case there aren't any var previousChoice = Scenarios .Where(scenario => scenario.Name.Contains(moralityToAdd)) .ToList(); // If there already are choices if (previousChoice.Count() != 0) { var previousMoralityNumber = previousChoice .Select(scenario => scenario.Name) .Last() .Remove(0, moralityToAdd.Length + 1); // + 1 to remove the underscore as well newMoralityNumber = int.Parse(previousMoralityNumber) + 1; } var newScene = Scenario.CreateEmpty(moralityToAdd, newMoralityNumber); var response = Responses.FirstOrDefault(r => r.Title.ToLower() == newScene.Name.ToLower()); if (response == null) { response = Response.CreateEmpty(moralityToAdd, newMoralityNumber); } SelectedScene = newScene; Scenarios.Add(newScene); Responses.Add(response); SortResponses(); }
public void SubmitContentResponse(ChallengeResponseModel challengeResponse = null) { if (challengeResponse != null) { Responses.Add(challengeResponse); } Challenge.CompletedCount = CompletedCount + (challengeResponse.ResponseCode > 0 ? 1 : 0); if (Responses.Count < ImagesAttach.Count && challengeResponse.ResponseMessage != "You completed that challenge!") { return; } /* * var errorResponces = Responses.FindAll((x) => x.ResponseCode <= 0); * if (errorResponces?.Count > 0) * { * string message = String.Empty; * int count = 0; * foreach (var item in errorResponces) * { * message += $"{(++count).ToString()}) {item.ResponseMessage} \n\n"; * } * new UIAlertView("Some images are not added", message, new UIAlertViewDelegate() as IUIAlertViewDelegate, "Ok").Show(); * } */ if (PosteringOverlay != null) { PosteringOverlay.RemoveFromSuperview(); PosteringOverlay = null; Platform.AnimateRotationComplete(Spinner); Spinner.RemoveFromSuperview(); Spinner = null; } if (CompletedCount >= TargetCount)//max responce { SubmitChallengeComplete(btnSubmitChallenge, challengeResponse); } else { SubmitChallengeComplete(btnSubmitChallenge, null);//remove overlay && animation } Responses.Clear(); }
public SmsResponseMessage AddResponse(string smsNumber, string text) { var player = Players.SingleOrDefault(p => p.SmsNumber == smsNumber); if (player == null) { return(new SmsResponseMessage() { Success = false }); } var currentAnswer = CurrentAnswer(); if (currentAnswer == null) { return(new SmsResponseMessage() { Success = false, Body = "no answer to respond to" }); } var hasPlayerResponded = HasPlayerResponded(smsNumber, currentAnswer); if (hasPlayerResponded) { return(new SmsResponseMessage() { Success = false, Body = "you have already provided a response to this answer" }); } var isCorrect = IsResponseCorrect(CurrentAnswer(), text); var response = new Response(player.Id, CurrentAnswer().Id, CurrentAnswer().Weight, text, isCorrect, DateTime.Now); Responses.Add(response); return(new SmsResponseMessage() { Success = true, Body = "your response has been accepted" }); }
public async Task PingButton() { ErrorMessage = ""; Responses.Clear(); if (string.IsNullOrWhiteSpace(Address)) { return; } Ping pingSender = new Ping(); int count = PingCount == 0 ? 4 : PingCount; for (int i = 0; i < count; i++) { try { PingReply reply = await pingSender.SendPingAsync(Address); pingSender.Dispose(); if (reply.Status == IPStatus.TtlExpired || reply.Status == IPStatus.BadRoute || reply.Status == IPStatus.TimedOut || reply.Status == IPStatus.DestinationHostUnreachable || reply.Status == IPStatus.DestinationNetworkUnreachable) { ErrorMessage = "Address is unreachable. Please check internet connection."; break; } else { Responses.Add(new ResponseViewModel { IPAddress = reply.Address.ToString(), ResponseTime = reply.RoundtripTime.ToString() + "ms", ErrorMessage = reply.Status.ToString() }); } } catch (PingException ex) { ErrorMessage = ex.Message; break; } catch (Exception ex) { ErrorMessage = ex.Message; break; } } }
public KillerNonPlayableCharacter(NonPlayableCharacter nonPlayableCharacter) : base(nonPlayableCharacter) { Responses = nonPlayableCharacter.Responses; Responses.Remove(ConversationType.INVENTORY); Item knife = new Item("Knife"); Inventory.Add(knife); Responses.Add(ConversationType.INVENTORY, new RandomList <string> { "I am currently carrying the following: " + Inventory, "In my bag I have: " + Inventory, Inventory + " is all I have.", "I have :" + Inventory + ". And money ain't a problem." }); // Removes an item to make sure all characters have the same number of items //Inventory.RemoveAt(0); }
public void Respond(int responderId, List <int> responses) { if (Responses == null) { Responses = new List <Response>(); } var response = Responses?.FirstOrDefault(i => i.PlayerId == responderId); if (response != null) { Responses.Remove(response); } Responses.Add(new Response() { PlayerId = responderId, Responses = responses }); }
public void Consume(ReadOnlySequence <byte> buffer) { var responsePart = buffer.ToArray().BytesToText(0, (int)buffer.Length); _responseBuilder.Append(responsePart); if (_responseBuilder.Length >= CurrentExpectedResponseLength) { // assume currentExpectedRequestLength is length of all // requests when multiple are received at one time var combinedResponse = _responseBuilder.ToString(); var combinedLength = combinedResponse.Length; var startIndex = 0; var last = false; while (!last) { var request = combinedResponse.Substring(startIndex, CurrentExpectedResponseLength); startIndex += CurrentExpectedResponseLength; Responses.Add(request); CurrentState.Access.WriteUsing("consumeCount", 1); _responseBuilder.Clear(); // reuse if (startIndex + CurrentExpectedResponseLength > combinedLength) { //Received combined responses has a part of a response. // Should save the part and append to the next combined responses. last = true; _responseBuilder.Append(combinedResponse, startIndex, combinedLength - startIndex); } else { last = startIndex == combinedLength; } } } }
public KillerNonPlayableCharacter(Character character, Inventory inventory, Dictionary <ConversationType, RandomList <String> > responses, String title, int id) : base(character, inventory, responses, title, id) { // Removes an item to make sure all characters have the same number of items //Inventory.RemoveAt(0); // Add Killing Weapon Inventory.Add(new Item("Knife")); // Add Inventory Responses Responses.Remove(ConversationType.INVENTORY); String list = Inventory.ToString(); Responses.Add(ConversationType.INVENTORY, new RandomList <string> { "I am currently carrying the following " + list, "All I have is the following " + list, list + " are all the items I posses right now.", "I have " + list + ", and money ain't a problem." }); }
private async Task OnRunTasks() { var urls = new[] { "http://www.google.com", "http://www.microsoft.com", "http://www.stackexchange.com", "http://www.tripadvisor.com", "http://www.bbc.co.uk", "http://www.github.com", "http://www.fivethirtyeight.com", "http://www.youtube.com", "http://www.notavalidurl.xyz" }; Responses.Clear(); var progress = new Progress <string>(); progress.ProgressChanged += (s, e) => ProgressDisplay += "\r\n" + e; ProgressDisplay = $"{DateTime.Now:HH:mm:ss.fff} - Downloads started"; var responsesDict = await urls .ForEachAsyncThrottled(url => GetWebContent(url, progress), 3) .ConfigureAwait(true); ProgressDisplay += $"\r\n{DateTime.Now:HH:mm:ss.fff} - Downloads completed"; var sortedKeys = responsesDict.Keys.OrderBy(x => x).ToList(); foreach (var key in sortedKeys) { var output = responsesDict[key].Replace("\r", " ").Replace("\n", " ").Trim().Left(100); Responses.Add(new Tuple <string, string>(key, output)); } }