Ejemplo n.º 1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_SUED_1648 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            ORM_CMN_BPT_EMP_Employee_PayroleDocument.Query payroleDocumentQuery = new ORM_CMN_BPT_EMP_Employee_PayroleDocument.Query();
            payroleDocumentQuery.Employee_RefID = Parameter.Employee_RefID;
            payroleDocumentQuery.Tenant_RefID   = securityTicket.TenantID;
            payroleDocumentQuery.IsDeleted      = false;
            List <ORM_CMN_BPT_EMP_Employee_PayroleDocument> payroleDocumentList = ORM_CMN_BPT_EMP_Employee_PayroleDocument.Query.Search(Connection, Transaction, payroleDocumentQuery);

            List <ORM_CMN_BPT_EMP_Employee_PayroleDocument> deletedDocumentList = new List <ORM_CMN_BPT_EMP_Employee_PayroleDocument>();
            ORM_DOC_DocumentRevision docReviosion = new ORM_DOC_DocumentRevision();
            ORM_DOC_Document         docDocument;
            FR_Base docRevisionResult = new FR_Base();
            FR_Base docDocumentResult = new FR_Base();
            foreach (var item in payroleDocumentList)
            {
                if (Parameter.Documents.Any(p => p.CMN_BPT_EMP_Employee_PayroleDocumentsID == item.CMN_BPT_EMP_Employee_PayroleDocumentsID))
                {
                    continue;
                }

                if (item.Document_RefID != Guid.Empty)
                {
                    docRevisionResult = docReviosion.Load(Connection, Transaction, item.Document_RefID);
                }

                if (docRevisionResult.Status == FR_Status.Success && docReviosion.DOC_DocumentRevisionID != Guid.Empty)
                {
                    docReviosion.Remove(Connection, Transaction);
                }

                item.Remove(Connection, Transaction);
                deletedDocumentList.Add(item);
            }
            payroleDocumentList = payroleDocumentList.Except(deletedDocumentList).ToList();

            foreach (var payroleDocument in Parameter.Documents)
            {
                ORM_CMN_BPT_EMP_Employee_PayroleDocument payroleDocuments = new ORM_CMN_BPT_EMP_Employee_PayroleDocument();

                if (payroleDocumentList.Any(item => item.CMN_BPT_EMP_Employee_PayroleDocumentsID == payroleDocument.CMN_BPT_EMP_Employee_PayroleDocumentsID))
                {
                    payroleDocuments.Load(Connection, Transaction, payroleDocument.CMN_BPT_EMP_Employee_PayroleDocumentsID);
                }

                docDocument  = new ORM_DOC_Document();
                docReviosion = new ORM_DOC_DocumentRevision();
                if (payroleDocuments.Document_RefID != Guid.Empty)
                {
                    docRevisionResult = docReviosion.Load(Connection, Transaction, payroleDocument.DocumentID);
                    docDocumentResult = docDocument.Load(Connection, Transaction, docReviosion.Document_RefID);
                }

                docDocument.Alias        = payroleDocument.File_Name;
                docDocument.Tenant_RefID = securityTicket.TenantID;
                docDocument.Save(Connection, Transaction);

                docReviosion.DOC_DocumentRevisionID = payroleDocument.DocumentID;
                docReviosion.Document_RefID         = docDocument.DOC_DocumentID;
                docReviosion.File_Name        = payroleDocument.File_Name;
                docReviosion.File_Description = payroleDocument.File_Description;
                docReviosion.File_Extension   = payroleDocument.File_Extension;
                docReviosion.File_MIMEType    = payroleDocument.File_MIMEType;
                docReviosion.Tenant_RefID     = securityTicket.TenantID;
                docReviosion.Save(Connection, Transaction);

                payroleDocuments.Tenant_RefID   = securityTicket.TenantID;
                payroleDocuments.Document_RefID = payroleDocument.DocumentID;
                payroleDocuments.DocumentDate   = payroleDocument.DocumentDate;
                payroleDocuments.Employee_RefID = Parameter.Employee_RefID;

                payroleDocuments.Save(Connection, Transaction);
            }

            return(returnValue);

            #endregion UserCode
        }
Ejemplo n.º 2
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_STR.CMN_STR_Office.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _CMN_STR_OfficeID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_STR_OfficeID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "CMN_STR_OfficeID", "OfficeITL", "Parent_RefID", "Country_RefID", "Region_RefID", "Default_BillingAddress_RefID", "Default_ShippingAddress_RefID", "CMN_CAL_CalendarInstance_RefID", "Default_PhoneNumber", "Default_FaxNumber", "Default_Website", "Default_Email", "Office_Name_DictID", "Office_Description_DictID", "Office_ShortName", "IsMockObject", "Office_InternalName", "Office_InternalNumber", "Comment", "DisplayImage_Document_RefID", "IsMedicalPractice", "IfMedicalPractise_HEC_MedicalPractice_RefID", "Creation_Timestamp", "Tenant_RefID", "IsDeleted", "Modification_Timestamp" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter CMN_STR_OfficeID of type Guid
                        _CMN_STR_OfficeID = reader.GetGuid(0);
                        //1:Parameter OfficeITL of type String
                        _OfficeITL = reader.GetString(1);
                        //2:Parameter Parent_RefID of type Guid
                        _Parent_RefID = reader.GetGuid(2);
                        //3:Parameter Country_RefID of type Guid
                        _Country_RefID = reader.GetGuid(3);
                        //4:Parameter Region_RefID of type Guid
                        _Region_RefID = reader.GetGuid(4);
                        //5:Parameter Default_BillingAddress_RefID of type Guid
                        _Default_BillingAddress_RefID = reader.GetGuid(5);
                        //6:Parameter Default_ShippingAddress_RefID of type Guid
                        _Default_ShippingAddress_RefID = reader.GetGuid(6);
                        //7:Parameter CMN_CAL_CalendarInstance_RefID of type Guid
                        _CMN_CAL_CalendarInstance_RefID = reader.GetGuid(7);
                        //8:Parameter Default_PhoneNumber of type String
                        _Default_PhoneNumber = reader.GetString(8);
                        //9:Parameter Default_FaxNumber of type String
                        _Default_FaxNumber = reader.GetString(9);
                        //10:Parameter Default_Website of type String
                        _Default_Website = reader.GetString(10);
                        //11:Parameter Default_Email of type String
                        _Default_Email = reader.GetString(11);
                        //12:Parameter Office_Name of type Dict
                        _Office_Name = reader.GetDictionary(12);
                        loader.Append(_Office_Name, TableName);
                        //13:Parameter Office_Description of type Dict
                        _Office_Description = reader.GetDictionary(13);
                        loader.Append(_Office_Description, TableName);
                        //14:Parameter Office_ShortName of type String
                        _Office_ShortName = reader.GetString(14);
                        //15:Parameter IsMockObject of type Boolean
                        _IsMockObject = reader.GetBoolean(15);
                        //16:Parameter Office_InternalName of type String
                        _Office_InternalName = reader.GetString(16);
                        //17:Parameter Office_InternalNumber of type String
                        _Office_InternalNumber = reader.GetString(17);
                        //18:Parameter Comment of type String
                        _Comment = reader.GetString(18);
                        //19:Parameter DisplayImage_Document_RefID of type Guid
                        _DisplayImage_Document_RefID = reader.GetGuid(19);
                        //20:Parameter IsMedicalPractice of type Boolean
                        _IsMedicalPractice = reader.GetBoolean(20);
                        //21:Parameter IfMedicalPractise_HEC_MedicalPractice_RefID of type Guid
                        _IfMedicalPractise_HEC_MedicalPractice_RefID = reader.GetGuid(21);
                        //22:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(22);
                        //23:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(23);
                        //24:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(24);
                        //25:Parameter Modification_Timestamp of type DateTime
                        _Modification_Timestamp = reader.GetDate(25);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_CMN_STR_OfficeID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_ACC_PAY.ACC_PAY_Condition_Detail.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _ACC_PAY_Condition_DetailID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ACC_PAY_Condition_DetailID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "ACC_PAY_Condition_DetailID", "Conditions_RefID", "DateInterval_From", "DateInterval_To", "DiscountPercentage", "SequenceNumber", "Creation_Timestamp", "IsDeleted", "Tenant_RefID" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter ACC_PAY_Condition_DetailID of type Guid
                        _ACC_PAY_Condition_DetailID = reader.GetGuid(0);
                        //1:Parameter Conditions_RefID of type Guid
                        _Conditions_RefID = reader.GetGuid(1);
                        //2:Parameter DateInterval_From of type int
                        _DateInterval_From = reader.GetInteger(2);
                        //3:Parameter DateInterval_To of type int
                        _DateInterval_To = reader.GetInteger(3);
                        //4:Parameter DiscountPercentage of type double
                        _DiscountPercentage = reader.GetDouble(4);
                        //5:Parameter SequenceNumber of type int
                        _SequenceNumber = reader.GetInteger(5);
                        //6:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(6);
                        //7:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(7);
                        //8:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(8);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_ACC_PAY_Condition_DetailID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 4
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_STR_PPS.CMN_STR_PPS_Workplace.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _CMN_STR_PPS_WorkplaceID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_STR_PPS_WorkplaceID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "CMN_STR_PPS_WorkplaceID", "WorkArea_RefID", "Name_DictID", "Description_DictID", "CMN_CAL_CalendarInstance_RefID", "ShortName", "IsMockObject", "DisplayColor", "Creation_Timestamp", "Tenant_RefID", "IsDeleted" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter CMN_STR_PPS_WorkplaceID of type Guid
                        _CMN_STR_PPS_WorkplaceID = reader.GetGuid(0);
                        //1:Parameter WorkArea_RefID of type Guid
                        _WorkArea_RefID = reader.GetGuid(1);
                        //2:Parameter Name of type Dict
                        _Name = reader.GetDictionary(2);
                        loader.Append(_Name, TableName);
                        //3:Parameter Description of type Dict
                        _Description = reader.GetDictionary(3);
                        loader.Append(_Description, TableName);
                        //4:Parameter CMN_CAL_CalendarInstance_RefID of type Guid
                        _CMN_CAL_CalendarInstance_RefID = reader.GetGuid(4);
                        //5:Parameter ShortName of type String
                        _ShortName = reader.GetString(5);
                        //6:Parameter IsMockObject of type Boolean
                        _IsMockObject = reader.GetBoolean(6);
                        //7:Parameter DisplayColor of type String
                        _DisplayColor = reader.GetString(7);
                        //8:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(8);
                        //9:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(9);
                        //10:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(10);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_CMN_STR_PPS_WorkplaceID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
Ejemplo n.º 5
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG_WRH.LOG_WRH_Area.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _LOG_WRH_AreaID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LOG_WRH_AreaID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "LOG_WRH_AreaID", "GlobalPropertyMatchingID", "CoordinateCode", "Area_Name", "Warehouse_RefID", "IsStructureHidden", "IsConsignmentArea", "IfConsignmentArea_DefaultOwningSupplier_RefID", "Rack_NamePrefix", "IsPointOfSalesArea", "IsLongTermStorageArea", "IsCrossDockArea", "IsDefaultIntakeArea", "Creation_Timestamp", "Tenant_RefID", "IsDeleted" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter LOG_WRH_AreaID of type Guid
                        _LOG_WRH_AreaID = reader.GetGuid(0);
                        //1:Parameter GlobalPropertyMatchingID of type String
                        _GlobalPropertyMatchingID = reader.GetString(1);
                        //2:Parameter CoordinateCode of type String
                        _CoordinateCode = reader.GetString(2);
                        //3:Parameter Area_Name of type String
                        _Area_Name = reader.GetString(3);
                        //4:Parameter Warehouse_RefID of type Guid
                        _Warehouse_RefID = reader.GetGuid(4);
                        //5:Parameter IsStructureHidden of type Boolean
                        _IsStructureHidden = reader.GetBoolean(5);
                        //6:Parameter IsConsignmentArea of type Boolean
                        _IsConsignmentArea = reader.GetBoolean(6);
                        //7:Parameter IfConsignmentArea_DefaultOwningSupplier_RefID of type Guid
                        _IfConsignmentArea_DefaultOwningSupplier_RefID = reader.GetGuid(7);
                        //8:Parameter Rack_NamePrefix of type String
                        _Rack_NamePrefix = reader.GetString(8);
                        //9:Parameter IsPointOfSalesArea of type Boolean
                        _IsPointOfSalesArea = reader.GetBoolean(9);
                        //10:Parameter IsLongTermStorageArea of type Boolean
                        _IsLongTermStorageArea = reader.GetBoolean(10);
                        //11:Parameter IsCrossDockArea of type Boolean
                        _IsCrossDockArea = reader.GetBoolean(11);
                        //12:Parameter IsDefaultIntakeArea of type Boolean
                        _IsDefaultIntakeArea = reader.GetBoolean(12);
                        //13:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(13);
                        //14:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(14);
                        //15:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(15);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_LOG_WRH_AreaID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
		protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
		{
			//Standard return type
			FR_Base retStatus = new FR_Base();

			bool cleanupConnection = false;
			bool cleanupTransaction = false;
			try
			{

				bool saveDictionary = false;
			    bool saveORMClass =   !Status_IsAlreadySaved || Status_IsDirty;


				//If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
				if (saveORMClass == false && saveDictionary == false)
			    {
			        return FR_Base.Status_OK;
			    }


				#region Verify/Create Connections
				//Create Connection if Connection is null
				if (Connection == null)
				{
					cleanupConnection = true;
					Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
					Connection.Open();
				}

				//Create Transaction if null
				if (Transaction == null)
				{
					cleanupTransaction = true;
					Transaction = Connection.BeginTransaction();
				}

				#endregion

				#region Dictionary Management

				//Save dictionary management
				 if (saveDictionary == true)
				{ 
					var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection,Transaction);
					//Save the dictionary or update based on if it has already been saved to the database
					if (Status_IsAlreadySaved)
			        {
			            loader.Update();
			        }
			        else
			        {
			            loader.Save();
			        }
				}
				#endregion

				#region Command Execution
				if (saveORMClass == true) { 
					//Retrieve Querry
					string Query = "";

					if (Status_IsAlreadySaved == true)
					{
						Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_ORD_CUO.ORD_CUO_CustomerOrderReturn_Header.SQL.Update.sql")).ReadToEnd();
					}
					else
					{
						Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_ORD_CUO.ORD_CUO_CustomerOrderReturn_Header.SQL.Insert.sql")).ReadToEnd();
					}

					DbCommand command = Connection.CreateCommand();
					command.Connection = Connection;
					command.Transaction = Transaction;
					command.CommandText = Query;
					command.CommandTimeout = QueryTimeout;

					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ORD_CUO_CustomerOrderReturn_HeaderID", _ORD_CUO_CustomerOrderReturn_HeaderID);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Customer_RefID", _Customer_RefID);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CorrespondingReceiptHeader_RefID", _CorrespondingReceiptHeader_RefID);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "DateOfCustomerReturn", _DateOfCustomerReturn);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CustomerOrderReturnNumber", _CustomerOrderReturnNumber);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Currency_RefID", _Currency_RefID);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "TotalValueBeforeTax", _TotalValueBeforeTax);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Customer_BillingAddressUCD_RefID", _Customer_BillingAddressUCD_RefID);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
					CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);


					try
					{
						var dbChangeCount = command.ExecuteNonQuery();
						Status_IsAlreadySaved = true;
						Status_IsDirty = false;
					}
					catch (Exception ex)
					{
						throw;
					}
					#endregion

					#region Cleanup Transaction/Connection
					//If we started the transaction, we will commit it
					if (cleanupTransaction && Transaction!= null)
						Transaction.Commit();

					//If we opened the connection we will close it
					if (cleanupConnection && Connection != null)
						Connection.Close();
				}
				#endregion

			}
			catch (Exception ex)
			{
				try
				{
					if (cleanupTransaction == true && Transaction != null)
						Transaction.Rollback();
				}
				catch { }

				try
				{
					if (cleanupConnection == true && Connection != null)
						Connection.Close();
				}
				catch { }

				throw;
			}

			return retStatus;
		}
Ejemplo n.º 7
0
        protected FR_Base Save(DbConnection connection, DbTransaction transaction, string connectionString)
        {
            //Standard return type
            var retStatus = new FR_Base();

            var cleanupConnection  = false;
            var cleanupTransaction = false;

            try
            {
                var saveDictionary = false;
                var saveOrmClass   = !StatusIsAlreadySaved || StatusIsDirty;

                //If Status Is Dirty (Meaning the data has been changed) or StatusIsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (!saveOrmClass && !saveDictionary)
                {
                    return(FR_Base.Status_OK);
                }

                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (connection == null)
                {
                    cleanupConnection = true;
                                        #pragma warning disable CA2000 // Dispose objects before losing scope
                    connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(connectionString);
                                        #pragma warning restore CA2000 // Dispose objects before losing scope
                    connection.Open();
                }

                //Create Transaction if null
                if (transaction == null)
                {
                    cleanupTransaction = true;
                    transaction        = connection.BeginTransaction();
                }
                #endregion

                #region Dictionary Management
                //Save dictionary management
                if (saveDictionary)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(connection, transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (StatusIsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveOrmClass)
                {
                    //Retrieve query
                    string query;

                    if (StatusIsAlreadySaved)
                    {
                                                #pragma warning disable CA2000 // Dispose objects before losing scope
                        query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_BIL.BIL_BillHeader_History.SQL.Update.sql")).ReadToEnd();
                                                #pragma warning restore CA2000 // Dispose objects before losing scope
                    }
                    else
                    {
                                                #pragma warning disable CA2000 // Dispose objects before losing scope
                        query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_BIL.BIL_BillHeader_History.SQL.Insert.sql")).ReadToEnd();
                                                #pragma warning restore CA2000 // Dispose objects before losing scope
                    }

                    var command = connection.CreateCommand();
                    command.Connection     = connection;
                    command.Transaction    = transaction;
                    command.CommandText    = query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BIL_BillHeader_HistoryID", _BIL_BillHeader_HistoryID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BillHeader_RefID", _BillHeader_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsCreated", _IsCreated);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsModified", _IsModified);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsSentToCustomer", _IsSentToCustomer);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "TriggeredBy_BusinessParticipant_RefID", _TriggeredBy_BusinessParticipant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Comment", _Comment);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Modification_Timestamp", _Modification_Timestamp);

                    command.ExecuteNonQuery();
                    StatusIsAlreadySaved = true;
                    StatusIsDirty        = false;

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction)
                    {
                        transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection)
                    {
                        connection.Close();
                    }
                    #endregion
                }
                #endregion
            }
            catch (Exception)
            {
                try
                {
                    if (cleanupTransaction)
                    {
                        transaction?.Rollback();
                    }
                }
                catch
                {
                    // ignored
                }

                try
                {
                    if (cleanupConnection)
                    {
                        connection?.Close();
                    }
                }
                catch
                {
                    // ignored
                }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 8
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG.LOG_ProductTrackingInstance.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _LOG_ProductTrackingInstanceID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LOG_ProductTrackingInstanceID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "LOG_ProductTrackingInstanceID", "TrackingInstanceTakenFromSourceTrackingInstance_RefID", "TrackingCode", "SerialNumber", "BatchNumber", "OwnedBy_BusinessParticipant_RefID", "CMN_PRO_Product_RefID", "CMN_PRO_Product_Variant_RefID", "CMN_PRO_Product_Release_RefID", "ExpirationDate", "IsDeleted", "Tenant_RefID", "InitialQuantityOnTrackingInstance", "CurrentQuantityOnTrackingInstance", "R_ReservedQuantity", "R_FreeQuantity", "Creation_Timestamp" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter LOG_ProductTrackingInstanceID of type Guid
                        _LOG_ProductTrackingInstanceID = reader.GetGuid(0);
                        //1:Parameter TrackingInstanceTakenFromSourceTrackingInstance_RefID of type Guid
                        _TrackingInstanceTakenFromSourceTrackingInstance_RefID = reader.GetGuid(1);
                        //2:Parameter TrackingCode of type String
                        _TrackingCode = reader.GetString(2);
                        //3:Parameter SerialNumber of type String
                        _SerialNumber = reader.GetString(3);
                        //4:Parameter BatchNumber of type String
                        _BatchNumber = reader.GetString(4);
                        //5:Parameter OwnedBy_BusinessParticipant_RefID of type Guid
                        _OwnedBy_BusinessParticipant_RefID = reader.GetGuid(5);
                        //6:Parameter CMN_PRO_Product_RefID of type Guid
                        _CMN_PRO_Product_RefID = reader.GetGuid(6);
                        //7:Parameter CMN_PRO_Product_Variant_RefID of type Guid
                        _CMN_PRO_Product_Variant_RefID = reader.GetGuid(7);
                        //8:Parameter CMN_PRO_Product_Release_RefID of type Guid
                        _CMN_PRO_Product_Release_RefID = reader.GetGuid(8);
                        //9:Parameter ExpirationDate of type DateTime
                        _ExpirationDate = reader.GetDate(9);
                        //10:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(10);
                        //11:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(11);
                        //12:Parameter InitialQuantityOnTrackingInstance of type double
                        _InitialQuantityOnTrackingInstance = reader.GetDouble(12);
                        //13:Parameter CurrentQuantityOnTrackingInstance of type double
                        _CurrentQuantityOnTrackingInstance = reader.GetDouble(13);
                        //14:Parameter R_ReservedQuantity of type double
                        _R_ReservedQuantity = reader.GetDouble(14);
                        //15:Parameter R_FreeQuantity of type double
                        _R_FreeQuantity = reader.GetDouble(15);
                        //16:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(16);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_LOG_ProductTrackingInstanceID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_BPT_EMP.CMN_BPT_EMP_EffectiveWorkTime_Header.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_BPT_EMP.CMN_BPT_EMP_EffectiveWorkTime_Header.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_STR_PPS_EffectiveWorkTime_HeaderID", _CMN_STR_PPS_EffectiveWorkTime_HeaderID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Employee_RefID", _Employee_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "EffectiveBusinessDay", _EffectiveBusinessDay);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SheduleBreakTemplate_RefID", _SheduleBreakTemplate_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsBreakTimeManualySpecified", _IsBreakTimeManualySpecified);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BreakDurationTime_in_sec", _BreakDurationTime_in_sec);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorktimeComment", _WorktimeComment);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ContractWorkerText", _ContractWorkerText);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 10
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG_WRH.LOG_WRH_Shelf.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _LOG_WRH_ShelfID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LOG_WRH_ShelfID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "LOG_WRH_ShelfID", "GlobalPropertyMatchingID", "Rack_RefID", "R_Warehouse_RefID", "R_Area_RefID", "Shelf_Name", "CoordinateCode", "CoordinateX", "CoordinateY", "CoordinateZ", "ShelfCapacity_Unit_RefID", "ShelfCapacity_Maximum", "R_ShelfCapacity_Free", "R_ShelfCapacity_Used", "LimitShelfContent_ToOneProduct", "LimitShelfContent_ToOneProductVariant", "LimitShelfContent_ToOneProductRelease", "IsShelfLocked", "Predefined_Product_RefID", "Predefined_Product_Variant_RefID", "Predefined_Product_Release_RefID", "Creation_Timestamp", "Tenant_RefID", "IsDeleted" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter LOG_WRH_ShelfID of type Guid
                        _LOG_WRH_ShelfID = reader.GetGuid(0);
                        //1:Parameter GlobalPropertyMatchingID of type String
                        _GlobalPropertyMatchingID = reader.GetString(1);
                        //2:Parameter Rack_RefID of type Guid
                        _Rack_RefID = reader.GetGuid(2);
                        //3:Parameter R_Warehouse_RefID of type Guid
                        _R_Warehouse_RefID = reader.GetGuid(3);
                        //4:Parameter R_Area_RefID of type Guid
                        _R_Area_RefID = reader.GetGuid(4);
                        //5:Parameter Shelf_Name of type String
                        _Shelf_Name = reader.GetString(5);
                        //6:Parameter CoordinateCode of type String
                        _CoordinateCode = reader.GetString(6);
                        //7:Parameter CoordinateX of type String
                        _CoordinateX = reader.GetString(7);
                        //8:Parameter CoordinateY of type String
                        _CoordinateY = reader.GetString(8);
                        //9:Parameter CoordinateZ of type String
                        _CoordinateZ = reader.GetString(9);
                        //10:Parameter ShelfCapacity_Unit_RefID of type Guid
                        _ShelfCapacity_Unit_RefID = reader.GetGuid(10);
                        //11:Parameter ShelfCapacity_Maximum of type decimal
                        _ShelfCapacity_Maximum = reader.GetDecimal(11);
                        //12:Parameter R_ShelfCapacity_Free of type decimal
                        _R_ShelfCapacity_Free = reader.GetDecimal(12);
                        //13:Parameter R_ShelfCapacity_Used of type decimal
                        _R_ShelfCapacity_Used = reader.GetDecimal(13);
                        //14:Parameter LimitShelfContent_ToOneProduct of type Boolean
                        _LimitShelfContent_ToOneProduct = reader.GetBoolean(14);
                        //15:Parameter LimitShelfContent_ToOneProductVariant of type Boolean
                        _LimitShelfContent_ToOneProductVariant = reader.GetBoolean(15);
                        //16:Parameter LimitShelfContent_ToOneProductRelease of type Boolean
                        _LimitShelfContent_ToOneProductRelease = reader.GetBoolean(16);
                        //17:Parameter IsShelfLocked of type Boolean
                        _IsShelfLocked = reader.GetBoolean(17);
                        //18:Parameter Predefined_Product_RefID of type Guid
                        _Predefined_Product_RefID = reader.GetGuid(18);
                        //19:Parameter Predefined_Product_Variant_RefID of type Guid
                        _Predefined_Product_Variant_RefID = reader.GetGuid(19);
                        //20:Parameter Predefined_Product_Release_RefID of type Guid
                        _Predefined_Product_Release_RefID = reader.GetGuid(20);
                        //21:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(21);
                        //22:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(22);
                        //23:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(23);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_LOG_WRH_ShelfID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Base Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5DWS_DEWTH_1126 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Base functionReturn = new FR_Base();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);


                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                Guid errorID = Guid.NewGuid();
                ServerLog.Instance.Fatal("Application error occured. ErrorID = " + errorID, ex);
                throw ex;
            }
            return(functionReturn);
        }
Ejemplo n.º 12
0
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L3EV_DSE_1353 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Base();



            P_L3EV_GSEFSE_1102 par = new P_L3EV_GSEFSE_1102();
            par.StructureEventID = Parameter.CMN_STR_SCE_StructureCalendarEventID;
            L3EV_GSEFSE_1102 sEvent = cls_Get_StructureEvent_For_StructureEventID.Invoke(Connection, Transaction, par, securityTicket).Result;


            ORM_CMN_CAL_Event whereInstanceEvent = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_CAL_Event>();
            whereInstanceEvent.CMN_CAL_EventID = sEvent.CMN_CAL_EventID;
            CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceEvent);


            if (sEvent.IsRepetitive)
            {
                ORM_CMN_CAL_Repetition whereInstanceRepetition = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_CAL_Repetition>();
                whereInstanceRepetition.CMN_CAL_RepetitionID = sEvent.CMN_CAL_RepetitionID;
                CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceRepetition);

                if (sEvent.IsDaily)
                {
                    ORM_CMN_CAL_RepetitionPatterns_Daily whereInstanceDaily = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_CAL_RepetitionPatterns_Daily>();
                    whereInstanceDaily.CMN_CAL_RepetitionPattern_DailyID = sEvent.dailyCMN_CAL_RepetitionPattern_DailyID;
                    CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceDaily);
                }
                else if (sEvent.IsWeekly)
                {
                    ORM_CMN_CAL_RepetitionPatterns_Weekly whereInstanceWeekly = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_CAL_RepetitionPatterns_Weekly>();
                    whereInstanceWeekly.CMN_CAL_RepetitionPattern_WeeklyID = sEvent.weeklyCMN_CAL_RepetitionPattern_WeeklyID;
                    CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceWeekly);
                }
                else if (sEvent.IsMonthly)
                {
                    ORM_CMN_CAL_RepetitionPatterns_Monthly whereInstanceMonthly = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_CAL_RepetitionPatterns_Monthly>();
                    whereInstanceMonthly.CMN_CAL_RepetitionPattern_MonthlyID = sEvent.monthlyCMN_CAL_RepetitionPattern_MonthlyID;
                    CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceMonthly);

                    if (sEvent.yearlyIsRelative)
                    {
                        ORM_CMN_CAL_RepetitionPatterns_Relative whereInstanceCapacityRelative = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_CAL_RepetitionPatterns_Relative>();
                        whereInstanceCapacityRelative.CMN_CAL_RepetitionPattern_RelativeID = sEvent.relativeCMN_CAL_RepetitionPattern_RelativeID;
                        CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceCapacityRelative);
                    }
                }
                else if (sEvent.IsYearly)
                {
                    ORM_CMN_CAL_RepetitionPatterns_Yearly whereInstanceYearly = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_CAL_RepetitionPatterns_Yearly>();
                    whereInstanceYearly.CMN_CAL_RepetitionPattern_YearlyID = sEvent.CMN_STR_SCE_CapacityRestrictionID;
                    CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceYearly);

                    if (sEvent.yearlyIsRelative)
                    {
                        ORM_CMN_CAL_RepetitionPatterns_Relative whereInstanceCapacityRelative = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_CAL_RepetitionPatterns_Relative>();
                        whereInstanceCapacityRelative.CMN_CAL_RepetitionPattern_RelativeID = sEvent.relativeCMN_CAL_RepetitionPattern_RelativeID;
                        CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceCapacityRelative);
                    }
                }
            }

            ORM_CMN_STR_SCE_CapacityRestriction whereInstanceCapacityRestriction = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_STR_SCE_CapacityRestriction>();
            whereInstanceCapacityRestriction.CMN_STR_SCE_CapacityRestrictionID = sEvent.CMN_STR_SCE_CapacityRestrictionID;
            CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceCapacityRestriction);


            ORM_CMN_STR_SCE_StructureCalendarEvent whereInstanceStructureCalendarEvent = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_STR_SCE_StructureCalendarEvent>();
            whereInstanceStructureCalendarEvent.CMN_STR_SCE_StructureCalendarEventID = Parameter.CMN_STR_SCE_StructureCalendarEventID;
            CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceStructureCalendarEvent);


            ORM_CMN_STR_SCE_ForbiddenLeaveType whereInstanceForbiddenLeaveType = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_STR_SCE_ForbiddenLeaveType>();
            whereInstanceForbiddenLeaveType.CMN_STR_SCE_ForbiddenLeaveTypeID = sEvent.CMN_STR_SCE_StructureCalendarEventID;
            CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstanceForbiddenLeaveType);

            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L6MRMS_FRS_1944 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Base();

            ORM_USR_Account userAccount = ORM_USR_Account.Query.Search(Connection, Transaction, new ORM_USR_Account.Query()
            {
                USR_AccountID = securityTicket.AccountID,
                IsDeleted     = false,
                Tenant_RefID  = securityTicket.TenantID
            }).FirstOrDefault();

            if (userAccount == null)
            {
                returnValue.Status       = FR_Status.Error_Internal;
                returnValue.ErrorMessage = String.Format("FinalizeReadingSession Fault: User account with id {0} not found.", securityTicket.AccountID.ToString());
                return(returnValue);
            }

            ORM_MRS_RUN_MeasurementRun measurementRun = ORM_MRS_RUN_MeasurementRun.Query.Search(Connection, Transaction, new ORM_MRS_RUN_MeasurementRun.Query()
            {
                MRS_RUN_MeasurementRunID = Parameter.ReadingSessionId,
                Tenant_RefID             = securityTicket.TenantID,
                IsDeleted = false
            }).FirstOrDefault();

            if (measurementRun == null)
            {
                returnValue.Status       = FR_Status.Error_Internal;
                returnValue.ErrorMessage = String.Format("FinalizeReadingSession Fault: Measurement run with id {0} not found.", measurementRun.MRS_RUN_MeasurementRunID.ToString());
                return(returnValue);
            }

            // Find status with global property matching id

            ORM_MRS_RUN_MeasurementRun_Status measurementRunStatus = ORM_MRS_RUN_MeasurementRun_Status.Query.Search(Connection, Transaction, new ORM_MRS_RUN_MeasurementRun_Status.Query()
            {
                GlobalPropertyMatchingID = Parameter.GlobalPropertyMatchingId,
                Tenant_RefID             = securityTicket.TenantID,
                IsDeleted = false
            }).FirstOrDefault();

            if (measurementRunStatus == null)
            {
                returnValue.Status       = FR_Status.Error_Internal;
                returnValue.ErrorMessage = String.Format("FinalizeReadingSession Fault: Measurement run status with gpmid {0} not found.", Parameter.GlobalPropertyMatchingId);
                return(returnValue);
            }

            // Create new status history
            ORM_MRS_RUN_MeasurementRun_StatusHistory measurementRunStatusHistory = new ORM_MRS_RUN_MeasurementRun_StatusHistory();
            measurementRunStatusHistory.Comment                                = "";
            measurementRunStatusHistory.Creation_Timestamp                     = DateTime.Now;
            measurementRunStatusHistory.IsDeleted                              = false;
            measurementRunStatusHistory.MeasurementRun_RefID                   = measurementRun.MRS_RUN_MeasurementRunID;
            measurementRunStatusHistory.MeasurementRun_Status_RefID            = measurementRunStatus.MRS_RUN_MeasurementRun_StatusID;
            measurementRunStatusHistory.Modification_Timestamp                 = DateTime.Now;
            measurementRunStatusHistory.MRS_RUN_MeasurementRun_StatusHistoryID = Guid.NewGuid();
            measurementRunStatusHistory.Tenant_RefID                           = securityTicket.TenantID;
            measurementRunStatusHistory.TriggeredBy_BusinessParticipant_RefID  = userAccount.BusinessParticipant_RefID;
            measurementRunStatusHistory.Save(Connection, Transaction);

            // Update measurement run status
            measurementRun.CurrentStatus_RefID = measurementRunStatus.MRS_RUN_MeasurementRun_StatusID;
            measurementRun.Save(Connection, Transaction);

            return(returnValue);

            #endregion UserCode
        }
