Пример #1
0
        public void BTN_Save_Click(object sender, EventArgs e)
        {
            int[]           _errors;
            SO_vNWS_Profile _profile;

            if (
                #region ((_profile = ...) != null)
                (this.IDProfile > 0)
                &&
                (
                    (_profile = BusinessInstances.NWS_Profile.InstanceClient.getObject(
                         Utilities.User.SessionGuid,
                         Utilities.ClientIPAddress,
                         this.IDProfile,
                         out _errors
                         ))
                    !=
                    null
                )
                &&
                !this.Master__base.Error_add(_errors)
                #endregion
                )
            {
                _profile.Name = this.TXT_Name.Text;

                BusinessInstances.NWS_Profile.InstanceClient.updObject(
                    Utilities.User.SessionGuid,
                    Utilities.ClientIPAddress,
                    _profile,
                    out _errors
                    );
            }
            else
            {
                _profile = new SO_vNWS_Profile();

                _profile.Name = this.TXT_Name.Text;
                _profile.Approved_date_isNull    = true;
                _profile.IFUser__Approved_isNull = true;
                _profile.IDApplication           = Utilities.IDApplication;
                BusinessInstances.NWS_Profile.InstanceClient.insObject(
                    Utilities.User.SessionGuid,
                    Utilities.ClientIPAddress,
                    _profile,
                    out _errors
                    );
            }
            if (!this.Master__base.Error_add(_errors))
            {
                Response.Redirect(
                    "NWS-NewsProfile-list.aspx",
                    true
                    );
            }
        }
Пример #2
0
        public static SO_vNWS_Profile getObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            long idProfile_in,

            out int[] errors_out
            )
        {
            SO_vNWS_Profile _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.News__Profile__select
                    )
                )
            {
                _errorlist.Add(ErrorType.news__profile__lack_of_permissions_to_read);
                errors_out = _errorlist.ToArray();
                return(_output);
            }
            #endregion

            _output = DO_vNWS_Profile.getObject_byProfile(
                idProfile_in,

                null
                );

            errors_out = _errorlist.ToArray();
            return(_output);
        }
Пример #3
0
		/// <summary>
		/// Selects vNWS_Profile values from Database (based on the search condition) and assigns them to the appropriate DO0_vNWS_Profile property.
		/// </summary>
		/// <param name="IDProfile_search_in">IDProfile search condition</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 vNWS_Profile doesn't exists at Database</returns>
		public static SO_vNWS_Profile getObject_byProfile(
			long IDProfile_search_in, 
			DBConnection dbConnection_in
		) {
			SO_vNWS_Profile _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("IDProfile_search_", DbType.Int64, ParameterDirection.Input, IDProfile_search_in, 0), 
				_connection.newDBDataParameter("IDProfile", DbType.Int64, ParameterDirection.Output, null, 0), 
				_connection.newDBDataParameter("Name", DbType.AnsiString, ParameterDirection.Output, null, 255), 
				_connection.newDBDataParameter("IDApplication", DbType.Int32, 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.newDBDataParameter("ManagerName", DbType.AnsiString, ParameterDirection.Output, null, 255)
			};
			_connection.Execute_SQLFunction(
				"sp0_vNWS_Profile_getObject_byProfile", 
				_dataparameters
			);
			if (dbConnection_in == null) { _connection.Dispose(); }

			if (_dataparameters[1].Value != DBNull.Value) {
				_output = new SO_vNWS_Profile();
				if (_dataparameters[1].Value == System.DBNull.Value) {
					_output.IDProfile = 0L;
				} else {
					_output.IDProfile = (long)_dataparameters[1].Value;
				}
				if (_dataparameters[2].Value == System.DBNull.Value) {
					_output.Name = string.Empty;
				} else {
					_output.Name = (string)_dataparameters[2].Value;
				}
				if (_dataparameters[3].Value == System.DBNull.Value) {
					_output.IDApplication_isNull = true;
				} else {
					_output.IDApplication = (int)_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;
				}
				if (_dataparameters[6].Value == System.DBNull.Value) {
					_output.ManagerName_isNull = true;
				} else {
					_output.ManagerName = (string)_dataparameters[6].Value;
				}

				return _output;
			}

			return null;
		}
