示例#1
0
        public int Update(ctl_fly model)
        {
            NpgsqlConnection con = new NpgsqlConnection(CodeDal.ConStr["postgres"]);

            try
            {
                using (con)
                {
                    con.Open();
                    return(SqlMapper.Execute(con, CodeDal.QueryStr["updateSingle"], model));
                }
            }
            catch (Exception)
            {
                if (con.State != ConnectionState.Closed)
                {
                    try
                    {
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                throw;
            }
        }
示例#2
0
        private string CommandToString(ctl_fly newCommand)
        {
            if (newCommand == null)
            {
                return(null);
            }
            switch (newCommand.fly_code)
            {
            case 1:
                return($@"{newCommand.input_time.ToString("yyyyMMdd HH:mm:ss")}执行起飞指令");

            case 2:
                return($@"{newCommand.input_time.ToString("yyyyMMdd HH:mm:ss")}执行降落指令");

            case 3:
                return($@"{newCommand.input_time.ToString("yyyyMMdd HH:mm:ss")}执行上升指令");

            case 4:
                return($@"{newCommand.input_time.ToString("yyyyMMdd HH:mm:ss")}执行下降指令");

            case 5:
                return($@"{newCommand.input_time.ToString("yyyyMMdd HH:mm:ss")}执行左转指令");

            case 6:
                return($@"{newCommand.input_time.ToString("yyyyMMdd HH:mm:ss")}执行右转指令");

            default:
                return(null);
            }
        }
示例#3
0
        public bool FlyRight()
        {
            ctl_fly ctlFly = new ctl_fly()
            {
                id = 1, input_time = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), fly_code = 6
            };

            try
            {
                return(Update(ctlFly));
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void RefreshLayout(object state)
        {
            lock (this)
            {
                CtlFlyBll bll = new CtlFlyBll();
                string    msg = string.Empty;
                _last = bll.ReadAndAnalysis(_last, out msg);
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    SystemSounds.Beep.Play();
                    PrintMsg(msg);
                    if (_last != null)
                    {
                        switch (_last.fly_code)
                        {
                        case 1:
                            ChangeOnColor();
                            break;

                        case 2:
                            ChangeOffColor();
                            break;

                        case 3:
                            ChangeUpColor();
                            break;

                        case 4:
                            ChangeDownColor();
                            break;

                        case 5:
                            ChangeLeftColor();
                            break;

                        case 6:
                            ChangeRightColor();
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
示例#5
0
 public ctl_fly ReadAndAnalysis(ctl_fly lastCommand, out string msg)
 {
     try
     {
         CtlFlyDal dal        = new CtlFlyDal();
         ctl_fly   newCommand = dal.GetSingle();
         if (lastCommand == null && newCommand == null)
         {
             msg = null;
             return(null);
         }
         else if (lastCommand == null && newCommand != null)
         {
             msg = CommandToString(newCommand);
             return(newCommand);
         }
         else if (lastCommand != null && newCommand == null)
         {
             msg = "命令已初始化完成";
             return(null);
         }
         else
         {
             if (lastCommand.input_time == newCommand.input_time && lastCommand.fly_code == newCommand.fly_code)
             {
                 msg = null;
                 return(newCommand);
             }
             else
             {
                 msg = CommandToString(newCommand);
                 return(newCommand);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#6
0
 private bool Update(ctl_fly ctlFly)
 {
     if (ctlFly == null || ctlFly.id != 1)
     {
         throw new Exception("couldnot be null and id must be 1");
     }
     try
     {
         CtlFlyDal dal = new CtlFlyDal();
         if (dal.GetCount() > 0)
         {
             return(dal.Update(ctlFly) > 0);
         }
         else
         {
             return(dal.Insert(ctlFly) > 0);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        private void RefreshLayout(object state)
        {
            lock (this)
            {
                CtlFlyBll bll = new CtlFlyBll();
                string    msg = string.Empty;
                _last = bll.ReadAndAnalysis(_last, out msg);
                //if (_last!=null)
                //{
                //    PrintMsg(_last.fly_code.ToString() + _last.input_time);
                //}
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    SystemSounds.Beep.Play();
                    PrintMsg(msg);
                    if (_last != null)
                    {
                        switch (_last.fly_code)
                        {
                        case 1:
                            ChangeForeColor(txtOn, Color.FromRgb(255, 52, 0));
                            Thread.Sleep(3000);
                            ChangeForeColor(txtOn, Color.FromRgb(135, 206, 235));
                            break;

                        case 2:
                            ChangeForeColor(txtOff, Color.FromRgb(255, 52, 0));
                            Thread.Sleep(3000);
                            ChangeForeColor(txtOff, Color.FromRgb(116, 116, 222));
                            break;

                        case 3:
                            ChangeForeColor(txtUp, Color.FromRgb(255, 52, 0));
                            Thread.Sleep(3000);
                            ChangeForeColor(txtUp, Color.FromRgb(0, 128, 0));
                            break;

                        case 4:
                            ChangeForeColor(txtDown, Color.FromRgb(255, 52, 0));
                            Thread.Sleep(3000);
                            ChangeForeColor(txtDown, Color.FromRgb(0, 128, 0));
                            break;

                        case 5:
                            ChangeForeColor(txtLeft, Color.FromRgb(255, 52, 0));
                            Thread.Sleep(3000);
                            ChangeForeColor(txtLeft, Color.FromRgb(0, 128, 0));
                            break;

                        case 6:
                            ChangeForeColor(txtRight, Color.FromRgb(255, 52, 0));
                            Thread.Sleep(3000);
                            ChangeForeColor(txtRight, Color.FromRgb(0, 128, 0));
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }