/// <summary>
        /// Create IUS without Data Sheet
        /// </summary>
        /// <param name="excelFile">Excel File</param>
        internal override void GenerateSheet(ref DevInfo.Lib.DI_LibBAL.UI.Presentations.DIExcelWrapper.DIExcel excelFile)
        {
            int sheetNo = base.CreateSheet(ref excelFile, DILanguage.GetLanguageString("IUS_WITHOUT_DATA"));
            DataTable Table = null;

            // -- sheet content
            excelFile.SetCellValue(sheetNo, Constants.HeaderRowIndex, Constants.HeaderColIndex, DILanguage.GetLanguageString("IUS_WITHOUT_DATA"));

            excelFile.GetCellFont(sheetNo, Constants.HeaderRowIndex, Constants.HeaderColIndex).Size = Constants.SheetsLayout.HeaderFontSize;

            // -- Get IUSLinked Data TAble.
            Table = this.GetIUSWithoutDataTable();
            excelFile.LoadDataTableIntoSheet(Constants.Sheet.IUSLinkedTOIC.IUSLinkedDetailsRowIndex, Constants.HeaderColIndex, Table, sheetNo, false);

            int LastRow = Constants.Sheet.IUSLinkedTOIC.IUSLinkedDetailsRowIndex + Table.Rows.Count;

            // -- Apply Font Settings
            this.ApplyFontSettings(ref excelFile, sheetNo, Constants.Sheet.IUSLinkedTOIC.IUSLinkedDetailsRowIndex, Constants.HeaderColIndex, LastRow, Constants.Sheet.IUSLinkedTOIC.IUSLinkedLastColIndex, true);

            // -- Set Column Width
            excelFile.SetColumnWidth(sheetNo, Constants.SheetsLayout.HeaderNameColWidth, Constants.Sheet.IUSLinkedTOIC.IUSLinkedNameColIndex, Constants.Sheet.IUSLinkedTOIC.IUSLinkedNameColIndex, LastRow, Constants.Sheet.IUSLinkedTOIC.IUSLinkedNameColIndex);
            // -- autofit Map
            excelFile.AutoFitColumns(sheetNo, Constants.Sheet.IUSLinkedTOIC.IUSLinkedDetailsRowIndex, Constants.Sheet.IUSLinkedTOIC.IUSLinkedLastColIndex, LastRow, Constants.Sheet.IUSLinkedTOIC.IUSLinkedLastColIndex);
            // -- Wrap Text of Indicator Column
            excelFile.WrapText(sheetNo, Constants.HeaderRowIndex, Constants.Sheet.IUSLinkedTOIC.IUSLinkedNameColIndex, LastRow, Constants.Sheet.IUSLinkedTOIC.IUSLinkedNameColIndex, true);
        }
        /// <summary>
        /// Create SubGroup Sheet
        /// </summary>
        /// <param name="excelFile"></param>
        internal override void GenerateSheet(ref DevInfo.Lib.DI_LibBAL.UI.Presentations.DIExcelWrapper.DIExcel excelFile)
        {
            int SheetNo = this.CreateSheet(ref excelFile, this.ColumnHeader[DSRColumnsHeader.SUBGROUP]);
            DataTable Table = null;

            // -- sheet content
            excelFile.SetCellValue(SheetNo, Constants.HeaderRowIndex, Constants.HeaderColIndex, ColumnHeader[DSRColumnsHeader.SUBGROUP]);
            excelFile.GetCellFont(SheetNo, Constants.HeaderRowIndex, Constants.HeaderColIndex).Size = Constants.SheetsLayout.HeaderFontSize;

            excelFile.SetCellValue(SheetNo, Constants.Sheet.Subgroup.SubGroupDetailsRowIndex, Constants.Sheet.SummaryReport.SubgroupColValueIndex, ColumnHeader[DSRColumnsHeader.SUBGROUP]);
            excelFile.SetCellValue(SheetNo, Constants.Sheet.Subgroup.SubGroupDetailsRowIndex, Constants.Sheet.SummaryReport.SubgroupColValueIndex, ColumnHeader[DSRColumnsHeader.GLOBAL]);

            Table = this.GetSubGroupTable();
            excelFile.LoadDataTableIntoSheet(Constants.Sheet.Subgroup.SubGroupDetailsRowIndex, Constants.HeaderColIndex, Table, SheetNo, false);

            int LastRow = Constants.Sheet.Subgroup.SubGroupDetailsRowIndex + Table.Rows.Count;

            // -- Apply Font Settings
            this.ApplyFontSettings(ref excelFile, SheetNo, Constants.Sheet.Subgroup.SubGroupDetailsRowIndex, Constants.HeaderColIndex, LastRow, Constants.Sheet.Subgroup.SubGroupLastColIndex, true);

            // -- Set Column Width
            excelFile.SetColumnWidth(SheetNo, Constants.SheetsLayout.HeaderNameColWidth, Constants.Sheet.Subgroup.SubGroupDetailsRowIndex, Constants.Sheet.Subgroup.SubGroupNameColIndex, LastRow, Constants.Sheet.Subgroup.SubGroupNameColIndex);
            // -- Wrap Text of Indicator Column
            excelFile.WrapText(SheetNo, Constants.Sheet.Subgroup.SubGroupDetailsRowIndex, Constants.Sheet.Subgroup.SubGroupNameColIndex, LastRow, Constants.Sheet.Subgroup.SubGroupNameColIndex, true);
        }
        /// <summary>
        /// Create Sources without DataValue Sheet
        /// </summary>
        /// <param name="excelFile"></param>
        internal override void GenerateSheet(ref DevInfo.Lib.DI_LibBAL.UI.Presentations.DIExcelWrapper.DIExcel excelFile)
        {
            int sheetNo = this.CreateSheet(ref excelFile, DILanguage.GetLanguageString("AREAS_WITHOUT_DATA"));
            DataTable Table = null;

            // -- sheet content
            excelFile.SetCellValue(sheetNo, Constants.HeaderRowIndex, Constants.HeaderColIndex, DILanguage.GetLanguageString("AREAS_WITHOUT_DATA"));
            excelFile.GetCellFont(sheetNo, Constants.HeaderRowIndex, Constants.HeaderColIndex).Size = Constants.SheetsLayout.HeaderFontSize;

            // -- Get Area Data TAble.
            Table = this.GetAreasWithoutDataTable();
            excelFile.LoadDataTableIntoSheet(Constants.Sheet.Area.AreaDetailsRowIndex, Constants.HeaderColIndex, Table, sheetNo, false);

            int LastRow = Constants.Sheet.Area.AreaDetailsRowIndex + Table.Rows.Count;

            // -- Apply Font Settings
            this.ApplyFontSettings(ref excelFile, sheetNo, Constants.Sheet.Area.AreaDetailsRowIndex, Constants.HeaderColIndex, LastRow, Constants.Sheet.Area.AreaWithoutDataLastColIndex, true);

            // -- Set Column Width
            excelFile.SetColumnWidth(sheetNo, Constants.SheetsLayout.OthersColumnWidth, Constants.Sheet.Area.AreaDetailsRowIndex, Constants.Sheet.Area.AreaIDColIndex, LastRow, Constants.Sheet.Area.AreaIDColIndex);
            excelFile.SetColumnWidth(sheetNo, Constants.SheetsLayout.HeaderNameColWidth, Constants.Sheet.Area.AreaDetailsRowIndex, Constants.Sheet.Area.AreaNameColIndex, LastRow, Constants.Sheet.Area.AreaNameColIndex);

            // -- Wrap Text of Indicator Column
            excelFile.WrapText(sheetNo, Constants.HeaderRowIndex, Constants.Sheet.SummaryReport.AreaColValueIndex, LastRow, Constants.Sheet.SummaryReport.AreaColValueIndex, true);
        }