Пример #4
0
		private static SO_vNWS_Profile[] getRecord(
			DataTable dataTable_in
		) {
			DataColumn _dc_idprofile = null;
			DataColumn _dc_name = null;
			DataColumn _dc_idapplication = null;
			DataColumn _dc_ifuser__approved = null;
			DataColumn _dc_approved_date = null;
			DataColumn _dc_managername = null;

			SO_vNWS_Profile[] _output 
				= new SO_vNWS_Profile[dataTable_in.Rows.Count];
			for (int r = 0; r < dataTable_in.Rows.Count; r++) {
				if (r == 0) {
					_dc_idprofile = dataTable_in.Columns["IDProfile"];
					_dc_name = dataTable_in.Columns["Name"];
					_dc_idapplication = dataTable_in.Columns["IDApplication"];
					_dc_ifuser__approved = dataTable_in.Columns["IFUser__Approved"];
					_dc_approved_date = dataTable_in.Columns["Approved_date"];
					_dc_managername = dataTable_in.Columns["ManagerName"];
				}

				_output[r] = new SO_vNWS_Profile();
				if (dataTable_in.Rows[r][_dc_idprofile] == System.DBNull.Value) {
					_output[r].IDProfile = 0L;
				} else {
					_output[r].IDProfile = (long)dataTable_in.Rows[r][_dc_idprofile];
				}
				if (dataTable_in.Rows[r][_dc_name] == System.DBNull.Value) {
					_output[r].Name = string.Empty;
				} else {
					_output[r].Name = (string)dataTable_in.Rows[r][_dc_name];
				}
				if (dataTable_in.Rows[r][_dc_idapplication] == System.DBNull.Value) {
					_output[r].IDApplication_isNull = true;
				} else {
					_output[r].IDApplication = (int)dataTable_in.Rows[r][_dc_idapplication];
				}
				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];
				}
				if (dataTable_in.Rows[r][_dc_managername] == System.DBNull.Value) {
					_output[r].ManagerName_isNull = true;
				} else {
					_output[r].ManagerName = (string)dataTable_in.Rows[r][_dc_managername];
				}

				_output[r].HasChanges = false;
			}

			return _output;
		}
Пример #5
0
        /// <summary>
        /// Selects vNWS_Profile values from Database (based on the search condition) and assigns them to the appropriate DO0_vNWS_Profile property.
        /// </summary>
        /// <param name="IDProfile_search_in">IDProfile search condition</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 vNWS_Profile doesn't exists at Database</returns>
        public static SO_vNWS_Profile getObject_byProfile(
            long IDProfile_search_in,
            DBConnection dbConnection_in
            )
        {
            SO_vNWS_Profile _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("IDProfile_search_", DbType.Int64, ParameterDirection.Input, IDProfile_search_in, 0),
                _connection.newDBDataParameter("IDProfile", DbType.Int64, ParameterDirection.Output, null, 0),
                _connection.newDBDataParameter("Name", DbType.AnsiString, ParameterDirection.Output, null, 255),
                _connection.newDBDataParameter("IDApplication", DbType.Int32, 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.newDBDataParameter("ManagerName", DbType.AnsiString, ParameterDirection.Output, null, 255)
            };
            _connection.Execute_SQLFunction(
                "sp0_vNWS_Profile_getObject_byProfile",
                _dataparameters
                );
            if (dbConnection_in == null)
            {
                _connection.Dispose();
            }

            if (_dataparameters[1].Value != DBNull.Value)
            {
                _output = new SO_vNWS_Profile();
                if (_dataparameters[1].Value == System.DBNull.Value)
                {
                    _output.IDProfile = 0L;
                }
                else
                {
                    _output.IDProfile = (long)_dataparameters[1].Value;
                }
                if (_dataparameters[2].Value == System.DBNull.Value)
                {
                    _output.Name = string.Empty;
                }
                else
                {
                    _output.Name = (string)_dataparameters[2].Value;
                }
                if (_dataparameters[3].Value == System.DBNull.Value)
                {
                    _output.IDApplication_isNull = true;
                }
                else
                {
                    _output.IDApplication = (int)_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;
                }
                if (_dataparameters[6].Value == System.DBNull.Value)
                {
                    _output.ManagerName_isNull = true;
                }
                else
                {
                    _output.ManagerName = (string)_dataparameters[6].Value;
                }

                return(_output);
            }

            return(null);
        }
