Exemple #1
0
        public IdpeVersion GetCurrentVersion(VersionObjectTypes versionObjectType, int referenceId)
        {
            IdpeVersion currentVersion = new IdpeVersion();

            currentVersion.Type = (int)versionObjectType;
            if (versionObjectType == VersionObjectTypes.DataSource)
            {
                DataSourceBundle dsb        = new DataSourceBundle();
                string           serialized = dsb.Export(referenceId, false);
                currentVersion.Data      = new System.Data.Linq.Binary(GZipArchive.Compress(serialized.GetByteArray()));
                currentVersion.CreatedBy = dsb.DataSource.CreatedBy;
                currentVersion.CreatedTS = (DateTime) new Manager().GetDataSourceLastUpdatedTime(referenceId);
                currentVersion.Source    = dsb.DataSource.Source;
            }
            else if (versionObjectType == VersionObjectTypes.Rule)
            {
                IdpeRule rule = new Manager().GetRule(referenceId);
                if (rule == null)
                {
                    return(null);
                }

                DataSourcePatch patch = new DataSourcePatch();
                patch.Rules.Add(rule);
                currentVersion.Data      = new System.Data.Linq.Binary(GZipArchive.Compress(patch.Export().GetByteArray()));
                currentVersion.CreatedBy = rule.CreatedBy;
                currentVersion.CreatedTS = rule.CreatedTS;
                currentVersion.Source    = rule.Source;
            }
            return(currentVersion);
        }
Exemple #2
0
        void LoadFromSerializedObject(string serializedObject)
        {
            DataSourcePatch dsp = serializedObject.Deserialize <DataSourcePatch>();

            this.Name     = dsp.Name;
            this.FileName = FileName;
            this.Keys     = dsp.Keys;
            this.Rules    = dsp.Rules;
            this.CodeSets = dsp.CodeSets;
        }
Exemple #3
0
        public void KeepVersionInternal(Manager manager, VersionObjectTypes versionObjectType, int referenceId)
        {
            if (referenceId == 0)
            {
                return;
            }

            IdpeVersion version = GetCurrentVersion(versionObjectType, referenceId);

            if (version == null)
            {
                return;
            }

            version.Version     = manager.GetLatestVersionNumber(versionObjectType, referenceId) + 1;
            version.Type        = (int)versionObjectType;
            version.ReferenceId = referenceId;

            switch (versionObjectType)
            {
            case VersionObjectTypes.DataSource:
                IdpeDataSource ds = manager.GetDataSourceDetails(referenceId);
                version.Data      = new Binary(GZipArchive.Compress(new DataSourceBundle().Export(referenceId, false).GetByteArray()));
                version.CreatedTS = ds.CreatedTS;
                break;

            case VersionObjectTypes.Rule:
                IdpeRule        rule  = manager.GetRule(referenceId);
                DataSourcePatch patch = new DataSourcePatch();
                patch.Rules.Add(rule);
                version.Data      = new Binary(GZipArchive.Compress(patch.Export().GetByteArray()));
                version.CreatedTS = rule.CreatedTS;
                break;
            }
            manager.Save(version);
        }