示例#1
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Base Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L2FE_SF_1202 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 { }

                throw new Exception("Exception occured in method cls_Save_Feature", ex);
            }
            return(functionReturn);
        }
示例#2
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Base Invoke(string ConnectionString, P_L2FE_SF_1202 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }
示例#3
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_Base Invoke(DbConnection Connection, DbTransaction Transaction, P_L2FE_SF_1202 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
示例#4
0
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L2FE_SF_1202 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

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

            #region Single Delete

            if (Parameter.IsDeleted == true && Parameter.ActionType.Equals("DeleteSingle"))
            {
                ORM_TMS_PRO_Feature.Query searchQuery = new ORM_TMS_PRO_Feature.Query();
                searchQuery.TMS_PRO_FeatureID = Parameter.FeatureID;

                ORM_TMS_PRO_Feature.Query.SoftDelete(Connection, Transaction, searchQuery);

                item.IsDeleted = true;
                item.Save(Connection, Transaction);

                DeleteTags(Connection, Transaction, Parameter.FeatureID, securityTicket);

                FR_Base retVal = new FR_Base();
                retVal.Status = FR_Status.Success;

                return(retVal);
            }

            #endregion

            #region Multiple Delete

            if (Parameter.IsDeleted == true && Parameter.ActionType.Equals("DeleteMultiple"))
            {
                foreach (var featureID in Parameter.FeaturesToDelete)
                {
                    ORM_TMS_PRO_Feature.Query searchQuery = new ORM_TMS_PRO_Feature.Query();
                    searchQuery.TMS_PRO_FeatureID = Guid.Parse(featureID);

                    ORM_TMS_PRO_Feature.Query.SoftDelete(Connection, Transaction, searchQuery);


                    DeleteTags(Connection, Transaction, Guid.Parse(featureID), securityTicket);
                }

                FR_Base retVal = new FR_Base();
                retVal.Status = FR_Status.Success;

                return(retVal);
            }

            #endregion

            #region Add New Feature

            if (Parameter.IsDeleted == false && Parameter.ActionType.Equals("NewFeature"))
            {
                FR_Base retVal = new FR_Base();

                ORM_TMS_PRO_Feature NewFeature = new ORM_TMS_PRO_Feature();

                NewFeature.TMS_PRO_FeatureID    = Guid.NewGuid();
                NewFeature.IdentificationNumber = cls_Get_NewFeatureIdentifier.Invoke(Connection, Transaction, securityTicket).Result.Identifier;

                NewFeature.Name             = Parameter.Name;
                NewFeature.Description      = Parameter.Description;
                NewFeature.IsDeleted        = false;
                NewFeature.IsArchived       = false;
                NewFeature.Feature_Deadline = Parameter.Feature_Deadline;

                NewFeature.Type_RefID                 = Guid.Empty;
                NewFeature.Status_RefID               = Guid.Empty;
                NewFeature.Component_RefID            = Guid.Empty;
                NewFeature.DOC_Structure_Header_RefID = Guid.Empty;

                NewFeature.Parent_RefID  = Parameter.Parent_RefID;
                NewFeature.Project_RefID = Parameter.Project_RefID;

                NewFeature.Tenant_RefID           = securityTicket.TenantID;
                NewFeature.CreatedByAccount_RefID = securityTicket.AccountID;

                if (SaveTagsForFeature(Connection, Transaction, NewFeature.TMS_PRO_FeatureID, Parameter.Tags, securityTicket).Status == FR_Status.Error_Internal)
                {
                    retVal.Status = FR_Status.Error_Internal;
                    return(retVal);
                }

                NewFeature.Save(Connection, Transaction);

                retVal.Status = FR_Status.Success;
                return(retVal);
            }

            #endregion

            #region Edit Feature

            if (Parameter.IsDeleted == false && Parameter.ActionType.Equals("EditFeature"))
            {
                ORM_TMS_PRO_Feature.Query featureSearchQuery = new ORM_TMS_PRO_Feature.Query();
                featureSearchQuery.TMS_PRO_FeatureID = Parameter.FeatureID;

                ORM_TMS_PRO_Feature FeatureItem = ORM_TMS_PRO_Feature.Query.Search(Connection, Transaction, featureSearchQuery).FirstOrDefault();

                FeatureItem.Name             = Parameter.Name;
                FeatureItem.Description      = Parameter.Description;
                FeatureItem.Project_RefID    = Parameter.Project_RefID;
                FeatureItem.Parent_RefID     = Parameter.Parent_RefID;
                FeatureItem.Feature_Deadline = Parameter.Feature_Deadline;


                SaveTagsFor_EditedFeature(Connection, Transaction, Parameter.FeatureID, Parameter.Tags, securityTicket);

                FeatureItem.Save(Connection, Transaction);

                FR_Base retVal = new FR_Base();
                retVal.Status = FR_Status.Success;

                return(retVal);
            }

            #endregion



            return(returnValue);

            #endregion UserCode
        }