Exemplo n.º 1
0
        public CTableTradeTimes(string name, IAlarmable alarmer, CSessionBoxASTS sessionBox)
            : base(name, alarmer)
        {
            IsNullDecimal = true;

            _sessionBox = sessionBox;
        }
Exemplo n.º 2
0
 public CBaseFunctional(string name, IAlarmable alarmer, ILogable logger)
 {
     _alarmer = alarmer;
     _logger  = logger;
     PrintStartUpBanner();
     _name = name;
 }
        async Task IAlarmRenderer.RenderAsync(IBotToUser botToUser, string title, DateTime now)
        {
            Alarm alarm;

            if (this.scheduler.TryFindAlarm(title, out alarm))
            {
                var card = new HeroCard();
                card.Title    = alarm.Title ?? "Default Alarm";
                card.Subtitle = alarm.State
                    ? (alarm.When.HasValue ? $"{alarm.When}" : "not set")
                    : "disabled";

                IAlarmable query = alarm;
                DateTime   next;
                if (query.TryFindNext(now, out next))
                {
                    var  remaining = next.Subtract(now);
                    bool today     = now.Date == next.Date;
                    card.Text = $"There is {remaining:dd\\.hh\\:mm\\:ss} remaining before this alarm rings.";
                }

                var buttons = this.actions.ActionsFor(alarm);
                card.Buttons = buttons.ToArray();

                var message = botToUser.MakeMessage();
                message.Attachments = new[] { card.ToAttachment() };

                await botToUser.PostAsync(message);
            }
            else
            {
                throw new AlarmNotFoundException();
            }
        }
        public CRemoteFileMover(string uri, int parHoursOld)

        {
            _parHoursOld = parHoursOld;

            _logger = new CLogger("CRemoteFileCopier");

            _alarmer = new CAlarmerConsole();

            _localCopyRoot = Environment.GetEnvironmentVariable("LOG_REMOTE_PATH");

            _ftpConnector = new CFTPConnector(uri, _alarmer);
        }
Exemplo n.º 5
0
        public CSnapshoter(IClientSnapshoter clientSnapshoter,
                           IAlarmable alarmer)
            : base(alarmer)
        {
            //GetSnapshot = getSnapshot;
            _fileName = "TablesSnapshot.dat";

            _fileIO       = new CFileIOBinaryDataStatic(GetFullPath(), _alarmer);
            _snapshotSave = _fileIO.LoadData <byte[]>();
            //_snapshotSave_snapshotNew.CopyTo(_snapshotSave, 0);

            CUtil.ThreadStart(ThreadSaveSnapshot);
            _client = clientSnapshoter;
        }
        public CDBSynchronizer(string fromHost, string fromDB, string fromUser, string fromPassword,
                               string toHost, string toDB, string toUser, string toPassword,
                               IClientDatabaseConnector dbClient,
                               IAlarmable alarmer)
        {
            _conFrom = new CMySQLConnector(fromHost, fromDB, fromUser, fromPassword, alarmer, dbClient);
            _conTo   = new CMySQLConnector(toHost, toDB, toUser, toPassword, alarmer, dbClient);

            _conFrom.Connect();
            _conFrom.GenTablesSchemas();

            _conTo.Connect();
            _conTo.GenTablesSchemas();
        }
Exemplo n.º 7
0
        public CSkypeRetransmitter(IAlarmable alarmer) : base(alarmer)
        {
            //TODO security !
            SkypeCredentials inAuthCreds = new SkypeCredentials("konstantin_a_arapov", "Vfieyz2011");


            authCreds = inAuthCreds;
            mainSkype = new Skype4Sharp.Skype4Sharp(inAuthCreds);
            Console.WriteLine("[DEBUG]: Logging in with {0}:{1}", inAuthCreds.Username, string.Join("", Enumerable.Repeat("*", inAuthCreds.Password.Length)));
            mainSkype.Login();
            Console.WriteLine("[DEBUG]: Login complete");
            mainSkype.messageReceived        += MainSkype_messageReceived;
            mainSkype.contactRequestReceived += MainSkype_contactRequestReceived;
            Console.WriteLine("[DEBUG]: Events set");
        }
