Exemple #1
0
        private CalendarEventEntity GetCalendarEntityFromIDataReader(DbDataReader dr)
        {
            CalendarEventEntity dt = new CalendarEventEntity();
            if (dr.FieldCount > 0)
            {
                dt.Content = dr["CalendarEventContent"].ToString();
                dt.EmailNote = dr["CalendarEventEmailNote"].ToString();
                dt.EndTime = DateTime.Parse(dr["CalendarEventEndTime"].ToString());
                dt.Invite = dr["CalendarEventInvite"].ToString();
                dt.Note = dr["CalendarEventNote"].ToString();
                dt.NoteBefore = Int32.Parse(dr["CalendarEventNoteBefore"].ToString());
                dt.Repeat = dr["CalendarEventRepeat"].ToString();
                dt.RepeatRate = Int32.Parse(dr["CalendarEventRepeatRate"].ToString());

                dt.StartTime = DateTime.Parse(dr["CalendarEventStartTime"].ToString());
                dt.Title = dr["CalendarEventTitle"].ToString();
                dt.Type = Int32.Parse(dr["CalendarEventType"].ToString());
                dt.Userial = Int32.Parse(dr["CalendarEventUserial"].ToString());
                dt.UserID = Int32.Parse(dr["CalendarEventUserID"].ToString());

                dr.Close();
                return dt;
            }
            dr.Close();
            return null;
        }
Exemple #2
0
 public int UpDateCalendarEvnetByID(CalendarEventEntity _CalendarEventEntity)
 {
     DbParameter[] pramsUpDate = {
                                    MakeInParam("@CalendarEventTitle",(DbType)SqlDbType.VarChar,50,_CalendarEventEntity.Title),
                                    MakeInParam("@CalendarEventContent",(DbType)SqlDbType.VarChar,100,_CalendarEventEntity.Content),
                                    MakeInParam("@CalendarEventType",(DbType)SqlDbType.Int,4,_CalendarEventEntity.Type),
                                    MakeInParam("@CalendarEventStartTime",(DbType)SqlDbType.DateTime,50,_CalendarEventEntity.StartTime),
                                    MakeInParam("@CalendarEventEndTime",(DbType)SqlDbType.DateTime,50,_CalendarEventEntity.EndTime),
                                    MakeInParam("@CalendarEventInvite",(DbType)SqlDbType.VarChar,1000,_CalendarEventEntity.Invite),
                                    MakeInParam("@CalendarEventEmailNote",(DbType)SqlDbType.VarChar,50,_CalendarEventEntity.EmailNote),
                                    MakeInParam("@CalendarEventNote",(DbType)SqlDbType.VarChar,50,_CalendarEventEntity.Note),
                                    MakeInParam("@CalendarEventNoteBefore",(DbType)SqlDbType.Int ,4,_CalendarEventEntity.NoteBefore),
                                    MakeInParam("@CalendarEventRepeat",(DbType)SqlDbType.VarChar,50,_CalendarEventEntity.Repeat),
                                    MakeInParam("@CalendarEventRepeatRate",(DbType)SqlDbType.Int,4,_CalendarEventEntity.RepeatRate),
                                    MakeInParam("@CalendarEventUserID",(DbType)SqlDbType.Int,4,_CalendarEventEntity.UserID),
                                   MakeInParam("@CalendarEventUserial",(DbType)SqlDbType.Int,4,_CalendarEventEntity.Userial),
                 };
     StringBuilder sb = new StringBuilder();
     sb.Append("UpDate [dbo].[CalendarEvent]");
     sb.Append(" set ");
     sb.Append(" [CalendarEventUserial]=@CalendarEventUserial,");
     sb.Append(" [CalendarEventUserID]=@CalendarEventUserID,");
     sb.Append(" [CalendarEventTitle]=@CalendarEventTitle,");
     sb.Append(" [CalendarEventContent]=@CalendarEventContent,");
     sb.Append(" [CalendarEventType]=@CalendarEventType,");
     sb.Append(" [CalendarEventStartTime]=@CalendarEventStartTime,");
     sb.Append(" [CalendarEventEndTime]=@CalendarEventEndTime,");
     sb.Append(" [CalendarEventInvite]=@CalendarEventInvite,");
     sb.Append(" [CalendarEventEmailNote]=@CalendarEventEmailNote,");
     sb.Append(" [CalendarEventNote]=@CalendarEventNote,");
     sb.Append(" [CalendarEventNoteBefore]=@CalendarEventNoteBefore,");
     sb.Append(" [CalendarEventRepeat]=@CalendarEventRepeat,");
     sb.Append(" [CalendarEventRepeatRate]=@CalendarEventRepeatRate");
     sb.Append(" where [CalendarEventUserial]=@CalendarEventUserial  and [CalendarEventUserID]=@CalendarEventUserID");
     sb.Append(" select @@identity;");
     return Int32.Parse(ExecuteScalar(CommandType.Text, sb.ToString(), pramsUpDate).ToString());
 }
