// The following function is not used but is included here for reference
        private SmartObjectDefinition CreateLookup(string smoName)
        {
            try
            {
                ManagementServerConnect();
                string smoDefinitionXml = _smoManagementServer.GetSmartObjectDefinition(smoName);

                SmartObjectDefinition smoDefinition = SmartObjectDefinition.Create(smoDefinitionXml);
                smoDefinition.Lookup.LookupDisplayProperties.Add(smoDefinition.Properties[1]);
                smoDefinition.Lookup.LookupKeyProperties.Add(smoDefinition.Properties[0]);

                smoDefinition.Build();
                return(smoDefinition);
            }

            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                ManagementServerCloseConnection();
            }
        }
        private SmartObjectDefinition CreateAssociation(string smoName, string associationName, SourceCode.SmartObjects.Authoring.AssociationType associationType)
        {
            try
            {
                toolStripStatusLabel1.Text = ("Creating association between '" + smoName + "' and '" + associationName + "'");
                statusStrip1.Update();
                ManagementServerConnect();

                string smartObjectXml = _smoManagementServer.GetSmartObjectDefinition(smoName);
                SmartObjectDefinition smoDefinition = SmartObjectDefinition.Create(smartObjectXml);

                string associationXml = _smoManagementServer.GetAssociationSmartObject(associationName);
                AssociationSmartObject associationDefinition = AssociationSmartObject.Create(associationXml);

                smoDefinition.AddAssociation(associationDefinition, associationDefinition.Properties[1], smoDefinition.Properties[1], associationType, "test association");
                smoDefinition.AddDeploymentCategory("Test SmartObjects");

                smoDefinition.Build();

                return(smoDefinition);
            }

            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                ManagementServerCloseConnection();
            }
        }
        private SmartObjectDefinition CreateSmartObject(string smoName)
        {
            try
            {
                // Delete the smartobject if it already exists
                this.DeleteSmartObject(smoName);

                toolStripStatusLabel1.Text = ("Creating SmartObject properties for '" + smoName + "'");
                statusStrip1.Update();
                ManagementServerConnect();

                // Get SmartBox service instance
                ServiceInstance serviceInstance = ServiceInstance.Create(_smoManagementServer.GetServiceInstanceForExtend(new Guid(_smartboxGuid), string.Empty));
                ExtendObject    extendObject    = serviceInstance.GetCreateExtender();

                extendObject.Name = smoName;
                extendObject.Metadata.DisplayName = smoName;

                // Create 'id' property
                ExtendObjectProperty idProperty = new ExtendObjectProperty();
                idProperty.Name = "ID";
                idProperty.Metadata.DisplayName = idProperty.Name;
                idProperty.Type       = PropertyDefinitionType.Autonumber;
                idProperty.ExtendType = ExtendPropertyType.UniqueIdAuto;

                // Create 'name' property
                ExtendObjectProperty nameProperty = new ExtendObjectProperty();
                nameProperty.Name = "Name";
                nameProperty.Metadata.DisplayName = nameProperty.Name;
                nameProperty.Type = PropertyDefinitionType.Text;

                // Create other properties here as needed
                // Add the new properties below

                // Add properties
                extendObject.Properties.Add(idProperty);
                extendObject.Properties.Add(nameProperty);

                SmartObjectDefinition smoDefinition = new SmartObjectDefinition();

                // Create SmartObject Definition
                smoDefinition.Create(extendObject);
                smoDefinition.AddDeploymentCategory("Test SmartObjects");

                smoDefinition.Build();

                return(smoDefinition);
            }

            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                ManagementServerCloseConnection();
            }
        }
        public static SmartObjectDefinition GetSmartObjectDefinition(string smartObjectName)
        {
            var managementServer = WrapperFactory.Instance.GetSmartObjectManagementServerWrapper(null);

            using (managementServer.BaseAPIServer?.Connection)
            {
                return(SmartObjectDefinition.Create(managementServer.GetSmartObjectDefinition(smartObjectName)));
            }
        }
