コード例 #1
0
        protected override void PreDeleteInsideTransaction(BusinessContext context)
        {
            // Call Base method
            base.PreDeleteInsideTransaction(context);

            #region Load Document Type
            // Load Document Type
            DocumentTypeEntity docType = (DocumentTypeEntity)BusinessManager.Load(DocumentTypeEntity.GetAssignedMetaClassName(),
                                                                                  context.GetTargetPrimaryKeyId().Value);

            if (docType != null)
            {
                // Read Card Name
                string cardName = docType.Name;

                // Delete meta class
                using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit())
                {
                    DataContext.Current.MetaModel.DeleteMetaClass(cardName);

                    scope.SaveChanges();
                }
            }
            #endregion
        }
コード例 #2
0
        /// <summary>
        /// Creates the entity object.
        /// </summary>
        /// <param name="metaClassName">Name of the meta class.</param>
        /// <param name="primaryKeyId">The primary key id.</param>
        /// <returns></returns>
        protected override EntityObject CreateEntityObject(string metaClassName, PrimaryKeyId?primaryKeyId)
        {
            if (metaClassName == DocumentTypeEntity.GetAssignedMetaClassName())
            {
                DocumentTypeEntity retVal = new DocumentTypeEntity();
                retVal.PrimaryKeyId = primaryKeyId;
                return(retVal);
            }

            return(base.CreateEntityObject(metaClassName, primaryKeyId));
        }
コード例 #3
0
        /// <summary>
        /// Pres the create inside transaction.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PreCreateInsideTransaction(BusinessContext context)
        {
            base.PreCreateInsideTransaction(context);

            // Initialize DocumentTypeId from
            string metaClassName = context.GetTargetMetaClassName();

            EntityObject[] documentTypes = BusinessManager.List(DocumentTypeEntity.GetAssignedMetaClassName(),
                                                                new FilterElement[] { FilterElement.EqualElement("Name", metaClassName) });

            if (documentTypes.Length > 0)
            {
                context.Request.Target["DocumentTypeId"] = documentTypes[0].PrimaryKeyId.Value;
            }

            // Initialize Processor Keys
            context.Items["MC_DocumentTemplateProcessorKeys"] = new Dictionary <string, EntityObject>();
        }