示例#1
0
        /// <summary>
        /// Function to save a ServiceEntity to the database.
        /// </summary>
        /// <param name="serviceEntity">ServiceEntity to save</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>null if the ServiceEntity was saved successfully, the same ServiceEntity otherwise</returns>
        /// <exception cref="ArgumentNullException">
        /// if <paramref name="serviceEntity"/> is null.
        /// </exception>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public ServiceEntity Save(ServiceEntity serviceEntity, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "save", "Service");

            if (!permited)
            {
                ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to save an entity"));
                throw new FaultException <ExceptionDetail>(detail);
            }

            if (!Validate(serviceEntity))
            {
                return(serviceEntity);
            }
            try
            {
                // Check that the service is not deployed
                if (serviceEntity.Deployed)
                {
                    serviceEntity.Errors.Add(new Error("Service Deployed", "", "The service is already deployed. Can not be saved."));
                    return(serviceEntity);
                }

                serviceDataAccess.Save(serviceEntity);
                return(null);
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }
 /// <summary>
 /// Actualiza los archivos de ensamblado en la entidad de servicio.
 /// </summary>
 /// <param name="serviceModel">El modelo de servicio desde el cuál se actualizan los datos.</param>
 /// <param name="fileName">El nombre de archivo.</param>
 /// <param name="clientVersionFileName">El nombre del archivo del cliente</param>
 /// <param name="sessionIdentifier">Sesión de usuario</param>
 /// <returns>True si se guardó con éxito.</returns>
 static private bool SaveCustomServiceModel(CustomerServiceDataEntity serviceModel, string fileName, string clientVersionFileName, string sessionIdentifier)
 {
     try
     {
         ServiceDataAccess serviceDataAccess = new ServiceDataAccess();
         ServiceEntity     serviceEntity     = serviceModel.Service;
         if (serviceEntity == null)
         {
             Service serviceLogic = new Service();
             serviceEntity = serviceLogic.GetService(serviceModel.IdService, false, sessionIdentifier);
         }
         serviceEntity.Deployed             = true;
         serviceEntity.PathAssemblyServer   = Path.GetFileNameWithoutExtension(fileName) + ".dll";
         serviceEntity.RelativePathAssembly = Path.GetFileNameWithoutExtension(clientVersionFileName) + ".dll";
         serviceDataAccess.Save(serviceEntity);
         return(true);
     }
     catch (UtnEmallDataAccessException error)
     {
         Debug.WriteLine("FAILURE : While updating custom service entity. ERROR : " + error.Message);
         return(false);
     }
     catch (UtnEmallBusinessLogicException error)
     {
         Debug.WriteLine("FAILURE : While updating custom service entity. ERROR : " + error.Message);
         return(false);
     }
 }
示例#3
0
 /// <summary>
 /// Función para guardar ServiceEntity en la base de datos.
 /// </summary>
 /// <param name="serviceEntity">ServiceEntity a guardar</param>
 /// <param name="session">Identificador de sesion del usuario.</param>
 /// <returns>null si el ServiceEntity se guardo con exito, el mismo ServiceEntity en otro caso</returns>
 /// <exception cref="ArgumentNullException">
 /// if <paramref name="serviceEntity"/> is null.
 /// </exception>
 /// <exception cref="UtnEmallBusinessLogicException">
 /// Si una excepción UtnEmallDataAccessException ocurre en el data model.
 /// </exception>
 public ServiceEntity Save(ServiceEntity serviceEntity)
 {
     if (serviceEntity == null)
     {
         throw new ArgumentException("The entity can't be null", "serviceEntity");
     }
     // Valida el ServiceEntity
     if (!Validate(serviceEntity))
     {
         return(serviceEntity);
     }
     try
     {
         // Guarda un serviceEntity usando un objeto de data access
         serviceDataAccess.Save(serviceEntity);
         return(null);
     }
     catch (UtnEmallDataAccessException utnEmallDataAccessException)
     {
         // Reenvía como una excepcion personalizada
         throw new UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
     }
 }