예제 #1
0
        /// <summary>
        /// Method sends a message via Telegram about every new file in directory.
        /// </summary>
        public void RemindAboutNewFile()
        {
            var message = FindNewFileInDir();

            if (message.Length != 0)
            {
                TelegramExtension.SendMessageAsync(message).GetAwaiter().GetResult();
                Logger.Log.Info($"{message}");
            }
            else
            {
                Logger.Log.Debug("No updates");
            }
        }
        static void Main(string[] args)
        {
            try
            {
                Display.ShowGeneralInfo();

                var foldersList = ConfigReader.GetTestResultsDir();

                TelegramExtension.AuthUserAsync().GetAwaiter().GetResult();

                var objectDirList = new List <FilesListener>();

                foreach (var folder in foldersList)
                {
                    objectDirList.Add(new FilesListener(folder));
                }

                foreach (var objectDir in objectDirList)
                {
                    objectDir.GetInitialDirectoryState();
                }
                Logger.Log.Info("Waiting for new files...");
                while (true)
                {
                    foreach (var objectDir in objectDirList)
                    {
                        objectDir.RemindAboutNewFile();
                    }
                    Thread.Sleep(ConfigReader.GetSearchTimeout());
                }
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex);
            }
        }