Пример #1
0
 /// <summary>
 /// 检查设备数据
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <param name="result">返回值</param>
 private void CheckDeviceExecute(DeviceExecute model, CommonResult <DeviceExecute> result)
 {
     if (model == null)
     {
         result.IsSuccess = false;
         result.Message   = "设备对象不能为空";
     }
     else if (string.IsNullOrEmpty(model.DeviCode))
     {
         result.IsSuccess = false;
         result.Message   = "设备编码不能为空!";
     }
 }
Пример #2
0
        /// <summary>
        /// 更新设备接口
        /// </summary>
        /// <param name="model">设备接口对象</param>
        /// <returns>返回处理结果</returns>
        public CommonResult <DeviceExecute> UpdateDeviceExecute(DeviceExecute model)
        {
            var result = new CommonResult <DeviceExecute>();

            try
            {
                var dbSession = new DBService <DeviceExecute>().DbSession;


                dbSession.GetQueryable(t => t.DeviCode == model.DeviCode).FirstOrDefault();


                result.Data = dbSession.Update(model);
            }

            /*
             * CheckDeviceExecute(model, result);
             * if (result.IsSuccess)
             * {
             *  var dbSession = new DBService<DeviceExecute>().DbSession;
             *  //var dbSession1 = new DBService<DeviceInterface>().DbSession;
             *  if (dbSession.GetQueryable(t => t.DeviCode == model.DeviCode && t.DeviCode == model.DeviCode).FirstOrDefault() == null)
             *  {
             *      result.IsSuccess = false;
             *      result.Message = "设备编码不存在!";
             *  }
             *  //else if (dbSession.GetQueryable(t => t.DeviName == model.DeviName && t.DevCode != model.DevCode).FirstOrDefault() != null)
             *  //{
             *  //    result.IsSuccess = false;
             *  //    result.Message = "接口名称不能重复!";
             *  //}
             *  //else if (dbSession.GetQueryable(t => t.DevCode == model.DevCode).FirstOrDefault() == null)
             *  //{
             *  //    result.IsSuccess = false;
             *  //    result.Message = "设备编码不能重复!";
             *  //
             *    * */

            catch (Exception ex)
            {
                Utils.Logger.Error(ex.ToString());
                throw ex;
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 新增设备接口
        /// </summary>
        /// <param name="model">设备接口对象</param>
        /// <returns>返回处理结果</returns>
        public CommonResult <DeviceExecute> AddDeviceExecute(DeviceExecute model)
        {
            var result = new CommonResult <DeviceExecute>();

            try
            {
                //   CheckDeviceExecute(model, result);
                if (result.IsSuccess)
                {
                    var dbSession = new DBService <DeviceExecute>().DbSession;



                    if (dbSession.GetQueryable(t => t.DeviCode == model.DeviCode).FirstOrDefault() != null)
                    {
                        result.IsSuccess = false;
                        result.Message   = "接口名称不能重复!";
                    }
                    //else if (dbSession.GetQueryable(t => t.DevCode == model.DevCode).FirstOrDefault() == null)
                    //{
                    //    result.IsSuccess = false;
                    //    result.Message = "设备编码不能重复!";
                    //}
                    else
                    {
                        result.Data = dbSession.Insert(model);
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.Logger.Error(ex.ToString());
                throw ex;
            }
            return(result);
        }
Пример #4
0
 public Server.Utility.CommonResult <DeviceExecute> UpdateDeviceExecute(string sessionId, DeviceExecute model)
 {
     //  return ForDeviceExecute.GetInstance(sessionId).UpdateDeviceExecute(model);
     try
     {
         return(ForDevExecuteServices.GetInstance(sessionId).UpdateDeviceExecute(model));
     }
     catch (Exception ex)
     {
         throw new FaultException <CustomFaultMessage>(new CustomFaultMessage()
         {
             ErrorCode  = ex.HResult,
             Message    = ex.Message,
             StackTrace = ex.StackTrace
         }, ex.Message);
     }
 }