Ejemplo n.º 1
0
        private PersonalizationStateInfoCollection FindSharedState(string path, int pageIndex, int pageSize, out int totalRecords)
        {
            MySQLPersonalizationConnectionHelper connection = new MySQLPersonalizationConnectionHelper(connectionString);

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                connection.OpenConnection(true);
                totalRecords = PersonalizationProviderProcedures.myaspnet_PersonalizationAdministration_FindState(true, ApplicationId, ApplicationName, pageIndex, pageSize,
                                                                                                                  path, null, DateTime.MinValue, connection, ref cmd);

                PersonalizationStateInfoCollection sharedStateInfoCollection = new PersonalizationStateInfoCollection();

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string   pathQuery       = reader.GetString("Path");
                        DateTime lastUpdatedDate = (reader.IsDBNull(1)) ? DateTime.MinValue :
                                                   DateTime.SpecifyKind(reader.GetDateTime(1), DateTimeKind.Utc);
                        int size           = (reader.IsDBNull(2)) ? 0 : reader.GetInt32("SharedDataLength");
                        int userDataLength = (reader.IsDBNull(3)) ? 0 : reader.GetInt32("UserDataLength");
                        int userCount      = (reader.IsDBNull(4)) ? 0 : reader.GetInt32("UserCount");

                        sharedStateInfoCollection.Add(new SharedPersonalizationStateInfo(
                                                          pathQuery, lastUpdatedDate, size, userDataLength, userCount));
                    }
                }
                connection.CloseConnection();
                return(sharedStateInfoCollection);
            }
            catch (Exception ex)
            {
                if (writeExceptionsToEventLog)
                {
                    WriteToEventLog(ex, "MySQLPersonalizationProvider - FindSharedState");
                }
                throw;
            }
            finally
            {
                connection.CloseConnection();
            }
        }
Ejemplo n.º 2
0
        private PersonalizationStateInfoCollection FindUserState(string path, DateTime inactiveSinceDate, string userName, int pageIndex, int pageSize, out int totalRecords)
        {
            MySQLPersonalizationConnectionHelper connection = new MySQLPersonalizationConnectionHelper(connectionString);

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                connection.OpenConnection(true);
                totalRecords = PersonalizationProviderProcedures.myaspnet_PersonalizationAdministration_FindState(false, ApplicationId, ApplicationName, pageIndex, pageSize,
                                                                                                                  path, userName, inactiveSinceDate, connection, ref cmd);

                PersonalizationStateInfoCollection stateInfoCollection = new PersonalizationStateInfoCollection();

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string   pathQuery        = reader.GetString("Path");
                        DateTime lastUpdatedDate  = DateTime.SpecifyKind(reader.GetDateTime("LastUpdatedDate"), DateTimeKind.Utc);
                        int      size             = reader.GetInt32("Size");
                        string   usernameQuery    = reader.GetString("name");
                        DateTime lastActivityDate = DateTime.SpecifyKind(reader.GetDateTime("LastActivityDate"), DateTimeKind.Utc);
                        stateInfoCollection.Add(new UserPersonalizationStateInfo(pathQuery, lastActivityDate, size, usernameQuery, lastActivityDate));
                    }
                }
                connection.CloseConnection();

                return(stateInfoCollection);
            }
            catch (Exception ex)
            {
                if (writeExceptionsToEventLog)
                {
                    WriteToEventLog(ex, "MySQLPersonalizationProvider - FindUserState");
                }
                throw;
            }
            finally
            {
                connection.CloseConnection();
            }
        }