public void TestLiveValueDistinct() { var x = new Live<int>(0, 0); var r = x.DistinctUntilChanged(); r.States().Take(1).Check( () => { }, results => { var state = results.Single(); Assert.AreEqual(StateStatus.Connecting, state.Status); Assert.AreEqual(0, state.NewValue); Assert.AreEqual(0, state.LastUpdated); }); r.States().Skip(1).Take(1).Check( () => x.SetValue(0, 100), results => Assert.AreEqual(0, results.Count())); r.States().Skip(1).Take(1).Check( () => x.SetValue(1, 200), results => { var state = results.Single(); Assert.AreEqual(StateStatus.Connected, state.Status); Assert.AreEqual(1, state.NewValue); Assert.AreEqual(0, state.OldValue); Assert.AreEqual(200, state.LastUpdated); }); }
public vLive(Live model) { this.ID = model.ID; this.Title = model.Title; this.Description = model.Description; this.LiveURL = model.LiveURL; this.Begin = model.Begin; this.End = model.End; }
public vSearchResultModel(Live model) { this.ID = model.ID; this.Title = model.Title; if (model.Begin <= DateTime.Now && model.End >= DateTime.Now) { this.URL = "/Live/Show/" + model.ID; } else { this.URL = "/Live/ReviewShow/" + model.ID; } this.Sumamry = Helpers.String.SubString(model.Description,50,"..."); this.Time = model.Begin; }
private void OnHarvest() { Harvesting.Invoke(); DateTime Today = new DateTime(Year, 1, 1); Today = Today.AddDays(Day - 1); string Indent = " "; string Title = Indent + Today.ToShortDateString() + " - Harvesting " + Name + " from " + Plant.Name; double YieldDW = (Live.Wt + Dead.Wt); Console.WriteLine(""); Console.WriteLine(Title); Console.WriteLine(Indent + new string('-', Title.Length)); Console.WriteLine(Indent + Name + " Yield DWt: " + YieldDW.ToString("f2") + " (g/m^2)"); Console.WriteLine(""); Live.Clear(); Dead.Clear(); }
/// <summary> /// // 获取可购票务列表 , 包括票务基本信息 /// </summary> private void GetTickets() { // 打开票务页面 // https://shop.48.cn/tickets // 查找每一个 <li class="gs_2t"><a title="星梦剧院11月11日NIII队剧场公演" href="/tickets/item/2607">广州星梦剧院11月11日NIII队剧场公演</a></li> var allTicketPageString = util.GET("https://shop.48.cn/tickets", cc); allTicketPageString = allTicketPageString.Replace("\\", ""); Regex regexp = new Regex("<li class=\"gs_2t\">.{20,100}</a></li>"); MatchCollection matchCollection1 = regexp.Matches(allTicketPageString); // 获取票务基本信息 foreach (var item in matchCollection1) { // item : <li class="gs_2t"><a title="星梦剧院11月11日NIII队剧场公演" href="/tickets/item/2607" title="....">广州星梦剧院11月11日NIII队剧场公演</a></li> string liString = item.ToString(); int num1 = liString.IndexOf("剧院"); int num2 = liString.IndexOf("月"); int num3 = liString.IndexOf("日"); int num4 = liString.IndexOf("公演"); int num5 = liString.LastIndexOf("\">"); int num6 = liString.LastIndexOf("星梦剧院"); int num7 = liString.LastIndexOf("item/"); int num8 = liString.LastIndexOf("title="); string city = liString.Substring(num5 + 2, num6 - num5 - 2); // 沈阳 string month = liString.Substring(num1 + 2, num2 - num1 - 2); // 11 string day = liString.Substring(num2 + 1, num3 - num2 - 1); // 10 string team = liString.Substring(num3 + 1, num4 - num3 - 1);; // SIII队 / 预备生 team = team.Replace("剧场", ""); string ticketNumber = liString.Substring(num7 + 5, num8 - num7 - 7); // 2607 Live live = LiveUtil.GetLive(city, month, day, team, ticketNumber); allLives.Add(live); } }
protected void Page_Load(object sender, EventArgs e) { if ((Session["adminUserName"] == null) && (Session["adminUserRole"] == null)) { Response.Redirect("../error.aspx"); } string studentNumber = Request.QueryString["studentNumber"]; this.studentNumber.Text = studentNumber; Live live = new Live(); if (false == live.GetOutInfo(studentNumber)) //得到该学生的迁出信息 { Response.Write("<script>alert('" + live.ErrMessage + "');location.href='liveInfoManage.aspx'</script>"); } if (!IsPostBack) { this.studentName.Text = live.StudentName; this.apartmentNo.Text = live.ApartmentNo; this.roomNo.Text = live.RoomNo; } }
private async Task <List <Fixture> > getTodaysFixtures(Event ev) { Live liveData = await _client.getLiveData(ev.id); if (liveData == null) { return(new List <Fixture>()); } List <Fixture> retFixtures = new List <Fixture>(); foreach (var fixture in liveData.fixtures) { DateTime now = DateTime.Now; DateTime kickoff = Date.fromApiString(fixture.kickoff_time); if (kickoff.Month == now.Month && kickoff.Day == now.Day) { retFixtures.Add(fixture); } } return(retFixtures); }
public int GoLive(int id, string author) { Live live = null; if (_repository.DraftExists(id)) { var draft = _repository.GetDraft(id); live = draft.GoLive(author); } if (_repository.PlannedExists(id)) { var planned = _repository.GetPlanned(id); live = planned.GoLive(author); } else { throw new NotSupportedException($"There is no draft or planned configuration with id: {id}"); } return(_repository.Save(live)); }
public static void Save() { try { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\GameTest\Save.txt")) { foreach (ILivingInterface Live in LivingList) { file.WriteLine(Live.ToString()); } } } catch (System.IO.IOException e) { Console.WriteLine("Game not saved properly"); Console.WriteLine(e); } finally { Console.WriteLine("Saving Ended"); } }
public Queue <IInstruction> CreateInstructions(string instructionString, ICell[,] grid, ICellPosition position) { Queue <IInstruction> result = new Queue <IInstruction>(); IInstruction tempInstruction = null; var set = instructionString.Split(' '); foreach (string instruction in set) { switch (instruction) { case "x": tempInstruction = new Live(grid, position); break; case "up": tempInstruction = new Up(grid, position); break; case "down": tempInstruction = new Down(grid, position); break; default: case "left": tempInstruction = new Left(grid, position); break; case "right": tempInstruction = new Right(grid, position); break; } result.Enqueue(tempInstruction); } return(result); }
public void TestLiveBasics() { var a = new Live<int>(-1) { Transactional = false }; a.Trace("a"); a.States().Take(1).Check( () => { }, results => { var state = results.Single(); Assert.AreEqual(StateStatus.Connecting, state.Status); Assert.IsFalse(state.HasChange); Assert.AreEqual(-1, state.NewValue); }); a.States().Check( () => a.SetValue(1, 1000), results => { var state = results.Single(); Assert.AreEqual(StateStatus.Connected, state.Status); Assert.IsTrue(state.HasChange); Assert.AreEqual(-1, state.OldValue); Assert.AreEqual(1000, state.LastUpdated); }); a.States().Skip(1).Take(1).Check( () => a.SetValue(2, 2000), results => { var state = results.Single(); Assert.AreEqual(StateStatus.Connected, state.Status); Assert.IsTrue(state.HasChange); Assert.AreEqual(1, state.OldValue); Assert.AreEqual(2, state.NewValue); Assert.AreEqual(2000, state.LastUpdated); }); }
public void Alternative_Simulation_War(DataManager manager) { int length = DataHolder.DataHolder.Lives.Count; if (length > 1) { Live hero = DataHolder.DataHolder.Lives.FirstOrDefault(); bool survived = true; Console.WriteLine(hero.Name + " started journey with " + hero.HP + " HP!"); manager.Write(hero.Name + " started journey with " + hero.HP + " HP!"); for (int i = 1; i < length; i++) { Live enemy = DataHolder.DataHolder.Lives[i]; bool state = Alternative_Attack(hero, enemy); if (state) { Console.WriteLine(hero.Name + " defeated " + enemy.Name + " with " + hero.HP + " HP remaining"); manager.Write(hero.Name + " defeated " + enemy.Name + " with " + hero.HP + " HP remaining"); } else { Console.WriteLine(hero.Name + " is Dead! Last seen at position " + hero.Location + "!!"); manager.Write(hero.Name + " is Dead! Last seen at position " + hero.Location + "!!"); survived = false; break; } } if (survived) { Console.WriteLine(hero.Name + " Survived!"); manager.Write(hero.Name + " Survived!"); } } }
/// <summary> /// 添加,修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { if (btnUpdate.Text == "添加") { Consumption model = new Consumption(); model.C_Name = txtName.Value.Trim(); model.C_Price = Convert.ToDecimal(txtPrice.Value.Trim()); model.C_Time = Convert.ToDateTime(txtTime.Value.Trim()); Live live = LiveBLL.GetIdByLive(Convert.ToInt32(Request.QueryString["id"])); model.L_Id = live.L_Id; model.U_Id = users.U_Id; if (ConsumptionBLL.AddConsumption(model) > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');window.location.replace('ConsumptionAdd.aspx?id=" + Request.QueryString["id"] + "');</script>"); return; } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>"); return; } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); var batTexture = Content.Load <Texture2D>("Bat"); var ballTexture = Content.Load <Texture2D>("Ball"); var font = Content.Load <SpriteFont>("Font"); var blockTextures = new List <Texture2D>() { { Content.Load <Texture2D>("block1") }, { Content.Load <Texture2D>("block2") }, { Content.Load <Texture2D>("block3") }, { Content.Load <Texture2D>("block4") }, { Content.Load <Texture2D>("block5") }, { Content.Load <Texture2D>("block6") }, { Content.Load <Texture2D>("block7") }, }; blocks = new Blocks(blockTextures); bat = new Bat(batTexture) { input = new Input() { Left = Keys.Left, Right = Keys.Right, } }; ball = new Ball(ballTexture); live = new Live(font) { position = new Vector2(2, 2), }; StartGame(); }
/// <summary> /// 添加,修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { if (btnUpdate.Text == "添加") { Live model = new Live(); model.L_Deposit = Convert.ToDecimal(txtDeposit.Value.Trim()); model.L_IdCard = txtIdCard.Value.Trim(); model.L_Name = txtName.Value.Trim(); model.L_No = txtNo.Value.Trim(); model.L_OutTime = Convert.ToDateTime("1900-01-01"); model.L_Pay = 0; model.L_State = "未结算"; model.L_Tel = txtTel.Value.Trim(); model.L_Time = Convert.ToDateTime(txtTime.Value); model.L_Total = 0; model.R_Id = Convert.ToInt32(ddlR_Id.SelectedValue); model.U_Id = users.U_Id; if (LiveBLL.AddLive(model) > 0) { Room room = RoomBLL.GetIdByRoom(Convert.ToInt32(ddlR_Id.SelectedValue)); room.R_State = "入住"; RoomBLL.UpdateRoom(room); Orders ord = OrdersBLL.GetIdByOrders(Convert.ToInt32(Request.QueryString["id"])); ord.O_State = "已入住"; OrdersBLL.UpdateOrders(ord); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');window.location.replace('OrdersJoin.aspx');</script>"); return; } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>"); return; } } }
void SendStart(string uuid) { LiveCourseNotifyClient client = new LiveCourseNotifyClient(); Uri url = client.Endpoint.Address.Uri; client.Endpoint.Address = new EndpointAddress(url.Scheme + "://" + config["cloud_ip"] + ":" + config["cloud_port"] + url.PathAndQuery); Log.log(string.Format("[LivingcastTask] SendStart: wsurl={0}\n", client.Endpoint.Address.ToString())); Live live = new Live() { Title = config["title"], Teacher = config["teacher"], Owner = config["teacher"] + "@" + config["domain"], Subject = StartParam.subject, Grade = config["grade"], Guid = Guid.Parse(uuid), LiveUrls = new LiveUrl[1], }; foreach (LivingcastStream s in Streams) { live.LiveUrls[0] = new LiveUrl() { Url = s.RtmpURL, Tag = s.Mode, }; } try { ZQNB.Gateway.LiveService.OperationResult result = client.NotifyRecordingStart(live, config["device_id"]); Log.log("\ten, success=" + result.Success + ", message=" + result.Message); } catch (CommunicationException) { Log.log("\tCommunicationException\n"); client.Abort(); } catch (TimeoutException) { Log.log("\tTimeoutException\n"); client.Abort(); } catch (Exception) { Log.log("\tException\n"); client.Abort(); } finally { if (client != null) { client.Close(); } } }
public void TestCollectionUnwrap() { var l = new Live<int>[0].ToCollection().ToLiveCollection(); l.Unwrap().ToIndependent().States().Take(1).Check( () => { }, state => { var s = state.Single(); Debug.Assert(s.Status == StateStatus.Connecting); Debug.Assert(s.Inner.SequenceEqual(new int[] { })); Debug.Assert(s.Delta == null); }); l.Unwrap().ToIndependent().States().Skip(1).Take(1).Check( () => l.PublishInner.Add(1.ToLive()), state => { var s = state.Single(); Debug.Assert(s.Status == StateStatus.Connected); Debug.Assert(s.Delta.HasChange()); Debug.Assert(s.Inner.UnorderedEqual(new[] { 1 })); Debug.Assert(s.Delta.Inserts.UnorderedEqual(new[] { 1 })); }); l.Unwrap().ToIndependent().States().Skip(1).Take(1).Check( () => l.PublishInner.Add(2.ToLive()), state => { var s = state.Single(); Debug.Assert(s.Status == StateStatus.Connected); Debug.Assert(s.Delta.HasChange()); Debug.Assert(s.Inner.UnorderedEqual(new[] { 1, 2 })); Debug.Assert(s.Delta.Inserts.UnorderedEqual(new[] { 2 })); }); l.Unwrap().ToIndependent().States().Skip(1).Take(1).Check( () => l.PublishInner.Single(i => i.Value == 2).PublishValue = 3, state => { var s = state.Single(); Debug.Assert(s.Status == StateStatus.Connected); Debug.Assert(s.Delta.HasChange()); Debug.Assert(s.Inner.UnorderedEqual(new[] { 1, 3 })); Debug.Assert(s.Delta.Inserts.UnorderedEqual(new[] { 3 })); Debug.Assert(s.Delta.Deletes.UnorderedEqual(new[] { 2 })); }); l.Unwrap().ToIndependent().States().Skip(1).Take(1).Check( () => l.PublishInner.Remove(l.PublishInner.Single(i => i.Value == 3)), state => { var s = state.Single(); Debug.Assert(s.Status == StateStatus.Connected); Debug.Assert(s.Delta.HasChange()); Debug.Assert(s.Inner.UnorderedEqual(new[] { 1 })); Debug.Assert(s.Delta.Deletes.UnorderedEqual(new[] { 3 })); }); l.Unwrap().ToIndependent().States().Skip(1).Take(1).Check( () => l.PublishInner.Remove(l.PublishInner.Single(i => i.Value == 1)), state => { var s = state.Single(); Debug.Assert(s.Status == StateStatus.Connected); Debug.Assert(s.Delta.HasChange()); Debug.Assert(s.Inner.UnorderedEqual(new int[0])); Debug.Assert(s.Delta.Deletes.UnorderedEqual(new[] { 1 })); }); }
void commentClient_CommentSent(object sender, Live.CommentRoomSentEventArgs e) { var client = (Live.CommentClient)sender; if (client.LeaveCommentCount == 0) { /*this.commentClient.BroadcastComment( "テスト(^o^)d", "184", DateTime.Now);*/ } }