Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AMS.Model.AMS_Device model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AMS_Device set ");
            strSql.Append("Number=@Number,");
            strSql.Append("DeviceType=@DeviceType,");
            strSql.Append("CampusId=@CampusId,");
            strSql.Append("IsDel=@IsDel,");
            strSql.Append("Flag=@Flag,");
            strSql.Append("Describe=@Describe,");
            strSql.Append("CaputrePath=@CaputrePath,");
            strSql.Append("CaputreTime=@CaputreTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Number",      SqlDbType.NVarChar,   50),
                new SqlParameter("@DeviceType",  SqlDbType.Int,         4),
                new SqlParameter("@CampusId",    SqlDbType.Int,         4),
                new SqlParameter("@IsDel",       SqlDbType.Bit,         1),
                new SqlParameter("@Flag",        SqlDbType.Bit,         1),
                new SqlParameter("@Describe",    SqlDbType.NVarChar,  200),
                new SqlParameter("@CaputrePath", SqlDbType.NVarChar,  100),
                new SqlParameter("@CaputreTime", SqlDbType.DateTime),
                new SqlParameter("@Id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Number;
            parameters[1].Value = model.DeviceType;
            parameters[2].Value = model.CampusId;
            parameters[3].Value = model.IsDel;
            parameters[4].Value = model.Flag;
            parameters[5].Value = model.Describe;
            parameters[6].Value = model.CaputrePath;
            parameters[7].Value = model.CaputreTime;
            parameters[8].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(AMS.Model.AMS_Device model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AMS_Device(");
            strSql.Append("Number,DeviceType,CampusId,IsDel,Flag,Describe,CaputrePath,CaputreTime)");
            strSql.Append(" values (");
            strSql.Append("@Number,@DeviceType,@CampusId,@IsDel,@Flag,@Describe,@CaputrePath,@CaputreTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Number",      SqlDbType.NVarChar,  50),
                new SqlParameter("@DeviceType",  SqlDbType.Int,        4),
                new SqlParameter("@CampusId",    SqlDbType.Int,        4),
                new SqlParameter("@IsDel",       SqlDbType.Bit,        1),
                new SqlParameter("@Flag",        SqlDbType.Bit,        1),
                new SqlParameter("@Describe",    SqlDbType.NVarChar, 200),
                new SqlParameter("@CaputrePath", SqlDbType.NVarChar, 100),
                new SqlParameter("@CaputreTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.Number;
            parameters[1].Value = model.DeviceType;
            parameters[2].Value = model.CampusId;
            parameters[3].Value = model.IsDel;
            parameters[4].Value = model.Flag;
            parameters[5].Value = model.Describe;
            parameters[6].Value = model.CaputrePath;
            parameters[7].Value = model.CaputreTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 /// <summary>
 /// 删除设备
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static string DeleteDevice(AMS.Model.AMS_Device model)
 {
     AMS.IBllService.IAdvertManageBllService bllService = AMS.ServiceConnectChannel.AdvertManageBllServiceChannel.CreateServiceChannel();
     try
     {
         return(bllService.DeleteDevice(model));
     }
     catch (EndpointNotFoundException ex)
     {
         throw new AMS.Model.CustomerException("连接服务器失败");
     }
     catch (CommunicationException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         ICommunicationObject ICommObjectService = bllService as ICommunicationObject;
         try
         {
             if (ICommObjectService.State == CommunicationState.Faulted)
             {
                 ICommObjectService.Abort();
             }
             else
             {
                 ICommObjectService.Close();
             }
         }
         catch
         {
             ICommObjectService.Abort();
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 上传设备截图
        /// </summary>
        /// <returns></returns>
        public static bool UpdateCaputre()
        {
            try
            {
                List <SeatManage.ClassModel.TerminalInfoV2> terminalList = SeatManage.Bll.TerminalOperatorService.GetAllTeminalInfo();
                SeatManage.Bll.FileOperate   seatfileTransport           = new SeatManage.Bll.FileOperate();
                AMS.ServiceProxy.FileOperate advertTransport             = new AMS.ServiceProxy.FileOperate();
                foreach (SeatManage.ClassModel.TerminalInfoV2 terminal in terminalList)
                {
                    if (!string.IsNullOrEmpty(terminal.ScreenshotPath))
                    {
                        AMS.Model.AMS_Device model = AMS.ServiceProxy.IDevice.GetDevicebyNo(terminal.ClientNo);
                        if (model == null)
                        {
                            return(true);//如果媒体服务器上获取不到信息,直接返回true,以便结束命令。
                        }

                        string fileFullName = string.Format("{0}{1}", ServiceSet.TempFilePath, terminal.ScreenshotPath);
                        if (seatfileTransport.FileDownLoad(fileFullName, terminal.ScreenshotPath, SeatManage.EnumType.SeatManageSubsystem.Caputre))
                        {
                            if (advertTransport.UpdateFile(fileFullName, terminal.ScreenshotPath, SeatManage.EnumType.SeatManageSubsystem.Caputre) == "")
                            {
                                File.Delete(fileFullName);
                                //上传完成,更新一下截图路径。
                                model.CaputrePath = terminal.ScreenshotPath;
                                AMS.ServiceProxy.IDevice.UpdateDeviceModel(model);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMS.Model.AMS_Device GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Number,DeviceType,CampusId,IsDel,Flag,Describe,CaputrePath,CaputreTime from AMS_Device ");
            if (!string.IsNullOrEmpty(strWhere) && strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            AMS.Model.AMS_Device model = new AMS.Model.AMS_Device();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Number"] != null && ds.Tables[0].Rows[0]["Number"].ToString() != "")
                {
                    model.Number = ds.Tables[0].Rows[0]["Number"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DeviceType"] != null && ds.Tables[0].Rows[0]["DeviceType"].ToString() != "")
                {
                    model.DeviceType = int.Parse(ds.Tables[0].Rows[0]["DeviceType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CampusId"] != null && ds.Tables[0].Rows[0]["CampusId"].ToString() != "")
                {
                    model.CampusId = int.Parse(ds.Tables[0].Rows[0]["CampusId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsDel"] != null && ds.Tables[0].Rows[0]["IsDel"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsDel"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDel"].ToString().ToLower() == "true"))
                    {
                        model.IsDel = true;
                    }
                    else
                    {
                        model.IsDel = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Flag"] != null && ds.Tables[0].Rows[0]["Flag"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Flag"].ToString() == "1") || (ds.Tables[0].Rows[0]["Flag"].ToString().ToLower() == "true"))
                    {
                        model.Flag = true;
                    }
                    else
                    {
                        model.Flag = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Describe"] != null && ds.Tables[0].Rows[0]["Describe"].ToString() != "")
                {
                    model.Describe = ds.Tables[0].Rows[0]["Describe"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CaputrePath"] != null && ds.Tables[0].Rows[0]["CaputrePath"].ToString() != "")
                {
                    model.CaputrePath = ds.Tables[0].Rows[0]["CaputrePath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CaputreTime"] != null && ds.Tables[0].Rows[0]["CaputreTime"].ToString() != "")
                {
                    model.CaputreTime = DateTime.Parse(ds.Tables[0].Rows[0]["CaputreTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMS.Model.AMS_Device GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Number,DeviceType,CampusId,IsDel,Flag,Describe,CaputrePath,CaputreTime from AMS_Device ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            AMS.Model.AMS_Device model = new AMS.Model.AMS_Device();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Number"] != null && ds.Tables[0].Rows[0]["Number"].ToString() != "")
                {
                    model.Number = ds.Tables[0].Rows[0]["Number"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DeviceType"] != null && ds.Tables[0].Rows[0]["DeviceType"].ToString() != "")
                {
                    model.DeviceType = int.Parse(ds.Tables[0].Rows[0]["DeviceType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CampusId"] != null && ds.Tables[0].Rows[0]["CampusId"].ToString() != "")
                {
                    model.CampusId = int.Parse(ds.Tables[0].Rows[0]["CampusId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsDel"] != null && ds.Tables[0].Rows[0]["IsDel"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsDel"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDel"].ToString().ToLower() == "true"))
                    {
                        model.IsDel = true;
                    }
                    else
                    {
                        model.IsDel = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Flag"] != null && ds.Tables[0].Rows[0]["Flag"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Flag"].ToString() == "1") || (ds.Tables[0].Rows[0]["Flag"].ToString().ToLower() == "true"))
                    {
                        model.Flag = true;
                    }
                    else
                    {
                        model.Flag = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Describe"] != null && ds.Tables[0].Rows[0]["Describe"].ToString() != "")
                {
                    model.Describe = ds.Tables[0].Rows[0]["Describe"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CaputrePath"] != null && ds.Tables[0].Rows[0]["CaputrePath"].ToString() != "")
                {
                    model.CaputrePath = ds.Tables[0].Rows[0]["CaputrePath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CaputreTime"] != null && ds.Tables[0].Rows[0]["CaputreTime"].ToString() != "")
                {
                    model.CaputreTime = DateTime.Parse(ds.Tables[0].Rows[0]["CaputreTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }