Exemplo n.º 1
0
        /// <summary>
        /// Removes the metadata.
        /// </summary>
        private static void RemoveMetadata()
        {
            foreach (MetaClass cl in MetaClass.GetList(OrderContext.MetaDataContext, "Mediachase.Commerce.Orders", true))
            {
                if (!cl.IsSystem)
                {
                    MetaClass.Delete(OrderContext.MetaDataContext, cl.Id);
                }
            }

            foreach (MetaClass cl in MetaClass.GetList(OrderContext.MetaDataContext, "Mediachase.Commerce.Orders", true))
            {
                MetaClass.Delete(OrderContext.MetaDataContext, cl.Id);
            }
        }
Exemplo n.º 2
0
        private static void DeleteProjectType(int ProjectTypeId)
        {
            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBProject.DeleteProjectType(ProjectTypeId);

                string    MetaClassName = String.Format("ProjectsEx_{0}", ProjectTypeId);
                MetaClass mc            = MetaClass.Load(MetaClassName);

                MetaClass parent = mc.Parent;

                if (mc != null)
                {
                    MetaClass.Delete(mc.Id);
                }

                RebuildProjectsSearch(parent);

                tran.Commit();
            }
        }
Exemplo n.º 3
0
        private void DeleteAllMetaClasses(bool doDelete, ClearCatalogAndModelsResult result)
        {
            MetaDataContext     metaDataContext     = new MetaDataContext();
            MetaClassCollection metaClassCollection = MetaClass.GetList(metaDataContext);
            List <string>       logList             = new List <string>();

            foreach (MetaClass metaClass in metaClassCollection)
            {
                if (doDelete && metaClass.IsSystem == false)
                {
                    _log.DebugFormat("Deleting class: {0} - {1} (System: {2})",
                                     metaClass.Name,
                                     metaClass.Id,
                                     metaClass.IsSystem);
                    try
                    {
                        MetaClass.Delete(metaDataContext, metaClass.Id);
                        result.MetaClassesDeleted++;
                    }
                    catch (Exception ex)
                    {
                        result.MetaClassesSkipped++;
                        _log.Error(string.Format("Cannot delete Class: {0} - {1} ({2})", metaClass.Name,
                                                 metaClass.Id, ex.Message),
                                   ex);
                    }
                }
                else
                {
                    result.MetaClassesSkipped++;
                    _log.DebugFormat("NOT deleting system class: {0} - {1} (System: {2})",
                                     metaClass.Name,
                                     metaClass.Id,
                                     metaClass.IsSystem);
                }
            }

            // List of meta data fields to keep.
            List <string> filterFields = new List <string>()
            {
                "TrackingNumber",
                "AddYourOwn"
            };
            MetaFieldCollection fields = MetaField.GetList(metaDataContext);

            foreach (MetaField field in fields)
            {
                // Do not delete: System fields, filtered fields and fields starting with underscore
                if (doDelete &&
                    field.IsSystem == false &&
                    filterFields.Contains(field.Name) == false &&
                    field.Name.StartsWith("_") == false)
                {
                    _log.DebugFormat("Deleting field: {0} - {1} (System: {2})",
                                     field.Name,
                                     field.Id,
                                     field.IsSystem);
                    try
                    {
                        MetaField.Delete(metaDataContext, field.Id);
                        result.MetaFieldsDeleted++;
                    }
                    catch (Exception ex)
                    {
                        result.MetaFieldsSkipped++;
                        _log.Error(string.Format("Cannot delete Field: {0} - {1} ({2})",
                                                 field.Name,
                                                 field.Id, ex.Message),
                                   ex);
                    }
                }
                else
                {
                    result.MetaFieldsSkipped++;
                    _log.DebugFormat("NOT deleting field: {0} - {1} (System: {2})",
                                     field.Name,
                                     field.Id,
                                     field.IsSystem);
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Handles the Click event of the DeleteButton control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void DeleteButton_Click(object sender, System.EventArgs e)
 {
     MetaClass.Delete(MDContext, int.Parse(ddlType.SelectedValue));
     BindElement();
 }