Пример #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     service = new Service.MeteoService();
     host    = new System.ServiceModel.ServiceHost(
         typeof(Service.MeteoService));
     host.Open();
 }
Пример #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     service = new Service.MeteoService();
     host = new System.ServiceModel.ServiceHost(
             typeof(Service.MeteoService));
     host.Open();
 }
Пример #3
0
        protected override void OnStart(string[] args)
        {
            storage = new WcfSessionStorage();

            log4net.Config.XmlConfigurator.Configure();

            // Create container
            IWindsorContainer container = new WindsorContainer();

            // Add Engine for the Host Service
            container.AddComponent("outfitEngineService", typeof(OutfitEngineService));
            container.AddComponent("outfitUpdaterService", typeof(OutfitUpdaterService));

            // Add the Services to the Container
            ComponentRegistrar.AddServicesTo(container);
            ComponentRegistrar.AddApplicationServicesTo(container);

            // Create the container
            ServiceLocatorInitializer.Init(container);

            // Initialize NHibernate
            NHibernateInitializer.Instance().InitializeNHibernateOnce(
                () => InitializeNHibernateSession());

            // Create Service Host
            host = new System.ServiceModel.ServiceHost(typeof(OutfitEngineService));
            host.Description.Behaviors.Add(new PerCallServiceBehavior());
            host.Open();

            hostUpdater = new SharpArch.Wcf.NHibernate.ServiceHost(typeof(OutfitUpdaterService));
            hostUpdater.Open();
        }
Пример #4
0
 static void Main(string[] args)
 {
     System.ServiceModel.ServiceHost _host = new System.ServiceModel.ServiceHost(typeof(PatientDataServiceLib.PatientDataService));
     _host.Open();
     Console.WriteLine("Server Started");
     Console.ReadLine();
 }
Пример #5
0
        private static void Main()
        {
            Console.CancelKeyPress += (sender, args) => CloseHost();

            try
            {
                _host =
                    new System.ServiceModel.ServiceHost(
                        new Service(new ChatService(new CurrentOperationContextChatClientProvider(),
                                                    new NLogLogger(LogManager.GetCurrentClassLogger(typeof(ChatService))))));

                // Start
                _host.Open();

                Logger.Info(
                    $"The service is ready at {_host.BaseAddresses.Select(uri => uri.ToString()).Aggregate((s, s1) => s + ", " + s1)}.");
                Logger.Info("Press <Enter> to stop the service.\n");
                Console.ReadLine();
            }
            catch (Exception exception)
            {
                Logger.Error("Service can not be started \n\nError Message [" + exception.Message + "]");
            }
            finally
            {
                // Stop
                CloseHost();
            }
        }
Пример #6
0
        public void Open()
        {
            var channel = new MosquitoChannelImpl(_owner.Queue, _owner.Container);

            _serviceHost = new System.ServiceModel.ServiceHost(channel);
            _serviceHost.Open();
        }
Пример #7
0
        static void Main(string[] args)
        {
            System.ServiceModel.ServiceHost objServiceHost = null;
            try
            {
                objServiceHost = new System.ServiceModel.ServiceHost(typeof(Service));
                objServiceHost.Open();

                Console.WriteLine("Listening... <press enter to stop>");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error:");
                Console.WriteLine(e.ToString());
                Console.ReadLine();
            }
            finally
            {
                try
                {
                    if (objServiceHost != null)
                        objServiceHost.Close();
                }
                catch
                { }
            }
        }
Пример #8
0
        protected override void OnStop()
        {
            LoggingUtility.LogDebug("OnStop", "AirtimeBilling.LoggingService.ServiceHost.Service.LoggingService",
                                    "Stopping Services");

            if (emailHost != null)
            {
                emailHost.Close();
                emailHost = null;
            }

            if (activityHost != null)
            {
                activityHost.Close();
                activityHost = null;
            }

            if (debugHost != null)
            {
                debugHost.Close();
                debugHost = null;
            }

            if (errorHost != null)
            {
                errorHost.Close();
                errorHost = null;
            }

            // Even though the service is no longer running, thanks to MSMQ, the next time it starts it'll get this message.
            LoggingUtility.LogDebug("OnStop", "AirtimeBilling.LoggingService.ServiceHost.Service.LoggingService",
                                    "Stopped Services");
        }
Пример #9
0
 /// <summary>
 /// Closes the service host.
 /// </summary>
 /// <param name="serviceHost">The service host.</param>
 private static void CloseServiceHost(System.ServiceModel.ServiceHost serviceHost)
 {
     if (serviceHost != null)
     {
         serviceHost.Close();
     }
 }
Пример #10
0
        static void Main(string[] args)
        {
            // set up the dependency container because instantiating
            // shopping manager and dependencies of it (ShoppingManager)
            ObjectBase.Container = MefLoader.Init();

            System.Console.WriteLine("-------------------------------------------------");
            System.Console.WriteLine("");
            System.Console.WriteLine("     Starting up services");
            System.Console.WriteLine("");
            System.Console.WriteLine("-------------------------------------------------");
            System.Console.WriteLine("");

            // initalize the service manager
            var hostInventoryManager = new System.ServiceModel.ServiceHost(typeof(InventoryManager));

            // start the service manager
            StartService(hostInventoryManager, "InventoryManager");
            System.Console.WriteLine("");
            System.Console.ReadKey();

            StopService(hostInventoryManager, "InventoryManager");

            System.Console.WriteLine("");
            System.Console.ReadKey();
        }
