Beispiel #1
0
        /// <summary>
        ///  添加通道分组 AddResourceGroupByName
        /// </summary>
        /// <param name="resourceGroup">分组中的 分组名与 分组的父节点</param>
        /// <param name="customerToken">用户的唯一Token</param>
        /// <returns>0 表示成功   3 代表服务器异常  5 代表失效</returns>
        public ResponseBaseDto AddResourceGroupByName(ResourceGroup resourceGroup, string customerToken)
        {
            ResponseBaseDto dto  = new ResponseBaseDto();
            OperaterLog     oLog = new OperaterLog();

            oLog.Action = "添加分组";
            //校验token
            UserTokenCache     utc = UserTokenCache.GetInstance();
            TokenCacheProperty tcp = new TokenCacheProperty();
            int customerId         = 0;

            if (utc.IsValid(customerToken) == false)
            {
                dto.Code    = (int)CodeEnum.ServerNoToken;
                dto.Message = "用户token已失效,请重新登录后继续";
            }
            else
            {
                try
                {
                    dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                    if (dto.Code != 0)
                    {
                        oLog.Remarks = dto.Message;
                        oLog.Result  = dto.Code;
                        bllHelper.AddOperaterLog(oLog, tcp);
                        return(dto);
                    }
                    //添加组
                    customerId = tcp.CustomerId;
                    resourceGroup.CustomerId = tcp.CustomerId;
                    int resourceGroupId = (int)resourceGroupServer.InsertResourceGorup(resourceGroup);
                    oLog.TargetId = resourceGroupId;
                    if (resourceGroupId > 0)
                    {
                        dto.Code    = (int)CodeEnum.Success;
                        dto.Message = "添加通道分组已完成";
                    }
                    else
                    {
                        dto.Code    = (int)CodeEnum.ApplicationErr;
                        dto.Message = "分组添加异常";
                    }
                }
                catch (Exception ex)
                {
                    dto.Code    = (int)CodeEnum.ApplicationErr;
                    dto.Message = "网络异常,添加分组失败!";
                    myLog.ErrorFormat("AddResourceGroupByName方法异常,用户Id:{0},添加的分组名:{2}", ex, customerId, resourceGroup.ResourceGroupName);
                }
            }
            oLog.TargetType = (int)OperaterLogEnum.ResourceGroup;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #2
0
        /// <summary>
        ///  修改通道是否启用 EnableChannel
        /// </summary>
        /// <param name="channel">Channel.ChannelId</param>
        /// <param name="customerToken">token</param>
        /// <returns></returns>
        public ResponseBaseDto EnableChannel(Channel channel, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            OperaterLog        oLog = new OperaterLog();
            TokenCacheProperty tcp  = new TokenCacheProperty();

            oLog.Action = "启用或禁用通道";
            try
            {
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "用户token已失效,请重新登录后继续";
                    return(dto);
                }
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    oLog.TargetType = (int)OperaterLogEnum.Channel;
                    oLog.Remarks    = dto.Message;
                    oLog.Result     = dto.Code;
                    bllHelper.AddOperaterLog(oLog, tcp);
                    return(dto);
                }
                else
                {
                    IList <Channel> channelFlag = channelServer.SelectChannelByChannelId(channel);
                    oLog.TargetId = channel.ChannelId;
                    if (channelFlag == null)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = "需要修改的通道不存在";
                    }
                    else
                    {
                        string originalChannelName = channelFlag[0].ChannelName;
                        channelFlag[0].IsEnable = channel.IsEnable;
                        channelServer.UpdateChannel(channelFlag[0]);
                        dto.Code     = 0;
                        dto.Message  = originalChannelName;
                        dto.Message += channel.IsEnable == 1 ? "通道已启用" : "通道已禁用";
                    }
                }/*end if(utc.IsValid(customerToken) == false)*/
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "网络异常,请刷新页面后继续";
                myLog.WarnFormat("EnableChannel方法异常,用户Id:{0},通道Id:{1}", ex, tcp.CustomerId, channel.ChannelId);
            }
            oLog.TargetType = (int)OperaterLogEnum.Channel;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #3
