public DigitalWalletController(ISettingsBase settingsBase, ICryptoProvider cryptoProvider, ILog logger)
 {
     _settings       = new Settings(settingsBase);
     _cryptoProvider = cryptoProvider;
     _logger         = logger;
     _securityKey    = _settings.MobileConfiguration.DigitalWallet.EncryptionSecurityKey;
 }
예제 #2
0
 private void SetSettingsModelInternal(ISettingsBase model)
 {
     if (model != null & model is T)
     {
         SettingsModel = (T)model;
         OnPropertyChanged();
     }
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Protocol" /> class.
 /// </summary>
 /// <param name="protocolPar">The protocol parameters.</param>
 /// <param name="Name">The name.</param>
 /// <param name="ID">The ID.</param>
 /// <param name="protocolPar_humanreadable">The protocol human readable description.</param>
 /// <param name="settingsBase">The settings base.</param>
 protected Protocol(string protocolPar, string Name, long ID, string protocolPar_humanreadable, ISettingsBase settingsBase)
 {
     m_SettingsBase = settingsBase ?? throw new ArgumentNullException("Settings provider must not be empty");
     m_Descriptor   = new ProtocolDsc(protocolPar, Name, ID, protocolPar_humanreadable);
     ProtocolList.Add(ID, this);
     m_TimeSlaveResponseDelay           = new MinMaxAvr((ushort)m_SettingsBase["MinAvgMax_FrameResponse_management"]);
     m_TimeMaxResponseDelay             = new MinMaxAvr((ushort)m_SettingsBase["MinAvgMax_FrameResponse_management"]);
     m_TimeCharGap                      = new MinMaxAvr((ushort)m_SettingsBase["MinAvgMax_CharacterGap_management"]);
     m_TimeMaxResponseDelay.MarkNewVal += new MinMaxAvr.newVal(TimeMaxResponseDelayEvHndlr);
     m_TimeCharGap.MarkNewVal          += new MinMaxAvr.newVal(TimeCharGapEvHndlr);
 }
        private void SetSettingsModelInternal(ISettingsBase model)
        {
            base.SetSettingsModel(model);

            BonusesList.CollectionChanged  -= BonusesList_CollectionChanged;
            RakeBackList.CollectionChanged -= RakeBackList_CollectionChanged;

            BonusesList.Clear();
            RakeBackList.Clear();

            if (SettingsModel?.BonusesList != null)
            {
                BonusesList.AddRange(SettingsModel.BonusesList);
            }

            if (SettingsModel?.RakeBackList != null)
            {
                RakeBackList.AddRange(SettingsModel.RakeBackList);
            }

            BonusesList.CollectionChanged  += BonusesList_CollectionChanged;
            RakeBackList.CollectionChanged += RakeBackList_CollectionChanged;
        }
 private IApplicationLayerMaster CreateApplicationProtocol(ComunicationNet.ProtocolRow protocol, CommServerComponent parent, PluginCollection plugins, ISettingsBase settings)
 {
     CommServerComponent.Tracer.TraceVerbose(60, m_src, "Creating protocol: " + protocol.Name);
     if (protocol.IsDPIdentifierNull())
     {
         //the protocol is not set so it cannot be created
         CommServerComponent.Tracer.TraceWarning(65, m_src, "The protocol is not set so it cannot be created, channel = " + this.myStatistics.myName);
         return(null);
     }
     CommServerComponent.Tracer.TraceVerbose(69, m_src, string.Format("Trying to find data provider: {0}", protocol.DPIdentifier.ToString()));
     try
     {
         IDataProviderID _DataProviderID = plugins[protocol.DPIdentifier];
         if (_DataProviderID != null)
         {
             string _format = "OK I have got DataProvider. Name = {0} [{1}]";
             CommServerComponent.Tracer.TraceVerbose(77, m_src, string.Format(_format, _DataProviderID.Title, _DataProviderID.GetDataProviderDescription.FullName));
             try
             {
                 _DataProviderID.SetSettings(protocol.DPConfig);
             }
             catch (XmlException xe)
             {
                 _format = "Problem with: {0} because of Xml content: {1}.";
                 CommServerComponent.Tracer.TraceWarning(85, m_src, string.Format(_format, protocol.DPConfig, xe.ToString()));
             }
             catch (Exception e)
             {
                 _format = "Problem with: {0} because of general failure: {1}.";
                 CommServerComponent.Tracer.TraceWarning(90, m_src, string.Format(_format, protocol.DPConfig, e.ToString()));
             }
             IProtocolParent         cStatistic  = Diagnostic.CommServerProtocol.CreateNewProtocol(protocol.DPConfig, protocol.Name, protocol.ProtocolID, _DataProviderID.GetSettingsHumanReadableFormat(), myStatistics, settings);
             IApplicationLayerMaster chnProtocol = _DataProviderID.GetApplicationLayerMaster(cStatistic, parent.m_CommonBusControl);
             CommServerComponent.Tracer.TraceVerbose(95, m_src, "I have created the DataProvider helper object.");
             return(chnProtocol);
         }
         else
         {
             string _message = "The data provider you are looking for is not available – check your configuration and execution path of the product.";
             CommServerComponent.Tracer.TraceInformation(102, m_src, _message);
         }
     }//try
     catch (System.ComponentModel.LicenseException ex)
     {
         string _format = "The component cannot be granted a license: {0}.";
         CommServerComponent.Tracer.TraceWarning(108, m_src, string.Format(_format, ex.LicensedType.ToString()));
     }
     catch (Exception _ex)
     {
         CommServerComponent.Tracer.TraceWarning(112, m_src, string.Format("Some problem encountered while trying to get a DataProvider. Exception {0}.", _ex.Message));
     }
     return(null);
 }
        }     //Channel

        #endregion creator

        #endregion

        #region API

        internal static void InitializeChannels(ComunicationNet.ChannelsDataTable channelsConfigTable, CommServerComponent parent, bool demoVersion, ISettingsBase settings)
        {
            Segment.DemoMode = demoVersion;
            foreach (ComunicationNet.ChannelsRow currRow in channelsConfigTable)
            {
                try
                {
                    myChannels.Add(new Channel(currRow, parent, demoVersion, settings));
                }
                catch (LicenseException ex)
                {
                    string msg = "Cannot create channel {0} because of {1}";
                    CommServerComponent.Tracer.TraceVerbose(220, m_src, string.Format(msg, currRow.Name, ex.Message));
                }
            }
        }
        }//Scanner

        #endregion private

        #region creator

        private Channel(ComunicationNet.ChannelsRow myCDsc, CommServerComponent parent, bool demoVersion, ISettingsBase settings)
            : base(false, "ChannelSegTOL_" + myCDsc.Name)
        {
            CommServerComponent.Tracer.TraceVerbose(150, m_src, "Creating channel: " + myCDsc.Name);
            Multichannel.NextChannnel();
            myStatistics = new Statistics.ChannelStatistics(myCDsc);
            PluginCollection m_Plugins = new PluginCollection(parent.m_CommonBusControl);

            foreach (ComunicationNet.ProtocolRow proto in myCDsc.GetProtocolRows())
            {
                IApplicationLayerMaster chnProtocol = CreateApplicationProtocol(proto, parent, m_Plugins, settings);
                if (chnProtocol != null)
                {
                    foreach (ComunicationNet.SegmentsRow currDSC in proto.GetSegmentsRows())
                    {
                        SegmentParameters  parameters       = new SegmentParameters(currDSC);
                        Diagnostic.Segment segmentStatistic = new Diagnostic.Segment(currDSC, myStatistics);
                        Segment            segment          = new Segment
                                                                  (currDSC, (byte)proto.MaxNumberOfRetries, chnProtocol, parameters, demoVersion, segmentStatistic, this)
                        {
                            Cycle = parameters.TimeReconnect
                        };
                        segment.ResetCounter();
                    }
                }
                else
                {
                    string name = proto != null ? proto.Name : "---not set---";
                    CommServerComponent.Tracer.TraceWarning(199, m_src, "Cannot find component implementing the required protocol: " + name);
                }
            } //foreach (NetworkConfig.ComunicationNet.ProtocolRow proto in myCDsc.GetProtocolRows)
            CommServerComponent.Tracer.TraceVerbose(203, m_src, "Channel: " + myCDsc.Name + " has been created.");
        }     //Channel
