Example #1
0
        /// <summary>Creates the assignment folder.</summary>
        /// <param name="properties">The assignment properties.</param>
        /// <returns>The assignment folder.</returns>
        public AssignmentFolder CreateAssignmentFolder(AssignmentProperties properties)
        {
            string url = DropBoxList.RootFolder.ServerRelativeUrl;

            SPFolder noPermissionsFolder = GetNoPermissionsFolder().Folder;

            using (new AllowUnsafeUpdates(web))
            {
                string   name   = GenerateFolderName(properties);
                SPFolder folder = noPermissionsFolder.SubFolders.Add(name);
                folder.MoveTo(url + "\\" + name);
                folder.Update();
                SPListItem assignmentFolder = folder.Item;
                DropBoxCreator.ClearPermissions(assignmentFolder);
                DropBoxList.Update();
                CreateAssignmentView(properties);
                return(new AssignmentFolder(assignmentFolder, false, properties));
            }
        }
Example #2
0
 public void MoveTo(string strNewUrl)
 {
     m_folder.MoveTo(strNewUrl);
 }
Example #3
0
        public void Save(SPWeb web, bool addTemplates = true)
        {
            SPListItem briefingItem = null;
            SPList     list         = web.Lists[ListId];
            string     folderName   = FileUtil.CleanForUrlAndFileNameUse(Title);

            if (Id.HasValue)
            {
                briefingItem = list.GetItemById(Id.Value);
                briefingItem["FileLeafRef"] = folderName;
                BriefingNumber = (string)briefingItem[BriefingFields.BriefingNumberId];
            }
            else
            {
                if (string.IsNullOrEmpty(Category))
                {
                    briefingItem = list.AddItem(list.RootFolder.Url, SPFileSystemObjectType.Folder, folderName);
                }
                else
                {
                    string folderUrl = SPUrlUtility.CombineUrl(list.RootFolder.Url, Category);
                    if (web.GetFolder(folderUrl).Exists)
                    {
                        briefingItem = list.AddItem(folderUrl, SPFileSystemObjectType.Folder, folderName);
                    }
                    else
                    {
                        briefingItem = list.AddItem(list.RootFolder.Url, SPFileSystemObjectType.Folder, folderName);
                    }
                }

                SPContentType ctype = list.ContentTypes[list.ContentTypes.BestMatch(ContentTypes.BriefingContentTypeId)];
                briefingItem[SPBuiltInFieldId.ContentTypeId] = ctype.Id;
                briefingItem[SPBuiltInFieldId.ContentType]   = ContentTypes.BriefingContentTypeName;
                if (string.IsNullOrEmpty(BriefingNumber))
                {
                    BriefingNumber = Config.System.CurrentSystem == SystemType.Poline ? BriefingNumbers.GetNextPolineNumber(StartEventDate.Value.Year) : BriefingNumbers.GetNextNumber(web, StartEventDate.Value);
                }
                briefingItem[BriefingFields.BriefingNumberId] = BriefingNumber;
            }

            briefingItem[BriefingFields.BriefingTitleId]  = Title;
            briefingItem[BriefingFields.StartEventDateId] = StartEventDate;
            briefingItem[BriefingFields.EndEventDateId]   = EndEventDate;
            if (briefingItem.Fields.ContainsField(BriefingFields.IsProtectedName))
            {
                briefingItem[BriefingFields.IsProtectedName] = IsProtected;
            }
            briefingItem[BriefingFields.LocationId]             = Location;
            briefingItem[BriefingFields.MainTopicsId]           = Topics;
            briefingItem[BriefingFields.RequestDateName]        = RequestDate;
            briefingItem[BriefingFields.DraftDeadlineId]        = DraftDeadline;
            briefingItem[BriefingFields.FinalDeadlineId]        = FinalDeadline;
            briefingItem[BriefingFields.ServicesDeadlineId]     = ServicesDeadline;
            briefingItem[BriefingFields.CabMemberResponsibleId] = CabMemberResponsibleValue;
            SPFieldUserValueCollection PrevSGResponsibleValue = briefingItem[BriefingFields.SGResponsibleId] as SPFieldUserValueCollection ?? new SPFieldUserValueCollection();

            if (SGResponsibleValue.Count != PrevSGResponsibleValue.Count ||
                SGResponsibleValue.Except(PrevSGResponsibleValue, new SPFieldUserValueComparer()).Any())
            {
                briefingItem.Properties[PREVIOUS_SGRESPONSIBLE_KEY] = string.Join(",", PrevSGResponsibleValue.Select(user => user.User.LoginName).ToArray());
            }
            briefingItem[BriefingFields.SGResponsibleId]    = SGResponsibleValue;
            briefingItem[BriefingFields.OtherResponsibleId] = OtherResponsibleValue;
            briefingItem[BriefingFields.UnitResponsibleId]  = UnitResponsibleValue;
            briefingItem[BriefingFields.LinkToReportId]     = LinkToReport;
            briefingItem[BriefingFields.UrgentRequestId]    = UrgentRequest;
            briefingItem[BriefingFields.BriefingUrgencyId]  = NumberOfDaysValue;
            briefingItem[BriefingFields.CancelledId]        = EventCancelled;
            briefingItem[BriefingFields.BeneficiaryId]      = Beneficiary;
            briefingItem[BriefingFields.CommentsId]         = Comments;
            briefingItem[BriefingFields.FinalizedName]      = Finalized;
            briefingItem[BriefingFields.NoteTakerId]        = NoteTakerValue;

            if (briefingItem.Fields.Contains(BriefingFields.Language))
            {
                briefingItem[BriefingFields.Language] = Language;
            }
            if (briefingItem.Fields.Contains(BriefingFields.AdditionalDocuments))
            {
                briefingItem[BriefingFields.AdditionalDocuments] = AdditionalDocumentsValue.ToString();
            }
            if (briefingItem.Fields.Contains(BriefingFields.PrintedCopies))
            {
                briefingItem[BriefingFields.PrintedCopies] = PrintedCopies;
            }
            if (briefingItem.Fields.Contains(BriefingFields.WhoHasRequestedMeeting))
            {
                briefingItem[BriefingFields.WhoHasRequestedMeeting] = WhoHasRequestedMeeting;
            }
            if (briefingItem.Fields.Contains(BriefingFields.ParticipantsCommission))
            {
                briefingItem[BriefingFields.ParticipantsCommission] = ParticipantsCommission;
            }
            if (briefingItem.Fields.Contains(BriefingFields.ParticipantsInterlocutors))
            {
                briefingItem[BriefingFields.ParticipantsInterlocutors] = ParticipantsInterlocutors;
            }
            if (briefingItem.Fields.Contains(BriefingFields.HaveTheyMetBefore))
            {
                briefingItem[BriefingFields.HaveTheyMetBefore] = HaveTheyMetBefore;
            }
            if (briefingItem.Fields.Contains(BriefingFields.MetInWhichCapacity))
            {
                briefingItem[BriefingFields.MetInWhichCapacity] = MetInWhichCapacity;
            }
            if (briefingItem.Fields.Contains(BriefingFields.MetWhen))
            {
                briefingItem[BriefingFields.MetWhen] = MetWhen;
            }
            if (briefingItem.Fields.Contains(BriefingFields.PreviousCommitmentsControversies))
            {
                briefingItem[BriefingFields.PreviousCommitmentsControversies] = PreviousCommitmentsControversies;
            }
            if (briefingItem.Fields.Contains(BriefingFields.WhatDoTheyWant))
            {
                briefingItem[BriefingFields.WhatDoTheyWant] = WhatDoTheyWant;
            }
            if (briefingItem.Fields.Contains(BriefingFields.WhatDoWeWant))
            {
                briefingItem[BriefingFields.WhatDoWeWant] = WhatDoWeWant;
            }
            if (briefingItem.Fields.Contains(BriefingFields.MeetingTopics))
            {
                briefingItem[BriefingFields.MeetingTopics] = MeetingTopics;
            }

            if (briefingItem.Fields.Contains(BriefingFields.HermesLinkId) && briefingItem.Fields.Contains(BriefingFields.HermesReferenceId))
            {
                ARESLink      = (string)briefingItem[BriefingFields.HermesLinkId];
                ARESReference = (string)briefingItem[BriefingFields.HermesReferenceId];
            }

            briefingItem.Update();

            ServerRelativeUrl = briefingItem.Folder.ServerRelativeUrl;

            SPUserToken userToken = SPContext.Current.Site.UserToken;
            Guid        siteId    = web.Site.ID;
            Guid        webId     = web.ID;
            int         itemId    = briefingItem.ID;

            if (Id.HasValue)
            {
                if (briefingItem.Folder.ParentFolder.Name != Category)
                {
                    SPFolder folder = briefingItem.Folder;
                    if (string.IsNullOrEmpty(Category))
                    {
                        ServerRelativeUrl = SPUrlUtility.CombineUrl(list.RootFolder.ServerRelativeUrl, folderName);
                    }
                    else
                    {
                        ServerRelativeUrl = SPUrlUtility.CombineUrl(SPUrlUtility.CombineUrl(list.RootFolder.ServerRelativeUrl, Category), folderName);
                    }
                    if (briefingItem.Folder.ServerRelativeUrl != ServerRelativeUrl)
                    {
                        folder.MoveTo(ServerRelativeUrl);
                        briefingItem = list.GetItemById(Id.Value);
                    }
                }
            }
            else
            {
                HostingEnvironment.QueueBackgroundWorkItem(token => copyTemplatesAsync(siteId, webId, ListId, itemId, userToken, addTemplates, IsProtected));
            }

            string bn = Id.HasValue ? BriefingNumber : web.CurrentUser.LoginName.Substring(web.CurrentUser.LoginName.LastIndexOf("|") + 1) + "-new-briefing";

            HostingEnvironment.QueueBackgroundWorkItem(token => saveAdditionalDocumentsAsync(siteId, webId, userToken, ListId, itemId, bn, AdditionalDocuments));

            Id              = briefingItem.ID;
            UniqueId        = briefingItem.Folder.UniqueId;
            Modified        = ((DateTime)briefingItem[SPBuiltInFieldId.Modified]).ToString();
            ModifiedBy      = new SPFieldUserValue(web, (string)briefingItem[SPBuiltInFieldId.Editor]).LookupValue;
            BasePermissions = briefingItem.EffectiveBasePermissions.ToString();

            HostingEnvironment.QueueBackgroundWorkItem(token => ensureBriefingProtectedAsync(siteId, webId, ListId, itemId, IsProtected));
        }