Exemple #1
0
        /// <summary>
        /// Method to get calendar events
        /// </summary>
        /// <param name="uId">uId</param>
        public List <CalendarEventInfo> GetCalendarEvents(string uId)
        {
            try {
                SqlParameter[] parms = { new SqlParameter("@UID", SqlDbType.VarChar, 50) };
                parms[0].Value = uId;

                var calEvents = new List <CalendarEventInfo>();
                using (var rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SqlText.SQL_SELECT_CALENDAR_GETCALENDAREVENTS, parms)) {
                    while (rdr.Read())
                    {
                        var calEvent = new CalendarEventInfo();
                        calEvent.EventID    = ComUtility.DBNullInt32Handler(rdr["EventID"]);
                        calEvent.CalendarID = ComUtility.DBNullInt32Handler(rdr["CalendarID"]);
                        calEvent.Title      = ComUtility.DBNullStringHandler(rdr["Title"]);
                        calEvent.StartDate  = ComUtility.DBNullDateTimeHandler(rdr["StartDate"]);
                        calEvent.EndDate    = ComUtility.DBNullDateTimeHandler(rdr["EndDate"]);
                        calEvent.IsAllDay   = ComUtility.DBNullNullableBooleanHandler(rdr["IsAllDay"]);
                        calEvent.Notes      = ComUtility.DBNullStringHandler(rdr["Notes"]);
                        calEvent.Location   = ComUtility.DBNullStringHandler(rdr["Location"]);
                        calEvent.Reminder   = ComUtility.DBNullStringHandler(rdr["Reminder"]);
                        calEvent.Url        = ComUtility.DBNullStringHandler(rdr["Url"]);
                        calEvent.IsNew      = ComUtility.DBNullNullableBooleanHandler(rdr["IsNew"]);
                        calEvent.UID        = ComUtility.DBNullStringHandler(rdr["UID"]);
                        calEvent.UpdateTime = ComUtility.DBNullDateTimeHandler(rdr["UpdateTime"]);
                        calEvents.Add(calEvent);
                    }
                }
                return(calEvents);
            } catch { throw; }
        }
Exemple #2
0
        public string AddRecord(string record)
        {
            try {
                var rec      = (Event)JsonConvert.DeserializeObject(record, typeof(Event));
                var calEvent = new CalendarEventInfo();
                calEvent.CalendarID = (rec.CalendarId == null ? WebUtility.DefaultInt32 : (int)rec.CalendarId);
                calEvent.Title      = (rec.Title == null ? WebUtility.DefaultString : rec.Title);
                calEvent.StartDate  = (rec.StartDate == null ? WebUtility.DefaultDateTime : (DateTime)rec.StartDate);
                calEvent.EndDate    = (rec.EndDate == null ? WebUtility.DefaultDateTime : (DateTime)rec.EndDate);
                calEvent.IsAllDay   = rec.IsAllDay;
                calEvent.Notes      = (rec.Notes == null ? WebUtility.DefaultString : rec.Notes);
                calEvent.Location   = (rec.Location == null ? WebUtility.DefaultString : rec.Location);
                calEvent.Reminder   = (rec.Reminder == null ? WebUtility.DefaultString : rec.Reminder);
                calEvent.Url        = (rec.Url == null ? WebUtility.DefaultString : rec.Url);
                calEvent.IsNew      = false;
                calEvent.UID        = Page.User.Identity.Name;
                calEvent.UpdateTime = DateTime.Now;

                var calendarEntity = new BCalendar();
                calendarEntity.AddCalendarEvent(calEvent);
                var store = RightNavCalendarPanel.EventStore;
                BindStoreData(store);
                WebUtility.ShowNotify(EnmErrType.Info, String.Format("{0}<br/>事件保存成功!", rec.Title));
            } catch (Exception err) {
                WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name);
                WebUtility.ShowMessage(EnmErrType.Error, err.Message);
                return(err.Message);
            }
            return(String.Empty);
        }
Exemple #3
0
 /// <summary>
 /// Method to delete calendar event
 /// </summary>
 /// <param name="calEvent">calEvent</param>
 public bool DeleteCalendarEvent(CalendarEventInfo calEvent)
 {
     try {
         return(calDal.DeleteCalendarEvent(calEvent));
     } catch {
         throw;
     }
 }
Exemple #4
0
 /// <summary>
 /// Method to delete calendar event
 /// </summary>
 /// <param name="calEvent">calEvent</param>
 public bool DeleteCalendarEvent(CalendarEventInfo calEvent)
 {
     try {
         using (var conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction)) {
             conn.Open();
             var trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
             try {
                 SqlParameter[] parms = { new SqlParameter("@EventID", SqlDbType.Int) };
                 parms[0].Value = calEvent.EventID;
                 SqlHelper.ExecuteNonQuery(trans, CommandType.Text, SqlText.SQL_DELETE_CALENDAR_DELETECALENDAREVENT, parms);
                 trans.Commit();
             } catch { trans.Rollback(); throw; }
         }
     } catch { throw; }
     return(true);
 }
        private ICSCalendar CreateEventICSInfo(int eventId, string user, string cal)
        {
            ICSCalendar       calInfo   = new ICSCalendar();
            CalendarEventInfo eventInfo = GetCalendarEventInfo(eventId, user);

            calInfo.EventStartDateTime = eventInfo.StartTime ?? DateTime.UtcNow;
            calInfo.EventEndDateTime   = eventInfo.EndTime ?? DateTime.UtcNow;
            calInfo.OrganizerName      = "Rich See";
            calInfo.OrganizerEmail     = "*****@*****.**";
            calInfo.EventDescription   = eventInfo.Description; //Text to display in event info
            calInfo.EventSummary       = eventInfo.Title;
            calInfo.AlarmTrigger       = 30;
            calInfo.AlarmRepeat        = 2;
            calInfo.AlarmDuration      = 15;
            calInfo.AlarmDescription   = eventInfo.Title;
            return(calInfo);
        }
