Exemplo n.º 1
0
        /// <summary>
        /// Gets an iCalendar version of the appointment
        /// </summary>
        /// <param name="Canceled">If true, it returns a cancellation version.
        /// If false, it returns a request version.</param>
        /// <returns>An iCalendar version of the appointment</returns>
        private string GetCalendar(bool Canceled)
        {
            string DateFormatUsing = "yyyyMMddTHHmmssZ";
            string Method;

            if (!Canceled)
            {
                Method = "REQUEST";
            }
            else
            {
                Method = "CANCEL";
            }
            string bodyCalendar = "BEGIN:VCALENDAR\r\nMETHOD:{10}\r\nPRODID:Microsoft CDO for Microsoft Exchange\r\nVERSION:2.0\r\nBEGIN:VTIMEZONE\r\nTZID:(GMT-06.00) Central Time (US & Canada)\r\nX-MICROSOFT-CDO-TZID:11\r\nBEGIN:STANDARD\r\nDTSTART:16010101T020000\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0600\r\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:16010101T020000\r\nTZOFFSETFROM:-0600\r\nTZOFFSETTO:-0500\r\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTAMP:{8}\r\nDTSTART:{0}\r\nSUMMARY:{7}\r\nUID:{5}\r\nATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"{9}\":MAILTO:{9}\r\nACTION;RSVP=TRUE;CN=\"{4}\":MAILTO:{4}\r\nORGANIZER;CN=\"{3}\":mailto:{4}\r\nLOCATION:{2}\r\nDTEND:{1}\r\nDESCRIPTION:{7}\\N\r\nSEQUENCE:1\r\nPRIORITY:5\r\nCLASS:\r\nCREATED:{8}\r\nLAST-MODIFIED:{8}\r\nSTATUS:CONFIRMED\r\nTRANSP:OPAQUE\r\nX-MICROSOFT-CDO-BUSYSTATUS:{11}\r\nX-MICROSOFT-CDO-INSTTYPE:0\r\nX-MICROSOFT-CDO-INTENDEDSTATUS:BUSY\r\nX-MICROSOFT-CDO-ALLDAYEVENT:FALSE\r\nX-MICROSOFT-CDO-IMPORTANCE:1\r\nX-MICROSOFT-CDO-OWNERAPPTID:-1\r\nX-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:{8}\r\nX-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:{8}\r\nBEGIN:VALARM\r\nACTION:DISPLAY\r\nDESCRIPTION:REMINDER\r\nTRIGGER;RELATED=START:-PT00H15M00S\r\nEND:VALARM\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";

            bodyCalendar = string.Format(bodyCalendar,
                                         StartDate.ToUniversalTime().ToString(DateFormatUsing),
                                         EndDate.ToUniversalTime().ToString(DateFormatUsing),
                                         Location,
                                         OrganizerName,
                                         OrganizerEmail,
                                         MeetingGUID.ToString("B"),
                                         Summary,
                                         Subject,
                                         DateTime.Now.ToUniversalTime().ToString(DateFormatUsing),
                                         AttendeeList.ToString(),
                                         Method,
                                         Status);
            return(bodyCalendar);
        }
Exemplo n.º 2
0
        public IActionResult UNRSVP(int id)
        {
            AttendeeList theRSVP = dbContext.AttendeeLists.FirstOrDefault(List => List.Activityid == id && List.Userid == loggedUser.Userid);

            dbContext.Remove(theRSVP);
            dbContext.SaveChanges();
            return(RedirectToAction("Home"));
        }