0
        /// <summary>
        ///  记录用户日志
        /// </summary>
        /// <param name="customerToken">token</param>
        /// <param name="oLog">日志 实体</param>
        internal void AddOperaterLog(OperaterLog oLog, TokenCacheProperty tcp)
        {
            try
            {
                //memcache中搜寻 customerToken 进行组织数据
                //UserTokenCache utc = UserTokenCache.GetInstance();
                StringBuilder builder = new StringBuilder();
                if (tcp != null)
                {
                    oLog.CustomerId = tcp.CustomerId;

                    oLog.OperaterTime = DateTime.Now;
                    builder.Append("用户:");
                    builder.Append(tcp.CustomerName);
                    builder.Append(" ");
                    builder.Append(oLog.Action);

                    string AgentType = "";
                    if (tcp.LoginType == (int)LoginTypeEnum.web)
                    {
                        AgentType = "web";
                    }
                    else if (tcp.LoginType == (int)LoginTypeEnum.window)
                    {
                        AgentType = "桌面客户端";
                    }
                    else if (tcp.LoginType == (int)LoginTypeEnum.android)
                    {
                        AgentType = "android";
                    }
                    else if (tcp.LoginType == (int)LoginTypeEnum.ios)
                    {
                        AgentType = "IOS";
                    }
                    else
                    {
                        AgentType = "未知";
                    }
                    builder.Append(AgentType);
                    if (tcp.AgentVersion != null && tcp.AgentVersion != "")
                    {
                        builder.Append(" 版本:" + tcp.AgentVersion + " ");
                    }
                    oLog.AgentType    = AgentType;
                    oLog.AgentVersion = tcp.AgentVersion;
                    builder.Append(oLog.Remarks);
                    oLog.Remarks = builder.ToString();
                    OperaterLogServer.GetInstance().InsertOperaterLog(oLog);
                }
            }
            catch (Exception ex)
            {
                myLog.WarnFormat("AddOperaterLog方法异常,Customer 日志未能写入", ex);
            }
        }
        /// <summary>
        /// 删除1-n个收藏 以NodeId
        /// </summary>
        /// <param name="nodeType"></param>
        /// <param name="nodeIdList"></param>
        /// <param name="customerToken"></param>
        /// <returns></returns>
        public ResponseBaseDto DeleteUserFavorite(int nodeType, int[] nodeIdList, string customerToken)
        {
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            TokenCacheProperty tcp  = new TokenCacheProperty();
            ResponseBaseDto    dto  = new ResponseBaseDto();
            OperaterLog        oLog = new OperaterLog();

            oLog.Action = "用户删除收藏";
            try
            {
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "用户token失效";
                    return(dto);
                }
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    return(dto);
                }
                if (nodeType == 0 || nodeIdList.Length == 0)
                {
                    dto.Code    = (int)CodeEnum.NoComplete;
                    dto.Message = "用户数据提交不完整!";
                    return(dto);
                }
                string nodeidListStr = "";
                for (int i = 0; i < nodeIdList.Length; i++)
                {
                    if (i != nodeIdList.Length - 1)
                    {
                        nodeidListStr += nodeIdList[i] + ",";
                    }
                    else
                    {
                        nodeidListStr += nodeIdList[i];
                    }
                }
                userFavoriteServer.DeleteUserFavorite(tcp.CustomerId, nodeType, nodeidListStr);
                oLog.Remarks    = tcp.CustomerName + "批量删除收藏类型:" + nodeType + " 收藏nodeId:" + nodeidListStr;
                oLog.TargetType = (int)OperaterLogEnum.Favorite;
                dto.Code        = (int)CodeEnum.Success;
                dto.Message     = "已完成批量删除!";
                oLog.Remarks   += dto.Message;
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "网络异常!,删除收藏失败!";
                myLog.ErrorFormat("DeleteUserFavorite方法异常,收藏类型:{0},收藏NodeId集合:{0}", ex, nodeType, nodeIdList.ToString());
            }
            return(dto);
        }
Beispiel #5
0
        /// <summary>
        /// 添加用户日志
        /// </summary>
        /// <param name="operaterLog">日志 实体</param>
        /// <returns>operaterLogId</returns>
        public int InsertOperaterLog(OperaterLog operaterLog)
        {
            int operaterLogId = 0;

            try
            {
                using (var sessionFactory = nhFactory.GetRepositoryFor <OperaterLog>())
                {
                    sessionFactory.Session.BeginTransaction();
                    operaterLogId = (int)sessionFactory.Save(operaterLog);
                    sessionFactory.Session.CommitChanges();
                }
            }
            catch (BPCloudException e)
            {
                throw new BPCloudException("error line 45", e, myLog);
            }
            return(operaterLogId);
        }
Beispiel #6
0
        /// <summary>
        /// 设置通道码流
        /// </summary>
        /// <param name="channelId">通道id</param>
        /// <param name="streamType">码流类型</param>
        /// <param name="customerToken">用户token</param>
        /// <returns></returns>
        public ResponseBaseDto UpdateChannelEncoderInfo(int channelId, int streamType, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            OperaterLog        oLog = new OperaterLog();
            TokenCacheProperty tcp  = new TokenCacheProperty();

            oLog.Action = "设置通道码流";
            try
            {
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "用户token已失效,请重新登录后继续";
                    return(dto);
                }
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    oLog.TargetType = (int)OperaterLogEnum.Channel;
                    oLog.Remarks    = dto.Message;
                    oLog.Result     = dto.Code;
                    bllHelper.AddOperaterLog(oLog, tcp);
                    return(dto);
                }
                else
                {
                    IList <Channel> channelFlag = channelServer.SelectChannelByChannelId(new Channel()
                    {
                        ChannelId = channelId
                    });
                    oLog.TargetId = channelId;
                    if (channelFlag == null)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = "需要修改的通道不存在";
                    }
                    else if (streamType == 0)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = "未选中码流类型";
                    }
                    else
                    {
                        try
                        {
                            //获取已预制的码流配置
                            IDictionary <int, AVEncoderInfoDto> avEncoderInfoList = GetXMLChannelEncoderList();
                            AVEncoderInfoDto enCoderInfo = avEncoderInfoList[streamType];
                            //调用BP4Server 设置码流
                            Bsr.ServiceProxy.Utils.ServiceFactory serviceFactory = new ServiceProxy.Utils.ServiceFactory();
                            var seviceAddr = bllHelper.GetServerModelStr();
                            serviceFactory.GetProxy <ICamera>(new Uri(seviceAddr)).Use(
                                p =>
                            {
                                if (streamType == 1)
                                {
                                    //主码流
                                    p.UpdateEncoderInfo(channelFlag[0].BPServerChannelId, (byte)(1), enCoderInfo);
                                }
                                else if (streamType == 2 || streamType == 3)
                                {
                                    //选择码流类型(streamType)在BP4Server中 2和3都属于子码流
                                    p.UpdateEncoderInfo(channelFlag[0].BPServerChannelId, (byte)(1 << 1), enCoderInfo);
                                }
                                else
                                {
                                    //第3码流
                                    p.UpdateEncoderInfo(channelFlag[0].BPServerChannelId, (byte)(1 << 2), enCoderInfo);
                                }
                            });
                        }
                        catch (Exception ex)
                        {
                            dto.Code    = (int)CodeEnum.ApplicationErr;
                            dto.Message = "通道所属设备已离线!离线状态无法修改通道码流";
                            myLog.ErrorFormat("UpdateChannelEncoderInfo(BP4Server设备已离线)通道Id:{0}", ex, channelId);
                            return(dto);
                        }
                    }
                }/*end if(utc.IsValid(customerToken) == false)*/
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "网络异常,请刷新页面后继续";
                myLog.WarnFormat("UpdateChannelEncoderInfo方法异常,用户Id:{0},通道Id:{1}", ex, tcp.CustomerId, channelId);
            }
            oLog.TargetType = (int)OperaterLogEnum.Channel;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #7
