示例#1
0
 /// <summary>
 /// Returns the latest version.
 /// </summary>
 /// <param name="groupId"></param>
 /// <returns></returns>
 public override VersionItem GetVersionByGroupId(string groupId)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var vDTS = new VersionItemDataStore(transaction);
         return(vDTS.FindVersionByGroupId(groupId));
     }
 }
示例#2
0
 public override IList <VersionItem> GetAllVersions(string groupId)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var vDTS = new VersionItemDataStore(transaction);
         return(vDTS.FindAllByGroupId(groupId));
     }
 }
示例#3
0
 public override void UpdateVersionItem(VersionItem item)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var vDTS = new VersionItemDataStore(transaction);
         vDTS.Update(item);
         transaction.Commit();
     }
 }
示例#4
0
 public override VersionItem GetVersionByItemId(string itemId)
 {
     //find the
     using (var transaction = new TransactionScope(_configuration))
     {
         var vDTS = new VersionItemDataStore(transaction);
         return(vDTS.FindGroupIdByItemId(itemId));
     }
 }
示例#5
0
 /// <summary>
 /// Finds all published versions of the item
 /// </summary>
 /// <param name="versionId"></param>
 public override IList <VersionItem> GetPublishedVersions(string groupId)
 {
     //pass in the group ID.
     // return the version item list with status as published in desc
     using (var transaction = new TransactionScope(_configuration))
     {
         var vDTS = new VersionItemDataStore(transaction);
         return(vDTS.FindPublishedVersions(groupId));
     }
 }
示例#6
0
 public override void CheckOutVersion(string versionId, string userName)
 {
     using (var transaction = new TransactionScope(_configuration))
     {
         var         vDTS    = new VersionItemDataStore(transaction);
         VersionItem version = vDTS.FindGroupIdByVersionId(versionId);
         version.UserName = userName;
         vDTS.Update(version);
         transaction.Commit();
     }
 }
示例#7
0
        public string GetNextVersionNumber(VersionType versionType, string itemId)
        {
            string versionNumber = string.Empty;

            //find the version item with the id
            // pass in the versionnumber

            using (var transaction = new TransactionScope(_configuration))
            {
                var vDTS = new VersionItemDataStore(transaction);

                //VersionItem item = vDTS.FindAll().First<VersionItem>(x => x.ItemId.Equals(ItemId));
                VersionItem item          = vDTS.FindGroupIdByItemId(itemId);
                VersionItem latestVersion = vDTS.FindVersionByGroupId(item.GroupId);
                return(GenerateVersionNumber(versionType, latestVersion.VersionNumber));
            }
        }
示例#8
0
        /// <summary>
        /// Accepts groupId and Returns username of the person who has the item checked out.
        /// </summary>
        /// <param name="groupId"></param>
        /// <returns></returns>
        public override string GetCheckedOutUser(string groupId)
        {
            using (var transaction = new TransactionScope(_configuration))
            {
                string userName = string.Empty;
                var    vDTS     = new VersionItemDataStore(transaction);

                IList <VersionItem> versions = vDTS.FindAllByGroupId(groupId);
                foreach (VersionItem version in versions)
                {
                    if (!string.IsNullOrEmpty(version.UserName))
                    {
                        userName = version.UserName;
                        break;
                    }
                }
                return(userName);
            }
        }
示例#9
0
        public override void CheckInVersion(string versionId)
        {
            if (string.IsNullOrEmpty(versionId))
            {
                throw new ArgumentNullException("versionId");
            }

            using (var transaction = new TransactionScope(_configuration))
            {
                var                 vDTS     = new VersionItemDataStore(transaction);
                VersionItem         version  = vDTS.FindGroupIdByVersionId(versionId);
                IList <VersionItem> versions = vDTS.FindAllByGroupId(version.GroupId);
                foreach (VersionItem vers in versions)
                {
                    vers.UserName = null;
                    vDTS.Update(vers);
                }
                transaction.Commit();
            }
        }
示例#10
0
        public override IList <VersionItem> GetRespectivePublishedVersions(string groupId, string versionNumber)
        {
            //pass in the group ID.
            // return the version item list with status as published in desc
            string versionMajorSuffix = versionNumber.Split('.').First();

            using (var transaction = new TransactionScope(_configuration))
            {
                var vDTS = new VersionItemDataStore(transaction);
                IList <VersionItem> pubVersions = vDTS.FindPublishedVersions(groupId);
                foreach (VersionItem version in pubVersions)
                {
                    string tempMajorSuffix = version.VersionNumber.Split('.').First();
                    if (!tempMajorSuffix.Equals(versionMajorSuffix))
                    {
                        pubVersions.RemoveAt(pubVersions.IndexOf(version));
                    }
                }
                return(pubVersions);
            }
        }
示例#11
0
        /// <summary>
        /// Returns list of all the latest drafts
        /// </summary>
        /// <returns></returns>
        public override List <VersionItem> GetAllLatestDrafts()
        {
            using (var transaction = new TransactionScope(_configuration))
            {
                var vDTS = new VersionItemDataStore(transaction);
                IList <VersionItem> allVersions = vDTS.FindAll();
                List <VersionItem>  A           = new List <VersionItem>(); //get only unique group ids
                List <VersionItem>  B           = new List <VersionItem>(); //get all group IDs
                List <VersionItem>  C           = new List <VersionItem>(); // the list with latest versions only

                //iterate through all version items.
                //put unique groupIds in one list
                //use that list to iterate through the versionItems again and retrieve the latest of all version for the particular groupID
                foreach (VersionItem item in allVersions)
                {
                    if (B.Count > 0 && B.Exists(x => x.GroupId.Equals(item.GroupId)) == true)
                    {
                        B.Add(item);
                    }
                    else
                    {
                        A.Add(item);
                        B.Add(item);
                    }
                    //get groupID
                    //add to list
                }

                foreach (VersionItem itemA in A)
                {
                    C.Add(vDTS.FindVersionByGroupId(itemA.GroupId));
                }
                //return the list which has the version items with only latest draft.
                return(C);
            }
        }