Exemplo n.º 1
0
        public static void call()
        {
            //调用WebServie接口工具
            WebService.gunServices        webService            = SingleWebService.getWebService();
            Bll.task_info_detail          task_info_detail_bll  = new Gunark.BLL.task_info_detail();
            Bll.magazine_info             magazine_info_bll     = new Gunark.BLL.magazine_info();
            List <Model.task_info_detail> task_info_detail_list = new List <Gunark.Model.task_info_detail>();

            task_info_detail_list = task_info_detail_bll.GetModelList("FLAG_TYPE = 0");
            foreach (Model.task_info_detail item in task_info_detail_list)
            {
                if ("get".Equals(item.BULLET_ID))
                {
                    if (item.GUN_INFO_ID != null)
                    {
                        //修改枪支、枪位信息
                        webService.setgunInUse(item.GUN_INFO_ID);
                        webService.setGunNotOnPosition(item.UNIT_ID, item.GUNARK_ID, item.GUN_POSITION_INFO_ID);
                    }
                    else
                    {
                        //修改子弹信息
                        webService.setMagazineStock(item.MAGAZINE_INFO_ID, (int)magazine_info_bll.GetModel(item.MAGAZINE_INFO_ID).STOCK_QTY);
                    }
                }
                else if ("return".Equals(item.BULLET_ID))
                {
                    if (item.GUN_INFO_ID != null)
                    {
                        //修改枪支、枪位信息
                        webService.setGunInStore(item.GUN_INFO_ID);
                        webService.setGunOnPosition(item.UNIT_ID, item.GUNARK_ID, item.GUN_POSITION_INFO_ID);
                    }
                    else
                    {
                        //修改子弹信息
                        webService.setMagazineStock(item.MAGAZINE_INFO_ID, (int)magazine_info_bll.GetModel(item.MAGAZINE_INFO_ID).STOCK_QTY);
                    }
                }
                item.FLAG_TYPE = 1;
                task_info_detail_bll.Update(item);
            }
        }
 public static void call()
 {
     //调用WebServie接口工具
     WebService.gunServices webService = SingleWebService.getWebService();
     Bll.task_info_detail task_info_detail_bll = new Gunark.BLL.task_info_detail();
     Bll.magazine_info magazine_info_bll = new Gunark.BLL.magazine_info();
     List<Model.task_info_detail> task_info_detail_list = new List<Gunark.Model.task_info_detail>();
     task_info_detail_list = task_info_detail_bll.GetModelList("FLAG_TYPE = 0");
     foreach (Model.task_info_detail item in task_info_detail_list)
     {
         if ("get".Equals(item.BULLET_ID))
         {
             if (item.GUN_INFO_ID != null)
             {
                 //修改枪支、枪位信息
                 webService.setgunInUse(item.GUN_INFO_ID);
                 webService.setGunNotOnPosition(item.UNIT_ID, item.GUNARK_ID, item.GUN_POSITION_INFO_ID);
             }
             else
                 //修改子弹信息
                 webService.setMagazineStock(item.MAGAZINE_INFO_ID, (int)magazine_info_bll.GetModel(item.MAGAZINE_INFO_ID).STOCK_QTY);
         }
         else if ("return".Equals(item.BULLET_ID))
         {
             if (item.GUN_INFO_ID != null)
             {
                 //修改枪支、枪位信息
                 webService.setGunInStore(item.GUN_INFO_ID);
                 webService.setGunOnPosition(item.UNIT_ID, item.GUNARK_ID, item.GUN_POSITION_INFO_ID);
             }
             else
                 //修改子弹信息
                 webService.setMagazineStock(item.MAGAZINE_INFO_ID, (int)magazine_info_bll.GetModel(item.MAGAZINE_INFO_ID).STOCK_QTY);
         }
         item.FLAG_TYPE = 1;
         task_info_detail_bll.Update(item);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 发指令后台进程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            //调用控制柜子公共类,返回值标识是否正常打开枪柜门
            bool control_status = Utils.ControlGunark.control(task_info, ListToByte.List2Byte(gun_number), ListToByte.List2Byte(magazine_number));

            //判断是否正常打开柜门,如果未正常打开,重新执行该任务
            if (!control_status)
            {
                MessageBox.Show(this, "超时未开门,请重新做任务", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                this.button1.Enabled = true;
                this.button2.Enabled = true;
            }
            else
            {
                this.Close();
                //上传任务信息为“执行中”(调用webService接口)
                //webService.setDoingTask(task_info.TASK_ID, DateTime.Now,true,GetUserByFingerId.getUser(PubFlag.verifyUserId_1).USER_POLICENUMB, GetUserByFingerId.getUser(PubFlag.verifyUserId_2).USER_POLICENUMB);
                //检测对比取枪弹状态,返回值为true表示无异常枪位
                _isUsual = Utils.CheckGun.Check(gun_number);
                //如果没有异常枪位
                if (_isUsual)
                {
                    //更改数据库任务,枪支,枪位,子弹信息,并插入操作日志
                    switch (task_info.TASK_BIGTYPE)
                    {
                    //枪弹入柜
                    case 2:
                        Utils.AddLog.add(1, "枪弹入柜", list_gun.Count.ToString(), list_bullet.Count.ToString());
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "6", "1", "3", "还弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                        //调用WebService接口,更改枪位状态
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            webService.setGunInStore(gun_info_id[i]);
                            webService.setGunOnPosition(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                        }
                        //调用webservice接口,更改子弹库存量
                        for (int i = 0; i < magazine_id.Count; i++)
                        {
                            webService.setMagazineStock(magazine_id[i], (int)magazine_info_bll.GetModel(magazine_id[i]).STOCK_QTY);
                        }
                        //调用WebService接口,更改任务状态为已完成
                        webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        break;

                    //申请枪弹
                    case 3:
                        if (task_info.TASK_STATUS == "3")
                        {
                            Utils.AddLog.add(1, "领取枪弹", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "5", "3", "2", "取弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //调用WebService接口,更改枪位状态
                            for (int i = 0; i < gun_number.Count; i++)
                            {
                                webService.setgunInUse(gun_info_id[i]);
                                webService.setGunNotOnPosition(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                            }
                            //调用webservice接口,更改子弹库存量
                            for (int i = 0; i < magazine_id.Count; i++)
                            {
                                webService.setMagazineStock(magazine_id[i], (int)magazine_info_bll.GetModel(magazine_id[i]).STOCK_QTY);
                            }
                            //调用WebService接口,更改任务状态为执行中
                            webService.setDoingTask(task_info.task_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        }
                        else if (task_info.TASK_STATUS == "5")
                        {
                            Utils.AddLog.add(1, "归还枪弹", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "6", "1", "3", "还弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //调用WebService接口,更改枪位状态
                            for (int i = 0; i < gun_number.Count; i++)
                            {
                                webService.setGunInStore(gun_info_id[i]);
                                webService.setGunOnPosition(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                            }
                            //调用webservice接口,更改子弹库存量
                            for (int i = 0; i < magazine_id.Count; i++)
                            {
                                webService.setMagazineStock(magazine_id[i], (int)magazine_info_bll.GetModel(magazine_id[i]).STOCK_QTY);
                            }
                            //调用WebService接口,更改任务状态为已完成
                            webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        }
                        else if (task_info.TASK_STATUS == "7")
                        {
                            Utils.AddLog.add(1, "超期归还", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "6", "1", "3", "还弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //调用WebService接口,更改枪位状态
                            for (int i = 0; i < gun_number.Count; i++)
                            {
                                webService.setGunInStore(gun_info_id[i]);
                                webService.setGunOnPosition(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                            }
                            //调用webservice接口,更改子弹库存量
                            for (int i = 0; i < magazine_id.Count; i++)
                            {
                                webService.setMagazineStock(magazine_id[i], (int)magazine_info_bll.GetModel(magazine_id[i]).STOCK_QTY);
                            }
                            //调用WebService接口,更改任务状态为已完成
                            webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        }
                        break;

                    //枪支封存
                    case 4:
                        Utils.AddLog.add(1, "枪支封存", list_gun.Count.ToString(), list_bullet.Count.ToString());
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "6", "8", "5", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                        //调用WebService接口,更改枪位状态
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            webService.setGunBeSeal(gun_info_id[i]);
                            webService.setGunPositionSeal(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                        }
                        //调用WebService接口,更改任务状态为已完成
                        webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        break;

                    //枪支报废
                    case 5:
                        Utils.AddLog.add(1, "枪支报废", list_gun.Count.ToString(), list_bullet.Count.ToString());
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "6", "5", "0", "取弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                        //调用WebService接口,更改枪位状态
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            webService.setGunBeScrap(gun_info_id[i]);
                            //webService.setGunPosNotOnGunark(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                            webService.setGunPosNotOnGunark(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                        }
                        //调用WebService接口,更改任务状态为已完成
                        webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        break;

                    //枪支保养
                    case 6:
                        if (task_info.TASK_STATUS == "3")
                        {
                            Utils.AddLog.add(1, "枪支保养", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "5", "3", "2", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //调用WebService接口,更改枪位状态
                            for (int i = 0; i < gun_number.Count; i++)
                            {
                                webService.setgunInUse(gun_info_id[i]);
                                webService.setGunNotOnPosition(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                            }
                            //调用WebService接口,更改任务状态为执行中
                            webService.setDoingTask(task_info.task_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        }
                        else if (task_info.TASK_STATUS == "5")
                        {
                            Utils.AddLog.add(1, "归还枪弹(保养)", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "6", "1", "3", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //调用WebService接口,更改枪位状态
                            for (int i = 0; i < gun_number.Count; i++)
                            {
                                webService.setGunInStore(gun_info_id[i]);
                                webService.setGunOnPosition(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                                webService.setMaintainconfig(task_info.gunarkId);
                            }
                            //调用WebService接口,更改任务状态为已完成
                            webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        }
                        break;

                    //枪支调拨
                    case 7:
                        Utils.AddLog.add(1, "枪支调拨", list_gun.Count.ToString(), list_bullet.Count.ToString());
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "6", "9", "0", "取弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                        //调用WebService接口,更改枪位状态
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            webService.setGunBeAllot(gun_info_id[i]);
                            webService.setGunPosNotOnGunark(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                        }
                        //调用webservice接口,更改子弹库存量
                        for (int i = 0; i < magazine_id.Count; i++)
                        {
                            Console.WriteLine((int)magazine_info_bll.GetModel(magazine_id[i]).STOCK_QTY);
                            webService.setMagazineStock(magazine_id[i], (int)magazine_info_bll.GetModel(magazine_id[i]).STOCK_QTY);
                        }
                        //调用WebService接口,更改任务状态为已完成
                        webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        break;

                    //紧急取枪
                    case 8:
                        if (task_info.TASK_STATUS == "5")
                        {
                            Utils.AddLog.add(1, "归还枪弹(紧急)", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "6", "1", "3", "还弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //更新调用接口参数
                            foreach (Model.task_info_detail item in list)
                            {
                                item.FLAG_TYPE = 2;
                                bll.Update(item);
                            }
                        }
                        else if (task_info.TASK_STATUS == "7")
                        {
                            Utils.AddLog.add(1, "超期归还(紧急取枪)", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "6", "1", "3", "还弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //更新调用接口参数
                            foreach (Model.task_info_detail item in list)
                            {
                                item.FLAG_TYPE = 2;
                                bll.Update(item);
                            }
                        }
                        break;

                    //枪弹检查(取出枪支)
                    case 9:
                        if (task_info.TASK_STATUS == "3")
                        {
                            Utils.AddLog.add(1, "枪弹检查", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "5", "3", "2", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //枪支点验不开枪锁,所以不更新数据库状态
                            //调用WebService接口,更改枪位状态
                            for (int i = 0; i < gun_number.Count; i++)
                            {
                                webService.setgunInUse(gun_info_id[i]);
                                webService.setGunNotOnPosition(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                            }
                            //调用WebService接口,更改任务状态为已完成
                            webService.setDoingTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        }
                        else if (task_info.TASK_STATUS == "5")
                        {
                            Utils.AddLog.add(1, "归还枪弹(检查)", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "6", "1", "3", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //调用WebService接口,更改枪位状态
                            for (int i = 0; i < gun_number.Count; i++)
                            {
                                webService.setGunInStore(gun_info_id[i]);
                                webService.setGunOnPosition(task_info.UNIT_ID, task_info.GUNARK_ID, gun_pos_id[i]);
                            }
                            for (int i = 0; i < magazine_id.Count; i++)
                            {
                                webService.setMagazineInfoCheck(magazine_id[i]);
                            }
                            //调用WebService接口,更改任务状态为已完成
                            webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        }
                        break;

                    //枪支解封
                    case 10:
                        Utils.AddLog.add(1, "枪支解封", list_gun.Count.ToString(), list_bullet.Count.ToString());
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "6", "1", "3", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                        //调用WebService接口,更改枪位状态
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            webService.setGunInStore(gun_info_id[i]);
                            webService.setGunOnPosition(task_info.unitId, task_info.gunarkId, gun_pos_id[i]);
                        }
                        //调用WebService接口,更改任务状态为已完成
                        webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        break;

                    //枪支寄存11
                    case 11:
                        Utils.AddLog.add(1, "枪支寄存", list_gun.Count.ToString(), list_bullet.Count.ToString());
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "6", "10", "1", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                        //调用WebService接口,更改枪位状态
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            webService.setgunLuggage(gun_info_id[i]);
                            webService.setgunpositionLuggage(gun_pos_id[i]);
                            //webService.setGunOnPosition(task_info.unitId, task_info.gunarkId, gun_info_id[i]);
                        }
                        //调用WebService接口,更改任务状态为已完成
                        webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        break;

                    //枪支解存12
                    case 12:
                        Utils.AddLog.add(1, "枪支解存", list_gun.Count.ToString(), list_bullet.Count.ToString());
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "6", "11", "2", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                        //调用WebService接口,更改枪位状态
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            webService.setgunExport(gun_info_id[i]);
                            webService.setGunPosNotOnGunark(task_info.unitId, task_info.gunarkId, gun_pos_id[i]);
                        }
                        //调用WebService接口,更改任务状态为已完成
                        webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        break;

                    //快速取枪
                    case 13:
                        if (task_info.TASK_STATUS == "5")
                        {
                            Utils.AddLog.add(1, "归还枪弹(快速取枪)", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "6", "1", "3", "还弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //更新调用接口参数
                            foreach (Model.task_info_detail item in list)
                            {
                                item.FLAG_TYPE = 2;
                                bll.Update(item);
                            }
                        }
                        else if (task_info.TASK_STATUS == "7")
                        {
                            Utils.AddLog.add(1, "超期归还(快速取枪)", list_gun.Count.ToString(), list_bullet.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "6", "1", "3", "还弹", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                            //更新调用接口参数
                            foreach (Model.task_info_detail item in list)
                            {
                                item.FLAG_TYPE = 2;
                                bll.Update(item);
                            }
                        }
                        break;

                    //枪支点验
                    case 14:
                        Utils.AddLog.add(1, "枪支点验", list_gun.Count.ToString(), list_bullet.Count.ToString());
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "6", "1", "3", "", gun_info_id, gun_pos_id, magazine_id, list_bullet);
                        //调用WebService接口,更改枪位状态
                        webService.setgunarkcheckingSuccess(task_info.gunarkId, task_info.unitId);
                        //调用WebService接口,更改任务状态为已完成
                        webService.setFinishTask(task_info.TASK_ID, DateTime.Now, true, PubFlag.policeNum, PubFlag.dutyLeaderNum);
                        break;

                    default:
                        break;
                    }
                }
            }
        }