0
        /// <summary>
        ///  修改通道名
        /// </summary>
        /// <param name="channel">Channel.ChannelId</param>
        /// <param name="customerToken">token</param>
        /// <returns></returns>
        public ResponseBaseDto UpdateChannelByChannelId(Channel channel, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            OperaterLog        oLog = new OperaterLog();
            TokenCacheProperty tcp  = new TokenCacheProperty();

            oLog.Action = "修改通道名";
            try
            {
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "用户token已失效,请重新登录后继续";
                    return(dto);
                }
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    oLog.TargetType = (int)OperaterLogEnum.Channel;
                    oLog.Remarks    = dto.Message;
                    oLog.Result     = dto.Code;
                    bllHelper.AddOperaterLog(oLog, tcp);
                    return(dto);
                }
                if (tcp.SignInType == (int)CustomerSignInTypeEnum.SubCustomer)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "子用户状态无法修改通道名!";
                    return(dto);
                }
                else
                {
                    IList <Channel> channelFlag = channelServer.SelectChannelByChannelId(channel);
                    oLog.TargetId = channel.ChannelId;
                    if (channelFlag == null)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = "需要修改的通道不存在!";
                    }
                    else
                    {
                        try
                        {
                            Bsr.ServiceProxy.Utils.ServiceFactory serviceFactory = new ServiceProxy.Utils.ServiceFactory();
                            var seviceAddr = bllHelper.GetServerModelStr();
                            serviceFactory.GetProxy <ICamera>(new Uri(seviceAddr)).Use(
                                p =>
                            {
                                p.UpdateName(channelFlag[0].BPServerChannelId, channel.ChannelName);
                            }
                                );
                        }
                        catch (Exception ex)
                        {
                            dto.Code    = (int)CodeEnum.ApplicationErr;
                            dto.Message = "修改失败,连接服务器超时!";
                            myLog.ErrorFormat("UpdateChannelByChannelId(Adapter服务器端没有做出响应)通道Id:{0},待修改的通道名:{1}", ex, channel.ChannelId, channel.ChannelName);
                            return(dto);
                        }
                        string originalChannelName = channelFlag[0].ChannelName;
                        channelFlag[0].ChannelName = channel.ChannelName;
                        channelServer.UpdateChannel(channelFlag[0]);
                        dto.Code    = 0;
                        dto.Message = "通道名 " + originalChannelName + "修改为 " + channel.ChannelName + " 已完成!";
                    }
                }/*end if(utc.IsValid(customerToken) == false)*/
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "无法连接服务器,请保证您的网络通畅!";
                myLog.ErrorFormat("UpdateChannelByChannelId方法异常,通道Id:{0},待修改的通道名:{1}", ex, channel.ChannelId, channel.ChannelName);
            }
            oLog.TargetType = (int)OperaterLogEnum.Channel;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #8
