private void DisableControlsByVersion(BindingSource bindingSource, IVersionable dataSource)
        {
            BindingManagerBase bindingManagerBase = this.ContainerBindingContext[bindingSource];

            for (int i = bindingManagerBase.Bindings.Count - 1; i >= 0; i--)
            {
                Binding binding = bindingManagerBase.Bindings[i];
                ExchangeObjectVersion propertyDefinitionVersion = PropertyConstraintProvider.GetPropertyDefinitionVersion(dataSource, binding.BindingMemberInfo.BindingMember);
                if (dataSource.ExchangeVersion.IsOlderThan(propertyDefinitionVersion))
                {
                    if (!this.removedBindings[bindingSource].ContainsKey(binding.Control))
                    {
                        this.removedBindings[bindingSource][binding.Control] = new List <Binding>();
                    }
                    this.removedBindings[bindingSource][binding.Control].Add(binding);
                    ISpecifyPropertyState specifyPropertyState = binding.Control as ISpecifyPropertyState;
                    if (specifyPropertyState != null)
                    {
                        specifyPropertyState.SetPropertyState(binding.PropertyName, PropertyState.UnsupportedVersion, Strings.FeatureVersionMismatchDescription(propertyDefinitionVersion.ExchangeBuild));
                    }
                    else
                    {
                        binding.Control.Enabled = false;
                    }
                    binding.Control.DataBindings.Remove(binding);
                }
            }
        }
Example #2
0
        private static bool CheckPublishedStatus(this IContent content, PagePublishedStatus status)
        {
            IVersionable obj = content as IVersionable;

            if (obj == null)
            {
                return(false);
            }

            if (status != PagePublishedStatus.Ignore)
            {
                if (obj.IsPendingPublish)
                {
                    return(false);
                }
                if (obj.Status != VersionStatus.Published)
                {
                    return(false);
                }
                if ((status >= PagePublishedStatus.PublishedIgnoreStopPublish) && (obj.StartPublish > DateTime.Now))                //Context.Current.RequestTime))
                {
                    return(false);
                }
                if ((status >= PagePublishedStatus.Published) && (obj.StopPublish < DateTime.Now))                //Context.Current.RequestTime))
                {
                    return(false);
                }
            }

            return(true);
        }
        private void UpdateReferenceProperty <T, S, R>(PropertyInfo p, T a, T b) where R : VersionableBase
        {
            if (p.PropertyType != typeof(S))
            {
                return;
            }
            var va = (Collection <R>)p.GetValue(a, null);
            var vb = (Collection <R>)p.GetValue(b, null);

            for (var i = 0; i < va.Count; i++)
            {
                ((IVersionable)va[i]).IsDirty = true;
                ((IVersionable)a).RemoveChild(((VersionableBase)va[i]).CompositeId);
            }
            if (!vb.Any())
            {
                return;
            }
            var tmp = repoSet.Where(x => x.UserIds.Count > 0).ToList();

            for (var i = 0; i < vb.Count; i++)
            {
                IVersionable found = tmp.FirstOrDefault(x => x.UserIds[0].Identifier == vb[i].UserIds[0].Identifier);
                found.IsDirty = true;
                va.Add((R)found);
            }
        }
Example #4
0
        public static List <RepositoryItemMetadata> GetAllRepositoryQuestions(string agency, Guid id, RepositoryClientBase client)
        {
            // Retrieves data for the selected study from the repository to be used in determining equivalences

            List <RepositoryItemMetadata> infoList = new List <RepositoryItemMetadata>();

            MultilingualString.CurrentCulture = "en-GB";

            //IVersionable item = client.GetLatestItem(id, agency,
            //     ChildReferenceProcessing.Populate);

            IVersionable item = client.GetLatestItem(id, agency);

            var studyUnit = item as StudyUnit;

            SetSearchFacet setFacet = new SetSearchFacet();

            setFacet.ItemTypes.Add(DdiItemType.QuestionItem);

            if (studyUnit == null)
            {
                return(infoList);
            }
            var matches = client.SearchTypedSet(studyUnit.CompositeId,
                                                setFacet);

            infoList = client.GetRepositoryItemDescriptions(matches.ToIdentifierCollection()).ToList();
            return(infoList);
        }