Exemple #6
0
        /// <summary>
        /// Method to add calendar event
        /// </summary>
        /// <param name="calEvent">calEvent</param>
        public bool AddCalendarEvent(CalendarEventInfo calEvent)
        {
            try {
                using (var conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction)) {
                    conn.Open();
                    var trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
                    try {
                        SqlParameter[] parms = { new SqlParameter("@CalendarID", SqlDbType.Int),
                                                 new SqlParameter("@Title",      SqlDbType.NVarChar,   255),
                                                 new SqlParameter("@StartDate",  SqlDbType.DateTime),
                                                 new SqlParameter("@EndDate",    SqlDbType.DateTime),
                                                 new SqlParameter("@IsAllDay",   SqlDbType.Bit),
                                                 new SqlParameter("@Notes",      SqlDbType.NVarChar,  1024),
                                                 new SqlParameter("@Location",   SqlDbType.NVarChar,   255),
                                                 new SqlParameter("@Reminder",   SqlDbType.NVarChar,   255),
                                                 new SqlParameter("@Url",        SqlDbType.VarChar,    255),
                                                 new SqlParameter("@IsNew",      SqlDbType.Bit),
                                                 new SqlParameter("@UID",        SqlDbType.VarChar,     50),
                                                 new SqlParameter("@UpdateTime", SqlDbType.DateTime) };

                        if (calEvent.CalendarID != ComUtility.DefaultInt32)
                        {
                            parms[0].Value = calEvent.CalendarID;
                        }
                        else
                        {
                            parms[0].Value = DBNull.Value;
                        }

                        if (calEvent.Title != ComUtility.DefaultString)
                        {
                            parms[1].Value = calEvent.Title;
                        }
                        else
                        {
                            parms[1].Value = DBNull.Value;
                        }

                        if (calEvent.StartDate != ComUtility.DefaultDateTime)
                        {
                            parms[2].Value = calEvent.StartDate;
                        }
                        else
                        {
                            parms[2].Value = DBNull.Value;
                        }

                        if (calEvent.EndDate != ComUtility.DefaultDateTime)
                        {
                            parms[3].Value = calEvent.EndDate;
                        }
                        else
                        {
                            parms[3].Value = DBNull.Value;
                        }

                        if (calEvent.IsAllDay != ComUtility.DefaultNullableBoolean)
                        {
                            parms[4].Value = calEvent.IsAllDay;
                        }
                        else
                        {
                            parms[4].Value = DBNull.Value;
                        }

                        if (calEvent.Notes != ComUtility.DefaultString)
                        {
                            parms[5].Value = calEvent.Notes;
                        }
                        else
                        {
                            parms[5].Value = DBNull.Value;
                        }

                        if (calEvent.Location != ComUtility.DefaultString)
                        {
                            parms[6].Value = calEvent.Location;
                        }
                        else
                        {
                            parms[6].Value = DBNull.Value;
                        }

                        if (calEvent.Reminder != ComUtility.DefaultString)
                        {
                            parms[7].Value = calEvent.Reminder;
                        }
                        else
                        {
                            parms[7].Value = DBNull.Value;
                        }

                        if (calEvent.Url != ComUtility.DefaultString)
                        {
                            parms[8].Value = calEvent.Url;
                        }
                        else
                        {
                            parms[8].Value = DBNull.Value;
                        }

                        if (calEvent.IsNew != ComUtility.DefaultNullableBoolean)
                        {
                            parms[9].Value = calEvent.IsNew;
                        }
                        else
                        {
                            parms[9].Value = DBNull.Value;
                        }

                        if (calEvent.UID != ComUtility.DefaultString)
                        {
                            parms[10].Value = calEvent.UID;
                        }
                        else
                        {
                            parms[10].Value = DBNull.Value;
                        }

                        if (calEvent.UpdateTime != ComUtility.DefaultDateTime)
                        {
                            parms[11].Value = calEvent.UpdateTime;
                        }
                        else
                        {
                            parms[11].Value = DBNull.Value;
                        }

                        SqlHelper.ExecuteNonQuery(trans, CommandType.Text, SqlText.SQL_INSERT_CALENDAR_ADDCALENDAREVENT, parms);
                        trans.Commit();
                    } catch { trans.Rollback(); throw; }
                }
            } catch { throw; }
            return(true);
        }