Exemplo n.º 1
0
		private static SO_DIC_TextLanguage[] getRecord(
			DataTable dataTable_in
		) {
			DataColumn _dc_iftext = null;
			DataColumn _dc_iflanguage = null;
			DataColumn _dc_text__small = null;
			DataColumn _dc_text__large = null;

			SO_DIC_TextLanguage[] _output 
				= new SO_DIC_TextLanguage[dataTable_in.Rows.Count];
			for (int r = 0; r < dataTable_in.Rows.Count; r++) {
				if (r == 0) {
					_dc_iftext = dataTable_in.Columns["IFText"];
					_dc_iflanguage = dataTable_in.Columns["IFLanguage"];
					_dc_text__small = dataTable_in.Columns["Text__small"];
					_dc_text__large = dataTable_in.Columns["Text__large"];
				}

				_output[r] = new SO_DIC_TextLanguage();
				if (dataTable_in.Rows[r][_dc_iftext] == System.DBNull.Value) {
					_output[r].IFText = 0L;
				} else {
					_output[r].IFText = (long)dataTable_in.Rows[r][_dc_iftext];
				}
				if (dataTable_in.Rows[r][_dc_iflanguage] == System.DBNull.Value) {
					_output[r].IFLanguage = 0;
				} else {
					_output[r].IFLanguage = (int)dataTable_in.Rows[r][_dc_iflanguage];
				}
				if (dataTable_in.Rows[r][_dc_text__small] == System.DBNull.Value) {
					_output[r].Text__small_isNull = true;
				} else {
					_output[r].Text__small = (string)dataTable_in.Rows[r][_dc_text__small];
				}
				if (dataTable_in.Rows[r][_dc_text__large] == System.DBNull.Value) {
					_output[r].Text__large_isNull = true;
				} else {
					_output[r].Text__large = (string)dataTable_in.Rows[r][_dc_text__large];
				}

				_output[r].HasChanges = false;
			}

			return _output;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Selects DIC_TextLanguage values from Database and assigns them to the appropriate DO_DIC_TextLanguage property.
		/// </summary>
		/// <param name="IFText_in">IFText</param>
		/// <param name="IFLanguage_in">IFLanguage</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 DIC_TextLanguage doesn't exists at Database</returns>
		public static SO_DIC_TextLanguage getObject(
			long IFText_in, 
			int IFLanguage_in, 
			DBConnection dbConnection_in
		) {
			SO_DIC_TextLanguage _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("IFText_", DbType.Int64, ParameterDirection.InputOutput, IFText_in, 0), 
				_connection.newDBDataParameter("IFLanguage_", DbType.Int32, ParameterDirection.InputOutput, IFLanguage_in, 0), 
				_connection.newDBDataParameter("Text__small_", DbType.AnsiString, ParameterDirection.Output, null, 8000), 
				_connection.newDBDataParameter("Text__large_", DbType.AnsiString, ParameterDirection.Output, null, 0)
			};
			_connection.Execute_SQLFunction("sp0_DIC_TextLanguage_getObject", _dataparameters);
			if (dbConnection_in == null) { _connection.Dispose(); }

			if (_dataparameters[0].Value != DBNull.Value) {
				_output = new SO_DIC_TextLanguage();

				if (_dataparameters[0].Value == System.DBNull.Value) {
					_output.IFText = 0L;
				} else {
					_output.IFText = (long)_dataparameters[0].Value;
				}
				if (_dataparameters[1].Value == System.DBNull.Value) {
					_output.IFLanguage = 0;
				} else {
					_output.IFLanguage = (int)_dataparameters[1].Value;
				}
				if (_dataparameters[2].Value == System.DBNull.Value) {
					_output.Text__small_isNull = true;
				} else {
					_output.Text__small = (string)_dataparameters[2].Value;
				}
				if (_dataparameters[3].Value == System.DBNull.Value) {
					_output.Text__large_isNull = true;
				} else {
					_output.Text__large = (string)_dataparameters[3].Value;
				}

				_output.HasChanges = false;
				return _output;
			}

			return null;
		}
Exemplo n.º 3
0
		/// <summary>
		/// Inserts/Updates DIC_TextLanguage values into/on Database. Inserts if DIC_TextLanguage doesn't exist or Updates if DIC_TextLanguage already exists.
		/// </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>
		/// <returns>True if it didn't exist (INSERT), and False if it did exist (UPDATE)</returns>
		public static bool setObject(
			SO_DIC_TextLanguage DIC_TextLanguage_in, 
			bool forceUpdate_in, 
			DBConnection dbConnection_in
		) {
			bool ConstraintExist_out;
			if (forceUpdate_in || DIC_TextLanguage_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("IFText_", DbType.Int64, ParameterDirection.Input, DIC_TextLanguage_in.IFText, 0), 
					_connection.newDBDataParameter("IFLanguage_", DbType.Int32, ParameterDirection.Input, DIC_TextLanguage_in.IFLanguage, 0), 
					_connection.newDBDataParameter("Text__small_", DbType.AnsiString, ParameterDirection.Input, DIC_TextLanguage_in.Text__small_isNull ? null : (object)DIC_TextLanguage_in.Text__small, 8000), 
					_connection.newDBDataParameter("Text__large_", DbType.AnsiString, ParameterDirection.Input, DIC_TextLanguage_in.Text__large_isNull ? null : (object)DIC_TextLanguage_in.Text__large, 0), 

					//_connection.newDBDataParameter("Exists", DbType.Boolean, ParameterDirection.Output, 0, 1)
					_connection.newDBDataParameter("Output_", DbType.Int32, ParameterDirection.Output, null, 0)
				};
				_connection.Execute_SQLFunction(
					"sp0_DIC_TextLanguage_setObject", 
					_dataparameters
				);
				if (dbConnection_in == null) { _connection.Dispose(); }

				ConstraintExist_out = (((int)_dataparameters[4].Value & 2) == 1);
				if (!ConstraintExist_out) {
					DIC_TextLanguage_in.HasChanges = false;
				}

				return (((int)_dataparameters[4].Value & 1) != 1);
			} else {
				ConstraintExist_out = false;

				return  false;
			}
		}