Пример #11
0
        public void Open(ICallbackProcessor callbackProcessor)
        {
            var callbackChannel = new MosquitoCallbackChannelImpl(callbackProcessor);

            _serviceHost = new System.ServiceModel.ServiceHost(callbackChannel);
            _serviceHost.Open();
        }
 public void PassArgumentsFromServiceHost(System.ServiceModel.ServiceHost serviceHost)
 {
     if (_createOutputAction != null)
     {
         _createOutputAction.UpdateURL(serviceHost.Description.Endpoints.FirstOrDefault().ListenUri.ToString());
     }
 }
Пример #13
0
        static void Main()
        {
            using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(WCFReportingservice.Reportingservice)))
            {
                //--------To configure service behavior ,contract ,binding and address in code instead of config file
                //host.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled =true });
                //host.AddServiceEndpoint(typeof(WCFReportingservice.IPublicReportingservice), new BasicHttpBinding(), "Reportingservice");
                //host.AddServiceEndpoint(typeof(WCFReportingservice.IPrivateReportingservice), new NetTcpBinding(), "Reportingservice");
                //host.AddServiceEndpoint(typeof(WCFReportingservice.IWCFEmployeeservice), new BasicHttpBinding(), "WCFEmployeeservice");

                //Throttling settings for the service in code .. can be done thru Config file also
                //System.ServiceModel.Description.ServiceThrottlingBehavior throttlingBehavior = new System.ServiceModel.Description.ServiceThrottlingBehavior
                //{
                //    MaxConcurrentCalls = 3,
                //    MaxConcurrentInstances = 3,
                //    MaxConcurrentSessions = 100
                //};
                //host.Description.Behaviors.Add(throttlingBehavior);

                host.Open();

                Console.WriteLine("Console WCF Host started @ " + DateTime.Now.ToString());

                Console.WriteLine(typeof(WCFReportingservice.FullTimeEmployee));

                Console.ReadLine();
            }
        }
Пример #14
0
        protected override void OnStart(string[] args)
        {
            // Even though the service isn't running yet, the message will sent via MSMQ,
            // so when the logging service starts it will get this message and log it.
            LoggingUtility.LogDebug("OnStart", "AirtimeBilling.LoggingService.ServiceHost.Service.LoggingService",
                                    "Starting Services");

            if (emailHost != null) emailHost.Close();
            if (activityHost != null) activityHost.Close();
            if (debugHost != null) debugHost.Close();
            if (errorHost != null) errorHost.Close();

            emailHost = new System.ServiceModel.ServiceHost(typeof(EmailService));
            activityHost = new System.ServiceModel.ServiceHost(typeof(ActivityLoggingService));
            debugHost = new System.ServiceModel.ServiceHost(typeof(DebugService));
            errorHost = new System.ServiceModel.ServiceHost(typeof(ErrorService));

            emailHost.Open();
            activityHost.Open();
            debugHost.Open();
            errorHost.Open();

            LoggingUtility.LogDebug("OnStart", "AirtimeBilling.LoggingService.ServiceHost.Service.LoggingService",
                                    "Started Services");
        }
Пример #15
0
        static void Main(string[] args)
        {
            var host = new System.ServiceModel.ServiceHost(typeof(WcfServiceLibrary1.Service1));

            Console.WriteLine("Service gestartet. Mit Enter beenden...");
            Console.ReadLine();
        }
Пример #16
0
        private void _load_soap_host()
        {
            Uri _soap_http_url = new Uri(
                System.Configuration.ConfigurationManager.AppSettings["SOAP_HTTP_Url"]);

            _soap_service_host = new System.ServiceModel.ServiceHost(wcf_service, _soap_http_url);

            //Añadimos endopoint soap
            System.ServiceModel.Description.ServiceEndpoint epoint =
                _soap_service_host.AddServiceEndpoint(_service_interface,
                                                      new System.ServiceModel.BasicHttpBinding(), _soap_http_url);



            //Habilitamos metadata para este endpoint
            System.ServiceModel.Description.ServiceMetadataBehavior mthttp =
                _soap_service_host.Description.Behaviors.Find <System.ServiceModel.Description.ServiceMetadataBehavior>();


            if (mthttp != null)
            {
                mthttp.HttpGetEnabled = true;
            }
            else
            {
                mthttp = new System.ServiceModel.Description.ServiceMetadataBehavior();
                mthttp.HttpGetEnabled = true;

                _soap_service_host.Description.Behaviors.Add(mthttp);
            }
        }
Пример #17
0
        /// <summary>
        /// When implemented in a derived class, executes when a Start command is sent to the service by the Service Control Manager (SCM) or when the operating system starts (for a service that starts automatically). Specifies actions to take when the service starts.
        /// </summary>
        /// <param name="args">Data passed by the start command.</param>
        protected override void OnStart(string[] args)
        {
            this.OnStop(false);
            KillAllCreatorApplications();

            // Create a ServiceHost for the each service type and provide the base address.
            adminConfigServiceHost        = new System.ServiceModel.ServiceHost(typeof(Web.Admin.ConfigurationService));
            configurationServiceHost      = new System.ServiceModel.ServiceHost(typeof(Web.Pivot.ConfigurationService));
            publishingServiceHost         = new System.ServiceModel.ServiceHost(typeof(Web.Pivot.PublishingService));
            dataModelServiceHost          = new System.ServiceModel.ServiceHost(typeof(Web.Data.DataModelService));
            resourceTypeServiceHost       = new System.ServiceModel.ServiceHost(typeof(Web.Data.ResourceTypeService));
            publishingProgressServiceHost = new System.ServiceModel.ServiceHost(typeof(Web.Pivot.PublishingProgressService));

            // Open the ServiceHostBase to create listeners and start
            // listening for messages.
            adminConfigServiceHost.Open();
            configurationServiceHost.Open();
            publishingServiceHost.Open();
            dataModelServiceHost.Open();
            resourceTypeServiceHost.Open();
            publishingProgressServiceHost.Open();

            Thread initThread = new Thread(InitializeService)
            {
                IsBackground = true
            };

            initThread.Start();
        }
