protected static FR_L3N_DNG_1103 Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3N_DNG_1103(); //Put your code here var ProjectNotesCreatedByCurrentUser = cls_Get_All_ProjectNotes_Created_by_AccountID.Invoke(Connection, Transaction, securityTicket).Result.ToList(); foreach (var note in ProjectNotesCreatedByCurrentUser) { var lastnoterevision = ORM_CMN_NoteRevision.Query.Search(Connection, Transaction, new ORM_CMN_NoteRevision.Query() { Tenant_RefID = securityTicket.TenantID, CMN_NoteRevisionID = note.Current_NoteRevision_RefID, IsDeleted = true }).SingleOrDefault(); if (lastnoterevision != null) { var noteToDelete = ORM_CMN_Note.Query.Search(Connection, Transaction, new ORM_CMN_Note.Query() { CMN_NoteID = note.CMN_NoteID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (noteToDelete != null) { noteToDelete.IsDeleted = true; noteToDelete.Save(Connection, Transaction); } } } var ProjectNoteswhereUserIscollab = cls_Get_All_ProjectNotes_Where_Current_User_is_Collaborator.Invoke(Connection, Transaction, securityTicket).Result.ToList(); foreach (var note in ProjectNoteswhereUserIscollab) { var lastnoterevision = ORM_CMN_NoteRevision.Query.Search(Connection, Transaction, new ORM_CMN_NoteRevision.Query() { Tenant_RefID = securityTicket.TenantID, CMN_NoteRevisionID = note.CMN_NoteID, IsDeleted = true }).SingleOrDefault(); if (lastnoterevision != null) { var noteToDelete = ORM_CMN_Note.Query.Search(Connection, Transaction, new ORM_CMN_Note.Query() { CMN_NoteID = note.CMN_NoteID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (noteToDelete != null) { noteToDelete.IsDeleted = true; noteToDelete.Save(Connection, Transaction); } } } return(returnValue); #endregion UserCode }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L3N_DNG_1103 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L3N_DNG_1103 functionReturn = new FR_L3N_DNG_1103(); try { if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } functionReturn = Execute(Connection, Transaction, 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 { } throw new Exception("Exception occured in method cls_Delete_Notes_Garbage", ex); } return(functionReturn); }