Ejemplo n.º 14
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_PRO.CMN_PRO_SubscribedCatalog.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _CMN_PRO_SubscribedCatalogID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_SubscribedCatalogID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "CMN_PRO_SubscribedCatalogID", "CatalogCodeITL", "SubscribedCatalog_Language_RefID", "SubscribedCatalog_Currency_RefID", "SubscribedCatalog_Name", "SubscribedCatalog_Description", "SubscribedCatalog_CurrentRevision", "PublishingSupplier_RefID", "SubscribedBy_BusinessParticipant_RefID", "SubscribedCatalog_PricelistRelease_RefID", "SubscribedCatalog_ValidFrom", "SubscribedCatalog_ValidThrough", "IsCatalogValid", "IsCatalogPublic", "Creation_Timestamp", "Tenant_RefID", "IsDeleted" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter CMN_PRO_SubscribedCatalogID of type Guid
                        _CMN_PRO_SubscribedCatalogID = reader.GetGuid(0);
                        //1:Parameter CatalogCodeITL of type String
                        _CatalogCodeITL = reader.GetString(1);
                        //2:Parameter SubscribedCatalog_Language_RefID of type Guid
                        _SubscribedCatalog_Language_RefID = reader.GetGuid(2);
                        //3:Parameter SubscribedCatalog_Currency_RefID of type Guid
                        _SubscribedCatalog_Currency_RefID = reader.GetGuid(3);
                        //4:Parameter SubscribedCatalog_Name of type String
                        _SubscribedCatalog_Name = reader.GetString(4);
                        //5:Parameter SubscribedCatalog_Description of type String
                        _SubscribedCatalog_Description = reader.GetString(5);
                        //6:Parameter SubscribedCatalog_CurrentRevision of type int
                        _SubscribedCatalog_CurrentRevision = reader.GetInteger(6);
                        //7:Parameter PublishingSupplier_RefID of type Guid
                        _PublishingSupplier_RefID = reader.GetGuid(7);
                        //8:Parameter SubscribedBy_BusinessParticipant_RefID of type Guid
                        _SubscribedBy_BusinessParticipant_RefID = reader.GetGuid(8);
                        //9:Parameter SubscribedCatalog_PricelistRelease_RefID of type Guid
                        _SubscribedCatalog_PricelistRelease_RefID = reader.GetGuid(9);
                        //10:Parameter SubscribedCatalog_ValidFrom of type DateTime
                        _SubscribedCatalog_ValidFrom = reader.GetDate(10);
                        //11:Parameter SubscribedCatalog_ValidThrough of type DateTime
                        _SubscribedCatalog_ValidThrough = reader.GetDate(11);
                        //12:Parameter IsCatalogValid of type Boolean
                        _IsCatalogValid = reader.GetBoolean(12);
                        //13:Parameter IsCatalogPublic of type Boolean
                        _IsCatalogPublic = reader.GetBoolean(13);
                        //14:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(14);
                        //15:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(15);
                        //16:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(16);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_CMN_PRO_SubscribedCatalogID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 15
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_ACT.HEC_ACT_PlannedAction.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_ACT.HEC_ACT_PlannedAction.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HEC_ACT_PlannedActionID", _HEC_ACT_PlannedActionID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HealthcarePlannedActionITL", _HealthcarePlannedActionITL);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Patient_RefID", _Patient_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Appointment_RefID", _Appointment_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PlannedFor_Date", _PlannedFor_Date);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsPerformed", _IsPerformed);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IfPerformed_PerformedAction_RefID", _IfPerformed_PerformedAction_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsToBePerformedExternally", _IsToBePerformedExternally);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "MedicalPractice_RefID", _MedicalPractice_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "MedicalPracticeType_RefID", _MedicalPracticeType_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ToBePerformedBy_BusinessParticipant_RefID", _ToBePerformedBy_BusinessParticipant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsPlannedFollowup", _IsPlannedFollowup);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IfPlannedFollowup_PreviousAction_RefID", _IfPlannedFollowup_PreviousAction_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Modification_Timestamp", _Modification_Timestamp);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_BPT_EMP.CMN_BPT_EMP_EffectiveWorkTime_Header.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _CMN_STR_PPS_EffectiveWorkTime_HeaderID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_STR_PPS_EffectiveWorkTime_HeaderID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "CMN_STR_PPS_EffectiveWorkTime_HeaderID", "Employee_RefID", "EffectiveBusinessDay", "SheduleBreakTemplate_RefID", "IsBreakTimeManualySpecified", "BreakDurationTime_in_sec", "WorktimeComment", "ContractWorkerText", "Creation_Timestamp", "Tenant_RefID", "IsDeleted" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter CMN_STR_PPS_EffectiveWorkTime_HeaderID of type Guid
                        _CMN_STR_PPS_EffectiveWorkTime_HeaderID = reader.GetGuid(0);
                        //1:Parameter Employee_RefID of type Guid
                        _Employee_RefID = reader.GetGuid(1);
                        //2:Parameter EffectiveBusinessDay of type DateTime
                        _EffectiveBusinessDay = reader.GetDate(2);
                        //3:Parameter SheduleBreakTemplate_RefID of type Guid
                        _SheduleBreakTemplate_RefID = reader.GetGuid(3);
                        //4:Parameter IsBreakTimeManualySpecified of type Boolean
                        _IsBreakTimeManualySpecified = reader.GetBoolean(4);
                        //5:Parameter BreakDurationTime_in_sec of type int
                        _BreakDurationTime_in_sec = reader.GetInteger(5);
                        //6:Parameter WorktimeComment of type String
                        _WorktimeComment = reader.GetString(6);
                        //7:Parameter ContractWorkerText of type String
                        _ContractWorkerText = reader.GetString(7);
                        //8:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(8);
                        //9:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(9);
                        //10:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(10);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_CMN_STR_PPS_EffectiveWorkTime_HeaderID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 17
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5WA_SWA_1545 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Base();
            //Put your code here

            var item = new ORM_CMN_STR_PPS_WorkArea();
            if (Parameter.CMN_STR_PPS_WorkAreaID != Guid.Empty)
            {
                var result = item.Load(Connection, Transaction, Parameter.CMN_STR_PPS_WorkAreaID);
                if (result.Status != FR_Status.Success || item.CMN_STR_PPS_WorkAreaID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }

            item.Default_StartWorkingHour = 0;
            if (Parameter.WorkAreaDescription != null)
            {
                item.Description = Parameter.WorkAreaDescription;
            }
            else
            {
                item.Description = new Dict();
                item.Description.DictionaryID = Guid.NewGuid();
            }
            item.Name         = Parameter.WorkAreaName;
            item.ShortName    = Parameter.ShortName;
            item.Parent_RefID = Parameter.Parent_RefID;
            item.Tenant_RefID = securityTicket.TenantID;
            item.Office_RefID = Parameter.Office_RefID;
            item.CMN_CAL_CalendarInstance_RefID = Parameter.CMN_CAL_CalendarInstance_RefID;

            ORM_CMN_STR_PPS_WorkArea_2_CostCenter whereCC2WAInstance = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_STR_PPS_WorkArea_2_CostCenter>();
            whereCC2WAInstance.WorkArea_RefID = item.CMN_STR_PPS_WorkAreaID;
            CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereCC2WAInstance);
            if (Parameter.Costcenter_RefID != null)
            {
                var cc2wa = new ORM_CMN_STR_PPS_WorkArea_2_CostCenter();
                cc2wa.CostCenter_RefID = Parameter.Costcenter_RefID;
                cc2wa.IsDeleted        = false;
                cc2wa.Tenant_RefID     = securityTicket.TenantID;
                cc2wa.WorkArea_RefID   = item.CMN_STR_PPS_WorkAreaID;
                cc2wa.Save(Connection, Transaction);
            }

            ORM_CMN_CAL_CalendarInstance calendar = new ORM_CMN_CAL_CalendarInstance();
            if (Parameter.CMN_CAL_CalendarInstance_RefID != Guid.Empty)
            {
                var result = calendar.Load(Connection, Transaction, Parameter.CMN_CAL_CalendarInstance_RefID);
                if (result.Status != FR_Status.Success || calendar.CMN_CAL_CalendarInstanceID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }
            calendar.WeekStartsOnDay = 1;
            calendar.Save(Connection, Transaction);
            item.CMN_CAL_CalendarInstance_RefID = calendar.CMN_CAL_CalendarInstanceID;
            item.Save(Connection, Transaction);

            ORM_CMN_STR_PPS_WorkArea_ResponsiblePerson whereInstance = CSV2Core_MySQL.Support.SQLClassFilter.GetDefaultInstance <ORM_CMN_STR_PPS_WorkArea_ResponsiblePerson>();
            whereInstance.WorkArea_RefID = item.CMN_STR_PPS_WorkAreaID;
            CSV2Core_MySQL.Support.SQLClassFilter.Delete(Connection, Transaction, whereInstance);
            if (Parameter.ResponsiblePersons != null && Parameter.ResponsiblePersons.Length > 0)
            {
                foreach (P_L5WA_SWA_1545_ResponsiblePersons obj in Parameter.ResponsiblePersons)
                {
                    ORM_CMN_STR_PPS_WorkArea_ResponsiblePerson person = new ORM_CMN_STR_PPS_WorkArea_ResponsiblePerson();
                    if (obj.CMN_STR_PPS_WorkArea_ResponsiblePersonID != Guid.Empty)
                    {
                        var result = calendar.Load(Connection, Transaction, obj.CMN_STR_PPS_WorkArea_ResponsiblePersonID);
                        if (result.Status != FR_Status.Success || person.CMN_STR_PPS_WorkArea_ResponsiblePersonID == Guid.Empty)
                        {
                            var error = new FR_Guid();
                            error.ErrorMessage = "No Such ID";
                            error.Status       = FR_Status.Error_Internal;
                            return(error);
                        }
                    }
                    if (obj.CMN_STR_PPS_WorkArea_ResponsiblePersonID != Guid.Empty)
                    {
                        person.IsDeleted = true;
                    }
                    else
                    {
                        person.CMN_BPT_EMP_Employee_RefID = obj.CMN_BPT_EMP_EmployeeID;
                        person.WorkArea_RefID             = item.CMN_STR_PPS_WorkAreaID;
                        person.Tenant_RefID = securityTicket.TenantID;
                    }

                    person.Save(Connection, Transaction);
                }
            }

            return(new FR_Guid(item.CMN_STR_PPS_WorkAreaID));

            #endregion UserCode
        }
