protected static string GetErrorMessageWithRequestIdInfo(Rest.Azure.CloudException cloudException) { if (cloudException == null) { throw new ArgumentNullException("cloudException"); } var sb = new StringBuilder(); if (!string.IsNullOrEmpty(cloudException.Message)) { sb.Append(cloudException.Message); } if (cloudException.Response == null) { return sb.ToString(); } if (cloudException.Response.StatusCode.Equals(HttpStatusCode.OK) && cloudException.Response.Content != null) { var errorReturned = JsonConvert.DeserializeObject<ComputeLongRunningOperationError>( cloudException.Response.Content); sb.AppendLine().AppendFormat("StartTime: {0}", errorReturned.StartTime); sb.AppendLine().AppendFormat("EndTime: {0}", errorReturned.EndTime); sb.AppendLine().AppendFormat("OperationID: {0}", errorReturned.OperationId); sb.AppendLine().AppendFormat("Status: {0}", errorReturned.Status); if (errorReturned.Error == null) { return sb.ToString(); } sb.AppendLine().AppendFormat("ErrorCode: {0}", errorReturned.Error.Code); sb.AppendLine().AppendFormat("ErrorMessage: {0}", errorReturned.Error.Message); } else { sb.AppendLine().AppendFormat("StatusCode: {0}", cloudException.Response.StatusCode.GetHashCode()); sb.AppendLine().AppendFormat("ReasonPhrase: {0}", cloudException.Response.ReasonPhrase); if (cloudException.Response.Headers == null || !cloudException.Response.Headers.ContainsKey(RequestIdHeaderInResponse)) { return sb.ToString(); } var headers = cloudException.Response.Headers; var match = Regex.Match(headers.ToString(), @"x-ms-request-id: ([a-z0-9]{8}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{12})", RegexOptions.IgnoreCase); string operationId = (match.Success) ? match.Groups[1].Value : ""; sb.AppendLine().AppendFormat( "OperationID : '{0}'", operationId); } return sb.ToString(); }
/// <summary> /// The register. /// </summary> public async void Register() { await TryRegisterChannel(); var registration = new PushRegistration { InstallationId = Storage.GetInstallationId(), ChannelUri = channel.Uri }; var rest = new Rest(); rest.Post<dynamic>("api/push/register", registration); }
public ActionResult Create(Rest rest) { if (this.ModelState.IsValid) { db.CreateNewRest(rest); return RedirectToAction("Index"); } else return View(); }
protected static string GetErrorMessageWithRequestIdInfo(Rest.Azure.CloudException cloudException) { if (cloudException == null) { throw new ArgumentNullException("cloudException"); } var sb = new StringBuilder(); if (!string.IsNullOrEmpty(cloudException.Message)) { sb.Append(cloudException.Message); } if (cloudException.Response == null) { return sb.ToString(); } if (cloudException.Response.StatusCode.Equals(HttpStatusCode.OK) && cloudException.Response.Content != null) { var errorReturned = JsonConvert.DeserializeObject<PSNetworkLongRunningOperation>( cloudException.Response.Content); sb.AppendLine().AppendFormat("Status: {0}", errorReturned.Status); if (errorReturned.Error == null) { return sb.ToString(); } sb.AppendLine().AppendFormat("ErrorMessage: {0}", errorReturned.Error.Message); } else { sb.AppendLine().AppendFormat("StatusCode: {0}", cloudException.Response.StatusCode.GetHashCode()); sb.AppendLine().AppendFormat("ReasonPhrase: {0}", cloudException.Response.ReasonPhrase); if (cloudException.Response.Headers == null || !cloudException.Response.Headers.ContainsKey(RequestIdHeaderInResponse)) { return sb.ToString(); } string operationId = cloudException.RequestId; sb.AppendLine().AppendFormat( "OperationID : '{0}'", operationId); } return sb.ToString(); }
public ActionResult Edit(Rest rest) { if (this.ModelState.IsValid) { db.SaveRest(rest); return RedirectToAction("Index"); } else { return View(); } }
internal void SaveRest(Rest rest) { var oldRest = db.Rests.SingleOrDefault(x => x.Id == rest.Id); oldRest.Comment = rest.Comment; oldRest.CountOfChildren = rest.CountOfChildren; oldRest.Date = rest.Date; oldRest.GAI = rest.GAI; oldRest.Money = rest.Money; oldRest.NameTeacher = rest.NameTeacher; oldRest.NameTour = rest.NameTour; oldRest.NextTour = rest.NextTour; oldRest.NumberSchool = rest.NumberSchool; oldRest.PhoneNumber = rest.PhoneNumber; oldRest.Email = rest.Email; db.SaveChanges(); }
public void MapTo(Rest.Issue issue, IConnection connection) { issue.CommentsCount = GetInt32("commentsCount"); issue.Created = GetDateTime("created"); issue.Description = GetString("description", ""); issue.NumberInProject = GetInt32("numberInProject"); issue.Priority = GetString("priority"); issue.ProjectShortName = GetString("projectShortName"); issue.ReporterName = GetString("reporterName"); issue.State = GetString("state"); issue.Subsystem = GetString("subsystem"); issue.Summary = GetString("summary"); issue.Type = GetString("Type"); issue.Updated = GetDateTime("updated"); issue.UpdaterName = GetString("updaterName"); issue.VotesCount = GetInt32("votes"); issue.Comments = Comments.Select(c => c.GetComment(connection)); }
public IEnumerable<PSADApplication> GetApplicationWithFilters(Rest.Azure.OData.ODataQuery<Application> odataQueryFilter) { return GraphClient.Applications.List(odataQueryFilter).Select(a => a.ToPSADApplication()); }
private void EnqueueClient(Uri baseUri, Rest.Client connection) { ConcurrentQueue<Rest.Client> queue; if (!this._clients.TryGetValue(baseUri, out queue)) return; queue.Enqueue(connection); }
internal void CreateNewRest(Rest rest) { db.Rests.Add(rest); db.SaveChanges(); }
public virtual void MapTo(Rest.Project project) { project.Description = Description; project.Name = Name; project.ProjectLeadLogin = Lead; }
public async Task StartEmulation(Action<bool> action, DateTime date) { //DateTime timeUtc = DateTime.UtcNow; _simulationStart = date; _simulationEnd = _simulationStart.AddMonths(1); try { await Task.Run(() => { new Rest().GetRequest((ResultJson result) => { bool ret; _resultJson = result; Timezone _tz = new Rest().GetTimeZone(Host + "/api/tz?id=" + _currentUniversity.Timezone); // info about timezone DateTime _tz_university = UtcTimeToVenueTimeNodaTime(result.currentDateDate, _tz.Tz); DateTime _now = UtcTimeToVenueTimeNodaTime(result.currentDateDate, DateTimeZoneProviders.Tzdb.GetSystemDefault().ToString()); _currentDate = _tz_university.ToString("dd-MM-yyyy HH:mm"); // to university time zone _currentDateSTZ = _now.ToString("dd-MM-yyyy HH:mm"); // to local time zone _numberAddedStudents = result.new_students_number; _numberExpeltStudents = result.expel_students_number; _largestNumberOfIncoming = result.largest_number_of_incoming; if (result == null) { ret = false; } else { ret = true; } action(ret); RaisePropertyChanged("BindCurrentDate"); RaisePropertyChanged("BindCurrentDateSTZ"); RaisePropertyChanged("BindNumberAddedStudents"); RaisePropertyChanged("BindNumberExpeltStudents"); RaisePropertyChanged("BindLargestNumberOfIncoming"); RaisePropertyChanged("BindLargestNumberOfEntrants"); }, Host + "/api/emulation?startCompain=" + _startEntrance + "&endCompain=" + _endEntrance + "&start=" + _simulationStart + "&end=" + _simulationEnd); }); } catch (Exception e) { action(false); Console.WriteLine("ret false ======= " + e.ToString()); } }
/// <summary> /// Initializes a new instance of the <see cref="NewSlapsStore"/> class. /// </summary> /// <param name="settingsStore"> /// The settings Store. /// </param> public NewSlapsStore(ISettingsStore settingsStore) { this.settingsStore = settingsStore; this.rest = new Rest(); }
public IAsyncOperation<Rest.RestResponse> SendRestRequest(Rest.RestRequest request) { return Task.Run(async () => { var restRequest = JsonConvert.SerializeObject(request); var req = JsonConvert.DeserializeObject<RestRequest>(restRequest); var userAgent = await ApplicationInformationService.GenerateUserAgentHeaderAsync(true, _smartSync); req.AdditionalHeaders?.Add("User-Agent", userAgent); var response = await _syncManager.SendRestRequest(req); var restResponse = JsonConvert.SerializeObject(response); return JsonConvert.DeserializeObject<Rest.RestResponse>(restResponse); }).AsAsyncOperation(); }
public ComputeCloudException(Rest.Azure.CloudException ex) : base(GetErrorMessageWithRequestIdInfo(ex), ex) { }
public OandaAdapter(string accountUrl, string ratesUrl, string streamingRatesUrl, string streamingEventsUrl, string labsUrl, string token) { this.proxy = new Rest(accountUrl, ratesUrl, streamingRatesUrl, streamingEventsUrl, labsUrl, token); }
/// <summary> /// Initializes a new instance of the <see cref="SubscriptionStore"/> class. /// </summary> public SubscriptionStore() { this.rest = new Rest(); }