Пример #6
0
        private static SO_vNWS_Profile[] getRecord(
            DataTable dataTable_in
            )
        {
            DataColumn _dc_idprofile        = null;
            DataColumn _dc_name             = null;
            DataColumn _dc_idapplication    = null;
            DataColumn _dc_ifuser__approved = null;
            DataColumn _dc_approved_date    = null;
            DataColumn _dc_managername      = null;

            SO_vNWS_Profile[] _output
                = new SO_vNWS_Profile[dataTable_in.Rows.Count];
            for (int r = 0; r < dataTable_in.Rows.Count; r++)
            {
                if (r == 0)
                {
                    _dc_idprofile        = dataTable_in.Columns["IDProfile"];
                    _dc_name             = dataTable_in.Columns["Name"];
                    _dc_idapplication    = dataTable_in.Columns["IDApplication"];
                    _dc_ifuser__approved = dataTable_in.Columns["IFUser__Approved"];
                    _dc_approved_date    = dataTable_in.Columns["Approved_date"];
                    _dc_managername      = dataTable_in.Columns["ManagerName"];
                }

                _output[r] = new SO_vNWS_Profile();
                if (dataTable_in.Rows[r][_dc_idprofile] == System.DBNull.Value)
                {
                    _output[r].IDProfile = 0L;
                }
                else
                {
                    _output[r].IDProfile = (long)dataTable_in.Rows[r][_dc_idprofile];
                }
                if (dataTable_in.Rows[r][_dc_name] == System.DBNull.Value)
                {
                    _output[r].Name = string.Empty;
                }
                else
                {
                    _output[r].Name = (string)dataTable_in.Rows[r][_dc_name];
                }
                if (dataTable_in.Rows[r][_dc_idapplication] == System.DBNull.Value)
                {
                    _output[r].IDApplication_isNull = true;
                }
                else
                {
                    _output[r].IDApplication = (int)dataTable_in.Rows[r][_dc_idapplication];
                }
                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];
                }
                if (dataTable_in.Rows[r][_dc_managername] == System.DBNull.Value)
                {
                    _output[r].ManagerName_isNull = true;
                }
                else
                {
                    _output[r].ManagerName = (string)dataTable_in.Rows[r][_dc_managername];
                }

                _output[r].HasChanges = false;
            }

            return(_output);
        }
		public void btn_Save_Click(object sender, EventArgs e) {
			int[] _errors;
			SO_vNWS_Profile _profile;
			if (
				#region ((_profile = ...) != null)
				(IDProfile > 0)
				&&
				(
					(_profile = BusinessInstances.NWS_Profile.InstanceClient.getObject(
						utils.User.SessionGuid,
						utils.ClientIPAddress,
						IDProfile,
						out _errors
					))
					!=
					null
				)
				&&
				!Master__base.Error_add(_errors)
				#endregion
			) {
				_profile.Name = txt_Name.Text;

				BusinessInstances.NWS_Profile.InstanceClient.updObject(
					utils.User.SessionGuid,
					utils.ClientIPAddress,
					_profile, 
					out _errors
				);
			} else {
				_profile = new SO_vNWS_Profile();

				_profile.Name = txt_Name.Text;
				_profile.Approved_date_isNull = true;
				_profile.IFUser__Approved_isNull = true;
				_profile.IDApplication = utils.IDApplication;
				BusinessInstances.NWS_Profile.InstanceClient.insObject(
					utils.User.SessionGuid,
					utils.ClientIPAddress,
					_profile,
					out _errors
				);
			}
			if (!Master__base.Error_add(_errors)) {
				Response.Redirect(
					"NWS-NewsProfile-list.aspx",
					true
				);
			}
		}
