Exemplo n.º 1
0
        private void AgentWindowLoad(object sender, EventArgs e)
        {
            LoggerClient.Initialize();
            this.logger.Send("ScadaDataClient", "Data (upload) Program starts at " + DateTime.Now);

            this.InitSysNotifyIcon();
            this.MakeWindowShownFront();
            this.ShowInTaskbar = false;
            this.SetExceptionToolStripMenuItem.Checked = false;
            this.statusStrip.Items.Add(this.GetConnetionString());
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add("MS: " + Settings.Instance.Mn);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            // this.statusStrip.Items.Add("数据中心IP:");

            this.cmdReceiver = new CommandReceiver(Ports.DataClient);
            cmdReceiver.Start(this.OnLocalCommand);

            SystemEvents.SessionEnding += SystemEvents_SessionEnding;

            this.InitDetailsListView();
            if (this.StartState)
            {
                this.Start();
            }
        }
Exemplo n.º 2
0
 private void ControlButton_Click(object sender, RoutedEventArgs e)
 {
     if (!Working)
     {
         try
         {
             NetworkOperator.ServerPort = int.Parse(ServerAddress.Text);
         }
         catch
         {
             MessageBox.Show("Некорректный адрес");
         }
         Receiver = new CommandReceiver(NetworkOperator.ServerPort);
         Receiver.Start();
         ServerAddress.IsEnabled = false;
         Working               = true;
         PowerIndicator.Fill   = Brushes.Green;
         ControlButton.Content = "Остановить";
     }
     else
     {
         Receiver.Stop();
         ServerAddress.IsEnabled = true;
         Working               = false;
         PowerIndicator.Fill   = Brushes.Red;
         ControlButton.Content = "Запустить";
     }
 }
Exemplo n.º 3
0
        private void AgentWindow_Load(object sender, EventArgs e)
        {
            this.CancelQuit = true;
            InitSysNotifyIcon();
            // StatusBar labels
            this.statusStrip.Items.Add(this.statusLabel);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add(this.addressLabel);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add(this.counterLabel);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add(this.uploadLabel);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add(this.pingLabel);

            this.CheckLastSendTime = true;

            if (!this.IsSecond)
            {
                this.cmdReceiver = new CommandReceiver(Ports.DataClient);
                cmdReceiver.Start(this.OnLocalCommand);
            }
            this.InitDetailsListView();
            this.Start();
        }
        public static void Init(TestContext tc)
        {
            CommandFile.SharedFolder   = "A:\\Cmmd";
            _cmmdTolocalDbFilePath     = Path.Combine(Properties.Resources.Local, $"{nameof(Add_SqliteDb_CmmdToSharedFolderToLocalDbVSDirectlyToLocalFolderVSToSharedFolderTest)}_local{NetCoreSqliteDB.SqliteDBContext.DBFileExtensionName}");
            _directlyTolocalDbFilePath = Path.Combine(Properties.Resources.Local, $"{nameof(Add_SqliteDb_CmmdToSharedFolderToLocalDbVSDirectlyToLocalFolderVSToSharedFolderTest)}_directlyToLocal{NetCoreSqliteDB.SqliteDBContext.DBFileExtensionName}");
            _sharedFolderDbFilePath    = Path.Combine(Properties.Resources.Shared, $"{nameof(Add_SqliteDb_CmmdToSharedFolderToLocalDbVSDirectlyToLocalFolderVSToSharedFolderTest)}_sharedFolder{NetCoreSqliteDB.SqliteDBContext.DBFileExtensionName}");

            NetCoreSqliteDB.SqliteDBContext.CopyTempateDBFile(_cmmdTolocalDbFilePath);
            NetCoreSqliteDB.SqliteDBContext.CopyTempateDBFile(_directlyTolocalDbFilePath);
            NetCoreSqliteDB.SqliteDBContext.CopyTempateDBFile(_sharedFolderDbFilePath);

            _cmmdLocalRepository       = new SqliteDBRepository(_cmmdTolocalDbFilePath);
            _directlyToLocalRepository = new SqliteDBRepository(_directlyTolocalDbFilePath);
            _sharedFolderRepository    = new SqliteDBRepository(_sharedFolderDbFilePath);

            _entitiy1000 = new Entity1[1000];
            for (int i = 0; i < 1000; i++)
            {
                _entitiy1000[i] = AddDataRowsHelper.CreateDataRow <Entity1>(0, i);
            }

            _cmmdReceiver = new CommandReceiver(new JsonSer(), _cmmdLocalRepository);
            _cmmdReceiver.Start();

            _cmmdSender = new CommandSender(new JsonSer());
        }
Exemplo n.º 5
0
        private void AgentWindowLoad(object sender, EventArgs e)
        {
            this.Visible = false;
            LoggerClient.Initialize();
            this.logger.Send("ScadaDataClient", "Data (upload) Program starts at " + DateTime.Now);

            this.InitSysNotifyIcon();
            this.MakeWindowShownFront();
            this.ShowInTaskbar = false;
            this.SetExceptionToolStripMenuItem.Checked = false;

            this.cmdReceiver = new CommandReceiver(Ports.DataClient);
            cmdReceiver.Start(this.OnLocalCommand);

            SystemEvents.SessionEnding += SystemEvents_SessionEnding;

            this.InitDetailsListView();
            if (this.StartState)
            {
                this.Start();
            }
        }
Exemplo n.º 6
0
        public static void Init(TestContext tc)
        {
            CommandFile.SharedFolder = "A:\\Cmmd";
            _localDbFilePath         = Path.Combine(Properties.Resources.Local, $"{nameof(Edit_SqliteDb_CmmdToSharedFolderToLocalDbVSToSharedFolderTest)}{SqliteDBContext.DBFileExtensionName}");
            _sharedFolderDbFilePath  = Path.Combine(Properties.Resources.Shared, $"{nameof(Edit_SqliteDb_CmmdToSharedFolderToLocalDbVSToSharedFolderTest)}{SqliteDBContext.DBFileExtensionName}");

            NetCoreSqliteDB.SqliteDBContext.CopyTempateDBFile(_localDbFilePath);


            _localRepository        = new SqliteDBRepository(_localDbFilePath);
            _sharedFolderRepository = new SqliteDBRepository(_sharedFolderDbFilePath);

            _entitiy1000 = new Entity1[1000];
            for (int i = 0; i < 1000; i++)
            {
                _entitiy1000[i] = AddDataRowsHelper.CreateDataRow <Entity1>(0, i);
            }

            var localDbContext = new NetCoreSqliteDB.SqliteDBContext(_localDbFilePath);

            localDbContext.Table1.AddRange(_entitiy1000);
            localDbContext.SaveChanges();

            File.Copy(_localDbFilePath, _sharedFolderDbFilePath, true);

            foreach (var e in _entitiy1000)
            {
                e.P3 = "Edited";
                e.BasedOnUpdatedDateTime = e.UpdatedDateTime;
                e.UpdatedDateTime        = DateTime.Now;
            }

            _cmmdReceiver = new CommandReceiver(new JsonSer(), _localRepository);
            _cmmdReceiver.Start();

            _cmmdSender = new CommandSender(new JsonSer());
        }
 public Task StartAsync(CancellationToken cancellationToken)
 {
     DataReceiver.Start(DataReceivedAsync);
     CommandReceiver.Start(CommandReceivedAsync);
     return(Task.CompletedTask);
 }