Пример #18
0
        public void ThreadMethod()
        {
            try
            {
                // Start the host
                this.serviceHost = new System.ServiceModel.ServiceHost(typeof(EFTConnectSvc));
                foreach (var endpoint in serviceHost.Description.Endpoints)
                {
                    //endpoint.Behaviors.Add(
                }

                this.serviceHost.Open();

                while (m_running)
                {
                    // Wait until thread is stopped
                    System.Threading.Thread.Sleep(SleepTime);
                }

                // Stop the host
                this.serviceHost.Close();
            }
            catch (Exception ex) {
                log.Error(ex);
                this.EventLogger(ex.Message, EventLogEntryType.Error);
            }
        }
Пример #19
0
 protected override void OnStop()
 {
     if (host != null)
     {
         host.Close();
         host = null;
     }
 }
Пример #20
0
 public static void ServiceStart(System.ServiceModel.ServiceHost host)
 {
     Console.WriteLine(string.Format("服务启动:{0}", host.Description.Name));
     foreach (System.ServiceModel.Description.ServiceEndpoint endpoint in host.Description.Endpoints)
     {
         Console.WriteLine(string.Format("   {0}", endpoint.Address));
     }
 }
Пример #21
0
 private void StartService()
 {
     host = new System.ServiceModel.ServiceHost(typeof(PushPollService.Invoke));
     host.Open();
     btn_start.Enabled = false;
     btn_stop.Enabled  = true;
     lbl_message.Text  = "Service Started @ " + DateTime.Now.ToString();
 }
Пример #22
0
        static void Main(string[] args)
        {
            var host = new System.ServiceModel.ServiceHost(typeof(ConsoleWCF.Service1));
            host.Open();

            Console.WriteLine("Service is running");
            Console.ReadLine();
        }
 public void Dispose()
 {
     if (_Host != null)
     {
         _Host.Abort();
     }
     _Host = null;
 }
Пример #24
0
 static void Main(string[] args)
 {
     using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(WcfService.LibraryService)))
     {
         host.Open();
         Console.ReadLine();
     }
 }
Пример #25
0
        static void Main(string[] args)
        {
            var host = new System.ServiceModel.ServiceHost(typeof(ConsoleWCF.Service1));

            host.Open();

            Console.WriteLine("Service is running");
            Console.ReadLine();
        }
Пример #26
0
 static void Main()
 {
     using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(CompanyService.CompanyService)))
     {
         host.Open();
         Console.WriteLine("Host started in @ " + DateTime.Now.ToString());
         Console.ReadLine();
     }
 }
Пример #27
0
        static void Main(string[] args)
        {
            var host = new System.ServiceModel.ServiceHost(typeof(UserInfo));

            host.Open();
            Console.WriteLine("http://localhost:8028/UserInfo");
            Console.ReadLine();
            host.Close();
        }
Пример #28
0
 public static void CreateHost()
 {
     using (System.ServiceModel.ServiceHost host = new
                                                   System.ServiceModel.ServiceHost(typeof(CadWebService)))
     {
         host.Open();
         Console.WriteLine("Host started @ " + DateTime.Now.ToString());
         Console.ReadLine();
     }
 }
Пример #29
0
 static void Main(string[] args)
 {
     using (System.ServiceModel.ServiceHost serviceHost = new System.ServiceModel.ServiceHost(typeof(Service1)))
     {
         serviceHost.Open();
         Console.WriteLine("Сервис запущен...");
         Console.WriteLine("Нажмите любую клавишу для остановки...");
         Console.ReadKey();
     }
 }
Пример #30
0
 static void Main(string[] args)
 {
     using (System.ServiceModel.ServiceHost host = new
                                                   System.ServiceModel.ServiceHost(typeof(PosWebService.PosWebService)))
     {
         host.Open();
         Console.WriteLine("Host started @ " + DateTime.Now.ToString());
         Console.ReadLine();
     }
 }
Пример #31
0
        protected override void OnStart(string[] args)
        {
            string apiHostUri  = ConfigurationManager.AppSettings["ApiHostUri"];
            Uri    baseAddress = new Uri(apiHostUri);

            MiracleSticksAPI msAPI = new MiracleSticksAPI();

            host = new System.ServiceModel.ServiceHost(msAPI, baseAddress);
            host.Open();
        }
Пример #32
0
 static void Main(string[] args)
 {
     using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost
                                                       (typeof(ConsumerManagementService.ConsumerManagementService)))
     {
         host.Open();
         Console.WriteLine("Host started, Press any key to stop...");
         Console.ReadLine();
     }
 }
Пример #33
0
 protected override void OnStart(string[] args)
 {
     if (host != null)
     {
         host.Close();
         host = null;
     }
     host = new XServiceHost(typeof(SGM.ECountJQ.UPG.Service.Service));
     host.Open();
 }
 static void Main(string[] args)
 {
     _server = new ChattingService();
     // start the server
     using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(_server))
     {
         host.Open();
         Console.WriteLine("Server is running...");
         Console.ReadLine();
     }
 }
