/// <summary> /// see <see cref="ICrazyflieParamConfigurator.RefreshParameterValue(string)"/> /// </summary> public Task <object> RefreshParameterValue(string completeName) { EnsureToc(); var id = CurrentToc.GetElementId(completeName); if (id == null) { throw new ArgumentException($"{completeName} not found in toc", nameof(completeName)); } var request = new ParamRequest(id.Value); lock (_openLoadRequestLock) { _openLoadRequests.Add(request); } return(Task.Run(() => { _paramSynchronizer.RequestLoadParamValue(id.Value); try { if (!request.Wait(10000)) { throw new ApplicationException($"failed to update parameter value {completeName} (timeout)"); } return GetLoadedParameterValue(completeName); } finally { request.Dispose(); } })); }
public void StartScanLiveDriver(bool isRestart = false) { ////Get Live data string urlInitLodds = IbetConfig.URL_INIT_LODDS_MARKET + ParamContainer["K"].KeyName + "=" + ParamContainer["K"].KeyValue + "&_=" + Utils.GetUnixTimestamp(); ParamContainer["LIVE_CT"] = new ParamRequest("CT", string.Empty); string updateTimeLive; var lOddMessage = Get(urlInitLodds, IbetConfig.URL_NEW_MARKET, "application/x-www-form-urlencoded"); var liveBag = ConvertFullData(lOddMessage.Result, out updateTimeLive, true); if (liveBag.Any()) { DataContainer.LiveMatchOddBag = liveBag; } //if (liveBag.Any()) //{ // //Logger.Info("SET LIVE BAG DATA !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); // DataContainer.LiveMatchOddBag = liveBag; //} ParamContainer["LIVE_CT"].KeyValue = updateTimeLive; //objLiveScanTimer = new System.Threading.Timer(WaitScanCallback, true, // SystemConfig.TIME_GET_UPDATE_LIVE_IBET, SystemConfig.TIME_GET_UPDATE_LIVE_IBET); }
private void UpdateOpenRequests(IList <ParamRequest> requests, object lockObject, ushort paramId, string operationName) { // UpdateOpenRequests is called both for the case a single update request with wait has been placed // or also in case all parameter updates have been requested (where we don't track individual requests) // therefore, for the first case, we expect a request in the openRequests whereas in the // second case, there is none. ParamRequest toRemove = null; lock (lockObject) { _log.Debug($"check for parameter {operationName} request for id {paramId}"); foreach (var request in requests) { if (request.CheckRequestFullfilledWithNotification(paramId)) { toRemove = request; _log.Debug($"fullfilled parameter {operationName} request for id {toRemove.Id}"); break; } } if (toRemove != null) { requests.Remove(toRemove); } } }
public ActionResult GetProject(ParamRequest paramRequest) { var query = new List <Project>(); if (string.IsNullOrEmpty(paramRequest.SearchString)) { query = ListProject; } else { query = ListProject.Where(x => x.Name.Contains(paramRequest.SearchString)).ToList(); } var totalItem = query.Count; var result = query.Skip(paramRequest.CurrentPage * paramRequest.ItemPerPage).Take(paramRequest.ItemPerPage); switch (paramRequest.ColumnSort) { case 1: result = paramRequest.DirectionSort == "asc" ? result.OrderBy(x => x.Name) : result.OrderByDescending(x => x.Name); break; case 2: result = paramRequest.DirectionSort == "asc" ? result.OrderBy(x => x.Number) : result.OrderByDescending(x => x.Number); break; case 3: result = paramRequest.DirectionSort == "asc" ? result.OrderBy(x => x.Cusotmer) : result.OrderByDescending(x => x.Cusotmer); break; } return(PartialView("_ListProject", query)); }
public override Task <SuckingCatResult> SuckingCat(ParamRequest param, ServerCallContext context) { Cat cat = null; if (Cats.Any(_ => _.Id == param.Id)) { cat = Cats.FirstOrDefault(_ => _.Id == param.Id); } else { cat = Cats[Rand.Next(0, Cats.Count)]; } return(Task.FromResult(new SuckingCatResult() { Message = $"您获得一只{cat.Name},{cat.Describe}" })); }
public void ProcessUpdateLiveData() { string urlUpdateLodds = string.Concat( IbetConfig.URL_UPDATE_LODDS_MARKET, ParamContainer["LIVE_CT"].KeyName + "=" + HttpUtility.UrlEncode(ParamContainer["LIVE_CT"].KeyValue), "&key=", GetKey(UserName, this.Host, "lodds", null, ParamContainer["LIVE_CT"].KeyValue, "U"), "&" + ParamContainer["K"].KeyName + "=" + ParamContainer["K"].KeyValue, "&_=" + Utils.GetUnixTimestamp()); var updateLiveOddMessage = Get(urlUpdateLodds, IbetConfig.URL_NEW_MARKET, "application/x-www-form-urlencoded"); try { if (updateLiveOddMessage.StatusCode == HttpStatusCode.OK && !string.IsNullOrEmpty(updateLiveOddMessage.Result)) { string updateTime; ConvertUpdateData(updateLiveOddMessage.Result, out updateTime, DataContainer.LiveMatchOddBag); if (!ParamContainer.ContainsKey("LIVE_CT")) { ParamContainer["LIVE_CT"] = new ParamRequest("CT", updateTime); } else { ParamContainer["LIVE_CT"].KeyValue = updateTime; } UpdateException(this); } else { //Logger.Error("IBET: END->ProcessUpdateLiveData -> FAIL"); //Logger.Error("MESSAGE : " + updateLiveOddMessage.Result + " URL REQUEST:: " + urlUpdateLodds); UpdateException(this, eExceptionType.RequestFail); } } catch (Exception ex) { //Logger.Error(ex); Logger.Error("MESSAGE : " + updateLiveOddMessage.Result, ex); //UpdateException(this, eExceptionType.RequestFail); } //UpdateException(this, eExceptionType.RequestFail); }
private void StartScanNonLive() { ////Get non Live data string urlInitDodds = IbetConfig.URL_INIT_DODDS_MARKET + ParamContainer["K"].KeyName + "=" + ParamContainer["K"].KeyValue + "&_=" + Utils.GetUnixTimestamp(); ParamContainer["NON_LIVE_CT"] = new ParamRequest("CT", string.Empty); string updateTimeNonLive; var dOddMessage = Get(urlInitDodds, IbetConfig.URL_NEW_MARKET, "application/x-www-form-urlencoded"); DataContainer.NonLiveMatchOddBag = ConvertFullData(dOddMessage.Result, out updateTimeNonLive, false); ParamContainer["NON_LIVE_CT"].KeyValue = updateTimeNonLive; //Start Timer update non live objNonLiveScanTimer = new System.Threading.Timer(WaitScanCallback, false, SystemConfig.TIME_GET_UPDATE_NON_LIVE_IBET, SystemConfig.TIME_GET_UPDATE_NON_LIVE_IBET); }
/// <summary> /// <see cref="ICrazyflieParamConfigurator.SetValue(string, object)"/> /// </summary> public Task SetValue(string completeName, object value) { EnsureToc(); var id = CurrentToc.GetElementId(completeName); if (id == null) { throw new ArgumentException($"{completeName} not found in toc", nameof(completeName)); } if (CurrentToc.GetElementById(id.Value).Access != ParamTocElement.AccessLevel.Readwrite) { throw new InvalidOperationException("unable to set a readonly parameter: " + completeName); } var element = CurrentToc.GetElementById(id.Value); var packId = ParamTocElement.GetIdFromCString(element.CType); var content = ParamTocElement.Pack(packId, value); var request = new ParamRequest(id.Value); lock (_openStoreRequestLock) { _openStoreRequests.Add(request); } return(Task.Run(() => { _paramSynchronizer.StoreParamValue(id.Value, content); try { if (!request.Wait(10000)) { throw new ApplicationException($"failed to store new parameter value {completeName} (timeout)"); } } finally { request.Dispose(); } })); }
public async Task <List <paciente> > getPacientes(long Id_dentista) { try { var paramrequest = new ParamRequest { id_dentista = Id_dentista.ToString() }; var jsonRequest = JsonConvert.SerializeObject(paramrequest); var httpContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json"); var client = new HttpClient(); client.BaseAddress = new Uri("https://www.painelstudio.com/perboyre/"); var url = "api/Paciente/getPacientes"; var response = await client.PostAsync(url, httpContent); if (!response.IsSuccessStatusCode) { return(null); } var result = await response.Content.ReadAsStringAsync(); List <paciente> exames = JsonConvert.DeserializeObject <List <paciente> >(result); return(exames.OrderBy(x => x.nome).ToList()); } catch (Exception ex) { return(null); /*return new Response * { * IsSuccess = false, * Message = ex.Message, * }; * throw;*/ } }
public MessageRespons UpdateStatusReceived(IUnitOfWork uow, ParamRequest requestaction) { MessageRespons responseaction = new MessageRespons(); //string[] idAll = requestaction.IdExport.Split(new char[] { ',' }); int receivedCount = 0; foreach (string id in requestaction.IdExport) { var obj = new ParamRequest(); RetrieveRequest retReq = new RetrieveRequest(); retReq.EntityId = id; var ord = new OrderRepository().Retrieve(uow.Connection, retReq); if (ord.Entity.OrderStatus == "Delivery" && ord.Entity.NoResi != "") { string URL = "https://api.rajaongkir.com/basic/waybill"; requestaction.waybill = ord.Entity.NoResi; WebRequest request = WebRequest.Create(URL); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Headers.Add("key", "4baeeab924c8e261d4397e79a1d52fb6"); string postData = "waybill=" + requestaction.waybill + "&courier=jne"; byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse response = request.GetResponse(); responseaction.message = ((HttpWebResponse)response).StatusDescription; dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string responseFromServer = reader.ReadToEnd(); Example result = Newtonsoft.Json.JsonConvert.DeserializeObject <Example>(responseFromServer); if (result.rajaongkir != null) { if (result.rajaongkir.result != null) { if (result.rajaongkir.result.delivered) { ord.Entity.OrderStatus = "Received"; ord.Entity.ReceiveBy = result.rajaongkir.result.delivery_status.pod_receiver; ord.Entity.ReceiveDate = result.rajaongkir.result.delivery_status.pod_date; ord.Entity.ReceiveTime = result.rajaongkir.result.delivery_status.pod_time; new OrderRepository().Update(uow, new SaveRequest <MyRow> { Entity = ord.Entity, EntityId = ord.Entity.OrderId }); receivedCount++; } } } reader.Close(); response.Close(); } } if (receivedCount > 0) { responseaction.message = receivedCount.ToString() + " paket Alhamdulillah sudah sampai."; } else { responseaction.message = "Belom ada paket yang sampai!! Sabar ya..."; } //generalResponse response = new generalResponse(); //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); //request.Method = "POST"; //request.ContentType = "application/x-www-form-urlencoded"; //request.ContentLength = Data.Length; //using (Stream webStream = request.GetRequestStream()) //using (StreamWriter requestWriter = new StreamWriter(webStream, System.Text.Encoding.ASCII)) //{ // requestWriter.Write(Data); //} //WebResponse webResponse = request.GetResponse(); //using (Stream webStream = webResponse.GetResponseStream() ?? Stream.Null) //using (StreamReader responseReader = new StreamReader(webStream)) //{ // res = responseReader.ReadToEnd(); // dynamic json1 = JsonConvert.DeserializeObject(res); // responseaction.message = "sukses"; //} return(responseaction); }
public MessageRespons sendNotif(IUnitOfWork uow, ParamRequest requestaction) { MessageRespons responseaction = new MessageRespons(); var msg = string.Empty; var order = new OrderRow(); var waLog = new List <WhatsappLogRow>(); if (requestaction.messageType == "Informasi Kirim") { msg = new MessageWaRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = 1 }).Entity.MessageDesc; order = new OrderRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = requestaction.orderId }).Entity; msg = msg.Replace("[Nama]", order.CustomerCustomerName); msg = msg.Replace("[NoOrder]", order.OrderId.ToString()); msg = msg.Replace("[Alamat]", order.CustomerAddress); msg = msg.Replace("[HP]", order.CustomerHandphone); new WhatsappLogRepository().Create(uow, new SaveRequest <WhatsappLogRow>() { Entity = new WhatsappLogRow() { MessageType = "Informasi Kirim", OrderId = requestaction.orderId, Sent = "No", MessageText = msg } }); } if (requestaction.messageType == "Informasi Resi") { msg = new MessageWaRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = 2 }).Entity.MessageDesc; order = new OrderRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = requestaction.orderId }).Entity; msg = msg.Replace("[Nama]", order.CustomerCustomerName); msg = msg.Replace("[NoOrder]", order.OrderId.ToString()); msg = msg.Replace("[Alamat]", order.CustomerAddress); msg = msg.Replace("[HP]", order.CustomerHandphone); msg = msg.Replace("[NORESI]", order.CustomerHandphone); new WhatsappLogRepository().Create(uow, new SaveRequest <WhatsappLogRow>() { Entity = new WhatsappLogRow() { MessageType = "Informasi Resi", OrderId = requestaction.orderId, Sent = "No", MessageText = msg } }); } if (requestaction.messageType == "Informasi Tagih") { msg = new MessageWaRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = 3 }).Entity.MessageDesc; order = new OrderRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = requestaction.orderId }).Entity; msg = msg.Replace("[Nama]", order.CustomerCustomerName); msg = msg.Replace("[NoOrder]", order.OrderId.ToString()); msg = msg.Replace("[Alamat]", order.CustomerAddress); msg = msg.Replace("[HP]", order.CustomerHandphone); new WhatsappLogRepository().Create(uow, new SaveRequest <WhatsappLogRow>() { Entity = new WhatsappLogRow() { MessageType = "Informasi Tagih", OrderId = requestaction.orderId, Sent = "No", MessageText = msg } }); } //if (msg != string.Empty) //{ // string URL = "http://api.woo-wa.com/v2.0/send-message"; // WebRequest request = WebRequest.Create(URL); // request.Method = "POST"; // request.ContentType = "application/x-www-form-urlencoded"; // string postData = "domain=basic.woo-wa.com&license=5c357854b7314&wa_number=6281908924400&text=" + msg; // //postData += "&gambar=https://hijrahqu.com/wp-content/uploads/2019/05/upside-down-arrow-md-nj8l5kchwcs62ekzzig1o1icptd26ks63coohbg2q2.png"; // byte[] byteArray = Encoding.UTF8.GetBytes(postData); // request.ContentLength = byteArray.Length; // Stream dataStream = request.GetRequestStream(); // dataStream.Write(byteArray, 0, byteArray.Length); // dataStream.Close(); // WebResponse response = request.GetResponse(); // dataStream = response.GetResponseStream(); // StreamReader reader = new StreamReader(dataStream); // string responseFromServer = reader.ReadToEnd(); // //Example result = Newtonsoft.Json.JsonConvert.DeserializeObject<Example>(responseFromServer); // responseaction.message = "okeh"; //} responseaction.message = "Data Tersimpan"; return(responseaction); }
public bool LoginProxy(string url, string userName, string password) { UrlHost = string.Empty; Host = string.Empty; LoginUrl = url; UserName = userName.ToUpper(); Password = password; ParamContainer = new Dictionary <string, ParamRequest>(); try { Uri uri = new Uri(url); NetTcpBinding b = new NetTcpBinding(); b.Security.Mode = SecurityMode.None; EndpointAddress vEndPoint = new EndpointAddress(ProxyEndpoint); ChannelFactory <IBcSupService> cf = new ChannelFactory <IBcSupService> (b, vEndPoint); IBcSupService serviceProxy = cf.CreateChannel(); serviceProxy.Ping(); var processLoginMsg = serviceProxy.Login(url, userName, password); if (processLoginMsg == null || processLoginMsg.Result.Contains("Incorrect username")) { throw new Exception(string.Format("Incorrect username: [{0}] and password: [{1}]", userName, password)); } var validateIndex = processLoginMsg.Result.IndexOf("location='"); var validateIndexEnd = processLoginMsg.Result.IndexOf("';", validateIndex); string validateUrl = processLoginMsg.Result.Substring(validateIndex + 10, validateIndexEnd - (validateIndex + 10)); Logger.Info(UserName + " >> Validate Url::::" + validateUrl); Uri uriValidate = new Uri(validateUrl); if (validateUrl.Contains("www")) { return(false); } var cookieValidate = BindCookieContainer(uriValidate, processLoginMsg.SetCookie); var validateMsg = SendIbet302(validateUrl, "GET", userAgent, cookieValidate, null, url + "ProcessLogin.aspx", uriValidate.Host, accept, null); UrlHost = uri.Scheme + Uri.SchemeDelimiter + uriValidate.Host; Uri urimain = new Uri(UrlHost); Host = urimain.Host; var cookieMain = BindCookieContainer(urimain, validateMsg.SetCookie, cookieValidate); //2 lan get main roi get top roi get left //var mainMsg1 = SendIbet302(UrlHost + validateMsg.Location, // "GET", userAgent, cookieMain, null, validateUrl, Host, accept, null); var mainMsg1 = SendIbet302(validateMsg.ReponseUri, "GET", userAgent, cookieMain, null, validateUrl, Host, accept, "text/html"); CookieContainer = BindCookieContainer(urimain, mainMsg1.SetCookie, cookieMain); var mainMsg2 = SendIbet302(mainMsg1.ReponseUri, "GET", userAgent, CookieContainer, null, mainMsg1.ReponseUri, Host, accept, "text/html"); CookieContainer = BindCookieContainer(urimain, mainMsg2.SetCookie, CookieContainer); if (mainMsg2.Result.Contains("frmChangePW") || mainMsg2.Result.Contains("Change_Password")) { var changePass = SendIbet302(UrlHost + "/Change_Password.aspx?expiry=yes", "GET", userAgent, CookieContainer, null, mainMsg1.ReponseUri, Host, accept, "text/html"); string changePassSubmitParam = "txtOldPW=&txtPW=&txtConPW=&hidSubmit=&hidRemindSubmit=next&hidLowerCaseOldPW=&hidExDate=1"; byte[] byteChangePassSubmitParam = Encoding.UTF8.GetBytes(changePassSubmitParam); var changePassSubmit = SendIbet302(UrlHost + "/Change_Password.aspx", "POST", userAgent, CookieContainer, byteChangePassSubmitParam, UrlHost + "/Change_Password.aspx?expiry=yes", Host, accept, "application/x-www-form-urlencoded"); } var topMenuMsg = SendIbet302(UrlHost + "/topmenu.aspx", "GET", userAgent, CookieContainer, null, mainMsg2.ReponseUri, Host, accept, "text/html"); ConvertServerTime(topMenuMsg.Result); CookieContainer = BindCookieContainer(urimain, topMenuMsg.SetCookie, CookieContainer); SendResponse leftMsg = SendIbet302(UrlHost + "/LeftAllInOne.aspx", "GET", userAgent, CookieContainer, null, mainMsg2.ReponseUri, Host, accept, "text/html"); if (string.IsNullOrEmpty(leftMsg.Result)) { Logger.Info("GET LEFT MESSAGE LAN 2!"); leftMsg = SendIbet302(UrlHost + "/LeftAllInOne.aspx", "GET", userAgent, CookieContainer, null, mainMsg2.ReponseUri, Host, accept, "text/html"); } CookieContainer = BindCookieContainer(urimain, leftMsg.SetCookie, CookieContainer); int indexNameK = leftMsg.Result.IndexOf("name=\"k"); int endIndexNameK = leftMsg.Result.IndexOf(" ", indexNameK); int indexValueK = leftMsg.Result.IndexOf("value=\"v", indexNameK); int endIndexValueK = leftMsg.Result.IndexOf(" ", indexValueK); string kName = leftMsg.Result.Substring(indexNameK + 6, endIndexNameK - (indexNameK + 7)).Trim(); string kValue = leftMsg.Result.Substring(indexValueK + 7, endIndexValueK - (indexValueK + 8)).Trim(); ParamContainer["K"] = new ParamRequest(kName, kValue); var newMarketMsg = SendIbet302(UrlHost + "/UnderOver.aspx?Market=t&DispVer=new", "GET", userAgent, CookieContainer, null, leftMsg.ReponseUri, Host, accept, "text/html"); CookieContainer = BindCookieContainer(urimain, newMarketMsg.SetCookie, CookieContainer); //CookieContainer = BindCookieContainer(urimain, setCookie, CookieContainer); UpdateException(this); ////Begin check login objCheckLoginTimer = new System.Threading.Timer(CheckLoginCallback, null, 0, SystemConfig.TIME_CHECK_LOGIN_IBET); AccountStatus = eAccountStatus.Online; return(true); } catch (Exception ex) { Logger.Error("Loi dang nhap", ex); UrlHost = string.Empty; Host = string.Empty; AvailabeCredit = 0; CashBalance = 0; Status = eServiceStatus.Unknown; AccountStatus = eAccountStatus.Offline; if (objCheckLoginTimer != null) { objCheckLoginTimer.Dispose(); } return(false); } }
public bool LoginNomal(string url, string userName, string password) { UrlHost = string.Empty; Host = string.Empty; LoginUrl = url; UserName = userName.ToUpper(); Password = password; ParamContainer = new Dictionary <string, ParamRequest>(); try { Uri uri = new Uri(url); string host = uri.Host; var getMain = SendIbet302(url + "login888.aspx", "GET", userAgent, null, null, url, host, accept, null); var docrootLeftInOne = new HtmlAgilityPack.HtmlDocument(); docrootLeftInOne.LoadHtml(getMain.Result); var codeLogin = docrootLeftInOne.DocumentNode.SelectSingleNode("//input[@type='text' and @name='txtCode']") .Attributes["value"].Value; var hashpass = GetHashPass(userName, password, codeLogin); string loginParam = string.Format(@"selLang=en&txtID={0}&txtPW={1}&txtCode={2}&hidubmit=&IEVerison =0&detecResTime=138&IsSSL=0&PF=Default", userName, hashpass, codeLogin); var cookieContainer = BindCookieContainer(uri, getMain.SetCookie); byte[] byteLoginParam = Encoding.UTF8.GetBytes(loginParam); SendResponse processLoginMsg = SendIbet302(url + "ProcessLogin.aspx", "POST", userAgent, cookieContainer, byteLoginParam, url, host, accept, "application/x-www-form-urlencoded"); if (processLoginMsg.Result.Contains("www")) { processLoginMsg = SendIbet302(url + "ProcessLogin.aspx", "POST", userAgent, cookieContainer, byteLoginParam, url, host, accept, "application/x-www-form-urlencoded"); } //Logger.Info("Process Msg: " + processLoginMsg.Result); if (processLoginMsg.Result.Contains("Incorrect username")) { throw new Exception(string.Format("Incorrect username: [{0}] and password: [{1}]", userName, password)); } var validateIndex = processLoginMsg.Result.IndexOf("location='"); var validateIndexEnd = processLoginMsg.Result.IndexOf("';", validateIndex); string validateUrl = processLoginMsg.Result.Substring(validateIndex + 10, validateIndexEnd - (validateIndex + 10)); Logger.Info(UserName + " >> Validate Url::::" + validateUrl); Uri uriValidate = new Uri(validateUrl); if (validateUrl.Contains("www")) { return(false); } var cookieValidate = BindCookieContainer(uriValidate, processLoginMsg.SetCookie); var validateMsg = SendIbet302(validateUrl, "GET", userAgent, cookieValidate, null, url + "ProcessLogin.aspx", uriValidate.Host, accept, null); UrlHost = uri.Scheme + Uri.SchemeDelimiter + uriValidate.Host; Uri urimain = new Uri(UrlHost); Host = urimain.Host; var cookieMain = BindCookieContainer(urimain, validateMsg.SetCookie, cookieValidate); var mainMsg1 = SendIbet302(validateMsg.ReponseUri, "GET", userAgent, cookieMain, null, validateUrl, Host, accept, "text/html"); CookieContainer = BindCookieContainer(urimain, mainMsg1.SetCookie, cookieMain); var mainMsg2 = SendIbet302(mainMsg1.ReponseUri, "GET", userAgent, CookieContainer, null, mainMsg1.ReponseUri, Host, accept, "text/html"); CookieContainer = BindCookieContainer(urimain, mainMsg2.SetCookie, CookieContainer); if (mainMsg2.Result.Contains("frmChangePW") || mainMsg2.Result.Contains("Change_Password")) { var changePass = SendIbet302(UrlHost + "/Change_Password.aspx?expiry=yes", "GET", userAgent, CookieContainer, null, mainMsg1.ReponseUri, Host, accept, "text/html"); string changePassSubmitParam = "txtOldPW=&txtPW=&txtConPW=&hidSubmit=&hidRemindSubmit=next&hidLowerCaseOldPW=&hidExDate=1"; byte[] byteChangePassSubmitParam = Encoding.UTF8.GetBytes(changePassSubmitParam); var changePassSubmit = SendIbet302(UrlHost + "/Change_Password.aspx", "POST", userAgent, CookieContainer, byteChangePassSubmitParam, UrlHost + "/Change_Password.aspx?expiry=yes", Host, accept, "application/x-www-form-urlencoded"); } var topMenuMsg = SendIbet302(UrlHost + "/topmenu.aspx", "GET", userAgent, CookieContainer, null, mainMsg2.ReponseUri, Host, accept, "text/html"); ConvertServerTime(topMenuMsg.Result); CookieContainer = BindCookieContainer(urimain, topMenuMsg.SetCookie, CookieContainer); SendResponse leftMsg = SendIbet302(UrlHost + "/LeftAllInOne.aspx", "GET", userAgent, CookieContainer, null, mainMsg2.ReponseUri, Host, accept, "text/html"); if (string.IsNullOrEmpty(leftMsg.Result)) { Logger.Info("GET LEFT MESSAGE LAN 2!"); leftMsg = SendIbet302(UrlHost + "/LeftAllInOne.aspx", "GET", userAgent, CookieContainer, null, mainMsg2.ReponseUri, Host, accept, "text/html"); } CookieContainer = BindCookieContainer(urimain, leftMsg.SetCookie, CookieContainer); int indexNameK = leftMsg.Result.IndexOf("name=\"k"); int endIndexNameK = leftMsg.Result.IndexOf(" ", indexNameK); int indexValueK = leftMsg.Result.IndexOf("value=\"v", indexNameK); int endIndexValueK = leftMsg.Result.IndexOf(" ", indexValueK); string kName = leftMsg.Result.Substring(indexNameK + 6, endIndexNameK - (indexNameK + 7)).Trim(); string kValue = leftMsg.Result.Substring(indexValueK + 7, endIndexValueK - (indexValueK + 8)).Trim(); ParamContainer["K"] = new ParamRequest(kName, kValue); var newMarketMsg = SendIbet302(UrlHost + "/UnderOver.aspx?Market=t&DispVer=new", "GET", userAgent, CookieContainer, null, leftMsg.ReponseUri, Host, accept, "text/html"); CookieContainer = BindCookieContainer(urimain, newMarketMsg.SetCookie, CookieContainer); //CookieContainer = BindCookieContainer(urimain, setCookie, CookieContainer); UpdateException(this); ////Begin check login objCheckLoginTimer = new System.Threading.Timer(CheckLoginCallback, null, 0, SystemConfig.TIME_CHECK_LOGIN_IBET); AccountStatus = eAccountStatus.Online; return(true); } catch (Exception ex) { Logger.Error("Loi dang nhap", ex); UrlHost = string.Empty; Host = string.Empty; AvailabeCredit = 0; CashBalance = 0; Status = eServiceStatus.Unknown; AccountStatus = eAccountStatus.Offline; if (objCheckLoginTimer != null) { objCheckLoginTimer.Dispose(); } return(false); } }