예제 #8
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);
            }
        }
예제 #9
0
        /// <summary>
        /// Initialize the communication server
        /// </summary>
        /// <param name="parent">Parent control hosting some common resources</param>
        /// <param name="demoVer">true if there is no valid license, false otherwise</param>
        /// <param name="valueConstrain">Number of item I can instantiate according of the license. �1 if unlimited. Valid if cDemoVer is false.</param>
        /// <param name="configurationFileName">Name of the configuration file.</param>
        internal static void InitializeServer(CommServerComponent parent, bool demoVer, ref int valueConstrain, string configurationFileName, ISettingsBase settings)
        {
            ProtocolHubConfiguration xml = new ProtocolHubConfiguration(configurationFileName, true);

            try
            {
                InitializeItemDescriber();
            }
            catch (Exception ex)
            {
                CommServerComponent.Tracer.TraceWarning(98, typeof(Initialization).FullName + ".Initialization", ex.Message);
            }
            //CAS.OpcSvr.Da.NETServer.Initialization.InitComponent();
            Station.InitStations(xml.configuration.Station, ref valueConstrain);
            Channel.InitializeChannels(xml.configuration.Channels, parent, demoVer, settings);
            Station.SwitchOnDataScanning();
        }
 public override void SetSettingsModel(ISettingsBase model)
 {
     SetSettingsModelInternal(model);
 }
예제 #11
0
 public virtual void SetSettingsModel(ISettingsBase model)
 {
     SetSettingsModelInternal(model);
 }
예제 #12
0
 public static String LoadPortalView(Int32 iduser, ISettingsBase settings)
 {
     return(GetPortalPage(iduser, settings.View) + "g=" + settings.GroupBy.ToString() + "&n=" + settings.GetNoticeboard(settings.View).ToString() + "&o=" + settings.OrderBy.ToString());
 }
예제 #13
0
 /// <summary>
 /// Creating new protocol.
 /// </summary>
 /// <param name="protocolPar">The protocol description containing parameter of the protocol in XML Format.</param>
 /// <param name="Name">The name of the protocol.</param>
 /// <param name="ID">The identifier of the protocol.</param>
 /// <param name="protocolPar_HumanReadable">The protocol parameters as human readable string.</param>
 /// <param name="settingsBase">The settings base.</param>
 /// <returns>Returns <see cref="IProtocolParent" /></returns>
 public static IProtocolParent CreateNewProtocol(string protocolPar, string Name, long ID, string protocolPar_HumanReadable, ISettingsBase settingsBase)
 {
     return(new Protocol(protocolPar, Name, ID, protocolPar_HumanReadable, settingsBase));
 }
예제 #14
0
        public override void SetSettingsModel(ISettingsBase model)
        {
            base.SetSettingsModel(model);

            UpdateSelectedSite(SelectedSiteType);
        }