Beispiel #4
0
        /// <summary>
        /// Returns qurey to change data type of Data_NID column to LongInteger
        /// </summary>
        /// <param name="tableName">RecommendedSource Tablename</param>
        /// <param name="forOnlineDB"></param>
        /// <param name="serverType"></param>
        /// <returns></returns>
        public static string UpdateTypeofDataNIdColumn(string tableName, bool forOnlineDB, DevInfo.Lib.DI_LibDAL.Connection.DIServerType serverType)
        {
            string RetVal = string.Empty;
            RetVal = "ALTER TABLE " + tableName + " ALTER COLUMN  " + DIColumns.RecommendedSources.DataNId+ " ";

            if (forOnlineDB)
            {
               // do nothing
            }
            else
            {
                RetVal += " Long ";
            }

            return RetVal;
        }
Beispiel #5
0
        public static void SetDeivInfo(DevInfo devinfo, device item)
        {
            devinfo.Abutment_Id    = item.id;
            devinfo.Code           = item.code;
            devinfo.Abutment_Type  = (Abutment_DevTypes)item.type;
            devinfo.Status         = (Abutment_Status)item.state;
            devinfo.RunStatus      = (Abutment_RunStatus)item.running_state;
            devinfo.Placed         = item.placed;
            devinfo.Abutment_DevID = item.raw_id;
            devinfo.IP             = item.ip;
            devinfo.Manufactor     = "霍尼韦尔";

            devinfo.ModifyTime      = DateTime.Now;
            devinfo.ModifyTimeStamp = TimeConvert.ToStamp(devinfo.ModifyTime);

            //devinfo.ParentId = area.Id;
            devinfo.KKS  = item.kks;
            devinfo.Name = item.name;
        }
 /// <summary>
 /// 显示设备信息
 /// </summary>
 /// <param name="devInfo"></param>
 public void ShowDevInfo(DevInfo devInfo)
 {
     Window.SetActive(true);
     currentDev = devInfo;
     if (devInfo == null || string.IsNullOrEmpty(devInfo.Name))
     {
         DevNameText.text = "设备";
     }
     else
     {
         DevNameText.text = devInfo.Name;
     }
     for (int i = 0; i < ItemList.Count; i++)
     {
         float  randomValue = Random.Range(25.8f, 40);
         string subDevName  = string.Format("子部件{0}温度", i + 1);
         ItemList[i].InitItem(randomValue, 50, subDevName);
     }
 }
        public ActionResult Create([Bind(Include = "Id,Code,Name,X,Y,Z,Type,IsAutoIp,Ip,ServerIp,ServerPort,Power,AliveTime,Enable,MapId")] Archor archor)
        {
            if (ModelState.IsValid)
            {
                DevInfo dev = new DevInfo();
                dev.Local_DevID = Guid.NewGuid().ToString();
                dev.IP          = "";
                dev.KKS         = "";
                dev.Name        = archor.Name;
                dev.ModelName   = TypeNames.Archor;
                dev.Status      = 0;
                string DepID = Request["DepID"];
                if (DepID == "" || DepID == null)
                {
                    GetListToViewBag();
                    return(View(archor));
                }
                dev.ParentId = Convert.ToInt32(Request["DepID"]);
                try
                {
                    dev.Local_TypeCode = TypeCodes.Archor;
                }
                catch (Exception e)
                {
                    dev.Local_TypeCode = 0;
                }
                dev.UserName = "******";

                archor.DevInfo = dev;
                var result = bll.Archors.Add(archor);
                if (result)
                {
                    return(Json(new { success = result }));
                }
                else
                {
                    return(Json(new { success = result, errors = bll.Archors.ErrorMessage }));
                }
            }
            GetListToViewBag();
            return(View(archor));
        }
