Exemplo n.º 1
0
        private static void addTask(string prams)
        {
            Bll.task_info task_info_bll = new Gunark.BLL.task_info();
            Bll.task_info_detail task_detail_info_bll = new Gunark.BLL.task_info_detail();
            Bll.position_info position_info_bll = new Gunark.BLL.position_info();
            Bll.gun_info gun_info_bll = new Gunark.BLL.gun_info();
            Bll.magazine_info magazine_info_bll = new Gunark.BLL.magazine_info();
            int j = 10;

            string[] attributes = prams.Split('|');
            //任务信息
            Model.task_info task_info = new Gunark.Model.task_info();
            task_info.task_ID = attributes[0];
            task_info.GUNARK_ID = attributes[1];
            task_info.UNIT_ID = attributes[2];
            task_info.TASK_STATUS = attributes[3];
            task_info.TASK_BIGTYPE = int.Parse(attributes[4]);
            task_info.TASK_SMALLTYPE = attributes[5];
            task_info.TASK_PROPERTY = attributes[6];
            task_info.TASK_PLAN_BEGINTIME = attributes[7];
            task_info.TASK_PLAN_FINISHTIME = attributes[8];
            task_info.TASK_APPLY_USERID = attributes[9];
            task_info.TASK_APPLY_TIME = attributes[10];
            task_info_bll.Add(task_info);
            //任务详情信息
            int task_detail_info_count = int.Parse(attributes[11].Substring(1, attributes[11].LastIndexOf("&") - 1));
            for (int i = 0; i < task_detail_info_count; i++)
            {
                Model.task_info_detail task_detail_info = new Gunark.Model.task_info_detail();
                if(i == 0)
                    task_detail_info.TASK_DETAIL_ID = attributes[++j].Substring(attributes[j].LastIndexOf("&") + 1);
                else
                    task_detail_info.TASK_DETAIL_ID = attributes[++j];
                task_detail_info.TASK_ID = attributes[++j];
                task_detail_info.GUNARK_ID = attributes[++j];
                task_detail_info.UNIT_ID = attributes[++j];
                task_detail_info.GUN_INFO_ID = attributes[++j];
                task_detail_info.GUN_POSITION_INFO_ID = attributes[++j];
                task_detail_info.GUN_DUTY_USER = attributes[++j];
                task_detail_info.BULLET_TYPE = attributes[++j];
                task_detail_info.MAGAZINE_INFO_ID = attributes[++j];
                task_detail_info.APPLY_BULLET_QTY = int.Parse(attributes[++j]);
                task_detail_info.DEPLETION_BULLET_QTY = int.Parse(attributes[++j]);
                if (i != task_detail_info_count - 1)
                    ++j;
                task_detail_info_bll.Add(task_detail_info);
            }
            //枪位信息
            int gun_position_info_count = 0;
            try
            {
                 gun_position_info_count = int.Parse(attributes[j + 1].Substring(1, attributes[j + 1].LastIndexOf("&") - 1));
            }
            catch { }
            if (gun_position_info_count != 0)
            {
                for (int i = 0; i < gun_position_info_count; i++)
                {
                    Model.position_info gun_position_info = new Gunark.Model.position_info();
                    if (i == 0)
                        gun_position_info.GUN_POSITION_INFO_ID = attributes[++j].Substring(3);
                    else
                        gun_position_info.GUN_POSITION_INFO_ID = attributes[++j];
                    gun_position_info.GUNARK_ID = attributes[++j];
                    gun_position_info.UNIT_ID = attributes[++j];
                    gun_position_info.GUN_POSITION_NUMBER = attributes[++j];
                    gun_position_info.GUN_POSITION_STATUS = attributes[++j];
                    gun_position_info.GUN_INFO_ID = attributes[++j];
                    gun_position_info.GUN_BULLET_NUMBER = attributes[++j];
                    gun_position_info.GUN_TYPE = attributes[++j];
                    if (i != gun_position_info_count - 1)
                        ++j;
                    position_info_bll.Add(gun_position_info);
                }
                //枪支信息
                int gun_info_count = int.Parse(attributes[j + 1].Substring(1, attributes[j + 1].LastIndexOf("&") - 1));
                for (int i = 0; i < gun_info_count; i++)
                {
                    Model.gun_info gun_info = new Gunark.Model.gun_info();
                    if (i == 0)
                        gun_info.GUN_INFO_ID = attributes[++j].Substring(3);
                    else
                        gun_info.GUN_INFO_ID = attributes[++j];
                    gun_info.GUNARK_ID = attributes[++j];
                    gun_info.UNIT_ID = attributes[++j];
                    gun_info.GUN_NUMBER = attributes[++j];
                    gun_info.GUN_TYPE = attributes[++j];
                    gun_info.GUN_STATUS = attributes[++j];
                    gun_info.GUN_BULLET_LOCATION = attributes[++j];
                    if (i != gun_info_count - 1)
                        ++j;
                    gun_info_bll.Add(gun_info);
                }
                //弹仓信息
                int magazine_info_count = int.Parse(attributes[j + 1].Substring(1, attributes[j + 1].LastIndexOf("&") - 1));
                for (int i = 0; i < magazine_info_count; i++)
                {
                    Model.magazine_info magazine_info = new Gunark.Model.magazine_info();
                    if (i == 0)
                        magazine_info.MAGAZINE_INFO_ID = attributes[++j].Substring(3);
                    else
                        magazine_info.MAGAZINE_INFO_ID = attributes[++j];
                    magazine_info.GUNARK_ID = attributes[++j];
                    magazine_info.UNIT_ID = attributes[++j];
                    magazine_info.MAGAZINE_NUMBER = attributes[++j];
                    magazine_info.STOCK_QTY = int.Parse(attributes[++j]);
                    magazine_info.CAPACITY_QTY = int.Parse(attributes[++j]);
                    magazine_info.MAGAZINE_NAME = attributes[++j];
                    magazine_info.BULLET_MODEL = attributes[++j];
                    magazine_info.BULLET_GROUP_ID = attributes[++j];
                    ////if (i != magazine_info_count - 1)
                    ////    ++j;
                    magazine_info_bll.Add(magazine_info);
                }
            }
            else
            {
                int magazine_info_count = 0;
                //弹仓信息
                try
                {
                    magazine_info_count = int.Parse(attributes[j + 1].Substring(7, attributes[j + 1].LastIndexOf("&") - 1));
                }
                catch { }
                for (int i = 0; i < magazine_info_count; i++)
                {
                    Model.magazine_info magazine_info = new Gunark.Model.magazine_info();
                    if (i == 0)
                        magazine_info.MAGAZINE_INFO_ID = attributes[++j].Substring(9);
                    else
                        magazine_info.MAGAZINE_INFO_ID = attributes[++j];
                    magazine_info.GUNARK_ID = attributes[++j];
                    magazine_info.UNIT_ID = attributes[++j];
                    magazine_info.MAGAZINE_NUMBER = attributes[++j];
                    magazine_info.STOCK_QTY = int.Parse(attributes[++j]);
                    magazine_info.CAPACITY_QTY = int.Parse(attributes[++j]);
                    magazine_info.MAGAZINE_NAME = attributes[++j];
                    magazine_info.BULLET_MODEL = attributes[++j];
                    magazine_info.BULLET_GROUP_ID = attributes[++j];
                    ////if (i != magazine_info_count - 1)
                    ////    ++j;
                    magazine_info_bll.Add(magazine_info);
                }
            }
        }
