public Task_Details(Model.task_info task)
 {
     InitializeComponent();
     this.task_info = task;
     //设置皮肤
     skinEngine1.SkinFile = Application.StartupPath + @"\RealOne.ssk";
 }
 public GunarkDoorStatus(Model.task_info _task_info, byte[] _gun_number, byte[] _magazine_number)
 {
     task_info = _task_info;
     gun_number = _gun_number;
     magazine_number = _magazine_number;
     InitializeComponent();
     //设置皮肤
     skinEngine1.SkinFile = Application.StartupPath + @"\RealOne.ssk";
 }
        public static void download(Model.fingerprint fingerprint)
        {
            //实例化指纹验证对象
            Printer p = PrinterInstance.getInstance().getPrinter();
            Bll.fingerprint fingerPrint_bll = new Gunark.BLL.fingerprint();
            //p.OpenPort();
            int userId = fingerprint.ID;
            string print = System.Text.Encoding.Default.GetString(fingerprint.USER_FINGERPRINT);
            string[] pr = print.Split(' ');

            byte[] finger = new byte[1600];
            for (int i = 0; i < pr.Length - 1; i++)
            {
                finger[i] = Convert.ToByte(pr[i], 16);
            }

            //System.Windows.Forms.MessageBox.Show(fingerByte.Length.ToString());

            //下载用户
            bool isDownloadUser = false;
            List<Model.fingerprint> list = fingerPrint_bll.GetModelList("USER_POLICENUMB = "+fingerprint.USER_POLICENUMB);
            foreach(Model.fingerprint fi in list)
            {
                if (fi.IS_UPDATE == 1)
                {
                    isDownloadUser = true;
                    break;
                }
            }
            if (!isDownloadUser)
            {
                p.downloadUser((byte)userId);
                //while (true)
                //{
                //    if (p.Downuserbool)
                //    {
                //        fingerprint.IS_UPDATE = 1;
                //        fingerPrint_bll.Update(fingerprint);
                //        p.Downuserbool = false;
                //        System.Windows.Forms.MessageBox.Show("用户下载成功");
                //        break;
                //    }
                //}
            }
            //下载指纹
            p.downloadfinger(finger, (byte)userId);
            //while (true)
            //{
            //    if (p.Downprinterbool)
            //    {
            //        System.Windows.Forms.MessageBox.Show("指纹下载成功!");
            //        break;
            //    }
            //}
        }
 public static void input(Model.fingerprint fingerprint, byte[] finger)
 {
     //实例化指纹验证对象
     Printer p = PrinterInstance.getInstance().getPrinter();
     Bll.fingerprint fingerPrint_bll = new Gunark.BLL.fingerprint();
     //p.OpenPort();
     int userId = fingerprint.ID;
     //下载用户
     //System.Windows.Forms.MessageBox.Show("开始下载用户");
     p.downloadUser((byte)userId);
     while (true)
     {
         if (p.Downuserbool)
         {
             p.Downuserbool = false;
             System.Windows.Forms.MessageBox.Show("用户下载成功");
             break;
         }
         if (!p.DownuserFail)
         {
             System.Windows.Forms.MessageBox.Show("用户下载失败");
             p.DownuserFail = true;
             break;
         }
     }
     //System.Threading.Thread.Sleep(5000);
     //if (p.GetDownuserbool())
     //{
     //    p.Downuserbool = false;
     //    System.Windows.Forms.MessageBox.Show("用户下载成功");
     //}
     //else
     //{
     //    System.Windows.Forms.MessageBox.Show("用户下载失败");
     //}
     //下载指纹
     //System.Windows.Forms.MessageBox.Show("开始下载用户");
     p.downloadfinger(finger, (byte)userId);
     while (true)
     {
         if (p.Downprinterbool)
         {
             p.Downprinterbool = false;
             System.Windows.Forms.MessageBox.Show("指纹录入成功!");
             break;
         }
         if(!p.DownprinterFail)
         {
             p.DownprinterFail = true;
             System.Windows.Forms.MessageBox.Show("指纹录入失败");
             break;
         }
     }
 }
 /// <summary>
 /// 更改任务、枪柜、枪位、子弹数量状态
 /// </summary>
 /// <param name="task_info">任务对象</param>
 /// <param name="task_status">任务状态</param>
 /// <param name="gun_status">枪支状态</param>
 /// <param name="gun_pos_status">枪位状态</param>
 /// <param name="gun_info_id">枪支id集合</param>
 /// <param name="gun_pos_id">枪位id集合</param>
 /// <param name="magazine_id">子弹id集合</param>
 /// <param name="list_bullet">子弹任务详情集合</param>
 public static void update(Model.task_info task_info, string task_status, string gun_status, string gun_pos_status,string bullet_opreat, List<string> gun_info_id, List<string> gun_pos_id, List<string> magazine_id, List<Model.task_info_detail> list_bullet)
 {
     task_info.TASK_STATUS = task_status;
     new BLL.task_info().Update(task_info);
     //更新枪支状态“3”表示未置枪,“1”表示置枪
     for (int i = 0; i < gun_info_id.Count; i++)
     {
         Model.gun_info gun_info = new BLL.gun_info().GetModel(gun_info_id[i]);
         if (task_info.task_BigType == 2)
         {
             gun_info.IN_TIME = DateTime.Now;
         }
         else if (task_info.task_BigType == 5 || task_info.task_BigType == 7 || task_info.task_BigType == 12)
         {
             gun_info.OUT_TIME = DateTime.Now;
         }
         gun_info.GUN_STATUS = gun_status;
         new BLL.gun_info().Update(gun_info);
     }
     //更新枪柜状态,“2”表示未置枪,“3”表示置枪,"8"表示已封存,”7“表示已出库
     for (int i = 0; i < gun_pos_id.Count; i++)
     {
         Model.position_info gun_pos_info = new BLL.position_info().GetModel(gun_pos_id[i]);
         gun_pos_info.GUN_POSITION_STATUS = gun_pos_status;
         new BLL.position_info().Update(gun_pos_info);
     }
     //更新现存子弹数量,库存量-取弹数量
     if (bullet_opreat == "取弹")
     {
         for (int i = 0; i < magazine_id.Count; i++)
         {
             Model.magazine_info mag_info = new BLL.magazine_info().GetModel(magazine_id[i]);
             mag_info.STOCK_QTY = mag_info.STOCK_QTY - list_bullet[i].APPLY_BULLET_QTY;
             new BLL.magazine_info().Update(mag_info);
         }
     }
     else if (bullet_opreat == "还弹")
     {
         for (int i = 0; i < magazine_id.Count; i++)
         {
             Model.magazine_info mag_info = new BLL.magazine_info().GetModel(magazine_id[i]);
             mag_info.STOCK_QTY = mag_info.STOCK_QTY + list_bullet[i].APPLY_BULLET_QTY;
             new BLL.magazine_info().Update(mag_info);
         }
     }
 }
        /// <summary>
        /// 控制柜子公共类
        /// </summary>
        /// <param name="task_info">任务对象</param>
        /// <param name="gun_number">枪位号集合</param>
        /// <param name="magazine_number">弹仓号集合</param>
        /// <returns></returns>
        public static bool control(Model.task_info task_info, byte[] gun_number, byte[] magazine_number)
        {
            Communication comm = CommunicationInstance.getInstance().getCommunication();

            //WebService接口调用工具
            WebService.gunServices webService = SingleWebService.getWebService();
            if (gun_number.Length > 0 || task_info.task_BigType == 14)
            {
                //标识发完开门指令后多少秒还未开门
                int count = 0;
                //开枪柜门(枪支封存解封不开柜门)
                if (task_info.task_BigType != 4 && task_info.task_BigType != 10)
                    comm.send_message(Port.Get_ComGun(), Communication.open);
                //枪支封存
                if (task_info.task_BigType == 4)
                {
                    PlaySound.paly(Properties.Resources._29);
                    return true;
                }
                //枪支解封
                if (task_info.task_BigType == 10)
                {
                    PlaySound.paly(Properties.Resources._30);
                    return true;
                }
                //语音提示
                PlaySound.paly(Properties.Resources._9);
                //如果柜门已经打开,再发解锁枪位指令
                while (PubFlag.gunark_control_isAile)
                {
                    //将此循环设置为1秒执行一次,判断25秒之后还未将门打开,此时柜门已重新锁上

                    //查询枪柜门状态
                    bool gunDoorStatus = SearchDoorStatus.searchGunStatus();
                    System.Threading.Thread.Sleep(1000);
                    count++;
                    if (count > 20)
                        return false;
                    //判断枪柜门是否已经打开
                    if (gunDoorStatus)
                    {
                        GunarkDoorStatus gds = new GunarkDoorStatus(task_info, gun_number, magazine_number);
                        gds.pictureBox1.Image = Properties.Resources.gun_open;
                        gds.pictureBox2.Image = Properties.Resources.openDoor;
                        gds.Flag = 1;
                        //gds.openBackgroundWorker();
                        gds.ShowDialog();
                        break;
                    }
                }
                ////判断是否已经关闭枪柜门,检测关闭枪柜门之后再开启弹柜门
                //while (PubFlag.gunark_control_isAile)
                //{
                //    //查询枪柜门状态
                //    bool doorStatus = SearchDoorStatus.searchGunStatus();
                //    System.Threading.Thread.Sleep(1000);
                //    //////假设已经关闭枪柜门,测试用,以后要删除下边这行代码
                //    ////doorStatus = false;
                //    //if (!doorStatus)
                //    if (true)
                //    {
                //        GunarkDoorStatus gds = new GunarkDoorStatus(task_info, gun_number, magazine_number);
                //        gds.pictureBox1.Image = Properties.Resources.gun_close;
                //        gds.pictureBox2.Image = Properties.Resources.closeDoor;
                //        gds.Flag = 2;
                //        gds.openBackgroundWorker();
                //        gds.ShowDialog();
                //        break;
                //    }
                //}

            }
            //结束取枪后,判断是否有子弹,若有在进行下面对弹柜的操作
            if (magazine_number.Length > 0)
            {
                //开弹柜门
                //comm.send_message(Port.Get_ComBullet(), Communication.open);
                //语音提示
                PlaySound.paly(Properties.Resources._10);
                //如果弹柜门已打开,再发弹开弹仓指令
                while (PubFlag.gunark_control_isAile)
                {
                    //查询弹柜门状态
                    //bool bulletDoorStatus = SearchDoorStatus.searchBulletStatus();
                    System.Threading.Thread.Sleep(1000);
                    //判断弹柜门是否已经打开(假设已经打开)
                    //if (bulletDoorStatus)
                    if(true)
                    {
                        GunarkDoorStatus gds = new GunarkDoorStatus(task_info, gun_number, magazine_number);
                        gds.pictureBox1.Image = Properties.Resources.bullet_open;
                        gds.pictureBox2.Image = Properties.Resources.openDoor;
                        gds.Flag = 3;
                        //gds.openBackgroundWorker();
                        gds.ShowDialog();
                        break;
                    }
                }
                /////判断弹柜门是否已经关闭
                //while (PubFlag.gunark_control_isAile)
                //{
                //    //查询弹柜门状态
                //    //bool doorStatus = SearchDoorStatus.searchBulletStatus();
                //    System.Threading.Thread.Sleep(1000);

                //    ////假设应经关闭
                //    //if (!doorStatus)
                //    if(true)
                //    {
                //        GunarkDoorStatus gds = new GunarkDoorStatus(task_info, gun_number, magazine_number);
                //        gds.pictureBox1.Image = Properties.Resources.bullet_close;
                //        gds.pictureBox2.Image = Properties.Resources.closeDoor;
                //        gds.Flag = 4;
                //        gds.openBackgroundWorker();
                //        gds.ShowDialog();
                //        break;
                //    }
                //}
            }
            return true;
        }
 public TaskObserver getTaskObserver(Model.task_info _task_info, List<string> _gun_position_info_id, Subject sub)
 {
     taskObserver = new TaskObserver(_task_info,_gun_position_info_id, sub);
     return taskObserver;
 }
 public TaskObserver(Model.task_info _task_info, List<string> _gun_position_info_id, Subject sub)
     : base(_task_info,_gun_position_info_id, sub)
 {
 }
 public Observer(Model.task_info _task_info, List<string> _gun_position_info_id , Subject sub)
 {
     this.task_info = _task_info;
     this.gun_position_info_id = _gun_position_info_id;
     this.sub = sub;
 }