示例#1
0
 /// <summary>
 /// 紧急取枪
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void emergency_Click(object sender, EventArgs e)
 {
     ////右下角升起提示框,提示有异常任务
     //PopForm.Instance().Show();
     gunark_status.Stop();
     Verify v = new Verify();
     v.Flag = 2;
     v.ShowDialog();
     if (v.Result)
     {
         QueryApply qa = new QueryApply("emergency");
         qa.ShowDialog();
     }
     gunark_status.Start();
 }
示例#2
0
 /// <summary>
 /// 快速申领
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void quick_get_gun_Click(object sender, EventArgs e)
 {
     gunark_status.Stop();
     Verify v = new Verify();
     v.Flag = 2;
     v.ShowDialog();
     if (v.Result)
     {
         QueryApply qa = new QueryApply("quick");
         qa.ShowDialog();
     }
     gunark_status.Start();
 }
示例#3
0
 /// <summary>
 /// 枪弹柜管理
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void gunark_management_Click(object sender, EventArgs e)
 {
     gunark_status.Stop();
     Verify v = new Verify();
     v.Flag = 4;
     v.ShowDialog();
     if (v.Result)
     {
         GunarkManagement gm = new GunarkManagement();
         gm.ShowDialog();
     }
     gunark_status.Start();
 }
        /// <summary>
        /// 执行任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            int[] applyQty = new int[apply_bullet_qty.Count];
            if (comboBox1.Text.Equals("") && task_type.Equals("quick"))
            {
                MessageBox.Show("请选择任务类型");
                return;
            }
            if (comboBox2.Text.Equals("") && task_type.Equals("quick"))
            {
                MessageBox.Show("请选择任务时间");
                return;
            }
            int count = 0;
            //获取选中的行数
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (listView1.Items[i].ImageIndex == 0)
                {
                    count++;
                    break;
                }
            }
            if (count <= 0)
            {
                MessageBox.Show("请选择枪支!", "提示");
                return;
            }
            //身份验证界面
            Verify v = new Verify();
            v.Flag = 3;
            v.ShowDialog();
            //如果身份验证通过
            if (v.Result)
            {
                if (MessageBox.Show(this, "您确定要执行该任务么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information).ToString() == "Yes")
                {
                    Model.task_info task_info = new Gunark.Model.task_info();
                    //机构ID
                    task_info.UNIT_ID = ConfigurationManager.AppSettings["unit_id"];
                    //枪柜ID
                    task_info.gunarkId = ConfigurationManager.AppSettings["gunark_id"];
                    //任务类型(13代表快速取枪,8代表紧急取枪)
                    if (task_type.Equals("quick"))
                    {
                        task_info.TASK_BIGTYPE = 13;
                        task_info.task_SmallType = "快速取枪";
                    }
                    else
                    {
                        task_info.TASK_BIGTYPE = 8;
                        task_info.task_SmallType = "紧急取枪";
                    }
                    //任务状态
                    task_info.task_Status = "3";
                    this.button1.Enabled = false;
                    this.button2.Enabled = false;
                    //调用控制柜子公共类,返回值标识是否正常打开枪柜门
                    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);
                    }
                    else
                    {
                        //生成任务信息
                        //32位GUID
                        task_info.TASK_ID = System.Guid.NewGuid().ToString();
                        //任务开始时间
                        task_info.task_Plan_BeginTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now);
                        switch (comboBox2.Text)
                        {
                            case "4小时":
                                task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now.AddHours(+4d));
                                break;
                            case "8小时":
                                task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now.AddHours(+8d));
                                break;
                            case "12小时":
                                task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now.AddHours(+12d));
                                break;
                            default:
                                //紧急任务(默认执勤时间为24小时)
                                task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now.AddHours(+24d));
                                break;
                        }

                        //任务申请人
                        task_info.TASK_APPLY_USERID = PubFlag.policeNum;
                        //任务申请时间
                        task_info.TASK_APPLY_TIME = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now);
                        //任务审批人
                        task_info.TASK_APPROVAL_USERID = PubFlag.bossLeaderNum;
                        //将同步状态设为未同步(0:未同步,1:已同步)
                        task_info.taskFlagType = "0";
                        //如果是快速取枪,调用webservice接口,将任务信息上传

                        task_info_bll.Add(task_info);
                        //生成任务详情信息(枪)
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            Model.task_info_detail task_info_details = new Gunark.Model.task_info_detail();
                            try
                            {
                                //任务详情ID
                                task_info_details.task_Detail_ID = System.Guid.NewGuid().ToString();
                                //任务ID
                                task_info_details.TASK_ID = task_info.task_ID;
                                //机构ID
                                task_info_details.UNIT_ID = task_info.unitId;
                                //枪柜ID
                                task_info_details.GUNARK_ID = task_info.gunarkId;
                                //枪支ID
                                task_info_details.GUN_INFO_ID = gun_info_id[i];
                                //枪位ID
                                task_info_details._gun_position_info_id = gun_position_info_bll.GetModelByGunInfo(task_info_details.GUN_INFO_ID).GUN_POSITION_INFO_ID;
                                //用枪人
                                task_info_details.GUN_DUTY_USER = PubFlag.policeNum;
                                task_info_details.FLAG_TYPE = 1;

                                task_info_details_bll.Add(task_info_details);
                            }
                            catch  {  }
                        }
                        //生成任务详情信息(弹)
                        for (int i = 0; i < magazine_number.Count; i++)
                        {
                            try
                            {
                                Model.task_info_detail task_info_details = new Gunark.Model.task_info_detail();
                                //任务详情ID
                                task_info_details.task_Detail_ID = System.Guid.NewGuid().ToString();
                                //任务ID
                                task_info_details.TASK_ID = task_info.task_ID;
                                //机构ID
                                task_info_details.UNIT_ID = task_info.unitId;
                                //枪柜ID
                                task_info_details.GUNARK_ID = task_info.gunarkId;
                                //弹仓ID
                                task_info_details.MAGAZINE_INFO_ID = magazine_info_id[i];
                                //子弹类型
                                task_info_details.BULLET_TYPE = magazine_info_bll.GetModel(magazine_info_id[i]).BULLET_MODEL;
                                //取弹数量
                                int qty = 0;
                                apply_bullet_qty.TryGetValue(task_info_details.MAGAZINE_INFO_ID,out qty);
                                task_info_details.apply_Bullet_Qty = qty;
                                applyQty[i] = qty;

                                if (task_info.task_BigType == 8)
                                {
                                    task_info_details.FLAG_TYPE = 0;
                                    //用这个字段标识紧急取枪需要调用接口情况,(get:调“未置枪接口”;return:调“置枪接口”)
                                    task_info_details.BULLET_ID = "get";
                                }

                                task_info_details_bll.Add(task_info_details);
                            }
                            catch { }
                        }

                        if (task_type.Equals("quick"))
                        {
                            //插入日志
                            Utils.AddLog.add(1, "快速取枪弹", gun_number.Count.ToString(), magazine_number.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "5", "3", "2", "取弹", gun_info_id, gun_position_info_id, magazine_info_id, task_info_details_bll.GetModelList("TASK_ID = '" + task_info.TASK_ID + "'"));
                            //调用webservice接口,上传快速取枪任务
                            //....
                            //调用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_position_info_id[i]);
                            }
                            //调用webservice接口,更改子弹库存量
                            for (int i = 0; i < magazine_info_id.Count; i++)
                            {
                                webService.setMagazineStock(magazine_info_id[i], (int)magazine_info_bll.GetModel(magazine_info_id[i]).STOCK_QTY);
                            }
                        }
                        else
                        {
                            //插入日志
                            Utils.AddLog.add(1, "紧急取枪弹", gun_number.Count.ToString(), magazine_number.Count.ToString());
                            //更新本地数据库任务状态,建立执行中任务
                            UpdateTaskInfo.update(task_info, "5", "3", "2", "取弹", gun_info_id, gun_position_info_id, magazine_info_id, task_info_details_bll.GetModelList("TASK_ID = '" + task_info.TASK_ID + "'"));
                            //调用webservice接口,上传紧急取枪任务
                            //....
                        }
                        this.Close();
                    }
                }
            }
        }
 /// <summary>
 /// 执行任务
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (task_info.task_BigType == 3 && task_info.task_Status == "3")
     {
         Verify v = new Verify();
         v.Flag = 1;
         v.ShowDialog();
         //如果身份验证通过
         if (v.Result)
         {
             //向串口发送指令
             backgroundWorker2.RunWorkerAsync();
             this.button1.Enabled = false;
         }
     }
     else
     {
         Verify v = new Verify();
         v.Flag = 5;
         v.ShowDialog();
         //如果身份验证通过
         if (v.Result)
         {
             //向串口发送指令
             backgroundWorker2.RunWorkerAsync();
             this.button1.Enabled = false;
             this.button2.Enabled = false;
         }
     }
 }
