Example #1
0
        public static string GenerateInfoXML(string accessCode, WebexHostInfo hostInfo)
        {
            string strXML = "<?xml version=\"1.0\" encoding=\"ISO - 8859 - 1\"?>\r\n";

            strXML += "<serv:message xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:serv=\"http://www.webex.com/schemas/2002/06/service\">\r\n";
            strXML += "<header>\r\n";
            strXML += "<securityContext>\r\n";
            strXML += $"<webExID>{hostInfo.ID}</webExID>\r\n";
            strXML += $"<password>{hostInfo.Password}</password>\r\n";
            strXML += $"<siteName>{hostInfo.Company}</siteName>\r\n";
            strXML += $"<email>{hostInfo.Email}</email>\r\n";
            strXML += "</securityContext>\r\n";
            strXML += "</header>\r\n";
            strXML += "<body>\r\n";
            strXML += "<bodyContent xsi:type=\"java:com.webex.service.binding.meeting.GetMeeting\">\r\n";
            strXML += "<meetingKey>";
            strXML += accessCode;
            strXML += "</meetingKey>\r\n";
            strXML += "</bodyContent>\r\n";
            strXML += "</body>\r\n";
            strXML += "</serv:message>\r\n";


            return(strXML);
        }
Example #2
0
        public static DateTime GetMeetingTimeByXML(string accessCode, WebexHostInfo meetingInfo)
        {
            Console.WriteLine(">\tRetrieving Meeting Info...");
            string strXMLServer = "https://companykm.my.webex.com/WBXService/XMLService";

            WebRequest request = WebRequest.Create(strXMLServer);

            // Set the Method property of the request to POST.
            request.Method = "POST";
            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";

            // Create POST data and convert it to a byte array.
            string strXML = XMLHelper.GenerateInfoXML(accessCode, meetingInfo);

            byte[] byteArray = Encoding.UTF8.GetBytes(strXML);

            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;

            // Get the request stream.
            Stream dataStream = request.GetRequestStream();

            // Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length);
            // Close the Stream object.
            dataStream.Close();
            // Get the response.
            WebResponse response = request.GetResponse();

            // Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();

            // Display the content.
            string startDate = XMLHelper.RetrieveStartDate(responseFromServer);

            //Time zone format is like ABC-H:MM, Common (Specific). Just take zone code.
            string timeZone = XMLHelper.RetrieveTimeZone(responseFromServer).Split(" ")[0];

            timeZone = Regex.Split(timeZone, @"-?\d+")[0];

            Console.WriteLine("startTime: " + startDate);
            Console.WriteLine("timeZone: " + timeZone);

            DateTime meetingTime;

            DateTime.TryParse($"{startDate}", out meetingTime);

            // Clean up the streams.
            reader.Close();
            dataStream.Close();
            response.Close();

            return(meetingTime);
        }
Example #3
0
 public MeetingInfo()
 {
     Meeting         = new DatabaseManager.Data.Meeting();
     Names           = new List <string>();
     HostInfo        = new WebexHostInfo();
     AttendeesEmails = new List <SendGrid.Helpers.Mail.EmailAddress>();
     Meeting.MeetingStartDateTime = new DateTime();
     Meeting.MeetingEndDateTime   = new DateTime();
 }
Example #4
0
        public MeetingInfo(DatabaseManager.Data.Meeting meeting, List <EmailAddress> attendeesEmails,
                           string password = "", WebexHostInfo hostInfo = null)

        {
            Meeting         = meeting;
            AttendeesEmails = attendeesEmails;
            HostInfo        = hostInfo;

            Names = GetNames();
        }
Example #5
0
        /// <summary>
        /// Handles a Webex invite email. Creates MeetingInfo object
        /// containing metadata about this meeting.
        /// </summary>
        /// <param name="emailBody"></param>
        /// <param name="appConfig"></param>
        /// <returns></returns>
        public static MeetingInfo HandleEmail(string emailBody, string emailSubject, string organizerEmail, IConfigurationRoot appConfig)
        {
            var hostInfo = new WebexHostInfo(appConfig["WEBEX_EMAIL"],
                                             appConfig["WEBEX_PW"], appConfig["WEBEX_ID"], appConfig["WEBEX_COMPANY"]);


            if (EmailListener.IsValidWebexInvitation(emailBody))
            {
                var meetingInfo = EmailListener.GetMeetingInfoFromWebexInvite(emailBody, emailSubject, hostInfo);
                meetingInfo.AttendeesEmails = MeetingController.GetAttendeeEmails(meetingInfo);

                return(meetingInfo);
            }


            return(null);
        }