Exemple #3
0
        public int AddNewsCalenderEvent(CalendarEventEntity _CalendarEvent)
        {
            DbParameter[] pramsInsert = {
                                           MakeInParam("@CalendarEventTitle",(DbType)SqlDbType.VarChar,50,_CalendarEvent.Title),
                                           MakeInParam("@CalendarEventContent",(DbType)SqlDbType.VarChar,100,_CalendarEvent.Content),
                                           MakeInParam("@CalendarEventType",(DbType)SqlDbType.Int,4,_CalendarEvent.Type),
                                           MakeInParam("@CalendarEventStartTime",(DbType)SqlDbType.DateTime,50,_CalendarEvent.StartTime),
                                           MakeInParam("@CalendarEventEndTime",(DbType)SqlDbType.DateTime,50,_CalendarEvent.EndTime),
                                           MakeInParam("@CalendarEventInvite",(DbType)SqlDbType.VarChar,1000,_CalendarEvent.Invite),
                                           MakeInParam("@CalendarEventEmailNote",(DbType)SqlDbType.VarChar,50,_CalendarEvent.EmailNote),
                                           MakeInParam("@CalendarEventNote",(DbType)SqlDbType.VarChar,50,_CalendarEvent.Note),
                                           MakeInParam("@CalendarEventNoteBefore",(DbType)SqlDbType.Int ,4,_CalendarEvent.NoteBefore),
                                           MakeInParam("@CalendarEventRepeat",(DbType)SqlDbType.VarChar,50,_CalendarEvent.Repeat),
                                           MakeInParam("@CalendarEventRepeatRate",(DbType)SqlDbType.Int,4,_CalendarEvent.RepeatRate),
                                           MakeInParam("@CalendarEventUserID",(DbType)SqlDbType.Int,4,_CalendarEvent.UserID),
                                             };
            StringBuilder sb = new StringBuilder();
            sb.Append("INSERT INTO [dbo].[CalendarEvent]");
            sb.Append("([CalendarEventTitle]");
            sb.Append(",[CalendarEventContent]");
            sb.Append(",[CalendarEventType]");
            sb.Append(",[CalendarEventStartTime]");
            sb.Append(",[CalendarEventEndTime]");
            sb.Append(",[CalendarEventInvite]");
            sb.Append(",[CalendarEventEmailNote]");
            sb.Append(",[CalendarEventNote]");
            sb.Append(",[CalendarEventNoteBefore]");
            sb.Append(",[CalendarEventRepeat]");
            sb.Append(",[CalendarEventRepeatRate]");
            sb.Append(",[CalendarEventUserID]");
            sb.Append(")");
            sb.Append("VALUES");
            sb.Append("(@CalendarEventTitle");
            sb.Append(",@CalendarEventContent");
            sb.Append(",@CalendarEventType");
            sb.Append(",@CalendarEventStartTime");
            sb.Append(",@CalendarEventEndTime");
            sb.Append(",@CalendarEventInvite");
            sb.Append(",@CalendarEventEmailNote");
            sb.Append(",@CalendarEventNote");
            sb.Append(",@CalendarEventNoteBefore");
            sb.Append(",@CalendarEventRepeat");
            sb.Append(",@CalendarEventRepeatRate");
            sb.Append(",@CalendarEventUserID");
            sb.Append(")");
            sb.Append(" select @@identity;");

            return Int32.Parse(ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString());
        }
