Ejemplo n.º 1
0
        private void InitInfrastructureServices()
        {
            try
            {
                // Cargar todos los modelos de datos y verificar ensamblados
                DataModelDataAccess          dataModelDataAccess = new DataModelDataAccess();
                Collection <DataModelEntity> result = dataModelDataAccess.LoadWhere(DataModelEntity.DBIdStore, "0", false, OperatorType.Equal);
                dataModelDataAccess = new DataModelDataAccess();
                Collection <DataModelEntity> dataModels = dataModelDataAccess.LoadAll(true);

                if (result.Count == 0)
                {
                    ConsoleWriter.SetText("Creating mall data model");
                    DataModelEntity dataModel = new DataModelEntity();

                    MallEntity mall = new MallEntity();
                    mall.MallName = "Mall";

                    (new MallDataAccess()).Save(mall);
                    dataModel.Mall = mall;

                    dataModelDataAccess.Save(dataModel);
                }

                foreach (DataModelEntity dataModel in dataModels)
                {
                    string assemblyFileName = dataModel.ServiceAssemblyFileName;
                    if (assemblyFileName != null)
                    {
                        if (File.Exists(Path.Combine(ServiceBuilder.AssembliesFolder, assemblyFileName)))
                        {
                            Type[]  servicesTypes  = ServiceBuilder.GetInfrastructureServiceTypes(assemblyFileName);
                            Binding serviceBinding = new BasicHttpBinding();
                            if (PublishInfrastructureService(servicesTypes[0], servicesTypes[1], serviceBinding))
                            {
                                Debug.WriteLine("SUCCESS : infrastructure service published.");
                            }
                            else
                            {
                                Debug.WriteLine("FAILURE : trying to publish infrastructure service.");
                            }
                        }
                        else
                        {
                            ServiceBuilder builder = new ServiceBuilder();
                            dataModel.Deployed = false;
                            builder.BuildAndImplementInfrastructureService(dataModel, false, serverSession);
                        }
                    }
                }
            }
            catch (DataException dataError)
            {
                Debug.WriteLine("ERROR : Data exception running infrastructure services. MESSAGE : " + dataError.Message);
            }
            catch (IOException ioError)
            {
                Debug.WriteLine("ERROR : IO error running infrastructure services. MESSAGE : " + ioError.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get collection of all dataModelEntity
        /// </summary>
        /// <param name="loadRelation">true to load the relations</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>Collection of all DataModelEntity</returns>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public Collection <DataModelEntity> GetAllDataModel(bool loadRelation, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "read", "DataModel");

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

            try
            {
                return(datamodelDataAccess.LoadAll(loadRelation));
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }