private void GetAllVipServices() { List <KeyValuePair <string, string> > paramlist = new List <KeyValuePair <string, string> >(); paramlist.Add(new KeyValuePair <string, string>("supplierID", supplier.SupplierID.ToString())); vips = WebCall.GetMethod <List <VIPDto> >(WebCall.GetVips, paramlist); dgVIP.DataSource = vips; }
public User GetMe() { var url = $"{baseUrl}/me"; var x = WebCall.GetRequestWithErrorHandling(url, this.authString); var t = JsonConvert.DeserializeObject <User>(x.Data); return(t); }
public List <Project> GetProjects() { var url = $"{baseUrl}/workspaces/{this.wid}/projects"; var x = WebCall.GetRequestWithErrorHandling(url, this.authString); var t = JsonConvert.DeserializeObject <List <Project> >(x.Data); return(t); }
public TimeEntry GetRunningTimer() { var x = WebCall.GetRequestWithErrorHandling($"{baseUrl}/time_entries/current", this.authString); var t = JsonConvert.DeserializeObject <TimeEntryData>(x.Data); var timeEntry = t.data; return(timeEntry); }
private void GetAllGuides() { List <KeyValuePair <string, string> > paramlist = new List <KeyValuePair <string, string> >(); paramlist.Add(new KeyValuePair <string, string>("supplierID", supplier.SupplierID.ToString())); guides = WebCall.GetMethod <List <GuideDto> >(WebCall.GetGuides, paramlist); dgGuides.DataSource = guides; }
private void GetProjectTypes() { projectTypes = WebCall.GetMethod <List <T_TravelProjectTypes> >(WebCall.GetTravelProjectTypes, null); foreach (T_TravelProjectTypes projectType in projectTypes) { cbxType.Items.Add(projectType.ProjectTypeName); } }
/// <summary> /// Получение json по url-адресу /// </summary> /// <param name="url">Адрес получения json</param> /// <returns>Строка в формате json</returns> public string GetJson(string url) { var separatorPosition = url.IndexOf('?'); var methodUrl = separatorPosition < 0 ? url : url.Substring(0, separatorPosition); var parameters = separatorPosition < 0 ? string.Empty : url.Substring(separatorPosition + 1); return(WebCall.MakeCall(methodUrl, _host, _port).Response); }
private void GetAllDrivers() { List <KeyValuePair <string, string> > paramlist = new List <KeyValuePair <string, string> >(); paramlist.Add(new KeyValuePair <string, string>("supplierID", supplier.SupplierID.ToString())); drivers = WebCall.GetMethod <List <DriverDto> >(WebCall.GetDrivers, paramlist); dgDrivers.DataSource = drivers; }
public Project GetProject(int projectId) { var url = $"{baseUrl}/projects/{projectId}"; var x = WebCall.GetRequestWithErrorHandling(url, this.authString); var t = JsonConvert.DeserializeObject <ProjectData>(x.Data); var proj = t.data; return(proj); }
static void Main(string[] args) { //New configuration object Config config = new Config(); //Get the URL from the appsettings string url = config.getConfig("url"); try { if ((args.Length != 2)) { Console.WriteLine(config.getConfig("argsError1")); Console.WriteLine(config.getConfig("argsError2")); Console.WriteLine(config.getConfig("argsError3")); Console.WriteLine(config.getConfig("argsError4")); Console.WriteLine(config.getConfig("argsError5")); } else { //Get the current folder string currentFolderPath = Directory.GetCurrentDirectory() + @"\"; //file name of the json string nameFile = args[0]; string completeFilePath = currentFolderPath + nameFile; //validate that the file exist in the current folder if (File.Exists(completeFilePath)) { //Reading the Json File. var readFile = new StreamReader(completeFilePath); var fileJson = readFile.ReadToEnd(); //Make the RestApi call WebCall restApiCall = new WebCall(url, fileJson); Console.Write(config.getConfig("callingMsg")); //Get the response string jsonOutPut = restApiCall.callWebResApi(); //Write the json object in the file. File.WriteAllText(currentFolderPath + args[1], jsonOutPut); } else { // Console.WriteLine("The robot didn't find the file of the tasks that needs to do"); Console.WriteLine(config.getConfig("fileErrorMsg1")); Console.WriteLine(config.getConfig("fileErrorMsg2")); Console.WriteLine(currentFolderPath); } } } catch (Exception e) { Console.WriteLine(config.getConfig("generalErrorMsg"), e.ToString()); } }
public void StopRunningTimer() { var te = GetRunningTimer(); if (te != null) { var url = $"{baseUrl}/time_entries/{te.id}/stop"; WebCall.PutRequest(url, basicAuth: this.apiKey); } }
private void btnOK_Click(object sender, EventArgs e) { if (!ClientUtils.CheckEmpty(txtName, "EMPTY_DRIVER_NAME") || !ClientUtils.CheckEmpty(txtBigCar, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtAgentBigCar, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtSmallCar, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtAgentSmallCar, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtBigCarPick, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtAgentBigCarPick, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtSmallCarPick, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtAgentSmallCarPick, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtBigCarSend, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtAgentBigCarSend, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtSmallCarSend, "EMPTY_FEE") || !ClientUtils.CheckEmpty(txtAgentSmallCarSend, "EMPTY_FEE")) { return; } int driverID = isModify ? selectedDriver.DriverID : 0; DriverDto param = new DriverDto { DriverID = driverID, DriverName = txtName.Text, Tel = txtTel.Text, Contact = txtContact.Text, BigCarFee = Convert.ToSingle(txtBigCar.Text), SmallCarFee = Convert.ToSingle(txtSmallCar.Text), AgentBigCarFee = Convert.ToSingle(txtAgentBigCar.Text), AgentBigCarPickAirportFee = Convert.ToSingle(txtAgentBigCarPick.Text), AgentBigCarSendAirportFee = Convert.ToSingle(txtAgentBigCarSend.Text), BigCarPickAirportFee = Convert.ToSingle(txtBigCarPick.Text), BigCarSendAirportFee = Convert.ToSingle(txtBigCarSend.Text), AgentSmallCarFee = Convert.ToSingle(txtAgentSmallCar.Text), AgentSmallCarPickAirportFee = Convert.ToSingle(txtAgentSmallCarPick.Text), AgentSmallCarSendAirportFee = Convert.ToSingle(txtAgentSmallCarSend.Text), SmallCarPickAirportFee = Convert.ToSingle(txtSmallCarPick.Text), SmallCarSendAirportFee = Convert.ToSingle(txtSmallCarSend.Text), Remark = txtRemark.Text, SupplierID = supplierID }; string strResult = WebCall.PostMethod <DriverDto>(isModify ? WebCall.ModifyDrivers: WebCall.AddDrivers, param); WebResult result = AppUtils.JsonDeserialize <WebResult>(strResult); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { ClientUtils.WarningCode(Travel.Client.Lang.LangBase.GetString(isModify ? "MODIFY_SUCCESS" : "ADD_SUCCESS") + result.Message); this.DialogResult = DialogResult.OK; this.Close(); } else { ClientUtils.WarningCode(result.Message); } }
private void btnSave_Click(object sender, EventArgs e) { if (!ClientUtils.CheckEmpty(txtSupplierName, "EMPTY_SUPPLIER_NAME") || !ClientUtils.CheckEmpty(txtContact, "EMPTY_SUPPLIER_CONTACT")) { return; } if (!isModify) { SupplierPara supplierPara = new SupplierPara(); supplierPara.supplier = new Supplier { SupplierName = txtSupplierName.Text, Contact = txtContact.Text }; supplierPara.travelProjects = travelProjects.ToList(); supplierPara.hotels = hotels.ToList(); string str_result = WebCall.PostMethod <SupplierPara>(WebCall.AddSupplier, supplierPara); WebResult result = AppUtils.JsonDeserialize <WebResult>(str_result); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { ClientUtils.WarningCode("ADD_SUCCESS"); this.DialogResult = DialogResult.OK; this.Close(); } else { ClientUtils.WarningCode(result.Message); } } else { Supplier selectSupplier = new Supplier { SupplierID = supplier.SupplierID, SupplierName = txtSupplierName.Text, Contact = txtContact.Text }; string str_result = WebCall.PostMethod <Supplier>(WebCall.ModifySupplier, selectSupplier); WebResult result = AppUtils.JsonDeserialize <WebResult>(str_result); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { ClientUtils.WarningCode("MODIFY_SUCCESS"); this.DialogResult = DialogResult.OK; this.Close(); } else { ClientUtils.WarningCode(result.Message); } } }
private void modifyHotel() { if (dgHotel.SelectedCells.Count == 0) { MessageBox.Show(LangBase.GetString("NOT_SELECT_HOTEL")); return; } else { int rowIndex = dgHotel.SelectedCells[0].RowIndex; HotelDto hotel = hotels[rowIndex]; AddHotel modifyHotel = new AddHotel(hotel); if (isModify) { if (modifyHotel.ShowDialog() == DialogResult.OK) { modifyHotel.hotel.HouseID = hotel.HouseID; string str_result = WebCall.PostMethod <HotelDto>(WebCall.ModifyHotel, modifyHotel.hotel); WebResult result = AppUtils.JsonDeserialize <WebResult>(str_result); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { hotel.HouseName = modifyHotel.hotel.HouseName; hotel.Fee = modifyHotel.hotel.Fee; hotel.AgentFee = modifyHotel.hotel.AgentFee; hotel.CoverPic = modifyHotel.hotel.CoverPic; hotel.Pics = modifyHotel.hotel.Pics; hotel.Description = modifyHotel.hotel.Description; hotel.Remark = modifyHotel.hotel.Remark; hotel.Location = modifyHotel.hotel.Location; hotel.RoomCount = modifyHotel.hotel.RoomCount; dgHotel.DataSource = null; dgHotel.DataSource = hotels; } else { ClientUtils.WarningCode(result.Message); } } } else { if (modifyHotel.ShowDialog() == DialogResult.OK) { hotels.RemoveAt(rowIndex); hotels.Add(modifyHotel.hotel); dgHotel.DataSource = null; dgHotel.DataSource = hotels; } } } }
private void modifyTravelService() { if (dgTravelService.SelectedCells.Count == 0) { MessageBox.Show(LangBase.GetString("NOT_SELECT_TRAVEL_SERVICE")); return; } else { int rowIndex = dgTravelService.SelectedCells[0].RowIndex; TravelProjectDto travelProject = travelProjects[rowIndex]; AddTravelProject modifyTravelProject = new AddTravelProject(travelProject); if (isModify) { if (modifyTravelProject.ShowDialog() == DialogResult.OK) { modifyTravelProject.travelProject.ProjectID = travelProject.ProjectID; string str_result = WebCall.PostMethod <TravelProjectDto>(WebCall.ModifyTravelService, modifyTravelProject.travelProject); WebResult result = AppUtils.JsonDeserialize <WebResult>(str_result); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { travelProject.ProjectName = modifyTravelProject.travelProject.ProjectName; travelProject.AdultFee = modifyTravelProject.travelProject.AdultFee; travelProject.ChildFee = modifyTravelProject.travelProject.ChildFee; travelProject.AgentAdultFee = modifyTravelProject.travelProject.AgentAdultFee; travelProject.AgentChildFee = modifyTravelProject.travelProject.AgentChildFee; travelProject.Description = modifyTravelProject.travelProject.Description; travelProject.ProjectTypeID = modifyTravelProject.travelProject.ProjectTypeID; travelProject.Remark = modifyTravelProject.travelProject.Remark; travelProject.CoverPic = modifyTravelProject.travelProject.CoverPic; dgTravelService.DataSource = null; dgTravelService.DataSource = travelProjects; } else { ClientUtils.WarningCode(result.Message); } } } else { if (modifyTravelProject.ShowDialog() == DialogResult.OK) { travelProjects.RemoveAt(rowIndex); travelProjects.Add(modifyTravelProject.travelProject); dgTravelService.DataSource = null; dgTravelService.DataSource = travelProjects; } } } }
public override bool Call() { try { { WebCall.Load(); return(true); } } finally { WebCall = null; typePool <_c1> .PushNotNull(this); } }
public TimeEntry GetRunningTimer() { var x = WebCall.GetRequestWithErrorHandling($"{baseUrl}/time_entries/current", this.apiKey); if (x.IsSuccessful) { var t = JsonConvert.DeserializeObject <TimeEntryData>(x.Data); var timeEntry = t.data; return(timeEntry); } else { return(null); } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "图片文件(*.jpg,*.gif,*.bmp)|*.jpg;*.gif;*.bmp"; if (openFileDialog.ShowDialog() == DialogResult.OK) { var result = AppUtils.JsonDeserialize <WebResult>(WebCall.UploadFile(openFileDialog.FileName)); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { } else { ClientUtils.WarningCode(result.Message); } } }
private void GetRoles() { RolesResult result = WebCall.GetMethod <RolesResult>(WebCall.GetRoles, null); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { roles = result.Data; foreach (T_Roles role in roles) { cbxRole.Items.Add(role.RoleName); } } else { ClientUtils.WarningCode(result.Message); } }
public override bool Call() { try { if (WebCall.ParseParameter(ref Parameter)) { WebCall.Xor(Parameter.left, Parameter.right); return(true); } } finally { WebCall = null; typePool <_c2> .PushNotNull(this); } return(false); }
public ActionResult ManageWebhooks() { var req = WebCall.GetRequestWithErrorHandling(WebhookRegisterURL); var hooks = new List <RegisteredWebhook>(); if (req.IsSuccessful) { hooks = JsonConvert.DeserializeObject <List <RegisteredWebhook> >(req.Data); } var x = from h in hooks select new { h.id , h.active , h.idModel , h.description , h.callbackURL , h.firstConsecutiveFailDate , h.consecutiveFailures }; return(View(model: JsonConvert.SerializeObject(x, Formatting.Indented))); }
public static void ProcessApiTest(string fileName, string url, int testCase) { Console.WriteLine("Processing from API '{0}'.", fileName); string completeFilePath = fileName; //Reading the Json File. var readFile = new StreamReader(completeFilePath); var fileJson = readFile.ReadToEnd(); //Make the RestApi call WebCall restApiCall = new WebCall(url, fileJson); //Get the response string jsonOutPut = restApiCall.callWebResApi(); //Write the json object in the file. File.WriteAllText(completeFilePath.Replace(".", "ApiTestCase" + testCase.ToString() + "."), jsonOutPut); Console.WriteLine("Processed from API '{0}'.", fileName); }
private void btnOK_Click(object sender, EventArgs e) { if (!ClientUtils.CheckEmpty(txtGuideName, "EMPTY_GUIDE_NAME") || !ClientUtils.CheckEmpty(txtLandFee, "EMPTY_LAND_FEE") || !ClientUtils.CheckEmpty(txtSeaFee, "EMPTY_SEA_FEE") || !ClientUtils.CheckEmpty(txtAgentLandFee, "EMPTY_AGENT_LAND_FEE") || !ClientUtils.CheckEmpty(txtAgentSeaFee, "EMPTY_AGENT_SEA_FEE")) { return; } int guideID = selectedGuide == null ? 0 : selectedGuide.GuideID; GuideDto param = new GuideDto { GuideID = guideID, GuideName = txtGuideName.Text, Tel = txtTel.Text, Contact = txtContact.Text, LandFee = Convert.ToSingle(txtLandFee.Text), AgentLandFee = Convert.ToSingle(txtAgentLandFee.Text), SeaFee = Convert.ToSingle(txtSeaFee.Text), AgentSeaFee = Convert.ToSingle(txtAgentSeaFee.Text), Remark = txtRemark.Text, SupplierID = supplierID }; string strResult = WebCall.PostMethod <GuideDto>(isModify ? WebCall.ModifyGuides: WebCall.AddGuides, param); WebResult result = AppUtils.JsonDeserialize <WebResult>(strResult); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { ClientUtils.WarningCode(Travel.Client.Lang.LangBase.GetString(isModify ? "MODIFY_SUCCESS" : "ADD_SUCCESS") + result.Message); this.DialogResult = DialogResult.OK; this.Close(); } else { ClientUtils.WarningCode(result.Message); } }
public async Task <ActionResult> Index() { try { _logger.LogDebug("Rendering the Index View"); List <Customer> wf = null; ViewBag.Comment = _config["Welcome"]; var response = await WebCall.GetApiDataAsync(_config["BackendServer"], "api/customers/"); if (response != null) { string responseString = await response.Content.ReadAsStringAsync(); wf = JsonConvert.DeserializeObject <List <Customer> >(responseString); } return(View(wf)); } catch (Exception ex) { _logger.LogError(ex.ToString()); throw ex; } }
private void btnLogin_Click(object sender, EventArgs e) { LoginPara para = new LoginPara() { Username = txtUser.Text, Password = AppUtils.SHA1Hash(txtPwd.Text) }; string str_result = WebCall.PostMethod <LoginPara>(WebCall.Login, para); LoginResult result = AppUtils.JsonDeserialize <LoginResult>(str_result); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { Configure.UserID = result.Data.UserID; Configure.UserName = result.Data.UserName; Configure.Functions = result.Data.Functions; isLogined = true; this.Close(); } else { MessageBox.Show(LangBase.GetString(result.Message)); } }
public AddHotel(HotelDto hotelDto) { InitializeComponent(); hotel = hotelDto; txtHotelName.Text = hotel.HouseName; txtFee.Text = hotel.Fee.ToString(); txtAgentFee.Text = hotel.AgentFee.ToString(); txtRemark.Text = hotel.Remark; txtDesc.Text = hotel.Description; txtLocation.Text = hotel.Location; txtRoomCount.Text = hotel.RoomCount.ToString(); pic = AppUtils.ToString(hotel.CoverPic); if (!pic.Equals(string.Empty)) { Stream picSteam = WebCall.GetPic(pic); btnPic.BackgroundImage = Image.FromStream(picSteam); picSteam.Close(); } if (hotel.Pics != null) { otherPics = hotel.Pics.ToString(); } }
public string GetMoviePosterUrl(string movieName) { var match = Regex.Match(movieName, @"\(\d{4}\)"); var year = ""; if (match.Success) { year = match.Value.Replace("(", ""); year = year.Replace(")", ""); cl("year is " + year); movieName = movieName.Replace(match.Value, ""); } var url = $@"{baseMovieUrl}/search/movie/?query={movieName}&{movieAuth}&year={year}"; var posterUrl = ""; MovieResult x = JsonConvert.DeserializeObject <MovieResult>(WebCall.GetRequest(url)); if (x.total_results == 0) { return(""); } posterUrl = posterBaseUrl + x.results[0].poster_path; return(posterUrl); }
public AddHotelPictures(string pics) { InitializeComponent(); Pics = pics; if (!Pics.Equals(string.Empty)) { picNames = AppUtils.JsonDeserialize <List <string> >(Pics); //for (int i = 1; i <= picNames.Count; i++) for (int i = picNames.Count; i > 0; i--) { string file = picNames[i - 1]; PictureBox pic = new PictureBox(); pic.SizeMode = PictureBoxSizeMode.StretchImage; Stream picSteam = WebCall.GetPic(file); pic.Image = Image.FromStream(picSteam); picSteam.Close(); pic.Size = new Size(picSize, picSize); pic.Left = 5 + i % rowCount * picSize + i % rowCount * 5; pic.Top = 5 + i / rowCount * picSize + i / rowCount * 5; this.Controls.Add(pic); } } btnAdd.Image = Properties.Resources.pic_add; }
public FrmLogin(FrmMain parent) { InitializeComponent(); WebCall.LoadUrl(); frmParent = parent; }
public ActionResult CreateHook(NewWebhook newWebhook) => JsonAllowed(WebCall.PostRequestWithErrorHandling(WebhookRegisterURL, newWebhook));