示例#1
0
        public void SendProgram(int ledId, Program program, TextStyle style = null)
        {
            //客户端发送的节目
            if (program.ID == 0 && !string.IsNullOrEmpty(program.ClientID))
            {
                ProgramManager.Save(program);
            }
            //客户端发送的节目默认为无限次播放,没有截至时间
            var schedule = new Schedule
            {
                LEDIDs = new int[] { ledId },
                BeginTime = DateTime.Now,
                PlayMode = PlayMode.立即开始,
                ProgramID = program.ID,
            };
            ScheduleManager.Save(schedule);

            if (style != null)
            {
                var led = LEDManager.GetModel(ledId);
                led.CustomStyle = style;
                LEDManager.Save(led);
            }
        }
示例#2
0
 public static void Save(Schedule model)
 {
     if (model.ID > 0)
     {
         DbHelper.ExecuteSql(@"
     update Schedule set
     PlayMode = @PlayMode,
     BeginTime = @BeginTime,
     EndTime = @EndTime,
     PlayTimes = @PlayTimes
     where ID = @ID
     ",
             new SQLiteParameter("@ID", model.ID),
             new SQLiteParameter("@PlayMode", (int)model.PlayMode),
             new SQLiteParameter("@BeginTime", model.BeginTime),
             new SQLiteParameter("@EndTime", model.EndTime),
             new SQLiteParameter("@PlayTimes", model.PlayTimes));
     }
     else
     {
         var newId = DbHelper.ExecuteScalar(@"
     insert into Schedule
     (ProgramID,CreateTime,PlayMode,BeginTime,EndTime,PlayTimes) values
     (@ProgramID,@CreateTime,@PlayMode,@BeginTime,@EndTime,@PlayTimes);
     select last_insert_rowid();",
             new SQLiteParameter("@ProgramID", model.ProgramID),
             new SQLiteParameter("@CreateTime", model.CreateTime),
             new SQLiteParameter("@PlayMode", (int)model.PlayMode),
             new SQLiteParameter("@BeginTime", model.BeginTime),
             new SQLiteParameter("@EndTime", model.EndTime),
             new SQLiteParameter("@PlayTimes", model.PlayTimes)
          );
         model.ID = int.Parse(newId.ToString());
     }
     DbHelper.ExecuteSql("delete from ScheduleLED where ScheduleID = " + model.ID);
     foreach (var ledId in model.LEDIDs)
     {
         DbHelper.ExecuteSql("insert into ScheduleLED(ScheduleID,LEDID)values(@ScheduleID,@LEDID)",
             new SQLiteParameter("@ScheduleID", model.ID),
             new SQLiteParameter("@LEDID", ledId));
     }
 }
示例#3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (lstLED.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择需要播放的LED屏幕,可多选");
                return;
            }

            var program = ProgramManager.GetModel(ProgramID);
            var playMode = StringHelper.ToEnum<Model.PlayMode>(cbxPlayMode.Text);
            var playTimes = StringHelper.ToInt(txtPlayTimes.Text);
            var duration = StringHelper.ToDouble(txtDuration.Text);
            var beginTime = playTimeControl1.GetValue();
            DateTime? endTime = null;
            if (duration > 0)
            {
                endTime = beginTime.AddMinutes(60 * duration);
            }
            else if (playTimes > 0) //如果设置了播放次数,则不能设置播放时长
            {
                duration = program.Duration * playTimes;
                endTime = beginTime.AddSeconds(duration);
            }

            var ledIds = new List<int>();
            foreach (DataGridViewRow row in lstLED.SelectedRows)
            {
                ledIds.Add(int.Parse(row.Cells["ID"].Value.ToString()));
            }

            var model = new Schedule()
            {
                ProgramID = ProgramID,
                LEDIDs = ledIds.ToArray(),
                PlayMode = playMode,
                BeginTime = beginTime,
                EndTime = endTime,
                PlayTimes = playTimes,
            };

            ScheduleManager.Save(model);

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }