/// <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__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.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; }
/// <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__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.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; } }
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; }
/// <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__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.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; }
/// <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 ); }
public static DataTable getDataTable( SO_NWS_Tag[] serializableobjects_in ) { DataTable _output = new DataTable(); DataRow _dr; DataColumn _dc_idtag = new DataColumn("IDTag", typeof(long)); _output.Columns.Add(_dc_idtag); DataColumn _dc_ifapplication = new DataColumn("IFApplication", typeof(int)); _output.Columns.Add(_dc_ifapplication); DataColumn _dc_iftag__parent = new DataColumn("IFTag__parent", typeof(long)); _output.Columns.Add(_dc_iftag__parent); DataColumn _dc_tx_name = new DataColumn("TX_Name", typeof(long)); _output.Columns.Add(_dc_tx_name); DataColumn _dc_ifuser__approved = new DataColumn("IFUser__Approved", typeof(long)); _output.Columns.Add(_dc_ifuser__approved); DataColumn _dc_approved_date = new DataColumn("Approved_date", typeof(DateTime)); _output.Columns.Add(_dc_approved_date); foreach (SO_NWS_Tag _serializableobject in serializableobjects_in) { _dr = _output.NewRow(); _dr[_dc_idtag] = _serializableobject.IDTag; _dr[_dc_ifapplication] = _serializableobject.IFApplication; _dr[_dc_iftag__parent] = _serializableobject.IFTag__parent; _dr[_dc_tx_name] = _serializableobject.TX_Name; _dr[_dc_ifuser__approved] = _serializableobject.IFUser__Approved; _dr[_dc_approved_date] = _serializableobject.Approved_date; _output.Rows.Add(_dr); } return _output; }
/// <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 void updObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_NWS_Tag tag_in, OGen.NTier.Kick.lib.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.hasPermition(PermitionType.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__utils.DBConnection_createInstance(...); DBConnection _con = DO__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.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.lib.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.lib.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.hasPermition(PermitionType.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__utils.DBConnection_createInstance(...); DBConnection _con = DO__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.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.lib.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.lib.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 Permitions . . . if ( !sessionUser_out.hasPermition( false, PermitionType.Tag__insert, PermitionType.Tag__update ) ) { errorlist_out.Add(ErrorType.tag__lack_of_permitions_to_write); return false; } if ( !sessionUser_out.hasPermition(PermitionType.Tag__approve) && ( !tag_ref.Approved_date_isNull || !tag_ref.IFUser__Approved_isNull ) ) { errorlist_out.Add(ErrorType.tag__lack_of_permitions_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()) == "" ) { errorlist_out.Add(ErrorType.tag__invalid_name); return false; } } } #endregion return true; }
private void btn_save_click( ref SO_NWS_Tag tag_ref ) { #region tag_ref.IFTag__parent = long.Parse(ddl_Tag_parent.SelectedValue); if (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(ddl_Tag_parent.SelectedValue); } #endregion }
public void btn_Save_Click(object sender, EventArgs e) { int[] _errors; SO_NWS_Tag _tag; if ( #region ((_tag = ...) != null) (IDTag > 0) && ( (_tag = BusinessInstances.NWS_Tag.InstanceClient.getObject( utils.User.SessionGuid, utils.ClientIPAddress, IDTag, out _errors )) != null ) && !Master__base.Error_add(_errors) #endregion ) { #region _tag.IFTag__parent = long.Parse(ddl_Tag_parent.SelectedValue); btn_save_click( ref _tag ); #endregion BusinessInstances.NWS_Tag.InstanceClient.updObject( utils.User.SessionGuid, utils.ClientIPAddress, _tag, dic_Name.Texts, out _errors ); } else { _tag = new SO_NWS_Tag(); #region _tag.IFTag__parent = long.Parse(ddl_Tag_parent.SelectedValue); btn_save_click( ref _tag ); #endregion _tag.Approved_date_isNull = true; _tag.IFUser__Approved_isNull = true; _tag.IFApplication = utils.IDApplication; BusinessInstances.NWS_Tag.InstanceClient.insObject( utils.User.SessionGuid, utils.ClientIPAddress, _tag, dic_Name.Texts, false, out _errors ); } if (!Master__base.Error_add(_errors)) { Response.Redirect( "NWS-NewsTag-list.aspx", true ); } }