Пример #35
0
        static void Main(string[] args)
        {
            Uri address = new Uri(@"http://localhost:49661/Service1.svc");

            System.ServiceModel.ServiceHost      host    = new System.ServiceModel.ServiceHost(typeof(MIC), address);
            System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
            host.AddServiceEndpoint(typeof(IMIC), binding, address);
            host.Open();
            Console.WriteLine("Able to operate");
            Console.ReadLine();
        }
Пример #36
0
        public WindowsService(IEtlService etlService)
        {
            //_serviceHost = new UnityServiceHost(Program.UnityContainer, typeof(DefaultEtlWebService));
            //_serviceHost = new System.ServiceModel.ServiceHost(typeof (DefaultEtlWebService));

            //var section = ConfigurationManager.GetSection("system.serviceModel/services") as ServicesSection;
            //var element = section.Services.Cast<ServiceElement>().Single();
            //var address = element.Endpoints.Cast<ServiceEndpointElement>().Select(s => s.Address);
            _serviceHost = new UnityServiceHost(Program.UnityContainer, typeof(DefaultEtlWebService));

        }
Пример #37
0
        static void Main(string[] args)
        {
            // Create a ServiceHost for the CaseStudyService type.
            System.ServiceModel.ServiceHost serviceHost = new
                System.ServiceModel.ServiceHost(typeof(SampleServices.Service));


            // Open the ServiceHost to create listeners and start listening for messages.
            serviceHost.Open();
            Console.WriteLine("Services are ready & running.");
            Console.WriteLine();
            Console.ReadLine();
        }