Exemplo n.º 4
0
		/// <summary>
		/// Inserts/Updates DIC_TextLanguage values into/on Database. Inserts if DIC_TextLanguage doesn't exist or Updates if DIC_TextLanguage already exists.
		/// </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>
		/// <returns>True if it didn't exist (INSERT), and False if it did exist (UPDATE)</returns>
		public static bool setObject(
			SO_DIC_TextLanguage DIC_TextLanguage_in, 
			bool forceUpdate_in
		) {
			return setObject(
				DIC_TextLanguage_in, 
				forceUpdate_in, 
				null
			);
		}
Exemplo n.º 5
0
		public static DataTable getDataTable(
			SO_DIC_TextLanguage[] serializableobjects_in
		) {
			DataTable _output = new DataTable();
			_output.Locale = System.Globalization.CultureInfo.CurrentCulture;
			DataRow _dr;

			DataColumn _dc_iflanguage = new DataColumn("IFLanguage", typeof(int));
			_output.Columns.Add(_dc_iflanguage);
			DataColumn _dc_text = new DataColumn("Text", typeof(string));
			_output.Columns.Add(_dc_text);

			foreach (SO_DIC_TextLanguage _serializableobject in serializableobjects_in) {
				_dr = _output.NewRow();

				_dr[_dc_iflanguage] = _serializableobject.IFLanguage;
				_dr[_dc_text] = _serializableobject.Text__large;

				_output.Rows.Add(_dr);
			}

			return _output;
		}
Exemplo n.º 6
0
		internal static void updObject(
			DBConnection dbConnection_in,

			long idText_in,

			params OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_DIC__TextLanguage[] textLanguage_in
		) {
			SO_DIC_TextLanguage _textlanguage;
			foreach (OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_DIC__TextLanguage _text in textLanguage_in) {
				#region _textlanguage = ...;
				_textlanguage 
					= new SO_DIC_TextLanguage(
						idText_in,
						_text.IFLanguage,
						"",
						""
					);
				if (_text.Text.Length > 8000) {
					_textlanguage.Text__large = _text.Text;
					_textlanguage.Text__small_isNull = true;
				} else {
					_textlanguage.Text__large_isNull = true;
					_textlanguage.Text__small = _text.Text;
				}
				#endregion
				DO_DIC_TextLanguage.setObject(
					_textlanguage,
					true, 

					dbConnection_in
				);
			}
		}
Exemplo n.º 7
0
		public static void insLanguage(
			string sessionGuid_in,
			string ip_forLogPurposes_in,

			SO_DIC__TextLanguage[] languageName_in,
			SO_DIC__TextLanguage[] existingLanguagesInNewLanguage_in, 

			out int[] errors_out
		) {
			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;
			}
			#endregion
			#region check permissions...
			if (!_sessionuser.hasPermission(PermissionType.Language__insert)) {
				_errorlist.Add(ErrorType.language__lack_of_permissions_to_write);
				errors_out = _errorlist.ToArray();
				return;
			}
			#endregion


			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 long _idtext = DO_DIC_Text.insObject(...);
				#region SO_DIC_Text _text = ...;
				SO_DIC_Text _text = new SO_DIC_Text(
					-1L, 
					-1, 
					-1
				);
				_text.IFApplication_isNull = true;
				_text.SourceTableField_ref_isNull = true;
				#endregion

				long _idtext = DO_DIC_Text.insObject(
					_text,
					true,
					_con
				);
				#endregion
				#region int _idlanguage = DO_DIC_Language.insObject(...);
				int _idlanguage = DO_DIC_Language.insObject(
					new SO_DIC_Language(
						-1,
						_idtext
					),
					true,
					_con
				);
				#endregion
				for (int i = 0; i < languageName_in.Length; i++) {
					updObject(
						_con, 
						_idtext,
						(languageName_in[i].IFLanguage > 0) 

							// name of the new language on existing languages
							? languageName_in[i]

							// name of the new language (on new language)
							: new SO_DIC__TextLanguage(
								_idlanguage, 
								languageName_in[i].Text
							)

					);
				}
				SO_DIC_TextLanguage _textlanguage;
				for (int i = 0; i < existingLanguagesInNewLanguage_in.Length; i++) {

					

					_textlanguage = new SO_DIC_TextLanguage();
					_textlanguage.IFText = DO_DIC_Language.getObject(
						existingLanguagesInNewLanguage_in[i].IFLanguage
					).TX_Name;
					_textlanguage.IFLanguage = _idlanguage;
					if (existingLanguagesInNewLanguage_in[i].Text.Length > 8000) {
						_textlanguage.Text__large = existingLanguagesInNewLanguage_in[i].Text;
						_textlanguage.Text__small_isNull = true;
					} else {
						_textlanguage.Text__large_isNull = true;
						_textlanguage.Text__small = existingLanguagesInNewLanguage_in[i].Text;
					}

					DO_DIC_TextLanguage.setObject(
						_textlanguage,
						true,
						_con
					);
				}

				#region _con.Transaction.Commit();
				if (_con.Transaction.InTransaction) {
					_con.Transaction.Commit();
				}
				#endregion
				_errorlist.Add(ErrorType.language__successfully_created__WARNING);
			} 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();
		}