Example #5
0
 public void AddVersionable(IVersionable versioner)
 {
     if (versioner != null)
     {
         versioners.Add(versioner);
     }
 }
Example #6
0
        public static List <RepositoryItemMetadata> GetReferences(string agency, Guid id)
        {
            MultilingualString.CurrentCulture = "en-GB";
            List <RepositoryItemMetadata> referenceItems = new List <RepositoryItemMetadata>();
            var client = ClientHelper.GetClient();

            // Retrieve the requested item from the Repository.
            // Populate the item's children, so we can display information about them.
            try
            {
                IVersionable item = client.GetLatestItem(id, agency,
                                                         ChildReferenceProcessing.Populate);
                // Use a graph search to find a list of all items that
                // directly reference this item.
                GraphSearchFacet facet = new GraphSearchFacet();
                facet.TargetItem            = item.CompositeId;
                facet.UseDistinctResultItem = false;

                var referencingItemsDescriptions = client.GetRepositoryItemDescriptionsByObject(facet);
                referenceItems = referencingItemsDescriptions.ToList();
                var referencingItemsSubject = client.GetRepositoryItemDescriptionsBySubject(facet).ToList();
            }
            catch (Exception e)
            {
                return(referenceItems);
            }
            return(referenceItems);
        }
        /// <summary>
        /// Process the given entry.
        /// </summary>
        /// <param name="entry">
        /// The <b>IInvocableCacheEntry</b> to process.
        /// </param>
        /// <param name="valueNew">
        /// The new value to update an entry with.
        /// </param>
        /// <param name="insert">
        /// Specifies whether or not an insert is allowed.
        /// </param>
        /// <param name="ret">
        /// Specifies whether or not a return value is required.
        /// </param>
        /// <returns>
        /// The result of the processing, if any.
        /// </returns>
        protected object processEntry(IInvocableCacheEntry entry, IVersionable valueNew, bool insert, bool ret)
        {
            bool         match;
            IVersionable valueCur = (IVersionable)entry.Value;

            if (valueCur == null)
            {
                match = insert;
            }
            else
            {
                IComparable verCur = valueCur.VersionIndicator;
                IComparable verNew = valueNew.VersionIndicator;

                match = (verCur.CompareTo(verNew) == 0);
            }

            if (match)
            {
                valueNew.IncrementVersion();
                entry.SetValue(valueNew, false);
                return(NO_RESULT);
            }

            return(ret ? valueCur : NO_RESULT);
        }
Example #8
0
        public ContentIndexResult ReindexSiteForRecovery(IContent siteRoot)
        {
            SlimContentReader slimContentReader = new SlimContentReader(this._contentRepository, siteRoot.ContentLink, (c =>
            {
                return(true);
            }));
            var listDocument = new List <SearchDocument>();

            while (slimContentReader.Next())
            {
                if (!slimContentReader.Current.ContentLink.CompareToIgnoreWorkID(ContentReference.RootPage))
                {
                    IVersionable current = slimContentReader.Current as IVersionable;
                    if (current == null || current.Status == VersionStatus.Published)
                    {
                        if (LuceneConfiguration.CanIndexContent(slimContentReader.Current))
                        {
                            var document = GetDocFromContent(slimContentReader.Current);
                            if (document != null)
                            {
                                listDocument.Add(document);
                            }
                        }
                    }
                }
            }
            _documentRepository.ReindexSiteForRecovery(listDocument, siteRoot.ContentGuid);
            return(new ContentIndexResult());
        }
        private void EnableControlsByVersion(BindingSource bindingSource, IVersionable dataSource)
        {
            List <Control> list = new List <Control>();

            foreach (Control item in this.removedBindings[bindingSource].Keys)
            {
                list.Add(item);
            }
            foreach (Control control in list)
            {
                List <Binding> list2 = new List <Binding>(this.removedBindings[bindingSource][control]);
                foreach (Binding binding in list2)
                {
                    ExchangeObjectVersion propertyDefinitionVersion = PropertyConstraintProvider.GetPropertyDefinitionVersion(dataSource, binding.BindingMemberInfo.BindingMember);
                    if (!dataSource.ExchangeVersion.IsOlderThan(propertyDefinitionVersion))
                    {
                        control.DataBindings.Add(binding);
                        this.removedBindings[bindingSource][control].Remove(binding);
                        if (this.removedBindings[bindingSource][control].Count == 0)
                        {
                            ISpecifyPropertyState specifyPropertyState = control as ISpecifyPropertyState;
                            if (specifyPropertyState != null)
                            {
                                specifyPropertyState.SetPropertyState(binding.PropertyName, PropertyState.Normal, string.Empty);
                            }
                            else
                            {
                                control.Enabled = true;
                            }
                        }
                    }
                }
            }
        }