Пример #8
0
		private static bool check(
			string sessionGuid_in,
			string ip_forLogPurposes_in, 

			ref SO_vNWS_Profile profile_ref,

			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.News__Profile__insert,
					PermissionType.News__Profile__update
				)
			) {
				errorlist_out.Add(ErrorType.news__profile__lack_of_permissions_to_write);
				return false;
			}

			if (
				(
					!profile_ref.Approved_date_isNull
					||
					!profile_ref.IFUser__Approved_isNull
				)
				&&
				!sessionUser_out.hasPermission(PermissionType.News__Profile__approve)
			) {
				errorlist_out.Add(ErrorType.news__profile__lack_of_permissions_to_approve);
				return false;
			}
			#endregion

			#region check Profile ...
			if (
				(profile_ref.Name = profile_ref.Name.Trim()).Length == 0
			) {
				errorlist_out.Add(ErrorType.news__profile__invalid_name);
				return false;
			}
			#endregion

			return true;
		} 
Пример #9
0
		public static void updObject(
			string sessionGuid_in,
			string ip_forLogPurposes_in, 

			SO_vNWS_Profile profile_in,

			out int[] errors_out
		) {

			Guid _sessionguid;
			Sessionuser _sessionuser;

			#region check...
			List<int> _errorlist;
			if (!check(
				sessionGuid_in,
				ip_forLogPurposes_in,

				ref profile_in,

				out _sessionguid,
				out _sessionuser,
				out _errorlist
			)) {
				errors_out = _errorlist.ToArray();
				return;
			}
			#endregion
			#region check existence . . . SO_NWS_Profile _nws_profile = DO_NWS_Profile.getObject(...);
			SO_NWS_Profile _nws_profile;
			if (
				profile_in.IDProfile <= 0
				||
				(
					(_nws_profile = DO_NWS_Profile.getObject(
						profile_in.IDProfile
					)) == null
				)
			) {
				_errorlist.Add(ErrorType.data__not_found);
				errors_out = _errorlist.ToArray();
				return;
			}
			#endregion
			#region _nws_profile.IFUser__Approved = ...;
			if (
					_nws_profile.IFUser__Approved_isNull
					||
					_nws_profile.Approved_date_isNull
				) {
				if (_sessionuser.hasPermission(PermissionType.News__Profile__approve)) {
					_nws_profile.Approved_date = DateTime.Now;
					_nws_profile.IFUser__Approved = _sessionuser.IDUser;
				} else {
					_nws_profile.Approved_date_isNull = true;
					_nws_profile.IFUser__Approved_isNull = true;
				}
			}
			#endregion

			#region SO_CRD_Profile _crd_profile = DO_CRD_Profile.getObject(_nws_profile.IFProfile);
			SO_CRD_Profile _crd_profile
				= DO_CRD_Profile.getObject(
					_nws_profile.IFProfile
				); 
			#endregion
			//// preserve, hence comment:
			//_crd_profile.IFApplication = profile_in.IDApplication;
			_crd_profile.Name = profile_in.Name;


			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();

				DO_NWS_Profile.setObject(
					_nws_profile,
					true,

					_con
				);

				DO_CRD_Profile.updObject(
					_crd_profile,
					false, // I did getObject prior, so no problem. BE CAREFULL in future updates!

					_con
				);

				_errorlist.Add(ErrorType.news__profile__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();
		}
Пример #10
0
		public static long insObject(
			string sessionGuid_in,
			string ip_forLogPurposes_in, 

			SO_vNWS_Profile profile_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 profile_in,

				out _sessionguid,
				out _sessionuser,
				out _errorlist
			)) {
				errors_out = _errorlist.ToArray();
				return _output;
			} 
			#endregion

			#region SO_CRD_Profile _crd_profile = new SO_CRD_Profile(...);
			SO_CRD_Profile _crd_profile
				= new SO_CRD_Profile(
					-1L,
					profile_in.Name,
					//profile_in.IDApplication
					_sessionuser.IDApplication
				); 
			#endregion
			#region _crd_profile.IFApplication = ...;
			//if (
			//    (profile_in.IDApplication_isNull)
			//    ||
			//    (profile_in.IDApplication <= 0)
			//) {
			//    _crd_profile.IFApplication_isNull = true;
			//} else {
			//    _crd_profile.IFApplication = profile_in.IDApplication;
			//}

			_crd_profile.IFApplication = _sessionuser.IDApplication;
			#endregion
			_crd_profile.Name = profile_in.Name;

			#region SO_NWS_Profile _nws_profile = new SO_NWS_Profile(...);
			SO_NWS_Profile _nws_profile 
				= new SO_NWS_Profile(
				); 
			#endregion
			#region _nws_profile.IFUser__Approved = ...;
			if (_sessionuser.hasPermission(PermissionType.News__Profile__approve)) {
				_nws_profile.Approved_date = DateTime.Now;
				_nws_profile.IFUser__Approved = _sessionuser.IDUser;
			} else {
				//// ALREADY CHECKED!!!
				//if (
				//    !profile_in.Approved_date_isNull
				//    ||
				//    !profile_in.IFUser__Approved_isNull
				//) {
				//    _errorlist.Add(ErrorType.news__profile__lack_of_permissions_to_approve);
				//    errors_out = _errorlist.ToArray();
				//    return _output;
				//} else {
					_nws_profile.Approved_date_isNull = true;
					_nws_profile.IFUser__Approved_isNull = true;
				//}
			} 
			#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();

				_output = DO_CRD_Profile.insObject(
					_crd_profile,
					true,

					_con
				);

				_nws_profile.IFProfile = _output;
				DO_NWS_Profile.setObject(
					_nws_profile,
					true,

					_con
				);

				_errorlist.Add(ErrorType.news__profile__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;
		}