Exemplo n.º 8
0
        public CBaseFunctional(IAlarmable alarmer, string name = null)
        {
            //string name;
            if (name == null)
            {
                _name = this.GetType().Name;
            }
            else
            {
                _name = name;
            }
            _logger  = new CLogger(_name);
            _alarmer = alarmer;

            PrintStartUpBanner();
        }
Exemplo n.º 9
0
        /*
         * public bool IsConnected
         * {
         *  get
         *  {
         *      if (_connection != null)
         *          if (_connection.State == ConnectionState.Open)
         *              return true;
         *
         *
         *
         *
         *          return false;
         *
         *
         *  }
         *
         * }
         */



        public CMySQLConnector(string host, string database, string user, string password,
                               IAlarmable alarmer, IClientDatabaseConnector dbConnectorClient)
            : base(alarmer)


        {
            _dbConnectorClient = dbConnectorClient;


            _host     = host;
            _database = database;
            _user     = user;
            _password = password;

            //if (_connection.State == ConnectionState.Open)
            //  GenTablesSchemas();
        }
Exemplo n.º 10
0
        private string _secBoard; // = "TQBR";


        public CTransactor(IClientTransactor transactor,
                           string account,
                           long clientCode,
                           string secBoard,
                           IAlarmable alarmer,
                           string logName = null)
            : base(alarmer, logName)
        {
            //_client = client;
            _clientTransactor = transactor;

            _account    = account;
            _clientCode = clientCode;
            _secBoard   = secBoard;


            //_clientCode = Parameters[];
        }
Exemplo n.º 11
0
        public CBaseDataSource(IAlarmable client, Dispatcher guiDispatcher)
            : base(client)
        {
            _dataSynchBotPosTrdMgr =
                new CDataSyncher_StockExch_Bot_InstrId <CBotPosTrdMgr, VMBotPosTrdMgr>(this,
                                                                                       VMBotPosTrdMgr.Create, guiDispatcher);

            _dataSynchBotStatus =
                new CDataSyncher_StockExch_BotId <CBotStatus, VMBotStatus>(this,
                                                                           VMBotStatus.Create, guiDispatcher);


            _dataSynchPosInstrTotal =
                new CDataSyncher_SockExch_Instr <CPositionInstrTotal, VMPosInstrTotal>(this,
                                                                                       VMPosInstrTotal.Create,
                                                                                       guiDispatcher);

            _dataSyncherClientInfo =
                new CDataSyncher_StockExch_BotId <CClientInfo, VMClientInfo>(this,
                                                                             VMClientInfo.Create,
                                                                             guiDispatcher);
        }
        public CPosistionsBoxASTS(IClientPositionsBoxASTS client)
            : base(client)
        {
            _client      = client;
            _instruments = client.Instruments;
            _alarmer     = client;
            _guiBox      = client.GUIBox;

            //TODO to base class
            DictPos = new Dictionary <string, CRawPosition>();
            foreach (var kvp in _instruments)
            {
                DictPos[kvp.instrument] = new CRawPosition();
            }

            _onlineDetector = new COnlineDetector(client.TriggerRecalcAllBots, EnmBotEventCode.OnPositionOnline,
                                                  parTimeAfterUpdateMs: 500, parTimeAfterObjectCreated: 8000);



            CreateListPos(_client.StockExchId, _instruments);
        }
Exemplo n.º 13
0
        public CMailer(IAlarmable alarmer,
                       string smtpServer,
                       int portSMTP,
                       string user,
                       string mailDomain,
                       string password,
                       bool bUseEamilAsUserName,
                       bool bEnableSSL)

            : base(alarmer)
        {
            _smtpServer = smtpServer;
            _user       = user;
            _mailDomain = mailDomain;
            _password   = password;

            _bUseEamilAsUserName = bUseEamilAsUserName;

            _bEnableSSL = bEnableSSL;

            _portSMTP = portSMTP;
        }
Exemplo n.º 14
0
        //    CSessionBoxASTS _sessionBoxASTS;


        public CTable_Stats(string name, IAlarmable client, CSessionBoxASTS sessionBoxASTS)
            : base(name, client)
        {
            //   _sessionBoxASTS = sessionBoxASTS;
        }
