コード例 #1
0
        public static void GetAllUsers(TelegramBotClient botClient, CallbackQuery _message, User user)
        {
            DataBase db = Singleton.GetInstance().Context;
            //создание файла
            String    files     = AppDomain.CurrentDomain.BaseDirectory + "\\newdoc.xls";
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = new Worksheet("Пользователи");

            worksheet.Cells[0, 0] = new Cell("ФИО");
            worksheet.Cells[0, 1] = new Cell("Username");
            worksheet.Cells[0, 2] = new Cell("Номер");
            worksheet.Cells[0, 3] = new Cell("Дата регистрации");

            User[] Users = db.GetUsers();

            IQueryable <User> temp  = Users.OrderByDescending(p => p.DateRegister).AsQueryable();
            Int32             count = 1;

            foreach (User ThisUser in temp)
            {
                worksheet.Cells[count + 1, 0] = new Cell(ThisUser.FIO);
                worksheet.Cells[count + 1, 1] = new Cell(ThisUser.Username);
                worksheet.Cells[count + 1, 2] = new Cell(ThisUser.Number);
                worksheet.Cells[count + 1, 3] = new Cell(ThisUser.DateRegister.Date.ToString("dd/MM/yyyy"));
                count++;
            }

            workbook.Worksheets.Add(worksheet);
            workbook.Save(files);
            SendMessage(botClient, _message, user, "Пользователи");
        }
コード例 #2
0
        private async Task <Boolean> SendNotificationAllUsers(TelegramBotClient botClient)
        {
            User[]       users        = db.GetUsers();
            InlineButton inlineButton = new InlineButton();
            var          temp         = inlineButton.PublishNotification(CollectionNotification);
            var          picture      = db.GetListCollectionPictureNotification(TextAndButton);

            /*List<IAlbumInputMedia> pictureList = new List<IAlbumInputMedia>();
             * if (picture.Count > 1)
             * {
             *      pictureList.Add(new InputMediaPhoto() { Media = picture[0].Picture});
             * }*/

            foreach (var ThisUser in users)
            {
                if (ThisUser.ID == user.ID)
                {
                    if (picture == null)
                    {
                        await botClient.SendTextMessageAsync(ThisUser.ID, TextAndButton.Text.Text, replyMarkup : temp);
                    }
                    else
                    {
                        await botClient.SendPhotoAsync(ThisUser.ID, picture[0].Picture, TextAndButton.Text.Text,
                                                       replyMarkup : temp);
                    }
                }
            }

            var tempList = db.GetListCollectionButtonNotification();

            foreach (CollectionButtonNotification collectionButtonNotification in tempList)
            {
                db.Remove(collectionButtonNotification);
            }

            foreach (CollectionPictureNotification collectionPictureNotification in picture)
            {
                db.Remove(collectionPictureNotification);
            }

            var TextTemp = db.GetTextNotification(TextAndButton.Text);

            db.Remove(TextAndButton);
            db.Remove(TextTemp);
            db.Save();

            return(true);
        }
コード例 #3
0
        public async Task Execute(IJobExecutionContext context)
        {
            DataBase db = Singleton.GetInstance().Context;

            User[] users = db.GetUsers();
            foreach (User user in users)
            {
                if (user.DateRegister.Month + 1 == System.DateTime.Today.Month)
                {
                    user.CountReviews = 3;
                    user.DateRegister = System.DateTime.Today;
                }
            }
            db.Save();
        }