示例#6
0
        /// <summary>
        /// 任务执行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text.Equals("") && task_type.Equals("quick"))
            {
                MessageBox.Show("请选择任务类型");
                return;
            }
            if (comboBox2.Text.Equals("") && task_type.Equals("quick"))
            {
                MessageBox.Show("请选择任务时间");
                return;
            }
            int count = 0;
            //获取选中的行数
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                if ((bool)dataGridView1.Rows[i].Cells[0].EditedFormattedValue)
                {
                    count++;
                }
            }
            if (count <= 0)
            {
                MessageBox.Show("请选择枪支!", "提示");
                return;
            }
            //身份验证界面
            Verify v = new Verify();
            v.Flag = 3;
            v.ShowDialog();
            //如果身份验证通过
            if (v.Result)
            {
                if (MessageBox.Show(this, "您确定要执行该任务么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information).ToString() == "Yes")
                {
                    for (int i = 0; i < dataGridView1.RowCount; i++)
                    {
                        if ((bool)dataGridView1.Rows[i].Cells[0].EditedFormattedValue)
                        {
                            //枪支信息
                            gun_number.Add(dataGridView1.Rows[i].Cells[1].Value.ToString());
                            gun_info_id.Add(dataGridView1.Rows[i].Cells[3].Value.ToString());
                            gun_position_info_id.Add(dataGridView1.Rows[i].Cells[4].Value.ToString());
                            ////子弹信息
                            //magazine_number.Add(dataGridView2.Rows[i].Cells[0].Value.ToString());
                            //magazine_info_id.Add(dataGridView2.Rows[i].Cells[4].Value.ToString());
                            //try
                            //{
                            //    apply_bullet_qty.Add(Convert.ToInt32(dataGridView2.Rows[i].Cells[3].Value.ToString()));
                            //}
                            //catch (NullReferenceException n)
                            //{
                            //    MessageBox.Show("第【" + (i + 1) + "】行没有填写取弹数量!如果只取枪不取弹,请填写【0】!");
                            //    return;
                            //}
                            //if (Convert.ToInt32(dataGridView2.Rows[i].Cells[3].Value.ToString()) == 0)
                            //{
                            //    magazine_number.RemoveAt(i);
                            //    magazine_info_id.RemoveAt(i);
                            //}
                        }
                    }
                    Model.task_info task_info = new Gunark.Model.task_info();
                    //机构ID
                    task_info.UNIT_ID = ConfigurationManager.AppSettings["unit_id"];
                    //枪柜ID
                    task_info.gunarkId = ConfigurationManager.AppSettings["gunark_id"];
                    //任务类型(13代表快速取枪,8代表紧急取枪)
                    if (task_type.Equals("quick"))
                    {
                        task_info.TASK_BIGTYPE = 13;
                        task_info.task_SmallType = "快速取枪";
                        //调用快速取枪接口
                        //...将任务id替换为调用接口返回的id值
                    }
                    else
                    {
                        task_info.TASK_BIGTYPE = 8;
                        task_info.task_SmallType = "紧急取枪";
                    }
                    //任务状态
                    task_info.task_Status = "3";
                    this.button1.Enabled = false;
                    this.button2.Enabled = false;
                    //调用控制柜子公共类,返回值标识是否正常打开枪柜门
                    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);
                    }
                    else
                    {
                        //生成任务信息
                        //32位GUID
                        task_info.TASK_ID = System.Guid.NewGuid().ToString();
                        //任务开始时间
                        task_info.task_Plan_BeginTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now);
                        switch (comboBox2.Text)
                        {
                            case "4小时":
                                task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now.AddHours(+4d));
                                break;
                            case "8小时":
                                task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now.AddHours(+8d));
                                break;
                            case "12小时":
                                task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now.AddHours(+12d));
                                break;
                            default:
                                //紧急任务(默认执勤时间为24小时)
                                task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", DateTime.Now.AddHours(+24d));
                                break;
                        }

                        //任务申请人
                        task_info.TASK_APPLY_USERID = PubFlag.policeNum;
                        //任务审批人
                        task_info.TASK_APPROVAL_USERID = PubFlag.bossLeaderNum;
                        task_info_bll.Add(task_info);
                        //生成任务详情信息
                        for (int i = 0; i < gun_number.Count; i++)
                        {
                            Model.task_info_detail task_info_details = new Gunark.Model.task_info_detail();
                            try
                            {
                                //任务详情ID
                                task_info_details.task_Detail_ID = System.Guid.NewGuid().ToString();
                                //任务ID
                                task_info_details.TASK_ID = task_info.task_ID;
                                //机构ID
                                task_info_details.UNIT_ID = task_info.unitId;
                                //枪柜ID
                                task_info_details.GUNARK_ID = task_info.gunarkId;
                                //枪支ID
                                task_info_details.GUN_INFO_ID = gun_info_id[i];
                                //枪位ID
                                task_info_details._gun_position_info_id = gun_position_info_bll.GetModelByGunInfo(task_info_details.GUN_INFO_ID).GUN_POSITION_INFO_ID;
                                //用枪人
                                task_info_details.GUN_DUTY_USER = PubFlag.policeNum;
                                //如果有子弹
                                if (magazine_number.Count > 0)
                                {
                                    //弹仓ID
                                    task_info_details.MAGAZINE_INFO_ID = magazine_info_id[i];
                                    //子弹类型
                                    task_info_details.BULLET_TYPE = magazine_info_bll.GetModel(magazine_info_id[i]).BULLET_MODEL;
                                    //取弹数量
                                    task_info_details.apply_Bullet_Qty = apply_bullet_qty[i];
                                }
                                task_info_details.FLAG_TYPE = 1;
                                task_info_details_bll.Add(task_info_details);
                            }
                            catch (ArgumentOutOfRangeException a) { task_info_details_bll.Add(task_info_details); }
                        }
                        if (task_type.Equals("quick"))
                        {
                            //插入日志
                            Utils.AddLog.add(1, "快速取枪弹", gun_number.Count.ToString(), magazine_number.Count.ToString());
                        }
                        else
                        {
                            //插入日志
                            Utils.AddLog.add(1, "紧急取枪弹", gun_number.Count.ToString(), magazine_number.Count.ToString());
                            //webService.setUrgentGunBulletTaskNew(task_info.task_ID,);
                        }
                        //更新本地数据库任务状态,建立执行中任务
                        UpdateTaskInfo.update(task_info, "5", "3", "2", "取弹", gun_info_id, gun_position_info_id, magazine_info_id, task_info_details_bll.GetModelList("TASK_ID = '"+task_info.TASK_ID+"'"));
                        this.Close();
                    }
                }
            }
        }