0
        /// <summary>
        /// 修改通道的默认图片
        /// </summary>
        /// <param name="channelId">通道的id</param>
        /// <param name="imageByte">图片的二进制数据</param>
        /// <param name="extName">图片扩展名</param>
        /// <param name="customerToken">用户的token</param>
        /// <returns></returns>
        public ResponseBaseDto UpdateChanneImagePathlByChannelId(int channelId,
                                                                 byte[] imageByte, string extName, string customerToken, ref string imagePath)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            TokenCacheProperty tcp  = new TokenCacheProperty();
            OperaterLog        oLog = new OperaterLog();

            oLog.Action   = "更新通道图片";
            oLog.TargetId = channelId;
            try
            {
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "用户token已失效,请重新登录后继续";
                    return(dto);
                }
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    oLog.TargetType = (int)OperaterLogEnum.Channel;
                    oLog.Remarks    = dto.Message;
                    oLog.Result     = dto.Code;
                    bllHelper.AddOperaterLog(oLog, tcp);
                    return(dto);
                }
                else
                {
                    //大图(源图)
                    //检查存放源图片的目录是否存在,不存在则创建
                    var bigImagePath = string.Format(@"{0}\channelImage", AppDomain.CurrentDomain.BaseDirectory);
                    Directory.CreateDirectory(bigImagePath);

                    //小图(封面)
                    //检查存放图片的目录是否存在,不存在则创建
                    var smallImagepath = string.Format(@"{0}\channelImage\small", AppDomain.CurrentDomain.BaseDirectory);
                    Directory.CreateDirectory(smallImagepath);

                    //生成随机且唯一的image文件名,将数据保存
                    string imageFile = string.Format("{0}_{1}.{2}",
                                                     PwdMD5.StringToMD5(DateTime.Now.ToString()), channelId, extName);

                    //打开文件,写入图片数据
                    string     bigImageFullPath   = string.Format(@"{0}\{1}", bigImagePath, imageFile);
                    string     smallImageFullPath = string.Format(@"{0}\{1}", smallImagepath, imageFile);
                    FileStream bigfs = new System.IO.FileStream(bigImageFullPath, FileMode.Create, FileAccess.Write);
                    bigfs.Write(imageByte, 0, imageByte.Length);
                    bigfs.Close();

                    #region 将图片进行尺寸的压缩
                    byte[] dstImageByte;
                    ImageConvertibleInfo icInfo = new ImageConvertibleInfo();
                    icInfo.srcByte   = imageByte;
                    icInfo.dstWidth  = 320;     // 目标图片像素宽
                    icInfo.dstHeight = 240;     // 目标图片像素高
                    icInfo.dstFmt    = extName; // 目标图片格式

                    int rs = 0;
                    if ((rs = ImageConvertion.Convert(icInfo, out dstImageByte)) != 0)
                    {
                        myLog.WarnFormat("图片压缩成{0}失败,错误码:{1}", icInfo.dstFmt, rs);
                    }
                    else
                    {
                        imageByte = dstImageByte; // 将压缩后的图片数据重新赋给imageByte
                    }
                    #endregion

                    FileStream smallfs = new System.IO.FileStream(smallImageFullPath, FileMode.Create, FileAccess.Write);
                    smallfs.Write(dstImageByte, 0, imageByte.Length);
                    smallfs.Close();
                    // 通过通道的id找到数据库记录,将文件名更新
                    Channel channel = new Channel()
                    {
                        ChannelId = channelId
                    };
                    IList <Channel> channelFlag = channelServer.SelectChannelByChannelId(channel);

                    if (channelFlag == null)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = "需要修改的通道不存在";
                    }
                    else
                    {
                        // 将原来指向的文件名删除。
                        // 如果是默认的文件名则不做删除。
                        if (channelFlag[0].ImagePath != null && !channelFlag[0].ImagePath.Contains("default"))
                        {
                            File.Delete(bigImagePath + "\\" + channelFlag[0].ImagePath);
                            File.Delete(smallImagepath + "\\" + channelFlag[0].ImagePath);
                        }

                        channelFlag[0].ImagePath = imageFile;
                        channelServer.UpdateChannel(channelFlag[0]);
                        dto.Code    = 0;
                        dto.Message = "修改通道图片完成!";
                        // 返回的图片路径是: "channelImage/图片名.jpg"
                        imagePath = string.Format(@"channelImage/{0}", imageFile);
                    }
                }/*end if(utc.IsValid(customerToken) == false)*/
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "网络异常,请刷新页面后继续";
                myLog.WarnFormat("UpdateChanneImagePathlByChannelId方法异常,通道id:{0}", ex, channelId);
            }
            oLog.TargetType = (int)OperaterLogEnum.Channel;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
        /// <summary>
        /// 添加收藏
        /// </summary>
        /// <param name="userFavorite">收藏实体对象</param>
        /// <param name="customerToken">token</param>
        /// <param name="userFavoriteId">ref 已完成添加的收藏Id</param>
        /// <returns></returns>
        public ResponseBaseDto AddUserFavorite(UserFavorite userFavorite, string customerToken, ref int userFavoriteId)
        {
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            TokenCacheProperty tcp  = new TokenCacheProperty();
            ResponseBaseDto    dto  = new ResponseBaseDto();
            OperaterLog        oLog = new OperaterLog();

            oLog.Action = "用户添加收藏";
            try
            {
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "用户token失效";
                    return(dto);
                }
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    return(dto);
                }

                userFavorite.CustomerId   = tcp.CustomerId;
                userFavorite.FavoriteTime = DateTime.Now;
                switch (userFavorite.UserFavoriteType)
                {
                case 1: oLog.Remarks = "通道,通道Id:"; break;

                case 2: oLog.Remarks = "事件,事件Id:"; break;

                case 3: oLog.Remarks = "视频,视频文件Id:"; break;
                }
                oLog.Remarks += userFavorite.UserFavoriteId;
                //判定添加收藏是否已经存在
                IList <UserFavorite> userFavoriteFlag = userFavoriteServer.SelectCustomerByTid(userFavorite);
                if (userFavoriteFlag != null && userFavoriteFlag.Count > 0)
                {
                    dto.Code    = (int)CodeEnum.ExistFavorite;
                    dto.Message = "收藏已经存在!";
                    return(dto);
                }
                //添加用户收藏
                userFavoriteId = userFavoriteServer.InsertUserFavorite(userFavorite);
                if (userFavoriteId > 0)
                {
                    dto.Code      = (int)CodeEnum.Success;
                    dto.Message   = "已加入收藏!";
                    oLog.Remarks += dto.Message;
                }
                else
                {
                    dto.Code      = (int)CodeEnum.ApplicationErr;
                    dto.Message   = "加入收藏失败!";
                    oLog.Remarks += dto.Message;
                }
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "网络异常!,加入收藏失败!";
                myLog.ErrorFormat("AddUserFavorite方法异常,用户:{0},UserFavoriteType:{1},UserFavoriteTypeId:{2}",
                                  ex, userFavorite.CustomerId, userFavorite.UserFavoriteType, userFavorite.UserFavoriteTypeId);
            }
            oLog.TargetType = (int)OperaterLogEnum.Favorite;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            return(dto);
        }
