private async void Button_Click(object sender, RoutedEventArgs e) { //Xsignature = XSignature_Generate(); HttpConnects h_Conn = new HttpConnects(ApiUrl_TB.Text + "/hotels", mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text); var Json_RQ = Json_RQ4HotelList().ToString(); RQ_Json_TB.Text = Json_RQ; change_button_status(); RSResult rsResult = await h_Conn.searhAllRoomsInHotelS(Json_RQ); if (rsResult.rq_status == true) { RS_Json_TB.Text = JValue.Parse(rsResult.result).ToString(Formatting.Indented); hotelRommsContionList = await Json_Paring(rsResult.result); hbHotelRoom_Grid.ItemsSource = hotelRommsContionList; statusBar.Content = "Done: Checking Successfully"; MessageBox.Show("Rate plan checking process has done !!"); } else { MessageBoxResult result = MessageBox.Show(rsResult.result); statusBar.Content = "Error: " + rsResult.result; } change_button_status(); }
// GET Method to GET A Static data for Hotels public async Task <RSResult> GetBookingDetail() { RSResult rsResult = new RSResult(); try { Console.WriteLine(apiUrl); Uri url = new Uri(apiUrl); var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Accept = "application/json"; httpWebRequest.Method = WebRequestMethods.Http.Get; httpWebRequest.Headers["Api-key"] = apiKey; httpWebRequest.Headers["X-Signature"] = XSignature_Generate(); httpWebRequest.Timeout = 100000; var response = await httpWebRequest.GetResponseAsync(); Stream responseStream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8); rsResult.result = streamReader.ReadToEnd(); rsResult.rq_status = true; streamReader.Close(); responseStream.Close(); response.Close(); } catch (WebException e) { var error_msg = "This program is expected to throw WebException on successful run." + "\n\nException Message :" + e.Message + "\n"; //Console.WriteLine(error_msg); if (e.Status == WebExceptionStatus.ProtocolError) { //Console.WriteLine("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode); //Console.WriteLine("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription); var resp = new StreamReader(e.Response.GetResponseStream()).ReadToEnd(); JObject obj = JObject.Parse(resp); //Console.WriteLine("Error:" + obj["error"]["message"].ToString()); error_msg += "Detail: " + obj["error"]["message"].ToString(); } rsResult.result = error_msg; rsResult.rq_status = false; //Console.WriteLine("error -------------: " + e.ToString()); } catch (Exception ex) { rsResult.result = ex.Message; rsResult.rq_status = false; //Console.WriteLine("error -------------: " + ex.ToString()); } return(rsResult); }
private async void Start_btn_Click(object sender, RoutedEventArgs e) { if (Booking_Ref.Text == "") { MessageBox.Show("Please Enter the HotelBeds Booking ID"); } else { string getApiUrl = ApiUrl_TB.Text + Booking_Ref.Text; HttpConnects h_Conn = new HttpConnects(getApiUrl, mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text); statusBar.Content = "Please wait for a Second.... Now We are Communicating with HB API ... -> Get Booking Info "; RSResult rsResult = await h_Conn.GetBookingDetail(); if (rsResult.rq_status == true) { RS_Json_TB.Text = JValue.Parse(rsResult.result).ToString(Formatting.Indented); statusBar.Content = "Done: Checking Successfully"; MessageBox.Show("Booking Detail checking process has done !!"); } else { statusBar.Content = "Error: " + rsResult.result; MessageBoxResult result = MessageBox.Show(rsResult.result); } } }
private async void GetRoomDescrip_btn_Click(object sender, RoutedEventArgs e) { string status_barTxt = ""; HBRoomDescList = new List <RoomDesc>(); from = 1; to = 1000; total_number = 0; current_from = from; current_to = to; string getApiUrl = ApiUrl_TB.Text + "types/rooms?fields=all&language=ENG&useSecondaryLanguage=false"; //Console.WriteLine(getApiUrl); HttpConnects h_Conn = new HttpConnects(getApiUrl, mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text); do { statusBar.Content = "Please wait for a Second.... Now We are Communicating with HB API ... -> Get Hotel from " + current_from + " to " + current_to; RSResult rsResult = await h_Conn.GetHotelContents(current_from, current_to); Console.WriteLine(rsResult.result); if (rsResult.rq_status == true) { //RS_Json_TB.Text = rsResult.result; await Json_Paring(rsResult.result); status_barTxt = "Done: Successfully, Get Hotel from 1 to " + current_to;; //popup_Txt = "Rate plan checking process has done !!" //MessageBox.Show("Rate plan checking process has done !!"); } else { status_barTxt = "Error: " + rsResult.result; //MessageBoxResult result = MessageBox.Show(rsResult.result); break; } current_from = current_to + 1; current_to = current_from + 999; //Console.WriteLine("ZZZZZZZ : " +total_number); } while (total_number > current_from); hbHotelRoom_Grid.ItemsSource = HBRoomDescList; await CreateCSVFromGenericList(HBRoomDescList, @"..\..\CSVfiles\RoomDesc.csv"); statusBar.Content = status_barTxt; MessageBox.Show(status_barTxt); }
private async void GetHotel_btn_Click(object sender, RoutedEventArgs e) { DestinationDescMomoryDB = File.ReadAllLines(@"..\..\CSVfiles\DestinationDesc.csv") .Skip(1) .Select(v => DestinationDesc.FromCsv(v)) .ToList(); RoomDescMomoryDB = File.ReadAllLines(@"..\..\CSVfiles\RoomDesc.csv") .Skip(1) .Select(v => RoomDesc.FromCsv(v)) .ToList(); change_button_status(); string status_barTxt = ""; hotelContentsList = new List <HotelInformation>(); HBRoomImageList = new List <RoomImage>(); HBWildCardsList = new List <HotelWildCards>(); HBHTRoomTypeList = new List <HotelRoomTypeInfo>(); from = 1; to = 1000; total_number = 0; current_from = from; current_to = to; string getApiUrl = ApiUrl_TB.Text + setField4HotelContents(GL_target_Data); //Console.WriteLine(getApiUrl); HttpConnects h_Conn = new HttpConnects(getApiUrl, mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text); do { statusBar.Content = "Please wait for a Second.... Now We are Communicating with HB API ... -> Get Hotel from " + current_from + " to " + current_to; RSResult rsResult = await h_Conn.GetHotelContents(current_from, current_to); //Console.WriteLine(rsResult.result); if (rsResult.rq_status == true) { await Json_Paring(GL_target_Data, rsResult.result); Console.WriteLine(GL_target_Data + " -- " + rsResult.result); status_barTxt = "Done: Successfully, Get Hotel from 1 to " + current_to;; } else { status_barTxt = "Error: " + rsResult.result; MessageBoxResult result = MessageBox.Show(rsResult.result); break; } current_from = current_to + 1; current_to = current_from + 999; } while (total_number > current_from); switch (GL_target_Data) { case "HT": //** THIS "hotelContentsList" Cooming from Json_Paring() function as a Global parameter hbHotelRoom_Grid.ItemsSource = hotelContentsList; break; case "IMG": //** THIS "hotelContentsList" Cooming from Json_Paring() function as a Global parameter HBRoomImageList = (from x in HBRoomImageList orderby x.hotel_code, x.imageOrder ascending select x).ToList(); hbHotelRoom_Grid.ItemsSource = HBRoomImageList; break; case "WILD": hbHotelRoom_Grid.ItemsSource = HBWildCardsList; break; case "HTROOM": hbHotelRoom_Grid.ItemsSource = HBHTRoomTypeList; break; default: hbHotelRoom_Grid.ItemsSource = hotelContentsList; break; } statusBar.Content = status_barTxt; MessageBox.Show(status_barTxt); change_button_status(); }
private async void GetImage_btn_Click(object sender, RoutedEventArgs e) { string status_barTxt = ""; //여기 부서 개발 시작 2018.06.27 RoomDescMomoryDB = File.ReadAllLines(@"..\..\CSVfiles\RoomDesc.csv") .Skip(1) .Select(v => RoomDesc.FromCsv(v)) .ToList(); //여기 부서 개발 시작 HBRoomImageList = new List <RoomImage>(); from = 1; to = 1000; total_number = 0; current_from = from; current_to = to; string getApiUrl = ApiUrl_TB.Text + "hotels?fields=name%2CcountryCode%2CdestinationCode%2Cimages&language=ENG&useSecondaryLanguage=false"; //Console.WriteLine(getApiUrl); HttpConnects h_Conn = new HttpConnects(getApiUrl, mainWindow.ApiKey_TB.Text, mainWindow.Security_TB.Text); do { statusBar.Content = "Please wait for a Second.... Now We are Communicating with HB API ... -> Get Hotel from " + current_from + " to " + current_to; RSResult rsResult = await h_Conn.GetHotelContents(current_from, current_to); Console.WriteLine(rsResult.result); if (rsResult.rq_status == true) { //RS_Json_TB.Text = rsResult.result; await Json_Paring_Img(rsResult.result); status_barTxt = "Done: Successfully, Get Hotel from 1 to " + current_to;; //popup_Txt = "Rate plan checking process has done !!" //MessageBox.Show("Rate plan checking process has done !!"); } else { status_barTxt = "Error: " + rsResult.result; //MessageBoxResult result = MessageBox.Show(rsResult.result); break; } current_from = current_to + 1; current_to = current_from + 999; //Console.WriteLine("ZZZZZZZ : " +total_number); } while (total_number > current_from); var HBRoomImageList_Oderby = (from x in HBRoomImageList orderby x.hotel_code, x.imageOrder ascending select x).ToList(); hbHotelRoom_Grid.ItemsSource = HBRoomImageList_Oderby; await CreateCSVFromGenericList(HBRoomImageList_Oderby, @"..\..\CSVfiles\HBRoomImages.csv"); statusBar.Content = status_barTxt; MessageBox.Show(status_barTxt); }
public void RSRiskControllerResult(RSResult entity) { bool result = false; if (entity != null && entity.reqID != "") { WorkFlowFunction wf = new WorkFlowFunction(); //00 - 成功 //01 - 正在处理中 //02 - 错误 //03 - 失败 //04 - 超时转人工 List <DataItemParam> keyValues = new List <DataItemParam>(); string fkResult = ""; if (entity.code == "00") { //localreject: 部署在东正本地规则拒绝; //cloudaccept: 部署在云端规则通过; //cloudreject: 部署在云端规则拒绝; //cloudmanual: 部署在云端规则返回转人工 fkResult = entity.data.action; keyValues.Add(new DataItemParam() { ItemName = "fkResult", ItemValue = fkResult }); //Automatic_approval:0人工(默认值),1自动审批,-1拒绝 if (fkResult == "cloudaccept") { //在融数通过的情况下,根据东正的业务判断是否需要走自动审批 #region int auto = 0; auto = wf.AutomaticApprovalByRongShu(entity.reqID); keyValues.Add(new DataItemParam() { ItemName = "Automatic_approval", ItemValue = auto }); #endregion } else { keyValues.Add(new DataItemParam() { ItemName = "Automatic_approval", ItemValue = 0 }); } string SchemaCode = wf.getSchemaCodeByInstanceID(entity.reqID); wf.SetItemValues(SchemaCode, wf.getBizobjectByInstanceid(entity.reqID), keyValues, wf.GetUserIDByCode("rsfk")); result = wf.SubmitWorkItemByRongShu(entity.reqID, "", wf.GetUserIDByCode("rsfk")); } else if (entity.code == "02") { //localreject: 部署在东正本地规则拒绝; //cloudaccept: 部署在云端规则通过; //cloudreject: 部署在云端规则拒绝; //cloudmanual: 部署在云端规则返回转人工 //manual:1--》 人工查询外部数据源 //manual:2--》 超时重提进件 fkResult = entity.data.action; keyValues.Add(new DataItemParam() { ItemName = "fkResult", ItemValue = "error" }); keyValues.Add(new DataItemParam() { ItemName = "Automatic_approval", ItemValue = 0 }); string SchemaCode = wf.getSchemaCodeByInstanceID(entity.reqID); wf.SetItemValues(SchemaCode, wf.getBizobjectByInstanceid(entity.reqID), keyValues, wf.GetUserIDByCode("rsfk")); result = wf.SubmitWorkItemByRongShu(entity.reqID, "", wf.GetUserIDByCode("rsfk")); } else if (entity.code == "03") { OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("融数风控回调执行结果:处理超时,重新提交"); //重新提交请求 //string SchemaCode = wf.getSchemaCodeByInstanceID(entity.reqID); //wf.postHttp(SchemaCode, entity.reqID); } else if (entity.code == "04")//超时转人工 { OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("融数风控回调执行结果:处理超时转人工"); //localreject: 部署在东正本地规则拒绝; //cloudaccept: 部署在云端规则通过; //cloudreject: 部署在云端规则拒绝; //cloudmanual: 部署在云端规则返回转人工 fkResult = entity.data.action; keyValues.Add(new DataItemParam() { ItemName = "fkResult", ItemValue = "overtime" }); keyValues.Add(new DataItemParam() { ItemName = "Automatic_approval", ItemValue = 0 }); string SchemaCode = wf.getSchemaCodeByInstanceID(entity.reqID); wf.SetItemValues(SchemaCode, wf.getBizobjectByInstanceid(entity.reqID), keyValues, wf.GetUserIDByCode("rsfk")); result = wf.SubmitWorkItemByRongShu(entity.reqID, "", wf.GetUserIDByCode("rsfk")); } } else { OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("融数风控回调执行结果:回传参数为空!"); } }
// GET Method to GET A Static data for Hotels public async Task <RSResult> GetHotelContents(int from, int to) { RSResult rsResult = new RSResult(); try { // do // { string numberOfData = "&from=" + from + "&to=" + to; Console.WriteLine(apiUrl + numberOfData); Uri url = new Uri(apiUrl + numberOfData); var httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ContentType = "application/json"; httpWebRequest.Accept = "application/json"; httpWebRequest.Method = WebRequestMethods.Http.Get; httpWebRequest.Headers["Api-key"] = apiKey; httpWebRequest.Headers["X-Signature"] = XSignature_Generate(); httpWebRequest.Timeout = 100000; var response = await httpWebRequest.GetResponseAsync(); Stream responseStream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8); // string json_result = streamReader.ReadToEnd(); // if (total_number == 0) // { // List<HotelContent> hotelContentsList = new List<HotelContent>(); // JObject obj = JObject.Parse(json_result); // Console.WriteLine(obj["total"].ToString()); // total_number = int.Parse(obj["total"].ToString()); // } // await Json_Paring(json_result); rsResult.result = streamReader.ReadToEnd(); rsResult.rq_status = true; streamReader.Close(); responseStream.Close(); response.Close(); // current_from = current_to + 1; // current_to = current_from + 999; // } while (total_number > current_from); //rsResult.rq_status = true; // rsResult.result = hotelContentsList; } catch (WebException e) { var error_msg = "This program is expected to throw WebException on successful run." + "\n\nException Message :" + e.Message + "\n"; //Console.WriteLine(error_msg); if (e.Status == WebExceptionStatus.ProtocolError) { //Console.WriteLine("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode); //Console.WriteLine("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription); var resp = new StreamReader(e.Response.GetResponseStream()).ReadToEnd(); JObject obj = JObject.Parse(resp); //Console.WriteLine("Error:" + obj["error"]["message"].ToString()); error_msg += "Detail: " + obj["error"]["message"].ToString(); } rsResult.result = error_msg; rsResult.rq_status = false; //Console.WriteLine("error -------------: " + e.ToString()); } catch (Exception ex) { rsResult.result = ex.Message; rsResult.rq_status = false; //Console.WriteLine("error -------------: " + ex.ToString()); } return(rsResult); }
public void RSRiskControllerResult(RSResult entity) { bool result = false; if (entity != null && entity.reqID != "") { WorkFlowFunction wf = new WorkFlowFunction(); WorkFlowFunctionNew wf_New = new WorkFlowFunctionNew(); //00 - 成功 //01 - 正在处理中 //02 - 错误 //03 - 失败 //04 - 超时转人工 List <DataItemParam> keyValues = new List <DataItemParam>(); string fkResult = ""; if (entity.code == "00") { //localreject: 部署在东正本地规则拒绝; //cloudaccept: 部署在云端规则通过; //cloudreject: 部署在云端规则拒绝; //cloudmanual: 部署在云端规则返回转人工 fkResult = entity.data.action; keyValues.Add(new DataItemParam() { ItemName = "fkResult", ItemValue = fkResult }); //Automatic_approval:0人工(默认值),1自动审批,-1拒绝 int auto = 0; if (fkResult == "cloudaccept") { //在融数通过的情况下,根据东正的业务判断是否需要走自动审批 #region auto = wf_New.AutomaticApprovalByRongShu(entity.reqID); keyValues.Add(new DataItemParam() { ItemName = "Automatic_approval", ItemValue = auto }); #endregion } else { keyValues.Add(new DataItemParam() { ItemName = "Automatic_approval", ItemValue = 0 }); } string SchemaCode = wf.getSchemaCodeByInstanceID(entity.reqID); wf.SetItemValues(SchemaCode, wf.getBizobjectByInstanceid(entity.reqID), keyValues, wf.GetUserIDByCode("rsfk")); //result = wf.SubmitWorkItemByRongShu(entity.reqID, "", wf.GetUserIDByCode("rsfk")); //判断是否是外网经销商 string dep = ""; string sql = @"select b.name from OT_User a join OT_Organizationunit b on a.parentid = b.objectid join OT_instancecontext c on c.originator = a.objectid where c.objectid = '{0}'"; sql = string.Format(sql, entity.reqID); dep = OThinker.H3.Controllers.AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql).ToString(); if (auto == 1 && !dep.Contains("外网"))//自动通过的外网经销商需要走大数据风控模型 { result = wf.SubmitWorkItemByRongShu(entity.reqID, "", wf.GetUserIDByCode("rsfk")); } else { //调用东正大数据模型 DataRisk.postDataRisk(entity.reqID); } } else if (entity.code == "02") { //localreject: 部署在东正本地规则拒绝; //cloudaccept: 部署在云端规则通过; //cloudreject: 部署在云端规则拒绝; //cloudmanual: 部署在云端规则返回转人工 //manual:1--》 人工查询外部数据源 //manual:2--》 超时重提进件 fkResult = entity.data.action; keyValues.Add(new DataItemParam() { ItemName = "fkResult", ItemValue = "error" }); keyValues.Add(new DataItemParam() { ItemName = "Automatic_approval", ItemValue = 0 }); string SchemaCode = wf.getSchemaCodeByInstanceID(entity.reqID); wf.SetItemValues(SchemaCode, wf.getBizobjectByInstanceid(entity.reqID), keyValues, wf.GetUserIDByCode("rsfk")); //result = wf.SubmitWorkItemByRongShu(entity.reqID, "", wf.GetUserIDByCode("rsfk")); //调用东正大数据模型 DataRisk.postDataRisk(entity.reqID); } else if (entity.code == "03") { OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("融数风控回调执行结果:处理超时,重新提交"); //重新提交请求 //string SchemaCode = wf.getSchemaCodeByInstanceID(entity.reqID); //wf.postHttp(SchemaCode, entity.reqID); } else if (entity.code == "04")//超时转人工 { OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("融数风控回调执行结果:处理超时转人工"); //localreject: 部署在东正本地规则拒绝; //cloudaccept: 部署在云端规则通过; //cloudreject: 部署在云端规则拒绝; //cloudmanual: 部署在云端规则返回转人工 fkResult = entity.data.action; keyValues.Add(new DataItemParam() { ItemName = "fkResult", ItemValue = "overtime" }); keyValues.Add(new DataItemParam() { ItemName = "Automatic_approval", ItemValue = 0 }); string SchemaCode = wf.getSchemaCodeByInstanceID(entity.reqID); wf.SetItemValues(SchemaCode, wf.getBizobjectByInstanceid(entity.reqID), keyValues, wf.GetUserIDByCode("rsfk")); //result = wf.SubmitWorkItemByRongShu(entity.reqID, "", wf.GetUserIDByCode("rsfk")); //调用东正大数据模型 DataRisk.postDataRisk(entity.reqID); } } else { OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("融数风控回调执行结果:回传参数为空!"); } }