Esempio n. 1
0
        private void ValidateLicense(ref uint?runTimeConstrain, ref uint?volumeConstrain)
        {
            License lic       = null;
            bool    m_DemoVer = true;

            if (!LicenseManager.IsValid(this.GetType(), this, out lic))
            {
                Tracer.TraceWarning(157, src, string.Format(Resources.Tx_LicNoFileErr + Resources.Tx_LicCap));
            }
            else
            {
                using (lic)
                {
                    LicenseFile m_license           = lic as LicenseFile;
                    MaintenanceControlComponent mcc = new MaintenanceControlComponent();
                    if (mcc.Warning != null)
                    {
                        Tracer.TraceInformation(159, this.GetType().Name, "The following warning(s) appeared during loading of the license: " + mcc.Warning);
                    }
                    UserOrganization = m_license.User.Organization;
                    UserEmail        = m_license.User.Email;
                    Debug.Assert(m_license != null);
                    if (!String.IsNullOrEmpty(m_license.FailureReason))
                    {
                        Tracer.TraceWarning(167, src, string.Format(m_license.FailureReason + Resources.Tx_LicCap));
                    }
                    else
                    {
                        m_DemoVer = false;
                        if (m_license.RunTimeConstrain > 0)
                        {
                            runTimeConstrain = 60 * 60 * (uint)m_license.RunTimeConstrain;
                        }
                        else
                        {
                            runTimeConstrain = null;
                        }
                        if (m_license.VolumeConstrain > 0)
                        {
                            volumeConstrain = (uint)m_license.VolumeConstrain;
                        }
                        else
                        {
                            volumeConstrain = null;
                        }
                    }
                }
            }
            if (m_DemoVer)
            {
                Tracer.TraceWarning(183, src, string.Format(Resources.Tx_LicDemoModeInfo + Resources.Tx_LicCap));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the Main CommServer Component using specified configuration file name.
        /// </summary>
        /// <param name="configurationFileName">The configuration file name.</param>
        public void Initialize(string configurationFileName, ISettingsBase settings)
        {
            if (m_isInitialized)
            {
                throw new ApplicationException("Only one initialization of CommServerComponent is allowed.");
            }
            m_isInitialized = true;
            int  cEventID     = (int)Error.CommServer_CommServerComponent;
            bool m_DemoVer    = true;
            int  cRTConstrain = 2;
            int  cVConstrain  = 15;

            LicenseManager.IsValid(this.GetType(), this, out License lic);
            LicenseFile m_license = lic as LicenseFile;

            if (m_license == null)
            {
                EventLogMonitor.WriteToEventLog(Resources.Tx_LicNoFileErr, EventLogEntryType.Error, cEventID, 93);
            }
            else
            {
                using (lic)
                {
                    MaintenanceControlComponent mcc = new MaintenanceControlComponent();
                    if (mcc.Warning != null)
                    {
                        Tracer.TraceWarning(143, this.GetType().Name, "The following warning(s) appeared during loading the license: " + mcc.Warning);
                    }
                    if (m_license.FailureReason != string.Empty)
                    {
                        EventLogMonitor.WriteToEventLog(m_license.FailureReason, EventLogEntryType.Error, cEventID, 95);
                    }
                    else
                    {
                        m_DemoVer = false;
                        EventLogMonitor.WriteToEventLog("Opened the license: " + m_license.ToString(), EventLogEntryType.Information, cEventID, 98);
                        cRTConstrain = m_license.RunTimeConstrain;
                        if (m_license.VolumeConstrain < 0)
                        {
                            cVConstrain = int.MaxValue;
                        }
                        else
                        {
                            cVConstrain = m_license.VolumeConstrain;
                        }
                    }
                }
            }
            if (m_DemoVer)
            {
                EventLogMonitor.WriteToEventLog(Resources.Tx_LicDemoModeInfo, EventLogEntryType.Information, cEventID, 98);
            }
            string cProductName;
            string cProductVersion;
            string cFullName;

            cProductName    = Assembly.GetExecutingAssembly().GetName().Name;
            cProductVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            cFullName       = Assembly.GetExecutingAssembly().GetName().FullName;
            ulong vd        = m_RuntimeStopWatch.Start;
            int   cVcounter = cVConstrain;

            EventLogMonitor.WriteToEventLog("Communication server started - product name:" + cFullName, EventLogEntryType.Information, (int)Error.CommServer_CommServerComponent, 130);
            Initialization.InitializeServer(this, m_DemoVer, ref cVcounter, configurationFileName, settings);
            ConsoleIterface.Start(cProductName, cProductVersion);
            if (cVcounter <= 0)
            {
                EventLogMonitor.WriteToEventLog("Some tags have not been added due to license limitation – the volume constrain have been reached", EventLogEntryType.Warning, (int)Error.CommServer_CommServerComponent, 134);
            }
            else
            {
                string msg = string.Format("Initiated {0} tags, The license allows you to add {1} more tags. ", cVConstrain - cVcounter, cVcounter);
                EventLogMonitor.WriteToEventLog(msg, EventLogEntryType.Information, (int)Error.CommServer_CommServerComponent, 139);
            }
            if (cRTConstrain > 0)
            {
                string msg = string.Format("Runtime of the product is constrained up to {0} hours.", cRTConstrain);
                EventLogMonitor.WriteToEventLog(msg, EventLogEntryType.Warning, (int)Error.CommServer_CommServerComponent, 145);
                m_RunTimeout = new System.Timers.Timer(cRTConstrain * 60 * 60 * 1000);
                m_RunTimeout.Start();
                m_RunTimeout.Elapsed += new System.Timers.ElapsedEventHandler(m_RunTimeout_Elapsed);
            }
        }