public ActivityManager(DBConnectionManager dbConnectionManager) : base(dbConnectionManager)
 {
 }
        public static void EnqueueActivity(Guid siteId, Guid webId, Guid listId, int userId, DateTime activityTime,
                                           DateTime relatedActivityTime, SPWeb contextWeb)
        {
            const string GET_QUEUED_ACTIVITY_SQL = @"
                SELECT   TOP (1) ActivityQueueId, ItemCount
                FROM     dbo.ActivityQueue
                WHERE    (ListId = @ListId) AND (WebId = @WebId) AND (UserId = @UserId) AND (PostTime >= @RelatedActivityTime)
                ORDER BY PostTime DESC";

            Guid queuedActivityId = Guid.Empty;
            int  itemCount        = 0;

            using (SqlConnection sqlConnection = new DBConnectionManager(contextWeb, false).EPMLiveSqlConnection)
            {
                using (var sqlCommand = new SqlCommand(GET_QUEUED_ACTIVITY_SQL, sqlConnection))
                {
                    sqlCommand.Parameters.AddWithValue("@WebId", webId);
                    sqlCommand.Parameters.AddWithValue("@ListId", listId);
                    sqlCommand.Parameters.AddWithValue("@UserId", userId);
                    sqlCommand.Parameters.AddWithValue("@RelatedActivityTime", relatedActivityTime);

                    using (SqlDataReader reader = sqlCommand.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            queuedActivityId = reader.GetGuid(0);
                            itemCount        = reader.GetInt32(1);
                        }

                        reader.Close();
                    }
                }

                if (queuedActivityId == Guid.Empty)
                {
                    const string INSERT_SQL =
                        @"INSERT INTO dbo.ActivityQueue (SiteId, WebId, ListId, UserId, PostTime, ItemCount) VALUES (@SiteId, @WebId, @ListId, @UserId, @ActivityTime, 2)";

                    using (var sqlCommand = new SqlCommand(INSERT_SQL, sqlConnection))
                    {
                        sqlCommand.Parameters.AddWithValue("@SiteId", siteId);
                        sqlCommand.Parameters.AddWithValue("@WebId", webId);
                        sqlCommand.Parameters.AddWithValue("@ListId", listId);
                        sqlCommand.Parameters.AddWithValue("@UserId", userId);
                        sqlCommand.Parameters.AddWithValue("@ActivityTime", activityTime);

                        sqlCommand.ExecuteNonQuery();
                    }
                }
                else
                {
                    const string UPDATE_SQL =
                        @"UPDATE dbo.ActivityQueue SET ItemCount = @ItemCount, PostTime = @ActivityTime WHERE ActivityQueueId = @Id";

                    using (var sqlCommand = new SqlCommand(UPDATE_SQL, sqlConnection))
                    {
                        sqlCommand.Parameters.AddWithValue("@ItemCount", ++itemCount);
                        sqlCommand.Parameters.AddWithValue("@ActivityTime", activityTime);
                        sqlCommand.Parameters.AddWithValue("@Id", queuedActivityId);

                        sqlCommand.ExecuteNonQuery();
                    }
                }

                sqlConnection.Close();
            }
        }
Ejemplo n.º 3
0
 public ThreadManager(DBConnectionManager dbConnectionManager) : base(dbConnectionManager)
 {
 }
Ejemplo n.º 4
0
 public StreamManager(DBConnectionManager dbConnectionManager) : base(dbConnectionManager)
 {
 }
Ejemplo n.º 5
0
 protected BaseManager(DBConnectionManager dbConnectionManager)
 {
     _dbConnectionManager = dbConnectionManager;
 }
Ejemplo n.º 6
0
 public TransactionManager(DBConnectionManager dbConnectionManager) : base(dbConnectionManager)
 {
 }