示例#5
0
        public void DeleteWorkflowReportingSmartObjects(ProcessSet processSet)
        {
            var smartObjectManagementServer = this.GetServer();

            using (smartObjectManagementServer.Connection)
            {
                var serviceObjectName = $"Rpt_{SmartObjectDefinition.GetNameFromDisplay(processSet.FullName)}";

                var smartObjects = from smo in smartObjectManagementServer.GetSmartObjects(Constants.ServiceInstance.WorkflowReporting).SmartObjectList
                                   from se in smo.Metadata.ServiceElements.Cast <ServiceElementInfo>()
                                   where se.Name == "serviceobject" && se.Value == serviceObjectName
                                   select smo;

                foreach (var smartobject in smartObjects)
                {
                    smartObjectManagementServer.DeleteSmartObject(smartobject.Guid, true);
                }
            }
        }
        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 SmartObjectDefinition CreateServiceJoin(string smoName1, string smoName2)
        {
            try
            {
                // Delete the smartobject if it already exists
                this.DeleteSmartObject(smoName1 + smoName2);

                toolStripStatusLabel1.Text = ("Creating ServiceJoin SmartObject '" + smoName1 + " " + smoName2 + "'");
                statusStrip1.Update();

                ManagementServerConnect();

                // Get first serviceobject

                ServiceInstance serviceInstance1 = ServiceInstance.Create(_smoManagementServer.GetServiceInstanceForExtend(new Guid(_smartboxGuid), smoName1));
                ServiceObject   serviceObject1   = serviceInstance1.ServiceObjects[0];

                if (serviceObject1 == null)
                {
                    throw new Exception("Serviceobject does not exist. " + smoName1);
                }

                // Get second serviceobject

                ServiceInstance serviceInstance2 = ServiceInstance.Create(_smoManagementServer.GetServiceInstanceForExtend(new Guid(_smartboxGuid), smoName2));
                ServiceObject   serviceObject2   = serviceInstance2.ServiceObjects[0];

                if (serviceObject2 == null)
                {
                    throw new Exception("Serviceobject does not exist. " + smoName2);
                }

                // Create SmartObjectDefinition

                SmartObjectDefinition smoDefinition = new SmartObjectDefinition();
                smoDefinition.Name = smoName1 + smoName2;
                smoDefinition.Metadata.DisplayName = smoName1 + " " + smoName2;

                // Get Getlist servicemethod

                ServiceObjectMethod method = serviceObject1.Methods["GetList"];

                if (method == null)
                {
                    throw new Exception("GetList method does not exist on " + serviceObject1.Name);
                }

                // Create SmartMethodDefinition

                SmartMethodDefinition soMethod = new SmartMethodDefinition();
                soMethod.Name = method.Name;
                soMethod.Metadata.DisplayName = method.DisplayName;

                smoDefinition.Methods.Add(soMethod);

                // Map the first ServiceObject
                string executionBlockName = soMethod.Map(method);

                foreach (ServiceObjectProperty soProperty in serviceObject1.Properties)
                {
                    SmartPropertyDefinition smartProperty = new SmartPropertyDefinition();
                    smartProperty.Name = soProperty.Name + "_1";
                    smartProperty.Metadata.DisplayName = soProperty.Name + "_1";
                    smoDefinition.Properties.Add(smartProperty);

                    smoDefinition.MapProperty(smartProperty, soProperty, executionBlockName, method.Name);
                }

                // Map the second ServiceObject

                method = serviceObject2.Methods["GetList"];

                if (method == null)
                {
                    throw new Exception("GetList method does not exist on " + serviceObject1.Name);
                }

                executionBlockName = soMethod.Map(method);

                foreach (ServiceObjectProperty soProperty in serviceObject2.Properties)
                {
                    SmartPropertyDefinition smartProperty = new SmartPropertyDefinition();
                    smartProperty.Name = soProperty.Name + "_2";
                    smartProperty.Metadata.DisplayName = soProperty.Name + "_2";
                    smoDefinition.Properties.Add(smartProperty);

                    smoDefinition.MapProperty(smartProperty, soProperty, executionBlockName, method.Name);
                }

                ServiceJoinDetails joinDetails = smoDefinition.Methods[0].JoinDetails;
                joinDetails.From = soMethod.ExecutionBlocks[0].ServiceInstance.ServiceObjects[0];

                ServiceJoin serviceJoin = new ServiceJoin();
                serviceJoin.From = soMethod.ExecutionBlocks[0].ServiceInstance.ServiceObjects[0];;
                serviceJoin.To   = soMethod.ExecutionBlocks[1].ServiceInstance.ServiceObjects[0];;

                serviceJoin.AddCondition("Condition", serviceObject1.Properties[1], serviceObject2.Properties[1]);

                joinDetails.ServiceJoins.Add(serviceJoin);

                smoDefinition.AddDeploymentCategory("Test SmartObjects");

                smoDefinition.Build();
                return(smoDefinition);
            }

            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                ManagementServerCloseConnection();
            }
        }