Example #10
0
        public long GetSize(IVersionable item)
        {
            long x = 0;

            long.TryParse(GetUserAttribute(item, "FileSize"), out x);
            return(x);
        }
Example #11
0
        public string GetReferenceItem(string agency, Guid id)
        {
            MultilingualString.CurrentCulture = "en-US";

            var client = ClientHelper.GetClient();

            // Retrieve the requested item from the Repository.
            // Populate the item's children, so we can display information about them.
            IVersionable item = client.GetLatestItem(id, agency,
                                                     ChildReferenceProcessing.Populate);
            // Use a graph search to find a list of all items that
            // directly reference this item.
            GraphSearchFacet facet = new GraphSearchFacet();

            facet.TargetItem            = item.CompositeId;
            facet.UseDistinctResultItem = true;

            var    referencingItemsDescriptions = client.GetRepositoryItemDescriptionsByObject(facet);
            string referenceItem = null;

            if (referencingItemsDescriptions.Count == 3)
            {
                referenceItem = referencingItemsDescriptions.Where(r => r.ItemType.ToString() == "91da6c62-c2c2-4173-8958-22c518d1d40d").FirstOrDefault().DisplayLabel;
            }
            return(referenceItem);
        }
Example #12
0
 public override void BeginVisitItem(IVersionable item)
 {
     if (!this.HaveVisited(item.CompositeId) && !item.IsDirty)
     {
         base.BeginVisitItem(item);
         if (!item.IsPopulated)
         {
             this.RepositoryClient.PopulateItem(
                 item,
                 true,
                 ChildReferenceProcessing.InstantiateLatest);
         }
         var latestChildren  = item.GetChildren();
         var currentChildren = this.RepositoryClient.GetItem(
             item.CompositeId,
             ChildReferenceProcessing.Instantiate).GetChildren();
         if (latestChildren.Count != currentChildren.Count)
         {
             item.IsDirty = true;
         }
         else
         {
             for (int i = 0; i < currentChildren.Count; i++)
             {
                 if (!latestChildren[i].CompositeId.Equals(
                         currentChildren[i].CompositeId))
                 {
                     item.IsDirty = true;
                     break;
                 }
             }
         }
     }
 }
        protected override void CheckObjectReadOnly()
        {
            bool isObjectReadOnly = false;
            ExchangeObjectVersion exchangeObjectVersion = ExchangeObjectVersion.Exchange2003;

            foreach (string name in this.dataObjectStore.GetKeys())
            {
                IVersionable versionable = this.dataObjectStore.GetDataObject(name) as IVersionable;
                if (versionable != null && versionable.IsReadOnly)
                {
                    isObjectReadOnly = true;
                }
                if (versionable != null && exchangeObjectVersion.IsOlderThan(versionable.ExchangeVersion))
                {
                    exchangeObjectVersion = versionable.ExchangeVersion;
                }
            }
            base.IsObjectReadOnly = isObjectReadOnly;
            if (base.IsObjectReadOnly)
            {
                base.ObjectReadOnlyReason = Strings.VersionMismatchWarning(exchangeObjectVersion.ExchangeBuild);
                return;
            }
            base.ObjectReadOnlyReason = string.Empty;
        }
