Esempio n. 1
0
 /// <summary>
 /// reading of configuration XML file
 /// </summary>
 /// <param name="myData">target data set</param>
 /// <param name="filename">filename</param>
 public void readXMLFile(DataSet myData, string filename)
 {
     if (string.IsNullOrEmpty(filename))
     {
         EventLogMonitor.WriteToEventLogInfo(itemdscHasNotBeenSet, 39);
         return;
     }
     else if (filename == "item_dsc.xml")
     {
         FileInfo fi          = RelativeFilePathsCalculator.GetAbsolutePathToFileInApplicationDataFolder(filename);
         string   itemdscPath = fi.FullName;
         if (!new FileInfo(itemdscPath).Exists)
         {
             EventLogMonitor.WriteToEventLog(itemdscDoesNotExists, EventLogEntryType.Warning);
             return;
         }
         else
         {
             filename = itemdscPath;
         }
     }
     else if (!new FileInfo(filename).Exists)
     {
         EventLogMonitor.WriteToEventLog(string.Format(itemdscDoesNotExists, filename), EventLogEntryType.Warning);
         return;
     }
     myData.Clear();
     try
     {
         myData.ReadXml(filename, XmlReadMode.IgnoreSchema);
     }
     catch (Exception)
     {
         EventLogMonitor.WriteToEventLog(itemdscCannotBeOpened, EventLogEntryType.Warning);
     }
 }
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);
            }
        }
Esempio n. 3
0
 private void m_RunTimeout_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     EventLogMonitor.WriteToEventLog("Runtime expired – server entered demo mode – no data will be read. ", EventLogEntryType.Warning, (int)Error.CommServer_CommServerComponent, 72);
     Segment.DemoMode = true;
 }
Esempio n. 4
0
 /// <summary>
 /// Starts the server with specified product name and version.
 /// </summary>
 /// <param name="cProductName">Name of the c product.</param>
 /// <param name="cProductVersion">The c product version.</param>
 public static void Start(string cProductName, string cProductVersion)
 {
     if (!started)
     {
         ProductName    = cProductName;
         ProductVersion = cProductVersion;
         //inicjalizacja kanalu
         started = true;
         try
         {
             TcpServerChannel channel;
             //        SoapServerFormatterSinkProvider ftProvider = new SoapServerFormatterSinkProvider();
             //        ftProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
             //        ftProvider.Next=new  System.Runtime.Remoting.MetadataServices.SdlChannelSinkProvider();
             BinaryServerFormatterSinkProvider ftProvider = new BinaryServerFormatterSinkProvider();
             ftProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
             channel = new TcpServerChannel(null, AppConfigManagement.ConsoleRemotingHTTPport, ftProvider);
             //rejestracja kana³u
             ChannelServices.RegisterChannel(channel, false);
         }
         catch (Exception ex)
         {
             EventLogMonitor.WriteToEventLog
             (
                 String.Format(Resources.ConsoleInterface_ChannelRegistrationError, ex.Message),
                 EventLogEntryType.Error, (int)Error.CommServer_CommServerComponent, 267
             );
         }
         //rejestracja OPCRealtimeDataAccess
         WellKnownServiceTypeEntry remObj = new WellKnownServiceTypeEntry
                                            (
             typeof(BaseStation.ConsoleIterface),
             "CommServerConsole",
             WellKnownObjectMode.Singleton
                                            );
         RemotingConfiguration.RegisterWellKnownServiceType(remObj);
         //inicjalizacja listy protokolow :
         //inicjalizacja listy stacji :
         stationlist = new SortedList <long, Statistics.StationStatistics.StationStatisticsInternal>(Statistics.stationList.Count);
         foreach (Statistics.StationStatistics obj in Statistics.stationList)
         {
             stationlist.Add(((Statistics.StationStatistics)obj).myStat.myID, ((Statistics.StationStatistics)obj).myStat);
         }
         //inicjalizacja listy segmentow :
         segmentlistpairs = new SortedList <long, StatisticAndIUpdatePair <Statistics.SegmentStatistics.SegmentStatisticsInternal> >(Statistics.segmentList.Count);
         segmentlist      = new SortedList <long, Statistics.SegmentStatistics.SegmentStatisticsInternal>(Statistics.segmentList.Count);
         foreach (Statistics.SegmentStatistics obj in Statistics.segmentList)
         {
             segmentlist.Add(obj.myStat.MyID, obj.myStat);
             segmentlistpairs.Add(
                 obj.myStat.MyID, new StatisticAndIUpdatePair <Statistics.SegmentStatistics.SegmentStatisticsInternal>
                     (obj.myStat, obj));
         }
         //inicjalizacja listy interfejsow :
         interfacelistpairs = new SortedList <ulong, StatisticAndIUpdatePair <Statistics.InterfaceStatistics.InterfaceStatisticsInternal> >(Statistics.interfaceList.Count);
         interfacelist      = new SortedList <ulong, Statistics.InterfaceStatistics.InterfaceStatisticsInternal>(Statistics.interfaceList.Count);
         foreach (Statistics.InterfaceStatistics obj in Statistics.interfaceList)
         {
             interfacelist.Add(obj.myStat.myID_Internal, obj.myStat);
             interfacelistpairs.Add(
                 obj.myStat.myID_Internal, new StatisticAndIUpdatePair <Statistics.InterfaceStatistics.InterfaceStatisticsInternal>
                     (obj.myStat, obj));
         }
         listSegmentStates   = new SortedList <long, Statistics.SegmentStatistics.States>(segmentlistpairs.Count);
         listStationStates   = new SortedList <long, int>(stationlist.Count);
         listInterfaceStates = new SortedList <ulong, Statistics.InterfaceStatistics.InterfaceState>(interfacelistpairs.Count);
     }
 }