/// <summary>
        /// 添加命令
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static Model.Enum.HandleResult AddAMS_CommandList(Model.AMS_CommandList model)
        {
            AMS.IBllService.IAdvertManageBllService bllService = AMS.ServiceConnectChannel.AdvertManageBllServiceChannel.CreateServiceChannel();
            bool error = false;

            try
            {
                return(bllService.AddAMS_CommandList(model));
            }
            catch (Exception ex)
            {
                error = true;
                SeatManage.SeatManageComm.WriteLog.Write(string.Format("根据学校编号获取设备列表遇到错误,异常来自:{0};信息:{1}", ex.Source, ex.Message));
                throw ex;
            }
            finally
            {
                ICommunicationObject ICommObjectService = bllService as ICommunicationObject;
                try
                {
                    if (ICommObjectService.State == CommunicationState.Faulted)
                    {
                        ICommObjectService.Abort();
                    }
                    else
                    {
                        ICommObjectService.Close();
                    }
                }
                catch
                {
                    ICommObjectService.Abort();
                }
            }
        }
示例#2
0
        public List <Model.AMS_CommandList> GetCommandListBySchoolNum(string schoolNum)
        {
            StringBuilder strWhere            = new StringBuilder();
            List <Model.AMS_CommandList> list = new List <Model.AMS_CommandList>();

            //添加条件
            if (!string.IsNullOrEmpty(schoolNum))
            {
                strWhere.AppendFormat("SchoolNum='{0}' and (FinishFlag={1} or FinishFlag={2} or FinishFlag={3}) ", schoolNum, (int)Model.Enum.CommandHandleResult.Wait, (int)Model.Enum.CommandHandleResult.Getting, (int)Model.Enum.CommandHandleResult.Failed);
                try
                {
                    DataSet ds = VComDal.GetList(strWhere.ToString());
                    //遍历查询结果,转换为Model,添加到List里面
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Model.AMS_CommandList model = DataRowToAMS_CammandListModel(ds.Tables[0].Rows[i]);
                        list.Add(model);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(list);
        }
示例#3
0
        private Model.AMS_CommandList DataRowToAMS_CammandListModel(DataRow dr)
        {
            Model.AMS_CommandList model = new Model.AMS_CommandList();

            if (dr["ID"] != null && dr["ID"].ToString() != "")
            {
                model.ID = int.Parse(dr["ID"].ToString());
            }
            if (dr["SchoolId"] != null && dr["SchoolId"].ToString() != "")
            {
                model.SchoolId = int.Parse(dr["SchoolId"].ToString());
            }
            if (dr["Command"] != null && dr["Command"].ToString() != "")
            {
                model.Command = (Model.Enum.CommandType) int.Parse(dr["Command"].ToString());
            }
            if (dr["CommandId"] != null && dr["CommandId"].ToString() != "")
            {
                model.CommandId = int.Parse(dr["CommandId"].ToString());
            }
            if (dr["ReleaseTime"] != null && dr["ReleaseTime"].ToString() != "")
            {
                model.ReleaseTime = DateTime.Parse(dr["ReleaseTime"].ToString());
            }
            if (dr["FinishTime"] != null && dr["FinishTime"].ToString() != "")
            {
                model.FinishTime = DateTime.Parse(dr["FinishTime"].ToString());
            }
            if (dr["FinishFlag"] != null && dr["FinishFlag"].ToString() != "")
            {
                model.FinishFlag = int.Parse(dr["FinishFlag"].ToString());
            }
            return(model);
        }
 /// <summary>
 /// 添加命令列表
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string AddNewCommandList(Model.AMS_CommandList model)
 {
     try
     {
         dal_CommandList.Add(model);
         return("");
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("下发命令出错:{0}", ex.Message));
     }
 }
示例#5
0
 public Model.Enum.HandleResult AddAMS_CommandList(Model.AMS_CommandList model)
 {
     try
     {
         if (ComDal.Add(model) > 0)
         {
             return(Model.Enum.HandleResult.Successed);
         }
         else
         {
             return(Model.Enum.HandleResult.Failed);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#6
0
        public Model.Enum.HandleResult UpdateFinishFlag(Model.AMS_CommandList model)
        {
            StringBuilder strWhere = new StringBuilder();

            if (model != null)
            {
                model.FinishTime = DateTime.Now;
                if (ComDal.Update(model))
                {
                    return(Model.Enum.HandleResult.Successed);
                }
                else
                {
                    return(Model.Enum.HandleResult.Failed);
                }
            }
            return(Model.Enum.HandleResult.Failed);
        }
 /// <summary>
 /// 下发文件
 /// </summary>
 /// <returns></returns>
 public static string IssuedFiles(Model.AMS_CommandList model)
 {
     AMS.IBllService.IAdvertManageBllService bllService = AMS.ServiceConnectChannel.AdvertManageBllServiceChannel.CreateServiceChannel();
     try
     {
         return(bllService.AddNewCommandList(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();
         }
     }
 }