Ejemplo n.º 18
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_COM.CMN_COM_CompanyInfo.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _CMN_COM_CompanyInfoID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_COM_CompanyInfoID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "CMN_COM_CompanyInfoID", "CompanyLogo_Document_RefID", "Contact_UCD_RefID", "CompanyType_RefID", "NumberOfEmployees", "CompanyInfo_EstablishmentNumber", "AnnualRevenueAmountValue_RefID", "VATIdentificationNumber", "Creation_Timestamp", "IsDeleted", "Tenant_RefID" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter CMN_COM_CompanyInfoID of type Guid
                        _CMN_COM_CompanyInfoID = reader.GetGuid(0);
                        //1:Parameter CompanyLogo_Document_RefID of type Guid
                        _CompanyLogo_Document_RefID = reader.GetGuid(1);
                        //2:Parameter Contact_UCD_RefID of type Guid
                        _Contact_UCD_RefID = reader.GetGuid(2);
                        //3:Parameter CompanyType_RefID of type Guid
                        _CompanyType_RefID = reader.GetGuid(3);
                        //4:Parameter NumberOfEmployees of type long
                        _NumberOfEmployees = reader.GetLong(4);
                        //5:Parameter CompanyInfo_EstablishmentNumber of type String
                        _CompanyInfo_EstablishmentNumber = reader.GetString(5);
                        //6:Parameter AnnualRevenueAmountValue_RefID of type Guid
                        _AnnualRevenueAmountValue_RefID = reader.GetGuid(6);
                        //7:Parameter VATIdentificationNumber of type String
                        _VATIdentificationNumber = reader.GetString(7);
                        //8:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(8);
                        //9:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(9);
                        //10:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(10);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_CMN_COM_CompanyInfoID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
		private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
		{
			//Standard return type
			FR_Base retStatus = new FR_Base();

			bool cleanupConnection = false;
			bool cleanupTransaction = false;
			try
			{
				#region Verify/Create Connections
				//Create connection if Connection is null
				if(Connection == null)
				{
					cleanupConnection = true;
					Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
					Connection.Open();
				}
				//If transaction is not open/not valid
				if(Transaction == null)
				{
					cleanupTransaction = true;
					Transaction = Connection.BeginTransaction();
				}
				#endregion
				//Get the SelectQuerry
				string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_ORD_CUO.ORD_CUO_CustomerOrderReturn_Header.SQL.Select.sql")).ReadToEnd();

				DbCommand command = Connection.CreateCommand();
				//Set Connection/Transaction
				command.Connection = Connection;
				command.Transaction = Transaction;
				//Set Query/Timeout
				command.CommandText =  SelectQuery;
				command.CommandTimeout = QueryTimeout;

				//Firstly, before loading, set the GUID to empty
				//So the entity does not exist, it will have a GUID set to empty
				_ORD_CUO_CustomerOrderReturn_HeaderID = Guid.Empty;
				CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command,"ORD_CUO_CustomerOrderReturn_HeaderID", ObjectID );

				#region Command Execution
				try
				{
					var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection,Transaction);
					var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
					reader.SetOrdinals(new string[] { "ORD_CUO_CustomerOrderReturn_HeaderID","Customer_RefID","CorrespondingReceiptHeader_RefID","DateOfCustomerReturn","CustomerOrderReturnNumber","Currency_RefID","TotalValueBeforeTax","Customer_BillingAddressUCD_RefID","Creation_Timestamp","Tenant_RefID","IsDeleted" });
					if (reader.HasRows == true)
					{
						reader.Read(); //Single result only
						//0:Parameter ORD_CUO_CustomerOrderReturn_HeaderID of type Guid
						_ORD_CUO_CustomerOrderReturn_HeaderID = reader.GetGuid(0);
						//1:Parameter Customer_RefID of type Guid
						_Customer_RefID = reader.GetGuid(1);
						//2:Parameter CorrespondingReceiptHeader_RefID of type Guid
						_CorrespondingReceiptHeader_RefID = reader.GetGuid(2);
						//3:Parameter DateOfCustomerReturn of type DateTime
						_DateOfCustomerReturn = reader.GetDate(3);
						//4:Parameter CustomerOrderReturnNumber of type String
						_CustomerOrderReturnNumber = reader.GetString(4);
						//5:Parameter Currency_RefID of type Guid
						_Currency_RefID = reader.GetGuid(5);
						//6:Parameter TotalValueBeforeTax of type Decimal
						_TotalValueBeforeTax = reader.GetDecimal(6);
						//7:Parameter Customer_BillingAddressUCD_RefID of type Guid
						_Customer_BillingAddressUCD_RefID = reader.GetGuid(7);
						//8:Parameter Creation_Timestamp of type DateTime
						_Creation_Timestamp = reader.GetDate(8);
						//9:Parameter Tenant_RefID of type Guid
						_Tenant_RefID = reader.GetGuid(9);
						//10:Parameter IsDeleted of type Boolean
						_IsDeleted = reader.GetBoolean(10);

					}
					//Close the reader so other connections can use it
					reader.Close();

					loader.Load();

					if(_ORD_CUO_CustomerOrderReturn_HeaderID != Guid.Empty){
						//Successfully loaded
						Status_IsAlreadySaved = true;
						Status_IsDirty = false;
					} else {
						//Fault in loading due to invalid UUID (Guid)
						Status_IsAlreadySaved = false;
						Status_IsDirty = false;
					}
				}
				catch (Exception ex)
				{
					throw;
				}
				#endregion

				#region Cleanup Transaction/Connection
				//If we started the transaction, we will commit it
				if (cleanupTransaction && Transaction!= null)
					Transaction.Commit();

				//If we opened the connection we will close it
				if (cleanupConnection && Connection != null)
					Connection.Close();

				#endregion

			} catch (Exception ex) {
				try
				{
					if (cleanupTransaction == true && Transaction != null)
						Transaction.Rollback();
				}
				catch { }

				try
				{
					if (cleanupConnection == true && Connection != null)
						Connection.Close();
				}
				catch { }

				throw;
			}

			return retStatus;
		}
Ejemplo n.º 20
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = !Status_IsAlreadySaved || Component_Name.IsDirty || Component_Description.IsDirty;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    loader.Append(Component_Name, TableName);
                    loader.Append(Component_Description, TableName);

                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_PRO.HEC_PRO_Component.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_PRO.HEC_PRO_Component.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HEC_PRO_ComponentID", _HEC_PRO_ComponentID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GlobalPropertyMatchingID", _GlobalPropertyMatchingID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ComponentMatterState", _ComponentMatterState);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "AbsoluteCompositionValue_Unit_RefID", _AbsoluteCompositionValue_Unit_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "AbsoluteCompositionValue", _AbsoluteCompositionValue);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RelativeCompositionValue_Unit_RefID", _RelativeCompositionValue_Unit_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RelativeCompositionValue", _RelativeCompositionValue);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BreadUnitContainedAmount", _BreadUnitContainedAmount);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "EthanolContained_VolumePercentage", _EthanolContained_VolumePercentage);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ComponentEneryValue_in_kJ", _ComponentEneryValue_in_kJ);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Component_SimpleName", _Component_SimpleName);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Component_Name", _Component_Name.DictionaryID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Component_Description", _Component_Description.DictionaryID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ComponentDisposalSpeedStatus", _ComponentDisposalSpeedStatus);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GalenicalTypeInsidePackageStatus", _GalenicalTypeInsidePackageStatus);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ComponentExcipientStatus", _ComponentExcipientStatus);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GalenicalType_RelativeComposition", _GalenicalType_RelativeComposition);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Modification_Timestamp", _Modification_Timestamp);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