Beispiel #10
0
        /// <summary>
        /// 删除一个分组下的一个通道(虚) DeleteSingleChannelByChannelId 2014/12/15
        /// </summary>
        /// <param name="resourceGroup">resourceGroup.resourceGroupId</param>
        /// <param name="channel">channel.ChannelId</param>
        /// <param name="customerToken">token</param>
        /// <returns></returns>
        public ResponseBaseDto DeleteSingleChannelByChannelId(ResourceGroup resourceGroup, Channel channel, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            OperaterLog        oLog = new OperaterLog();
            TokenCacheProperty tcp  = new TokenCacheProperty();

            oLog.Action = "删除通道";
            UserTokenCache utc = UserTokenCache.GetInstance();

            if (utc.IsValid(customerToken) == false)
            {
                dto.Code    = (int)CodeEnum.ServerNoToken;
                dto.Message = "用户token已失效,请重新登录后继续";
            }
            else
            {
                try
                {
                    dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                    if (dto.Code != 0)
                    {
                        oLog.Remarks = dto.Message;
                        oLog.Result  = dto.Code;
                        bllHelper.AddOperaterLog(oLog, tcp);
                        return(dto);
                    }
                    GroupChannel groupChannel = new GroupChannel();
                    groupChannel.channel = new Channel()
                    {
                        ChannelId = channel.ChannelId
                    };
                    groupChannel.resourceGroup = new ResourceGroup()
                    {
                        ResourceGroupId = resourceGroup.ResourceGroupId
                    };
                    IList <GroupChannel> groupChannelFlag =
                        groupChannelServer.SelectGroupChannelByChannelIdAndResourceGroupId(groupChannel);
                    if (groupChannelFlag == null && groupChannelFlag.Count <= 0)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = "需要删除的通道不存在";
                    }
                    else
                    {
                        groupChannelServer.DeleteGroupChannel(groupChannelFlag[0]);
                        dto.Code    = (int)CodeEnum.Success;
                        dto.Message = "通道" + groupChannelFlag[0].channel.ChannelName + "已被删除";
                    }
                }
                catch (Exception ex)
                {
                    dto.Code    = (int)CodeEnum.ApplicationErr;
                    dto.Message = "网络异常,删除通道失败!";
                    myLog.ErrorFormat("DeleteSingleChannelByChannelId方法异常,分组Id:{0},通道Id:{1}", ex, resourceGroup.ResourceGroupId, channel.ChannelId);
                }
            }
            oLog.TargetType = (int)OperaterLogEnum.ResourceGroup;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #11
0
        /// <summary>
        ///  删除一个分组并移除分组下的所有(虚)通道
        /// </summary>
        /// <param name="resourceGroup">通道分组Id</param>
        public ResponseBaseDto RemoveResourceGroup(ResourceGroup resourceGroup, string customerToken)
        {
            ResponseBaseDto    dto = new ResponseBaseDto();
            TokenCacheProperty tcp = new TokenCacheProperty();
            string             groupChannelIdList = "";
            //校验token
            OperaterLog oLog = new OperaterLog();

            oLog.Action = "删除分组(所有)";
            UserTokenCache utc = UserTokenCache.GetInstance();

            if (utc.IsValid(customerToken) == false)
            {
                dto.Code    = (int)CodeEnum.ServerNoToken;
                dto.Message = "用户token已失效,请重新登录后继续";
            }
            else
            {
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    oLog.Remarks = dto.Message;
                    oLog.Result  = dto.Code;
                    bllHelper.AddOperaterLog(oLog, tcp);
                    return(dto);
                }
                //查找当前分组下的所有子分组
                IList <ResourceGroup> allResourceList = new List <ResourceGroup>();
                try
                {
                    GetchildResourceGroup(resourceGroup, ref allResourceList);
                    IList <ResourceGroup> rgFlag = resourceGroupServer.SelectResourceGorupByResourceGroupId(resourceGroup);
                    if (rgFlag != null && rgFlag.Count != 0)
                    {
                        allResourceList.Add(rgFlag[0]);
                    }
                    for (int i = 0; i < allResourceList.Count; i++)
                    {
                        ResourceGroup rg = allResourceList[i];//重复命名:rg
                        //判定当前分组下通道
                        IList <GroupChannel> groupChannelFlag =
                            groupChannelServer.SelectGroupChannelByResourceGroupId(rg);
                        for (int j = 0; j < groupChannelFlag.Count; j++)
                        {
                            GroupChannel groupChannel = groupChannelFlag[j];
                            //关联时必须先删除关系表
                            groupChannelServer.DeleteGroupChannel(groupChannel);
                            groupChannelIdList += groupChannel.GroupChannelId + " ";
                        }
                        resourceGroupServer.DeleteResourceGorup(rg);
                    }
                    dto.Code    = (int)CodeEnum.Success;
                    dto.Message = "分组移除完成!";
                }
                catch (Exception ex)
                {
                    dto.Code    = (int)CodeEnum.ApplicationErr;
                    dto.Message = "网络异常,请刷新页面后继续";
                    myLog.WarnFormat("RemoveResourceGroup方法异常,分组id:{0},分组关系id:{1}", ex, resourceGroup.ResourceGroupId, groupChannelIdList);
                }
            }
            oLog.TargetType = (int)OperaterLogEnum.ResourceGroup;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #12
