/// <summary> /// 同步子弹信息 /// </summary> /// <param name="unit_id"></param> /// <param name="gunark_id"></param> public static void syn_Magazine_Info(string unit_id, string gunark_id) { BLL.magazine_info magazine_info_bll = new Gunark.BLL.magazine_info(); WebService.gunServices webService = SingleWebService.getWebService(); WebService.magazineInfo[] magazine_info_list = webService.getMagazineInfo(unit_id, gunark_id); for (int i = 0; i < magazine_info_list.Length; i++) { if (!magazine_info_bll.Exists(magazine_info_list[i].magazine_Info_ID)) { Model.magazine_info magazine_info = new Gunark.Model.magazine_info(); magazine_info.MAGAZINE_INFO_ID = magazine_info_list[i].magazine_Info_ID; magazine_info.GUNARK_ID = magazine_info_list[i].gunArk.gunarkId; magazine_info.UNIT_ID = magazine_info_list[i].unitInfo.unitInfoCode; magazine_info.MAGAZINE_NUMBER = magazine_info_list[i].magazine_Number; magazine_info.STOCK_QTY = magazine_info_list[i].stock_Qty; magazine_info.MAGAZINE_NAME = magazine_info_list[i].magazine_Name; magazine_info.CAPACITY_QTY = magazine_info_list[i].capacity_Qty; magazine_info.BULLET_MODEL = magazine_info_list[i].bullet_Model; magazine_info.MAGAZINE_STATUS = magazine_info_list[i].magazine_Status; magazine_info.SYN_FLAG = magazine_info_list[i].syn_Flag; magazine_info_bll.Add(magazine_info); } } }
public static void getSynInfo() { //WebService接口调用工具 WebService.gunServices webService = SingleWebService.getWebService(); try { WebService.synInfo[] syn_info_list = webService.getSynInfo(ConfigurationManager.AppSettings["gunark_ip"]); for (int i = 0; i < syn_info_list.Length; i++) { try { //System.Windows.Forms.MessageBox.Show(syn_info_list[i].gunArk.gunarkId); Analysis.analysis(syn_info_list[i]); webService.setSynInfoSuccess(syn_info_list[i].syn_Id); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); } } } catch (Exception e1) { System.Windows.Forms.MessageBox.Show("请检查网络连接!"); } }
/// <summary> /// 同步任务信息 /// </summary> public static void syn_Task_Info() { //同步枪柜信息(以后要改成通过guark_ip获取) //syn_gunark_info(ConfigurationManager.AppSettings["gunark_ip"]); syn_gunark_info("TEST"); WebService.gunServices webService = SingleWebService.getWebService(); BLL.task_info task_info_bll = new Gunark.BLL.task_info(); WebService.taskInfo[] task_info_list = webService.getTaskInfo(ConfigurationManager.AppSettings["unit_id"], ConfigurationManager.AppSettings["gunark_id"]); for (int i = 0; i < task_info_list.Length; i++) { if (!task_info_bll.Exists(task_info_list[i].task_ID) && task_info_list[i].task_BigType != 1) { Model.task_info task_info = new Gunark.Model.task_info(); //为对象设置属性 task_info.gunarkId = task_info_list[i].gunArk.gunarkId; task_info.unitId = task_info_list[i].unitInfo.unitInfoCode; task_info.TASK_APPLY_USERID = task_info_list[i].task_Apply_User.userPoliceNumb; task_info.task_Plan_BeginTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", task_info_list[i].task_Plan_BeginTime); task_info.task_Plan_FinishTime = string.Format("{0:yyyy-MM-dd HH:mm:ss.f}", task_info_list[i].task_Plan_FinishTime); task_info.TASK_STATUS = task_info_list[i].task_Status.ToString(); task_info.TASK_BIGTYPE = Convert.ToInt32(task_info_list[i].task_BigType.ToString()); ClassValueCopier.Copy(task_info, task_info_list[i]); task_info_bll.Add(task_info); syn_Task_Details(task_info_list[i].task_ID, task_info_list[i].unitInfo.unitInfoCode, task_info_list[i].gunArk.gunarkId); } } }
/// <summary> /// 同步枪支信息 /// </summary> /// <param name="unit_id"></param> /// <param name="gunark_id"></param> public static void syn_Gun_Info(string unit_id, string gunark_id) { BLL.gun_info gun_info_bll = new Gunark.BLL.gun_info(); WebService.gunServices webService = SingleWebService.getWebService(); WebService.gunInfo[] gun_info_list = webService.getGunInfo(unit_id, gunark_id); for (int i = 0; i < gun_info_list.Length; i++) { if (!gun_info_bll.Exists(gun_info_list[i].gun_Info_Id)) { Model.gun_info gun_info = new Gunark.Model.gun_info(); gun_info.GUN_INFO_ID = gun_info_list[i].gun_Info_Id; gun_info.GUNARK_ID = gun_info_list[i].gunArk.gunarkId; gun_info.UNIT_ID = gun_info_list[i].unitInfo.unitInfoCode; gun_info.GUN_NUMBER = gun_info_list[i].gun_Bullet_Number; gun_info.GUN_TYPE = gun_info_list[i].gun_Bullet_Name; gun_info.GUN_STATUS = gun_info_list[i].gun_Bullet_Status.ToString(); gun_info.GUN_BULLET_LOCATION = gun_info_list[i].gun_Bullet_Location; gun_info.LOSS_DESCRIPTION = gun_info_list[i].loss_Description; gun_info.REMARK = gun_info_list[i].remark; gun_info.SYN_FLAG = gun_info_list[i].syn_Flag; gun_info_bll.Add(gun_info); } } }
/// <summary> /// 同步任务详情 /// </summary> public static void syn_Task_Details(string task_id, string unit_id, string gunark_id) { BLL.task_info_detail task_info_detail_bll = new Gunark.BLL.task_info_detail(); WebService.gunServices webService = SingleWebService.getWebService(); WebService.taskInfoDetail[] task_info_details_list = webService.getTaskDetail(task_id); //标识是否有枪的信息 bool gunIsNull = true; //标识是否有弹的信息 bool bulletIsNull = true; for (int i = 0; i < task_info_details_list.Length; i++) { if (!task_info_detail_bll.Exists(task_info_details_list[i].task_Detail_ID)) { Model.task_info_detail task_info_detail = new Gunark.Model.task_info_detail(); //为对象设置属性 task_info_detail.TASK_ID = task_id; task_info_detail.UNIT_ID = task_info_details_list[i].unitInfo.unitInfoCode; task_info_detail.GUNARK_ID = task_info_details_list[i].gunArk.gunarkId; if (task_info_details_list[i].gunInfo != null) { task_info_detail.GUN_INFO_ID = task_info_details_list[i].gunInfo.gun_Info_Id; gunIsNull = false; } if (task_info_details_list[i].gunPositionInfo != null) { task_info_detail.GUN_POSITION_INFO_ID = task_info_details_list[i].gunPositionInfo.gun_Position_Info_Id; } if (task_info_details_list[i].magazineInfo != null) { task_info_detail.MAGAZINE_INFO_ID = task_info_details_list[i].magazineInfo.magazine_Info_ID; bulletIsNull = false; } if (task_info_details_list[i].gun_Duty_User != null) { task_info_detail.GUN_DUTY_USER = task_info_details_list[i].gun_Duty_User.userPoliceNumb; } task_info_detail.task_Detail_ID = task_info_details_list[i].task_Detail_ID; task_info_detail.apply_Bullet_Qty = task_info_details_list[i].apply_Bullet_Qty; task_info_detail.BULLET_TYPE = task_info_details_list[i].bullet_Model; task_info_detail_bll.Add(task_info_detail); } } if (!gunIsNull) { //同步枪支信息 syn_Gun_Info(unit_id, gunark_id); //同步枪位信息 syn_Gun_Position_Info(unit_id, gunark_id); } if (!bulletIsNull) { syn_Magazine_Info(unit_id, gunark_id); } }
/// <summary> /// 同步用户信息 /// </summary> /// <returns>WebService.user[]</returns> public static WebService.user[] getUserInfo() { WebService.user[] userList = null; WebService.gunServices webService = SingleWebService.getWebService(); try { userList = webService.getUser(ConfigurationManager.AppSettings["unit_id"]); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); } return(userList); }
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); } }
/// <summary> /// 同步枪柜信息 /// </summary> /// <param name="guanrk_ip"></param> public static void syn_gunark_info(string guanrk_ip) { BLL.gunark gunark_bll = new Gunark.BLL.gunark(); WebService.gunServices webService = SingleWebService.getWebService(); WebService.gunArk gunark_syn = webService.getGunarkInfo(guanrk_ip); if (gunark_syn != null) { Model.gunark gunark = new Gunark.Model.gunark(); gunark.GUNARK_ID = gunark_syn.gunarkId; gunark.GUNARK_IP = gunark_syn.gunarkIp; gunark.GUNARK_ENTERTIME = gunark_syn.enterTime.ToString(); gunark.GUNARK_GATEWAY = gunark_syn.gunarkGateway; gunark.GUNARK_SUBNET = gunark_syn.gunarkSubnet; gunark.GUNARK_TYPE = gunark_syn.gunarkType; gunark.GUNARK_NAME = gunark_syn.gunarkName; gunark.GUNARK_NUMOFGUN = gunark_syn.numOfGun; gunark.GUNARK_NUMOFBULLETWAREHOUSE = gunark_syn.numOfBulletWarehouse; gunark.UNITINFO_CODE = gunark_syn.unitInfo.unitInfoCode; gunark.GUNARK_STATUS = gunark_syn.gunarkStatus; if (!gunark_bll.Exists(gunark_syn.gunarkId)) { Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); cfa.AppSettings.Settings["gunark_id"].Value = gunark.GUNARK_ID; cfa.AppSettings.Settings["unit_id"].Value = gunark.UNITINFO_CODE; cfa.Save(); ConfigurationManager.RefreshSection("appSettings"); ConfigurationManager.RefreshSection("appSettings"); gunark_bll.Add(gunark); //使能弹柜 Communication comm = CommunicationInstance.getInstance().getCommunication(); comm.enableBullet(); } else { gunark_bll.Update(gunark); } } }
/// <summary> /// 同步枪位信息 /// </summary> /// <param name="unit_id"></param> /// <param name="gunark_id"></param> public static void syn_Gun_Position_Info(string unit_id, string gunark_id) { BLL.position_info gun_position_info_bll = new Gunark.BLL.position_info(); WebService.gunServices webService = SingleWebService.getWebService(); WebService.gunPositionInfo[] gun_position_info_list = webService.getGunPositionInfo(unit_id, gunark_id); for (int i = 0; i < gun_position_info_list.Length; i++) { if (!gun_position_info_bll.Exists(gun_position_info_list[i].gun_Position_Info_Id)) { Model.position_info gun_position_info = new Gunark.Model.position_info(); gun_position_info.GUN_POSITION_INFO_ID = gun_position_info_list[i].gun_Position_Info_Id; gun_position_info.UNIT_ID = gun_position_info_list[i].unitInfo.unitInfoCode; gun_position_info.GUNARK_ID = gun_position_info_list[i].gunArk.gunarkId; gun_position_info.GUN_POSITION_NUMBER = gun_position_info_list[i].gun_Position_Number; gun_position_info.GUN_POSITION_STATUS = gun_position_info_list[i].gun_Position_Status.ToString();; gun_position_info.GUN_INFO_ID = gun_position_info_list[i].gun_Info_ID; gun_position_info.GUN_BULLET_NUMBER = gun_position_info_list[i].gun_Bullet_Number; gun_position_info.GUN_TYPE = gun_position_info_list[i].gun_Bullet_Name; gun_position_info_bll.Add(gun_position_info); } } }
public static void analysis(WebService.synInfo synInfo) { WebService.gunServices webService = SingleWebService.getWebService(); #region model Model.gunark gunark = new Gunark.Model.gunark(); Model.user user = new Gunark.Model.user(); Model.group group = new Gunark.Model.group(); Model.gbg gbg = new Gunark.Model.gbg(); Model.fingerprint fingerPrint = new Gunark.Model.fingerprint(); #endregion model #region bll Bll.user user_bll = new Gunark.BLL.user(); Bll.gunark gunark_bll = new Gunark.BLL.gunark(); Bll.group group_bll = new Gunark.BLL.group(); Bll.gbg gbg_bll = new Gunark.BLL.gbg(); Bll.fingerprint fingerPrint_bll = new Gunark.BLL.fingerprint(); #endregion bll #region attritubes string[] attritubes = null; #endregion attritubes #region 步类型 switch (synInfo.syn_Type) { #region 枪柜 case "枪柜信息增加": //通过 gunark = analysisGunark(synInfo.syn_Param); gunark_bll.Add(gunark); //获取枪弹绑定关系 attritubes = synInfo.syn_Param.Split('|'); WebService.gunarkGroupGunBullet[] gggb = webService.getGunarkGroupGunBullet(attritubes[0]); for (int i = 0; i < gggb.Length; i++) { Model.gbg ggbg = new Gunark.Model.gbg(); gbg.GGGBID = gggb[i].gggbId; gbg.GROUP_ID = gggb[i].groupId; gbg.GUN_LOCATION = gggb[i].gunLocation; gbg.GUNARK_ID = gggb[i].gunarkId; gbg.BULLET_LOCATION = int.Parse(gggb[i].bulletLocation); gbg_bll.Add(gbg); } break; case "枪柜信息修改": //未通过 gunark = analysisGunark(synInfo.syn_Param); gunark_bll.Update(gunark); break; case "注销": //未通过 attritubes = synInfo.syn_Param.Split('|'); gunark = gunark_bll.GetModel(attritubes[0]); gunark.GUNARK_STATUS = 0; gunark_bll.Update(gunark); break; case "是否枪弹对应": //未通过 break; case "是否使用组权限": //未通过 break; #endregion 枪柜 #region 用户(用户绑定组未通过【寄存组有问题】、新增枪柜增加用户) case "增加用户": user = analysisUser(synInfo.syn_Param); user_bll.Add(user); break; case "更新用户": user = analysisUser(synInfo.syn_Param); user_bll.Update(user); break; case "枪柜增加用户": analysisUser1(synInfo.syn_Param); break; #endregion 用户 #region 组信息(组增加已通过、新增枪柜增加组) case "增加班组": group = analysisGroup(synInfo.syn_Param); group_bll.Add(group); break; case "组注销": attritubes = synInfo.syn_Param.Split('|'); group = group_bll.GetModel(attritubes[0]); group_bll.Update(group); break; case "枪柜增加组": analysisGroup1(synInfo.syn_Param); break; #endregion 组信息 #region 枪弹组绑定关系(未测试) case "枪柜对应修改": attritubes = synInfo.syn_Param.Split('|'); gbg = gbg_bll.GetModel(attritubes[0]); gbg.GUN_LOCATION = int.Parse(attritubes[2]); gbg.BULLET_LOCATION = int.Parse(attritubes[3]); gbg_bll.Update(gbg); break; case "枪位所属组修改": attritubes = synInfo.syn_Param.Split('|'); gbg = gbg_bll.GetModelByGunPos(attritubes[0], attritubes[1]); gbg.GROUP_ID = attritubes[2]; gbg_bll.Update(gbg); break; #endregion 枪弹组绑定关系 #region 指纹信息(未测试) case "指纹增加": fingerPrint = analysisFingerPrint(synInfo.syn_Param); fingerPrint_bll.Add(fingerPrint); break; case "指纹修改": //通过USER_ID查 fingerPrint = fingerPrint_bll.GetModelByUser(attritubes[1], attritubes[4]); fingerPrint.USER_FINGERPRINT = StrToByte(attritubes[6]); fingerPrint.USER_BAN = int.Parse(attritubes[7]); fingerPrint_bll.Update(fingerPrint); break; #endregion 指纹信息 #region 增加任务(测试通过) case "增加任务": addTask(synInfo.syn_Param); break; #endregion 增加任务 default: break; } #endregion 步类型 }
/// <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); }