コード例 #1
0
        /*
         * ///<summary></summary>
         * public static void Update(TaskSubscription subsc) {
         *      if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         *              Meth.GetVoid(MethodBase.GetCurrentMethod(),subsc);
         *              return;
         *      }
         *      Crud.TaskSubscriptionCrud.Update(subsc);
         * }*/

        ///<summary>Attempts to create a subscription to a TaskList with TaskListNum of subscribeToTaskListNum.
        ///The curUserNum must be the currently logged in user.</summary>
        public static bool TrySubscList(long subscribeToTaskListNum, long curUserNum)
        {
            //No remoting role check; no call to db
            //Get the list of directly subscribed TaskListNums.  This avoids the concurrency issue of the same user logged in via multiple WS and
            //subscribing to the same TaskList.  Additionally, this allows the user to directly subscribe to child TaskLists of subscribed parent Tasklists
            //which was old behavior that was inadvertently removed.
            List <long> listExistingSubscriptionNums = GetTaskSubscriptionsForUser(curUserNum).Select(x => x.TaskListNum).ToList();

            if (listExistingSubscriptionNums.Contains(subscribeToTaskListNum))
            {
                return(false);               //Already subscribed.
            }
            //Get all currently subscribed unread Reminder tasks before adding new subscription.
            List <long>      listReminderTaskNumsOld = GetUnreadReminderTasks(curUserNum).Select(x => x.TaskNum).ToList();
            TaskSubscription subsc = new TaskSubscription();

            subsc.IsNew       = true;
            subsc.UserNum     = curUserNum;
            subsc.TaskListNum = subscribeToTaskListNum;
            Insert(subsc);
            //Get newly subscribed unread Reminder tasks.
            List <Task> listNewReminderTasks = GetUnreadReminderTasks(curUserNum).FindAll(x => !x.TaskNum.In(listReminderTaskNumsOld));

            //Set any past unread Reminder tasks as read.
            TaskUnreads.SetRead(curUserNum, listNewReminderTasks.FindAll(x => x.DateTimeEntry < DateTime.Now).ToArray());
            //Get all future reminders in the newly subscribed Tasklist (and sub Tasklists) that the user was not previously subscribed to.
            List <Task> listFutureReminders = GetNewReadReminders(listExistingSubscriptionNums, subscribeToTaskListNum, curUserNum)
                                              .Where(x => x.DateTimeEntry >= DateTime.Now).ToList();

            //We already know these tasks do not have any TaskUnreads (due to GetNewReadReminders->Tasks.RefreshChildren()), safe to insert TaskUnreads.
            TaskUnreads.InsertManyForTasks(listFutureReminders, curUserNum);
            return(true);
        }
コード例 #2
0
ファイル: TaskSubscriptions.cs プロジェクト: mnisl/OD
		///<summary></summary>
		public static long Insert(TaskSubscription subsc){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				subsc.TaskSubscriptionNum=Meth.GetLong(MethodBase.GetCurrentMethod(),subsc);
				return subsc.TaskSubscriptionNum;
			}
			return Crud.TaskSubscriptionCrud.Insert(subsc);
		}
コード例 #3
0
 ///<summary></summary>
 public static long Insert(TaskSubscription subsc)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         subsc.TaskSubscriptionNum = Meth.GetLong(MethodBase.GetCurrentMethod(), subsc);
         return(subsc.TaskSubscriptionNum);
     }
     return(Crud.TaskSubscriptionCrud.Insert(subsc));
 }
コード例 #4
0
ファイル: TaskSubscriptions.cs プロジェクト: mnisl/OD
		/*
		///<summary></summary>
		public static void Update(TaskSubscription subsc) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),subsc);
				return;
			}
			Crud.TaskSubscriptionCrud.Update(subsc);
		}*/

		///<summary>Creates a subscription to a list.</summary>
		public static void SubscList(long taskListNum,long userNum) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),taskListNum,userNum);
				return;
			}
			string command="SELECT COUNT(*) FROM tasksubscription "
				+"WHERE UserNum="+POut.Long(userNum)
				+" AND TaskListNum="+POut.Long(taskListNum);
			if(Db.GetCount(command)!="0"){
				throw new ApplicationException(Lans.g("TaskSubscriptions","User already subscribed."));
			}
			TaskSubscription subsc=new TaskSubscription();
			subsc.IsNew=true;
			subsc.UserNum=userNum;
			subsc.TaskListNum=taskListNum;
			Insert(subsc);
		}
コード例 #5
0
        /*
         * ///<summary></summary>
         * public static void Update(TaskSubscription subsc) {
         *      if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         *              Meth.GetVoid(MethodBase.GetCurrentMethod(),subsc);
         *              return;
         *      }
         *      Crud.TaskSubscriptionCrud.Update(subsc);
         * }*/

        ///<summary>Creates a subscription to a list.</summary>
        public static void SubscList(long taskListNum, long userNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), taskListNum, userNum);
                return;
            }
            string command = "SELECT COUNT(*) FROM tasksubscription "
                             + "WHERE UserNum=" + POut.Long(userNum)
                             + " AND TaskListNum=" + POut.Long(taskListNum);

            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("TaskSubscriptions", "User already subscribed."));
            }
            TaskSubscription subsc = new TaskSubscription();

            subsc.IsNew       = true;
            subsc.UserNum     = userNum;
            subsc.TaskListNum = taskListNum;
            Insert(subsc);
        }