0
        //------------------------------------------------------
        #region 移动分组下所有通道 UpdateChannelListByResourceGroupId Date:2014/12/15
        /// <summary>
        /// 移动分组下的所有通道 UpdateChannelListByResourceGroupId
        /// Date:2014/12/15
        /// </summary>
        /// <param name="resourceGroup">ResourceGroupId</param>
        /// <param name="channelIdList">通道数组</param>
        /// <param name="customerToken">token</param>
        /// <returns></returns>
        public ResponseBaseDto UpdateChannelListByResourceGroupId(ResourceGroup resourceGroup, int[] channelIdList, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            TokenCacheProperty tcp  = new TokenCacheProperty();
            OperaterLog        oLog = new OperaterLog();

            oLog.Action = "移动分组下通道";
            if (utc.IsValid(customerToken) == false)
            {
                dto.Code    = (int)CodeEnum.ServerNoToken;
                dto.Message = "用户token已失效,请重新登录后继续";
            }
            else
            {
                try
                {
                    dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                    if (dto.Code != 0)
                    {
                        oLog.Remarks = dto.Message;
                        oLog.Result  = dto.Code;
                        bllHelper.AddOperaterLog(oLog, tcp);
                        return(dto);
                    }
                    //查找关联其他通道信息
                    string channelNameListStr = "";
                    string channelMoveErrName = "";
                    for (int i = 0; i < channelIdList.Length; i++)
                    {
                        GroupChannel groupChannel = new GroupChannel();
                        groupChannel.CustomerId = tcp.CustomerId;
                        groupChannel.channel    = new Channel()
                        {
                            ChannelId = channelIdList[i]
                        };
                        groupChannel.resourceGroup = new ResourceGroup {
                            ResourceGroupId = resourceGroup.ResourceGroupId
                        };
                        IList <GroupChannel> groupChannelFlag = groupChannelServer.SelectGroupChannelByChannelIdAndCustomerId(groupChannel);
                        channelNameListStr += "[" + groupChannel.channel.ChannelName + "] ";
                        channelNameListStr += channelIdList[i] + "]";
                        if (groupChannelFlag != null && groupChannelFlag.Count != 0)
                        {
                            groupChannelFlag[0].resourceGroup.ResourceGroupId =
                                groupChannel.resourceGroup.ResourceGroupId;
                            groupChannelServer.UpdateGroupChannel(groupChannelFlag[0]);
                        }
                        else
                        {
                            try
                            {
                                groupChannelServer.InertGroupChannel(groupChannel);
                            }
                            catch
                            {
                                channelMoveErrName += "[" + groupChannel.channel.ChannelName + "]";
                            }
                            dto.Code    = (int)CodeEnum.Success;
                            dto.Message = "已完成通道移动!" + channelMoveErrName + "通道已有过分组";
                        }
                    }
                    IList <ResourceGroup> resourceGroupFlag = resourceGroupServer.SelectResourceGorupByResourceGroupId(resourceGroup);
                    if (resourceGroupFlag != null && resourceGroupFlag.Count != 0 &&
                        channelNameListStr.Length > 0)
                    {
                        channelNameListStr = channelNameListStr.Substring(0, channelNameListStr.Length - 1);
                        dto.Message        = "已将通道" + channelNameListStr + "移动至分组" + resourceGroupFlag[0].ResourceGroupName;
                    }
                }
                catch (Exception ex)
                {
                    dto.Code    = (int)CodeEnum.ApplicationErr;
                    dto.Message = "网络异常,通道移动失败";
                    myLog.ErrorFormat("UpdateChannelListByResourceGroupId方法异常,分组id:{0},通道id集合:{1}", ex, resourceGroup.ResourceGroupId, channelIdList.ToString());
                }
            }
            oLog.TargetType = (int)OperaterLogEnum.ResourceGroup;
            oLog.Remarks    = dto.Message;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #13
0
        /// <summary>
        ///  更新分组名称 UpdateResourceGorupByName
        /// </summary>
        /// <param name="resourceGroup">ResourceGroupId, 需要修改的节点名称</param>
        /// <param name="customerToken"></param>
        /// <returns></returns>
        public ResponseBaseDto UpdateResourceGorupByName(ResourceGroup resourceGroup, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            TokenCacheProperty tcp  = new TokenCacheProperty();
            OperaterLog        oLog = new OperaterLog();

            oLog.Action = "更新分组名称";
            if (utc.IsValid(customerToken) == false)
            {
                dto.Code    = (int)CodeEnum.ServerNoToken;
                dto.Message = "用户token已失效,请重新登录后继续";
            }
            else
            {
                try
                {
                    dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                    if (dto.Code != 0)
                    {
                        oLog.Remarks = dto.Message;
                        oLog.Result  = dto.Code;
                        bllHelper.AddOperaterLog(oLog, tcp);
                        return(dto);
                    }
                    if (resourceGroup.ResourceGroupId == 0 && resourceGroup.ResourceGroupName == null)
                    {
                        dto.Code     = (int)CodeEnum.NoComplete;
                        dto.Message  = "数据请求不完整";
                        oLog.Remarks = dto.Message;
                        oLog.Result  = dto.Code;
                        bllHelper.AddOperaterLog(oLog, tcp);
                        return(dto);
                    }
                    else
                    {
                        IList <ResourceGroup> resourceGroupFlag =
                            resourceGroupServer.SelectResourceGorupByResourceGroupId(resourceGroup);
                        if (resourceGroupFlag != null && resourceGroupFlag.Count != 0)
                        {
                            ResourceGroup rg = resourceGroupFlag[0];
                            rg.ResourceGroupId   = resourceGroup.ResourceGroupId;
                            rg.ResourceGroupName = resourceGroup.ResourceGroupName;
                            resourceGroupServer.UpdateResourceGorupByName(rg);
                            dto.Code     = (int)CodeEnum.Success;
                            dto.Message  = "分组名称更新完成!";
                            oLog.Remarks = "已将分组名为:" + rg.ResourceGroupName + "修改为:" + resourceGroup.ResourceGroupName;
                        }
                        else
                        {
                            dto.Code    = (int)CodeEnum.NoData;
                            dto.Message = "用户数据不存在!";
                        }
                    }
                }
                catch (Exception ex)
                {
                    dto.Code    = (int)CodeEnum.ApplicationErr;
                    dto.Message = "网络异常,更新分组名称失败!";
                    myLog.ErrorFormat("UpdateResourceGorupByName方法异常,用户Id:{0},分组id:{1},分组名:{2}", ex, tcp.CustomerId, resourceGroup.ResourceGroupId, resourceGroup.ResourceGroupName);
                }
            }
            if (oLog.Remarks == null || oLog.Remarks == "")
            {
                oLog.Remarks = dto.Message;
            }
            oLog.TargetType = (int)OperaterLogEnum.ResourceGroup;
            oLog.Result     = dto.Code;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #14
0
        /// <summary>
        ///  更新设备名称 UpdateDeviceByDeviceName
        /// </summary>
        /// <param name="device"></param>
        /// <param name="customerToken"></param>
        /// <returns></returns>
        public ResponseBaseDto UpdateDeviceByDeviceName(Device device, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            TokenCacheProperty tcp  = new TokenCacheProperty();
            OperaterLog        oLog = new OperaterLog();

            oLog.Action = "修改设备名";
            try
            {
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "用户token已失效,请重新登录后继续";
                    return(dto);
                }
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    oLog.TargetType = (int)OperaterLogEnum.Device;
                    oLog.Result     = dto.Code;
                    oLog.Remarks    = dto.Message;
                    bllHelper.AddOperaterLog(oLog, tcp);
                    return(dto);
                }
                else
                {
                    IList <Device> deviceFlag = deviceServer.SelectDeviceByDeviceId(device);
                    oLog.TargetId = device.DeviceId;
                    if (deviceFlag == null || deviceFlag.Count <= 0)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = device.DeviceName + "设备不存在";
                    }
                    else if (deviceFlag[0].CustomerId != tcp.CustomerId)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = "用户没有权限修改设备 " + device.DeviceName;
                    }
                    else
                    {
                        try
                        {
                            //修改BP4Server的设备名
                            UpdateDeviceNameMethod(deviceFlag[0].BPServerDeviceId, deviceFlag[0].DeviceName);
                        }
                        catch (Exception ex)
                        {
                            dto.Code    = (int)CodeEnum.ApplicationErr;
                            dto.Message = "设备已离线!离线状态无法修改设备名";
                            myLog.ErrorFormat("UpdateDeviceByDeviceName(BP4Server设备已离线)设备id:{0},新设备名:{1}",
                                              ex, device.DeviceId, device.DeviceName);
                            return(dto);
                        }
                        deviceFlag[0].DeviceName = device.DeviceName;
                        deviceServer.UpdateDevice(deviceFlag[0]);
                        dto.Code    = 0;
                        dto.Message = "修改设备 " + device.DeviceName + " 完成!";
                    }
                }/*end if(utc.IsValid(customerToken) == false)*/
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "网络异常,修改设备名时,远程连接超时!";
                myLog.ErrorFormat("UpdateDeviceByDeviceName方法异常, 设备id:{0},新设备名:{1}",
                                  ex, device.DeviceId, device.DeviceName);
            }
            oLog.TargetType = (int)OperaterLogEnum.Device;
            oLog.Result     = dto.Code;
            oLog.Remarks    = dto.Message;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #15
