Esempio n. 1
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            string username = tbLoginUsername.Text;
            string password = tbLoginPassword.Text;

            if (SqLite.IsLoginSuccessful(username, password))
            {
                User user = SqLite.QueryLoggedInUser(username);
                if (user.AccountTypeId == 3)
                {
                    var developerWindow = new DeveloperWindow();
                    this.Close();
                    developerWindow.Show();
                }
                else
                {
                    MatchSelectWindow matchSelectWindow = new MatchSelectWindow(user);
                    this.Close();
                    matchSelectWindow.Show();
                }
            }
            else
            {
                tbLoginUsername.Clear();
                tbLoginPassword.Clear();
                MessageBox.Show("Invalid username or password");
            }
        }
Esempio n. 2
0
        private void GenerateGrid()  // retrieves all record from MASTERBALLOT table and binds to datagrid
        {
            List <BallotData> list = new List <BallotData>();

            // dgBallotMaster.ItemsSource = null;

            sqlite_conn = SqLite.OpenSQLLiteConnection(sqlite_conn);
            DataTable dt;

            using (SQLiteDataAdapter Sqa = new SQLiteDataAdapter("Select BALLOT_ID , " + " CASE WHEN  ELECTION_FOR ='P' then 'Parliamentary'  " + " when ELECTION_FOR ='A' then 'Assembly' " + " end ELECTION_FOR ,  " + "STATE_CODE ,LANGUAGE_1 , LANGUAGE_2 , " + " CASE WHEN IS_FINALIZED ='N'  then 'No' else 'Yes' end IS_FINALIZED " + " , FINALIZATION_DATE from " + " MASTERBALLOT", sqlite_conn))
            {
                dt = new DataTable();
                Sqa.Fill(dt);  // fill the dataset
            }
            foreach (DataRow row in dt.Rows)
            {
                list.Add(new BallotData()
                {
                    BallotID           = Convert.ToInt32(row["BALLOT_ID"]),
                    state              = row["STATE_CODE"].ToString(),
                    constituency       = row["ELECTION_FOR"].ToString(),
                    language1          = row["LANGUAGE_1"].ToString(),
                    language2          = row["LANGUAGE_2"].ToString(),
                    IsFinalized        = row["IS_FINALIZED"].ToString(),
                    dateOfFinalization = row["FINALIZATION_DATE"].ToString()
                });
            }
            Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { dgBallotMaster.ItemsSource = list; }));
            SqLite.CloseSQLLiteConnection(sqlite_conn);
        }
Esempio n. 3
0
        internal static int?AddPhotoToDb(PhotoSize photoLarge)
        {
            var photoId = GetPhotoId_From_FileId_OR_UniqueFileId(photoLarge.FileId, photoLarge.FileUniqueId);

            if (photoId != null)
            {
                return(photoId.Value);
            }

            const string q =
                "INSERT INTO Photos (file_id, file_size, height, width, unique_id) VALUES (@fi, @fs, @h, @w, @u)";
            var keyValuePairs = new Dictionary <string, object>
            {
                { "@fi", photoLarge.FileId },
                { "@fs", photoLarge.FileSize },
                { "@h", photoLarge.Height },
                { "@w", photoLarge.Width },
                { "@u", photoLarge.FileUniqueId }
            };

            SqLite.Execute(q, keyValuePairs);
            Tables.FixIdTable("Photos", "id_photo", "file_id");

            return(GetPhotoId_From_FileId_OR_UniqueFileId(photoLarge.FileId, photoLarge.FileUniqueId));
        }
