private static InitInfo CreateInitInfo(TopoInfo floor, string parkName) { InitInfo initInfo = new InitInfo(); TopoInfo root = new TopoInfo("根节点", AreaTypes.区域); initInfo.TopoInfo = root; TopoInfo park = new TopoInfo(parkName, AreaTypes.园区);//todo:可以扩展成园区、大楼手动设置 root.AddChild(park); //TopoInfo group = new TopoInfo("分组1", AreaTypes.分组); //park.AddChild(group); TopoInfo building = new TopoInfo("大楼1", AreaTypes.大楼); park.AddChild(building); building.AddChild(floor); BoundInfo buildBound = floor.BoundInfo.CloneByXml(); buildBound.SetRectangle(); //比例调整 buildBound.Scale(1.05f); //比例调整 building.BoundInfo = buildBound; //大楼默认和楼层一致 BoundInfo parkBound = building.BoundInfo.CloneByXml(); parkBound.SetRectangle(); parkBound.Scale(2);//园区默认是比大楼周围一圈 park.BoundInfo = parkBound; return(initInfo); }
/// <summary> /// 获取参数 /// </summary> /// <returns></returns> private InitInfo GetInitInfo() { InitInfo info = new InitInfo(); string url = "https://kyfw.12306.cn/otn/confirmPassenger/initDc"; string data = "_json_att="; string response = HttpHelper.StringPost(_agent, url, data, _cookie); string regexStr = @"var globalRepeatSubmitToken = '(.*?)'"; string submitToken = Regex.Match(response, regexStr).Value.Replace("'", "").Split('=')[1].Trim(); info.SubmitToken = submitToken; regexStr = @"'leftTicketStr':'(.*?)'"; string leftInfo = Regex.Match(response, regexStr).Value.Replace("'", "").Split(':')[1].Trim(); info.LeftTicketInfo = leftInfo; regexStr = @"'key_check_isChange':'(.*?)'"; string keyCheck = Regex.Match(response, regexStr).Value.Replace("'", "").Split(':')[1].Trim(); info.KeyCheck = keyCheck; regexStr = @"'train_location':'(.*?)'"; string location = Regex.Match(response, regexStr).Value.Replace("'", "").Split(':')[1].Trim(); info.Location = location; regexStr = @"'purpose_codes':'(.*?)'"; string codes = Regex.Match(response, regexStr).Value.Replace("'", "").Split(':')[1].Trim(); info.PurposeCodes = codes; LogHelper.Info("initDc:" + url + "成功!"); return(info); }
public MainForm() { this.BringToForeground(); InitializeComponent(); // Init buttons IReadOnlyDictionary <MainFormControlsTabOrder, InitInfo> buttonsInitInfo = GetButtonsInitInfo(); Array mainFormControlsTabOrderItems = Enum.GetValues(typeof(MainFormControlsTabOrder)); foreach (MainFormControlsTabOrder item in mainFormControlsTabOrderItems) { InitInfo info = buttonsInitInfo[item]; Button button = new Button { Name = info.Name, Size = new Size(259, 23), TabIndex = (int)item, Text = info.Name, UseVisualStyleBackColor = true }; button.Click += info.Click; flowLayoutPanelUITypeEditors.Controls.Add(button); } // Calculate the form size. ClientSize = new Size(545, 18 + (mainFormControlsTabOrderItems.Length + 1) / 2 * 29); MinimumSize = Size; // Force the panel to show all buttons flowLayoutPanelUITypeEditors.PerformLayout(); flowLayoutPanelUITypeEditors.Controls[(int)MainFormControlsTabOrder.ButtonsButton].Focus(); }
/// <summary> /// 获取排队数 /// </summary> /// <param name="selectedTrain"></param> /// <param name="buySeat"></param> /// <param name="info"></param> /// <returns></returns> private bool GetQueueCount(QueryTicket selectedTrain, string buySeat, InitInfo info) { try { string url = "https://kyfw.12306.cn/otn/confirmPassenger/getQueueCount"; DateTime dt; DateTime.TryParse(_date, out dt); string trainDate = UrlEncode(dt.ToString("ddd MMM dd yyyy ", CultureInfo.CreateSpecificCulture("en-GB")) + "00:00:00 GMT+0800 (CST)"); string fromStationTelecode = _fromStation.Code; string toStationTelecode = _toStation.Code; string stationTrainCode = selectedTrain.Station_Train_Code; string trainNo = selectedTrain.Train_No; string data = string.Format( "train_date={0}&train_no={1}&stationTrainCode={2}&seatType={3}&fromStationTelecode={4}&toStationTelecode={5}&leftTicket={6}&purpose_codes={7}&train_location={8}&_json_att=&REPEAT_SUBMIT_TOKEN={9}", trainDate, trainNo, stationTrainCode, buySeat, fromStationTelecode, toStationTelecode, info.LeftTicketInfo, info.PurposeCodes, info.Location, info.SubmitToken); HttpJsonEntity <Dictionary <string, string> > contentEntity = HttpHelper.Post(_agent, url, data, _cookie); LogHelper.Info(selectedTrain.Station_Train_Code + " GetQueueCount成功"); return(contentEntity.status.ToUpper().Equals("TRUE") && contentEntity.httpstatus.Equals(200)); } catch (Exception ex) { LogHelper.Error("GetQueueCount", ex); return(false); } }
/// <summary> /// 确认购票 /// </summary> /// <param name="passengerTicketStr"></param> /// <param name="oldPassengerStr"></param> /// <param name="randCode"></param> /// <param name="info"></param> /// <returns></returns> private bool ConfirmSingleForQueue(string passengerTicketStr, string oldPassengerStr, string randCode, InitInfo info, out string msg) { msg = "确认购票失败!"; try { string url = "https://kyfw.12306.cn/otn/confirmPassenger/confirmSingleForQueue"; string data = string.Format( "passengerTicketStr={0}&oldPassengerStr={1}&randCode={2}&purpose_codes={3}&key_check_isChange={4}C&leftTicketStr={5}&train_location={6}&choose_seats=&seatDetailType=000&whatsSelect=1&roomType=00&dwAll=N&_json_att=&REPEAT_SUBMIT_TOKEN={7}", UrlEncode(passengerTicketStr), UrlEncode(oldPassengerStr), randCode, info.PurposeCodes, info.KeyCheck, info.LeftTicketInfo, info.Location, info.SubmitToken); HttpJsonEntity <Dictionary <string, string> > contentEntity = HttpHelper.Post(_agent, url, data, _cookie); if (contentEntity.status.ToUpper().Equals("TRUE") && contentEntity.httpstatus.Equals(200)) { if (contentEntity.data.ContainsKey("submitStatus") && contentEntity.data["submitStatus"].ToUpper().Equals("TRUE")) { return(true); } if (contentEntity.data.ContainsKey("errMsg")) { msg = contentEntity.data["errMsg"]; } } } catch (Exception ex) { LogHelper.Error("ConfirmSingleForQueue", ex); } return(false); }
/// <summary> /// 购票 /// </summary> /// <param name="info"></param> /// <param name="msg"></param> /// <returns></returns> private bool QueryOrderWaitTime(InitInfo info, out string msg) { msg = "购票失败,请重试!"; try { string timeSpan = GetTimeStamp(); string url = string.Format( "https://kyfw.12306.cn/otn/confirmPassenger/queryOrderWaitTime?random={0}&tourFlag=dc&_json_att=&REPEAT_SUBMIT_TOKEN={1}", timeSpan, info.SubmitToken); string response = HttpHelper.StringGet(_agent, url, _cookie); HttpJsonEntity <Dictionary <string, string> > contentEntity = JsonConvert.DeserializeObject <HttpJsonEntity <Dictionary <string, string> > >(response); if (contentEntity.status.ToUpper().Equals("TRUE") && contentEntity.httpstatus.Equals(200)) { if (contentEntity.data.ContainsKey("msg")) { msg = contentEntity.data["msg"]; return(false); } if (contentEntity.data.ContainsKey("orderId") && !string.IsNullOrEmpty(contentEntity.data["orderId"])) { return(true); } } return(false); } catch (Exception ex) { LogHelper.Error("QueryOrderWaitTime", ex); return(false); } }
/// <summary> /// 获取完整的园区初始化xml /// </summary> /// <param name="floor"></param> /// <param name="parkName"></param> /// <returns></returns> public static InitInfo CreateParkInitInfoByFloors(string parkName, string buildingName, params TopoInfo[] floors) { InitInfo initInfo = new InitInfo(); TopoInfo root = new TopoInfo("根节点", AreaTypes.区域); initInfo.TopoInfo = root; TopoInfo park = new TopoInfo(parkName, AreaTypes.园区);//todo:可以扩展成园区、大楼手动设置 root.AddChild(park); TopoInfo group = new TopoInfo("生产区域", AreaTypes.分组);//todo:可以扩展成园区、大楼手动设置 park.AddChild(group); TopoInfo building = CreateBuildingInitInfoByFloors(buildingName, floors); group.AddChild(building); BoundInfo parkBound = building.BoundInfo.CloneByXml(); parkBound.SetRectangle(); parkBound.Scale(2);//园区默认是比大楼周围一圈 park.BoundInfo = parkBound; park.BoundInfo.IsRelative = false; return(initInfo); }
/// <summary> /// リクエスト処理部分 /// </summary> /// <param name="listenerContext"></param> private async void ProcessRequest(HttpListenerContext listenerContext) { using (WebSocket ws = (await listenerContext.AcceptWebSocketAsync(subProtocol: null)).WebSocket) { try { ArraySegment <byte> initBuff = new ArraySegment <byte>(new byte[1024]); WebSocketReceiveResult ret = await ws.ReceiveAsync(initBuff, CancellationToken.None); if (ret.MessageType == WebSocketMessageType.Text) { string initMessage = Encoding.UTF8.GetString(initBuff.Take(ret.Count).ToArray()); /* * 文字列からTypeに変換する処理のメモ。※今後このコードを使う可能性は低いけれど、メモとして残しておきます。 * Type type = Assembly.GetExecutingAssembly().GetTypes(). * FirstOrDefault(x => x.BaseType == typeof(SessionBase) && x.Name == initMessage); */ WebSocketParam.SessionCount++; InitInfo info = JsonConvert.DeserializeObject <InitInfo>(Encoding.UTF8.GetString(initBuff.Take(ret.Count).ToArray())); if (info.Type != null) { SessionBase session = Activator.CreateInstance(info.Type) as SessionBase; session.WS = ws; await session.Init(info); if (session.Enabled) { await session.Receive(); _logger.Debug("Session End."); if (!string.IsNullOrEmpty(session.Remark)) { _logger.Info(session.Remark); } } else { _logger.Error("Skip: session disable."); if (!string.IsNullOrEmpty(session.Remark)) { _logger.Info(session.Remark); } } } else { _logger.Error("Type Mismatch. [{0}]", initMessage); } WebSocketParam.SessionCount--; } } catch (Exception e) { _logger.Error(e.ToString()); } } }
public static InitInfo GetInstance() { if (_instance == null) { _instance = new InitInfo(); } return(_instance); }
public override bool Init() { if (!base.Init()) { return(false); } Effects.InitAll(Device); InputLayouts.InitAll(Device); RenderStates.InitAll(Device); Patch.InitPatchData(Terrain.CellsPerPatch, Device); _sky = new Sky(Device, "Textures/grasscube1024.dds", 5000.0f); var tii = new InitInfo { HeightMapFilename = null, LayerMapFilename0 = "textures/grass.dds", LayerMapFilename1 = "textures/darkdirt.dds", LayerMapFilename2 = "textures/stone.dds", LayerMapFilename3 = "Textures/lightdirt.dds", LayerMapFilename4 = "textures/snow.dds", BlendMapFilename = null, HeightScale = 50.0f, HeightMapWidth = 2049, HeightMapHeight = 2049, CellSpacing = 0.5f, Seed = 0, NoiseSize1 = 3.0f, Persistence1 = 0.7f, Octaves1 = 7, NoiseSize2 = 2.5f, Persistence2 = 0.8f, Octaves2 = 3, }; _terrain = new Terrain(); _terrain.Init(Device, ImmediateContext, tii); _camera.Height = _terrain.Height; AddUIElements(); _camera.SetLens(0.25f * MathF.PI, AspectRatio, 1.0f, 1000.0f); _ssao = new Ssao(Device, ImmediateContext, ClientWidth, ClientHeight, _camera.FovY, _camera.FarZ); _whiteTex = ShaderResourceView.FromFile(Device, "Textures/white.dds"); _sMap = new ShadowMap(Device, SMapSize, SMapSize); _sceneBounds = new BoundingSphere(new Vector3(), MathF.Sqrt(_terrain.Width * _terrain.Width + _terrain.Depth * _terrain.Depth) / 2); _minimap = new Minimap(Device, ImmediateContext, MinimapSize, MinimapSize, _terrain, _camera); return(true); }
internal InitInfo Parse() { var rslt = new InitInfo(); if (this.State != null) { rslt.Statements.AddRange(State.Parse(null)); } return rslt; }
internal InitInfo Parse() { var rslt = new InitInfo(); if (this.State != null) { rslt.Statements.AddRange(State.Parse(null)); } return(rslt); }
public TransformManager(EntityManager em) { entityManager = em; InitInfo ii = new InitInfo { entityManager = em.GetObj(), pNext = UIntPtr.Zero }; obj = TransformManager_CreateTransformManager_C(ii); em.RegisterForDestroyNow(this); }
//Soukromé metody #region Private methods /// <summary> /// Načtení inicializačních dat z Init.xml do statické třídy InitInfo /// </summary> private void nacistDataZXml() { InitInfo.GetInfo(); XmlRW initXml = new XmlRW(InitInfo.AdresarDat + "\\Init.xml"); //initInfo.AdresarDat obsahuje dafaultně cestu aplikace/Data InitInfo.Ladeni = initXml.ReadBool("bLadeni", "Value", false); string defAdrDat = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Deimos"; InitInfo.AdresarDat = initXml.ReadString("StrAdresarDat", "Value", defAdrDat); }
public SceneManager(EntityManager em, TransformManager tm) { entityManager = em; InitInfo ii = new InitInfo { entityManager = em.GetObj(), transformManager = tm.GetObj(), pNext = UIntPtr.Zero }; obj = SceneManager_CreateSceneManager_C(ii); SceneManager_RegisterManager_C(obj, tm.GetObj()); em.RegisterForDestroyNow(this); }
// GET: DataInit public void SaveInitInfoXml(bool containCAD = true) { Log.InfoStart(LogTags.DbInit, "SaveInitInfoXml"); var root = _bll.GetAreaTree(false, null, containCAD); InitInfo initInfo = new InitInfo(); initInfo.TopoInfo = new TopoInfo(root, containCAD); string initFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\InitTopo_Save.xml"; XmlSerializeHelper.Save(initInfo, initFile, Encoding.UTF8); Log.InfoEnd("SaveInitInfoXml"); }
private bool BuyTicket(string secretStr, List <Passenger> selectedPassengers, string buySeat, QueryTicket selectedTrain, out string msg) { string url = " https://kyfw.12306.cn/otn/login/checkUser"; string data = "_json_att="; msg = "购票失败!"; HttpJsonEntity <Dictionary <string, string> > contentEntity = HttpHelper.Post(_agent, url, data, _cookie); if (contentEntity.status.ToUpper().Equals("TRUE") && contentEntity.httpstatus.Equals(200)) { if (SubmitOrderRequest(secretStr, out msg)) { FormatLogInfo("预提交订单成功!"); InitInfo info = GetInitInfo(); FormatLogInfo("获取页面信息成功!"); if (info != null) { Thread.Sleep(1000); string randCode, passengerTicketStr, oldPassengerStr; if (CheckOrderInfo(selectedPassengers, buySeat, info, out randCode, out passengerTicketStr, out oldPassengerStr)) { FormatLogInfo("核查订单成功!"); Thread.Sleep(1000); if (GetQueueCount(selectedTrain, buySeat, info)) { FormatLogInfo("获取排队人数成功!"); Thread.Sleep(1000); if (ConfirmSingleForQueue(passengerTicketStr, oldPassengerStr, randCode, info, out msg)) { Thread.Sleep(1000); FormatLogInfo("开始排队!"); if (QueryOrderWaitTime(info, out msg)) { EmailHelper.Send("*****@*****.**", "", selectedTrain.Station_Train_Code); MessageBox.Show("订票成功,请及时查询及支付订单!"); return(true); } FormatLogInfo(msg); } } } } } } else { MessageBox.Show("状态异常,需重新登录"); } return(false); }
// GET: DataInit public void SaveInitInfoXml() { Log.InfoStart("SaveInitInfoXml"); var root = _bll.GetAreaTree(false); InitInfo initInfo = new InitInfo(); initInfo.TopoInfo = new TopoInfo(root); string initFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\InitInfo.xml"; XmlSerializeHelper.Save(initInfo, initFile, Encoding.UTF8); Log.InfoEnd("SaveInitInfoXml"); }
public static void GetParkInfoEx(string parkName, int maxFloorCount) { DateTime start = DateTime.Now; InitInfo initInfo = CreateInitInfo(parkName, maxFloorCount); DateTime end = DateTime.Now; TimeSpan t = end - start; string xml = XmlSerializeHelper.GetXmlText(initInfo); MyTool.TextReport("获取整个园区", xml, 700, 500); }
public static void GetParkInfoEx() { DateTime start = DateTime.Now; InitInfo initInfo = CreateInitInfo(); DateTime end = DateTime.Now; TimeSpan t = end - start; string xml = XmlSerializeHelper.GetXmlText(initInfo); Gui.TextReport("获取整个园区", xml, 700, 500); }
private bool CreateFile(string fileName) { if (File.Exists(DataDirInfo.FullName + "\\" + fileName)) { return(true); } else { Write(fileName, InitInfo.ToString()); Config = InitInfo; return(false); } }
public static void TssSdkInit(uint gameId) { InitInfo info; info = new InitInfo { size_ = Marshal.SizeOf(info), game_id_ = gameId, send_data_to_svr = IntPtr.Zero }; tss_sdk_init(info); tss_enable_get_report_data(); tss_log_str(TssSdkVersion.GetSdkVersion()); tss_log_str(TssSdtVersion.GetSdtVersion()); }
/// <summary> /// 核查订单 /// </summary> /// <param name="passengers"></param> /// <param name="buySeat"></param> /// <param name="info"></param> /// <param name="randCode"></param> /// <param name="passengerTicketStr"></param> /// <param name="oldPassengerStr"></param> /// <returns></returns> private bool CheckOrderInfo(List <Passenger> passengers, string buySeat, InitInfo info, out string randCode, out string passengerTicketStr, out string oldPassengerStr) { randCode = ""; passengerTicketStr = string.Empty; oldPassengerStr = string.Empty; try { string url = "https://kyfw.12306.cn/otn/confirmPassenger/checkOrderInfo"; foreach (Passenger passenger in passengers) { string passengerticket = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", buySeat, "0", "1", passenger.passenger_name, passenger.passenger_id_type_code, passenger.passenger_id_no, passenger.mobile_no, 'N'); passengerTicketStr = passengerTicketStr + passengerticket + "_"; string oldPassenger = string.Format("{0},{1},{2},{3}", passenger.passenger_name, passenger.passenger_id_type_code, passenger.passenger_id_no, passenger.passenger_type); oldPassengerStr = oldPassengerStr + oldPassenger + "_"; } string data = string.Format( "cancel_flag=2&bed_level_order_num=000000000000000000000000000000&passengerTicketStr={0}&oldPassengerStr={1}&tour_flag=dc&randCode=&_json_att=&REPEAT_SUBMIT_TOKEN={2}", passengerTicketStr.TrimEnd('_'), oldPassengerStr, info.SubmitToken); LogHelper.Info("CheckOrderInfo data+" + data); HttpJsonEntity <Dictionary <string, string> > contentEntity = HttpHelper.Post(_agent, url, data, _cookie); if (contentEntity.status.ToUpper().Equals("TRUE") && contentEntity.httpstatus.Equals(200)) { if (contentEntity.data.ContainsKey("ifShowPassCode") && contentEntity.data["ifShowPassCode"].ToUpper().Equals("Y")) { ImgCodeForm form = new ImgCodeForm(); form.Cookie = _cookie; form.Agent = _agent; randCode = form.RandCode; form.ShowDialog(); } LogHelper.Info("checkOrderInfo" + url + "成功"); return(true); } return(false); } catch (Exception ex) { LogHelper.Error("CheckOrderInfo", ex); return(false); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Company") { GameObject clone = Instantiate(other.gameObject); clone.GetComponent <BoxCollider>().isTrigger = false; for (int i = 0; i < GameObject.Find("Top").transform.childCount; i++) { GameObject.Find("Top").transform.GetChild(i).GetComponent <BoxCollider>().isTrigger = false; } InitInfo.GetInstance().aviliable = false; clone.transform.parent = GameObject.Find("HandColliderLeft").transform; clone.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0); clone.GetComponent <RectTransform>().localScale = new Vector3(0.3f, 0.3f, 1); } }
public override bool Init() { if (!base.Init()) { return(false); } Effects.InitAll(Device); InputLayouts.InitAll(Device); RenderStates.InitAll(Device); Patch.InitPatchData(Terrain.CellsPerPatch, Device); _sky = new Sky(Device, "Textures/grasscube1024.dds", 5000.0f); var tii = new InitInfo { HeightMapFilename = null, LayerMapFilename0 = "textures/grass.dds", LayerMapFilename1 = "textures/darkdirt.dds", LayerMapFilename2 = "textures/stone.dds", LayerMapFilename3 = "Textures/lightdirt.dds", LayerMapFilename4 = "textures/snow.dds", BlendMapFilename = null, HeightScale = 50.0f, HeightMapWidth = 2049, HeightMapHeight = 2049, CellSpacing = 0.5f, Seed = 0, NoiseSize1 = 1.0f, Persistence1 = 0.7f, Octaves1 = 7, NoiseSize2 = 2.5f, Persistence2 = 0.8f, Octaves2 = 3 }; _terrain = new Terrain(); _terrain.Init(Device, ImmediateContext, tii); _camera.Height = _terrain.Height; AddUIElements(); return(true); }
public override bool Init() { if (!base.Init()) { return(false); } Enable4XMsaa = true; Effects.InitAll(Device); InputLayouts.InitAll(Device); RenderStates.InitAll(Device); _sky = new Sky(Device, "Textures/grasscube1024.dds", 5000.0f); var tii = new InitInfo { HeightMapFilename = "Textures/terrain.raw", LayerMapFilename0 = "textures/grass.dds", LayerMapFilename1 = "textures/darkdirt.dds", LayerMapFilename2 = "textures/stone.dds", LayerMapFilename3 = "Textures/lightdirt.dds", LayerMapFilename4 = "textures/snow.dds", BlendMapFilename = "textures/blend.dds", HeightScale = 50.0f, HeightMapWidth = 2049, HeightMapHeight = 2049, CellSpacing = 0.5f }; Patch.InitPatchData(Terrain.CellsPerPatch, Device); _terrain = new Terrain(); _terrain.Init(Device, ImmediateContext, tii); _randomTex = Util.CreateRandomTexture1DSRV(Device); _flareTexSRV = Util.CreateTexture2DArraySRV(Device, ImmediateContext, new[] { "Textures/flare0.dds" }, Format.R8G8B8A8_UNorm); _fire = new ParticleSystem(); _fire.Init(Device, Effects.FireFX, _flareTexSRV, _randomTex, 500); _fire.EmitPosW = new Vector3(0, 1.0f, 120.0f); _rainTexSRV = Util.CreateTexture2DArraySRV(Device, ImmediateContext, new[] { "Textures/raindrop.dds" }, Format.R8G8B8A8_UNorm); _rain = new ParticleSystem(); _rain.Init(Device, Effects.RainFX, _rainTexSRV, _randomTex, 10000); return(true); }
/// <summary> /// InitInfoにExtensionを埋め込む為のオーバーライド /// </summary> /// <returns></returns> public override async Task Init() { for (int i = 0; WS == null || WS.State != WebSocketState.Open && i < Item.TRY_OPENWAIT; i++) { Thread.Sleep(Item.TRY_INTERVAL); } InitInfo info = new InitInfo(Name, this.GetType()); if (info.Extension == null) { info.Extension = new Dictionary <string, string>(); } info.Extension[Ex_InitInfo_PSPath] = PSPath; await WS.SendAsync( new ArraySegment <byte>(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(info))), WebSocketMessageType.Text, true, CancellationToken.None); if (WS.State == WebSocketState.Open) { using (MemoryStream ms = new MemoryStream()) { ArraySegment <byte> buff = new ArraySegment <byte>(new byte[1024]); WebSocketReceiveResult ret = null; do { ret = await WS.ReceiveAsync(buff, CancellationToken.None); ms.Write(buff.Array, buff.Offset, ret.Count); } while (!ret.EndOfMessage); ms.Seek(0, SeekOrigin.Begin); info = JsonConvert.DeserializeObject <InitInfo>(Encoding.UTF8.GetString(ms.ToArray())); this.Enabled = info.Success; if (!Enabled) { this.Remark = "Error: Server connect failed."; } } } }
private static InitInfo GetClassInitInfo(AbcInstance instance) { var type = instance.Type; if (type == null) { return(null); } var info = new InitInfo(); foreach (var field in type.Fields) { if (field.HasEmbedAttribute()) { info.Assets.Add(field); } } return(info); }
void OnTriggerEnter(Collider other) { if (this.name == "Checkin" && other.gameObject.tag == "Company") { GameObject newOther = Instantiate(other.gameObject); CompanyList.Add(newOther); Destroy(other.gameObject); //other.transform.parent=GameObject.Find("Right").transform; } else if (this.name == "Cancel" && other.gameObject.tag == "Company") { Destroy(other.gameObject); } for (int i = 0; i < GameObject.Find("Top").transform.childCount; i++) { GameObject.Find("Top").transform.GetChild(i).GetComponent <BoxCollider>().isTrigger = true; } InitInfo.GetInstance().aviliable = true; }
/// <summary> /// Initメッセージ受信 (セッション開始) /// </summary> /// <param name="info"></param> public virtual async Task Init(InitInfo info) { if (info.CheckVersion()) { this.Enabled = true; info.Success = true; } else { this.Remark = string.Format( "Error: Version mismatch. Sender->{0} Receiver->{1}", info.Version, WebSocketParam.Version); //"Error: Version mismatch. Sender->{0} Receiver->{1}", info.Version, Item.Version); } await WS.SendAsync( new ArraySegment <byte>(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(info))), WebSocketMessageType.Text, true, CancellationToken.None); }
/// <summary> /// 确认购票 /// </summary> /// <param name="passengerTicketStr"></param> /// <param name="oldPassengerStr"></param> /// <param name="randCode"></param> /// <param name="info"></param> /// <returns></returns> private bool ConfirmSingleForQueue(string passengerTicketStr, string oldPassengerStr, string randCode, InitInfo info, out string msg) { msg = "确认购票失败!"; try { Thread.Sleep(3000); string url = "https://kyfw.12306.cn/otn/confirmPassenger/confirmSingleForQueue"; string data = string.Format( "passengerTicketStr={0}&oldPassengerStr={1}&randCode={2}&purpose_codes={3}&key_check_isChange={4}C&leftTicketStr={5}&train_location={6}&choose_seats=&seatDetailType=000&whatsSelect=1&roomType=00&dwAll=N&_json_att=&REPEAT_SUBMIT_TOKEN={7}", UrlEncode(passengerTicketStr), UrlEncode(oldPassengerStr), randCode, info.PurposeCodes, info.KeyCheck, info.LeftTicketInfo, info.Location, info.SubmitToken); dynamic contentEntity = HttpHelper.DynamicPost(_agent, url, data, _cookie); LogHelper.Info(contentEntity.ToString()); if ((bool)contentEntity.status && contentEntity.httpstatus == 200) { if (contentEntity.data.submitStatus != null && (bool)contentEntity.data.submitStatus) { return(true); } if (contentEntity.data.errMsg != null) { msg = contentEntity.data.errMsg; } } else { msg = contentEntity.data; } } catch (Exception ex) { LogHelper.Error("ConfirmSingleForQueue", ex); } return(false); }
private static extern void tss_sdk_init(InitInfo info);
/// <summary> /// Tsses the sdk init. /// </summary> /// <param name='gameId'> /// game id provided by sdk provider /// </param> public static void TssSdkInit(uint gameId) { InitInfo info = new InitInfo(); info.size_ = (uint)Marshal.SizeOf(info); info.game_id_ = gameId; info.send_data_to_svr = (IntPtr)0; tss_sdk_init(info); tss_enable_get_report_data(); tss_log_str(TssSdkVersion.GetSdkVersion()); tss_log_str(TssSdtVersion.GetSdtVersion()); }