Ejemplo n.º 21
0
        private FR_Base Load(DbConnection connection, DbTransaction transaction, Guid objectId, string connectionString)
        {
            //Standard return type
            var retStatus = new FR_Base();

            var cleanupConnection  = false;
            var cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (connection == null)
                {
                    cleanupConnection = true;
                    connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(connectionString);
                    connection.Open();
                }
                //If transaction is not open/not valid
                if (transaction == null)
                {
                    cleanupTransaction = true;
                    transaction        = connection.BeginTransaction();
                }
                #endregion

                //Get the Select query
                                #pragma warning disable CA2000 // Dispose objects before losing scope
                var selectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_BIL.BIL_BillHeader_History.SQL.Select.sql")).ReadToEnd();
                                #pragma warning restore CA2000 // Dispose objects before losing scope

                var command = connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = connection;
                command.Transaction = transaction;
                //Set Query/Timeout
                command.CommandText    = selectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _BIL_BillHeader_HistoryID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BIL_BillHeader_HistoryID", objectId);

                #region Command Execution
                var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(connection, transaction);
                var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                reader.SetOrdinals(new[] { "BIL_BillHeader_HistoryID", "BillHeader_RefID", "IsCreated", "IsModified", "IsSentToCustomer", "TriggeredBy_BusinessParticipant_RefID", "Comment", "Creation_Timestamp", "Tenant_RefID", "IsDeleted", "Modification_Timestamp" });
                if (reader.HasRows)
                {
                    reader.Read();                     //Single result only
                    //0:Parameter BIL_BillHeader_HistoryID of type Guid
                    _BIL_BillHeader_HistoryID = reader.GetGuid(0);
                    //1:Parameter BillHeader_RefID of type Guid
                    _BillHeader_RefID = reader.GetGuid(1);
                    //2:Parameter IsCreated of type Boolean
                    _IsCreated = reader.GetBoolean(2);
                    //3:Parameter IsModified of type Boolean
                    _IsModified = reader.GetBoolean(3);
                    //4:Parameter IsSentToCustomer of type Boolean
                    _IsSentToCustomer = reader.GetBoolean(4);
                    //5:Parameter TriggeredBy_BusinessParticipant_RefID of type Guid
                    _TriggeredBy_BusinessParticipant_RefID = reader.GetGuid(5);
                    //6:Parameter Comment of type String
                    _Comment = reader.GetString(6);
                    //7:Parameter Creation_Timestamp of type DateTime
                    _Creation_Timestamp = reader.GetDate(7);
                    //8:Parameter Tenant_RefID of type Guid
                    _Tenant_RefID = reader.GetGuid(8);
                    //9:Parameter IsDeleted of type Boolean
                    _IsDeleted = reader.GetBoolean(9);
                    //10:Parameter Modification_Timestamp of type DateTime
                    _Modification_Timestamp = reader.GetDate(10);
                }
                //Close the reader so other connections can use it
                reader.Close();

                loader.Load();

                if (_BIL_BillHeader_HistoryID != Guid.Empty)
                {
                    //Successfully loaded
                    StatusIsAlreadySaved = true;
                    StatusIsDirty        = false;
                }
                else
                {
                    //Fault in loading due to invalid UUID (Guid)
                    StatusIsAlreadySaved = false;
                    StatusIsDirty        = false;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction)
                {
                    transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection)
                {
                    connection.Close();
                }
                #endregion
            }
            catch (Exception)
            {
                try
                {
                    if (cleanupTransaction)
                    {
                        transaction?.Rollback();
                    }
                }
                catch
                {
                    // ignored
                }

                try
                {
                    if (cleanupConnection)
                    {
                        connection?.Close();
                    }
                }
                catch
                {
                    // ignored
                }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 22
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_PRO.HEC_PRO_Component.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _HEC_PRO_ComponentID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HEC_PRO_ComponentID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "HEC_PRO_ComponentID", "GlobalPropertyMatchingID", "ComponentMatterState", "AbsoluteCompositionValue_Unit_RefID", "AbsoluteCompositionValue", "RelativeCompositionValue_Unit_RefID", "RelativeCompositionValue", "BreadUnitContainedAmount", "EthanolContained_VolumePercentage", "ComponentEneryValue_in_kJ", "Component_SimpleName", "Component_Name_DictID", "Component_Description_DictID", "ComponentDisposalSpeedStatus", "GalenicalTypeInsidePackageStatus", "ComponentExcipientStatus", "GalenicalType_RelativeComposition", "Creation_Timestamp", "Tenant_RefID", "IsDeleted", "Modification_Timestamp" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter HEC_PRO_ComponentID of type Guid
                        _HEC_PRO_ComponentID = reader.GetGuid(0);
                        //1:Parameter GlobalPropertyMatchingID of type String
                        _GlobalPropertyMatchingID = reader.GetString(1);
                        //2:Parameter ComponentMatterState of type int
                        _ComponentMatterState = reader.GetInteger(2);
                        //3:Parameter AbsoluteCompositionValue_Unit_RefID of type Guid
                        _AbsoluteCompositionValue_Unit_RefID = reader.GetGuid(3);
                        //4:Parameter AbsoluteCompositionValue of type Double
                        _AbsoluteCompositionValue = reader.GetDouble(4);
                        //5:Parameter RelativeCompositionValue_Unit_RefID of type Guid
                        _RelativeCompositionValue_Unit_RefID = reader.GetGuid(5);
                        //6:Parameter RelativeCompositionValue of type Double
                        _RelativeCompositionValue = reader.GetDouble(6);
                        //7:Parameter BreadUnitContainedAmount of type Double
                        _BreadUnitContainedAmount = reader.GetDouble(7);
                        //8:Parameter EthanolContained_VolumePercentage of type Double
                        _EthanolContained_VolumePercentage = reader.GetDouble(8);
                        //9:Parameter ComponentEneryValue_in_kJ of type Double
                        _ComponentEneryValue_in_kJ = reader.GetDouble(9);
                        //10:Parameter Component_SimpleName of type String
                        _Component_SimpleName = reader.GetString(10);
                        //11:Parameter Component_Name of type Dict
                        _Component_Name = reader.GetDictionary(11);
                        loader.Append(_Component_Name, TableName);
                        //12:Parameter Component_Description of type Dict
                        _Component_Description = reader.GetDictionary(12);
                        loader.Append(_Component_Description, TableName);
                        //13:Parameter ComponentDisposalSpeedStatus of type int
                        _ComponentDisposalSpeedStatus = reader.GetInteger(13);
                        //14:Parameter GalenicalTypeInsidePackageStatus of type int
                        _GalenicalTypeInsidePackageStatus = reader.GetInteger(14);
                        //15:Parameter ComponentExcipientStatus of type int
                        _ComponentExcipientStatus = reader.GetInteger(15);
                        //16:Parameter GalenicalType_RelativeComposition of type String
                        _GalenicalType_RelativeComposition = reader.GetString(16);
                        //17:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(17);
                        //18:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(18);
                        //19:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(19);
                        //20:Parameter Modification_Timestamp of type DateTime
                        _Modification_Timestamp = reader.GetDate(20);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_HEC_PRO_ComponentID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
Ejemplo n.º 23
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG_WRH.LOG_WRH_Area.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG_WRH.LOG_WRH_Area.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LOG_WRH_AreaID", _LOG_WRH_AreaID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GlobalPropertyMatchingID", _GlobalPropertyMatchingID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CoordinateCode", _CoordinateCode);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Area_Name", _Area_Name);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Warehouse_RefID", _Warehouse_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsStructureHidden", _IsStructureHidden);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsConsignmentArea", _IsConsignmentArea);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IfConsignmentArea_DefaultOwningSupplier_RefID", _IfConsignmentArea_DefaultOwningSupplier_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Rack_NamePrefix", _Rack_NamePrefix);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsPointOfSalesArea", _IsPointOfSalesArea);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsLongTermStorageArea", _IsLongTermStorageArea);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsCrossDockArea", _IsCrossDockArea);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDefaultIntakeArea", _IsDefaultIntakeArea);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 24
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region VerifySessionToken/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC.HEC_Patient_Prescription_Transaction.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC.HEC_Patient_Prescription_Transaction.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HEC_Patient_Prescription_TransactionID", _HEC_Patient_Prescription_TransactionID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PerscriptionTransaction_DeliveryAddress_RefID", _PerscriptionTransaction_DeliveryAddress_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_Patient_RefID", _PrescriptionTransaction_Patient_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_InternalNubmer", _PrescriptionTransaction_InternalNubmer);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_IsComplete", _PrescriptionTransaction_IsComplete);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_RequestedDateOfDeliveryFrom", _PrescriptionTransaction_RequestedDateOfDeliveryFrom);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_RequestedDateOfDeliveryTo", _PrescriptionTransaction_RequestedDateOfDeliveryTo);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_CreatedByBusinessParticpant_RefID", _PrescriptionTransaction_CreatedByBusinessParticpant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_Comment", _PrescriptionTransaction_Comment);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_UsePatientAddress", _PrescriptionTransaction_UsePatientAddress);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_UseReceiptAddress", _PrescriptionTransaction_UseReceiptAddress);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PrescriptionTransaction_UseParticipationPolicyAddress", _PrescriptionTransaction_UseParticipationPolicyAddress);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
Ejemplo n.º 25
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = !Status_IsAlreadySaved || Office_Name.IsDirty || Office_Description.IsDirty;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    loader.Append(Office_Name, TableName);
                    loader.Append(Office_Description, TableName);

                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_STR.CMN_STR_Office.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_STR.CMN_STR_Office.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_STR_OfficeID", _CMN_STR_OfficeID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "OfficeITL", _OfficeITL);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Parent_RefID", _Parent_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Country_RefID", _Country_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Region_RefID", _Region_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Default_BillingAddress_RefID", _Default_BillingAddress_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Default_ShippingAddress_RefID", _Default_ShippingAddress_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_CAL_CalendarInstance_RefID", _CMN_CAL_CalendarInstance_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Default_PhoneNumber", _Default_PhoneNumber);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Default_FaxNumber", _Default_FaxNumber);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Default_Website", _Default_Website);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Default_Email", _Default_Email);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Office_Name", _Office_Name.DictionaryID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Office_Description", _Office_Description.DictionaryID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Office_ShortName", _Office_ShortName);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsMockObject", _IsMockObject);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Office_InternalName", _Office_InternalName);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Office_InternalNumber", _Office_InternalNumber);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Comment", _Comment);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "DisplayImage_Document_RefID", _DisplayImage_Document_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsMedicalPractice", _IsMedicalPractice);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IfMedicalPractise_HEC_MedicalPractice_RefID", _IfMedicalPractise_HEC_MedicalPractice_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Modification_Timestamp", _Modification_Timestamp);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 26
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_RES_BLD.RES_BLD_Building.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_RES_BLD.RES_BLD_Building.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RES_BLD_BuildingID", _RES_BLD_BuildingID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_CurrentAverageRentPrice_per_sqm_RefID", _Building_CurrentAverageRentPrice_per_sqm_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BuildingRevisionHeader_RefID", _BuildingRevisionHeader_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_BalconyPortionPercent", _Building_BalconyPortionPercent);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_Name", _Building_Name);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_DocumentationStructure_RefID", _Building_DocumentationStructure_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsContaminationSuspected", _IsContaminationSuspected);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfFloors", _Building_NumberOfFloors);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_ElevatorCoveragePercent", _Building_ElevatorCoveragePercent);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfAppartments", _Building_NumberOfAppartments);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfOccupiedAppartments", _Building_NumberOfOccupiedAppartments);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfOffices", _Building_NumberOfOffices);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfRetailUnits", _Building_NumberOfRetailUnits);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfProductionUnits", _Building_NumberOfProductionUnits);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfOtherUnits", _Building_NumberOfOtherUnits);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_ACT.HEC_ACT_PerformedAction_Procedure.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _HEC_ACT_PerformedAction_ProcedureID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HEC_ACT_PerformedAction_ProcedureID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "HEC_ACT_PerformedAction_ProcedureID", "ActionProcedureITL", "HEC_ACT_PerformedAction_RefID", "PotentialProcedure_RefID", "PotentialProcedure_Name", "PotentialProcedure_Code", "PotentialProcedure_Localization_RefID", "PotentialProcedure_Localization_Name", "PotentialProcedure_Localization_Code", "Creation_Timestamp", "Tenant_RefID", "IsDeleted", "Modification_Timestamp" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter HEC_ACT_PerformedAction_ProcedureID of type Guid
                        _HEC_ACT_PerformedAction_ProcedureID = reader.GetGuid(0);
                        //1:Parameter ActionProcedureITL of type String
                        _ActionProcedureITL = reader.GetString(1);
                        //2:Parameter HEC_ACT_PerformedAction_RefID of type Guid
                        _HEC_ACT_PerformedAction_RefID = reader.GetGuid(2);
                        //3:Parameter PotentialProcedure_RefID of type Guid
                        _PotentialProcedure_RefID = reader.GetGuid(3);
                        //4:Parameter PotentialProcedure_Name of type String
                        _PotentialProcedure_Name = reader.GetString(4);
                        //5:Parameter PotentialProcedure_Code of type String
                        _PotentialProcedure_Code = reader.GetString(5);
                        //6:Parameter PotentialProcedure_Localization_RefID of type Guid
                        _PotentialProcedure_Localization_RefID = reader.GetGuid(6);
                        //7:Parameter PotentialProcedure_Localization_Name of type String
                        _PotentialProcedure_Localization_Name = reader.GetString(7);
                        //8:Parameter PotentialProcedure_Localization_Code of type String
                        _PotentialProcedure_Localization_Code = reader.GetString(8);
                        //9:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(9);
                        //10:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(10);
                        //11:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(11);
                        //12:Parameter Modification_Timestamp of type DateTime
                        _Modification_Timestamp = reader.GetDate(12);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_HEC_ACT_PerformedAction_ProcedureID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
