private void CheckMeetingStatus()
 {
     try
     {
         con = new SqlConnection(cs.DBConn);
         con.Open();
         string qr2 = "SELECT MAX(Meeting.MeetingId) FROM Meeting";
         cmd = new SqlCommand(qr2, con);
         rdr = cmd.ExecuteReader();
         if (rdr.Read())
         {
             if (!(rdr.IsDBNull(0)))
             {
                 meetingId = (rdr.GetInt32(0));
                 this.Hide();
                 MeetingEntry frm = new MeetingEntry();
                 frm.Show();
             }
             else
             {
                 MessageBox.Show("Please Create  or Shedule a meeting First.", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
 public MeetingEntry(MeetingEntry entry)
 {
     start   = entry.start;
     end     = entry.end;
     url     = entry.url;
     label   = entry.label;
     comment = entry.comment;
 }
Beispiel #3
0
        private void LoadSchududle()
        {
            if (!File.Exists(options.SrcFile))
            {
                throw new FileNotFoundException("File " + options.SrcFile + " dont exists.");
            }

            StreamReader fileStream = File.OpenText(options.SrcFile);

            Meetings = new Queue <MeetingEntry>();
            while (!fileStream.EndOfStream)
            {
                String       line = fileStream.ReadLine();
                MeetingEntry me   = new MeetingEntry();
                int          idxb = line.LastIndexOf('(');
                int          idxe = line.LastIndexOf(')');
                int          diff = idxe - idxb;
                me.label = line.Substring(0, idxb);
                String[] time = line.Substring(idxb + 1, diff - 1).Split('-');
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write(me.label + " ");
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine(time[0] + " " + time[1]);
                me.start = TimeSpan.ParseExact(time[0], "h\\:mm", System.Globalization.CultureInfo.InvariantCulture);
                me.end   = TimeSpan.ParseExact(time[1], "h\\:mm", System.Globalization.CultureInfo.InvariantCulture);
                String url = fileStream.ReadLine();
                if (url.StartsWith("https://"))
                {
                    me.url = new Uri(url);
                }
                else
                {
                    me.comment = url;
                }

                Meetings.Enqueue(me);
            }
            fileStream.Close();
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("Shedule loaded.");
            Console.ResetColor();
        }
Beispiel #4
0
        } //Todo

        private void ActivateMeeting()
        {
            while (Meetings.Count != 0)
            {
                if (driver.Url != "data:,")
                {
                    driver.Navigate().GoToUrl("data:,");
                }

                ActiveMeeting = Meetings.Dequeue();
                if (ActiveMeeting.url == null)
                {
                    continue;
                }

                //Time managment
                if (ActiveMeeting.url != null && ActiveMeeting.start.CompareTo(DateTime.Now.TimeOfDay) == 1)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Title           = "Waiting to start " + ActiveMeeting.label + " in " + ActiveMeeting.start + ".";
                    Console.WriteLine(Console.Title);
                    Task.Delay(ActiveMeeting.start - DateTime.Now.TimeOfDay).Wait();
                }
                else if (!(DateTime.Now.TimeOfDay - ActiveMeeting.start < ActiveMeeting.end - ActiveMeeting.start))
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine(ActiveMeeting.label + " gone.");
                    continue;
                }

                Console.ForegroundColor = ConsoleColor.Green;
                Console.Title           = "Connecting to " + ActiveMeeting.label + ".";
                Console.WriteLine(Console.Title);

                driver.Navigate().GoToUrl(ActiveMeeting.url);

                driver.FindElements(By.CssSelector("button.btn.primary"))[1].Click();

                //Try login
                try
                {
                    Miscellaneous.Timeout(() => {
                        var e = driver.FindElement(By.LinkText("войти"));
                        try
                        {
                            e.Click();
                            return(0);
                        }
                        catch (Exception)
                        {
                            return(-1);
                        }
                    }, TimeSpan.FromSeconds(4));
                    Miscellaneous.Timeout(() => { return(Login()); }, ActiveMeeting.end - DateTime.Now.TimeOfDay);
                }
                catch (NoSuchElementException ex) { }

                Miscellaneous.Timeout(() => {
                    var e = driver.FindElement(
                        By.CssSelector("button.join-btn.ts-btn.inset-border.ts-btn-primary"));
                    try
                    {
                        e.Click();
                        return(0);
                    }
                    catch (Exception)
                    {
                        return(-1);
                    }
                }, ActiveMeeting.end - DateTime.Now.TimeOfDay);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Title           = "Connected.";
                Console.WriteLine(Console.Title);


                Task.Delay(ActiveMeeting.end - DateTime.Now.TimeOfDay).Wait();
                Console.WriteLine(ActiveMeeting.label + " Ended.");
            }
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.Title           = "No meetings.";
            Console.WriteLine(Console.Title);
            SaveConfig();

            Console.ResetColor();
        }