/// <summary> /// Makes a PUT request and update the resource for the given URL and a request body. /// </summary> /// <param name="url">Service URL passed by the user.</param> /// <param name="parameters">The parameters contains the query string parameters in the form of key, value pair.</param> /// <param name="requestBody">It contains the request body parameters to make the POST request.</param> /// <param name="attachment">It contains the files to attach or post for the requested URL.</param> /// <returns>HttpResponseMessage which contains the data in the form of JSON.</returns> /// <exception cref="BooksException">Throws the Exception with error messege return from the server.</exception> public static HttpResponseMessage put(string url, Dictionary <object, object> parameters, Dictionary <object, object> requestBody, KeyValuePair <string, string> attachment) { var client = getClient(); var boundary = DateTime.Now.Ticks.ToString(); client.DefaultRequestHeaders.Add("Accept", "application/json"); MultipartFormDataContent content = new MultipartFormDataContent(boundary); foreach (var requestBodyParam in requestBody) { content.Add(new StringContent(requestBodyParam.Value.ToString()), requestBodyParam.Key.ToString()); } if (attachment.Value != null) { string _filename = Path.GetFileName(attachment.Value); FileStream fileStream = new FileStream(attachment.Value, FileMode.Open, FileAccess.Read, FileShare.Read); StreamContent fileContent = new StreamContent(fileStream); content.Add(fileContent, attachment.Key, _filename); } var responce = client.PutAsync(getQueryString(url, parameters), content).Result; if (responce.IsSuccessStatusCode) { return(responce); } else { throw new BooksException(ErrorParser.getErrorMessage(responce)); } }
protected override ClaimsIdentity GetOutputClaimsIdentity(ClaimsPrincipal principal, RequestSecurityToken request, Scope scope) { if (principal == null) { throw new InvalidRequestException("The caller's principal is null."); } AppStsConfig cfg = SecurityTokenServiceConfiguration as AppStsConfig; if (cfg == null) { throw new InvalidOperationException("SecurityTokenServiceConfiguration should be AppStsConfig"); } if (!principal.Identity.IsAuthenticated || principal.Identity.Name == null) { throw new UnauthorizedAccessException("User is not authorized."); } try { IPersonService svc = cfg.ServiceProvider.GetService <IPersonService>(); PersonInfo info = svc.Read(principal.Identity.Name).Result; return(SecurityManager.CreateIdentity(principal.Identity.AuthenticationType, info)); } catch (Exception ex) { ErrorParser errorParser = cfg.ServiceProvider.GetService <ErrorParser>(); ErrorList errors = errorParser.FromException(ex); throw new RequestFailedException(errors.ErrorsText, ex); } }
// GET: Register public async Task <ActionResult> Fan() { if (Sessions.isAuthenticated(Request, Session)) { int sessionRol = Int32.Parse(Session["rol"].ToString()); if (Sessions.isBand(sessionRol)) { return(RedirectToAction("Index", "Bands", new { area = "Bands", userId = Session["id"] })); } else if (Sessions.isFan(sessionRol)) { return(RedirectToAction("Index", "Fans", new { area = "Fans", userId = Session["id"] })); } else { return(HttpNotFound()); } } string response = await clsRegisterRequests.GetRegisterFanForm(); string ParsedMessage = ErrorParser.parse(response); //Hubo error if (!ParsedMessage.Equals("")) { ViewBag.Message = ParsedMessage; return(RedirectToAction("Index")); } Form formModel = DataParser.parseFanForm(response); return(View(formModel)); }
public async Task <ActionResult> Edit(int userId) { string response = await clsFanRequests.GetFanBands(userId); //Hubo error if (!ErrorParser.parse(response).Equals("")) { ViewBag.Message = "F**k my life2..."; } FanProfileViewModel profile = DataParser.parseFanBands(response); string response2 = await clsRegisterRequests.GetRegisterFanForm(); string ParsedMessage = ErrorParser.parse(response2); profile.EditForm = DataParser.parseFanForm(response2); string response3 = await clsFanRequests.GetFanInfo(userId); profile.Info = DataParser.parseFanInfo(response3); try { profile.Id = Int32.Parse(Session["Id"].ToString()); profile.Username = Session["Username"].ToString(); profile.Name = Session["Name"].ToString(); } catch (NullReferenceException) { //Not logged in ViewBag.Message = "Please log in first"; return(View("~/Views/Login/Index.cshtml")); } return(View(profile)); }
// GET: Bands/News public async Task <ActionResult> Index(int userId, int id) { System.Diagnostics.Debug.WriteLine("check band from " + userId + " with new " + id); string response = await clsBandRequests.getBandAlbums(userId); string response2 = await clsNewRequests.GetNew(userId, id); System.Diagnostics.Debug.WriteLine("antes de parsear " + response2); if (!ErrorParser.parse(response2).Equals("")) { ViewBag.Message = "Couldn´t get the news correctly"; } BandProfileViewModel profile = new BandProfileViewModel(); profile.Id = Int32.Parse(Session["Id"].ToString()); profile.Username = Session["Username"].ToString(); profile.Name = Session["Name"].ToString(); profile.Albums = DataParser.parseAlbums(response); profile.New = DataParser.parseNew(response2); return(View(profile)); }
public override ReadOnlyCollection <ClaimsIdentity> ValidateToken(SecurityToken token) { if (!(token is UserNameSecurityToken userNameToken)) { throw new SecurityTokenException("The security token is not a valid username security token."); } if (DI.DefaultServiceProvider == null) { throw new InvalidOperationException("Default service provider is not initialized."); } try { IPersonService svc = DI.DefaultServiceProvider.GetService <IPersonService>(); var credentials = new Credentials() { Email = userNameToken.UserName, Password = userNameToken.Password }; Task.Run(async() => await svc.AuthenticateAsync(credentials)).Wait(); ClaimsIdentity identity = new ClaimsIdentity(AuthenticationTypes.Password); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, userNameToken.UserName)); identity.AddClaim(new Claim(ClaimTypes.Name, userNameToken.UserName)); return(Array.AsReadOnly(new[] { identity })); } catch (Exception ex) { ErrorParser errorParser = DI.DefaultServiceProvider.GetService <ErrorParser>(); ErrorList errors = errorParser.FromException(ex); throw new SecurityTokenException(errors.ErrorsText, ex); } }
public async Task <ActionResult> NewNoticia(string NewTitle, string inputContent) { System.Diagnostics.Debug.WriteLine(NewTitle); System.Diagnostics.Debug.WriteLine(inputContent); clsNew form = new clsNew(); form.Title = NewTitle; form.Content = inputContent; string response = await clsNewRequests.PostNewForm(form, Int32.Parse(Session["Id"].ToString())); if (!ErrorParser.parse(response).Equals("")) { ViewBag.Message = "Couldn´t get the news correctly"; } System.Diagnostics.Debug.WriteLine(response); int Id = DataParser.parseNewForm(response); System.Diagnostics.Debug.WriteLine("Got id: " + Id); return(Json(new { redirectUrl = Url.Action("Index", "News", new { userId = Int32.Parse(Session["Id"].ToString()), id = Id }), isRedirect = true })); }
public response Validare() { bool succes; response toReturn = Validator.Validate(authenticatedUserId, connectionString, this, _TABLE_NAME, out succes); Error err = new Error(); if (!succes) // daca nu s-au putut citi validarile din fisier, sau nu sunt definite in fisier, mergem pe varianta hardcodata { toReturn = new response(true, "", null, null, new List <Error>());; if (this.NR_DOCUMENT == null || this.NR_DOCUMENT.Trim() == "") { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyNrDocumentPlata"); toReturn.Message = string.Format("{0}{1};", toReturn.Message ?? "", err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } if (this.DATA_DOCUMENT == null) { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyDataDocumentPlata"); toReturn.Message = string.Format("{0}{1};", toReturn.Message ?? "", err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } if (this.SUMA == null) { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptySumaPlata"); toReturn.Message = string.Format("{0}{1};", toReturn.Message ?? "", err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } if (this.ID_DOSAR == null) { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyIdDosarPlata"); toReturn.Message = string.Format("{0}{1};", toReturn.Message ?? "", err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } if (this.ID_TIP_PLATA == null) { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyIdTipPlata"); toReturn.Message = string.Format("{0}{1};", toReturn.Message ?? "", err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } } if (this.ID_DOSAR != null && !((Dosar)this.GetDosar().Result).IsAvizat()) { toReturn.Status = false; err = ErrorParser.ErrorMessage("dosarNeavizat"); toReturn.Message = string.Format("{0}{1};", toReturn.Message ?? "", err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } return(toReturn); }
/// <summary> /// Gets the file data for the given GET request . /// </summary> /// <param name="url">Service URL passed by the user.</param> /// <param name="parameters">The parameters contains the query string parameters in the form of key, value pair.</param> /// <exception cref="BooksException">Throws the Exception with error messege return from the server.</exception> public static void getFile(string url, Dictionary <object, object> parameters) { var client = getClient(); client.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); var responce = client.GetAsync(getQueryString(url, parameters)).Result; if (responce.IsSuccessStatusCode) { var contentDisposition = responce.Content.Headers.ContentDisposition.ToString(); const string contentFileNamePortion = "filename=\""; var fileNameStartIndex = contentDisposition.IndexOf(contentFileNamePortion, StringComparison.InvariantCulture) + contentFileNamePortion.Length; var originalFileNameLength = contentDisposition.Length - fileNameStartIndex - 1; var filename = contentDisposition.Substring(fileNameStartIndex, originalFileNameLength); var fileStream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); responce.Content.CopyToAsync(fileStream); fileStream.Close(); Process.Start(filename); } else { throw new BooksException(ErrorParser.getErrorMessage(responce)); } }
public response Validare() { response toReturn = new response(true, "", null, null, new List <Error>());; Error err = new Error(); if (this.NR_SENTINTA == null || this.NR_SENTINTA.Trim() == "") { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyNrSentinta"); toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } if (this.DATA_SENTINTA == null || this.DATA_SENTINTA == new DateTime()) { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyDataSentinta"); toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } /* * if (this.ID_SOLUTIE == null || this.ID_SOLUTIE <= 0) * { * toReturn.Status = false; * err = ErrorParser.ErrorMessage("emptySolutieSentinta"); * toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); * toReturn.InsertedId = null; * toReturn.Error.Add(err); * } */ return(toReturn); }
public async Task <ActionResult> Index(int userId) { if (Sessions.isAuthenticated(Request, Session)) { int sessionRol = Int32.Parse(Session["rol"].ToString()); if (!Sessions.isFan(sessionRol)) { return(View("~/Views/Login/Index.cshtml")); } } //[Bandas,Posts] List <string> response = await clsFanRequests.GetFanProfile(userId); //Hubo error if (!ErrorParser.parse(response[0]).Equals("") || !ErrorParser.parse(response[1]).Equals("")) { ViewBag.Message = "F**k my life..."; } FanProfileViewModel profile = DataParser.parseFanProfile(response); try { profile.Id = Int32.Parse(Session["Id"].ToString()); profile.Username = Session["Username"].ToString(); profile.Name = Session["Name"].ToString(); } catch (NullReferenceException) { //Not logged in ViewBag.Message = "Please log in first"; return(View("~/Views/Login/Index.cshtml")); } return(View(profile)); }
// GET: Bands/Albums public async Task <ActionResult> Index(int userId, int Id) { //System.Diagnostics.Debug.WriteLine("check band from " + userId + " with album " + Id); string response = await clsBandRequests.getBandAlbums(userId); //System.Diagnostics.Debug.WriteLine("Soy yo 1: " + response); string response2 = await clsAlbumRequests.GetAlbumInfo(userId, Id); //System.Diagnostics.Debug.WriteLine("Soy yo: " + response2); //Hubo error if (!ErrorParser.parse(response).Equals("")) { ViewBag.Message = "F**k my life..."; } BandProfileViewModel profile = new BandProfileViewModel(); profile.Id = Int32.Parse(Session["Id"].ToString()); profile.Username = Session["Username"].ToString(); profile.Name = Session["Name"].ToString(); profile.Albums = DataParser.parseAlbums(response); profile.Disk = DataParser.parseDisk(response2); return(View(profile)); }
public async Task <ActionResult> NewSong(int albumId, string Name, string Duration, bool Live, bool LimitedEdition, string UrlVideo) { /* System.Diagnostics.Debug.WriteLine(albumId); * System.Diagnostics.Debug.WriteLine(Name); * System.Diagnostics.Debug.WriteLine(Live); * System.Diagnostics.Debug.WriteLine(Duration); * System.Diagnostics.Debug.WriteLine(LimitedEdition); * System.Diagnostics.Debug.WriteLine(UrlVideo);*/ clsSong form = new clsSong(); form.Duration = Duration; form.Link = UrlVideo; form.Name = Name; form.LimitedEdition = LimitedEdition; form.Type = Live; string response = await clsAlbumRequests.PostSongForm(form, Int32.Parse(Session["Id"].ToString()), albumId); if (!ErrorParser.parse(response).Equals("")) { ViewBag.Message = "F**k my life..."; } return(Json(form)); }
/// <summary> /// Makes a POST request and creates a resource for the given URL and a request body. /// </summary> /// <param name="url">Service URL passed by the user.</param> /// <param name="requestBody">It contains the request body parameters to make the POST request.</param> /// <returns>HttpResponseMessage which contains the data in the form of JSON .</returns> /// <exception cref="BooksException">Throws the Exception with error messege return from the server.</exception> public static HttpResponseMessage post(string url, Dictionary <object, object> requestBody) { Console.WriteLine("ZohoHttpClient.post:{0}", url); var client = getClient(); List <KeyValuePair <string, string> > contentBody = new List <KeyValuePair <string, string> >(); foreach (var requestbodyParam in requestBody) { Console.WriteLine("{0} => {1}", requestbodyParam.Key.ToString(), requestbodyParam.Value.ToString()); var temp = new KeyValuePair <string, string>(requestbodyParam.Key.ToString(), requestbodyParam.Value.ToString()); contentBody.Add(temp); } var content = new ZohoFormUrlEncodedContent(contentBody); try { var responce = client.PostAsync(url, content).Result; if (responce.IsSuccessStatusCode) { return(responce); } else { throw new BooksException(ErrorParser.getErrorMessage(responce)); } } catch (HttpRequestException ex) { throw new BooksException(String.Format("Error posting data to {0}", url), ex); } }
public response Validare() { bool succes; response toReturn = Validator.Validate(authenticatedUserId, connectionString, this, _TABLE_NAME, out succes); if (!succes) // daca nu s-au putut citi validarile din fisier, sau nu sunt definite in fisier, mergem pe varianta hardcodata { toReturn = new response(true, "", null, null, new List <Error>());; Error err = new Error(); if (this.NAME == null || this.NAME.Trim() == "") { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyNumeActiune"); toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } if (this.ACTION == null || this.ACTION.Trim() == "") { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyAction"); toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } } return(toReturn); }
public response Validare() { bool succes; response toReturn = Validator.Validate(authenticatedUserId, connectionString, this, _TABLE_NAME, out succes); if (!succes) // daca nu s-au putut citi validarile din fisier, sau nu sunt definite in fisier, mergem pe varianta hardcodata { toReturn = new response(true, "", null, null, new List <Error>()); Error err = new Error(); if (String.IsNullOrWhiteSpace(this.NR_CONTRACT)) { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyNrContract"); toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } if (this.DATA_CONTRACT == null) { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyDataContract"); toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } } return(toReturn); }
public async Task <ActionResult> GetBandStats(int fanId, int bandId) { System.Diagnostics.Debug.WriteLine(fanId + " unfollwing " + bandId); if (Sessions.isAuthenticated(Request, Session)) { string response = await clsFanRequests.GetBandStats(fanId, bandId); System.Diagnostics.Debug.WriteLine(response); string ParsedMessage = ErrorParser.parse(response); if (!ParsedMessage.Equals("")) { ViewBag.Message = "Something went wrong"; return(Json("")); } string j = DataParser.parseResponse(response).Data; //return Json(j); return(Json(new { Followers = 1200000, Calification = 5 })); } else { return(View("~/Views/Login/Index.cshtml")); } }
public static async ValueTask <ATResult <PinStatusResult> > GetPinStatusAsync( this ICommunicator <string> comm, ResponseFormat responseFormat, CancellationToken cancellationToken = default) { await comm.Write($"AT+CPIN?\r", cancellationToken); var message = await comm.ReadSingleMessageAsync(Constants.BYTE_LF, cancellationToken); if (PinStatusParser.TryParse(message, responseFormat, out ATResult <PinStatusResult> pinResult)) { message = await comm.ReadSingleMessageAsync(Constants.BYTE_LF, cancellationToken); if (OkParser.TryParse(message, responseFormat, out ATResult <OkResult> _)) { return(pinResult); } else if (ErrorParser.TryParse(message, responseFormat, out ATResult <ErrorResult> errorResult)) { return(ATResult.Error <PinStatusResult>(errorResult.ErrorMessage)); } } else if (ErrorParser.TryParse(message, responseFormat, out ATResult <ErrorResult> errorResult)) { return(ATResult.Error <PinStatusResult>(errorResult.ErrorMessage)); } return(ATResult.Error <PinStatusResult>(Constants.PARSING_FAILED)); }
protected override void Save(object sender, EventArgs e) { DetailsViewModel dvm = Model as DetailsViewModel; AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject; try { dvm.Save(sender, e); if (dvm.Errors != null && dvm.Errors.HasErrors()) { return; } PersonInfo userInfo = dvm.ServiceProvider.GetService <IPersonService>().Read(authObj.EmailProperty.Value).Result; ClaimsIdentity ci = SecurityManager.CreateIdentity(AuthenticationTypes.Password, userInfo); Thread.CurrentPrincipal = new ClaimsPrincipal(ci); MainView.Start(); Close(); } catch (Exception ex) { ErrorParser ep = dvm.ServiceProvider.GetService <ErrorParser>(); ErrorList errors = ep.FromException(ex); ErrorPresenter.Show(errors); } }
public async Task <ActionResult> UpdateProfile(string inputName, string inputDateCreation, string inputHashtag, int selectCountry, List <int> selectGenres, List <string> inputMembers, string inputBiography, string profilePicture) { if (Sessions.isAuthenticated(Request, Session)) { PostRegisterBandForm form = new PostRegisterBandForm(); form.Name = inputName; form.DateCreation = inputDateCreation; form.Hashtag = inputHashtag; form.Country = selectCountry; form.Genres = selectGenres; form.Members = inputMembers; form.Biography = inputBiography; form.Picture = profilePicture; string response = await clsBandRequests.UpdateProfile((int)Session["Id"], form); System.Diagnostics.Debug.WriteLine("form posted", response); string ParsedMessage = ErrorParser.parse(response); if (!ParsedMessage.Equals("")) { ViewBag.Message = ParsedMessage; } Session["Name"] = form.Name; return(RedirectToAction("Edit", "Bands", new { area = "Bands", userId = Session["id"] })); } else { return(View("~/Views/Login/Index.cshtml")); } }
public async Task <ActionResult> Edit(int userId) { string response = await clsBandRequests.GetBandInfo(userId); //Hubo error if (!ErrorParser.parse(response).Equals("")) { ViewBag.Message = "F**k my life..."; } System.Diagnostics.Debug.WriteLine(response); string response2 = await clsRegisterRequests.GetRegisterBandForm(); string ParsedMessage = ErrorParser.parse(response2); string response3 = await clsBandRequests.getBandAlbums(userId); BandProfileViewModel profile = new BandProfileViewModel(); profile.Id = Int32.Parse(Session["Id"].ToString()); profile.Username = Session["Username"].ToString(); profile.Name = Session["Name"].ToString(); profile.Info = DataParser.parseBandInfo(response); profile.EditForm = DataParser.parseBandForm(response2); profile.Albums = DataParser.parseAlbums(response3); return(View(profile)); }
/// <summary> /// Metoda pentru validarea Utilizatorului curent /// </summary> /// <returns>SOCISA.response = new object(bool = status, string = error message, int = id-ul cheie returnat)</returns> public response Validare() { response toReturn = new response(true, "", null, null, new List <Error>());; Error err = new Error(); if (this.USER_NAME == null || this.USER_NAME.Trim() == "") { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyUserName"); toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } if (this.PASSWORD == null || this.PASSWORD.Trim() == "") { toReturn.Status = false; err = ErrorParser.ErrorMessage("emptyUserPassword"); toReturn.Message = string.Format("{0}{1};", toReturn.Message == null ? "" : toReturn.Message, err.ERROR_MESSAGE); toReturn.InsertedId = null; toReturn.Error.Add(err); } return(toReturn); }
/// <summary> /// Performs asynchronous search with the current criteria and populates the list. /// </summary> /// <param name="preserveSelection">A flag indicating whether or not to preserve selection.</param> /// <param name="token">Cancellation token.</param> /// <returns>True on success, false in case of errors.</returns> public virtual async Task <bool> SearchAsync(bool preserveSelection, CancellationToken token = default) { if (List == null) { return(false); } try { List.Validate(true); ErrorList msgList = List.GetValidationErrors(); msgList.AbortIfHasErrors(); var res = await List.ReadAsync(new DataObject.CrudOptions { PreserveSelection = preserveSelection }, token); msgList.MergeWith(res); Errors = msgList; return(!msgList.HasErrors()); } catch (Exception ex) { Errors = ErrorParser.FromException(ex); return(false); } }
/// <summary> /// Default constructor. /// </summary> public BaseService(IServiceProvider serviceProvider) { this.serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); currentErrors = serviceProvider.GetRequiredService <ErrorList>(); errorParser = serviceProvider.GetRequiredService <ErrorParser>(); operators = serviceProvider.GetService <OperatorRegistry>() ?? new OperatorRegistry(); currentPrincipal = serviceProvider.GetCurrentPrincipal(); }
public BooksException(HttpResponseMessage httpResponse) : base(ErrorParser.GetErrorMessage(httpResponse)) { Code = ErrorParser.GetErrorCode(httpResponse); if (!Data.Contains("Code")) { Data.Add("Code", Code); // Для совместимости } }
public void CheckForErrors_DoesNothing_WhenPassedNullResponse() { try { ErrorParser.CheckForErrors(null); Assert.IsTrue(true); } catch (Exception) { Assert.Fail(); } }
/// <summary> /// Constructs a new lookup table controller. /// </summary> /// <param name="errorList">An error list for the current errors.</param> /// <param name="errorParser">An injected error parser.</param> /// <param name="cacheProvider">An injected instance of the cache provider.</param> public LookupTableController(ErrorList errorList, ErrorParser errorParser, ILookupCacheProvider cacheProvider) : base(errorList, errorParser) { if (cacheProvider == null) { throw new ArgumentNullException(nameof(cacheProvider)); } globalCache = cacheProvider.GetLookupCache(LookupCache.Global); }
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { ErrorParser errorParser = Services.GetService <ErrorParser>(); IErrorPresenter errorPresenter = Services.GetService <IErrorPresenter>(); if (errorPresenter != null && errorParser != null) { e.Handled = true; errorPresenter.Show(errorParser.FromException(e.Exception)); } }
/// <summary> /// Make a DELETE request for the given URL and a query string. /// </summary> /// <param name="url">Service URL passed by the user.</param> /// <param name="parameters">The parameters contains the query string parameters in the form of key, value pair.</param> /// <returns>HttpResponseMessage which contains the data in the form of JSON.</returns> /// <exception cref="BooksException">Throws the Exception with error messege return from the server.</exception> public static HttpResponseMessage delete(string url, Dictionary <object, object> parameters) { var client = getClient(); var responce = client.DeleteAsync(getQueryString(url, parameters)).Result; if (responce.IsSuccessStatusCode) { return(responce); } throw new BooksException(ErrorParser.getErrorMessage(responce)); }
public void NextRound() { while ((int)SharedRefs.ReplayJson[SharedRefs.ReplayCursor]["gamestate"] != 2) { ++SharedRefs.ReplayCursor; if (ErrorParser.HandleErrorCheck(this)) { return; } } DoneAndGoBackToPreparation(); }