Exemplo n.º 3
0
        public void ShuffleAttendeeList()
        {
            _currentSelectionIdx = 0;
            var names = ShuffleNames(_appConfig.AttendeeNames);

            AttendeeList.Clear();
            AttendeeList.AddRange(names);
        }
        static void Main(string[] args)
        {
            Messaging.EventBus myBus                 = null;
            IDisposable        addConferenceSub      = null;
            IDisposable        newRegistrationSub    = null;
            IDisposable        cancelRegistrationSub = null;

            try
            {
                myBus            = new Messaging.EventBus();
                addConferenceSub = myBus.Subscribe <AddConferenceEvent>("AddConference",
                                                                        async x =>
                {
                    await ConferenceDetail.Handle(x);
                    await ConferenceList.Handle(x);
                });

                newRegistrationSub = myBus.Subscribe <NewRegistrationEvent>("NewRegistration", async x =>
                {
                    await ConferenceDetail.Handle(x);
                    await AttendeeList.Handle(x);
                });

                cancelRegistrationSub = myBus.Subscribe <CancelRegistrationEvent>("CancelRegistration", async x =>
                {
                    await ConferenceDetail.Handle(x);
                    await AttendeeList.Handle(x);
                });

                while (Console.ReadLine() != "quit")
                {
                    Thread.Sleep(int.MaxValue);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Event-Handler");
                Console.WriteLine(ex);
            }
            finally
            {
                addConferenceSub?.Dispose();
                newRegistrationSub?.Dispose();
                cancelRegistrationSub?.Dispose();

                myBus?.Dispose();
            }
        }
Exemplo n.º 5
0
        public async void GetDataListAttendeeAsync()
        {
            try
            {
                StorageFile file = await localfolder.GetFileAsync(filnavn);

                string jsonAttendee = await FileIO.ReadTextAsync(file);

                this.AttendeeList.Clear();
                AttendeeList.InsertJson(jsonAttendee);
            }
            catch (Exception)
            {
                MessageDialog NoDataList = new MessageDialog("No saved list yet", "Error");
                await NoDataList.ShowAsync();
            }
        }
Exemplo n.º 6
0
        public IActionResult Join(int id)
        {
            AttendeeList newAttendee = new AttendeeList();

            newAttendee.Userid     = loggedUser.Userid;
            newAttendee.Activityid = id;
            // checking if something is already scheduled then
            // User thisUser = dbContext.Users
            // .Include(u => u.attendingActivites)
            //     .ThenInclude(list => list.AnActivity)
            // .FirstOrDefault(u => u.Userid == loggedUser.Userid);
            // foreach(var activity in loggedUser.attendingActivites)
            // {
            //     if(activity.AnActivity.date == newAttendee.AnActivity.date)
            //     {
            //         ModelState.AddModelError("LogEmail", "Invalid Email/Password");
            //         return View("Index");
            //     }
            // }
            // enter into database and return
            dbContext.AttendeeLists.Add(newAttendee);
            dbContext.SaveChanges();
            return(RedirectToAction("Home"));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds an appointment to a user's calendar
        /// </summary>
        public virtual void AddAppointment()
        {
            string XMLNSInfo = "xmlns:g=\"DAV:\" "
                               + "xmlns:e=\"http://schemas.microsoft.com/exchange/\" "
                               + "xmlns:mapi=\"http://schemas.microsoft.com/mapi/\" "
                               + "xmlns:mapit=\"http://schemas.microsoft.com/mapi/proptag/\" "
                               + "xmlns:x=\"xml:\" xmlns:cal=\"urn:schemas:calendar:\" "
                               + "xmlns:dt=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" "
                               + "xmlns:header=\"urn:schemas:mailheader:\" "
                               + "xmlns:mail=\"urn:schemas:httpmail:\"";

            string CalendarInfo = "<cal:location>" + Location + "</cal:location>"                                                                               // + Location + "</cal:location>"
                                  + "<cal:dtstart dt:dt=\"dateTime.tz\">" + StartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.000Z") + "</cal:dtstart>" // + StartDate.ToUniversalTime().ToString("yyyyMMddTHHmmssZ") + "</cal:dtstart>"
                                  + "<cal:dtend dt:dt=\"dateTime.tz\">" + EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.000Z") + "</cal:dtend>"       // + EndDate.ToUniversalTime().ToString("yyyyMMddTHHmmssZ") + "</cal:dtend>"
                                  + "<cal:instancetype dt:dt=\"int\">0</cal:instancetype>"
                                  + "<cal:busystatus>" + Status + "</cal:busystatus>"
                                  + "<cal:meetingstatus>CONFIRMED</cal:meetingstatus>"
                                  + "<cal:alldayevent dt:dt=\"boolean\">0</cal:alldayevent>"
                                  + "<cal:responserequested dt:dt=\"boolean\">1</cal:responserequested>"
                                  + "<cal:reminderoffset dt:dt=\"int\">900</cal:reminderoffset>"
                                  + "<cal:uid>" + MeetingGUID.ToString("B") + "</cal:uid>";

            string HeaderInfo = "<header:to>" + AttendeeList.ToString() + "</header:to>";

            string MailInfo = "<mail:subject>" + Subject + "</mail:subject>"
                              + "<mail:htmldescription>" + Summary + "</mail:htmldescription>";

            string AppointmentRequest = "<?xml version=\"1.0\"?>"
                                        + "<g:propertyupdate " + XMLNSInfo + ">"
                                        + "<g:set><g:prop>"
                                        + "<g:contentclass>urn:content-classes:appointment</g:contentclass>"
                                        + "<e:outlookmessageclass>IPM.Appointment</e:outlookmessageclass>"
                                        + MailInfo
                                        + CalendarInfo
                                        + HeaderInfo
                                        + "<mapi:finvited dt:dt=\"boolean\">1</mapi:finvited>"
                                        + "</g:prop></g:set>"
                                        + "</g:propertyupdate>";

            System.Net.HttpWebRequest PROPPATCHRequest = (System.Net.HttpWebRequest)HttpWebRequest.Create(ServerName + "/exchange/" + Directory + "/Calendar/" + MeetingGUID.ToString() + ".eml");

            System.Net.CredentialCache MyCredentialCache = new System.Net.CredentialCache();
            if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
            {
                MyCredentialCache.Add(new System.Uri(ServerName + "/exchange/" + Directory + "/Calendar/" + MeetingGUID.ToString() + ".eml"),
                                      "NTLM",
                                      new System.Net.NetworkCredential(UserName, Password));
            }
            else
            {
                MyCredentialCache.Add(new System.Uri(ServerName + "/exchange/" + Directory + "/Calendar/" + MeetingGUID.ToString() + ".eml"),
                                      "Negotiate",
                                      (System.Net.NetworkCredential)CredentialCache.DefaultCredentials);
            }

            PROPPATCHRequest.Credentials = MyCredentialCache;
            PROPPATCHRequest.Method      = "PROPPATCH";
            byte[] bytes = Encoding.UTF8.GetBytes((string)AppointmentRequest);
            PROPPATCHRequest.ContentLength = bytes.Length;
            using (System.IO.Stream PROPPATCHRequestStream = PROPPATCHRequest.GetRequestStream())
            {
                PROPPATCHRequestStream.Write(bytes, 0, bytes.Length);
                PROPPATCHRequestStream.Close();
                PROPPATCHRequest.ContentType = "text/xml";
                System.Net.WebResponse PROPPATCHResponse = (System.Net.HttpWebResponse)PROPPATCHRequest.GetResponse();
                PROPPATCHResponse.Close();
            }
        }
        public virtual string GetICalendar()
        {
            StringBuilder FileOutput = new StringBuilder();

            FileOutput.AppendLine("BEGIN:VCALENDAR")
            .AppendLineFormat("METHOD:{0}", Cancel ? "CANCEL" : "REQUEST")
            .AppendLine("PRODID:-//Craigs Utility Library//EN")
            .AppendLine("VERSION:2.0")
            .AppendLine("BEGIN:VEVENT")
            .AppendLine("CLASS:PUBLIC")
            .AppendLineFormat("DTSTAMP:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture))
            .AppendLineFormat("CREATED:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture))
            .AppendLine(StripHTML(Description.Replace("<br />", System.Environment.NewLine)))
            .AppendLineFormat("DTStart:{0}", CurrentTimeZone.ToUniversalTime(StartTime).ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture))
            .AppendLineFormat("DTEnd:{0}", CurrentTimeZone.ToUniversalTime(EndTime).ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture))
            .AppendLineFormat("LOCATION:{0}", Location)
            .AppendLineFormat("SUMMARY;LANGUAGE=en-us:{0}", Subject)
            .AppendLineFormat("UID:{0}{1}{2}", CurrentTimeZone.ToUniversalTime(StartTime).ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture), CurrentTimeZone.ToUniversalTime(EndTime).ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture), Subject);
            if (AttendeeList.Count > 0)
            {
                FileOutput.AppendLineFormat("ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"{0}\":MAILTO:{0}", AttendeeList.ToString());
            }
            if (Organizer != null)
            {
                FileOutput.AppendLineFormat("ACTION;RSVP=TRUE;CN=\"{0}\":MAILTO:{0}\r\nORGANIZER;CN=\"{1}\":mailto:{0}", Organizer.Address, Organizer.DisplayName);
            }
            if (ContainsHTML(Description))
            {
                FileOutput.AppendLineFormat("X-ALT-DESC;FMTTYPE=text/html:{0}", Description.Replace("\n", ""));
            }
            else
            {
                FileOutput.AppendLineFormat("DESCRIPTION:{0}", Description);
            }
            return(FileOutput.AppendLine("SEQUENCE:1")
                   .AppendLine("PRIORITY:5")
                   .AppendLine("CLASS:")
                   .AppendLineFormat("LAST-MODIFIED:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture))
                   .AppendLine("STATUS:CONFIRMED")
                   .AppendLine("TRANSP:OPAQUE")
                   .AppendLineFormat("X-MICROSOFT-CDO-BUSYSTATUS:{0}", Status)
                   .AppendLine("X-MICROSOFT-CDO-INSTTYPE:0")
                   .AppendLine("X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY")
                   .AppendLine("X-MICROSOFT-CDO-ALLDAYEVENT:FALSE")
                   .AppendLine("X-MICROSOFT-CDO-IMPORTANCE:1")
                   .AppendLine("X-MICROSOFT-CDO-OWNERAPPTID:-1")
                   .AppendLineFormat("X-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture))
                   .AppendLineFormat("X-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:{0}", DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture))
                   .AppendLine("BEGIN:VALARM")
                   .AppendLine("TRIGGER;RELATED=START:-PT00H15M00S")
                   .AppendLine("ACTION:DISPLAY")
                   .AppendLine("DESCRIPTION:Reminder")
                   .AppendLine("END:VALARM")
                   .AppendLine("END:VEVENT")
                   .AppendLine("END:VCALENDAR")
                   .ToString());
        }