예제 #1
0
        public ValueObject.Column SelectByColumneName(string databaseName, string tableName, string columnName)
        {
            ValueObject.Column column = null;
            System.Data.DataRow row = null;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                row = mySql.GetDataRow(StoredProcedures.Column_Select_ByColumnName.ToString(), "@DatabaseName", databaseName, "@TableName", tableName, "@ColumnName", columnName);

                if (row != null)
                    column = Fill(row);

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading column.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return column;
        }
예제 #2
0
        public static IEnumerable<Role> SelectAll()
        {
            IEnumerable<Role> roles = null;
            DataTable table = null;
            DataLayer.MySQL mySql = null;

            try
            {
                mySql = new DataLayer.MySQL(DatConnectionString);
                table = mySql.GetDataTable(StoredProcedures.Roles_Select_All.ToString());
                if (table != null)
                    roles = table.Rows.Select<Role>( );

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading roles.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return roles;
        }
예제 #3
0
        public static IEnumerable<AssetSubscription> ByPublisherAssetGuid(Guid publisherAssetGuid)
        {
            IEnumerable<AssetSubscription> assetSubscriptions = null;
            DataTable table = null;
            DataLayer.MySQL mySql = null;

            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                table = mySql.GetDataTable(StoredProcedures.AssetSubscriptions_Select_ByPublisherAssetGuid.ToString(), "_PublisherAssetGuid", publisherAssetGuid);
                if (table != null)
                    assetSubscriptions = table.Rows.Select<AssetSubscription>( );

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading asset subscriptions.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return assetSubscriptions;
        }
예제 #4
0
        public static IEnumerable<RolePermission> ByPermissionId(int permissionId )
        {
            IEnumerable<RolePermission> rolePermissions = null;
              DataTable table = null;
              DataLayer.MySQL mySql = null;

              try
              {
                  mySql = new DataLayer.MySQL(DatConnectionString);
                  table = mySql.GetDataTable(StoredProcedures.RolePermissions_Select_ByPermissionId.ToString(), "_PermissionId", permissionId);
                  if (table != null)
                      rolePermissions = table.Rows.Select<RolePermission>( );

              }
              catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading asset permissions.", ex); }
              finally { if (mySql != null) mySql.Dispose(); }

              return rolePermissions;
        }
예제 #5
0
        public static IEnumerable<Subscription> ByUserGuid(Guid userGuid)
        {
            IEnumerable<Subscription> subscriptions = null;
            DataTable table = null;
            DataLayer.MySQL mySql = null;

            try
            {
                mySql = new DataLayer.MySQL(DatConnectionString);
                table = mySql.GetDataTable(StoredProcedures.Subscriptions_Select_ByUserGuid.ToString(), "_UserGuid", userGuid);
                if (table != null)
                    subscriptions = table.Rows.Select<Subscription>();

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading subscriptions.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return subscriptions;
        }
예제 #6
0
        public bool ByUserEventId(long userEventID)
        {
            DataRow row = null;
            bool success = false;
            DataLayer.MySQL mySql = null;

            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                row = mySql.GetDataRow(StoredProcedures.UserEvents_Select_ByUserEventId.ToString(),
                    "_UserEventID", userEventID);

                if (row != null)
                    success = row.TryParse<UserEvent>(this) && UserEventId > 0;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading user event.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #7
0
        public List<ValueObject.Database> SelectAll()
        {
            List<ValueObject.Database> databases = null;
            System.Data.DataTable table= null;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                table = mySql.GetDataTable(StoredProcedures.Database_Select_All.ToString());

                if (table != null)
                {
                    databases = new List<ValueObject.Database>();
                    foreach (System.Data.DataRow row in table.Rows)
                        databases.Add(Fill(row));
                }

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading database.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return databases;
        }
예제 #8
0
        public List<ValueObject.Column> SelectByTableName(string databaeName, string tableName)
        {
            List<ValueObject.Column> columns = null;
            System.Data.DataTable table = null;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                table = mySql.GetDataTable(StoredProcedures.Column_Select_ByTableName.ToString(), "@DatabaseName", databaeName, "@TableName", tableName);

                if (table != null)
                {
                    columns = new List<ValueObject.Column>();
                    foreach (System.Data.DataRow row in table.Rows)
                        columns.Add(Fill(row));
                }

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading columns.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return columns;
        }
예제 #9
0
        protected override bool Insert()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;

            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                UserEventId = mySql.ExecuteScalar(StoredProcedures.UserEvents_Update.ToString(),
                    "_UserEventId", UserEventId,
                    "_UserEventReferenceKey", UserEventReferenceKey,
                    "_UserGuid", UserGuid,
                    "_EventId", EventId,
                    "_UserEventDescription", Description);
                success = UserEventId > 0;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving user event.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #10
0
        protected override bool Insert()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                AssetSubscriptionId = (int)mySql.ExecuteScalar(StoredProcedures.AssetSubscriptions_Insert.ToString(),
                    "_SubscriberAssetGuid", SubscriberAssetGuid,
                    "_PublisherAssetGuid", PublisherAssetGuid,
                    "_CreatedBy", CreatedBy);
                success = AssetSubscriptionId > 1;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving asset subscription.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #11
0
        public bool ByRoleId(int roleId)
        {
            bool success = false;
            DataRow row = null;
            DataLayer.MySQL mySql = null;

            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                row = mySql.GetDataRow(StoredProcedures.Roles_Select_ByRoleId.ToString(),
                    "_RoleId", roleId);

                if (row != null)
                    success = row.TryParse<Role>(this) && RoleId > 0;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading role.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #12
0
        public static List<PostalCodeInfo> LoadPostalCodes(string postal_code, string connectionString)
        {
            Boolean success = false;
            DataLayer.MySQL mySQL = null;
            DataTable dt = null;
            List<PostalCodeInfo> postalcodes = new List<PostalCodeInfo>(); ;

            try
            {

                mySQL = new DataLayer.MySQL(connectionString);
                dt = mySQL.GetDataTable(DataLayer.StoredProcedures.postal_codes_std_get_postal_code,
                    "@_postal_code", postal_code);
                if (dt != null)
                    foreach (System.Data.DataRow row in dt.Rows)
                    {
                        PostalCodeInfo postalcode = new PostalCodeInfo(connectionString);
                        if (postalcode.Load(row) && postalcode.PostalCodeID > 0)
                            postalcodes.Add(postalcode);
                    }
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading postal code.", ex); }
            finally { if (mySQL != null) mySQL.Dispose(); }

            return postalcodes;
        }
예제 #13
0
        protected override bool Save()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                RoleId = (int)mySql.ExecuteScalar(StoredProcedures.Roles_Update_ByRoleId.ToString(),
                    "_RoleName", RoleName,
                    "_RoleDescription", RoleDescription);

                success = RoleId > 0;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error role user.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #14
0
        protected override bool Save()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;
            string truncatedResult = Result;

            try {

              if (Result != null)
                if (Result.ToCharArray().Length >= 20000) truncatedResult = Result.Substring(0, 20000);

              mySql = new DataLayer.MySQL(ConnectionString);
              RequestId = mySql.ExecuteScalar(StoredProcedures.Requests_Update.ToString(),
                          "_RequestId", RequestId,
                          "_Result", truncatedResult );
              success = RequestId > 0;

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving request.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #15
0
        protected override bool Insert()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                LogId = (int)mySql.ExecuteScalar(StoredProcedures.Logs_Insert.ToString(),
                    "_RequestId", RequestId,
                    "_LogType", LogType,
                    "_Title", Title,
                    "_Text", Text,
                    "_ReferenceKey", ReferenceKey,
                    "_Action", Action,
                    "_Success", Success);
                success = LogId > 1;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving log.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #16
0
        public Boolean Load(long postalcode_id)
        {
            Boolean success = false;
            DataLayer.MySQL mySQL = null;
            DataRow row = null;

            try
            {

                mySQL = new DataLayer.MySQL(ConnectionString);
                row = mySQL.GetDataRow(DataLayer.StoredProcedures.postal_codes_std_get_id,
                    "@_id_postal_code", postalcode_id);

                if (row != null) success = Load(row);

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading postal code.", ex); }
            finally { if (mySQL != null) mySQL.Dispose(); }

            return success;
        }
예제 #17
0
        public static IEnumerable<AssetRole> ByRoleId(int roleId)
        {
            IEnumerable<AssetRole> assetRoles = null;
            DataTable table = null;
            DataLayer.MySQL mySql = null;

            try
            {
                mySql = new DataLayer.MySQL(DatConnectionString);
                table = mySql.GetDataTable(StoredProcedures.AssetRoles_Select_ByAssetGuid.ToString(), "_RoleId", roleId);
                if (table != null)
                    assetRoles = table.Rows.Select<AssetRole>();

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading asset roles.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return assetRoles;
        }
예제 #18
0
 public static bool IsSubscribed(Guid assetGuid,Guid userGuid)
 {
     bool success = false;
     DataLayer.MySQL mySql = null;
     try
     {
         mySql = new DataLayer.MySQL(DatConnectionString);
         return (bool)mySql.ExecuteScalarObject(StoredProcedures.Subscriptions_Insert.ToString(),
             "_AssetGuid", assetGuid,
             "_UserGuid", userGuid);
     }
     catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving subscription.", ex); }
     finally { if (mySql != null) mySql.Dispose(); }
 }
예제 #19
0
        protected override bool Save()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                UserId = mySql.ExecuteScalar(StoredProcedures.Users_Update.ToString(),
                    "_UserId", UserId,
                    "_EmailAddress", EmailAddress,
                    "_FirstName", FirstName,
                    "_LastName", LastName,
                    "_UserGuid", UserGuid,
                    "_Password", Password,
                    "_Active", Active,
                    "_RoleId", RoleId);
                success = UserId > 0;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving user.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #20
0
        public bool ByEmailAddress(string emailAddress)
        {
            bool success = false;
            DataRow row = null;
            DataLayer.MySQL mySql = null;

            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                row = mySql.GetDataRow(StoredProcedures.Users_Select_ByEmailAddress.ToString(),
                    "_EmailAddress", emailAddress);
                if (row != null)
                    success = row.TryParse<User>(this) && UserId > 0;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading user.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }
            return success;
        }
예제 #21
0
        public static User Authenticate(string emailAddress, string password)
        {
            DataRow row = null;
            User user = null;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(DatConnectionString);
                row = mySql.GetDataRow(StoredProcedures.Users_Authenticate.ToString(),
                    "_EmailAddress", emailAddress,
                    "_Password", password);
                if (row == null)
                    return user;
                user = new User();
                if (!row.TryParse<User>(user) || user.UserId < 1)
                    user = null;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading user.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return user;
        }
예제 #22
0
        protected override bool Save()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                AssetId = (int)mySql.ExecuteScalar(StoredProcedures.Assets_Update.ToString(),
                    "_AssetName", AssetName,
                    "_AssetGuid", AssetGuid,
                    "_AssetCode", AssetCode);
                success = AssetId > 1;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving asset.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #23
0
        protected override bool Insert()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;
            string truncatedResult = Result;

            try {

              if (Result != null)
                if (Result.ToCharArray().Length >= 20000) truncatedResult = Result.Substring(0, 20000);

                mySql = new DataLayer.MySQL(ConnectionString);
                RequestId = mySql.ExecuteScalar(StoredProcedures.Requests_Insert.ToString(),
                            "_Version", Version,
                            "_AssetCode", AssetCode,
                            "_Service", Service,
                            "_EndPoint", EndPoint,
                            "_Parameters", Parameters,
                            "_Method", Method,
                            "_UserGuid", UserGuid,
                            "_IpAddress", IpAddress,
                            "_Url", Url,
                            "_Headers", Headers,
                            "_HttpAuth", HttpAuth,
                            "_Language", Language,
                            "_Referrer", Referrer,
                            "_UserAgent", UserAgent,
                            "_Cookies", Cookies,
                            "_InputStream", InputStream,
                            "_ContentType", ContentType,
                            "_SubscriberAssetGuid", SubscriberAssetGuid,
                            "_AcceptType", AcceptType,
                            "_Result", truncatedResult,
                            "_ServerIpAddress", ServerIpAddress);
                success = RequestId > 0;

            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving request.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #24
0
        public bool ByAssetCode(string assetCode)
        {
            bool success = false;
            DataRow row = null;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);

                row = mySql.GetDataRow(StoredProcedures.Assets_Select_ByAssetCode.ToString(),
                    "_AssetCode", assetCode);

                if (row != null)
                    success = row.TryParse<Asset>(this) && AssetId > 0;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading asset.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }
예제 #25
0
        protected override bool Insert()
        {
            bool success = false;
            DataLayer.MySQL mySql = null;
            try
            {
                mySql = new DataLayer.MySQL(ConnectionString);
                RolePermissionId = (int)mySql.ExecuteScalar(StoredProcedures.RolePermissions_Insert.ToString(),
                    "_RoleId", RoleId,
                    "_PermissionId", PermissionId,
                    "_CreatedBy", CreatedBy);
                success = RolePermissionId > 1;
            }
            catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving role permission.", ex); }
            finally { if (mySql != null) mySql.Dispose(); }

            return success;
        }