Exemplo n.º 15
0
 public CDBLayer(IAlarmable client)
 {
     _client = client;
 }
Exemplo n.º 16
0
 public void CheckLimit(int countLim, bool bOutAlarm = true, int secRepeatAlarm = 20, IAlarmable alarmer = null, string queueName = "Unknown")
 {
     if (this.Count > countLim)
     {
         if ((DateTime.Now - _lastAlarm).TotalSeconds > secRepeatAlarm && bOutAlarm)
         {
             if (alarmer != null)
             {
                 alarmer.Error(queueName + " quee more than max =" + this.Count);
             }
             _lastAlarm = DateTime.Now;
         }
     }
 }
Exemplo n.º 17
0
 public CTableMarkets(string name, IAlarmable alarmer)
     : base(name, alarmer)
 {
 }
        public void CheckDriveSpace(double minSizeInGB)
        {
            _parMinFreeSpaceGb = minSizeInGB;
            _logger            = new CLogger("CDriveSpaceChecker");
            _alarmer           = new CAlarmerConsole();


            Log("Starting disk cleaner");

            string dirLog = Environment.GetEnvironmentVariable("LOG_PATH");


            DriveInfo[] dinf      = DriveInfo.GetDrives();
            DriveInfo   dinfClean = null;

            //string stDriveClean = String.Format(@"{0}:\", _parLetterToClean).ToUpper();
            string stDriveClean = dirLog.Substring(0, 3).ToUpper();

            //  List<DriveInfo> _hardDrives = new List<DriveInfo>();

            for (int i = 0; i < dinf.Count(); i++)
            {
                if (dinf[i].DriveType == DriveType.Fixed &&
                    dinf[i].IsReady == true &&
                    dinf[i].Name == stDriveClean)
                {
                    dinfClean = dinf[i];
                }
            }



            if (dinfClean == null)
            {
                Console.WriteLine(String.Format(@"Drive {0}:\ not found", stDriveClean));

                return;
            }

            while (true)
            {
                try
                {
                    double _freeSpaceGB = dinfClean.AvailableFreeSpace / 1024 / 1024 / 1024;

                    while (_freeSpaceGB < _parMinFreeSpaceGb)
                    {
                        Log(String.Format("FreeSpace={0} < MinFreeSpace={1} ", _freeSpaceGB, _parMinFreeSpaceGb));
                        //level 1 app dir
                        string[] appDirs = Directory.GetDirectories(dirLog);

                        foreach (var dirApp in appDirs)
                        {
                            if (dirApp.Contains("DiskCleaner")) //do not clean self
                            {
                                continue;
                            }


                            string[] dirDates = Directory.GetDirectories(dirApp);
                            if (dirDates.Count() > 0)
                            {
                                Log("Cleaning directory " + dirDates[0]);
                                Directory.Delete(dirDates[0], recursive: true);
                            }
                            Thread.Sleep(1000);

                            _freeSpaceGB = dinfClean.AvailableFreeSpace / 1024 / 1024 / 1024;

                            if (_freeSpaceGB > _parMinFreeSpaceGb)
                            {
                                break;
                            }
                        }


                        Thread.Sleep(60000);
                    }
                }

                catch (Exception e)
                {
                    Error("CheckDriveSpace", e);
                }


                Thread.Sleep(1000);
            }
        }
Exemplo n.º 19
0
 public CPasswordSaver(IAlarmable alarmer)
 {
     _alarmer = alarmer;
     LoadData();
 }
Exemplo n.º 20
0
 public CFTPConnector(string uri, IAlarmable alarmer)
 {
     _uri                 = uri;
     _alarmer             = alarmer;
     _networkCredentional = new NetworkCredential(user, password);
 }
Exemplo n.º 21
0
 public CPerfAnlzr(int parSinceStart, IAlarmable _alarmer)
     : this(_alarmer)
 {
     _parSinceStart = parSinceStart;
     // _parMaxMsecScan = parMaxMsecScan;
 }