Exemple #4
0
        public void ProcessRequest(HttpContext context)
        {
            string myaction = context.Request.Params["action"];
            string temp = "";
            if (myaction.ToLower() == "add")
            {
                string Title = context.Request.Params["TxtTitle"];
                string Content = context.Request.Params["TxtContent"];
                string Type = context.Request.Params["drType"];
                string BeginTime = context.Request.Params["TxtBeginTime"];
                string EndTime = context.Request.Params["TxtEndTime"];
                string Invite = context.Request.Params["TxtInvite"];
                string ckRemind = context.Request.Params["ckTiXing"];  //是否提醒
                string Remind = context.Request.Params["drTiXing"];   //多久提醒
                string ckRepeat = context.Request.Params["ckRepeat"];  //是否重复
                string RepeatRate = context.Request.Params["drRepeatRate"];  //重复频率
                string ckEmailNote = context.Request.Params["ckEmailNote"];  //是否邮件提醒

                CalendarEventEntity _CalendarEvent = new CalendarEventEntity();
                _CalendarEvent.Content = Content;
                _CalendarEvent.EmailNote = ckEmailNote;
                _CalendarEvent.EndTime = DateTime.Parse(EndTime);
                _CalendarEvent.Invite = Invite;
                _CalendarEvent.Note = ckRemind;
                _CalendarEvent.NoteBefore = Int16.Parse(Remind);
                _CalendarEvent.Repeat = ckRepeat;
                _CalendarEvent.RepeatRate = Int16.Parse(RepeatRate);
                _CalendarEvent.StartTime = DateTime.Parse(BeginTime);
                _CalendarEvent.Title = Title;
                _CalendarEvent.Type = Int16.Parse(Type);
                _CalendarEvent.UserID = Int32.Parse(context.Session["UserID"].ToString());
                int id = DbHelper.GetInstance().AddNewsCalenderEvent(_CalendarEvent);

                     string[] UserList = Invite.Split(',');
                    foreach(string UserID in UserList)
                    {
                        if (UserID != "")
                        {
                            if (ckEmailNote == "true")  //发邮件提醒
                            {
                                EmailEntity _EmailEntity = new EmailEntity();
                                _EmailEntity.UserID = context.Session["UserID"].ToString();
                                _EmailEntity.SenderID = UserID;
                                _EmailEntity.ReceiverID = context.Session["UserID"].ToString();
                                _EmailEntity.SendTime = DateTime.Now;
                                _EmailEntity.ReceiveTime = DateTime.Now;
                                _EmailEntity.MailTitle = "[提醒]" + Title;
                                _EmailEntity.MailContent = Content;
                                _EmailEntity.ISRead = 0;  //0: 未读   1: 已读  2:删除(非彻底删除)
                                _EmailEntity.SecretSenderID = "";
                                _EmailEntity.IsScret = 0;
                                _EmailEntity.AttachID = "";
                                _EmailEntity.UserMasterID = 0;
                                string szResult = DbHelper.GetInstance().AddEmailInfor(_EmailEntity);
                            }
                            //添加到提醒好友的事件中
                            _CalendarEvent.Content = Content;
                            _CalendarEvent.EmailNote = ckEmailNote;
                            _CalendarEvent.EndTime = DateTime.Parse(EndTime);
                            _CalendarEvent.Invite = Invite;
                            _CalendarEvent.Note = ckRemind;
                            _CalendarEvent.NoteBefore = Int16.Parse(Remind);
                            _CalendarEvent.Repeat = ckRepeat;
                            _CalendarEvent.RepeatRate = Int16.Parse(RepeatRate);
                            _CalendarEvent.StartTime = DateTime.Parse(BeginTime);
                            _CalendarEvent.Title = Title;
                            _CalendarEvent.Type = Int16.Parse(Type);
                            _CalendarEvent.UserID =  Int32.Parse( UserID);
                            int idd = DbHelper.GetInstance().AddNewsCalenderEvent(_CalendarEvent);

                        }

                    }

                if (ckRemind=="true")    //提醒
                {}

                if (ckRepeat == "true")   //重复
                { }

                Global.CalendarNote(); //提醒定时器

            }
            else if (myaction.ToLower() == "show")
            {
                int UserID = Int32.Parse(context.Session["UserID"].ToString());
                int id = Int32.Parse(context.Request.Params["activity.id"].ToString());
                StringBuilder jsonBuilder = new StringBuilder();
                DataTable dtCalendar = DbHelper.GetInstance().GetCalenderEventByID(id);
                if (dtCalendar.Rows.Count > 0)
                {

                    if (dtCalendar.Rows.Count > 0)
                    {
                        jsonBuilder.Append("{\"");
                        jsonBuilder.Append(dtCalendar.TableName);
                        jsonBuilder.Append("\":[");
                        for (int i = 0; i < dtCalendar.Rows.Count; i++)
                        {
                            jsonBuilder.Append("{");
                            for (int j = 0; j < dtCalendar.Columns.Count; j++)
                            {
                                jsonBuilder.Append("\"");
                                jsonBuilder.Append(dtCalendar.Columns[j].ColumnName);
                                jsonBuilder.Append("\":\"");
                                jsonBuilder.Append(dtCalendar.Rows[i][j].ToString());
                                jsonBuilder.Append("\",");
                            }

                            jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                            jsonBuilder.Append("},");
                        }
                        jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                        jsonBuilder.Append("]");
                        jsonBuilder.Append("}");
                    }
                }

                context.Response.Write(jsonBuilder);

            }
            else if (myaction.ToLower() == "delete")
            {
            }
            else if (myaction.ToLower() == "update")
            {
                int id = Int32.Parse(context.Request.Form["activity.id"].ToString());
                CalendarEventEntity _CalendarEventEntity = DbHelper.GetInstance().GetCalendarEntityByID(id);

                string Title = context.Request.Params["TxtTitle"];
                string Content = context.Request.Params["TxtContent"];
                string Type = context.Request.Params["drType"];
                string BeginTime = context.Request.Params["TxtBeginTime"];
                string EndTime = context.Request.Params["TxtEndTime"];
                string Invite = context.Request.Params["TxtInvite"];
                string ckRemind = context.Request.Params["ckTiXing"];  //是否提醒
                string Remind = context.Request.Params["drTiXing"];   //多久提醒
                string ckRepeat = context.Request.Params["ckRepeat"];  //是否重复
                string RepeatRate = context.Request.Params["drRepeatRate"];  //重复频率
                string ckEmailNote = context.Request.Params["ckEmailNote"];  //是否邮件提醒

                _CalendarEventEntity.Content = Content;
                _CalendarEventEntity.EmailNote = ckEmailNote;
                _CalendarEventEntity.EndTime = DateTime.Parse(EndTime);
                _CalendarEventEntity.Invite = Invite;
                _CalendarEventEntity.Note = ckRemind;
                _CalendarEventEntity.NoteBefore = Int16.Parse(Remind);
                _CalendarEventEntity.Repeat = ckRepeat;
                _CalendarEventEntity.RepeatRate = Int16.Parse(RepeatRate);
                _CalendarEventEntity.StartTime = DateTime.Parse(BeginTime);
                _CalendarEventEntity.Title = Title;
                _CalendarEventEntity.Type = Int16.Parse(Type);

                int id_update = DbHelper.GetInstance().UpDateCalendarEvnetByID(_CalendarEventEntity);
                Global.CalendarNote(); //提醒定时器
            }
            else if (myaction.ToLower() == "save")
            {
                string title = context.Request.Form["activity.title"];
                DateTime startTime = DateTime.Parse(context.Request.Form["activity.startTime"]);
                DateTime endTime = DateTime.Parse(context.Request.Form["activity.endTime"]);
                CalendarEventEntity _CalendarEventEntity = new CalendarEventEntity();
                _CalendarEventEntity.UserID = Int32.Parse(context.Session["UserID"].ToString());
                _CalendarEventEntity.Type = 0;
                _CalendarEventEntity.Title = title;
                _CalendarEventEntity.StartTime = startTime;
                _CalendarEventEntity.RepeatRate = 0;
                _CalendarEventEntity.Repeat = "";
                _CalendarEventEntity.NoteBefore = 0;
                _CalendarEventEntity.Note = "";
                _CalendarEventEntity.Invite = "";
                _CalendarEventEntity.EndTime = endTime;
                _CalendarEventEntity.EmailNote = "";
                _CalendarEventEntity.Content = "";
                int id = DbHelper.GetInstance().AddNewsCalenderEvent(_CalendarEventEntity);
                if (id != 0)
                {
                    SortedDictionary<string, object> values = new SortedDictionary<string, object>();
                    values.Add("returnStr", "success");
                    values.Add("id", id);
                    context.Response.Write(new JavaScriptSerializer().Serialize(values));
                }
                Global.CalendarNote(); //提醒定时器
            }
            else if (myaction.ToLower() == "loadmonth")
            {
                DateTime startTime = DateTime.Parse(context.Request.Form["activity.startTime"]);
                DateTime endTime = DateTime.Parse(context.Request.Form["activity.endTime"]);
                int PermissionUserID = Int32.Parse(context.Request.Params["PerssionUserID"].ToString());
                int UserID;
                if (PermissionUserID == 0)

                    UserID = Int32.Parse(context.Session["UserID"].ToString());
                else
                    UserID = PermissionUserID;
                ////本月第一天时间
                //DateTime dt_First = startTime.AddDays(-(startTime.Day) + 1);
                ////将本月月数+1
                //DateTime dt2 = startTime.AddMonths(1);
                ////本月最后一天时间
                //DateTime dt_Last = dt2.AddDays(-(startTime.Day));
               DataTable dtMonth = DbHelper.GetInstance().GetCalendarByDate(startTime, endTime, UserID);
               StringBuilder jsonBuilder = new StringBuilder();
               if (dtMonth.Rows.Count > 0)
               {

                   if (dtMonth.Rows.Count > 0)
                   {
                       jsonBuilder.Append("{\"");
                       jsonBuilder.Append(dtMonth.TableName);
                       jsonBuilder.Append("\":[");
                       for (int i = 0; i < dtMonth.Rows.Count; i++)
                       {
                           jsonBuilder.Append("{");
                           for (int j = 0; j < dtMonth.Columns.Count; j++)
                           {
                               jsonBuilder.Append("\"");
                               jsonBuilder.Append(dtMonth.Columns[j].ColumnName);
                               jsonBuilder.Append("\":\"");
                               jsonBuilder.Append(dtMonth.Rows[i][j].ToString());
                               jsonBuilder.Append("\",");
                           }

                           jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                           jsonBuilder.Append("},");
                       }
                       jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                       jsonBuilder.Append("]");
                       jsonBuilder.Append("}");
                   }
               }
               context.Response.Write(jsonBuilder);

            }
            else if (myaction.ToLower() == "loadweek")
            {
                DateTime startTime = DateTime.Parse(context.Request.Form["activity.startTime"]);
                DateTime endTime = DateTime.Parse(context.Request.Form["activity.endTime"]);
                int PermissionUserID = Int32.Parse( context.Request.Params["PerssionUserID"].ToString());
                int UserID;
                if(PermissionUserID==0)

                     UserID = Int32.Parse(context.Session["UserID"].ToString());
                else
                    UserID = PermissionUserID;
                //int weeknow = Convert.ToInt32(startTime.DayOfWeek);
                ////星期日 获取weeknow为0
                //weeknow = weeknow == 0 ? 7 : weeknow;
                //int daydiff = (-1) * weeknow + 1;
                //int dayadd = 7 - weeknow;
                ////本周第一天
                //DateTime datebegin = startTime.AddDays(daydiff);
                ////本周最后一天
                //DateTime dateend = startTime.AddDays(dayadd);

                DataTable dtWeek = DbHelper.GetInstance().GetCalendarByDate(startTime, endTime, UserID);
                StringBuilder jsonBuilder = new StringBuilder();
                if (dtWeek.Rows.Count > 0)
                {
                    if (dtWeek.Rows.Count > 0)
                    {
                        jsonBuilder.Append("{\"");
                        jsonBuilder.Append(dtWeek.TableName);
                        jsonBuilder.Append("\":[");
                        for (int i = 0; i < dtWeek.Rows.Count; i++)
                        {
                            jsonBuilder.Append("{");
                            for (int j = 0; j < dtWeek.Columns.Count; j++)
                            {
                                jsonBuilder.Append("\"");
                                jsonBuilder.Append(dtWeek.Columns[j].ColumnName);
                                jsonBuilder.Append("\":\"");
                                jsonBuilder.Append(dtWeek.Rows[i][j].ToString());
                                jsonBuilder.Append("\",");
                            }

                            jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                            jsonBuilder.Append("},");
                        }
                        jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                        jsonBuilder.Append("]");
                        jsonBuilder.Append("}");
                    }

                    context.Response.Write(jsonBuilder);
                }
            }
        }