Ejemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            Log.Info("Starting the application...");
            IocContainer.Container = IocLoader.Init();

            hostAccountService       = new SimpleInjectorServiceHost(IocContainer.Container, typeof(AccountService));
            hostAddressService       = new SimpleInjectorServiceHost(IocContainer.Container, typeof(AddressService));
            hostAuditService         = new SimpleInjectorServiceHost(IocContainer.Container, typeof(AuditService));
            hostCompanyService       = new SimpleInjectorServiceHost(IocContainer.Container, typeof(CompanyService));
            hostEmployeeService      = new SimpleInjectorServiceHost(IocContainer.Container, typeof(EmployeeService));
            hostEntityProductService = new SimpleInjectorServiceHost(IocContainer.Container, typeof(EntityProductService));
            hostFeeScheduleService   = new SimpleInjectorServiceHost(IocContainer.Container, typeof(FeeScheduleService));
            hostInvoiceService       = new SimpleInjectorServiceHost(IocContainer.Container, typeof(InvoiceService));
            hostLedgerService        = new SimpleInjectorServiceHost(IocContainer.Container, typeof(LedgerService));
            hostOrderService         = new SimpleInjectorServiceHost(IocContainer.Container, typeof(OrderService));
            hostProductService       = new SimpleInjectorServiceHost(IocContainer.Container, typeof(ProductService));
            hostSessionService       = new SimpleInjectorServiceHost(IocContainer.Container, typeof(SessionService));
            hostTypeService          = new SimpleInjectorServiceHost(IocContainer.Container, typeof(TypeService));
            hostIdentityUserService  = new SimpleInjectorServiceHost(IocContainer.Container, typeof(IdentityUserService));
            hostIdentityRoleService  = new SimpleInjectorServiceHost(IocContainer.Container, typeof(IdentityRoleService));

            //using (IocContainer.Container)
            //{

            Log.Info("Configuring SimpleInjectorServiceHost...");

            try
            {
                StartService(hostAccountService, "Account Service");
                StartService(hostAddressService, "Address Service");
                StartService(hostAuditService, "Audit Service");
                StartService(hostCompanyService, "Company Service");
                StartService(hostEmployeeService, "Employee Service");
                StartService(hostEntityProductService, "Entity Product Service");
                StartService(hostFeeScheduleService, "Fee Schedule Service");
                StartService(hostInvoiceService, "Invoice Service");
                StartService(hostLedgerService, "Ledger Service");
                StartService(hostOrderService, "Order Service");
                StartService(hostProductService, "Product Service");
                StartService(hostSessionService, "Session Service");
                StartService(hostTypeService, "Type Service");
                StartService(hostIdentityUserService, "Identity User Service");
                StartService(hostIdentityRoleService, "Identity Role Service");
                //Console.ReadLine();
            }
            catch (SM.CommunicationException ce)
            {
                Log.Error("An exception occurred: {0}", ce.Message);
            }
            catch (Exception ex)
            {
                Log.Error("An exception occurred: {0}", ex.Message);
            }
            //finally
            //{
            //    hostAccountService.Abort();
            //    hostAddressService.Abort();
            //    hostAuditService.Abort();
            //    hostCompanyService.Abort();
            //    hostEmployeeService.Abort();
            //    hostEntityProductService.Abort();
            //    hostFeeScheduleService.Abort();
            //    hostInvoiceService.Abort();
            //    hostLedgerService.Abort();
            //    hostOrderService.Abort();
            //    hostProductService.Abort();
            //    hostSessionService.Abort();
            //    hostTypeService.Abort();
            //    hostIdentityUserService.Abort();
            //    hostIdentityRoleService.Abort();
            //}
            //}
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //using (ServiceHost host = new ServiceHost(typeof(QIQO.Business.Services.AccountService)))
            //{
            //    host.Open();
            //    Console.WriteLine("Account Service Started @ " + DateTime.Now.ToString());
            //    Console.ReadLine();
            //    host.Close();
            //}

            //Logger logr = new Logger("QIQO.Common.Core");
            Log.Info("Starting the application...");
            IocContainer.Container = IocLoader.Init();

            //using (IUnityContainer container = new UnityContainer())
            using (IocContainer.Container)
            {
                //RegisterTypes(container);
                //IocContainer.Container = container;

                // Step 1 Create a URI to serve as the base address.
                //Uri baseAddress = new Uri("net.tcp://*****:*****@ " + DateTime.Now.ToString());
                    //    Console.ReadLine();
                    //    hostAccountService.Close();
                    //    Log.Info("Account Service stopped @ " + DateTime.Now.ToString());
                    //}

                    StartService(hostAccountService, "Account Service");
                    StartService(hostAddressService, "Address Service");
                    StartService(hostAuditService, "Audit Service");
                    StartService(hostCompanyService, "Company Service");
                    StartService(hostEmployeeService, "Employee Service");
                    StartService(hostEntityProductService, "Entity Product Service");
                    StartService(hostFeeScheduleService, "Fee Schedule Service");
                    StartService(hostInvoiceService, "Invoice Service");
                    StartService(hostLedgerService, "Ledger Service");
                    StartService(hostOrderService, "Order Service");
                    StartService(hostProductService, "Product Service");
                    StartService(hostSessionService, "Session Service");
                    StartService(hostTypeService, "Type Service");
                    StartService(hostIdentityUserService, "Identity User Service");
                    StartService(hostIdentityRoleService, "Identity Role Service");


                    Console.WriteLine("");
                    Console.WriteLine("Press [Enter] to exit.");
                    Console.ReadLine();
                    Console.WriteLine("");

                    StopService(hostAccountService, "Account Service");
                    StopService(hostAddressService, "Address Service");
                    StopService(hostAuditService, "Audit Service");
                    StopService(hostCompanyService, "Company Service");
                    StopService(hostEmployeeService, "Employee Service");
                    StopService(hostEntityProductService, "Entity Product Service");
                    StopService(hostFeeScheduleService, "Fee Schedule Service");
                    StopService(hostInvoiceService, "Invoice Service");
                    StopService(hostLedgerService, "Ledger Service");
                    StopService(hostOrderService, "Order Service");
                    StopService(hostProductService, "Product Service");
                    StopService(hostSessionService, "Session Service");
                    StopService(hostTypeService, "Type Service");
                    StopService(hostIdentityUserService, "Identity User Service");
                    StopService(hostIdentityRoleService, "Identity Role Service");
                }
                catch (SM.CommunicationException ce)
                {
                    Log.Error("An exception occurred: {0}", ce.Message);
                }
                catch (Exception ex)
                {
                    Log.Error("An exception occurred: {0}", ex.Message);
                }
                finally
                {
                    hostAccountService.Abort();
                    hostAddressService.Abort();
                    hostAuditService.Abort();
                    hostCompanyService.Abort();
                    hostEmployeeService.Abort();
                    hostEntityProductService.Abort();
                    hostFeeScheduleService.Abort();
                    hostInvoiceService.Abort();
                    hostLedgerService.Abort();
                    hostOrderService.Abort();
                    hostProductService.Abort();
                    hostSessionService.Abort();
                    hostTypeService.Abort();
                    hostIdentityUserService.Abort();
                    hostIdentityRoleService.Abort();
                }
            }
        }