Example #6
0
        public IActionResult Create(MeetingClass mc, string Participants, string ParticiNames, string HostName, string HostEmail)
        {
            WebexHostInfo meetingHost = new WebexHostInfo("!!ADD WEBEX HOST EMAIL!!", "!!ADD WEBEX HOST PW!!", "!ADD WEBEX HOST ID!!", "!!ADD WEBEX COMPANY NAME!!");

            List <string> emails           = new List <string>(Participants.Split(','));
            List <string> names            = new List <string>(ParticiNames.Split(','));
            string        startDateTimeStr = mc.MeetingStartDateTime.ToString("MM/dd/yyyy HH:mm:ss");
            string        endDateTimeStr   = mc.MeetingEndDateTime.ToString("MM/dd/yyyy HH:mm:ss");
            Int64         duration         = (Int64)(mc.MeetingEndDateTime - mc.MeetingStartDateTime).TotalMinutes;

            emails.Add(HostEmail);
            emails.Add("!!ADD BOT EMAIL ACCOUNT!!");
            names.Add(HostName);
            names.Add("bot");

            //emails = emails.Select(s => s.Trim());

            for (int i = 0; i < emails.Count; i++)
            {
                emails[i] = emails[i].Trim();
            }

            for (int i = 0; i < names.Count; i++)
            {
                names[i] = names[i].Trim();
            }

            Microsoft.Graph.EmailAddress delegateEmailAddress = new Microsoft.Graph.EmailAddress();
            delegateEmailAddress.Name    = HostName.Trim();
            delegateEmailAddress.Address = HostEmail.Trim();
            var meetingInfo = MeetingController.CreateWebexMeeting(mc.MeetingSubject, names, emails, mc.MeetingStartDateTime, duration.ToString(), meetingHost, delegateEmailAddress);

            mc.WebExID = meetingInfo.AccessCode;

            /*try
             * {C:\repos\Final_Successful\cs319-2019w1-hsbc\WebMVC\Views\
             *  var attendees = MeetingController.GetAttendeeEmails(access_code, meetingHost);
             *  //MeetingController.SendEmailsToAnyUnregisteredUsers(attendees);
             *  //EmailSender.SendEmailForStartURL(attendees, access_code, mc.MeetingSubject);
             * }
             * catch (Exception ex)
             * {
             *  //Console.WriteLine(ex);
             *  Trace.WriteLine(ex);
             * }
             *
             * try
             * {
             *  // TODO warning this part is hardcoded
             *  //SchedulerController.ScheduleTask(access_code, mc.MeetingStartDate, "Main.exe", @"C:\cs319_main");
             * }
             * catch (Exception ex)
             * {
             *
             * }*/

            //_amc.Add(mc);
            //_amc.SaveChanges();
            ViewBag.message = "The Meeting " + mc.MeetingSubject + " Is Saved Successfully!";
            return(View());
        }
Example #7
0
        public static string GenerateMeetingXML(string meetingSubject, List <string> names, List <string> emails, string startTime, string duration,
                                                WebexHostInfo hostInfo, Microsoft.Graph.EmailAddress hostDelegate = default)
        {
            string strXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";

            strXML += "<serv:message xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n";
            strXML += "<header>\r\n";
            strXML += "<securityContext>\r\n";
            strXML += $"<webExID>{hostInfo.ID}</webExID>\r\n";
            strXML += $"<password>{hostInfo.Password}</password>\r\n";
            strXML += $"<siteName>{hostInfo.Company}</siteName>\r\n";
            strXML += $"<email>{hostInfo.Email}</email>\r\n";
            strXML += "</securityContext>\r\n";
            strXML += "</header>\r\n";
            strXML += "<body>\r\n";
            strXML += "<bodyContent xsi:type=\"java:com.webex.service.binding.meeting.CreateMeeting\">\r\n";
            strXML += "<accessControl>\r\n";
            strXML += "<meetingPassword>pZGiw4JU</meetingPassword>\r\n";
            strXML += "</accessControl>\r\n";
            strXML += "<metaData>\r\n";
            strXML += "<confName>" + meetingSubject + "</confName>\r\n";
            strXML += "<agenda>Test</agenda>\r\n";
            strXML += "</metaData>\r\n";
            strXML += "<participants>\r\n";
            strXML += "<maxUserNumber>10</maxUserNumber>\r\n";
            strXML += "<attendees>\r\n";
            strXML += GenerateAttendeeElement(names, emails, hostDelegate.Address);
            strXML += "</attendees>\r\n";
            strXML += "</participants>\r\n";
            strXML += "<enableOptions>\r\n";
            strXML += "<chat>true</chat>\r\n";
            strXML += "<poll>true</poll>\r\n";
            strXML += "<audioVideo>true</audioVideo>\r\n";
            strXML += "<supportE2E>TRUE</supportE2E>\r\n";
            strXML += "<autoRecord>TRUE</autoRecord>\r\n";
            strXML += "</enableOptions>\r\n";
            strXML += "<schedule>\r\n";
            strXML += "<startDate>";
            strXML += startTime;
            strXML += "</startDate>\r\n";
            strXML += "<openTime>900</openTime>\r\n";
            strXML += "<joinTeleconfBeforeHost>true</joinTeleconfBeforeHost>\r\n";
            strXML += "<duration>";
            strXML += duration;
            strXML += "</duration>\r\n";
            strXML += "</schedule>\r\n";
            strXML += "<telephony>\r\n";
            strXML += "<telephonySupport>CALLIN</telephonySupport>\r\n";
            strXML += "<extTelephonyDescription>";
            strXML += "Call 1-800-555-1234, Passcode 98765";
            strXML += "</extTelephonyDescription>\r\n";
            strXML += "</telephony>\r\n";
            strXML += "<attendeeOptions>";
            strXML += "<emailInvitations>TRUE</emailInvitations>\r\n";
            strXML += "</attendeeOptions>\r\n";
            strXML += "</bodyContent>\r\n";
            strXML += "</body>\r\n";
            strXML += "</serv:message>\r\n";

            return(strXML);
        }