Example #14
0
 /// <summary>
 ///     Manually compares the rowversion of the dbEntity to
 ///     the one passed in for updates.
 ///     Used for concurrency checks when records must stay detached
 ///     fromt the Context.
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="updater"></param>
 protected void CompareVersionOrThrow(IVersionable entity, IVersionable updater)
 {
     if (updater.Version == null || !entity.Version.SequenceEqual(updater.Version))
     {
         throw new DbUpdateConcurrencyException();
     }
 }
Example #15
0
        public virtual ContentIndexResult IndexContent(IContent content, bool includeChild = false)
        {
            SlimContentReader slimContentReader = new SlimContentReader(this._contentRepository, content.ContentLink, (c =>
            {
                return(includeChild);
            }));
            var listDocument = new List <SearchDocument>();

            while (slimContentReader.Next())
            {
                if (!slimContentReader.Current.ContentLink.CompareToIgnoreWorkID(ContentReference.RootPage))
                {
                    IVersionable current = slimContentReader.Current as IVersionable;
                    if (current == null || current.Status == VersionStatus.Published)
                    {
                        if (LuceneConfiguration.CanIndexContent(slimContentReader.Current))
                        {
                            var document = GetDocFromContent(slimContentReader.Current);
                            if (document != null)
                            {
                                listDocument.Add(document);
                            }
                        }
                    }
                }
            }
            _documentRepository.UpdateBatchIndex(listDocument);
            return(new ContentIndexResult());
        }
Example #16
0
        private bool?CheckRbacForNotAccessPermission(DataRow input, DataTable dataTable, DataObjectStore store, Variable variable, IEnumerable <Workflow> sets)
        {
            bool?flag = null;
            Collection <Activity> activities = base.Activities;
            bool hasDataObject = !string.IsNullOrWhiteSpace(variable.DataObjectName);

            foreach (Activity activity in activities)
            {
                flag = flag.Or(activity.FindAndCheckPermission((Activity a) => (hasDataObject && a is GetCmdlet && (a as GetCmdlet).DataObjectName == variable.DataObjectName) || a.HasOutputVariable(variable.Name), input, dataTable, store, variable));
                if (flag.IsTrue())
                {
                    break;
                }
            }
            if (hasDataObject)
            {
                IVersionable versionable = store.GetDataObject(variable.DataObjectName) as IVersionable;
                if (versionable != null && versionable.ExchangeVersion != null)
                {
                    PropertyDefinition propertyDefinition = versionable.ObjectSchema[variable.MappingProperty];
                    if (propertyDefinition != null && !versionable.IsPropertyAccessible(propertyDefinition))
                    {
                        flag = new bool?(false);
                    }
                }
            }
            return(flag);
        }
        /// <summary>
        /// Processing Test ID 001, 002, and 003
        /// Register Items with Repository
        /// </summary>
        /// <returns></returns>
        public static async Task RegisterItems(IVersionable item)
        {
            // First find all the items that should be registered.
            // The dirty item finder can collect new and changed items in a model
            var dirtyItemGatherer = new DirtyItemGatherer();

            item.Accept(dirtyItemGatherer);

            // Get an API client, windows or username
            var api = GetRepositoryApiWindows();

            // start a transaction
            var transaction = await api.CreateTransactionAsync();

            // Add all of the items to register to a transaction
            var addItemsRequest = new RepositoryTransactionAddItemsRequest();

            foreach (var itemToRegister in dirtyItemGatherer.DirtyItems)
            {
                addItemsRequest.Items.Add(VersionableToRepositoryItem(itemToRegister));
            }

            // commit the transaction, the Repository will handle the versioning
            var options = new RepositoryTransactionCommitOptions()
            {
                TransactionId   = transaction.TransactionId,
                TransactionType = RepositoryTransactionType.CommitAsLatestWithLatestChildrenAndPropagateVersions
            };
            var results = await api.CommitTransactionAsync(options);
        }