Exemplo n.º 2
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();
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static void addTask(string prams)
        {
            Bll.task_info        task_info_bll        = new Gunark.BLL.task_info();
            Bll.task_info_detail task_detail_info_bll = new Gunark.BLL.task_info_detail();
            Bll.position_info    position_info_bll    = new Gunark.BLL.position_info();
            Bll.gun_info         gun_info_bll         = new Gunark.BLL.gun_info();
            Bll.magazine_info    magazine_info_bll    = new Gunark.BLL.magazine_info();
            int j = 10;

            string[] attributes = prams.Split('|');
            //任务信息
            Model.task_info task_info = new Gunark.Model.task_info();
            task_info.task_ID              = attributes[0];
            task_info.GUNARK_ID            = attributes[1];
            task_info.UNIT_ID              = attributes[2];
            task_info.TASK_STATUS          = attributes[3];
            task_info.TASK_BIGTYPE         = int.Parse(attributes[4]);
            task_info.TASK_SMALLTYPE       = attributes[5];
            task_info.TASK_PROPERTY        = attributes[6];
            task_info.TASK_PLAN_BEGINTIME  = attributes[7];
            task_info.TASK_PLAN_FINISHTIME = attributes[8];
            task_info.TASK_APPLY_USERID    = attributes[9];
            task_info.TASK_APPLY_TIME      = attributes[10];
            task_info_bll.Add(task_info);
            //任务详情信息
            int task_detail_info_count = int.Parse(attributes[11].Substring(1, attributes[11].LastIndexOf("&") - 1));

            for (int i = 0; i < task_detail_info_count; i++)
            {
                Model.task_info_detail task_detail_info = new Gunark.Model.task_info_detail();
                if (i == 0)
                {
                    task_detail_info.TASK_DETAIL_ID = attributes[++j].Substring(attributes[j].LastIndexOf("&") + 1);
                }
                else
                {
                    task_detail_info.TASK_DETAIL_ID = attributes[++j];
                }
                task_detail_info.TASK_ID              = attributes[++j];
                task_detail_info.GUNARK_ID            = attributes[++j];
                task_detail_info.UNIT_ID              = attributes[++j];
                task_detail_info.GUN_INFO_ID          = attributes[++j];
                task_detail_info.GUN_POSITION_INFO_ID = attributes[++j];
                task_detail_info.GUN_DUTY_USER        = attributes[++j];
                task_detail_info.BULLET_TYPE          = attributes[++j];
                task_detail_info.MAGAZINE_INFO_ID     = attributes[++j];
                task_detail_info.APPLY_BULLET_QTY     = int.Parse(attributes[++j]);
                task_detail_info.DEPLETION_BULLET_QTY = int.Parse(attributes[++j]);
                if (i != task_detail_info_count - 1)
                {
                    ++j;
                }
                task_detail_info_bll.Add(task_detail_info);
            }
            //枪位信息
            int gun_position_info_count = 0;

            try
            {
                gun_position_info_count = int.Parse(attributes[j + 1].Substring(1, attributes[j + 1].LastIndexOf("&") - 1));
            }
            catch { }
            if (gun_position_info_count != 0)
            {
                for (int i = 0; i < gun_position_info_count; i++)
                {
                    Model.position_info gun_position_info = new Gunark.Model.position_info();
                    if (i == 0)
                    {
                        gun_position_info.GUN_POSITION_INFO_ID = attributes[++j].Substring(3);
                    }
                    else
                    {
                        gun_position_info.GUN_POSITION_INFO_ID = attributes[++j];
                    }
                    gun_position_info.GUNARK_ID           = attributes[++j];
                    gun_position_info.UNIT_ID             = attributes[++j];
                    gun_position_info.GUN_POSITION_NUMBER = attributes[++j];
                    gun_position_info.GUN_POSITION_STATUS = attributes[++j];
                    gun_position_info.GUN_INFO_ID         = attributes[++j];
                    gun_position_info.GUN_BULLET_NUMBER   = attributes[++j];
                    gun_position_info.GUN_TYPE            = attributes[++j];
                    if (i != gun_position_info_count - 1)
                    {
                        ++j;
                    }
                    position_info_bll.Add(gun_position_info);
                }
                //枪支信息
                int gun_info_count = int.Parse(attributes[j + 1].Substring(1, attributes[j + 1].LastIndexOf("&") - 1));
                for (int i = 0; i < gun_info_count; i++)
                {
                    Model.gun_info gun_info = new Gunark.Model.gun_info();
                    if (i == 0)
                    {
                        gun_info.GUN_INFO_ID = attributes[++j].Substring(3);
                    }
                    else
                    {
                        gun_info.GUN_INFO_ID = attributes[++j];
                    }
                    gun_info.GUNARK_ID           = attributes[++j];
                    gun_info.UNIT_ID             = attributes[++j];
                    gun_info.GUN_NUMBER          = attributes[++j];
                    gun_info.GUN_TYPE            = attributes[++j];
                    gun_info.GUN_STATUS          = attributes[++j];
                    gun_info.GUN_BULLET_LOCATION = attributes[++j];
                    if (i != gun_info_count - 1)
                    {
                        ++j;
                    }
                    gun_info_bll.Add(gun_info);
                }
                //弹仓信息
                int magazine_info_count = int.Parse(attributes[j + 1].Substring(1, attributes[j + 1].LastIndexOf("&") - 1));
                for (int i = 0; i < magazine_info_count; i++)
                {
                    Model.magazine_info magazine_info = new Gunark.Model.magazine_info();
                    if (i == 0)
                    {
                        magazine_info.MAGAZINE_INFO_ID = attributes[++j].Substring(3);
                    }
                    else
                    {
                        magazine_info.MAGAZINE_INFO_ID = attributes[++j];
                    }
                    magazine_info.GUNARK_ID       = attributes[++j];
                    magazine_info.UNIT_ID         = attributes[++j];
                    magazine_info.MAGAZINE_NUMBER = attributes[++j];
                    magazine_info.STOCK_QTY       = int.Parse(attributes[++j]);
                    magazine_info.CAPACITY_QTY    = int.Parse(attributes[++j]);
                    magazine_info.MAGAZINE_NAME   = attributes[++j];
                    magazine_info.BULLET_MODEL    = attributes[++j];
                    magazine_info.BULLET_GROUP_ID = attributes[++j];
                    ////if (i != magazine_info_count - 1)
                    ////    ++j;
                    magazine_info_bll.Add(magazine_info);
                }
            }
            else
            {
                int magazine_info_count = 0;
                //弹仓信息
                try
                {
                    magazine_info_count = int.Parse(attributes[j + 1].Substring(7, attributes[j + 1].LastIndexOf("&") - 1));
                }
                catch { }
                for (int i = 0; i < magazine_info_count; i++)
                {
                    Model.magazine_info magazine_info = new Gunark.Model.magazine_info();
                    if (i == 0)
                    {
                        magazine_info.MAGAZINE_INFO_ID = attributes[++j].Substring(9);
                    }
                    else
                    {
                        magazine_info.MAGAZINE_INFO_ID = attributes[++j];
                    }
                    magazine_info.GUNARK_ID       = attributes[++j];
                    magazine_info.UNIT_ID         = attributes[++j];
                    magazine_info.MAGAZINE_NUMBER = attributes[++j];
                    magazine_info.STOCK_QTY       = int.Parse(attributes[++j]);
                    magazine_info.CAPACITY_QTY    = int.Parse(attributes[++j]);
                    magazine_info.MAGAZINE_NAME   = attributes[++j];
                    magazine_info.BULLET_MODEL    = attributes[++j];
                    magazine_info.BULLET_GROUP_ID = attributes[++j];
                    ////if (i != magazine_info_count - 1)
                    ////    ++j;
                    magazine_info_bll.Add(magazine_info);
                }
            }
        }
Exemplo n.º 4
0
        /// <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();
                    }
                }
            }
        }