Пример #1
0
        public void insertevent(calendar_globalevent newe, Guid target )
        {
            string sourceuser= (Membership.GetUser(newe.userid,true)).UserName;
            string targuser="";
            calendar_notification newnot = null;
            if(target!=null)
               targuser = (Membership.GetUser(target,true)).UserName;

            if (newe.eventtype == "addfriend")
            {
                //here we dont need to init redirecturl, because we only need it when the event is "new calendar event added", which redirecturl is the link to the new event
                newe.content = sourceuser + " added " + targuser + " as a friend !";
                DAL.GlobalEvent_DAL.insertevent(db, newe);
                if (!sourceuser.Equals(targuser))
                {
                    //add notification says someone added him as friend
                    newnot = new calendar_notification();
                    newnot.eventtype = "addfriend";
                    newnot.content = sourceuser + " added you as friend";
                    newnot.userid = target;
                    newnot.userid2 = newe.userid;
                    DAL.Notification_DAL.insert(db, newnot);

                }
            }

            else if (newe.eventtype == "commentedOnWall")
            {
                //here we dont need to init redirecturl, because we only need it when the event is "new calendar event added", which redirecturl is the link to the new event
                newe.content = sourceuser + " Commented on " + targuser + "'s wall !";
                DAL.GlobalEvent_DAL.insertevent(db, newe);
                if (!sourceuser.Equals(targuser))
                {
                    //add notification says someone commented on his wall
                    newnot = new calendar_notification();
                    newnot.content = sourceuser + " commented on your wall";
                    newnot.userid = target;
                    newnot.userid2 = newe.userid;
                    newnot.eventtype = "commentedOnWall";
                    DAL.Notification_DAL.insert(db, newnot);
                }
            }
            else if (newe.eventtype == "addedcalevent")
            {
                //here we dont need to init redirecturl, because we only need it when the event is "new calendar event added", which redirecturl is the link to the new event
                newe.content = sourceuser + " Created Calendar Event: " + targuser + "'s wall !";
                DAL.GlobalEvent_DAL.insertevent(db, newe);
            }
        }
Пример #2
0
        protected void bt_newEvent(object sender, EventArgs e)
        {
            ((Panel)this.loginview.FindControl("container")).Visible = false;
            ViewState["cont_visible"] = false;
            calendar_entity db = new calendar_entity();
            string unm = Membership.GetUser().UserName;
            Guid uid = (from user in db.aspnet_Users
                      where user.UserName == unm
                      select user.UserId).Single();

            DateTime start = ((Calendar)this.loginview.FindControl("mycalendar")).SelectedDate;
            DateTime end = ((Calendar)this.loginview.FindControl("mycalendar")).SelectedDate;
            start=start.AddHours( ((TimeSelector)this.loginview.FindControl("startTimeSel")).Hour);
            start=start.AddMinutes( ((TimeSelector)this.loginview.FindControl("startTimeSel")).Minute);

            end = end.AddHours(((TimeSelector)this.loginview.FindControl("endTimeSel")).Hour);
            end = end.AddMinutes(((TimeSelector)this.loginview.FindControl("endTimeSel")).Minute);

               calendar_event evt= calendarContext.insertEvent(uid,
                                         Guid.NewGuid(),
                                         ((TextBox)this.loginview.FindControl("tittle")).Text,
                                         ((TextBox)this.loginview.FindControl("TextBox1")).Text,
                                         ((TextBox)this.loginview.FindControl("TextBox2")).Text,
                                        ((Calendar)this.loginview.FindControl("mycalendar")).SelectedDate,
                                         start,
                                         end);

            calendar_globalevent newge=new calendar_globalevent(){ userid=uid, eventtype="addedcalevent", createtime=DateTime.Today};
               this.globalevent_context.insertevent(newge,this.Page,evt);
            //calendar_event newe = new calendar_event()
            //{

            //    UserId = uid,
            //    eventid = Guid.NewGuid(),
            //    content = ((TextBox)this.loginview.FindControl("TextBox1")).Text,
            //    place = ((TextBox)this.loginview.FindControl("TextBox2")).Text,
            //    createtime = ((Calendar)this.loginview.FindControl("mycalendar")).SelectedDate
            //};

            //db.calendar_event.AddObject(newe);
            //db.SaveChanges();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the calendar_globalevent EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTocalendar_globalevent(calendar_globalevent calendar_globalevent)
 {
     base.AddObject("calendar_globalevent", calendar_globalevent);
 }
 /// <summary>
 /// Create a new calendar_globalevent object.
 /// </summary>
 /// <param name="eventid">Initial value of the eventid property.</param>
 /// <param name="eventtype">Initial value of the eventtype property.</param>
 /// <param name="userid">Initial value of the userid property.</param>
 /// <param name="createtime">Initial value of the createtime property.</param>
 /// <param name="content">Initial value of the content property.</param>
 public static calendar_globalevent Createcalendar_globalevent(global::System.Guid eventid, global::System.String eventtype, global::System.Guid userid, global::System.DateTime createtime, global::System.String content)
 {
     calendar_globalevent calendar_globalevent = new calendar_globalevent();
     calendar_globalevent.eventid = eventid;
     calendar_globalevent.eventtype = eventtype;
     calendar_globalevent.userid = userid;
     calendar_globalevent.createtime = createtime;
     calendar_globalevent.content = content;
     return calendar_globalevent;
 }
Пример #5
0
        public void insertevent(calendar_globalevent newe, Page page,calendar_event evt )
        {
            /*handels new calendar event case, eventtittle is the event tittle*/
            string sourceuser = (Membership.GetUser(newe.userid, true)).UserName;
            string targuser  = (Membership.GetUser(evt.UserId, true)).UserName;
            calendar_notification newnot = null;
            if (newe.eventtype == "addedcalevent")
            {
                //here we dont need to init redirecturl, because we only need it when the event is "new calendar event added", which redirecturl is the link to the new event
                newe.content = sourceuser + " Created Calendar Event: " + evt.tittle;
            }
            else if (newe.eventtype == "joinevent")
            {
                newe.content = sourceuser + " joined " + targuser+" 's Event: "+evt.tittle;

                if (!sourceuser.Equals(targuser))
                {
                    newnot = new calendar_notification();
                    newnot.content = sourceuser + " Joined your event: "+evt.tittle;
                    newnot.userid = evt.UserId;
                    newnot.userid2 = newe.userid;
                    newnot.eventtype = "joinevent";
                    newnot.redirecturl = "eventroom.aspx?eventid=" + evt.eventid + "&tittle=" + evt.tittle + "&event=" +
                                        page.Server.UrlEncode(evt.content) + "&username="******"&date=" + evt.createtime + "&place=" + evt.place;
                    DAL.Notification_DAL.insert(db, newnot);
                }
            }
                newe.redirecturl = "eventroom.aspx?eventid=" + evt.eventid + "&tittle=" + evt.tittle + "&event=" +
                                    page. Server.UrlEncode(evt.content) + "&username="******"&date=" + evt.createtime + "&place=" + evt.place;

                DAL.GlobalEvent_DAL.insertevent(db, newe);
        }