0
        /// <summary>
        ///  1添加设备 2初次添加设备通道
        /// </summary>
        /// <returns>ResponseBaseDto</returns>
        public ResponseBaseDto AddDevice(string deviceName, string serialNumber, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            TokenCacheProperty tcp  = new TokenCacheProperty();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            OperaterLog        oLog = new OperaterLog();

            oLog.Action = " 添加设备 ";
            try
            {
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                //获取 判定token
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "Token已失效";
                }
                else
                {
                    Device device = new Device();
                    device.SerialNumber = serialNumber;
                    IList <Device> deviceFlag = deviceServer.SelectDeviceSerialNumber(device);

                    if (device != null && deviceFlag.Count != 0)
                    {
                        //设备被添加过
                        dto.Code     = (int)CodeEnum.NoHardWare;
                        dto.Message  = "此设备正在被使用中";
                        oLog.Result  = dto.Code;
                        oLog.Remarks = dto.Message;
                        bllHelper.AddOperaterLog(oLog, tcp);
                        return(dto);
                    }
                    //参数 0=IP  3等于 CN
                    AddDeviceResponseDto result = AddDeviceMethod(serialNumber);
                    if (result != null && result.Success == true)
                    {
                        //添加本地设备列表
                        Bsr.Cloud.Model.Entities.Device dev = new Model.Entities.Device();
                        dev.SerialNumber     = result.DeviceDto.AddDeviceEntity.SerialNumber;
                        dev.BPServerDeviceId = result.DeviceDto.AddDeviceEntity.Id;
                        if (deviceName == null || deviceName == "")
                        {
                            deviceName = "BStar";
                        }
                        dev.DeviceName = deviceName;
                        // 序列号添加时填3,需用IDeviceEntity.getDeviceType获取真正实际类型
                        dev.DeviceType   = result.DeviceDto.AddDeviceEntity.AddMode;
                        dev.HardwareType = result.DeviceDto.AddDeviceEntity.HardwareType;
                        dev.CustomerId   = tcp.CustomerId;
                        dev.UserName     = result.DeviceDto.AddDeviceEntity.User;
                        dev.PassWord     = result.DeviceDto.AddDeviceEntity.Password;
                        //以规则需要定义服务器位置
                        BPServerConfig bpServerConfig = new BPServerConfig();
                        bpServerConfig.Domain = "default";
                        IList <BPServerConfig> bpServerConfigFlag = bpServerConfigServer.GetBPServerConfigByDomain(bpServerConfig);
                        if (bpServerConfigFlag != null && bpServerConfigFlag.Count != 0)
                        {
                            dev.BPServerConfigId = bpServerConfigFlag[0].BPServerConfigId;
                        }
                        else
                        {
                            dev.BPServerConfigId = 1; //需修改
                        }
                        int deviceId = deviceServer.InsertDevice(dev);

                        //日志动作的目标对象Id
                        oLog.TargetId = deviceId;
                        //通道添加
                        IList <CameraEntity> channelFlag = result.DeviceDto.AddDeviceEntity.Cameras;
                        for (int i = 0; i < channelFlag.Count; i++)
                        {
                            Bsr.Cloud.Model.Entities.Channel channel = new Model.Entities.Channel();
                            CameraEntity ce = channelFlag[i];
                            channel.DeviceId          = deviceId;
                            channel.ChannelNumber     = ce.ChannelNo;
                            channel.ChannelName       = ce.Name;
                            channel.IsEnable          = 1;
                            channel.BPServerChannelId = ce.Id;
                            channel.ImagePath         = "default.jpg";
                            channelServer.InsertChannel(channel);
                        }
                        dto.Code    = (int)CodeEnum.Success;
                        dto.Message = "设备" + deviceName + "已添加完成!";
                    }
                    else
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = result.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "网络异常,添加设备时,远程连接超时!";
                myLog.ErrorFormat("AddDevice方法异常,设备名:{0}, 设备序列号:{1}", ex, deviceName, serialNumber);
            }
            oLog.TargetType = (int)OperaterLogEnum.Device;
            oLog.Result     = dto.Code;
            oLog.Remarks    = dto.Message;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }
