Ejemplo n.º 1
0
        private string GetXml(DoorEntity door, DeviceEntity device)
        {
            var flag = door.SyncVersion == 0 ? "C" : "U"; //增|删|改,C|D|U

            if (door.Deleted)
            {
                flag = "D";
            }
            var area           = _areaRepository.GetById(door.AreaUUID);
            var DeviceTypeDict = device.DeviceType.HasValue ? _dictService.GetById(device.DeviceType.Value) : null;
            var LockTypeDict   = device.LockType.HasValue ? _dictService.GetById(device.LockType.Value) : null;

            var xmlBuilder = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

            xmlBuilder.Append("<Tpp2Fpp>");
            xmlBuilder.Append("<ReqHeader>");
            xmlBuilder.AppendFormat("<ReqSeqNo>{0}</ReqSeqNo>", Utils.MakeRndName());
            xmlBuilder.AppendFormat("<ReqSPID>{0}</ReqSPID>", DESHelper.Encrypt3Des(Constant.LkbAccount, Constant.DescKeyBytes));
            xmlBuilder.AppendFormat("<ReqCode>{0}</ReqCode>", DESHelper.Encrypt3Des(Constant.LkbPassword, Constant.DescKeyBytes));
            xmlBuilder.Append("</ReqHeader>");
            xmlBuilder.Append("<ReqBody>");
            xmlBuilder.Append("<device>");
            xmlBuilder.AppendFormat("<uuid>{0}</uuid>", door.DoorUUID);
            xmlBuilder.AppendFormat("<name>{0}</name>", device.DeviceName);
            xmlBuilder.AppendFormat("<mac>{0}</mac>", device.Mac);
            xmlBuilder.AppendFormat("<type>{0}</type>", DeviceTypeDict != null ? DeviceTypeDict.DictCode : ""); //设备类型 必传
            xmlBuilder.AppendFormat("<gw_uuid>{0}</gw_uuid>", "");                                              //所属控制器(网关)的uuid
            xmlBuilder.AppendFormat("<status>{0}</status>", door.Status == 1?1:2);                              //文档中未提及
            xmlBuilder.AppendFormat("<area_uuid>{0}</area_uuid>", area.AreaUUID);                               //证件号码(需要加密) 必填
            xmlBuilder.AppendFormat("<area_layercode>{0}</area_layercode>", area.AreaCode);                     //房屋区域层级编码 必填
            xmlBuilder.AppendFormat("<cdate>{0}</cdate>", door.CreateTime.ToString("yyyyMMddHHmmss"));
            xmlBuilder.AppendFormat("<udate>{0}</udate>", door.CreateTime.ToString("yyyyMMddHHmmss"));
            xmlBuilder.AppendFormat("<inner_key>{0}</inner_key>", device.InnerKey);
            xmlBuilder.AppendFormat("<cuser>{0}</cuser>", Constant.LkbAccount);
            xmlBuilder.AppendFormat("<locktype>{0}</locktype>", LockTypeDict != null ? LockTypeDict.DictCode : "");
            xmlBuilder.AppendFormat("<flag>{0}</flag>", flag);
            xmlBuilder.Append("</device>");
            xmlBuilder.Append("</ReqBody>");
            xmlBuilder.Append("</Tpp2Fpp>");
            return(xmlBuilder.ToString());
        }
Ejemplo n.º 2
0
        private string GetXml(DeviceAlarmEntity entity, DoorDto door)
        {
            var flag = entity.SyncVersion == 0 ? "C" : "U"; //增|删|改,C|D|U

            if (entity.Deleted)
            {
                flag = "D";
            }

            var AlarmTypeDict = _dictService.GetById(entity.AlarmType);

            var xmlBuilder = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

            xmlBuilder.Append("<Tpp2Fpp>");
            xmlBuilder.Append("<ReqHeader>");
            xmlBuilder.AppendFormat("<ReqSeqNo>{0}</ReqSeqNo>", Utils.MakeRndName());
            xmlBuilder.AppendFormat("<ReqSPID>{0}</ReqSPID>", DESHelper.Encrypt3Des(Constant.LkbAccount, Constant.DescKeyBytes));
            xmlBuilder.AppendFormat("<ReqCode>{0}</ReqCode>", DESHelper.Encrypt3Des(Constant.LkbPassword, Constant.DescKeyBytes));
            xmlBuilder.Append("</ReqHeader>");
            xmlBuilder.Append("<ReqBody>");
            xmlBuilder.Append("<deviceAlarm>");
            xmlBuilder.AppendFormat("<uuid>{0}</uuid>", entity.AlarmUUID);
            xmlBuilder.AppendFormat("<occur_date>{0}</occur_date>", entity.OccurTime.ToString("yyyyMMddHHmmss"));
            xmlBuilder.AppendFormat("<cdate>{0}</cdate>", entity.CreateTime.ToString("yyyyMMddHHmmss"));
            xmlBuilder.AppendFormat("<type>{0}</type>", AlarmTypeDict.DictCode);
            xmlBuilder.AppendFormat("<status>{0}</status>", entity.Status);
            xmlBuilder.AppendFormat("<udate>{0}</udate>", entity.UpdateTime.HasValue?entity.UpdateTime.Value.ToString("yyyyMMddHHmmss"):"");
            xmlBuilder.AppendFormat("<mac>{0}</mac>", "");
            xmlBuilder.AppendFormat("<area_uuid>{0}</area_uuid>", door.AreaUUID);
            xmlBuilder.AppendFormat("<account_uuid>{0}</account_uuid>", Constant.LkbAccount);
            xmlBuilder.AppendFormat("<device_uuid>{0}</device_uuid>", entity.DeviceUUID); //存的时候是不是存门ID
            xmlBuilder.AppendFormat("<remark>{0}</remark>", entity.Remark);
            xmlBuilder.AppendFormat("<cardno>{0}</cardno>", string.Format("0000{0}", entity.CardNo));
            xmlBuilder.AppendFormat("<dev_date>{0}</dev_date>", "");
            xmlBuilder.AppendFormat("<ctrl_mac>{0}</ctrl_mac>", "");
            xmlBuilder.AppendFormat("<flag>{0}</flag>", flag);
            xmlBuilder.Append("</deviceAlarm>");
            xmlBuilder.Append("</ReqBody> ");
            xmlBuilder.Append("</Tpp2Fpp> ");
            return(xmlBuilder.ToString());
        }