Esempio n. 4
0
        private void btnEvent_click(object sender, EventArgs e)
        {
            Seat seat = Seats.Find(x => x.Name == ((Control)sender).Text);

            if (SqLite.IsTicketSelectedByUser(seat.Id, match.Id, user.Id))
            {
                SqLite.UnselectTicket(seat.Id, match.Id);
                ((Control)sender).BackColor = Color.White;
            }
            else if (SqLite.IsTicketOwnedByUser(seat.Id, match.Id, user.Id))
            {
                string message = "This ticket is already yours.";
                MessageBox.Show(message);
            }
            else if (SqLite.IsTicketSelected(seat.Id, match.Id) || SqLite.IsTicketOwned(seat.Id, match.Id))
            {
                string message = "This ticket is not available.";
                MessageBox.Show(message);
            }
            else
            {
                SqLite.SelectTicket(seat.Id, match.Id, user.Id);
                ((Control)sender).BackColor = Color.Yellow;
            }
        }
Esempio n. 5
0
        private void BtnDevDisconnect_Click(object sender, EventArgs e)
        {
            string message = "Disconnected from Database";

            SqLite.Disconnect();
            MessageBox.Show(message);
        }
Esempio n. 6
0
        public MainWindow(Match match, User user)
        {
            this.user  = user;
            this.match = match;


            InitializeComponent();

            if (SqLite.IsAdmin(user.Id))
            {
                int sizeX = 1124;
                int sizeY = 524;
                this.MinimumSize = new Size(sizeX, sizeY);
                this.Size        = new Size(sizeX, sizeY);
                this.MaximumSize = new Size(sizeX, sizeY);
                adminControl1.InitAdmin(match);
            }
            else
            {
                adminControl1.Hide();
                int sizeX = 794;
                int sizeY = 524;
                this.MinimumSize = new Size(sizeX, sizeY);
                this.Size        = new Size(sizeX, sizeY);
                this.MaximumSize = new Size(sizeX, sizeY);
            }

            stadiumControl1.InitStadium(match, user);

            lblMainUser.Text    = "Logged in as: " + user.AccountName;
            testMatchLabel.Text = match.TeamHome + " " + match.TeamAway;
        }
Esempio n. 7
0
        private void BtnDevClearData_Click(object sender, EventArgs e)
        {
            string message = "Data Cleared";

            SqLite.ClearData();
            MessageBox.Show(message);
        }
Esempio n. 8
0
        public static int?AddVideoToDb(Video video)
        {
            var photoId = GetVideoId_From_FileId_OR_UniqueFileId(video.FileId, video.FileUniqueId);

            if (photoId != null)
            {
                return(photoId.Value);
            }

            var q =
                "INSERT INTO Videos " +
                "(file_id, file_size, height, width, unique_id, duration, mime) " +
                " VALUES " +
                "(@fi, @fs, @h, @w, @u, @d, @mime)";


            var keyValuePairs = new Dictionary <string, object>
            {
                { "@fi", video.FileId },
                { "@fs", video.FileSize },
                { "@h", video.Height },
                { "@w", video.Width },
                { "@u", video.FileUniqueId },
                { "@d", video.Duration },
                { "@mime", video.MimeType }
            };

            SqLite.Execute(q, keyValuePairs);
            Tables.FixIdTable("Videos", "id_video", "file_id");

            return(GetVideoId_From_FileId_OR_UniqueFileId(video.FileId, video.FileUniqueId));
        }
        public IList <ConnectionInfo> GetList()
        {
            List <ConnectionInfo> list = new List <ConnectionInfo>();
            string    sql = "select * from ConnectionInfo;";
            DataTable dt  = SqLite.Select(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    list.Add(new ConnectionInfo()
                    {
                        Id        = int.Parse(row["Id"].ToString()),
                        FServer   = row["FServer"].ToString(),
                        FType     = int.Parse(row["FType"].ToString()),
                        FUserId   = row["FUserId"].ToString(),
                        FPassword = row["FPassword"].ToString(),
                        FRemember = int.Parse(row["FRemember"].ToString())
                    });
                }
            }

            return(list);


            //string connString = null;//SettingManager.GetSettingValue("sqlite");
            //connString = "Data Source=T4CodeGenerator.db;";
            //using (SQLiteConnection conn = new SQLiteConnection(connString))
            //{
            //    if (conn.State != ConnectionState.Open)
            //    {
            //        conn.Open();
            //    }
            //    using (SQLiteCommand cmd = new SQLiteCommand(conn))
            //    {
            //        SQLiteHelper helper = new SQLiteHelper(cmd);

            //        string sql = "select * from ConnectionInfo;";
            //        DataTable dt = helper.Select(sql);
            //        if (dt != null && dt.Rows.Count > 0)
            //        {
            //            foreach (DataRow row in dt.Rows)
            //            {
            //                list.Add(new ConnectionInfo()
            //                {
            //                    Id = int.Parse(row["Id"].ToString()),
            //                    FServer = row["FServer"].ToString(),
            //                    FType = int.Parse(row["FType"].ToString()),
            //                    FUserId = row["FUserId"].ToString(),
            //                    FPassword = row["FPassword"].ToString(),
            //                    FRemember = int.Parse(row["FRemember"].ToString())
            //                });
            //            }
            //        }
            //    }

            //    conn.Close();
            //}
            //return list;
        }