Beispiel #16
0
        /// <summary>
        ///  删除个设备(慎用)
        /// </summary>
        /// <param name="customer">customerId</param>
        /// <param name="DeviceId">设备本地数据库Id</param>
        /// <param name="customerToken"></param>
        /// <returns></returns>
        public ResponseBaseDto DeleteDeviceByDeviceId(Device device, string customerToken)
        {
            ResponseBaseDto    dto  = new ResponseBaseDto();
            UserTokenCache     utc  = UserTokenCache.GetInstance();
            OperaterLog        oLog = new OperaterLog();
            TokenCacheProperty tcp  = new TokenCacheProperty();

            oLog.Action = "删除设备";
            try
            {
                //获取 判定token
                if (utc.IsValid(customerToken) == false)
                {
                    dto.Code    = (int)CodeEnum.ServerNoToken;
                    dto.Message = "Token已失效 ";
                    return(dto);
                }
                dto = bllHelper.CheckCustomer(dto, customerToken, ref tcp);
                if (dto.Code != 0)
                {
                    oLog.TargetType = (int)OperaterLogEnum.Device;
                    oLog.Result     = dto.Code;
                    oLog.Remarks    = dto.Message;
                    bllHelper.AddOperaterLog(oLog, tcp);
                    return(dto);
                }
                else
                {
                    //查询本地的deviceId
                    IList <Device> deviceFlag = deviceServer.SelectDeviceByDeviceId(device);
                    if (deviceFlag == null || deviceFlag.Count <= 0)
                    {
                        dto.Code    = (int)CodeEnum.NoHardWare;
                        dto.Message = "删除时没有检索到需要的设备";
                    }
                    else if (deviceFlag[0].CustomerId != tcp.CustomerId)
                    {
                        dto.Code    = (int)CodeEnum.NoAuthorization;
                        dto.Message = "删除时用户没有拥有对此设备权限";
                    }
                    else
                    {
                        oLog.TargetId = deviceFlag[0].DeviceId;
                        bool bFlag = ClearDevice(deviceFlag[0]);
                        if (bFlag)
                        {
                            dto.Code    = (int)CodeEnum.Success;
                            dto.Message = "用户删除设备 " + deviceFlag[0].DeviceName + " 完成!";
                        }
                        else //if(bFlag==false)
                        {
                            dto.Code    = (int)CodeEnum.ServerNoToken;
                            dto.Message = "删除设备设备失败!";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dto.Code    = (int)CodeEnum.ApplicationErr;
                dto.Message = "网络异常,请刷新页面后操作";
                myLog.ErrorFormat("DeleteDeviceByDeviceId方法异常, 设备id:{0}", ex, device.DeviceId);
            }
            oLog.TargetType = (int)OperaterLogEnum.Device;
            oLog.Result     = dto.Code;
            oLog.Remarks    = dto.Message;
            bllHelper.AddOperaterLog(oLog, tcp);
            return(dto);
        }