Esempio n. 1
0
 public Item(Category category, string owner,
             string title, string description,
             string url, string urlName, DateTime newsDate, DateTime?expiry, ItemApprovalStatus approvalStatus)
 {
     Owner          = owner;
     Title          = title;
     Author         = owner;
     Category       = category;
     Description    = description;
     URL            = url;
     URLName        = urlName;
     NewsDate       = newsDate;
     Expiry         = expiry;
     ApprovalStatus = approvalStatus;
 }
Esempio n. 2
0
        public static Item GetPublishedItem(string groupId)
        {
            IList <VersionItem> versions       = VersionManager.GetAllVersions(groupId);
            List <Item>         publishedItems = new List <Item>();

            foreach (VersionItem version in versions)
            {
                Item newsItem = GetItem(version.ItemId);
                ItemApprovalStatus approvalStatus = ItemApprovalStatusManager.GetStatusByName("Published");
                if (newsItem.ApprovalStatus.Id.Equals(approvalStatus.Id))
                {
                    publishedItems.Add(newsItem);
                }
            }
            if (publishedItems.Count > 0)
            {
                return(publishedItems.OrderByDescending(x => x.InsertDate).First <Item>());
            }
            else
            {
                return(new Item());
            }
        }
Esempio n. 3
0
 public abstract Item CreateItem(Category category, string owner,
                                 string title, string description,
                                 string url, string urlName,
                                 DateTime newsDate, bool acknowledge, bool approve, string groups, Attachment.FileInfo attachment, DateTime?expiry, ItemApprovalStatus approvalStatus);
Esempio n. 4
0
 private Item CreateItem(Category category, string owner, string title, string content, ItemApprovalStatus approvalStatus)
 {
     return(NewsManager.CreateItem(
                category,
                owner,
                title,
                content,
                "",
                "",
                DateTime.Now,
                rblAcknowledge.Items.FindByValue("required").Selected,
                rblApproval.Items.FindByValue("required").Selected,
                "",
                null,
                null, approvalStatus
                ));
 }
Esempio n. 5
0
    private void SaveItem(Category category, SaveType saveType)
    {
        if (txtTitle.Text.Length >= 100)
        {
            ((IFeedback)Page.Master).SetError(GetType(), "The announcement title must be less than 100 characters long");
            return;
        }
        Item.Category    = category;
        Item.Description = txtDescription.Content;
        Item.Title       = txtTitle.Text;
        Item.Tag         = rblAcknowledge.Items.FindByValue("required").Selected.ToString() + ":" +
                           rblApproval.Items.FindByValue("required").Selected.ToString();
        //Item.Expiry = rdpExpiry.SelectedDate;

        string versionId = VersionId;

        if (string.IsNullOrEmpty(versionId))
        {
            versionId = NewVersionId;
        }

        VersionItem versionItem = VersionManager.GetVersionById(versionId);
        VersionType versionType = VersionType.Draft;

        string GroupID       = Item.Id;
        string VersionNumber = VersionManager.GetVersionNumber(VersionType.New, string.Empty);

        ItemApprovalStatus approvalStatus = new ItemApprovalStatus();

        if (rblApproval.SelectedValue.Equals("required"))
        {
            if (saveType == SaveType.CheckIn)
            {
                approvalStatus = ItemApprovalStatusManager.GetDraftStatus();
            }
            else if (saveType == SaveType.Publish)
            {
                approvalStatus = (Item.Author.Equals(Utilities.GetUserName(Page.User.Identity.Name)) == true) ?
                                 ItemApprovalStatusManager.GetForApprovalStatus() : Item.ApprovalStatus = ItemApprovalStatusManager.GetForEditApprovalStatus();
            }
            else
            {
                approvalStatus = new ItemApprovalStatus()
                {
                    Id = string.Empty, Name = string.Empty
                }
            };
        }
        else
        {
            if (saveType == SaveType.CheckIn)
            {
                approvalStatus = ItemApprovalStatusManager.GetDraftStatus();
            }
            else if (saveType == SaveType.Publish)
            {
                approvalStatus = ItemApprovalStatusManager.GetStatusByName("Published");
                versionType    = (rblEditDetails.SelectedIndex == 0) ? VersionType.Minor : VersionType.Major;
            }
        }

        if (versionItem != null)
        {
            //Create a new record only when saving after editing an existing version
            //if it's being put on hold then don't create a new record
            if (saveType == SaveType.Hold)
            {
                NewsManager.UpdateItem(Item);
            }
            else
            {
                Item = CreateItem(category, ddlOwner.SelectedItem.Text, txtTitle.Text, txtDescription.Content, approvalStatus);
            }
            GroupID       = versionItem.GroupId;
            VersionNumber = VersionManager.GetVersionNumber(versionType, versionItem.ItemId);
        }
        //this applies to announcements when they don't have any versions previously.
        else
        {
            Item.ApprovalStatus = approvalStatus;
            NewsManager.UpdateItem(Item);
        }
        //save version item only when checkin or publish.
        if (saveType != SaveType.Hold)
        {
            NewVersionId = SaveVersionItem(GroupID, VersionNumber, saveType);
        }
    }
        public override Item CreateItem(Category category, string owner,
                                        string title, string description, string url, string urlName,
                                        DateTime newsDate, bool acknowledge, bool approve, string groups,
                                        Attachment.FileInfo attachment, DateTime?expiry, ItemApprovalStatus approvalStatus)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                ItemDataStore dataStore = new ItemDataStore(transaction);

                Item item = new Item(category, owner, title, description, url, urlName, newsDate, expiry, approvalStatus);
                item.Tag        = acknowledge.ToString() + ":" + approve.ToString();
                item.Groups     = groups;
                item.Attachment = attachment;

                dataStore.Insert(item);
                transaction.Commit();
                return(item);
            }
        }
Esempio n. 7
0
 public static Item CreateItem(Category category, string owner,
                               string title, string description,
                               string url, string urlName,
                               DateTime newsDate, bool acknowledge, bool approve, string groups, Attachment.FileInfo attachment, DateTime?expiry, ItemApprovalStatus approvalStatus)
 {
     return(Provider.CreateItem(category, owner, title, description, url, urlName, newsDate, acknowledge, approve, groups, attachment, expiry, approvalStatus));
 }