Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inServiceHost"></param>
        /// <returns></returns>
        protected bool OpenServiceHost(ServiceHost inServiceHost)
        {
            bool result = false;

            try
            {
                inServiceHost.Open();
                LogServiceInformation(inServiceHost);

                result = true;
            }
            catch (SystemException e)
            {
                ServiceLogger.LogException(String.Format("{0} Service Host failed to open.", inServiceHost.Description.Name), e);
            }
            catch (Exception e)
            {
                ServiceLogger.LogException(String.Format("{0} Service Host Service failed to open: {1}", inServiceHost.Description.Name, e.Message), e);
            }
            finally
            {
                //inServiceHost.Close();
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected virtual int Execute()
        {
            if (_failedToStart)
            {
                int timeDiff = m_tickCount.CompareTo(DateTime.Now);

                if (timeDiff <= 0)
                {
                    try
                    {
                        _failedToStart = !startServiceTask();

                        if (_failedToStart)
                        {
                            setTickCountInMin(1); // This make startService() to be called every minute if it fails
                        }
                    }
                    catch (Exception e)
                    {
                        ServiceLogger.LogException(String.Format(@"Error starting {0} service", ServiceName), e);
                    }
                }
            }

            return(-1);
        }
Ejemplo n.º 3
0
 private void AddService(List <ServiceBase> services, MenumateServicesIdentifier serviceIdentifier)
 {
     try
     {
         services.Add(LoadService(serviceIdentifier));
     }
     catch (Exception e)
     {
         ServiceLogger.LogException(String.Format(@"Error loading Service {0}. Does this file really exist?", serviceName(serviceIdentifier)), e);
     }
 }
Ejemplo n.º 4
0
        //:::::::::::::::::::::::::::::::::

        /// <summary>
        /// Load all WCF Services: The Service IDs are in an XML configuration file
        /// </summary>
        /// <param name="inConfigFilename"></param>
        /// <returns></returns>
        public List <ServiceHost> LoadWebServices(string inConfigFilename)
        {
            try
            {
                return(LoadWebServicesFromXML(ServiceInfo.GetXMLDocFromFile(inConfigFilename)));
            }
            catch (System.Xml.XmlException xe)
            {
                string message = String.Format("Error loading Menumate.WinServices config file: {0} (problem with XML format?)", inConfigFilename);
                ServiceLogger.LogException(message, xe);

                return(defaultWebService());
            }
            catch (Exception e)
            {
                ServiceLogger.LogException("Error loading Menumate.WinServices config file", e);

                return(defaultWebService());
            }
        }
Ejemplo n.º 5
0
        public List <ServiceBase> LoadServices(string configFilename)
        {
            ServiceLogger.Log(string.Format(@"Loading Config File: {0} ...", configFilename));
            try
            {
                return(LoadServicesFromXML(ServiceInfo.Instance.GetXmlDocumentFromFile(configFilename)));
            }
            catch (XmlException xe)
            {
                string message = String.Format("Error loading Service Loader config file: {0} (problem with XML format?)", configFilename);
                ServiceLogger.LogException(message, xe);

                return(defaultService());
            }
            catch (Exception e)
            {
                ServiceLogger.LogException("Error loading Service Loader config file", e);

                return(defaultService());
            }
        }
Ejemplo n.º 6
0
        //:::::::::::::::::::::::::::::::::

        /// <summary>
        /// Load all WCF Services: The Service IDs are in an XmlDocument object
        /// </summary>
        /// <param name="inDoc"></param>
        /// <returns></returns>
        public List <ServiceHost> LoadWebServicesFromXML(XmlDocument inDoc)
        {
            List <ServiceHost> result = new List <ServiceHost>();

            //::::::::::::::::::::::::::::::::::::::

            XmlNodeList serviceNodeList = null;
            string      serviceName     = "";

            serviceNodeList = inDoc.DocumentElement.SelectNodes("WebServices/WebService");

            foreach (XmlNode serviceNode in serviceNodeList)
            {
                serviceName = serviceNode.Attributes["name"].Value;

                try
                {
                    string loadThisService = serviceNode.Attributes["load"].Value;

                    if (loadThisService.ToUpper() == @"YES")
                    {
                        result.Add(LoadWebService(strToServiceID(serviceNode.Attributes["id"].Value)));
                        ServiceLogger.Log(String.Format(@"Web Service {0} created.", serviceName));
                    }
                }
                catch (Exception e)
                {
                    ServiceLogger.LogException(String.Format(@"Error loading Web Service {0}. Does this file really exist?", serviceName), e);
                }
            }

            if (result.Count == 0)
            {
                //result.Add(new ServiceBase());
                ServiceLogger.Log(@"No Menumate Web Services to be loaded.");
            }

            return(result);
        }