Example #18
0
 public static void SetUserAttribute(this IVersionable item, string key, DateTime?date)
 {
     if (date.HasValue)
     {
         item.SetUserAttribute(key, date.Value.ToString());
     }
 }
        public static bool IsNotModified(this Request request, IVersionable versionable)
        {
            if (!request.Headers.IfNoneMatch.Any())
            return false;

              var etag = request.Headers.IfNoneMatch.First();
              return string.Format("\"{0}\"", versionable.Version) == etag;
        }
 public static bool HasExpired(this IVersionable content)
 {
     if (content.Status == VersionStatus.Published && content.StopPublish < DateTime.Now)
     {
         return(true);
     }
     return(false);
 }
Example #21
0
 private void Increment(IVersionable item)
 {
     if (!incremented.Contains(item))
     {
         item.Version++;
         incremented.Add(item);
     }
 }
Example #22
0
 private void Dig(IVersionable item)
 {
     foreach (var child in item.GetChildren())
     {
         AddParent(child, item);
         Dig(child);
     }
 }
 private bool IsPublished(IVersionable content)
 {
     if (content == null)
     {
         return(true);
     }
     return(content.Status.HasFlag(VersionStatus.Published));
 }
 private bool Compare <T>(string[] ps, IVersionable A, IVersionable B)
 {
     if (Compare <T>(ps, (object)A, (object)B))
     {
         A.IsDirty = true;
         return(true);
     }
     return(false);
 }
        public override void EndVisitItem(IVersionable item)
        {
            base.EndVisitItem(item);

            var versionable = item as VersionableBase;
            if (versionable != null)
            {
                Console.WriteLine("Ending visit to " + DdiItemType.GetLabelForItemType(item.ItemType) + " " + versionable.DisplayLabel);
            }
        }
        public static bool IsNotModified(this Request request, IVersionable versionable)
        {
            if (!request.Headers.IfNoneMatch.Any())
            {
                return(false);
            }
            var etag = request.Headers.IfNoneMatch.First();

            return(string.Format("\"{0}\"", versionable.Version) == etag);
        }
        /// <summary>
        /// Called before the action result executes.
        /// </summary>
        /// <param name="filterContext">The filter context, which encapsulates information for using <see cref="T:System.Web.Mvc.AuthorizeAttribute"/>.</param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="filterContext"/> parameter is null.</exception>
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            if (Disable)
            {
                return;
            }

            if (!_initialized)
            {
                //If no values are set on attrbute take default values from config
                if (Duration == 0)
                {
                    Duration = Convert.ToInt32(ConfigurationSettings.Service.HttpCacheExpiration.TotalSeconds);
                }
                if (String.IsNullOrEmpty(VaryByCustom))
                {
                    VaryByCustom = ConfigurationSettings.Service.HttpCacheVaryByCustom;
                }
                _initialized = true;
            }

            var contentLink = filterContext.RequestContext.GetContentLink();

            if (!ContentReference.IsNullOrEmpty(contentLink))
            {
                DateTime now = DateTime.Now;

                IVersionable versionable = ContentLoader.Service.Get <IContent>(contentLink) as IVersionable;
                if (versionable != null && versionable.StopPublish.HasValue)
                {
                    if (versionable.StopPublish < now)
                    {
                        return;
                    }

                    if (versionable.StopPublish.Value < now.AddSeconds(Duration))
                    {
                        Duration = Convert.ToInt32((versionable.StopPublish.Value - now).TotalSeconds);
                    }
                }

                var duration = new TimeSpan(0, 0, Duration);
                var refresh  = new TimeSpan(0, 0, Refresh == 0 ? Math.Max(0, Duration - 10) : Refresh);

                if (UseOutputCacheValidator(filterContext.HttpContext.User, filterContext.HttpContext, duration))
                {
                    base.OnResultExecuting(filterContext);
                    filterContext.HttpContext.Response.Cache.AddValidationCallback(new HttpCacheValidateHandler(BurstOutputCacheHandler.ValidateOutputCache),
                                                                                   new BurstOutputCacheHandler.State(
                                                                                       ConfigurationSettings.Service,
                                                                                       DataFactoryCache.Version,
                                                                                       now + refresh));
                }
            }
        }