Ejemplo n.º 28
0
        private FR_Base Load(DbConnection Connection, DbTransaction Transaction, Guid ObjectID, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                #region Verify/Create Connections
                //Create connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                //If transaction is not open/not valid
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }
                #endregion
                //Get the SelectQuerry
                string SelectQuery = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_RES_BLD.RES_BLD_Building.SQL.Select.sql")).ReadToEnd();

                DbCommand command = Connection.CreateCommand();
                //Set Connection/Transaction
                command.Connection  = Connection;
                command.Transaction = Transaction;
                //Set Query/Timeout
                command.CommandText    = SelectQuery;
                command.CommandTimeout = QueryTimeout;

                //Firstly, before loading, set the GUID to empty
                //So the entity does not exist, it will have a GUID set to empty
                _RES_BLD_BuildingID = Guid.Empty;
                CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RES_BLD_BuildingID", ObjectID);

                #region Command Execution
                try
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());
                    reader.SetOrdinals(new string[] { "RES_BLD_BuildingID", "Building_CurrentAverageRentPrice_per_sqm_RefID", "BuildingRevisionHeader_RefID", "Building_BalconyPortionPercent", "Building_Name", "Building_DocumentationStructure_RefID", "IsContaminationSuspected", "Building_NumberOfFloors", "Building_ElevatorCoveragePercent", "Building_NumberOfAppartments", "Building_NumberOfOccupiedAppartments", "Building_NumberOfOffices", "Building_NumberOfRetailUnits", "Building_NumberOfProductionUnits", "Building_NumberOfOtherUnits", "Creation_Timestamp", "IsDeleted", "Tenant_RefID" });
                    if (reader.HasRows == true)
                    {
                        reader.Read();                         //Single result only
                        //0:Parameter RES_BLD_BuildingID of type Guid
                        _RES_BLD_BuildingID = reader.GetGuid(0);
                        //1:Parameter Building_CurrentAverageRentPrice_per_sqm_RefID of type Guid
                        _Building_CurrentAverageRentPrice_per_sqm_RefID = reader.GetGuid(1);
                        //2:Parameter BuildingRevisionHeader_RefID of type Guid
                        _BuildingRevisionHeader_RefID = reader.GetGuid(2);
                        //3:Parameter Building_BalconyPortionPercent of type double
                        _Building_BalconyPortionPercent = reader.GetDouble(3);
                        //4:Parameter Building_Name of type String
                        _Building_Name = reader.GetString(4);
                        //5:Parameter Building_DocumentationStructure_RefID of type Guid
                        _Building_DocumentationStructure_RefID = reader.GetGuid(5);
                        //6:Parameter IsContaminationSuspected of type Boolean
                        _IsContaminationSuspected = reader.GetBoolean(6);
                        //7:Parameter Building_NumberOfFloors of type int
                        _Building_NumberOfFloors = reader.GetInteger(7);
                        //8:Parameter Building_ElevatorCoveragePercent of type double
                        _Building_ElevatorCoveragePercent = reader.GetDouble(8);
                        //9:Parameter Building_NumberOfAppartments of type int
                        _Building_NumberOfAppartments = reader.GetInteger(9);
                        //10:Parameter Building_NumberOfOccupiedAppartments of type int
                        _Building_NumberOfOccupiedAppartments = reader.GetInteger(10);
                        //11:Parameter Building_NumberOfOffices of type int
                        _Building_NumberOfOffices = reader.GetInteger(11);
                        //12:Parameter Building_NumberOfRetailUnits of type int
                        _Building_NumberOfRetailUnits = reader.GetInteger(12);
                        //13:Parameter Building_NumberOfProductionUnits of type int
                        _Building_NumberOfProductionUnits = reader.GetInteger(13);
                        //14:Parameter Building_NumberOfOtherUnits of type int
                        _Building_NumberOfOtherUnits = reader.GetInteger(14);
                        //15:Parameter Creation_Timestamp of type DateTime
                        _Creation_Timestamp = reader.GetDate(15);
                        //16:Parameter IsDeleted of type Boolean
                        _IsDeleted = reader.GetBoolean(16);
                        //17:Parameter Tenant_RefID of type Guid
                        _Tenant_RefID = reader.GetGuid(17);
                    }
                    //Close the reader so other connections can use it
                    reader.Close();

                    loader.Load();

                    if (_RES_BLD_BuildingID != Guid.Empty)
                    {
                        //Successfully loaded
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    else
                    {
                        //Fault in loading due to invalid UUID (Guid)
                        Status_IsAlreadySaved = false;
                        Status_IsDirty        = false;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion

                #region Cleanup Transaction/Connection
                //If we started the transaction, we will commit it
                if (cleanupTransaction && Transaction != null)
                {
                    Transaction.Commit();
                }

                //If we opened the connection we will close it
                if (cleanupConnection && Connection != null)
                {
                    Connection.Close();
                }

                #endregion
            } catch (Exception ex) {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_PRO_PRC.CMN_PRO_PRC_General_AverageProcurementPrice.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_PRO_PRC.CMN_PRO_PRC_General_AverageProcurementPrice.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_PRC_General_AverageProcurementPricesID", _CMN_PRO_PRC_General_AverageProcurementPricesID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CurrentAverageProcurement_Price_RefID", _CurrentAverageProcurement_Price_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Product_RefID", _Product_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Product_Variant_RefID", _Product_Variant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsCurrentAveragePrice", _IsCurrentAveragePrice);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Modification_Timestamp", _Modification_Timestamp);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L3C_SCaM_1612 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Base();
            //Put your code here

            // check if there is mentions for saving
            if (Parameter.Mentions != null)
            {
                #region Save comment

                ORM_TMS_PRO_Comment comment = new ORM_TMS_PRO_Comment();

                comment.TMS_PRO_CommentID = Guid.NewGuid();
                comment.Comment_BoundTo_BusinessTask_RefID  = Parameter.Comment_BoundTo_BusinessTask_RefID;
                comment.Comment_BoundTo_DeveloperTask_RefID = Parameter.Comment_BoundTo_DeveloperTask_RefID;
                comment.Comment_BoundTo_Feature_RefID       = Parameter.Comment_BoundTo_Feature_RefID;
                comment.Comment_BoundTo_Project_RefID       = Parameter.Comment_BoundTo_Project_RefID;
                comment.Comment_CreatedByAccount_RefID      = Parameter.Comment_CreatedByAccount_RefID;
                comment.Comment_Quoatation_RefID            = Parameter.Comment_Quoatation_RefID;
                comment.Comment_Quotation_Text         = Parameter.Comment_Quotation_Text;
                comment.Comment_TextContent            = Parameter.Comment_TextContent;
                comment.Creation_Timestamp             = DateTime.Now;
                comment.Tenant_RefID                   = securityTicket.TenantID;
                comment.IsComment_BoundToDeveloperTask = Parameter.Comment_BoundTo_DeveloperTask_RefID != Guid.Empty;
                comment.IsComment_BoundToBusinessTask  = Parameter.Comment_BoundTo_BusinessTask_RefID != Guid.Empty;
                comment.IsComment_BoundToFeature       = Parameter.Comment_BoundTo_Feature_RefID != Guid.Empty;

                comment.Save(Connection, Transaction);

                #endregion

                #region Save mention/s

                foreach (var item in Parameter.Mentions)
                {
                    ORM_TMS_PRO_Comment_Mention mention = new ORM_TMS_PRO_Comment_Mention();

                    mention.TMS_PRO_Comment_MentionID   = Guid.NewGuid();
                    mention.Comment_RefID               = comment.TMS_PRO_CommentID;
                    mention.IsMentionFor_Account        = item.Mention_Account_RefID != Guid.Empty;
                    mention.IsMentionFor_BusinessTask   = item.Mention_BusinessTask_RefID != Guid.Empty;
                    mention.IsMentionFor_Feature        = item.Mention_Feature_RefID != Guid.Empty;
                    mention.IsMentionFor_DeveloperTask  = item.Mention_DeveloperTask_RefID != Guid.Empty;
                    mention.Mention_Account_RefID       = item.Mention_Account_RefID;
                    mention.Mention_BusinessTask_RefID  = item.Mention_BusinessTask_RefID;
                    mention.Mention_Feature_RefID       = item.Mention_Feature_RefID;
                    mention.Mention_DeveloperTask_RefID = item.Mention_DeveloperTask_RefID;
                    mention.CommentMention_Position     = item.CommentMention_Position;
                    mention.R_CommentMention_Text       = item.R_CommentMention_Text;
                    mention.Creation_Timestamp          = DateTime.Now;
                    mention.Tenant_RefID = securityTicket.TenantID;

                    mention.Save(Connection, Transaction);
                }

                #endregion
            }

            else

            {
                #region Save comment without mention


                ORM_TMS_PRO_Comment comment = new ORM_TMS_PRO_Comment();

                comment.TMS_PRO_CommentID = Guid.NewGuid();
                comment.Comment_BoundTo_BusinessTask_RefID  = Parameter.Comment_BoundTo_BusinessTask_RefID;
                comment.Comment_BoundTo_DeveloperTask_RefID = Parameter.Comment_BoundTo_DeveloperTask_RefID;
                comment.Comment_BoundTo_Feature_RefID       = Parameter.Comment_BoundTo_Feature_RefID;
                comment.Comment_BoundTo_Project_RefID       = Parameter.Comment_BoundTo_Project_RefID;
                comment.Comment_CreatedByAccount_RefID      = Parameter.Comment_CreatedByAccount_RefID;
                comment.Comment_Quoatation_RefID            = Parameter.Comment_Quoatation_RefID;
                comment.Comment_Quotation_Text         = Parameter.Comment_Quotation_Text;
                comment.Comment_TextContent            = Parameter.Comment_TextContent;
                comment.Creation_Timestamp             = DateTime.Now;
                comment.Tenant_RefID                   = securityTicket.TenantID;
                comment.IsComment_BoundToDeveloperTask = Parameter.Comment_BoundTo_DeveloperTask_RefID != Guid.Empty;
                comment.IsComment_BoundToBusinessTask  = Parameter.Comment_BoundTo_BusinessTask_RefID != Guid.Empty;
                comment.IsComment_BoundToFeature       = Parameter.Comment_BoundTo_Feature_RefID != Guid.Empty;

                comment.Save(Connection, Transaction);


                #endregion
            }

            return(returnValue);

            #endregion UserCode
        }