/// <summary> /// Updates NWS_Tag values on Database. /// </summary> /// <param name="forceUpdate_in">assign with True if you wish to force an Update (even if no changes have been made since last time getObject method was run) and False if not</param> /// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param> public static void updObject( SO_NWS_Tag NWS_Tag_in, bool forceUpdate_in, DBConnection dbConnection_in ) { if (forceUpdate_in || NWS_Tag_in.HasChanges) { DBConnection _connection = (dbConnection_in == null) ? DO__Utilities.DBConnection_createInstance( DO__Utilities.DBServerType, DO__Utilities.DBConnectionstring, DO__Utilities.DBLogfile ) : dbConnection_in; IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _connection.newDBDataParameter("IDTag_", DbType.Int64, ParameterDirection.Input, NWS_Tag_in.IDTag, 0), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Input, NWS_Tag_in.IFApplication_isNull ? null : (object)NWS_Tag_in.IFApplication, 0), _connection.newDBDataParameter("IFTag__parent_", DbType.Int64, ParameterDirection.Input, NWS_Tag_in.IFTag__parent_isNull ? null : (object)NWS_Tag_in.IFTag__parent, 0), _connection.newDBDataParameter("TX_Name_", DbType.Int64, ParameterDirection.Input, NWS_Tag_in.TX_Name, 0), _connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Input, NWS_Tag_in.IFUser__Approved_isNull ? null : (object)NWS_Tag_in.IFUser__Approved, 0), _connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Input, NWS_Tag_in.Approved_date_isNull ? null : (object)NWS_Tag_in.Approved_date, 0) }; _connection.Execute_SQLFunction( "sp0_NWS_Tag_updObject", _dataparameters ); if (dbConnection_in == null) { _connection.Dispose(); } NWS_Tag_in.HasChanges = false; } }
/// <summary> /// Updates NWS_Tag values on Database. /// </summary> /// <param name="forceUpdate_in">assign with True if you wish to force an Update (even if no changes have been made since last time getObject method was run) and False if not</param> public static void updObject( SO_NWS_Tag NWS_Tag_in, bool forceUpdate_in ) { updObject( NWS_Tag_in, forceUpdate_in, null ); }
/// <summary> /// Inserts NWS_Tag values into Database. /// </summary> /// <param name="selectIdentity_in">assign with True if you wish to retrieve insertion sequence/identity seed and with False if not</param> /// <returns>insertion sequence/identity seed</returns> public static long insObject( SO_NWS_Tag NWS_Tag_in, bool selectIdentity_in ) { return(insObject( NWS_Tag_in, selectIdentity_in, null )); }
public static SO_NWS_Tag getObject( string sessionGuid_in, string ip_forLogPurposes_in, long idTag_in, out int[] errors_out ) { SO_NWS_Tag _output = null; List <int> _errorlist; Guid _sessionguid; Sessionuser _sessionuser; #region check... if (!SBO_CRD_Authentication.isSessionGuid_valid( sessionGuid_in, ip_forLogPurposes_in, out _sessionguid, out _sessionuser, out _errorlist, out errors_out )) { //// no need! //errors_out = _errors.ToArray(); return(_output); } #endregion #region check Permissions . . . if ( !_sessionuser.hasPermission( PermissionType.Tag__select ) ) { _errorlist.Add(ErrorType.tag__lack_of_permissions_to_read); errors_out = _errorlist.ToArray(); return(_output); } #endregion _output = DO_NWS_Tag.getObject( idTag_in, null ); errors_out = _errorlist.ToArray(); return(_output); }
private void btn_save_click( ref SO_NWS_Tag tag_ref ) { #region tag_ref.IFTag__parent = long.Parse(this.DDL_Tag_parent.SelectedValue); if (string.IsNullOrEmpty(this.DDL_Tag_parent.SelectedValue)) { tag_ref.IFTag__parent_isNull = true; } else { //tag_ref.IFTag__parent = DDL_Tag_parent.Kick.SelectedValue__get<long>(); tag_ref.IFTag__parent = long.Parse( this.DDL_Tag_parent.SelectedValue, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.CurrentCulture ); } #endregion }
/// <summary> /// Inserts NWS_Tag values into Database. /// </summary> /// <param name="selectIdentity_in">assign with True if you wish to retrieve insertion sequence/identity seed and with False if not</param> /// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param> /// <returns>insertion sequence/identity seed</returns> public static long insObject( SO_NWS_Tag NWS_Tag_in, bool selectIdentity_in, DBConnection dbConnection_in ) { DBConnection _connection = (dbConnection_in == null) ? DO__Utilities.DBConnection_createInstance( DO__Utilities.DBServerType, DO__Utilities.DBConnectionstring, DO__Utilities.DBLogfile ) : dbConnection_in; IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _connection.newDBDataParameter("IDTag_", DbType.Int64, ParameterDirection.Output, null, 0), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Input, NWS_Tag_in.IFApplication_isNull ? null : (object)NWS_Tag_in.IFApplication, 0), _connection.newDBDataParameter("IFTag__parent_", DbType.Int64, ParameterDirection.Input, NWS_Tag_in.IFTag__parent_isNull ? null : (object)NWS_Tag_in.IFTag__parent, 0), _connection.newDBDataParameter("TX_Name_", DbType.Int64, ParameterDirection.Input, NWS_Tag_in.TX_Name, 0), _connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Input, NWS_Tag_in.IFUser__Approved_isNull ? null : (object)NWS_Tag_in.IFUser__Approved, 0), _connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Input, NWS_Tag_in.Approved_date_isNull ? null : (object)NWS_Tag_in.Approved_date, 0), _connection.newDBDataParameter("SelectIdentity_", DbType.Boolean, ParameterDirection.Input, selectIdentity_in, 1) }; _connection.Execute_SQLFunction( "sp0_NWS_Tag_insObject", _dataparameters ); if (dbConnection_in == null) { _connection.Dispose(); } NWS_Tag_in.IDTag = (long)_dataparameters[0].Value; NWS_Tag_in.HasChanges = false; return(NWS_Tag_in.IDTag); }
public void BTN_Save_Click(object sender, EventArgs e) { int[] _errors; SO_NWS_Tag _tag; if ( #region ((_tag = ...) != null) (this.IDTag > 0) && ( (_tag = BusinessInstances.NWS_Tag.InstanceClient.getObject( Utilities.User.SessionGuid, Utilities.ClientIPAddress, this.IDTag, out _errors )) != null ) && !this.Master__base.Error_add(_errors) #endregion ) { #region _tag.IFTag__parent = long.Parse(this.DDL_Tag_parent.SelectedValue); this.btn_save_click( ref _tag ); #endregion BusinessInstances.NWS_Tag.InstanceClient.updObject( Utilities.User.SessionGuid, Utilities.ClientIPAddress, _tag, this.DIC_Name.Texts, out _errors ); } else { _tag = new SO_NWS_Tag(); #region _tag.IFTag__parent = long.Parse(this.DDL_Tag_parent.SelectedValue); this.btn_save_click( ref _tag ); #endregion _tag.Approved_date_isNull = true; _tag.IFUser__Approved_isNull = true; _tag.IFApplication = Utilities.IDApplication; BusinessInstances.NWS_Tag.InstanceClient.insObject( Utilities.User.SessionGuid, Utilities.ClientIPAddress, _tag, this.DIC_Name.Texts, false, out _errors ); } if (!this.Master__base.Error_add(_errors)) { Response.Redirect( "NWS-NewsTag-list.aspx", true ); } }
public static void updObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_NWS_Tag tag_in, OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_DIC__TextLanguage[] tx_Name_in, out int[] errors_out ) { Guid _sessionguid; Sessionuser _sessionuser; #region check... List <int> _errorlist; if (!check( sessionGuid_in, ip_forLogPurposes_in, ref tag_in, tx_Name_in, out _sessionguid, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return; } #endregion #region check existence . . . SO_NWS_Tag _tag; if ( tag_in.IDTag <= 0 || ( (_tag = DO_NWS_Tag.getObject( tag_in.IDTag )) == null ) ) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return; } #endregion if ( _tag.IFUser__Approved_isNull || _tag.Approved_date_isNull ) { if (_sessionuser.hasPermission(PermissionType.Tag__approve)) { tag_in.Approved_date = DateTime.Now; tag_in.IFUser__Approved = _sessionuser.IDUser; } else { tag_in.Approved_date_isNull = true; tag_in.IFUser__Approved_isNull = true; } } else { tag_in.Approved_date = _tag.Approved_date; tag_in.IFUser__Approved = _tag.IFUser__Approved; } tag_in.IFApplication = _tag.IFApplication; Exception _exception = null; #region DBConnection _con = DO__Utilities.DBConnection_createInstance(...); DBConnection _con = DO__Utilities.DBConnection_createInstance( DO__Utilities.DBServerType, DO__Utilities.DBConnectionstring, DO__Utilities.DBLogfile ); #endregion try { _con.Open(); _con.Transaction.Begin(); #region TX_Name . . . if ((tx_Name_in != null) && (tx_Name_in.Length != 0)) { SBO_DIC_Dic.updObject( _con, _tag.TX_Name, tx_Name_in ); } #endregion tag_in.TX_Name = _tag.TX_Name; DO_NWS_Tag.updObject( tag_in, true, _con ); _errorlist.Add(ErrorType.tag__successfully_updated__WARNING); #region _con.Transaction.Commit(); if ( _con.IsOpen && _con.Transaction.InTransaction ) { _con.Transaction.Commit(); } #endregion } catch (Exception _ex) { #region _con.Transaction.Rollback(); if ( _con.IsOpen && _con.Transaction.InTransaction ) { _con.Transaction.Rollback(); } #endregion _exception = _ex; } finally { #region _con.Transaction.Terminate(); _con.Close(); _con.Dispose(); if (_con.IsOpen) { if (_con.Transaction.InTransaction) { _con.Transaction.Terminate(); } _con.Close(); } _con.Dispose(); #endregion } if (_exception != null) { #region SBO_LOG_Log.Log(ErrorType.data); OGen.NTier.Kick.Libraries.BusinessLayer.SBO_LOG_Log.log( _sessionuser, LogType.error, ErrorType.data, -1L, _sessionuser.IDApplication, "{0}", new string[] { _exception.Message } ); #endregion _errorlist.Add(ErrorType.data); } errors_out = _errorlist.ToArray(); }
public static long insObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_NWS_Tag tag_in, OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_DIC__TextLanguage[] tx_Name_in, bool selectIdentity_in, out int[] errors_out ) { long _output = -1L; Guid _sessionguid; Sessionuser _sessionuser; #region check... List <int> _errorlist; if (!check( sessionGuid_in, ip_forLogPurposes_in, ref tag_in, tx_Name_in, out _sessionguid, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return(_output); } #endregion if (_sessionuser.hasPermission(PermissionType.Tag__approve)) { tag_in.Approved_date = DateTime.Now; tag_in.IFUser__Approved = _sessionuser.IDUser; } else { tag_in.Approved_date_isNull = true; tag_in.IFUser__Approved_isNull = true; } tag_in.IFApplication = _sessionuser.IDApplication; Exception _exception = null; #region DBConnection _con = DO__Utilities.DBConnection_createInstance(...); DBConnection _con = DO__Utilities.DBConnection_createInstance( DO__Utilities.DBServerType, DO__Utilities.DBConnectionstring, DO__Utilities.DBLogfile ); #endregion try { _con.Open(); _con.Transaction.Begin(); long _tx_name = SBO_DIC_Dic.insObject( _con, _sessionuser.IDApplication, TableFieldSource.NWS_TAG__TX_NAME, tx_Name_in ); tag_in.TX_Name = _tx_name; _output = DO_NWS_Tag.insObject( tag_in, selectIdentity_in, _con ); _errorlist.Add(ErrorType.tag__successfully_created__WARNING); #region _con.Transaction.Commit(); if ( _con.IsOpen && _con.Transaction.InTransaction ) { _con.Transaction.Commit(); } #endregion } catch (Exception _ex) { #region _con.Transaction.Rollback(); if ( _con.IsOpen && _con.Transaction.InTransaction ) { _con.Transaction.Rollback(); } #endregion _exception = _ex; } finally { #region _con.Transaction.Terminate(); _con.Close(); _con.Dispose(); if (_con.IsOpen) { if (_con.Transaction.InTransaction) { _con.Transaction.Terminate(); } _con.Close(); } _con.Dispose(); #endregion } if (_exception != null) { #region SBO_LOG_Log.Log(ErrorType.data); OGen.NTier.Kick.Libraries.BusinessLayer.SBO_LOG_Log.log( _sessionuser, LogType.error, ErrorType.data, -1L, _sessionuser.IDApplication, "{0}", new string[] { _exception.Message } ); #endregion _errorlist.Add(ErrorType.data); } errors_out = _errorlist.ToArray(); return(_output); }
private static bool check( string sessionGuid_in, string ip_forLogPurposes_in, ref SO_NWS_Tag tag_ref, OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_DIC__TextLanguage[] tx_Name_in, out Guid sessionGuid_out, out Sessionuser sessionUser_out, out List <int> errorlist_out ) { #region check... if (!SBO_CRD_Authentication.isSessionGuid_valid( sessionGuid_in, ip_forLogPurposes_in, out sessionGuid_out, out sessionUser_out, out errorlist_out )) { return(false); } #endregion #region check Permissions . . . if ( !sessionUser_out.hasPermission( false, PermissionType.Tag__insert, PermissionType.Tag__update ) ) { errorlist_out.Add(ErrorType.tag__lack_of_permissions_to_write); return(false); } if ( !sessionUser_out.hasPermission(PermissionType.Tag__approve) && ( !tag_ref.Approved_date_isNull || !tag_ref.IFUser__Approved_isNull ) ) { errorlist_out.Add(ErrorType.tag__lack_of_permissions_to_approve); return(false); } #endregion // ToDos: here! check parent existence // ToDos: here! check if parent within same application // ToDos: here! check if any other checkings needed ... if (tag_ref.IFTag__parent <= 0) { tag_ref.IFTag__parent_isNull = true; } #region check Tag ... if ( (tx_Name_in == null) || (tx_Name_in.Length == 0) ) { errorlist_out.Add(ErrorType.tag__invalid_name); return(false); } else { foreach (SO_DIC__TextLanguage _tx_name in tx_Name_in) { if ( (_tx_name.Text = _tx_name.Text.Trim()).Length == 0 ) { errorlist_out.Add(ErrorType.tag__invalid_name); return(false); } } } #endregion return(true); }
/// <summary> /// Selects NWS_Tag values from Database and assigns them to the appropriate DO_NWS_Tag property. /// </summary> /// <param name="IDTag_in">IDTag</param> /// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param> /// <returns>null if NWS_Tag doesn't exists at Database</returns> public static SO_NWS_Tag getObject( long IDTag_in, DBConnection dbConnection_in ) { SO_NWS_Tag _output = null; DBConnection _connection = (dbConnection_in == null) ? DO__Utilities.DBConnection_createInstance( DO__Utilities.DBServerType, DO__Utilities.DBConnectionstring, DO__Utilities.DBLogfile ) : dbConnection_in; IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _connection.newDBDataParameter("IDTag_", DbType.Int64, ParameterDirection.InputOutput, IDTag_in, 0), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Output, null, 0), _connection.newDBDataParameter("IFTag__parent_", DbType.Int64, ParameterDirection.Output, null, 0), _connection.newDBDataParameter("TX_Name_", DbType.Int64, ParameterDirection.Output, null, 0), _connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Output, null, 0), _connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Output, null, 0) }; _connection.Execute_SQLFunction("sp0_NWS_Tag_getObject", _dataparameters); if (dbConnection_in == null) { _connection.Dispose(); } if (_dataparameters[0].Value != DBNull.Value) { _output = new SO_NWS_Tag(); if (_dataparameters[0].Value == System.DBNull.Value) { _output.IDTag = 0L; } else { _output.IDTag = (long)_dataparameters[0].Value; } if (_dataparameters[1].Value == System.DBNull.Value) { _output.IFApplication_isNull = true; } else { _output.IFApplication = (int)_dataparameters[1].Value; } if (_dataparameters[2].Value == System.DBNull.Value) { _output.IFTag__parent_isNull = true; } else { _output.IFTag__parent = (long)_dataparameters[2].Value; } if (_dataparameters[3].Value == System.DBNull.Value) { _output.TX_Name = 0L; } else { _output.TX_Name = (long)_dataparameters[3].Value; } if (_dataparameters[4].Value == System.DBNull.Value) { _output.IFUser__Approved_isNull = true; } else { _output.IFUser__Approved = (long)_dataparameters[4].Value; } if (_dataparameters[5].Value == System.DBNull.Value) { _output.Approved_date_isNull = true; } else { _output.Approved_date = (DateTime)_dataparameters[5].Value; } _output.HasChanges = false; return(_output); } return(null); }
private static SO_NWS_Tag[] getRecord( DataTable dataTable_in ) { DataColumn _dc_idtag = null; DataColumn _dc_ifapplication = null; DataColumn _dc_iftag__parent = null; DataColumn _dc_tx_name = null; DataColumn _dc_ifuser__approved = null; DataColumn _dc_approved_date = null; SO_NWS_Tag[] _output = new SO_NWS_Tag[dataTable_in.Rows.Count]; for (int r = 0; r < dataTable_in.Rows.Count; r++) { if (r == 0) { _dc_idtag = dataTable_in.Columns["IDTag"]; _dc_ifapplication = dataTable_in.Columns["IFApplication"]; _dc_iftag__parent = dataTable_in.Columns["IFTag__parent"]; _dc_tx_name = dataTable_in.Columns["TX_Name"]; _dc_ifuser__approved = dataTable_in.Columns["IFUser__Approved"]; _dc_approved_date = dataTable_in.Columns["Approved_date"]; } _output[r] = new SO_NWS_Tag(); if (dataTable_in.Rows[r][_dc_idtag] == System.DBNull.Value) { _output[r].IDTag = 0L; } else { _output[r].IDTag = (long)dataTable_in.Rows[r][_dc_idtag]; } if (dataTable_in.Rows[r][_dc_ifapplication] == System.DBNull.Value) { _output[r].IFApplication_isNull = true; } else { _output[r].IFApplication = (int)dataTable_in.Rows[r][_dc_ifapplication]; } if (dataTable_in.Rows[r][_dc_iftag__parent] == System.DBNull.Value) { _output[r].IFTag__parent_isNull = true; } else { _output[r].IFTag__parent = (long)dataTable_in.Rows[r][_dc_iftag__parent]; } if (dataTable_in.Rows[r][_dc_tx_name] == System.DBNull.Value) { _output[r].TX_Name = 0L; } else { _output[r].TX_Name = (long)dataTable_in.Rows[r][_dc_tx_name]; } if (dataTable_in.Rows[r][_dc_ifuser__approved] == System.DBNull.Value) { _output[r].IFUser__Approved_isNull = true; } else { _output[r].IFUser__Approved = (long)dataTable_in.Rows[r][_dc_ifuser__approved]; } if (dataTable_in.Rows[r][_dc_approved_date] == System.DBNull.Value) { _output[r].Approved_date_isNull = true; } else { _output[r].Approved_date = (DateTime)dataTable_in.Rows[r][_dc_approved_date]; } _output[r].HasChanges = false; } return(_output); }