Beispiel #8
0
    /// <summary>
    /// 设备类型
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public bool DeviceType(DevInfo type)
    {
        int level = DeviceTypeDropdown.Instance.DevTypeDropdown.value;

        if (level == 0)
        {
            return(true);
        }
        else
        {
            if (type.TypeName == GetDevSeachType())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }
Beispiel #9
0
 /// <summary>
 /// 根据设备信息,获取摄像头信息
 /// </summary>
 /// <param name="dev"></param>
 public Dev_CameraInfo GetCameraInfo(DevInfo dev)
 {
     if (CameraInfo != null)
     {
         return(CameraInfo);
     }
     if (dev != null)
     {
         CommunicationObject service = CommunicationObject.Instance;
         if (service)
         {
             CameraInfo = service.GetCameraInfoByDevInfo(dev);
             if (CameraInfo == null)
             {
                 Debug.LogError(string.Format("CamerInfo not find-> DevName:{0} DevId:{1}", dev.Name, dev.Id));
             }
         }
     }
     return(CameraInfo);
 }
Beispiel #10
0
    /// <summary>
    /// 保存数据信息
    /// </summary>
    private void SaveData()
    {
        CommunicationObject service = CommunicationObject.Instance;

        if (service == null)
        {
            return;
        }
        DevNode modelTemp = CopyObj.GetComponent <DevNode>();

        if (modelTemp == null)
        {
            return;
        }
        modelTemp.Info.Pos.RotationY = CopyObj.transform.eulerAngles.y;
        service.ModifyDevPos(modelTemp.Info.Pos);
        if (list != null && list.Count != 0)
        {
            //DataAccessController.Instance.ModifyDevInRoomEx(model);
            List <DevInfo> devinfoList = new List <DevInfo>();
            for (int i = 0; i < list.Count; i++)
            {
                GameObject devModel = list[i];
                DevInfo    devInfo  = GetDevInfo(modelTemp.Info, i);
                devModel.transform.parent = CopyObj.transform.parent;
                devModel.layer            = CopyObj.layer;
                DevNode dev = SetDevController(devInfo, devModel);
                if (dev == null)
                {
                    continue;
                }
                DevPos pos = GetDevPos(dev, devInfo.DevID);
                devInfo.Pos = pos;
                devinfoList.Add(devInfo);
            }
            List <DevInfo> infoList = service.AddDevInfo(devinfoList);
            SetDevInfoId(devinfoList, infoList);
            SaveDevSubInfo(list, service);
        }
        AddSelectionDevs(list);
    }
Beispiel #11
0
    /// <summary>
    /// 设置设备的Controller
    /// </summary>
    /// <param name="devModel"></param>
    /// <param name="devInfo"></param>
    /// <param name="parentID"></param>
    private DoorAccessDevController SetDevController(GameObject devModel, DevInfo devInfo, int?parentID)
    {
        ObjectModel_DoorAccess access = devModel.GetComponent <ObjectModel_DoorAccess>();
        DepNode node = RoomFactory.Instance.GetDepNodeById((int)parentID);

        devModel.transform.parent = GetDevContainer(node).transform;
        DoorAccessDevController controller = devModel.AddMissingComponent <DoorAccessDevController>();

        controller.DevId = devInfo.DevID;
        if (RoomFactory.Instance)
        {
            RoomFactory.Instance.SaveDepDevInfo(node, controller, devInfo);
        }
        if (access)
        {
            controller.DoorItem = access.DoorItem;
            access.DoorItem.AddDoorAccess(controller);
        }
        devModel.RemoveComponent <ObjectModel_DoorAccess>();
        return(controller);
    }
Beispiel #12
0
        /// <summary>
        /// 获取设备所在的机房
        /// </summary>
        /// <param name="rooms"></param>
        /// <param name="dev"></param>
        /// <returns></returns>
        public static Area GetDevRoom(List <Area> rooms, DevInfo dev)
        {
            var inRooms = rooms.FindAll(j => j.InitBound != null && j.InitBound.Contains(dev.PosX, dev.PosZ));

            if (inRooms.Count > 0)
            {
                if (inRooms.Count == 1)
                {
                    return(inRooms[0]);
                }
                else
                {
                    Log.Warn("设备有多个机房:" + dev.Name);
                    return(inRooms[0]);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #13
0
 /// <summary>
 /// 设备信息
 /// </summary>
 /// <param name="dataRow"></param>
 /// <param name="devInfo"></param>
 private void LoadDevInfo(DataRow dataRow, DevInfo devInfo)
 {
     devInfo.ID                    = Convert.ToInt32(dataRow["ID"]);
     devInfo.Install_Man           = dataRow["Install_Man"].ToString();
     devInfo.Install_Time          = Convert.ToDateTime(dataRow["Install_Time"]);
     devInfo.Install_Address       = dataRow["Install_Address"].ToString();
     devInfo.Dev_Type              = dataRow["Dev_Type"].ToString();
     devInfo.Dev_Factory           = dataRow["Dev_Factory"].ToString();
     devInfo.Dev_Brand             = dataRow["Dev_Brand"].ToString();
     devInfo.Dev_Model             = dataRow["Dev_Model"].ToString();
     devInfo.Dev_Price             = dataRow["Dev_Price"].ToString();
     devInfo.Dev_Number            = dataRow["Dev_Number"].ToString();
     devInfo.Dev_Imei              = dataRow["Dev_Imei"].ToString();
     devInfo.Dev_Ccid              = dataRow["Dev_Ccid"].ToString();
     devInfo.Dev_NB_Number         = dataRow["Dev_NB_Number"].ToString();
     devInfo.Dev_NB_ExpirationDate = dataRow["Dev_NB_ExpirationDate"].ToString();
     devInfo.Dev_Ex1               = dataRow["Dev_Ex1"].ToString();
     devInfo.Dev_Ex2               = dataRow["Dev_Ex2"].ToString();
     devInfo.Dev_Ex3               = dataRow["Dev_Ex3"].ToString();
     devInfo.Remarks               = dataRow["Remarks"].ToString();
 }
Beispiel #14
0
        /// <summary>
        /// 获取静态设备相关的测点数据
        /// </summary>
        public static void GetAllStaticDevsMonitorData()
        {
            WebApiHelper.IsSaveJsonToFile = true;
            Bll             bll     = Bll.Instance();
            LocationService service = new LocationService();

            var      staticDevs = bll.DevInfos.Where(i => i.Local_TypeCode == 20181008); //镜头设备
            DateTime start      = DateTime.Now;

            for (int i = 0; i < staticDevs.Count; i++)
            {
                DevInfo dev = staticDevs[i];
                Log.Info(LogTags.KKS, string.Format("获取数据:{0}[{1}],({2}/{3})", dev.Name, dev.KKS, i, staticDevs.Count));
                var monitor = service.GetDevMonitorInfoByKKS(dev.KKS, true); //获取数据,这里需要优化
            }

            TimeSpan time = DateTime.Now - start;

            Log.Info(LogTags.KKS, string.Format("完成 用时:{0}", time));
            WebApiHelper.IsSaveJsonToFile = false;
        }
        public DevInfoTrans GetDevInfo(int?id)
        {
            DevInfoTrans send = new DevInfoTrans();

            send.total = 1;
            send.msg   = "ok";

            if (id != null)
            {
                //DevInfo devinfo = bll.DevInfos.DbSet.Where(p=>p.Id == id).ToList()[0];//ToList结果为0个时会出异常,改为下面语句
                //DevInfo devinfo = bll.DevInfos.DbSet.Where(p => p.Id == id).FirstOrDefault();//等效于下面语句
                DevInfo devinfo = bll.DevInfos.DbSet.FirstOrDefault(p => p.Id == id);
                if (devinfo != null)
                {
                    List <DevInfo> devinfoList = new List <DevInfo>();
                    devinfoList.Add(devinfo);
                    send.data = devinfoList;
                }
            }

            return(send);
        }
Beispiel #16
0
        /// <summary>
        /// 解析登录包
        /// </summary>
        /// <param name="data"></param>
        /// <param name="info"></param>
        /// <returns>登录是否成功</returns>
        private bool ParseLoginPkg(RecvPkg pkg, out DevInfo info)
        {
            info                = new DevInfo();
            info.ConnId         = pkg.connId;
            info.IsOnline       = true;
            info.ConnTime       = DateTime.Now;
            info.LastActiveTime = DateTime.Now;

            int i;

            for (i = 0; i < pkg.data.Length; i++)
            {
                if (pkg.data[i] == '#')
                {
                    break;
                }
            }
            if (pkg.data.First() == '*' && pkg.data.Last() == '*' && i > 0)
            {
                string s = Encoding.Default.GetString(pkg.data);
                try
                {
                    info.ProdName = s.Substring(1, i - 1);
                    info.DevId    = Convert.ToUInt32(s.Substring(i + 1, s.Length - i - 2));
                    return(true);
                }
                catch (Exception)
                {
                    info = null;
                    return(false);
                }
            }
            else
            {
                info = null;
                return(false);
            }
        }
    /// <summary>
    /// 设置信息
    /// </summary>
    /// <param name="devInfo"></param>
    public void SetInfo(DevNode devNode)
    {
        InitMethod();
        this.devNode = devNode;

        if (devNode == null)
        {
            Log.Error("DeviceFollowUI.SetInfo", "devNode == null");
            return;
        }

        DevInfo devInfo = devNode.Info;

        if (devInfo == null)
        {
            Log.Error("DeviceFollowUI.SetInfo", "devInfo == null");
            return;
        }
        TitleText.text = devInfo.Name;
        string info = "";

        if (devInfo.ParentId != null && RoomFactory.Instance)
        {
            DepNode node = RoomFactory.Instance.GetDepNodeById((int)devInfo.ParentId);
            //if (node != null) info = node.NodeName+ "/";
            if (node != null)
            {
                info = node.NodeName;
            }
        }
        //info += devInfo.KKSCode;
        if (string.IsNullOrEmpty(info))
        {
            info = "四会热电厂";
        }
        InfoText.text = info;
        TemperatureInfo.Init();
    }
Beispiel #18
0
        public void GetAndStoreProductInfo(List <string> filterToGetChilds, List <string> filterToGetParents)
        {
            List <Task> tasks = new List <Task>();
            string      reqUri, nextUri;
            string      filterToGetChild, filterToGetParent;
            JObject     result;

            filterToGetChild  = String.Join(" or ", filterToGetChilds.ToArray());
            filterToGetParent = String.Join(" or ", filterToGetParents.ToArray());
            filterToGetChilds.Clear();
            filterToGetParents.Clear();

            // Get Parents
            tasks.Add(Task.Run(() =>
            {
                reqUri = $"https://api.channeladvisor.com/v1/Products?access_token={DevInfo.GetAccessToken()}&$filter={filterToGetParent}&$expand=Attributes,Labels,DCQuantities";
                result = _channelAdvisor.RetrieveProductsFromAPI(reqUri);
                _product.AddProducts((JArray)result["value"]);
            }));

            // Get Childs
            tasks.Add(Task.Run(() =>
            {
                reqUri = $"https://api.channeladvisor.com/v1/Products?access_token={DevInfo.GetAccessToken()}&$filter=({filterToGetChild}) and TotalAvailableQuantity gt 0&$expand=Attributes,Labels,DCQuantities";
                result = _channelAdvisor.RetrieveProductsFromAPI(reqUri);
                _product.AddProducts((JArray)result["value"]);
                nextUri = (string)result["@odata.nextLink"];

                while (nextUri != null)
                {
                    result = _channelAdvisor.RetrieveProductsFromAPI(nextUri);
                    _product.AddProducts((JArray)result["value"]);
                    nextUri = (string)result["@odata.nextLink"];
                }
            }));

            Task.WaitAll(tasks.ToArray());
        }
Beispiel #19
0
    /// <summary>
    /// 生成设备信息
    /// </summary>
    /// <returns></returns>
    private DevInfo GetDevInfo(int?parentId)
    {
        DevInfo dev = new DevInfo();

        dev.DevID      = Guid.NewGuid().ToString();
        dev.IP         = "";
        dev.CreateTime = DateTime.Now;
        dev.ModifyTime = DateTime.Now;
        dev.Name       = ModelName;
        dev.ModelName  = ModelName;
        dev.Status     = 0;
        dev.ParentId   = parentId;
        try
        {
            dev.TypeCode = int.Parse(TypeCode);
        }
        catch (Exception e)
        {
            dev.TypeCode = 0;
        }
        dev.UserName = "******";
        return(dev);
    }
        /// <summary>
        ///  Create Unmatched IUS Classification Sheet
        /// </summary>
        /// <param name="excelFile"></param>
        internal override void GenerateSheet(ref DevInfo.Lib.DI_LibBAL.UI.Presentations.DIExcelWrapper.DIExcel excelFile)
        {
            int sheetNo = this.CreateSheet(ref excelFile, DILanguage.GetLanguageString("CLASSIFICATION_MISSING_IUS"));
            DataTable Table = null;

            // -- sheet content
            excelFile.SetCellValue(sheetNo, Constants.HeaderRowIndex, Constants.HeaderColIndex, DILanguage.GetLanguageString("CLASSIFICATION_MISSING_IUS"));
            excelFile.GetCellFont(sheetNo, Constants.HeaderRowIndex, Constants.HeaderColIndex).Size = Constants.SheetsLayout.HeaderFontSize;

            // -- Get UnmatchedIUSIC Data TAble.
            Table = this.GetUnmatchedIUSClassesTable();
            excelFile.LoadDataTableIntoSheet(Constants.Sheet.ICMissingIUS.UnmatchedIUSICDetailsRowIndex, Constants.HeaderColIndex, Table, sheetNo, false);

            int LastRow = Constants.Sheet.ICMissingIUS.UnmatchedIUSICDetailsRowIndex + Table.Rows.Count;

            // -- Apply Font Settings
            this.ApplyFontSettings(ref excelFile, sheetNo, Constants.Sheet.ICMissingIUS.UnmatchedIUSICDetailsRowIndex, Constants.HeaderColIndex, LastRow, Constants.Sheet.ICMissingIUS.UnmatchedIUSICLastColIndex, true);

            // -- Set Column Width
            excelFile.SetColumnWidth(sheetNo, Constants.SheetsLayout.HeaderNameColWidth, Constants.Sheet.ICMissingIUS.UnmatchedIUSICColIndex, Constants.Sheet.ICMissingIUS.UnmatchedIUSICColIndex, LastRow, Constants.Sheet.ICMissingIUS.UnmatchedIUSICColIndex);
            // -- Wrap Text of Indicator Column
            excelFile.WrapText(sheetNo, Constants.HeaderRowIndex, Constants.Sheet.ICMissingIUS.UnmatchedIUSICColIndex, LastRow, Constants.Sheet.ICMissingIUS.UnmatchedIUSICColIndex, true);
        }
Beispiel #21
0
    /// <summary>
    /// 添加设备控制脚本
    /// </summary>
    /// <param name="devInfo"></param>
    /// <param name="modelTemp"></param>
    /// <returns></returns>
    private DevNode DevControllerAdd(DevInfo devInfo, GameObject modelTemp, DepNode parentNode)
    {
        string typeCode = devInfo.TypeCode.ToString();

        if (TypeCodeHelper.IsBorderAlarmDev(typeCode))
        {
            BorderDevController borderDev = modelTemp.AddMissingComponent <BorderDevController>();
            InitDevInfo(borderDev, devInfo, parentNode);
            return(borderDev);
        }
        else if (TypeCodeHelper.IsCamera(typeCode))
        {
            CameraDevController cameraDev = modelTemp.AddMissingComponent <CameraDevController>();
            InitDevInfo(cameraDev, devInfo, parentNode);
            return(cameraDev);
        }
        else
        {
            DepDevController controller = modelTemp.AddComponent <DepDevController>();
            InitDevInfo(controller, devInfo, parentNode);
            return(controller);
        }
    }
Beispiel #22
0
        public static void SetDevice(device item, DevInfo devinfo)
        {
            item.id   = devinfo.Abutment_Id ?? 0;
            item.code = devinfo.Code;
            item.type = (int)devinfo.Abutment_Type;
            if (item.type == 0)
            {
                item.type = GetDeviceType(devinfo);
            }
            item.state         = (int)devinfo.Status;
            item.running_state = (int)devinfo.RunStatus;
            item.placed        = devinfo.Placed;
            item.raw_id        = devinfo.Abutment_DevID;
            item.ip            = devinfo.IP;
            //devinfo.Manufactor = "霍尼韦尔";

            //devinfo.ModifyTime = DateTime.Now;
            //devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

            //devinfo.ParentId = area.Id;
            item.kks  = devinfo.KKS;
            item.name = devinfo.Name;
            item.pid  = devinfo.ParentId ?? 0;

            if (devinfo.DevDetail is Dev_CameraInfo)
            {
                Dev_CameraInfo camera = devinfo.DevDetail as Dev_CameraInfo;
                item.uri = camera.RtspUrl;

                if (string.IsNullOrEmpty(item.uri))
                {
                    item.uri = "rtsp://*****:*****@192.168.1.56/h264/ch1/main/av_stream";
                }

                item.ip = camera.Ip;
            }
        }
Beispiel #23
0
        /// <summary>
        /// Get devices from database.
        /// </summary>
        /// <param name="lscId">lscId</param>
        /// <param name="devId">devId</param>
        /// <returns>devices list</returns>
        public List <DevInfo> GetDevices(Int32 lscId, Int32 devId)
        {
            SqlParameter[] parms = { new SqlParameter("@LscID", SqlDbType.Int),
                                     new SqlParameter("@DevID", SqlDbType.Int) };
            parms[0].Value = lscId;
            parms[1].Value = ComUtility.DBNullInt32Checker(devId);

            var devices = new List <DevInfo>();

            using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_COMMON_GETDEVICES, parms)) {
                while (rdr.Read())
                {
                    var dev = new DevInfo();
                    dev.LscID   = ComUtility.DBNullInt32Handler(rdr["LscID"]);
                    dev.DevID   = ComUtility.DBNullInt32Handler(rdr["DevID"]);
                    dev.DevName = ComUtility.DBNullStringHandler(rdr["DevName"]);
                    dev.DevDesc = ComUtility.DBNullStringHandler(rdr["DevDesc"]);
                    dev.StaID   = ComUtility.DBNullInt32Handler(rdr["StaID"]);
                    devices.Add(dev);
                }
            }

            return(devices);
        }
        public static bool DevSetDevCnt(string ip, int devflag)
        {
            bool flag = false;

            if (!dicIPDevInfo.ContainsKey(ip))
            {
                return(flag);
            }
            if (devflag == 1)
            {
                DevInfo local1 = dicIPDevInfo[ip];
                local1.devCnt++;
                flag = true;
            }
            if ((devflag != 2) || (dicIPDevInfo[ip].devCnt <= 1))
            {
                return(flag);
            }
            DevInfo local2 = dicIPDevInfo[ip];

            local2.devCnt--;
            if (dicIPDevInfo[ip].conCnt > 1)
            {
                if (dicIPDevInfo[ip].conDecreaseCnt <= 0)
                {
                    DevInfo local3 = dicIPDevInfo[ip];
                    local3.conCnt--;
                }
                else
                {
                    DevInfo local4 = dicIPDevInfo[ip];
                    local4.conDecreaseCnt--;
                }
            }
            return(true);
        }
    /// <summary>
    /// 生成设备信息
    /// </summary>
    /// <returns></returns>
    private DevInfo GetDevInfo()
    {
        DevInfo dev = new DevInfo();

        dev.DevID      = Guid.NewGuid().ToString();
        dev.IP         = "";
        dev.KKSCode    = "";
        dev.CreateTime = DateTime.Now;
        dev.ModifyTime = DateTime.Now;
        dev.Name       = ModelName;
        dev.ModelName  = ModelName;
        dev.Status     = 0;
        dev.ParentId   = GetPID(model);
        try
        {
            dev.TypeCode = TypeCodeHelper.IsDoorAccess(ModelName)?TypeCodeHelper.DoorAccessTypecode:int.Parse(TypeCode);
        }
        catch (Exception e)
        {
            dev.TypeCode = 0;
        }
        dev.UserName = "******";
        return(dev);
    }
        /// <summary>
        /// 获取DevInfo(没有ParentId)  (电子设备间|集控楼0m层  外部批量转ParentId)
        /// </summary>
        /// <returns></returns>
        public DevInfo GetDevInfoWithoutParentId()
        {
            DevInfo devInfo = new DevInfo();

            devInfo.Local_DevID    = DevId;
            devInfo.Local_TypeCode = TryParseInt(TypeCode);
            devInfo.Name           = Name;

            devInfo.ModelName = ModelName;
            devInfo.KKS       = KKSCode;

            devInfo.PosX = TryParseFloat(XPos);
            devInfo.PosY = TryParseFloat(YPos);
            devInfo.PosZ = TryParseFloat(ZPos);

            devInfo.RotationX = TryParseFloat(RotationX);
            devInfo.RotationY = TryParseFloat(RotationY);
            devInfo.RotationZ = TryParseFloat(RotationZ);

            devInfo.ScaleX = TryParseFloat(ScaleX);
            devInfo.ScaleY = TryParseFloat(ScaleY);
            devInfo.ScaleZ = TryParseFloat(ScaleZ);
            return(devInfo);
        }
Beispiel #27
0
        /// <summary>
        /// 获取设备信息
        /// </summary>
        /// <param name="locationDev"></param>
        /// <param name="areaId"></param>
        /// <returns></returns>
        private static DevInfo GetDevInfo(LocationDevice locationDev, int?areaId)
        {
            DevInfo dev = new DevInfo();

            dev.DevID      = Guid.NewGuid().ToString();
            dev.IP         = "";
            dev.KKSCode    = "";
            dev.CreateTime = DateTime.Now;
            dev.ModifyTime = DateTime.Now;
            dev.Name       = locationDev.Name;
            dev.ModelName  = LocationDevModelName;
            dev.Status     = 0;
            dev.ParentId   = areaId;
            try
            {
                dev.TypeCode = int.Parse(LocationDevTypeCode);
            }
            catch (Exception e)
            {
                dev.TypeCode = 0;
            }
            dev.UserName = "******";
            return(dev);
        }
 /// <summary>
 /// 设置门禁的DevInfo
 /// </summary>
 /// <param name="dev"></param>
 public void SetDev(DevInfo dev)
 {
     Dev = dev;
 }
Beispiel #29
0
        public void Run()
        {
            using (var db = new MyDbContext())
            {
                var list = db.Clients.Where(x => x.status == 0).ToList();
                if (list.Count == 0)
                {
                    return;
                }

                string ComPort = config.GetSection("AppSettings:ComPort").Value;
                var    modem   = new GsmModem.GsmModem(ComPort);

                try
                {
                    modem.ReceiveTimeount = 1000;
                    var isOpen = modem.Connect();
                    if (isOpen == false)
                    {
                        return;
                    }
                    var sig = modem.SignalStrength;
                    logger.LogInformation($"Signal ==> {sig}");

                    if (sig == -1)
                    {
                        logger.LogError($"No signal");
                        return;
                    }


                    if (devInfo == null)
                    {
                        devInfo = new DevInfo()
                        {
                            SignalStrength = modem.SignalStrength,
                            Comands        = modem.SupportedCommands.ToList()
                        };
                    }

                    foreach (var it in list)
                    {
                        var res = modem.SendSms(it.phone_num, it.text);

                        if (!res)
                        {
                            logger.LogInformation($"Sended => {it.phone_num}");
                            it.status = 1;
                            it.sended = DateTime.Now;
                        }

                        db.SaveChanges();
                    }
                }
                catch (Exception ee)
                {
                    logger.LogError(ee.Message);
                    logger.LogError(ee.InnerException?.Message);
                    logger.LogError(ee.StackTrace);
                }
                finally
                {
                    modem?.Close();
                }
            }
        }
Beispiel #30
0
        private void procEnvironmentInfo(String str)
        {
            String[] tmpStrArr;
            Action   act;

            if (str.Contains("*************************************************************************"))
            {
                if (platInfoStart == false)
                {
                    platInfoStart = true;
                    platInfo      = new PlatInfo();

                    allDevInfo = new List <DevInfo>();
                    allDevInfo.Clear();
                }
                else
                {
                    platInfoStart = false;

                    act = new Action(() =>
                    {
                        tbxPlatName.Text = platInfo.platName;
                        tbxPlatVen.Text  = platInfo.platVen;
                        tbxPlatVer.Text  = platInfo.platVer;
                    });
                    this.Dispatcher.Invoke(act);
                }
            }

            if (platInfoStart)
            {
                if (str.Contains("Platform Name"))
                {
                    tmpStrArr         = str.Split(new char[] { ':', '=' });
                    platInfo.platName = tmpStrArr.Last().Trim();
                }
                if (str.Contains("Version"))
                {
                    tmpStrArr        = str.Split(new char[] { ':', '=' });
                    platInfo.platVer = tmpStrArr.Last().Trim();
                }
                if (str.Contains("Vendor Name"))
                {
                    tmpStrArr        = str.Split(new char[] { ':', '=' });
                    platInfo.platVen = tmpStrArr.Last().Trim();
                }
            }

            if (str.Contains("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"))
            {
                if (devInfoStart == false)
                {
                    devInfoStart = true;
                    devInfoTmp   = new DevInfo();
                    devCnt++;
                }
                else
                {
                    devInfoStart = false;
                    allDevInfo.Add(devInfoTmp);
                    act = new Action(() =>
                    {
                        lbxDevList.Items.Add("device: " + devCnt.ToString());
                        lbxDevList.SelectedIndex = 0;

                        tbxDevName.Text = allDevInfo[0].devName;
                        tbxDevVen.Text  = allDevInfo[0].devVen;
                        tbxDevVer.Text  = allDevInfo[0].rtVer;
                        tbxDevCU.Text   = allDevInfo[0].cuNum;
                        tbxDevFreq.Text = allDevInfo[0].freq;
                        tbxDevPerf.Text = allDevInfo[0].perf;
                    });
                    this.Dispatcher.Invoke(act);
                }
            }

            if (devInfoStart)
            {
                if (str.Contains("Vendor Name"))
                {
                    tmpStrArr         = str.Split(new char[] { ':', '=' });
                    devInfoTmp.devVen = tmpStrArr.Last().Trim();
                }
                if (str.Contains("Device Name"))
                {
                    tmpStrArr          = str.Split(new char[] { ':', '=' });
                    devInfoTmp.devName = tmpStrArr.Last().Trim();
                }
                if (str.Contains("Runtime Version"))
                {
                    tmpStrArr        = str.Split(new char[] { ':', '=' });
                    devInfoTmp.rtVer = tmpStrArr.Last().Trim();
                }
                if (str.Contains("CU Number"))
                {
                    tmpStrArr        = str.Split(new char[] { ':', '=' });
                    devInfoTmp.cuNum = tmpStrArr.Last().Trim();
                }
                if (str.Contains("Core Frequency"))
                {
                    tmpStrArr       = str.Split(new char[] { ':', '=' });
                    devInfoTmp.freq = tmpStrArr.Last().Trim();
                }
                if (str.Contains("Performance(fp32)"))
                {
                    tmpStrArr       = str.Split(new char[] { ':', '=' });
                    devInfoTmp.perf = tmpStrArr.Last().Trim();
                }
            }
        }
Beispiel #31
0
        /// <summary>Handles a message.</summary>
        public void HandleMessage(IMessage message)
        {
            try
            {
                Init();

                int count1 = bll.DevInfos.GetCount();

                string msg  = Encoding.UTF8.GetString(message.Body);
                events recv = JsonConvert.DeserializeObject <events>(msg);

                if (recv == null)
                {
                    return;
                }

                int nsrc = recv.src;

                DevInfo di = null;

                if (nsrc == 1 || nsrc == 2)
                {
                    if (recv.raw_id == null || recv.raw_id == "")
                    {
                        return;
                    }
                    di = DevList.Find(p => p.Abutment_DevID == recv.raw_id);
                }
                else if (nsrc == 3)
                {
                    if (recv.node == null || recv.node == "")
                    {
                        return;
                    }

                    di = DevList.Find(p => p.Code == recv.node);
                }

                long lTimeStamp = recv.t * 1000;
                bool bFlag      = false;
                int  nLevel     = (int)recv.level;
                Abutment_DevAlarmLevel adLevel = (Abutment_DevAlarmLevel)nLevel;
                if (nLevel == 0)
                {
                    adLevel = Abutment_DevAlarmLevel.未定;
                }
                if (di == null)
                {
                    //DevAlarm da2 = new DevAlarm();
                    //da2.Abutment_Id = recv.id;
                    //da2.Title = recv.title;
                    //da2.Msg = recv.msg;
                    //da2.Level = adLevel;
                    //da2.Code = recv.code;
                    //da2.Src = (Abutment_DevAlarmSrc)recv.src;
                    //da2.DevInfoId = 0;//未找到设备
                    //da2.Device_desc = recv.deviceDesc;
                    //da2.AlarmTime = TimeConvert.ToDateTime(lTimeStamp);
                    //da2.AlarmTimeStamp = lTimeStamp;
                    //bll.DevAlarms.Add(da2);//未找到设备的告警也记录下来,
                    //Log. bv

                    //LogEvent.Info("RealAlarm", string.Format("没找到设备信息,json:{0}", msg));
                    //LogEvent.Info("RealAlarm", string.Format("没找到设备信息:{0}", recv.title));
                    SaveMessageToFile(msg, "noDev");
                    return;//没找到设备信息,则不做任何处理,
                }



                if (recv.title.Contains("防拆") || recv.msg.Contains("防拆"))
                {
                    SaveMessageToFile(msg, "filter");
                    return;//过滤掉有“防拆”字段的告警,没有意义。
                }

                LogEvent.Info("RealAlarm", string.Format("获取设备:{0}", recv.title));
                SaveMessageToFile(msg, "");

                DevAlarm da = DaList.Find(p => p.DevInfoId == di.Id && p.AlarmTimeStamp == lTimeStamp);
                if (da == null)
                {
                    if (recv.state == 0)
                    {
                        da = CreateDevAlarm(recv, di, lTimeStamp, adLevel);

                        bll.DevAlarms.Add(da);
                        DaList.Add(da);
                        bFlag = true;
                    }
                }
                else
                {
                    if (recv.state == 1 || recv.state == 2)
                    {
                        DevAlarmHistory da_history = da.RemoveToHistory();
                        DaList.Remove(da);
                        bll.DevAlarms.DeleteById(da.Id);
                        bll.DevAlarmHistorys.Add(da_history);//告警恢复 放到历史数据中
                        da.Level = Abutment_DevAlarmLevel.无;
                        bFlag    = true;
                    }
                    else if (adLevel != da.Level)
                    {
                        da.Level = adLevel;
                        da.Title = recv.title;
                        da.Msg   = recv.msg;
                        bll.DevAlarms.Edit(da);
                        bFlag = true;
                    }
                }

                if (bFlag)
                {
                    OnDevAlarmReceived(da);
                }
                int count2 = bll.DevInfos.GetCount();
                if (count2 > count1)
                {
                    Log.Info(LogTags.RealAlarm, "添加了数据:" + count1 + "->" + count2);
                }
                return;
            }
            catch (Exception ex)
            {
                Log.Info(LogTags.RealAlarm, "HandleMessage:" + ex);
            }
        }
Beispiel #32
0
 /// <summary>
 /// 获取设备所在的机房
 /// </summary>
 /// <param name="rooms"></param>
 /// <param name="dev"></param>
 /// <returns></returns>
 public static Area GetDevRoom(List <Area> rooms, DevInfo dev)
 {
     return(GetRoomByPos(rooms, dev.PosX, dev.PosZ));
 }
Beispiel #33
0
        public static void CopyDevData()
        {
            try
            {
                KQInfo DAccess = new KQInfo(Common.GetDataConnection(DataCollection.Config.FRASConnectionString, SND.DA.DataAccessHelper.DataSourceType.SqlClient));
                object lockObj = new object();
                // 获取设备信息
                System.Data.DataTable dt = DAccess.GetDevInfo();
                if (dt != null)
                {
                    foreach (System.Data.DataRow row in dt.Rows)
                    {
                        if (!DataCollection.DevInfos.ContainsKey(row["AntNo"].ToString()))
                        {
                            DevInfo devinfo = new DevInfo();
                            devinfo.AntNo = row["AntNo"] is DBNull ? "0" : row["AntNo"].ToString().Trim();
                            devinfo.DevIp = row["devIp"].ToString().Trim();
                            devinfo.DevPort = row["devPort"].ToString().Trim();
                            devinfo.DevType = row["devType"].ToString().Trim();
                            devinfo.DevUserName = row["devUserName"].ToString().Trim();
                            devinfo.DevPassWord = row["devPassWord"].ToString().Trim();
                            devinfo.AccessFlag = row["accessFlag"] is DBNull ? "0" : row["accessFlag"].ToString().Trim();
                            devinfo.Flag = row["flag"] is DBNull ? "0" : row["flag"].ToString().Trim();
                            lock (lockObj)
                            {
                                if (!DataCollection.DevInfos.ContainsKey(row["AntNo"].ToString()))
                                {
                                    DataCollection.DevInfos.Add(devinfo.AntNo, devinfo);
                                }

                            }
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.LogSys("==CopyDevData==" + ex.Message);
            }
        }
        public OperationResult <DeviceCV> GetDeviceCV(string api_account, long timeStamp, string sign, string deviceID, string localDate)
        {
            if (!checkSignForGetDeviceCV(api_account, timeStamp, sign, deviceID, localDate))
            {
                var result4 = new OperationResult <DeviceCV>(OperationCode.Error_Sign);
                result4.Entity = null;

                return(result4);
            }


            if (!_parameterValidateService.CheckTimestamp(timeStamp))
            {
                var result2 = new OperationResult <DeviceCV>(OperationCode.Error_TimeStamp);
                result2.Entity = null;

                return(result2);
            }

            Guid theCompanyId;

            if (!_parameterValidateService.ApiAccountExist(api_account, out theCompanyId))
            {
                var result3 = new OperationResult <DeviceCV>(OperationCode.Error_ApiAccountNotExist);
                result3.Entity = null;

                return(result3);
            }

            DeviceCV cv     = new DeviceCV();
            DevInfo  info   = _devInfoRepository.FindBy(x => x.DeviceID == deviceID).Where(x => x.Delete_Flag == 0).FirstOrDefault();
            var      result = new OperationResult <DeviceCV>(OperationCode.Success);

            if (info == null)
            {
                result     = new OperationResult <DeviceCV>(OperationCode.Success);
                cv.Status  = "Failed1";
                cv.Time    = null;
                cv.CVTotal = null;
                cv.CV1     = null;
                cv.CV2     = null;
                cv.CV3     = null;

                result.Entity = cv;

                return(result);
            }

            var dataLst = _devDataRepository.GetDeviceCVByDeviceID(deviceID, localDate).ToList();

            if (dataLst == null || dataLst.Count == 0)
            {
                result     = new OperationResult <DeviceCV>(OperationCode.Success);
                cv.Status  = "Failed2";
                cv.Time    = null;
                cv.CVTotal = null;
                cv.CV1     = null;
                cv.CV2     = null;
                cv.CV3     = null;

                result.Entity = cv;

                return(result);
            }

            int num = dataLst.Count;

            string[]  times    = new string[num];
            decimal[] CVTotals = new decimal[num];
            decimal[] CVs1     = new decimal[num];
            decimal[] CVs2     = new decimal[num];
            decimal[] CVs3     = new decimal[num];

            for (int i = 0; i < num; i++)
            {
                times[i]    = dataLst[i].Upload_DateTime.ToString();
                CVTotals[i] = dataLst[i].CV;
                CVs1[i]     = dataLst[i].CV1 == null ? 0 : (decimal)dataLst[i].CV1;
                CVs2[i]     = dataLst[i].CV2 == null ? 0 : (decimal)dataLst[i].CV2;
                CVs3[i]     = dataLst[i].CV3 == null ? 0 : (decimal)dataLst[i].CV3;
            }

            result     = new OperationResult <DeviceCV>(OperationCode.Success);
            cv.Status  = "Success";
            cv.Time    = times;
            cv.CVTotal = CVTotals;
            cv.CV1     = CVs1;
            cv.CV2     = CVs2;
            cv.CV3     = CVs3;

            result.Entity = cv;

            return(result);
        }
        /// <summary>
        /// 获取门禁卡操作历史
        /// </summary>
        /// <param name="id"></param>
        /// <param name="begin_date"></param>
        /// <param name="end_date"></param>
        /// <returns></returns>
        public BaseTran <cards_actions> GetSingleCardActionHistory(int id, string begin_date, string end_date)
        {
            BaseTran <cards_actions> recv = new BaseTran <cards_actions>();

            try
            {
                string path = "api/cards/" + Convert.ToString(id) + "/actions";
                string url  = BaseUri + path;
                if (begin_date != null)
                {
                    url += "?begin_date=" + begin_date;
                }
                else
                {
                    url += "?begin_date";
                }

                if (end_date != null)
                {
                    url += "&end_date=" + end_date;
                }
                else
                {
                    url += "&end_date";
                }

                recv = GetEntityList <cards_actions>(url);

                if (recv.data == null)
                {
                    recv.data = new List <cards_actions>();
                }

                EntranceGuardCard egc = bll.EntranceGuardCards.DbSet.FirstOrDefault(p => p.Abutment_Id == id);

                if (egc != null)
                {
                    foreach (cards_actions item in recv.data)
                    {
                        DevEntranceGuardCardAction degca = bll.DevEntranceGuardCardActions.DbSet.FirstOrDefault(p => p.Abutment_Id == item.id);
                        DevInfo devinfo = bll.DevInfos.DbSet.FirstOrDefault(p => p.Abutment_Id == item.device_id);
                        if (devinfo == null)
                        {
                            continue;
                        }

                        int nFlag = 0;
                        if (degca == null)
                        {
                            degca             = new DevEntranceGuardCardAction();
                            degca.OperateTime = null;
                            nFlag             = 1;
                        }

                        degca.Abutment_Id         = item.id;
                        degca.DevInfoId           = devinfo.Id;
                        degca.EntranceGuardCardId = egc.Id;
                        degca.code             = item.code;
                        degca.description      = item.description;
                        degca.OperateTimeStamp = item.t;
                        degca.nInOutState      = 0;

                        if (item.t != null)
                        {
                            long t = (long)item.t;
                            degca.OperateTime = TimeConvert.TimeStampToDateTime(t);
                        }

                        if (nFlag == 1)
                        {
                            bll.DevEntranceGuardCardActions.Add(degca);
                        }
                        else
                        {
                            bll.DevEntranceGuardCardActions.Edit(degca);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string messgae = ex.Message;
            }

            return(recv);
        }
        /// <summary>
        /// 获取设备列表
        /// </summary>
        /// <param name="types"></param>
        /// <param name="code"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public BaseTran <device> GetDeviceList(string types, string code, string name)
        {
            BaseTran <device> recv = new BaseTran <device>();

            try
            {
                string path = "api/devices";
                string url  = BaseUri + path;

                if (types != null)
                {
                    url += "?types=" + types;
                }
                else
                {
                    url += "?types";
                }

                if (code != null)
                {
                    url += "&code=" + code;
                }
                else
                {
                    url += "&code";
                }

                if (name != null)
                {
                    url += "&name=" + name;
                }
                else
                {
                    url += "&name";
                }

                recv = GetEntityList <device>(url);

                if (recv.data == null)
                {
                    recv.data = new List <device>();
                }

                foreach (device item in recv.data)
                {
                    DevInfo devinfo = bll.DevInfos.DbSet.Where(p => p.KKS == item.kksCode).FirstOrDefault();
                    int     nFlag   = 0;
                    if (devinfo == null)
                    {
                        devinfo = new DevInfo();
                        nFlag   = 1;
                    }

                    devinfo.Abutment_Id    = item.id;
                    devinfo.Code           = item.code;
                    devinfo.KKS            = item.kksCode;
                    devinfo.Name           = item.name;
                    devinfo.Abutment_Type  = (Abutment_DevTypes)item.type;
                    devinfo.Status         = (Abutment_Status)item.state;
                    devinfo.RunStatus      = (Abutment_RunStatus)item.running_state;
                    devinfo.Placed         = item.placed;
                    devinfo.Abutment_DevID = item.raw_id;

                    if (nFlag == 1)
                    {
                        devinfo.CreateTime = DateTime.Now;
                        devinfo.ModifyTime = DateTime.Now;

                        devinfo.CreateTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.CreateTime);
                        devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                        bll.DevInfos.Add(devinfo);
                    }
                    else
                    {
                        devinfo.ModifyTime      = DateTime.Now;
                        devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                        bll.DevInfos.Edit(devinfo);
                    }
                }
            }
            catch (Exception ex)
            {
                string messgae = ex.Message;
            }

            return(recv);
        }