//studentBus model internal Models.Stud_BusModel.MapStudBusResp MapStudent2Bus(Models.Stud_BusModel.MapStudBusReq req) { Models.Stud_BusModel.MapStudBusResp rsp = new Models.Stud_BusModel.MapStudBusResp(); ITStud_Bus studBus; bool sall = true; APIErrors apiError = new APIErrors(); foreach (long entity in req.nEntityId) { studBus = _storage.MapStudent2Bus(req.nBusFKup, req.nBusFKdown, entity, req.nStopUp, req.nStopDown); if (studBus.n > 0) { } else { sall = false; } } if (!sall) { apiError.sErrorMessage = "Not all Mappings successful"; apiError.jErrorVal = 1000; } else { apiError.jErrorVal = 0; apiError.sErrorMessage = "Mappings successful"; } //Added Entity rsp.apiError = apiError; return(rsp); }
/// <summary> /// Perform simple actions based on the errors from the API /// </summary> /// <param name="errors"></param> public static APIErrors HandleErrors(List <string> errors) { APIErrors errorResponse = APIErrors.None; if (errors == null) { return(errorResponse); } foreach (string error in errors) { switch (error) { case "Could not authenticate. Username or password incorrect": //Disable buttons QuantConnectPlugin.Logged = false; SetButtonsState(false); //ProjectLoaded = false; RemoveCredentials(); errorResponse = APIErrors.NotLoggedIn; break; case "Time out on build request": errorResponse = APIErrors.CompileTimeout; break; default: errorResponse = APIErrors.CompileError; break; } } return(errorResponse); }
/// <summary> /// Read page from download, store in Content property /// </summary> /// <param name="tempfile"></param> private bool LoadPage(string tempfile) { if (tempfile == null) { return(false); } else { try { Content = File.ReadAllText(tempfile); File.Delete(tempfile); } catch (Exception e) { APIErrors.UnableToRetrieveDownload(e.Message); return(false); } return(true); } }
/// <summary>Download page from Wiki web site into temp file</summary> /// <returns>Temp file name</returns> private Boolean DownloadPage() { //var tempfile = Path.GetTempFileName(); var wikiClient = new WebClient(); wikiClient.Headers.Add("user-agent", $"{Botname} Contact: {Contact})"); var fullUrl = $"{this.ApIurl}{this.Parameters}"; try { //wikiClient.DownloadFile( fullUrl, tempfile ); this.Content = wikiClient.DownloadString(fullUrl); return(true); } catch (WebException e) { //tempfile = null; APIErrors.CannotAccessWiki(fullUrl, e.Message); } return(false); //return tempfile; }
internal Models.Stud_BusModel.updateStudBusResp updateStudBus(Models.Stud_BusModel.updateStudBusreq req) { Models.Stud_BusModel.updateStudBusResp rsp = new Models.Stud_BusModel.updateStudBusResp(); APIErrors apiError = new APIErrors(); ITStud_Bus studBus = _storage.GetBus2stud(req.nEntityId); if (studBus != null || studBus.n > 0) { studBus = _storage.updateStudBus(studBus, req.nEntityId, req.nBusFKup, req.nBusFKdown, req.nStopUp, req.nStopDown); } if (studBus.nBusFKup == req.nBusFKup && studBus.nBusFKdown == req.nBusFKdown && studBus.nStopUp == req.nStopUp && studBus.nStopDown == req.nStopDown) { apiError.jErrorVal = 0; apiError.sErrorMessage = "Mappings successful"; } else { apiError.sErrorMessage = "Not all Mappings successful"; apiError.jErrorVal = 1000; } rsp.apiError = apiError; return(rsp); }
/// <summary> /// Download page from Wiki web site into temp file /// </summary> /// <returns>Temp file name</returns> private async Task <string> DownloadPage() { string Tempfile = Path.GetTempFileName(); var wikiClient = new HttpClient(); // WebClient wikiClient = new WebClient(); var headers = wikiClient.DefaultRequestHeaders; //headers.Add("user-agent", BOTNAME + " Contact: " + CONTACT + ")"); string fullURL = APIurl + Parameters; //Windows.Web.Http.HttpResponseMessage httpResponse = new Windows.Web.Http.HttpResponseMessage(); string httpResponseBody = ""; try { //Send the GET request var httpResponse = await wikiClient.GetAsync(fullURL); httpResponse.EnsureSuccessStatusCode(); httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); } catch (Exception ex) { httpResponseBody = "Error: " + ex.HResult.ToString("X") + " Message: " + ex.Message; } try { //wikiClient.DownloadFile(fullURL, Tempfile); } catch (WebException e) { Tempfile = null; APIErrors.CannotAccessWiki(fullURL, e.Message); } return(Tempfile); }
/// <summary> /// Constructor from a custom exception. /// </summary> /// <param name="error"></param> /// <param name="message"></param> public APIResult(APIErrors error, string message) { m_error = error; m_errorMessage = message; }
/// <summary> /// Constructor from an XML serialization exception wrapped into an InvalidOperationException /// </summary> public APIResult(InvalidOperationException exc) { m_error = APIErrors.Xml; m_errorMessage = (exc.InnerException == null ? exc.Message : exc.InnerException.Message); }
/// <summary> /// Constructor from an XSLT exception /// </summary> public APIResult(System.Xml.Xsl.XsltException exc) { m_error = APIErrors.Xslt; m_errorMessage = exc.Message; }
/// <summary> /// Constructor from an XML exception /// </summary> public APIResult(XmlException exc) { m_error = APIErrors.Xml; m_errorMessage = exc.Message; }
/// <summary> /// Constructor from an http exception /// </summary> public APIResult(HttpWebServiceException exc) { m_error = APIErrors.Http; m_errorMessage = exc.Message; }
/// <summary> /// Default constructor. /// </summary> public APIResult() { m_error = APIErrors.None; m_errorMessage = ""; }