private void BuildSmartObjects()
        {
            try
            {
                toolStripStatusLabel1.Text = "Creating SmartObjects...";
                statusStrip1.Update();

                InitializeConnectionString();

                SmartObjectDefinitionsPublish publishSmo = new SmartObjectDefinitionsPublish();

                publishSmo.SmartObjects.Add(this.CreateSmartObject(_smoEmployees));
                publishSmo.SmartObjects.Add(this.CreateSmartObject(_smoRegions));
                publishSmo.SmartObjects.Add(this.CreateSmartObject(_smoDepartments));


                // Publish SmartObjects before creating associations
                PublishSmartObjects(publishSmo);

                // Re-intialize the SmartObject definitions
                publishSmo.Dispose();
                publishSmo = new SmartObjectDefinitionsPublish();

                // Create SmartObject associations
                publishSmo.SmartObjects.Add(this.CreateAssociation(_smoEmployees, _smoRegions, SourceCode.SmartObjects.Authoring.AssociationType.OneToMany));
                publishSmo.SmartObjects.Add(this.CreateAssociation(_smoDepartments, _smoEmployees, SourceCode.SmartObjects.Authoring.AssociationType.ManyToOne));
                publishSmo.SmartObjects.Add(this.CreateAssociation(_smoRegions, _smoDepartments, SourceCode.SmartObjects.Authoring.AssociationType.ManyToOne));

                // Publish SmartObjects with associations
                PublishSmartObjects(publishSmo);

                // Re-intialize the SmartObject definitions
                publishSmo.Dispose();
                publishSmo = new SmartObjectDefinitionsPublish();

                publishSmo.SmartObjects.Add(CreateServiceJoin(_smoEmployees, _smoRegions));

                // Publish association SmO
                PublishSmartObjects(publishSmo);

                toolStripStatusLabel1.Text = "SmartObject creation successful.";
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public static void PublishSmartObjects(SmartObjectDefinitionsPublish smartObjectDefinitionsPublish)
        {
            smartObjectDefinitionsPublish.ThrowIfNull("smartObjectDefinitionsPublish");

            var managementServer = WrapperFactory.Instance.GetSmartObjectManagementServerWrapper(null);

            using (managementServer.BaseAPIServer?.Connection)
            {
                // Delete SmartObjects
                foreach (SmartObjectDefinition smartObject in smartObjectDefinitionsPublish.SmartObjects)
                {
                    SmartObjectHelper.DeleteSmartObject(managementServer, smartObject.Name);
                }

                managementServer.PublishSmartObjects(smartObjectDefinitionsPublish.ToPublishXml());
            }
        }
        private void PublishSmartObjects(SmartObjectDefinitionsPublish publishSmo)
        {
            try
            {
                toolStripStatusLabel1.Text = "Publishing SmartObjects...";
                statusStrip1.Update();
                ManagementServerConnect();
                _smoManagementServer.PublishSmartObjects(publishSmo.ToPublishXml());
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            finally
            {
                ManagementServerCloseConnection();
            }
        }
Esempio n. 4
0
        public void PublishSmartObjectsFromResources_DefaultValues()
        {
            // Arrange
            var smartObjectInfo         = SmartObjectInfo.Create(Resources.SmartObjectDefinition_ProcessInfo);
            var mockSmartObjectExplorer = Mock.Of <SmartObjectExplorer>();

            mockSmartObjectExplorer.SmartObjects.Add(smartObjectInfo);

            MockWrapperFactory.Instance.SmartObjectManagementServer
            .Setup(i => i.GetSmartObjects(
                       It.IsAny <string>()))
            .Returns(mockSmartObjectExplorer);

            var smartObjectDefinitionsPublish = new SmartObjectDefinitionsPublish();

            smartObjectDefinitionsPublish.SmartObjects.Add(new SmartObjectDefinition());

            // Action
            SmartObjectHelper.PublishSmartObjectsFromResources(this.GetType().Assembly, null);
        }
        public static void PublishSmartObjectsFromResources(Assembly assembly, string category)
        {
            assembly.ThrowIfNull("assembly");

            using (var publishSmO = new SmartObjectDefinitionsPublish())
            {
                // Get the SmartObjects from the embeded resources of the assembly
                foreach (var resource in assembly.GetManifestResourceNames())
                {
                    if (resource.IndexOf(".sodx", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        using (var streamSodx = assembly.GetManifestResourceStream(resource))
                        {
                            var resourceSmartObject = SmartObjectDefinition.Create(streamSodx);
                            resourceSmartObject.AddDeploymentCategory(category);
                            publishSmO.SmartObjects.Add(resourceSmartObject);
                        }
                    }
                }

                // Publish the SmartObjects
                PublishSmartObjects(publishSmO);
            }
        }
        private void btnCreateFrameworkSmartObjects_Click(object sender, RoutedEventArgs e)
        {
            //string BaseDirectory = @"C:\Development\K2 Field App Framework";
            //System.IO.File.WriteAllText(BaseDirectory + "\\K2App.Core.SMO.AppType.json", Newtonsoft.Json.JsonConvert.SerializeObject(AppType));

            //SourceCode.SmartObjects.Management.SmartObjectManagementServer Server = GetSmOServer();

            //SmartObjectManagementSvr.PublishSmartObject(Def.ToXml(), "Test Category");

            string DeploymentCategory = @"App Framework\SmartObjects";
            string LookupCategory = @"App Framework\Lookups";

            SmartObjectDefinitionsPublish smoPublish = new SmartObjectDefinitionsPublish();
            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdAudit = CreateSmartBoxSmartObject(Server, (new AppBusinessAudit().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdAudit);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdException = CreateSmartBoxSmartObject(Server, (new AppException().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdException);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdInstance = CreateSmartBoxSmartObject(Server, (new AppInstance().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdInstance);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdKPI = CreateSmartBoxSmartObject(Server, (new AppKPI().GetDefinition()), LookupCategory);
            smoPublish.SmartObjects.Add(sdKPI);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdPriority = CreateSmartBoxSmartObject(Server, (new AppPriority().GetDefinition()), LookupCategory);
            smoPublish.SmartObjects.Add(sdPriority);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdProcess = CreateSmartBoxSmartObject(Server, (new AppProcess().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdProcess);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdStage = CreateSmartBoxSmartObject(Server, (new AppStage().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdStage);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdStageAction = CreateSmartBoxSmartObject(Server, (new AppStageAction().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdStageAction);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdStatus = CreateSmartBoxSmartObject(Server, (new AppStatus().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdStatus);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdType = CreateSmartBoxSmartObject(Server, (new AppType().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdType);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdTypeAction = CreateSmartBoxSmartObject(Server, (new AppTypeAction().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdTypeAction);

            SourceCode.SmartObjects.Authoring.SmartObjectDefinition sdImage = CreateSmartBoxSmartObject(Server, (new AppImage().GetDefinition()), DeploymentCategory);
            smoPublish.SmartObjects.Add(sdImage);

            // App Instance to App Business Audit
            sdInstance.AddAssociation(sdAudit, sdAudit.Properties["App_Instance_ID"], sdInstance.Properties["ID"], "AppInstanceAppBusinessAudt");
            // App Instance to App Process
            sdInstance.AddAssociation(sdProcess, sdProcess.Properties["App_Instance_ID"], sdInstance.Properties["ID"], "AppInstanceAppProcess");
            // Parent App Instance to App Instance
            sdInstance.AddAssociation(sdInstance, sdProcess.Properties["ID"], sdInstance.Properties["Parent_Application_Instance_ID"], "ParentAppInstanceAppInstance");

            // App Type to App Stage
            sdType.AddAssociation(sdStage, sdStage.Properties["App_Type_ID"], sdType.Properties["ID"], "AppTypeAppStage");

            // App Type to App Status
            sdType.AddAssociation(sdStatus, sdStatus.Properties["App_Type_ID"], sdType.Properties["ID"], "AppTypeAppStatus");

            // App Type to App Type Action
            sdType.AddAssociation(sdTypeAction, sdTypeAction.Properties["App_Type_ID"], sdType.Properties["ID"], "AppTypeAppTypeAction");

            // App Type Action to Image
            sdImage.AddAssociation(sdTypeAction, sdTypeAction.Properties["Icon_ID"], sdImage.Properties["ID"], "AppImageAppTypeActionIcon");

            // App Type to Image
            sdImage.AddAssociation(sdType, sdType.Properties["Icon_ID"], sdImage.Properties["ID"], "AppImageAppTypeIcon");

            // App Stage Action to Image
            sdImage.AddAssociation(sdStageAction, sdStageAction.Properties["Icon_ID"], sdImage.Properties["ID"], "AppImageAppStageActionIcon");

            // App Type to App KPI
            //sdType.AddAssociation(sdKPI, sdKPI.Properties["App_Type_ID"], sdType.Properties["ID"], "AppTypeAppKPI");

            // App Type to App Priority
            //sdType.AddAssociation(sdPriority, sdStatus.Properties["App_Type_ID"], sdPriority.Properties["ID"], "AppTypeAppPriority");

            // App Stage to App Stage Action
            sdStage.AddAssociation(sdStageAction, sdStageAction.Properties["App_Stage_ID"], sdStage.Properties["ID"], "AppStageAppStageAction");

            // NEED TO CREATE APP TYPE ACTION object

            Server.PublishSmartObjects(smoPublish.ToPublishXml());

            //SourceCode.SmartObjects.Authoring.SmartObjectDefinition AuditDef = CreateSmartBoxSmartObject(Server, (new AppBusinessAudit().GetDefinition()), DeploymentCategory);
            //Server.DeploySmartObject(AuditDef.ToSmartObjectDeployXml(), AuditDef.Guid);

            //SourceCode.SmartObjects.Authoring.SmartObjectDefinition ExcDef = CreateSmartObject(Server, (new AppException().GetDefinition()), DeploymentCategory);

            //Server.DeploySmartObject(ExcDef.ToSmartObjectDeployXml(), ExcDef.Guid);

            //string InstanceAudit = Server.GetAssociationSmartObject(Guid.NewGuid());
            //AssociationSmartObject a = AssociationSmartObject.Create(sdAudit.to

            smoPublish = new SmartObjectDefinitionsPublish();

            MessageBox.Show("Framework Created");
        }