Example #8
0
        /// <summary>
        /// Parses an html body email element to create a MeetingInfo object.
        /// </summary>
        /// <param name="inviteBody"></param>
        /// <param name="subject"></param>
        /// <param name="organizerAddress"></param>
        /// <param name="hostInfo"></param>
        /// <returns></returns>
        public static Meeting.MeetingInfo GetMeetingInfoFromWebexInvite(string inviteBody, string subject, WebexHostInfo hostInfo)
        {
            if (inviteBody is null)
            {
                throw new Exception("Email body was <NULL>");
            }

            if (!IsValidWebexInvitation(inviteBody))
            {
                throw new Exception("Not a Webex Meeting Invitation Email");
            }

            var meetingInfo = GetMeetingInfoFromWebexHTML(inviteBody, subject);

            meetingInfo.HostInfo = hostInfo;

            /*Add all other meeting attendees to meetingInfo*/
            meetingInfo.AttendeesEmails = Meeting.MeetingController.GetAttendeeEmails(meetingInfo);

            meetingInfo.AttendeesEmails = meetingInfo.AttendeesEmails.Distinct().ToList();

            foreach (var attendee in meetingInfo.AttendeesEmails)
            {
                Console.WriteLine("\t-\t" + attendee.Email);
            }

            return(meetingInfo);
        }
Example #9
0
        /// <summary>
        /// Creates a webex meeting with the specified parameters. Note that duration is in minutes.
        /// </summary>
        /// <param name="meetingSubject"></param>
        /// <param name="names"></param>
        /// <param name="emails"></param>
        /// <param name="duration"></param>
        /// <param name="hostInfo"></param>
        /// <returns></returns>
        public static MeetingInfo CreateWebexMeeting(string meetingSubject,
                                                     List <string> names,
                                                     List <string> emails,
                                                     DateTime startTime,
                                                     string duration,
                                                     WebexHostInfo hostInfo,
                                                     Microsoft.Graph.EmailAddress delegateEmail)
        {
            string strXMLServer = "https://companykm.my.webex.com/WBXService/XMLService";

            WebRequest request = WebRequest.Create(strXMLServer);

            // Set the Method property of the request to POST.
            request.Method = "POST";
            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";

            // Create POST data and convert it to a byte array.
            // string strXML = GenerateXMLCreateMeeting();

            string formattedStartTime = startTime.ToString("MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

            string strXML = XMLHelper.GenerateMeetingXML(meetingSubject, names, emails, formattedStartTime, duration, hostInfo, delegateEmail);

            //string strXML = XMLHelper.GenerateMeetingXML(meetingSubject, names, emails, formattedStartTime, duration, hostInfo);

            byte[] byteArray = Encoding.UTF8.GetBytes(strXML);

            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;

            // Get the request stream.
            Stream dataStream = request.GetRequestStream();

            // Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length);
            // Close the Stream object.
            dataStream.Close();
            // Get the response.
            WebResponse response = request.GetResponse();

            // Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();

            // Display the content.
            string accessCode = XMLHelper.RetrieveAccessCode(responseFromServer);

            // Clean up the streams.
            reader.Close();
            dataStream.Close();
            response.Close();


            Console.WriteLine("\tMeeting has been successfully created");


            var endTime = startTime.AddMinutes(double.Parse(duration));

            /*Convert email list to Sendgrid email objects */
            var sendGridEmails = EmailListener.ParseEmailList(emails);

            /*Store meeting record in database for the created meeting */
            var         meeting     = DatabaseController.CreateMeeting(emails, startTime, endTime, accessCode, meetingSubject);
            MeetingInfo meetingInfo = new MeetingInfo(meeting, sendGridEmails, "", hostInfo);


            /*Send an email to allow host or delegates to start the meeting */
            EmailSender.SendEmailForStartURL(meetingInfo, new EmailAddress(delegateEmail.Address, delegateEmail.Name));

            return(meetingInfo);
        }