// This is the Constructor that we need. public Join(Type type, string tableName, string columnName, string joinOnColumnName) { try { // Authorize if the User is allowed to Read from this table. if (cdb.ValidateCRUD(tableName, CloudDB.CRUD.READ)) { // We get the Join statements that the user wants to join. this.type = type; this.columnName = Regex.Replace(columnName, " ", ""); this.joinOnColumnName = Regex.Replace(joinOnColumnName, " ", ""); this.tableName = Regex.Replace(tableName, " ", ""); joinSQL = new StringBuilder(); // Build the Join SQL. // Add the type of the Join. switch (type) { case Type.INNER_JOIN: joinSQL.Append(" INNER JOIN "); break; case Type.JOIN: joinSQL.Append(" JOIN "); break; case Type.OUTTER_JOIN: joinSQL.Append(" OUTTER JOIN "); break; case Type.LEFT_JOIN: joinSQL.Append(" LEFT JOIN "); break; case Type.RIGHT_JOIN: joinSQL.Append(" RIGHT JOIN "); break; case Type.FULL_JOIN: joinSQL.Append(" FULL JOIN "); break; } // Add the Table Name of the Join. joinSQL.Append(this.tableName); // Add the Column Name of the Join. joinSQL.Append(" ON ") .Append(this.columnName) .Append('=') .Append(this.joinOnColumnName); } else { // The user is not authorized to proceed. } } catch (Exception e) { // There was an Error. } }
// The Method to also set the Table to be read. public Select From(string tableName) { try { // Check for authenticated. AddStatus("Going to Authenticate : " + tableName); if (this.tableName == null) { if (cdb.ValidateCRUD(tableName, CloudDB.CRUD.READ)) { AddStatus("User Authorized to Read from the Table"); // The user has provided // We will remove all spaces and then add the table name. // Authenticate the User against the Table. this.tableName = Regex.Replace(tableName.Trim(), " ", ""); AddStatus("Set Table"); // The Security has been completed return(this); } else { // The user does'nt have authority to read from this table. AddStatus("Not Authorized to Read Table"); isError = true; return(null); } } else { // The Table name has already been set. return(this); } } catch (Exception e) { // There was an Error. AddStatus(e.Message); this.tableName = null; isError = true; return(null); } }
// Main Constructor will be used to set the table name. public Insert Into(string tableName) { try { // Here we will set the table name. // Authentication. if (this.tableName == null) { if (cdb.ValidateCRUD(tableName, CloudDB.CRUD.WRITE) && cdb.user.IsActive) { this.tableName = Regex.Replace(tableName, " ", ""); // The user is allowed to write into the table. // Initiate the required variables. columnDataBuilder = new StringBuilder(); columnPlaceHolderBuilder = new StringBuilder(); bindObjs = new Dictionary <string, object>(); syncable = CloudDB.IsSyncable(tableName); AddStatus("Valid CRUD"); return(this); } else { // The user is not authorized to write into this table. AddStatus("Not Authorized to Write into Table"); this.tableName = null; return(this); } } else { // The Table name has already been set. return(this); } } catch (Exception e) { // There was an Error. this.tableName = null; AddStatus("Error with the Cloud DB Validation"); return(this); } }
// This Constructor we will use to set the table name. public Delete From(string tableName) { try { // Set the Table Name. // Authentication. if (cdb.ValidateCRUD(tableName, CloudDB.CRUD.DELETE) && cdb.user.IsActive) { this.tableName = Regex.Replace(tableName, " ", ""); // Initiate the Required Variables. whereClauseBuilder = new StringBuilder(); whereBindObjs = new Dictionary <string, object>(); AddStatus("User Authorized to Delete from the Table"); if (CloudDB.IsSyncable(tableName)) { // The table is syncable. // Lets not do anything here, as the user might not want to sync this table. } else { // This table is not syncable. syncable = false; } return(this); } else { // The user is not authorized to delete from this table. isError = true; AddStatus("User NOT Authorized to Delete from the Table"); return(this); } } catch (Exception e) { // There was an Error. isError = true; AddStatus("Error : " + e.Message); return(this); } }