Exemplo n.º 22
0
 public CBitfinexRestConnectorV2(IAlarmable client, string key, string secret)
     : base(client, key, secret)
 {
 }
Exemplo n.º 23
0
 public CFileIOBinaryDataStatic(string fileName, IAlarmable alarmer)
     : base(fileName, alarmer)
 {
 }
Exemplo n.º 24
0
 public CPerfAnlzr(IAlarmable alarmer)
 {
     _alarmer = alarmer;
 }
Exemplo n.º 25
0
 //TODO: swith off flushMode
 public CBaseTable(string name, IAlarmable alarmer)
     : base(name, alarmer, new CLogger(name, flushMode: true, subDir: "Tables"))
 {
 }
Exemplo n.º 26
0
 /*
  * KeysDependenciesTrdMgr _keyset = new KeysDependenciesTrdMgr();
  * CDataSyncher_StockExch_Bot_InstrId<CBotPosTrdMgr, VMBotPosTrdMgr> _dataSynchBotPosTrdMgr;
  *
  *
  *      CDataSyncher_StockExch_BotId <CBotStatus, VMBotStatus> _dataSynchBotStatus;
  */
 public TestDataSyncher(IAlarmable client)
     : base(client, System.Windows.Threading.Dispatcher.CurrentDispatcher)
 {
     TestBotPosTrdMgr();
     TestBotStatus();
 }
        //IntPtr conn;
        public CP2ConnectorNative(IAlarmable alarmer)
        {
            dtStarted = DateTime.Now;
            _alarmer  = alarmer;
            //_alarmer.Error("Test");
            _log = new  CLogger("NatConnectionMarket");
            _log.Log("+++++++++++++++++++++++++++++++++ Connection started      +++++++++++++++++++++++++++++++++++++++++++++++");


            CallbackDelegate = Callback;


            UInt32 res = cg_env_open("ini=repl.ini;key=11111111");


            unsafe
            {
                int *conn = null;



                res      = cg_conn_new("p2tcp://127.0.0.1:4001;app_name=test_nat", &conn);
                protConn = (IntPtr)conn;
                int * lstn = null;
                void *data = null;
                //res = cg_lsn_new(conn, "p2repl://FORTS_DEALS_REPL;tables=deal", CallbackDelegate, data, &lstn);
                res = cg_lsn_new(conn, "p2repl://FORTS_FUTAGGR50_REPL", CallbackDelegate, data, &lstn);

                UInt32 state;

                bool bExit = false;
                while (!bExit)
                {
                    res = cg_conn_getstate(conn, &state);
                    if (state == CG_STATE_ERROR)
                    {
                        res = cg_conn_close(conn);
                    }
                    else if (state == CG_STATE_CLOSED)
                    {
                        res = cg_conn_open(conn, "");
                    }

                    else if (state == CG_STATE_ACTIVE)
                    {
                        res = cg_conn_process(conn, 0, null);

                        res = cg_lsn_getstate(lstn, &state);

                        if (state == CG_STATE_CLOSED)
                        {
                            // res = cg_lsn_open(lstn, "mode=online");
                            res = cg_lsn_open(lstn, "");
                        }
                        else if (state == CG_STATE_ERROR)
                        {
                            cg_lsn_close(lstn);
                        }
                    }
                }
            }
            //  res = cg_conn_new("p2tcp://127.0.0.1:4001;app_name=test_repl", pt);
        }
Exemplo n.º 28
0
 public CBaseCommunicator(IAlarmable alarmer)
     : base(alarmer)
 {
     IsEnabledUserConnectionToServer = true;
     ReadServerConf();
 }
Exemplo n.º 29
0
 public CTableSecurities(string name, IAlarmable alarmer, CListInstruments instruments, int StockExchID)
     : base(name, alarmer)
 {
     _instruments = instruments;
     _stockExchID = StockExchID;
 }
Exemplo n.º 30
0
 public CDBSource(ModelDBCon conf, IAlarmable client)
 {
     _conf           = conf;
     _client         = client;
     _mysqlConnector = new CMySQLConnector(_conf.Host, _conf.DatabaseName, "root", "profinvest", this, this);
 }