Esempio n. 10
0
        private void BtnDevGenerateTickets_Click(object sender, EventArgs e)
        {
            string message = "Tickets generated";

            SqLite.GenerateTickets();
            MessageBox.Show(message);
        }
Esempio n. 11
0
        private static Tuple <bool, List <string> > CheckIfLimitOfMaxKingsHasBeenReached(
            TelegramBotAbstract telegramBotClient, MessageEventArgs e, string t)
        {
            var q = "SELECT * FROM Primo";
            var r = SqLite.ExecuteSelect(q);

            if (r == null || r.Rows.Count == 0)
            {
                return(new Tuple <bool, List <string> >(false, null));
            }

            var countOfUser = CountOfUserMethod(r, e);

            if (countOfUser == null)
            {
                return(new Tuple <bool, List <string> >(false, null));
            }

            if (countOfUser.Count >= 2)
            {
                return(new Tuple <bool, List <string> >(true, countOfUser));
            }

            return(new Tuple <bool, List <string> >(false, null));
        }
Esempio n. 12
0
        private void BtnDevConnect_Click(object sender, EventArgs e)
        {
            string message = "Connected to Database";

            SqLite.Connect();
            MessageBox.Show(message);
        }
Esempio n. 13
0
        public static async Task <bool> CheckIfToExitAndUpdateGroupList(TelegramBotAbstract sender, MessageEventArgs e)
        {
            switch (e.Message.Chat.Type)
            {
            case ChatType.Private:
                return(false);

            case ChatType.Group:
                break;

            case ChatType.Channel:
                break;

            case ChatType.Supergroup:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            const string q1 = "SELECT id, valid FROM Groups WHERE id = @id";
            var          dt = SqLite.ExecuteSelect(q1, new Dictionary <string, object> {
                { "@id", e.Message.Chat.Id }
            });

            if (dt != null && dt.Rows.Count > 0)
            {
                return(await CheckIfToExit(sender, e, dt.Rows[0].ItemArray[1]));
            }

            InsertGroup(sender, e);
            return(await CheckIfToExit(sender, e, null));
        }
        private void BtnCheckoutPurchase_Click(object sender, EventArgs e)
        {
            string emailContent    = "";
            int    incomeGenerated = 0;

            //Change selected tickets to owned tickets
            foreach (var ticket in Tickets)
            {
                emailContent += "Seat: " + ticket.SeatId + " Type: " + ticket.TicketTypeId;
                SqLite.BuyTicket(ticket.SeatId, ticket.MatchId);
                int income = SqLite.QueryTicketPrice(ticket.TicketTypeId);
                incomeGenerated += income;
            }

            //Update user
            User.FirstName = TbCheckoutFirstName.Text;
            User.LastName  = TbCheckoutLastName.Text;
            SqLite.UpdateUser(User.Id, User.FirstName, User.LastName);

            //Update match income
            SqLite.IncreaseIncome(incomeGenerated, Match.Id);

            //Send email
            SendEmail(emailContent);

            MainWindow mainWindow = new MainWindow(Match, User);

            mainWindow.Show();
            this.Close();
        }
Esempio n. 15
0
        private static bool AddGroupToDb2(ChatJson chat, DateTime?lastUpdateLinkTime, bool?we_are_admin,
                                          int botIdWhoInsertedThem)
        {
            try
            {
                const string q1 = "INSERT INTO Groups (id, bot_id, type, title, link, last_update_link, valid) " +
                                  " VALUES " +
                                  " (@id, @botid, @type, @title, @link, @lul, @valid)";
                SqLite.Execute(q1, new Dictionary <string, object>
                {
                    { "@id", chat.id },
                    { "@botid", botIdWhoInsertedThem },
                    { "@type", chat.type },
                    { "@title", chat.title },
                    { "@link", chat.invite_link },
                    { "@lul", lastUpdateLinkTime },
                    { "@valid", we_are_admin }
                });
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Esempio n. 16
0
        private void BtnDevLoadData_Click(object sender, EventArgs e)
        {
            string message = "Data Loaded";

            SqLite.LoadDefaultData();
            MessageBox.Show(message);
        }
        private void _SqLiteWriter_DoWork(object sender, DoWorkEventArgs e)
        {
            var messageQuery = "SELECT * from whldata.messenger_messages WHERE threadID = 0 ";
            var threadQuery  = "SELECT * from whldata.messenger_threads where participantid = " +
                               AuthdEmployee.PayrollId.ToString() + ";";

            foreach (var pair in _currentThreads)
            {
                messageQuery += " OR threadid = " + pair.Key;
            }
            var results       = SQLServer.MSSelectDataDictionary(messageQuery);
            var threadresults = SQLServer.MSSelectDataDictionary(threadQuery);

            foreach (var result in results)
            {
                var query =
                    "REPLACE INTO messenger_messages (messageid,participantid,messagecontent,timestamp,threadid) VALUES ('" +

                    result["messageid"].ToString() + "','" + result["participantid"].ToString() + "','" +
                    result["messagecontent"] + "','" + result["timestamp"].ToString() + "','" + result["threadid"].ToString() + "');";
                Console.WriteLine(SqLite.SqliteOtherQuery(query));
            }
            foreach (var result in threadresults)
            {
                var query =
                    "REPLACE INTO messenger_messages (idmessenger_threads,threadid,participantid, notified,istwoway) VALUES ('" +
                    result["idmessenger_threads"].ToString() + "','" + result["threadid"].ToString() + "','" +
                    result["participantid"].ToString() + "','" + result["notified"].ToString() + "','" + result["istwoway"].ToString() +
                    "');";
                Console.WriteLine(SqLite.SqliteOtherQuery(query));
            }
        }
Esempio n. 18
0
        public void OpenCheckoutWindow()
        {
            SelectedTickets = SqLite.QuerySelectedTickets(match.Id, user.Id);
            CheckoutWindow checkoutWindow = new CheckoutWindow(match, user, SelectedTickets);

            checkoutWindow.Show();
            ((Form)stadiumControl.TopLevelControl).Close();
        }
Esempio n. 19
0
 public void InitAdmin(Match match)
 {
     this.match           = match;
     ticketTypes          = SqLite.QueryTicketTypes();
     tickets              = SqLite.QueryOwnedTickets(match.Id);
     TextAdminIncome.Text = SqLite.CalculateMatchIncome(match.Id).ToString();
     LoadTicketsToListViewAll();
     LoadTicketToListViewByType();
 }
        public static async Task <Tuple <ToExit, ChatMember[], List <int>, string> > CheckIfToExitAndUpdateGroupList(
            TelegramBotAbstract sender, MessageEventArgs e)
        {
            switch (e.Message.Chat.Type)
            {
            case ChatType.Private:
                return(new Tuple <ToExit, ChatMember[], List <int>, string>(ToExit.STAY, null, new List <int> {
                    13
                },
                                                                            "private"));

            case ChatType.Group:
                break;

            case ChatType.Channel:
                break;

            case ChatType.Supergroup:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            //start | exclude groups, bot will not operate in them
            if (e.Message.Chat.Id == ConfigAnon.ModAnonCheckGroup)
            {
                return(new Tuple <ToExit, ChatMember[], List <int>, string>(ToExit.STAY, null, new List <int> {
                    30
                }, null));
            }
            //end | exclude groups

            const string q1 = "SELECT id, valid FROM Groups WHERE id = @id";
            var          dt = SqLite.ExecuteSelect(q1, new Dictionary <string, object> {
                { "@id", e.Message.Chat.Id }
            });

            if (dt != null && dt.Rows.Count > 0)
            {
                var r1 = await CheckIfToExit(sender, e, dt.Rows[0].ItemArray[1]);

                r1.Item3.Insert(0, 11);
                return(r1);
            }

            InsertGroup(sender, e);
            var r2 = await CheckIfToExit(sender, e, null);

            var list2 = r2.Item3;

            list2.Insert(0, 12);
            return(new Tuple <ToExit, ChatMember[], List <int>, string>(r2.Item1, r2.Item2, list2, r2.Item4));
        }
        /// <summary>
        /// Interaction for the program's initial load
        /// </summary>
        private void Messenger_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var file        = new StreamReader(@"Z:\DomainProfiles\WHL\AutoLogin");
                var payrollcode = file.ReadToEnd();
                payrollcode   = payrollcode.Replace("qzu", "");
                AuthdEmployee = _empcol.FindEmployeeByID(int.Parse(payrollcode));
                file.Close();
            }
            catch (Exception)
            {
                var loginwindow = new Login();
                loginwindow.ShowDialog();
            }
            while (AuthdEmployee == null)
            {
                var loginwindow = new Login();
                loginwindow.ShowDialog();
            }
            _isOffline = SQLServer.TestConn();

            _threadLoader.DoWork += ThreadLoader_DoWork;
            _threadLoader.WorkerSupportsCancellation = true;
            _threadLoader.RunWorkerAsync();

            _threadRefreshTimer.Interval = new TimeSpan(0, 0, 0, 1);
            _threadRefreshTimer.Tick    += RefreshTimer_Tick;
            _threadRefreshTimer.Start();
            _refreshLatestThread.Interval = new TimeSpan(0, 0, 0, 10);
            _refreshLatestThread.Tick    += RefreshLatestThread_Tick;
            _refreshLatestThread.Start();

            _threadContactLoader.Interval = new TimeSpan(0, 0, 0, 30);
            _threadContactLoader.Tick    += ThreadLoaderTimerTick;
            _threadContactLoader.Start();

            _threadFinder.DoWork                    += ThreadFinder_DoWork;
            _threadFinder.RunWorkerCompleted        += ThreadLoader_RunWorkerCompleted;
            _threadFinder.WorkerSupportsCancellation = true;

            _sqLiteWriter.DoWork             += _SqLiteWriter_DoWork;
            _sqLiteWriter.RunWorkerCompleted += _SqLiteWriter_RunWorkerCompleted;

            _currentStatusChecker.Tick    += _currentStatusChecker_Tick;
            _currentStatusChecker.Interval = new TimeSpan(1000);
            _currentStatusChecker.Start();

            LoadThreads(); //Load the thread data
            TypeBox.IsReadOnly = true;
            LoadContactInfo();
            SqLite.PrepareDb();
            _updateSqliteDb = true;
        }
        public void EnsureOutputCanBeParsedExists()
        {
            var getFileBenchmark = new FileExistsBenchmark();
            var sqLite           = new SqLite(getFileBenchmark.SqLitePath);

            // run the setup
            getFileBenchmark.ChooseFile();

            var exists = sqLite.FileExists(getFileBenchmark.SqLiteFileRowId16384, getFileBenchmark.CurrentFile);

            Assert.IsTrue(exists);
        }
Esempio n. 23
0
        private int GetBallotId() // gets incremented ballot id to insert new record in MASTERBALLOT table
        {
            sqlite_conn = SqLite.OpenSQLLiteConnection(sqlite_conn);
            string commandstring = "select  COALESCE(max(ballot_id) ,0)   from MASTERBALLOT";

            sqlite_cmd             = sqlite_conn.CreateCommand();
            sqlite_cmd.CommandText = commandstring;
            object objMax = sqlite_cmd.ExecuteScalar();
            int    cntMax = Convert.ToInt32(objMax) + 1;

            return(cntMax);
        }
Esempio n. 24
0
        private static async Task MaybeKing(TelegramBotAbstract telegramBotClient, MessageEventArgs e, string t,
                                            bool toInsert)
        {
            var tooManyKingsForThisUser = CheckIfLimitOfMaxKingsHasBeenReached(telegramBotClient, e, t);

            if (tooManyKingsForThisUser.Item1 == false)
            {
                if (toInsert)
                {
                    var q2 = "INSERT INTO Primo (title, firstname, lastname, when_king, king_id) " +
                             " VALUES " +
                             " (@title, @fn, @ln, @wk, @ki)";

                    var r2 = SqLite.Execute(q2, new Dictionary <string, object>
                    {
                        { "@title", t },
                        { "@fn", e.Message.From.FirstName },
                        { "@ln", e.Message.From.LastName },
                        { "@wk", DateTime.Now },
                        { "@ki", e.Message.From.Id }
                    });
                }
                else
                {
                    var q3 =
                        "UPDATE Primo SET when_king = @wk, king_id = @ki, firstname = @fn, lastname = @ln WHERE title = @t";
                    var dict3 = new Dictionary <string, object>
                    {
                        { "@t", t },
                        { "@fn", e.Message.From.FirstName },
                        { "@ln", e.Message.From.LastName },
                        { "@wk", DateTime.Now },
                        { "@ki", e.Message.From.Id }
                    };
                    var r3 = SqLite.Execute(q3, dict3);
                }

                await SendMessageYouAreKingAsync(telegramBotClient, e, t);

                return;
            }

            var roles = GetRoles(tooManyKingsForThisUser.Item2);
            var dict4 = new Dictionary <string, string>
            {
                { "it", "Hai già troppi ruoli!" + roles },
                { "en", "You have already too many titles!" + roles }
            };
            var text = new Language(dict4);
            var r4   = await SendMessage.SendMessageInAGroup(telegramBotClient, e.Message.From.LanguageCode, text,
                                                             e.Message.Chat.Id, e.Message.Chat.Type, ParseMode.Html, e.Message.MessageId, true);
        }
Esempio n. 25
0
        private static bool AddAssocToDb(string name, IReadOnlyCollection <long> users)
        {
            const string q1 = "INSERT INTO Entities (Name) VALUES (@name)";

            _ = SqLite.Execute(q1, new Dictionary <string, object> {
                { "@name", name }
            });

            Tables.FixIdTable("Entities", "id", "name");

            const string q2 = "SELECT id FROM Entities WHERE Name = @name";
            var          r2 = SqLite.ExecuteSelect(q2, new Dictionary <string, object> {
                { "@name", name }
            });

            var r3 = SqLite.GetFirstValueFromDataTable(r2);
            int?r4 = null;

            try
            {
                r4 = Convert.ToInt32(r3);
            }
            catch
            {
                ;
            }

            if (r4 == null)
            {
                return(false);
            }

            if (users == null)
            {
                return(true);
            }

            if (users.Count == 0)
            {
                return(true);
            }

            foreach (var u in users)
            {
                const string q3 = "INSERT INTO PeopleInEntities (id_entity, id_person) VALUES (@ide, @idp)";
                _ = SqLite.Execute(q3, new Dictionary <string, object> {
                    { "@ide", r4.Value }, { "@idp", u }
                });
            }

            return(true);
        }
Esempio n. 26
0
        private void LoadTicketsToListViewAll()
        {
            for (int i = 0; i < tickets.Count; i++)
            {
                string fullName    = SqLite.QueryUserFullName(tickets[i].UserId);      //ki
                string seatName    = SqLite.QuerySeatName(tickets[i].SeatId);          //hova
                int    ticketPrice = SqLite.QueryTicketPrice(tickets[i].TicketTypeId); // milyen ertekben

                var ticketListView = new ListViewItem(new[] { seatName, fullName, ticketPrice.ToString() });

                LvAdminTicketsAll.Items.Add(ticketListView);
            }
        }
Esempio n. 27
0
        private static void InsertGroup(TelegramBotAbstract sender, MessageEventArgs e)
        {
            const string q1 = "INSERT INTO Groups (id, bot_id, type, title) VALUES (@id, @botid, @type, @title)";

            SqLite.Execute(q1, new Dictionary <string, object>
            {
                { "@id", e.Message.Chat.Id },
                { "@botid", sender.GetId() },
                { "@type", e.Message.Chat.Type.ToString() },
                { "@title", e.Message.Chat.Title }
            });
            _ = CreateInviteLinkAsync(sender, e);
        }
Esempio n. 28
0
        private void LoadMatchesToListView()
        {
            List <Match> MatchesList = SqLite.QueryListOfMatches();

            for (int i = 0; i < MatchesList.Count; i++)
            {
                var matchListView = new ListViewItem(new[] { MatchesList[i].TeamHome, MatchesList[i].TeamAway })
                {
                    Text = MatchesList[i].TeamHome,
                    Tag  = MatchesList
                };
                matchSelectLvMatches.Items.Add(matchListView);
            }
        }
Esempio n. 29
0
        private void BtnDevConnectionState_Click(object sender, EventArgs e)
        {
            string state;

            if (SqLite.IsConnected() == true)
            {
                state = "Connected";
            }
            else
            {
                state = "Disconnected";
            }

            MessageBox.Show(state);
        }
Esempio n. 30
0
        private static async Task <int?> QueryBot2(bool execute_true_select_false, MessageEventArgs e,
                                                   TelegramBotAbstract sender)
        {
            if (e.Message.ReplyToMessage == null || string.IsNullOrEmpty(e.Message.ReplyToMessage.Text))
            {
                var text = new Language(new Dictionary <string, string>
                {
                    { "en", "You have to reply to a message containing the query" }
                });
                await sender.SendTextMessageAsync(e.Message.From.Id, text, ChatType.Private,
                                                  e.Message.From.LanguageCode, ParseMode.Html, null, e.Message.From.Username, e.Message.MessageId);

                return(null);
            }

            var query = e.Message.ReplyToMessage.Text;

            if (execute_true_select_false)
            {
                var i = SqLite.Execute(query);

                var text = new Language(new Dictionary <string, string>
                {
                    { "en", "Query execution. Result: " + i }
                });
                await sender.SendTextMessageAsync(e.Message.From.Id, text, ChatType.Private,
                                                  e.Message.From.LanguageCode, ParseMode.Html, null, e.Message.From.Username, e.Message.MessageId);

                return(i);
            }

            var x             = SqLite.ExecuteSelect(query);
            var x2            = StreamSerialization.SerializeToStream(x);
            var documentInput =
                new TelegramFile(x2, "table.bin", "Query result", "application/octet-stream");
            TLAbsInputPeer peer2 = new TLInputPeerUser {
                UserId = e.Message.From.Id
            };
            var peer  = new Tuple <TLAbsInputPeer, long>(peer2, e.Message.From.Id);
            var text2 = new Language(new Dictionary <string, string>
            {
                { "en", "Query result" }
            });
            var v = await sender.SendFileAsync(documentInput, peer, text2, TextAsCaption.AS_CAPTION,
                                               e.Message.From.Username, e.Message.From.LanguageCode, e.Message.MessageId, false);

            return(v ? 1 : 0);
        }