/// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="NetworkModuleRequest"></param>
        /// <returns></returns>
        public BasicResponse AddNetworkModules(NetworkModulesRequest NetworkModuleRequest)
        {
            BasicResponse     Result = new BasicResponse();
            List <Jc_MacInfo> items  = NetworkModuleRequest.NetworkModulesInfo;
            List <Jc_MacInfo> NetworkModuleCaches = new List <Jc_MacInfo>();
            Jc_MacInfo        olditem             = null;

            NetworkModuleCacheGetAllRequest NetworkModuleCacheRequest = new NetworkModuleCacheGetAllRequest();
            var result = _NetworkModuleCacheService.GetAllNetworkModuleCache(NetworkModuleCacheRequest);

            NetworkModuleCaches = result.Data;

            foreach (Jc_MacInfo item in items)
            {
                olditem = NetworkModuleCaches.Find(a => a.MAC == item.MAC);
                //增加重复判断
                if (olditem != null)
                { //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前添加列表中的数据在数据库中已经存在!";
                    return(Result);
                }
            }

            //向网关同步数据
            List <Jc_MacInfo> SendItemList = items;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }

            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_MacInfo item in items)
                {
                    item.IsMemoryData = false;
                    //保存数据库
                    var _jc_Mac = ObjectConverter.Copy <Jc_MacInfo, Jc_MacModel>(item);
                    //保存数据库不存连接号  20170713
                    _jc_Mac.NetID    = 0;
                    var resultjc_Def = _Repository.AddNetworkModule(_jc_Mac);
                }


                //添加到缓存
                NetworkModuleCacheBatchAddRequest BatchAddNetworkModuleCacheRequest = new NetworkModuleCacheBatchAddRequest();
                BatchAddNetworkModuleCacheRequest.NetworkModuleInfos = items;
                _NetworkModuleCacheService.BacthAddNetworkModuleCache(BatchAddNetworkModuleCacheRequest);
            });

            return(Result);
        }
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="NetworkModuleRequest"></param>
        /// <returns></returns>
        public BasicResponse UpdateNetworkModules(NetworkModulesRequest NetworkModuleRequest)
        {
            BasicResponse     Result = new BasicResponse();
            List <Jc_MacInfo> items  = NetworkModuleRequest.NetworkModulesInfo;
            List <Jc_MacInfo> NetworkModuleCaches = new List <Jc_MacInfo>();
            Jc_MacInfo        olditem             = null;

            NetworkModuleCacheGetAllRequest NetworkModuleCacheRequest = new NetworkModuleCacheGetAllRequest();
            var result = _NetworkModuleCacheService.GetAllNetworkModuleCache(NetworkModuleCacheRequest);

            NetworkModuleCaches = result.Data;

            foreach (Jc_MacInfo item in items)
            {
                olditem = NetworkModuleCaches.Find(a => a.MAC == item.MAC);
                //增加重复判断
                if (olditem == null)
                { //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前更新列表中的数据在数据库中不存在!";
                    return(Result);
                }
                else
                {
                    if (olditem.IsMemoryData)//如果内存中存在数据,则重置添加、修改标记  20170415
                    {
                        if (olditem.InfoState == InfoState.AddNew)
                        {
                            if (item.InfoState == InfoState.Modified)
                            {
                                item.InfoState = InfoState.AddNew;
                            }
                        }
                        if (olditem.InfoState == InfoState.Delete)
                        {
                            if (item.InfoState == InfoState.AddNew)
                            {
                                item.InfoState = InfoState.Modified;
                            }
                        }
                        item.IsMemoryData = false;//置完标记后,将内存数据变成非内存数据标记  20170415
                    }
                }
            }
            //向网关同步数据
            List <Jc_MacInfo> SendItemList = items;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }
            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_MacInfo item in items)
                {
                    if (item.InfoState == InfoState.AddNew)
                    {
                        //保存数据库
                        var _jc_Mac = ObjectConverter.Copy <Jc_MacInfo, Jc_MacModel>(item);
                        _Repository.AddNetworkModule(_jc_Mac);
                    }
                    else
                    {
                        //保存数据库
                        var _jc_Mac = ObjectConverter.Copy <Jc_MacInfo, Jc_MacModel>(item);
                        _Repository.UpdateNetworkModule(_jc_Mac);
                    }
                    //更新到缓存
                    UpdateNetworkModuleCacheByProperty(item);
                }
            });

            return(Result);
        }