Example #28
0
 private void AddParent(IVersionable item, IVersionable parent)
 {
     if (!parents.ContainsKey(item))
     {
         parents[item] = new List <IVersionable>();
     }
     if (!parents[item].Contains(parent))
     {
         parents[item].Add(parent);
     }
 }
        public static QuestionModel GetAllQuestions(QuestionModel model, string agency, Guid id, string itemType)
        {
            MultilingualString.CurrentCulture = "en-GB";

            var client = ClientHelper.GetClient();

            IVersionable item = client.GetLatestItem(id, agency,
                                                     ChildReferenceProcessing.Populate);

            var studyUnit = item as StudyUnit;

            //var studyModel = new List<RepositoryItemMetadata>();
            //studyModel.StudyUnit = studyUnit;

            foreach (var qualityStatement in studyUnit.QualityStatements)
            {
                client.PopulateItem(qualityStatement);
            }

            // Use a set search to get a list of all questions that are referenced
            // by the study. A set search will return items that may be several steps
            // away.
            SetSearchFacet setFacet = new SetSearchFacet();

            setFacet.ItemTypes.Add(DdiItemType.QuestionItem);

            var matches = client.SearchTypedSet(studyUnit.CompositeId,
                                                setFacet);
            var infoList = client.GetRepositoryItemDescriptions(matches.ToIdentifierCollection());

            foreach (var info in infoList)
            {
                model.AllQuestions.Add(info);
                var references = Helper.GetReferences(info.AgencyId, info.Identifier);

                foreach (var reference in references)
                {
                    if (itemType == "Variable")
                    {
                        if (reference.ItemType == new Guid("683889c6-f74b-4d5e-92ed-908c0a42bb2d"))
                        {
                            reference.ItemType = info.Identifier;
                            model.AllVariables.Add(reference);
                        }
                    }
                    if (reference.ItemType == new Guid("5cc915a1-23c9-4487-9613-779c62f8c205"))
                    {
                        reference.ItemType = info.Identifier;
                        model.AllConcepts.Add(reference);
                    }
                }
            }
            return(model);
        }
        private void bindingSource_ListChanged(object sender, ListChangedEventArgs e)
        {
            BindingSource bindingSource = (BindingSource)sender;
            IVersionable  versionable   = bindingSource.DataSource as IVersionable;

            if (versionable != null)
            {
                if (!this.datasourceVersions.ContainsKey(bindingSource))
                {
                    this.datasourceVersions[bindingSource] = versionable.ExchangeVersion;
                    this.DisableControlsByVersion(bindingSource, versionable);
                    return;
                }
                ExchangeObjectVersion exchangeObjectVersion = this.datasourceVersions[bindingSource];
                if (!exchangeObjectVersion.IsSameVersion(versionable.ExchangeVersion))
                {
                    this.datasourceVersions[bindingSource] = versionable.ExchangeVersion;
                    this.EnableControlsByVersion(bindingSource, versionable);
                    return;
                }
            }
            else
            {
                DataTable dataTable = bindingSource.DataSource as DataTable;
                if (dataTable != null)
                {
                    DataObjectStore dataObjectStore = dataTable.ExtendedProperties["DataSourceStore"] as DataObjectStore;
                    if (dataObjectStore != null)
                    {
                        foreach (string text in dataObjectStore.GetKeys())
                        {
                            IVersionable versionable2 = dataObjectStore.GetDataObject(text) as IVersionable;
                            if (versionable2 != null)
                            {
                                if (this.dataSourceInTableVersions.ContainsKey(text))
                                {
                                    ExchangeObjectVersion exchangeObjectVersion2 = this.dataSourceInTableVersions[text];
                                    if (!exchangeObjectVersion2.IsSameVersion(versionable2.ExchangeVersion))
                                    {
                                        this.dataSourceInTableVersions[text] = versionable2.ExchangeVersion;
                                        this.EnableControlsByVersion(bindingSource, versionable2);
                                    }
                                }
                                else
                                {
                                    this.dataSourceInTableVersions[text] = versionable2.ExchangeVersion;
                                    this.DisableControlsByVersion(bindingSource, versionable2);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #31
0
        /// <summary>
        /// Apply version if entry is versionable
        /// </summary>
        /// <param name="entry"></param>
        protected virtual void ApplyVersionProperties(DbEntityEntry entry)
        {
            //TODO: Analizar como aplicar conceptos.. globales... ABP
            //TODO: JSA que pase si existe un error se debe reversar la version???
            IVersionable entityVersionable = entry.Entity as IVersionable;

            if (entityVersionable != null)
            {
                entityVersionable.VersionRegistro = entityVersionable.VersionRegistro + 1;
            }
        }
 public static VersionStatus Status(this IVersionable content)
 {
     if (content is IContentMedia)
     {
         IContent assetOwner = ServiceLocator.Current.GetInstance <ContentAssetHelper>().GetAssetOwner((content as IContent).ContentLink);
         if (ObjectExtensions.IsNotNull((object)assetOwner) && assetOwner is IVersionable)
         {
             return((assetOwner as IVersionable).Status);
         }
     }
     return(content.Status);
 }
        /// <summary>
        /// Executes when an item is created.
        /// </summary>
        /// <param name="item">The item being created.</param>
        public void Execute(IVersionable item)
        {
            // Cast the item as a StudyUnit, and make sure it is what we expect.
            var studyUnit = item as StudyUnit;
            if (studyUnit == null)
            {
                return;
            }

            // Initialize the abstract.
            studyUnit.StudyAbstract.Current = "Hello, world.";

            // Initialize the copyright property of the Dublin Core metadata.
            studyUnit.DublinCoreMetadata.Rights.Current =
                "Created as a Sample.";
        }
        public ElasticLease(
            Guid leasedResourceId, 
            DateTime expires, 
            ElasticLeaseOwner owner, 
            long version = -1)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            this._id = leasedResourceId;
            this._expires = expires;
            this._owner = owner;
            this.versioning = new VersioningMixin(version);
        }
Example #35
0
		public static bool Build(ILogger logger, IVersionable component, string packagesOutputDirectory)
		{
			var componentName = component.Name;
			var version = component.CurrentVersion.ToString();
			if (component is IProject) {
				logger.Info("Building {0}.{1}", componentName, version);
				if (!(component as IProject).Build(logger)) {
					logger.Error("Could not build component '{0}'", componentName);
					return false;
				}
			}
			if (component is INugetSpec) {
				logger.Info("Packaging {0}.{1}", componentName, version);
				if (!(component as INugetSpec).Pack(logger, packagesOutputDirectory)) {
					logger.Error("Could not package component '{0}'", componentName);
					return false;
				}
			}
			return true;
		}
 public static SaveAction GetForcedSaveActionFor(IVersionable page)
 {
     var saveAction = SaveAction.SkipValidation | SaveAction.ForceCurrentVersion;
     switch (page.Status)
     {
         case VersionStatus.Published:
             saveAction = saveAction | SaveAction.Publish;
             break;
         case VersionStatus.CheckedIn:
             saveAction = saveAction | SaveAction.CheckIn;
             break;
         default:
             saveAction = saveAction | SaveAction.Save;
             break;
     }
     return saveAction;
 }
 public VersionableItemViewModelBase GetViewModelForItem(IVersionable item)
 {
     return new VersionableItemViewModelBase<OrganizationScheme>(item as OrganizationScheme);
 }
Example #38
0
        private static bool IsPublished(IVersionable versionableContent)
        {
            var isPublished = versionableContent.Status == VersionStatus.Published;

            if (!isPublished || versionableContent.IsPendingPublish)
            {
                return false;
            }

            var now = DateTime.Now.ToUniversalTime();
            var startPublish = versionableContent.StartPublish.GetValueOrDefault(DateTime.MinValue).ToUniversalTime();
            var stopPublish = versionableContent.StopPublish.GetValueOrDefault(DateTime.MaxValue).ToUniversalTime();

            if (startPublish > now || stopPublish < now)
            {
                return false;
            }

            return true;
        }
		private static bool BumpUp(ILogger logger, IVersionable component, VersionPart partToBump)
		{
			var componentName = component.Name;
			Version currentVersion = component.CurrentVersion;
			Version newVersion = currentVersion.Bump(partToBump);
			if (component.SetNewVersion(logger, newVersion)) {
				logger.Info("Bumped component '{0}' version from {1} to {2}", componentName, currentVersion.ToString(), newVersion.ToString());
				return true;
			}
			logger.Error("Could not bump component '{0}' version to {1}", componentName, newVersion.ToString());
			return false;
		}
		private bool BumpVersion(ILogger logger, IVersionable component, VersionPart partToBump, string packagesOutputDirectory, bool noBuild)
		{
			var componentsToRebuild = new List<IProject>();
			logger.Info("Bumping versions. Affected version part: {0} number", partToBump);
			using (logger.Block) {
				if (!BumpUp(logger, component, partToBump))
					return false;
				foreach (IComponent dependentComponent in component.DependentComponents) {
					if (dependentComponent is IVersionable) {
						var versionableComponent = (IVersionable)dependentComponent;
						if (BumpUp(logger, versionableComponent, versionableComponent.PartToCascadeBump(partToBump)))
							if (dependentComponent is IProject)
								componentsToRebuild.Add((IProject)dependentComponent);
					}
				}
			}
			if (noBuild)
				return true;
			logger.Info("Rebuilding bumped components");
			return BuildHelper.BuildChain(logger, component, packagesOutputDirectory, componentsToRebuild);
		}
 public void Initialize(IVersionable item)
 {
     var study = item as StudyUnit;
     this.DataContext = new SampleVersionableViewModel(study);
 }
 public static Negotiator WithCacheHeaders(this Negotiator response, IVersionable versionable, TimeSpan? maxAge = null)
 {
     return response.WithHeaders(
     new { Header = "ETag", Value = string.Format("\"{0}\"", versionable.Version) },
     new { Header = "Cache-Control", Value = string.Format("max-age={0}, public", maxAge ?? TimeSpan.FromSeconds(10)) });
 }
 private bool IsPublished(IVersionable content)
 {
     if (content == null)
         return true;
     return content.Status.HasFlag(VersionStatus.Published);
 }
Example #44
0
		public static bool BuildChain(ILogger logger, IVersionable component, string packagesOutputDirectory, IEnumerable<IProject> componentsToRebuild)
		{
			using (logger.Block) {
				if (!BuildAndUpdate(logger, component, packagesOutputDirectory))
					return false;
				foreach (IProject dependentComponent in componentsToRebuild)
					if (!BuildAndUpdate(logger, dependentComponent, packagesOutputDirectory))
						return false;
			}
			return true;
		}
 /// <summary>
 /// Called when an item is selected from the ItemPicker.
 /// </summary>
 /// <param name="referencingItem">The item that should reference the selected item.</param>
 /// <param name="item">The item that was selected from the ItemPicker.</param>
 public void HandleSelectedItem(IVersionable referencingItem, object item)
 {
     // It is not necessary to implement this method unless the selection requires
     // special handling. Otherwise, the reference will be added like normal.
 }
 public ElasticContactIdentityMap(string identity, Guid contactId, long version = -1)
 {
     this.identity = identity;
     this.contactId = contactId;
     this.versioning = new VersioningMixin(version);
 }
Example #47
0
 /// <summary>
 ///     Creates and shows a new about window in modal mode
 /// </summary>
 /// <param name="versionInfo">A <see cref="IVersionable" /> containing the information to display on the window</param>
 public static void ShowWindow(IVersionable versionInfo)
 {
     (new AboutDialogWindow {DataContext = versionInfo}).ShowDialog();
 }
Example #48
0
		private static bool BuildAndUpdate(ILogger logger, IVersionable component, string packagesOutputDirectory)
		{
			if (!BuildHelper.Build(logger, component, packagesOutputDirectory))
				return false;
			if (!BuildHelper.UpdatePackageDependency(logger, component as INugetSpec, packagesOutputDirectory))
				return false;
			return true;
		}
 public void Initialize(Algenta.Colectica.Navigator.NodeTypes.Node node, IVersionable item)
 {
     throw new NotImplementedException();
 }