Ejemplo n.º 3
0
        public ActionResult Edit(string id)
        {
            var mdoel = _dictService.GetById(id);

            return(View(mdoel));
        }
Ejemplo n.º 4
0
        private string GetCardXml(CardEntity entity, PersonEntity person)
        {
            var flag = entity.SyncVersion == 0 ? "C" : "U"; //增|删|改,C|D|U

            if (entity.Deleted)
            {
                flag = "D";
            }

            //根据卡号需要找到房间ID  得到AreaCode及LayerCode
            var query = from r in _roomRepository.Table
                        join ru in _roomUserRepository.Table on r.RoomUUID equals ru.RoomUUID
                        join uc in _userCardRepository.Table on ru.RoomUserUUID equals uc.RoomUserUUID
                        where uc.CardUUID == entity.CardUUID
                        orderby uc.CreateTime descending
                        select new {
                r.AreaUUID,
                ru.FamilyRelation
            };

            var room = query.FirstOrDefault();

            if (room == null)
            {
                return(string.Empty);
            }

            var familyRelationDict = _dictService.GetById(room.FamilyRelation.Value);

            var area = _areaService.GetById(room.AreaUUID);

            var type1 = "2";

            if (person.PersonType == 272)
            {
                type1 = "1";
            }

            var type2 = familyRelationDict?.DictCode ?? "0";

            if (type2 == "10")
            {
                type2 = "9";
            }


            var xmlBuilder = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

            xmlBuilder.Append("<Tpp2Fpp>");
            xmlBuilder.Append("<ReqHeader>");
            xmlBuilder.AppendFormat("<ReqSeqNo>{0}</ReqSeqNo>", Utils.MakeRndName());
            xmlBuilder.AppendFormat("<ReqSPID>{0}</ReqSPID>", DESHelper.Encrypt3Des(Constant.LkbAccount, Constant.DescKeyBytes));
            xmlBuilder.AppendFormat("<ReqCode>{0}</ReqCode>", DESHelper.Encrypt3Des(Constant.LkbPassword, Constant.DescKeyBytes));
            xmlBuilder.Append("</ReqHeader>");
            xmlBuilder.Append("<ReqBody>");
            xmlBuilder.Append("<crk>");
            xmlBuilder.AppendFormat("<uuid>{0}</uuid>", entity.CardUUID);
            xmlBuilder.AppendFormat("<crkno>{0}</crkno>", entity.CardNo);
            xmlBuilder.AppendFormat("<idcode>{0}</idcode>", DESHelper.Encrypt3Des(person.IDCardNo + type1 + type2, Constant.DescKeyBytes)); //身份信息编码( 参见杭州市规范 ) ,护照正常传入,不用编码(需要加密)
            xmlBuilder.AppendFormat("<addrcode>{0}</addrcode>", "");                                                                        //住址信息编码( 参见杭州市规范 )
            xmlBuilder.AppendFormat("<udate>{0}</udate>", Constant.FormatDateTime(entity.UpdateTime));
            xmlBuilder.AppendFormat("<cuser>{0}</cuser>", Constant.LkbAccount);
            xmlBuilder.AppendFormat("<state>{0}</state>", "2"); //出入卡状态(0:初始化;1:操作中;2:正常;3:挂失;4:注销)
            xmlBuilder.AppendFormat("<stime>{0}</stime>", Constant.FormatDateTime(entity.ValidFrom));
            xmlBuilder.AppendFormat("<etime>{0}</etime>", Constant.FormatDateTime(entity.ValidTo));
            xmlBuilder.AppendFormat("<cdate>{0}</cdate>", entity.CreateTime.ToString("yyyyMMddHHmmss"));
            xmlBuilder.AppendFormat("<key>{0}</key>", entity.AreaKey);            //区域权限因子(二级) (定长为 4位)
            xmlBuilder.AppendFormat("<mac>{0}</mac>", "");                        //
            xmlBuilder.AppendFormat("<layercode>{0}</layercode>", area.AreaCode); //归属区域层级编码
            xmlBuilder.AppendFormat("<crkno4>{0}</crkno4>", entity.CardLast4NO);
            xmlBuilder.AppendFormat("<key1>{0}</key1>", entity.AreaKey1);         //区域权限因子(一级) (定长为 4位)
            xmlBuilder.AppendFormat("<flag>{0}</flag>", flag);
            xmlBuilder.Append("</crk>");
            xmlBuilder.Append("</ReqBody> ");
            xmlBuilder.Append("</Tpp2Fpp> ");
            return(xmlBuilder.ToString());
        }