Пример #11
0
        private static bool check(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            ref SO_vNWS_Profile profile_ref,

            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.News__Profile__insert,
                    PermissionType.News__Profile__update
                    )
                )
            {
                errorlist_out.Add(ErrorType.news__profile__lack_of_permissions_to_write);
                return(false);
            }

            if (
                (
                    !profile_ref.Approved_date_isNull
                    ||
                    !profile_ref.IFUser__Approved_isNull
                )
                &&
                !sessionUser_out.hasPermission(PermissionType.News__Profile__approve)
                )
            {
                errorlist_out.Add(ErrorType.news__profile__lack_of_permissions_to_approve);
                return(false);
            }
            #endregion

            #region check Profile ...
            if (
                (profile_ref.Name = profile_ref.Name.Trim()).Length == 0
                )
            {
                errorlist_out.Add(ErrorType.news__profile__invalid_name);
                return(false);
            }
            #endregion

            return(true);
        }
Пример #12
0
        public static void updObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            SO_vNWS_Profile profile_in,

            out int[] errors_out
            )
        {
            Guid        _sessionguid;
            Sessionuser _sessionuser;

            #region check...
            List <int> _errorlist;
            if (!check(
                    sessionGuid_in,
                    ip_forLogPurposes_in,

                    ref profile_in,

                    out _sessionguid,
                    out _sessionuser,
                    out _errorlist
                    ))
            {
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion
            #region check existence . . . SO_NWS_Profile _nws_profile = DO_NWS_Profile.getObject(...);
            SO_NWS_Profile _nws_profile;
            if (
                profile_in.IDProfile <= 0
                ||
                (
                    (_nws_profile = DO_NWS_Profile.getObject(
                         profile_in.IDProfile
                         )) == null
                )
                )
            {
                _errorlist.Add(ErrorType.data__not_found);
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion
            #region _nws_profile.IFUser__Approved = ...;
            if (
                _nws_profile.IFUser__Approved_isNull
                ||
                _nws_profile.Approved_date_isNull
                )
            {
                if (_sessionuser.hasPermission(PermissionType.News__Profile__approve))
                {
                    _nws_profile.Approved_date    = DateTime.Now;
                    _nws_profile.IFUser__Approved = _sessionuser.IDUser;
                }
                else
                {
                    _nws_profile.Approved_date_isNull    = true;
                    _nws_profile.IFUser__Approved_isNull = true;
                }
            }
            #endregion

            #region SO_CRD_Profile _crd_profile = DO_CRD_Profile.getObject(_nws_profile.IFProfile);
            SO_CRD_Profile _crd_profile
                = DO_CRD_Profile.getObject(
                      _nws_profile.IFProfile
                      );
            #endregion
            //// preserve, hence comment:
            //_crd_profile.IFApplication = profile_in.IDApplication;
            _crd_profile.Name = profile_in.Name;


            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();

                DO_NWS_Profile.setObject(
                    _nws_profile,
                    true,

                    _con
                    );

                DO_CRD_Profile.updObject(
                    _crd_profile,
                    false,                     // I did getObject prior, so no problem. BE CAREFULL in future updates!

                    _con
                    );

                _errorlist.Add(ErrorType.news__profile__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();
        }
Пример #13
0
        public static long insObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            SO_vNWS_Profile profile_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 profile_in,

                    out _sessionguid,
                    out _sessionuser,
                    out _errorlist
                    ))
            {
                errors_out = _errorlist.ToArray();
                return(_output);
            }
            #endregion

            #region SO_CRD_Profile _crd_profile = new SO_CRD_Profile(...);
            SO_CRD_Profile _crd_profile
                = new SO_CRD_Profile(
                      -1L,
                      profile_in.Name,
                      //profile_in.IDApplication
                      _sessionuser.IDApplication
                      );
            #endregion
            #region _crd_profile.IFApplication = ...;
            //if (
            //    (profile_in.IDApplication_isNull)
            //    ||
            //    (profile_in.IDApplication <= 0)
            //) {
            //    _crd_profile.IFApplication_isNull = true;
            //} else {
            //    _crd_profile.IFApplication = profile_in.IDApplication;
            //}

            _crd_profile.IFApplication = _sessionuser.IDApplication;
            #endregion
            _crd_profile.Name = profile_in.Name;

            #region SO_NWS_Profile _nws_profile = new SO_NWS_Profile(...);
            SO_NWS_Profile _nws_profile
                = new SO_NWS_Profile(
                      );
            #endregion
            #region _nws_profile.IFUser__Approved = ...;
            if (_sessionuser.hasPermission(PermissionType.News__Profile__approve))
            {
                _nws_profile.Approved_date    = DateTime.Now;
                _nws_profile.IFUser__Approved = _sessionuser.IDUser;
            }
            else
            {
                //// ALREADY CHECKED!!!
                //if (
                //    !profile_in.Approved_date_isNull
                //    ||
                //    !profile_in.IFUser__Approved_isNull
                //) {
                //    _errorlist.Add(ErrorType.news__profile__lack_of_permissions_to_approve);
                //    errors_out = _errorlist.ToArray();
                //    return _output;
                //} else {
                _nws_profile.Approved_date_isNull    = true;
                _nws_profile.IFUser__Approved_isNull = true;
                //}
            }
            #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();

                _output = DO_CRD_Profile.insObject(
                    _crd_profile,
                    true,

                    _con
                    );

                _nws_profile.IFProfile = _output;
                DO_NWS_Profile.setObject(
                    _nws_profile,
                    true,

                    _con
                    );

                _errorlist.Add(ErrorType.news__profile__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);
        }