internal ProjectVariantAssignment(IContentClass contentClass, IProjectVariant projectVariant,
                                   ITemplateVariant templateVariant)
 {
     _contentClass    = contentClass;
     _projectVariant  = projectVariant;
     _templateVariant = templateVariant;
 }
        public void Remove(IProjectVariant projectVariant, ILanguageVariant languageVariant)
        {
            var entry =
                this.FirstOrDefault(x => x.ProjectVariant.Guid == projectVariant.Guid && x.LanguageVariant.Guid == languageVariant.Guid);

            if (entry != null)
            {
                entry.Delete();
            }
        }
        public void Add(IProjectVariant projectVariant, ILanguageVariant languageVariant)
        {
            const string ADD =
                @"<PROJECT><EXPORTSETTING action=""save"" guid=""{0}"" projectvariantguid=""{1}"" languagevariantguid=""{2}"" copyguid="""" /></PROJECT>";

            var doc = Project.ExecuteRQL(ADD.RQLFormat(PublicationPackage, projectVariant, languageVariant.Guid.ToRQLString()));

            //TODO check answer?

            InvalidateCache();
        }
示例#4
0
        /// <summary>
        ///     Assign this template to a specific project variant
        /// </summary>
        public void AssignToProjectVariant(IProjectVariant variant, bool doNotPublish, bool doNotUseTidy)
        {
            const string ASSIGN_PROJECT_VARIANT =
                @"<TEMPLATE guid=""{0}""><TEMPLATEVARIANTS> <TEMPLATEVARIANT guid=""{1}"">
                                                    <PROJECTVARIANTS action=""assign""><PROJECTVARIANT donotgenerate=""{3}"" donotusetidy=""{4}"" guid=""{2}"" />
                                                    </PROJECTVARIANTS></TEMPLATEVARIANT></TEMPLATEVARIANTS></TEMPLATE>";

            ContentClass.Project.ExecuteRQL(string.Format(ASSIGN_PROJECT_VARIANT, ContentClass.Guid.ToRQLString(),
                                                          Guid.ToRQLString(), variant.Guid.ToRQLString(),
                                                          doNotPublish.ToRQLString(), doNotUseTidy.ToRQLString()));

            ContentClass.ProjectVariantAssignments.InvalidateCache();
        }
示例#5
0
        /// <summary>
        ///     Assign this template to a specific project variant
        /// </summary>
        public void AssignToProjectVariant(IProjectVariant variant, bool doNotPublish, bool doNotUseTidy)
        {
            const string ASSIGN_PROJECT_VARIANT =
                @"<TEMPLATE guid=""{0}""><TEMPLATEVARIANTS> <TEMPLATEVARIANT guid=""{1}"">
                                                    <PROJECTVARIANTS action=""assign""><PROJECTVARIANT donotgenerate=""{3}"" donotusetidy=""{4}"" guid=""{2}"" />
                                                    </PROJECTVARIANTS></TEMPLATEVARIANT></TEMPLATEVARIANTS></TEMPLATE>";

            ContentClass.Project.ExecuteRQL(string.Format(ASSIGN_PROJECT_VARIANT, ContentClass.Guid.ToRQLString(),
                                                          Guid.ToRQLString(), variant.Guid.ToRQLString(),
                                                          doNotPublish.ToRQLString(), doNotUseTidy.ToRQLString()));

            ContentClass.ProjectVariantAssignments.InvalidateCache();
        }
示例#6
0
    //create alternate part. Need to make functional.
    public void Command_CreateComponentVariantion(IServerDocumentView view, ref string parameters)
    {
        IWorkspace workspace = DXP.GlobalVars.DXPWorkSpace as IWorkspace;
        IProject   project   = workspace.DM_FocusedProject();

        if (project.DM_NeedsCompile())
        {
            project.DM_Compile();
        }

        // Get or create "Test" Project Variant
        IProjectVariant projectVariant = null;

        for (int i = 0; i < project.DM_ProjectVariantCount(); i++)
        {
            if (project.DM_ProjectVariants(i).DM_Description().Equals("Test", StringComparison.OrdinalIgnoreCase))
            {
                projectVariant = project.DM_ProjectVariants(i);
                break;
            }
        }

        if (projectVariant == null)
        {
            projectVariant = project.DM_AddProjectVariant();
            projectVariant.DM_SetName("Test");
            projectVariant.DM_SetDescription("Test");
        }

        // Create alternate part for each component in the project, using "Bridge2" in "Miscellaneous Devices.IntLib".
        project.DM_BeginUpdate();
        try
        {
            IDocument documentFlattened = project.DM_DocumentFlattened();
            for (int i = 0; i < documentFlattened.DM_ComponentCount(); i++)
            {
                IComponent component = documentFlattened.DM_Components(i);
                if (component.DM_IsInferredObject())
                {
                    continue;
                }

                IComponentVariation componentVariation = projectVariant.DM_FindComponentVariationByUniqueId(component.DM_UniqueId());
                if (componentVariation == null)
                {
                    componentVariation = projectVariant.DM_AddComponentVariation();
                }

                componentVariation.DM_SetUniqueId(component.DM_UniqueId());
                IComponentLibraryLink componentLibraryLink = componentVariation.DM_AlternateLibraryLink();
                componentLibraryLink.DM_SetUseLibraryName(true);
                componentLibraryLink.DM_SetLibraryIdentifier("Miscellaneous Devices.IntLib");
                componentLibraryLink.DM_SetSourceLibraryName("Miscellaneous Devices.IntLib");
                componentLibraryLink.DM_SetDesignItemID("Bridge2");
                componentVariation.DM_SetVariationKind(TVariationKind.eVariation_Alternate);
            }
        }
        finally
        {
            project.DM_EndUpdate();
        }
    }