Пример #38
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     try
     {
         WCFService broadcastSvc = new WCFService();
         m_Host = new System.ServiceModel.ServiceHost(broadcastSvc);
         m_Host.Open();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 protected override void OnStop()
 {
     try
     {
         if (ServiceHost != null)
         {
             ServiceHost.Close();
             ServiceHost = null;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #40
0
        static void Main(string[] args)
        {
            var selfHost = new System.ServiceModel.ServiceHost(typeof(QualityBotService));

            selfHost.Open();

            Console.WriteLine("QualityBotService is up and running with the following endpoints:");
            foreach (ServiceEndpoint se in selfHost.Description.Endpoints)
            {
                Console.WriteLine(se.Address.ToString());
            }

            Console.ReadLine();

            selfHost.Close();
        }
 protected override void OnStart(string[] args)
 {
     try
     {
         if (ServiceHost != null)
         {
             ServiceHost.Close();
         }
         ServiceHost = new System.ServiceModel.ServiceHost(typeof(Service1));
         ServiceHost.Open();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #42
0
 static void Main(string[] args)
 {
     try
     {
         RoomService.Library.RoomService.Initialize();
         System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(RoomService.Library.RoomService));
         host.Open();
         Console.WriteLine("Room Service OK : ");
         Console.WriteLine(host.BaseAddresses[0].AbsoluteUri);
         Console.Read();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.Read();
     }
 }
Пример #43
0
        static void Main(string[] args)
        {
            var sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();

            var serviceNamespace = "msswit2013relay";
            var issuerName = "owner";
            var issuerSecret = "IqyIwa7gNjBO89HT+3Vd1CcoBbyibvcv6Hd92J+FtPg=";

            sharedSecretServiceBusCredential.TokenProvider =
                TokenProvider.CreateSharedSecretTokenProvider(
                    issuerName,
                    issuerSecret);

            Uri address =
                ServiceBusEnvironment.CreateServiceUri(
                    "sb",
                    serviceNamespace,
                    "Service");

            ServiceBusEnvironment.SystemConnectivity.Mode =
                ConnectivityMode.AutoDetect;

            var host = new System.ServiceModel.ServiceHost(
                typeof(Service),
                address);

            IEndpointBehavior serviceRegistrySettings =
                new ServiceRegistrySettings(DiscoveryType.Public);

            foreach (ServiceEndpoint endpoint in host.Description.Endpoints)
            {
                endpoint.Behaviors.Add(serviceRegistrySettings);
                endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
            }

            host.Open();

            Console.WriteLine("Service address: " + address);
            Console.WriteLine("Press [Enter] to close");
            Console.ReadLine();

            host.Close();
        }
Пример #44
0
        private void _load_soap_host()
        {
            Uri _soap_http_url = new Uri(
                System.Configuration.ConfigurationManager.AppSettings["SOAP_HTTP_Url"]);
            _soap_service_host = new System.ServiceModel.ServiceHost(wcf_service, _soap_http_url);

            //Añadimos endopoint soap
            System.ServiceModel.Description.ServiceEndpoint epoint =
                _soap_service_host.AddServiceEndpoint(_service_interface,
                    new System.ServiceModel.BasicHttpBinding(), _soap_http_url);

            //Habilitamos metadata para este endpoint
            System.ServiceModel.Description.ServiceMetadataBehavior mthttp =
                _soap_service_host.Description.Behaviors.Find<System.ServiceModel.Description.ServiceMetadataBehavior>();

            if (mthttp != null)
            {
                mthttp.HttpGetEnabled = true;
            }
            else
            {
                mthttp = new System.ServiceModel.Description.ServiceMetadataBehavior();
                mthttp.HttpGetEnabled = true;

                _soap_service_host.Description.Behaviors.Add(mthttp);
            }
        }
Пример #45
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            log.Info("Starting program");

            //Loading configuration from file
            try
            {
                config = new ConfLoader().loadConfFromFile("LMAX_sender_config.txt");
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                log.Debug(e.StackTrace.ToString());
                log.Error("Exit program");
                return;
            }
            random = new Random((int)DateTime.Now.Ticks / 10000);
            isQuit = isRefrash = false;
            Thread t = new Thread(new ThreadStart(KeyReadHandler));
            t.Name = "Key handler thread";
            t.Start();

            syncUsers = new List<string>();
            NewUsers  = new List<string>();

            //Create lock objects
            usersLock      = new Object();
            errorWriteLock = new Object();
            mustSyncLock   = new Object();
            randomLock     = new Object();
            newUserLock    = new Object();

            //Create necessary datas
            BlockingCollection<Operations>  blokingQueue = new BlockingCollection<Operations>();

            //create sender db handler
            dbHandler = new ErrorDbHandler();

            //create object for manipulat with local DB
            localDbHandler = new LocalDbHandler();

            //Create error handler class for error solutions
            ErrorHandler errorHandler = new ErrorHandler("ytsnotify", "YTS_admin password");

            // Get datas from DB about users
            remoteDbHandler = new DataBase();

            try
            {
                lock (usersLock)
                {
                    idUsers = remoteDbHandler.getConnectedUsers(dbHandler, errorHandler);
                    /*
                    idUsers = new Dictionary<int, List<TradingClass>>();
                    List<TradingClass> list1 = new List<TradingClass>();
                    List<TradingClass> list2 = new List<TradingClass>();

                    for (int i = 0; i < 2; ++i)
                    {
                        list.Add(new TradingClass("user_"+i,"userName_"+i,"Passwd_0"+i,"URL","userEmail",dbHandler));
                        list[i].Login();
                        Console.WriteLine("\tConnected users {0}", i);
                    }

                    list1.Add(new TradingClass("user_1", "userName_1", "Passwd_1", "URL", "userEmail", dbHandler));
                    list2.Add(new TradingClass("user_2", "userName_2", "Passwd_2", "URL", "userEmail", dbHandler));
                    list1[0].Login();
                    list2[0].Login();
                    idUsers.Add(10001, list1);
                    idUsers.Add(10002, list2);*/
                }
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                log.Debug(e.StackTrace.ToString());
                log.Error("Exit program");
                log.Info("Exit program becouse of error");
                return;
            }
            System.Console.WriteLine("Get {0} users from DB", idUsers.Values.Count);

            //Create class for user control directly after create users
            externalClientManager = new ExternalClientManager();

            //Create listen port
            Type serviceType = typeof(ExternalClientManager);
            Uri  serviceUri  = new Uri("http://localhost:9081/");
            System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(serviceType, serviceUri);
            host.Open();

            // Start NETlistener to get new users from DB
            //NETlistener netListener = new NETlistener();

            DateTime time0 = new DateTime();
            DateTime oTime = new DateTime();

            //Create time reader from file
            DateFileWritter dateFile = new DateFileWritter();

            time0 = dateFile.ReadTime();

            //Create systemContainer to cach DB lastest data
            systemContainer = new SystemContainer(blokingQueue,time0);

            //Create sender class
            SenderClass sender = new SenderClass(blokingQueue);

            List<DBResult> res = new List<DBResult>();

            Console.WriteLine("Loaded time value : {0}", time0.ToString("yyyy-MM-dd HH:mm:ss.fff"));

            long start;
            long finish;
            long waitTime;

            while (true)
            {
                if (isQuit)
                {
                    Console.WriteLine("Buy....");
                    return;
                }
                //Створити нових фоловерів якщо вони є в списку
                //CreateFromMarketFollowers(time0);
                //Вирішити проблеми синхронізації
                ProcessUsersSolveProblem(time0);

                start = DateTime.Now.Ticks / 10000;

                res = (List<DBResult>)remoteDbHandler.GetDBResult(time0);

                if(res != null && res.Count > 0)
                {
                    System.Console.WriteLine("Get results : {0}", res.Count);
                    oTime = time0;
                    time0 = res[0].DbTime;
                    dateFile.WriteTime(time0);

                    foreach (DBResult item in res)
                    {
                        systemContainer.AddElement(item);
                    }
                    systemContainer.processSystems(idUsers, oTime);
                }

                finish = DateTime.Now.Ticks / 10000;
                waitTime = MUST_WAIT - (finish - start);

                if (waitTime > 0)
                {
                    Thread.Sleep((int)waitTime);
                }
                Console.WriteLine("wait in main loop");
            }
            //netListener.ShutDown();
            sender.ShutDown();
        }
Пример #46
0
        static void Main(string[] args)
        {
            try
            {
                Uri storageBaseAddress = new Uri("http://localhost:8080/s3storageGateway");
                Uri preBaseAddress = new Uri("http://localhost:8080/s3pre");

                Logger.Initialize();
                Logger.LogInfo("ServiceHost is starting...");

                if (WinSecurity.IsVistaOrHigher() && !WinSecurity.IsAdmin())
                {
                    Console.WriteLine("This application requires administrator rights to work");
                    Console.WriteLine("Press any key to restart the application with administrative rights, or close the program to exit...");
                    Console.ReadKey();

                    Logger.LogInfo("Restarting process as admin");

                    WinSecurity.RestartElevated();
                    return;
                }

                System.ServiceModel.ServiceHost storageHost =
                    new System.ServiceModel.ServiceHost(typeof(StorageService), storageBaseAddress);

                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                storageHost.Description.Behaviors.Add(smb);

                // Add application endpoint
                storageHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
                                        MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

                storageHost.AddServiceEndpoint(typeof(IGatewayService), ProxyFactory.CreateBinding(), "");

                System.ServiceModel.ServiceHost preHost =
                    new System.ServiceModel.ServiceHost(typeof(PreService), preBaseAddress);

                smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                preHost.Description.Behaviors.Add(smb);

                // Add application endpoint
                preHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
                                        MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

                preHost.AddServiceEndpoint(typeof(IPreService), ProxyFactory.CreateBinding(), "");

                preHost.Open();
                storageHost.Open();

                Logger.LogInfo("ServiceHosts are ready...");

                Console.WriteLine("The storage services is ready at {0}", storageBaseAddress);
                Console.WriteLine("The pre services is ready at {0}", preBaseAddress);
                Console.WriteLine("Press <Enter> to stop the services.");
                Console.ReadKey();

                Console.WriteLine();

                Logger.LogInfo("ServiceHosts are closing...");

                preHost.Close();
                storageHost.Close();

                Console.WriteLine("Services have been closed");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error hosting services. See log for details.");
                Logger.LogError("Unhandled exception in service hoster", e);
            }

            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
        }
Пример #47
0
 /// <summary>
 /// Opens the host using the specified type.
 /// </summary>
 /// <param name="hostType">The host type.</param>
 private void OpenHost(Type hostType)
 {
     // Create the host
     System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(hostType);
     // Open the host
     OpenHost(host);
 }
Пример #48
0
        private void BackgroundInit()
        {
            WriteEventLog("Initializing background Init for GwupeService" + BuildMarker);
            XmlConfigurator.Configure(Assembly.GetExecutingAssembly().GetManifestResourceStream("Gwupe.Service.log4net.xml"));
            WriteEventLog("Got log4net resource location for GwupeService" + BuildMarker);
            Logger.Debug("Got log4net resource location for GwupeService" + BuildMarker);
            _version =
                Regex.Replace(FileVersionInfo.GetVersionInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) +
                                                             "/Gwupe.Agent.exe").FileVersion, "\\.[0-9]+$", "");
            WriteEventLog("Determined Version for GwupeService" + BuildMarker);
            Logger.Debug("Determined Version for GwupeService" + BuildMarker);
            Logger.Info("Gwupe Service Starting Up [" + Environment.UserName + ", " + _version + "]");
            SaveVersion();
            WriteEventLog("Saved Version for GwupeService" + BuildMarker);
            Logger.Debug("Saved Version for GwupeService" + BuildMarker);
            #if DEBUG
            foreach (var manifestResourceName in Assembly.GetExecutingAssembly().GetManifestResourceNames())
            {
                Logger.Debug("Embedded Resource : " + manifestResourceName);
            }
            #endif
            // Check for update on startup

            // check for updates every interval
            _updateCheck = new Timer(UpdateCheckInterval * 1000);
            _updateCheck.Elapsed += delegate { CheckForNewVersion(); };
            _updateCheck.Start();
            WriteEventLog("Started update check timer for GwupeService" + BuildMarker);
            Logger.Debug("Started update check timer for GwupeService" + BuildMarker);
            initServers();
            WriteEventLog("Initialized servers for GwupeService" + BuildMarker);
            Logger.Debug("Initialized servers for GwupeService" + BuildMarker);
            _serviceHost = new System.ServiceModel.ServiceHost(new ServiceHost.GwupeService(this),
                new Uri("net.pipe://localhost/GwupeService" + BuildMarker));
            _serviceHost.Open();
            WriteEventLog("Opened Service Host for GwupeService" + BuildMarker);
            Logger.Debug("Opened Service Host for GwupeService" + BuildMarker);
            Logger.Info("Gwupe Service Init Complete [" + Environment.UserName + ", " + _version + "]");
        }
Пример #49
0
        public void ConfiguredStart()
        {

            guiService.ConfiguredStart();

            //initialize the scout helper; needed for scouts that rely on upnp discovery
            ScoutHelper.Init(logger);

            //start the configured scouts. starting scouts before modules.
            foreach (var sInfo in config.GetAllScouts())
            {
                StartScout(sInfo);
            }

            //start the heartbeat service (directly writes to cloud)
            if (Settings.HeartbeatServiceMode != "Off")
            {
                InitHeartbeatService();
            }

            //config updater
            if(this.configLookup==null)
            {
                ConfigUpdater configLookup = null;
                LoadConfig loadNewConfig = this.LoadConfigFromDir;

                configLookup = new ConfigUpdater(null, logger, Settings.ConfigLookupFrequency, loadNewConfig, this);
                this.configLookup = configLookup;
                if (this.configLookup != null)
                {
                    this.configLookup.setConfig(this.config);
                }

            }

            // start the authentication service
            {
                authenticationService = new HomeOS.Hub.Platform.Authentication.AuthenticationService(logger, this);
                authenticationServiceHost = HomeOS.Hub.Platform.Authentication.AuthenticationService.CreateServiceHost(logger, this, authenticationService);
                authenticationServiceHost.Open();
            }

            InitHomeService();

            if (Settings.RunningMode.Equals("standard"))
            {
                InitAutoStartModules();
            }
            else
            #region developers' running modes
            {
                if (Settings.RunningMode.Equals("unittesting"))
                {

                    // don't start any modules, we just need a module-less platform to initialize the module (app/device)
                    // being unit tested
                }
                else if (Settings.RunningMode.Equals("ratul"))
                {
                    //StartModule(new ModuleInfo("axiscamdriver", "DriverAxisCamera", "DriverAxisCamera", null, false, "192.168.0.198", "root", "homeos"));
                    //StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "192.168.1.125", "admin", ""));
                    
                    StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "HomeOS.Hub.Drivers.WebCam", null, false, @"Microsoft® LifeCam VX-7000"));
                    StartModule(new ModuleInfo("AppCam", "AppCamera", "HomeOS.Hub.Apps.SmartCam", null, false));

                    //string para1 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                    //string para2 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                    //StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));                   

                    //StartModule(new ModuleInfo("HomeOS.Hub.Drivers.Gadgeteer.MicrosoftResearch.WindowCamera for HomeOSGadgeteerDevice_WindowCamera_MicrosoftResearch_65355695098562951548", "DriverGadgetCamera", "HomeOS.Hub.Drivers.Gadgeteer.MicrosoftResearch.WindowCamera", null, false, "192.168.0.197"));

                    //StartModule(new ModuleInfo("zwavezensys", "DriverZwaveZensys", "HomeOS.Hub.Drivers.ZwaveZensys_4_55", null, false));
                    //StartModule(new ModuleInfo("switchapp", "AppSwitch", "HomeOS.Hub.Apps.Switch", null, false));

                    //StartModule(new ModuleInfo("alerts", "AppAlerts", "HomeOS.Hub.Apps.Alerts", null, false));

                    //StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "192.168.1.125", "admin", ""));

                    //StartModule(new ModuleInfo("AppDummy1", "AppDummy1", "HomeOS.Hub.Apps.Dummy", null, false, null));
                    //StartModule(new ModuleInfo("DriverDummy1", "DriverDummy1", "HomeOS.Hub.Drivers.Dummy", null, false, null));
                }
                else if (Settings.RunningMode.Equals("rayman"))
                {
                    ModuleInfo d = new ModuleInfo("HomeOS.Hub.Drivers.Mic", "HomeOS.Hub.Drivers.Mic", "HomeOS.Hub.Drivers.Mic", null, false,"foo", "8000", "1" );
                    StartModule(d);

                    /*
                    HomeOS.Hub.Platform.Authentication.AuthenticationService auth = new HomeOS.Hub.Platform.Authentication.AuthenticationService(logger, this);
                    System.ServiceModel.ServiceHost s = HomeOS.Hub.Platform.Authentication.AuthenticationService.CreateServiceHost(logger, this, auth);
                    s.Open();


                    ModuleInfo app = new ModuleInfo("AppDummy1", "AppDummy1", "HomeOS.Hub.Apps.Dummy", null, false, null);
                    StartModule(app);
                    ModuleInfo app1 = new ModuleInfo("DriverDummy1", "DriverDummy1", "HomeOS.Hub.Drivers.Dummy", null, false, null);
                    StartModule(app1);
                    
                    HomeOS.Hub.Common.TokenHandler.SafeTokenHandler t = new Common.TokenHandler.SafeTokenHandler("randomsalt");
                    string s1 = t.GenerateToken("helloworlergwergwergwergwergwegrwegewgewrgwergwregwgwgd"); 
                    logger.Log("Encryting helloworld: "+s1);
                    t = null;
                    t = new Common.TokenHandler.SafeTokenHandler("randomsalt");
                    logger.Log("decrypting token: " + t.ProcessToken(s1).Name);*/


                    //    DateTime t = policyEngine.AllowAccess("*","AppDummy1", "jeff");
                    //    logger.Log(">>>>>>>>>>> " + t.ToString()+ "  , " + DateTime.Now);


                    // Dont touch my running mode
                    /*
                     AddInToken t =  null ; 
                         foreach (AddInToken token in allAddinTokens)
                         {
                             if (token.Name.Equals("HomeOS.Hub.Drivers.Dummy") )
                             {
                                 t = token ; 
                             }
                         }
                         VModule a = t.Activate<VModule>(AddInSecurityLevel.FullTrust);
                      ModuleInfo info = new ModuleInfo("friendlyName", "moduleName", "moduleName", null, false, null);
                         AddInController aic = AddInController.GetAddInController(a);
                         a.Initialize(this, logger,info, 0);
                         SafeThread moduleThread = new SafeThread(delegate() { a.Start(); },"", logger);
                         moduleThread.Start();
                         System.Threading.Thread.Sleep(1 * 11 * 1000);
                         aic.Shutdown();
                    

                     ModuleInfo[] app = new ModuleInfo[100];
                     int i;
                     for (i = 0; i < 30; i++)
                     {
                         app[i] = new ModuleInfo("AppDummy"+i.ToString(), "AppDummy"+i.ToString(), "HomeOS.Hub.Apps.Dummy", null, false, null);
                         StartModule(app[i]);
                     }
            

                 

                     ModuleInfo[] driver = new ModuleInfo[3000]; 
                     int j;
                     for (j = 0; j <30; j++)
                     {
                         driver[j] = new ModuleInfo("DriverDummy"+j.ToString(), "DriverDummy"+j.ToString(), "HomeOS.Hub.Drivers.Dummy", null, false, null);
                         StartModule(driver[j]);
                     }
            
                     System.Threading.Thread.Sleep(1 * 20 * 1000);
                    
                     
                     for (j = 29; j >=0; j--)
                     {
                         StopModule(runningModules.First(x => x.Value.Equals(driver[j])).Key.Secret());

                     }
                     for (i = 29;i >= 1; i--)
                     {
                         StopModule(runningModules.First(x => x.Value.Equals(app[j])).Key.Secret());

                     }
          */


                }
                else if (Settings.RunningMode.Equals("chunte"))
                {
                    //StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "logitech"));
                    //StartModule(new ModuleInfo("foscamdriver", "DriverFoscam", "DriverFoscam", null, false, "192.168.0.196", "admin", "whoareyou?"));
                    //StartModule(new ModuleInfo("foscamdriver", "DriverFoscam", "DriverFoscam", null, false, "172.31.42.177", "admin", ""));
                    string video1 = "c:\\img\\cam2_20120821165455_test1.avi";
                    string video2 = "c:\\img\\DSCN7066_test1.avi";
                    StartModule(new ModuleInfo("loadvideo1", "DriverVideoLoading", "DriverVideoLoading", null, false, video1));
                    StartModule(new ModuleInfo("loadvideo2", "DriverVideoLoading", "DriverVideoLoading", null, false, video2));
                    //StartModule(new ModuleInfo("cameraapp", "AppCamera", "AppCamera", null, false));

                    string para1 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                    string para2 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                    StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                }
                else if (Settings.RunningMode.Contains("khurshed"))
                {
                    if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam"))
                    {
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "HomeOS.Hub.Apps.SmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam_notifications"))
                    {
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_webcam"))
                    {
                        StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "Logitech QuickCam Pro 9000"));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam_webcam"))
                    {
                        StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "Logitech QuickCam Pro 9000"));
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_tracking_foscam"))
                    {
                        string para1 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                        string para2 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_tracking_videoloading"))
                    {
                        string video1 = "c:\\img\\cam2_20120821165455_test1.avi";
                        string video2 = "c:\\img\\DSCN7066_test1.avi";
                        StartModule(new ModuleInfo("loadvideo1", "DriverVideoLoading", "DriverVideoLoading", null, false, video1));
                        StartModule(new ModuleInfo("loadvideo2", "DriverVideoLoading", "DriverVideoLoading", null, false, video2));
                        string para1 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                        string para2 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                        StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                    }
                }
                else if (Settings.RunningMode.Equals("jamie"))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(new XmlTextReader(@"C:\homeos\LightSettings.xml"));

                    XmlNode xmlData = xmlDoc.SelectSingleNode("data");
                    string strLightsIP = xmlData.SelectSingleNode("lightsIP").InnerText;
                    string strLightsUser = xmlData.SelectSingleNode("lightsUser").InnerText;
                    string strfoscamIP = xmlData.SelectSingleNode("foscamIP").InnerText;
                    string strfoscamUser = xmlData.SelectSingleNode("foscamUser").InnerText;
                    string strLightCount = xmlData.SelectSingleNode("light_count").InnerText;

                    StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, strfoscamIP, strfoscamUser, ""));
                    StartModule(new ModuleInfo("huedriver1", "HueBridge", "HomeOS.Hub.Drivers.HueBridge", null, false, strLightsIP, strLightsUser, strLightCount));
                    StartModule(new ModuleInfo("LightsHome1", "LightsHome", "HomeOS.Hub.Apps.LightsHome", null, false));
                }
                else if (Settings.RunningMode.Equals("sarah"))
                {
                    //Sarah to fill in the right device id
                    StartModule(new ModuleInfo("couchdriver", "DriverCouch", "HomeOS.Hub.Drivers.GadgetCouch", null, false, ".."));
                    StartModule(new ModuleInfo("couchapp", "EmotoCouch", "HomeOS.Hub.Apps.EmotoCouch", null, false));
                }
                else if (Settings.RunningMode.Equals("erin"))
                {
                    //app startup needed since it's not in the install repository
                    StartModule(new ModuleInfo("AppDoorjamb", "AppDoorjamb", "HomeOS.Hub.Apps.Doorjamb", null, false));
                }
                else
                {
                    throw new Exception("Unknown running mode: " + Settings.RunningMode);
                }

                //we ran using a non-standard running mode
                //make sure that the modules we ran are entered in the config, so that we can keep it consistent
                //otherwise, a service (port) will get added without its exporting module
                lock (this)
                {
                    foreach (ModuleInfo moduleInfo in runningModules.Values)
                    {
                        if (moduleInfo.GetManifest() == null)
                            moduleInfo.SetManifest(new Manifest());

                        config.AddModuleIfMissing(moduleInfo);
                    }
                }

            }
            #endregion


            if (String.IsNullOrEmpty(Settings.WifiSsid))
                logger.Log("Warning: WiFi credentials are not configured");

            if (!Settings.StayOffline)
            {
                //start checking for the uniqueness of home id on a separate thread
                SafeThread uniqueHomeIdCheck = new SafeThread(delegate()
                {
                    heartbeatService.CanIClaimHomeId(Utils.HardwareId, Settings.HomeId, UniqueHomeIdCheckCompleted);
                }, "UniqueHomeIdCheck", logger);

                uniqueHomeIdCheck.Start();
            }
        }
Пример #50
0
    static void start_service()
    {
      using (var host = new System.ServiceModel.ServiceHost(typeof(ServiceT)))
      {

        host.AddServiceEndpoint(typeof(IServiceT), new System.ServiceModel.NetTcpBinding(), new Uri(addr));
        host.Open();
        WriteLine("Listening at:");
        foreach (var e in host.Description.Endpoints) WriteLine(e.Address.Uri);
        WriteLine("Press ENTER to exit");
        ReadLine();
      }
    }
Пример #51
0
        public void InitialiseServer()
        {
            var server = new System.ServiceModel.ServiceHost(typeof(Wcf.ServiceServer));

            ScenarioContext.Current.Set(server);
        }