private async void LoadContentItem()
        {
            Loading     = true;
            ContentItem = await _contentService.GetContentItem(Mph.BaseUrl, _contentItemId);

            Loading = false;
        }
        private void goBack()
        {
            if (IsLoading)
            {
                IsLoading = false;
            }

            if (selectedFolder == null)
            {
                return;
            }

            var previousItem = selectedFolder.Parent;

            if (previousItem != null)
            {
                if (previousItem.IsRoot || selectedFolder.IsDeepLink)
                {
                    SelectedItem = previousItem;
                    return;
                }

                selectedItem   = previousItem;
                SelectedFolder = selectedItem;

                if (selectedItem.IsChannel)
                {
                    SelectedChannel = selectedItem;
                }

                OnPropertyChanged("SelectedItem");
                updateBreadcrumbs();
            }
        }
Esempio n. 3
0
 protected virtual async Task <TPublishRecord> GetRecordAsync(IContentItem entity, Site site, bool allSites)
 {
     return(await _dbContext.Set <TPublishRecord>()
            .FirstOrDefaultAsync(r =>
                                 r.Type == entity.GetKey() && r.ContentId == entity.Id &&
                                 (allSites || r.SiteIds.Contains(site.Id))));
 }
Esempio n. 4
0
 public void DeleteContent(IContentItem contentItem)
 {
     using (IndexBuilder indexBuilder = CreateIndexBuilder())
     {
         indexBuilder.DeleteContent(contentItem);
     }
 }
Esempio n. 5
0
        public virtual async Task <bool> DeleteAsync(IContentItem entity, TConfig config, Site site, bool allSites = false)
        {
            var records = (await GetRecordsAsync(entity)).ToArray();

            if (!records.Any())
            {
                return(false);
            }

            foreach (var record in records)
            {
                if (!allSites && !record.SiteIds.Contains(site.Id))
                {
                    continue;
                }

                var deleted = await DoDeleteAsync(record, config);

                if (!deleted)
                {
                    Logger.LogError("Can't delete content from {publisher}", GetType().FullName);
                    return(false);
                }

                _dbContext.Set <TPublishRecord>().Remove(record);
            }

            await _dbContext.SaveChangesAsync();

            return(true);
        }
Esempio n. 6
0
 protected async Task <IEnumerable <TPublishRecord> > GetRecordsAsync(IContentItem entity)
 {
     return(await _dbContext.Set <TPublishRecord>()
            .Where(r =>
                   r.Type == entity.GetKey() && r.ContentId == entity.Id)
            .ToListAsync());
 }
        public string Import(IContentItem contentItem)
        {
            if (contentItem.ShouldInstall)
            {

                IApplicationHostData[] applicationHost;
                //Get the addin data since it is installed with VS.  This content type does not
                //set any of the custom data need to located the VS installation path.
                _site.GetApplicationData("Addin", contentItem.ContentVersion, out applicationHost);

                string vsApplicationDirectory = Path.GetDirectoryName(applicationHost[0].ApplicationPath.Replace("\"",""));
                string destinationDirectory = Path.Combine(vsApplicationDirectory, "PrivateAssemblies");

                string actualDestinationPath;

                string[] sourceFileNames = contentItem.GetFileNames();
                string[] rootFileNames = contentItem.GetRootFileNames();

                for (int i = 0; i < sourceFileNames.Length; i++)
                {
                    string destinationPath = Path.Combine(destinationDirectory, rootFileNames[i]);

                    _site.StatusMessage("installing " + contentItem.DisplayName);

                    _site.CopyFile(sourceFileNames[i], destinationPath,
                                   DuplicateFileCase.EnableOverwrite | DuplicateFileCase.EnableSkip,
                                   out actualDestinationPath);
                }

                return "Installation completed successfully!";
            }
            return "Skipped";
        }
Esempio n. 8
0
 public void DeleteContent(IContentItem contentItem)
 {
     using (IndexBuilder indexBuilder = CreateIndexBuilder())
     {
         indexBuilder.DeleteContent(contentItem);
     }
 }
 public DocumentTrackingStrategy(IContentItem item)
 {
     _item = item;
     Precedence = 2;
     Context = Interfaces.Context.Original;
     DisplayName = "Document Tracking Strategy";
 }
Esempio n. 10
0
        private static Task OpenOptions(IContentItem contentItem)
        {
            var config = new ActionSheetConfig();

            //TODO: Bug in Acr.Userdialogs where style is not applied
            config.UseBottomSheet = true;

            config.Cancel = new ActionSheetOption(GetText("Cancel"));
            //config.Title = "";
            //config.Message = "";

            if (contentItem is IMediaItem mediaItem)
            {
                if (_topViewModel == typeof(QueueViewModel))
                {
                    config.Add(GetText("RemoveFromQueue"), () =>
                    {
                        _mediaManager.MediaQueue.Remove(mediaItem);
                        _userDialogs.Toast(GetText("ItemRemovedFromQueue"));
                    });
                }
                else
                {
                    config.Add(GetText("AddToQueue"), () =>
                    {
                        _mediaManager.MediaQueue.Add(mediaItem);
                        _userDialogs.Toast(GetText("ItemAddedToQueue"));
                    }, "add_to_queue");
                }
                config.Add(GetText("AddToPlaylist"), async() =>
                {
                    await _navigationService.Navigate <AddToPlaylistViewModel, IMediaItem>(mediaItem);
                }, "add_to_playlist");

                //config.Add(GetText("ShowArtist"), () => _navigationService.Navigate<ArtistViewModel>());
                //config.Add(GetText("ShowAlbum"), () => _navigationService.Navigate<AlbumViewModel>());
                //config.Add(GetText("Share"), () => { });
            }
            else if (contentItem is IPlaylist playlist)
            {
                config.Add(GetText("RenamePlaylist"), async() => {
                    await RenamePlaylist(playlist);
                });
                config.Add(GetText("DeletePlaylist"), async() => {
                    await DeletePlaylist(playlist);
                });
            }
            else if (contentItem is IArtist artist)
            {
                config.Add(GetText("Share"), () => {
                });
            }
            else if (contentItem is IAlbum album)
            {
                config.Add(GetText("Share"), () => {
                });
            }
            _userDialogs.ActionSheet(config);
            return(Task.CompletedTask);
        }
Esempio n. 11
0
        public UIView CreateContentItemView(IContentItem contentItem)
        {
            foreach (var alternate in contentItem.Alternates)
            {
                var locatedAlternate = alternate;
                var path             = NSBundle.MainBundle.PathForResource(locatedAlternate, "nib");

                if (path == null)
                {
                    locatedAlternate += "_";
                    path              = NSBundle.MainBundle.PathForResource(locatedAlternate, "nib");
                }

                if (path != null)
                {
                    var arr             = NSBundle.MainBundle.LoadNib(locatedAlternate, null, null);
                    var contentItemView = Runtime.GetNSObject <ContentItemView>(arr.ValueAt(0));

                    contentItemView.TranslatesAutoresizingMaskIntoConstraints = false;
                    contentItemView.DisplayContext = _displayContext;
                    contentItemView.ContentItem    = contentItem;

                    return(contentItemView);
                }
            }

            return(null);
        }
Esempio n. 12
0
        private ProcessResult FillContent(XElement contentControl, IContentItem item)
        {
            var processResult = ProcessResult.NotHandledResult;

            if (!(item is RepeatContent))
            {
                return(ProcessResult.NotHandledResult);
            }

            var repeat = item as RepeatContent;

            // If there isn't a list with that name, add an error to the error string.
            if (contentControl == null)
            {
                processResult.AddError(new ContentControlNotFoundError(repeat));

                return(processResult);
            }

            // If the list doesn't contain content controls in items, then error.
            var itemsContentControl = contentControl
                                      .Descendants(W.sdt)
                                      .FirstOrDefault();

            if (itemsContentControl == null)
            {
                processResult.AddError(
                    new CustomContentItemError(repeat, "doesn't contain content controls in items"));

                return(processResult);
            }

            var fieldNames = repeat.FieldNames.ToList();

            // Create a prototype of new items to be inserted into the document.
            var prototype = new Prototype(_context, contentControl, fieldNames);

            if (!prototype.IsValid)
            {
                processResult.AddError(
                    new CustomContentItemError(repeat,
                                               String.Format("doesn't contain items with content controls {0}",
                                                             string.Join(", ", fieldNames))));

                return(processResult);
            }

            // Propagates a prototype.
            var propagationResult = PropagatePrototype(prototype, repeat.Items);

            processResult.Merge(propagationResult);

            // Remove the prototype row and add all of the newly constructed rows.
            prototype.PrototypeItems.Last().AddAfterSelf(propagationResult.Result);
            prototype.PrototypeItems.Remove();

            processResult.AddItemToHandled(repeat);

            return(processResult);
        }
 public override int CompareTo(IContentItem other)
 {
     if (_item is IMail)
     {
         var otherMail = other as IMail;
         var thisMail = _item as IMail;
         if ((otherMail != null) && (thisMail != null))
         {
             foreach (IMailAttachment attachment in thisMail.Attachments)
             {
                 foreach (IMailAttachment otherAttachment in otherMail.Attachments)
                 {
                     if (attachment.TrackingId == otherAttachment.TrackingId)
                     {
                         return 0;
                     }
                 }
             }
         }
     }
     else if (_item is IMailAttachment)
     {
         var thisAttachment = _item as IMailAttachment;
         var otherAttachment = other as IMailAttachment;
         if ((otherAttachment != null) && (thisAttachment != null))
         {
             if (otherAttachment.TrackingId == thisAttachment.TrackingId)
             {
                 return 0;
             }
         }
     }
     return -1;
 }
Esempio n. 14
0
        public ProcessResult FillContent(XElement contentControl, IContentItem item)
        {
            var processResult = ProcessResult.NotHandledResult;

            if (!(item is FieldContent))
            {
                processResult = ProcessResult.NotHandledResult;
                return(processResult);
            }

            var field = item as FieldContent;

            // If there isn't a field with that name, add an error to the error string,
            // and continue with next field.
            if (contentControl == null)
            {
                processResult.AddError(new ContentControlNotFoundError(field));
                return(processResult);
            }

            var newValue = field.IsHidden ? string.Empty : field.Value;

            contentControl.ReplaceContentControlWithNewValue(newValue);

            processResult.AddItemToHandled(item);

            return(processResult);
        }
		public ListItemContent AddNestedItem(IContentItem nestedItem)
		{
			if (NestedFields == null) NestedFields = new List<ListItemContent>();

			NestedFields.Add(new ListItemContent(nestedItem));
			return this;
		}
Esempio n. 16
0
        public string Import(IContentItem contentItem)
        {
            if (contentItem.ShouldInstall)
            {
                IApplicationHostData[] applicationHost;
                //Get the addin data since it is installed with VS.  This content type does not
                //set any of the custom data need to located the VS installation path.
                _site.GetApplicationData("Addin", contentItem.ContentVersion, out applicationHost);

                string vsApplicationDirectory = Path.GetDirectoryName(applicationHost[0].ApplicationPath.Replace("\"", ""));
                string destinationDirectory   = Path.Combine(vsApplicationDirectory, "PrivateAssemblies");

                string actualDestinationPath;

                string[] sourceFileNames = contentItem.GetFileNames();
                string[] rootFileNames   = contentItem.GetRootFileNames();

                for (int i = 0; i < sourceFileNames.Length; i++)
                {
                    string destinationPath = Path.Combine(destinationDirectory, rootFileNames[i]);

                    _site.StatusMessage("installing " + contentItem.DisplayName);

                    _site.CopyFile(sourceFileNames[i], destinationPath,
                                   DuplicateFileCase.EnableOverwrite | DuplicateFileCase.EnableSkip,
                                   out actualDestinationPath);
                }

                return("Installation completed successfully!");
            }
            return("Skipped");
        }
Esempio n. 17
0
 public ContentChangedStrategy(IContentItem item)
 {
     Precedence = 3;
     Context = Interfaces.Context.Modified;
     DisplayName = "Content Changed Strategy";
     _item = item;
 }
Esempio n. 18
0
        private Document BuildDocumentFromContentItem(IContentItem contentItem, ITextExtractor textExtractor)
        {
            ISearchableContent searchInfo = contentItem as ISearchableContent;

            if (searchInfo == null)
            {
                throw new ArgumentException("Argument must implement ISearchableContent");
            }

            // Get the text of the content item to index
            string contentToIndex = searchInfo.ToSearchContent(textExtractor);
            // strip (x)html tags
            string plainTextContent = System.Text.RegularExpressions.Regex.Replace(contentToIndex, @"<(.|\n)*?>", string.Empty);
            // create the actual url
            string path = contentItem.GetContentUrl();
            // check that summary is not null.
            string summary = contentItem.Summary ?? Text.TruncateText(plainTextContent, 200);

            Document doc = new Document();

            doc.Add(new Field("globalid", contentItem.GlobalId.ToString("N"), Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("title", contentItem.Title, Field.Store.YES, Field.Index.TOKENIZED));
            doc.Add(new Field("summary", summary, Field.Store.YES, Field.Index.TOKENIZED));
            doc.Add(new Field("contents", plainTextContent, Field.Store.NO, Field.Index.TOKENIZED));
            doc.Add(new Field("author", contentItem.CreatedBy.FullName, Field.Store.YES, Field.Index.TOKENIZED));
            doc.Add(new Field("moduletype", contentItem.Section.ModuleType.Name, Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("path", path, Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("site", contentItem.Section.Node.Site.Id.ToString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("datecreated", contentItem.CreatedAt.ToString("u"), Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("datemodified", contentItem.ModifiedAt.ToString("u"), Field.Store.YES, Field.Index.UN_TOKENIZED));
            if (contentItem.PublishedAt.HasValue)
            {
                doc.Add(new Field("datepublished", contentItem.PublishedAt.Value.ToString("u"), Field.Store.YES,
                                  Field.Index.UN_TOKENIZED));
            }
            // do not index the sectionid here (since it's used for access filtering)
            doc.Add(new Field("sectionid", contentItem.Section.Id.ToString(), Field.Store.YES, Field.Index.NO));

            foreach (Category cat in contentItem.Categories)
            {
                doc.Add(new Field("category", cat.Name, Field.Store.YES, Field.Index.UN_TOKENIZED));
            }

            foreach (Role viewRole in contentItem.ViewRoles)
            {
                doc.Add(new Field("viewroleid", viewRole.Id.ToString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
            }

            foreach (CustomSearchField field in searchInfo.GetCustomSearchFields())
            {
                Field.Store store = field.IsStored ? Field.Store.YES : Field.Store.NO;
                Field.Index index = field.IsTokenized ? Field.Index.TOKENIZED : Field.Index.UN_TOKENIZED;
                if (field.FieldKey != null && field.FieldValue != null)
                {
                    doc.Add(new Field(field.FieldKey, field.FieldValue, store, index));
                }
            }
            return(doc);
        }
Esempio n. 19
0
        public ProcessResult FillContent(XElement contentControl, IContentItem item)
        {
            var processResult = ProcessResult.NotHandledResult;

            if (!(item is ImageContent))
            {
                processResult = ProcessResult.NotHandledResult;
                return(processResult);
            }

            var field = item as ImageContent;

            // If there isn't a field with that name, add an error to the error string,
            // and continue with next field.
            if (contentControl == null)
            {
                processResult.AddError(new ContentControlNotFoundError(field));
                return(processResult);
            }

            if (item.IsHidden)
            {
                var graphic = contentControl.DescendantsAndSelf(W.drawing).First();
                graphic.Remove();
            }
            else
            {
                var blip = contentControl.DescendantsAndSelf(A.blip).First();
                if (blip == null)
                {
                    processResult.AddError(new CustomContentItemError(field, "doesn't contain an image for replace"));
                    return(processResult);
                }

                var imageId = blip.Attribute(R.embed).Value;

                var imagePart = (ImagePart)_context.Document.GetPartById(imageId);

                if (imagePart != null)
                {
                    _context.Document.RemovePartById(imageId);
                }

                string imagePartId;
                if (field.Binary != null)
                {
                    imagePartId = _context.Document.AddImagePart(field.Binary);
                }
                else
                {
                    imagePartId = _context.Document.AddImagePart(System.IO.File.ReadAllBytes(field.FilePath));
                }

                blip.Attribute(R.embed).SetValue(imagePartId);
            }

            processResult.AddItemToHandled(item);
            return(processResult);
        }
Esempio n. 20
0
 public void AddContent(IContentItem contentItem)
 {
     if (this._indexWriter == null)
     {
         InitIndexWriter();
     }
     this._indexWriter.AddDocument(BuildDocumentFromContentItem(contentItem, this._textExtractor));
 }
Esempio n. 21
0
 public DataTemplate GetDisplayModeDataTemplate(IContentItem contentItem)
 {
     if (null == this.displayModeDataTemplate)
     {
         this.displayModeDataTemplate = XamlReader.Load(SignaturePadFactory.ReadOnlyControlTemplate) as DataTemplate;
     }
     return(this.displayModeDataTemplate);
 }
Esempio n. 22
0
        public static string GetContentItemName(this IContentItem value)
        {
            var contentItemNameAttribute = value.GetType()
                                           .GetCustomAttributes(typeof(ContentItemNameAttribute), true)
                                           .FirstOrDefault() as ContentItemNameAttribute;

            return(contentItemNameAttribute?.Name);
        }
Esempio n. 23
0
 public override bool Equals(IContentItem other)
 {
     if (other is EmptyContent)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 24
0
 public void SetContent(IContentItem contentItem)
 {
     Data = JsonConvert.SerializeObject(contentItem,
                                        new JsonSerializerSettings
     {
         ReferenceLoopHandling = ReferenceLoopHandling.Ignore, TypeNameHandling = TypeNameHandling.Auto
     });
 }
Esempio n. 25
0
 public bool Equals(IContentItem other)
 {
     if (other == null)
     {
         return(false);
     }
     return(other.ItemId == ItemId);
 }
Esempio n. 26
0
 public void AddContent(IContentItem contentItem)
 {
     if (this._indexWriter == null)
     {
         InitIndexWriter();
     }
     this._indexWriter.AddDocument(BuildDocumentFromContentItem(contentItem, this._textExtractor));
 }
Esempio n. 27
0
        public bool Equals(IContentItem other)
        {
            if (!(other is FieldContent))
            {
                return(false);
            }

            return(Equals((FieldContent)other));
        }
        public virtual string GenerateKey(IContentItem item)
        {
            if (!string.IsNullOrEmpty(item.Id) && item.Id.Length == 36)
            {
                return(item.Id);
            }

            return(Guid.NewGuid().ToString());
        }
Esempio n. 29
0
        public ContentItemCell(DisplayContext displayContext, IContentItem contentItem, string cellId) : base(UITableViewCellStyle.Default, cellId)
        {
            var contentItemView = displayContext.ViewFactory.CreateContentItemView(contentItem);

            contentItemView.TranslatesAutoresizingMaskIntoConstraints = false;

            ContentView.AddSubview(contentItemView);
            ContentView.AddConstraints(ContentConstraints(contentItemView, ContentView));
        }
        public override string GenerateKey(IContentItem item)
        {
            if (!string.IsNullOrWhiteSpace(item.Slug))
            {
                return(item.Slug);
            }

            return(base.GenerateKey(item));
        }
Esempio n. 31
0
        public override bool Equals(IContentItem other)
        {
            if (!(other is TableContent))
            {
                return(false);
            }

            return(this.Equals((TableContent)other));
        }
Esempio n. 32
0
        public async Task <bool> PerformChannelLogin(IContentItem item)
        {
            if (mediaContentViewModel != null)
            {
                return(await mediaContentViewModel.PerformChannelLogin(item));
            }

            return(false);
        }
 public ContentItemViewHolder(
     DisplayContext displayContext,
     ViewGroup container,
     IContentItem contentItem)
 {
     DisplayContext = displayContext;
     Container      = container;
     ContentItem    = contentItem;
 }
Esempio n. 34
0
        /// <summary>
        /// Добавить владельца
        /// </summary>
        /// <param name="emailMessage"></param>
        private void AddOwner(IContentItem emailMessage)
        {
            var mailOwnerSummary = new MailOwnerSummary(MailBox.Login, MailBox.User?.Fio);

            if (!emailMessage.Owners.Any(c => c.Equals(mailOwnerSummary)))
            {
                emailMessage.Owners.Add(mailOwnerSummary);
            }
        }
Esempio n. 35
0
        public bool Equals(IContentItem other)
        {
            if (!(other is TableContent))
            {
                return(false);
            }

            return(Equals((TableContent)other));
        }
Esempio n. 36
0
        public override bool Equals(IContentItem other)
        {
            if (!(other is RepeatContent))
            {
                return(false);
            }

            return(Equals((RepeatContent)other));
        }
Esempio n. 37
0
        public override bool Equals(IContentItem other)
        {
            if (!(other is FieldDeleteContent))
            {
                return(false);
            }

            return(Equals((FieldDeleteContent)other));
        }
 private static Uri GetIconForCommand(IContentItem contentItem, IconConverterBase.CollectionIconVisualState visualState)
 {
     string str;
     ICommand details = contentItem.Details as ICommand;
     if ((details != null) && ((str = details.Name) != null))
     {
         if (str == "AddAndEditNew")
         {
             if (visualState != IconConverterBase.CollectionIconVisualState.MouseOver)
             {
                 return IconAddSmall;
             }
             return IconAddSmallHover;
         }
         if (str == "AddNew")
         {
             if (visualState != IconConverterBase.CollectionIconVisualState.MouseOver)
             {
                 return IconAddSmall;
             }
             return IconAddSmallHover;
         }
         if (str == "DeleteSelected")
         {
             if (visualState != IconConverterBase.CollectionIconVisualState.MouseOver)
             {
                 return IconDeleteSmall;
             }
             return IconDeleteSmallHover;
         }
         if (str == "EditSelected")
         {
             if (visualState != IconConverterBase.CollectionIconVisualState.MouseOver)
             {
                 return IconEditSmall;
             }
             return IconEditSmallHover;
         }
         if (str == "Refresh")
         {
             if (visualState != IconConverterBase.CollectionIconVisualState.MouseOver)
             {
                 return IconRefreshSmall;
             }
             return IconRefreshSmallHover;
         }
         if (str == "RemoveSelected")
         {
             if (visualState != IconConverterBase.CollectionIconVisualState.MouseOver)
             {
                 return IconDeleteSmall;
             }
             return IconDeleteSmallHover;
         }
     }
     return null;
 }
        public ConverstationTopicStrategy(IContentItem item)
        {
            _item = item as IMail;
            if (_item == null)
                throw new System.InvalidCastException("Expecting an IMail item");

            Precedence = 1;
            DisplayName = "Conversation Topic Strategy";
            Context = Interfaces.Context.Original;
        }
Esempio n. 40
0
		internal static Workshare.PolicyContent.ContentItem GetContentItem(IContentItem contentIn, bool keepContentBytes)
		{
			bool useFileInstead = false;

			if (null == contentIn)
				throw new ArgumentNullException("contentIn");

			useFileInstead = contentIn.Properties.ContainsKey(ContentDataSourceKey);

			Workshare.PolicyContent.ContentItem contentOut = new Workshare.PolicyContent.ContentItem();
			contentOut.ContentType = contentIn.Type;
			contentOut.Encrypted = contentIn.Encrypted;
			contentOut.Name = contentIn.Name;
		    contentOut.DisplayName = contentIn.DisplayName;
			contentOut.Size = contentIn.Size;
			List<CustomProperty> properties = new List<CustomProperty>();

			if (keepContentBytes && !useFileInstead)    
				contentOut.Content = GetContentBytes(contentIn);

			if (useFileInstead)
			{
				string filename = contentIn.Properties[ContentDataSourceKey];
				if (string.IsNullOrEmpty(filename)) // need to create new file then
				{
					filename = Path.GetTempFileName();
					contentIn.Properties[ContentDataSourceKey] = filename;
					GetContentToFile(contentIn, filename);
				}
			}
			

			int index = 0;
			
			if (contentIn.Properties != null && contentIn.Properties.Count > 0)
			{
				HandleContentIds(contentIn, contentOut);
				
				foreach (KeyValuePair<string, string> kvp in contentIn.Properties)
				{
					CustomProperty cp = new CustomProperty(kvp.Key, kvp.Value);
					properties.Add(cp);
				}
			}
			
			contentOut.Properties = properties.ToArray();
			contentOut.PolicySets = new PolicySet[contentIn.PolicySetCollection.Count];
			index = 0;
			foreach (IPolicySetResponse response in contentIn.PolicySetCollection)
			{
				contentOut.PolicySets[index++] = PolicySetAdaptor.GetPolicySet(response);
			}
			
			return contentOut;
		}
Esempio n. 41
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TrackbackMessage"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="urlToNotifyTrackback">The URL to notify trackback.</param>
        public TrackbackMessage(IContentItem item, Uri urlToNotifyTrackback, Uri itemUrl)
        {
            if (item == null)
            throw new ArgumentNullException("item");

             Title = item.Title;
             PostUrl = itemUrl;
             Excerpt = item.Title;
             BlogName = item.Site.Name;
             UrlToNotifyTrackback = urlToNotifyTrackback;
        }
 public override int CompareTo(IContentItem other)
 {
     IMail otherMail = other as IMail;
     if (otherMail != null)
     {
         if (_item.ConversationTopic == otherMail.ConversationTopic)
         {
             return 0;
         }
     }
     return -1;
 }
 public bool AddContentItem(IContentItem[] contentItems, IContentInstallerSite site)
 {
     _site = site;
     foreach (IContentItem contentItem in contentItems)
     {
         if (contentItem.FileContentType == "WizardExtension")
         {
             return true;
         }
     }
     return false;
 }
Esempio n. 44
0
		private static byte[] GetContentBytes(IContentItem item)
		{
			Workshare.Policy.Engine.ContentItem content = (Workshare.Policy.Engine.ContentItem)item;
			if ((content.File == null) || (content.File.RawContents == null))
			{
				return null;
			}
			using (System.IO.Stream stream = content.File.RawContents.AsStream())
			{
				byte[] bytes = StreamUtils.SafeButUnpleasantReadAllStreamIntoByteArray(stream);
				return bytes;
			}
		}
        public void FillContent(XElement contentControl, IContentItem item)
        {
            if (!(item is ImageContent))
            {
                _processResult = ProcessResult.NotHandledResult;
                return;
            }

            var field = item as ImageContent;
            // If image bytes was not provided, then doing nothing
            if (field.Binary == null || field.Binary.Length == 0) { return; }

            // If there isn't a field with that name, add an error to the error string,
            // and continue with next field.
            if (contentControl == null)
            {
                _processResult.Errors.Add(String.Format("Field Content Control '{0}' not found.",
                    field.Name));
                return;
            }


            var blip = contentControl.DescendantsAndSelf(A.blip).First();
            if (blip == null)
            {
                _processResult.Errors.Add(String.Format("Image to replace for '{0}' not found.",
                    field.Name));
                return;
            }

            // Creating a new image part
            var imagePart = _context.WordDocument.MainDocumentPart.AddImagePart(field.MIMEType);
            // Writing image bytes to it
            using (BinaryWriter writer = new BinaryWriter(imagePart.GetStream()))
            {
                writer.Write(field.Binary);
            }
            // Setting reference for CC to newly uploaded image
            blip.Attribute(R.embed).Value = _context.WordDocument.MainDocumentPart.GetIdOfPart(imagePart);

            //var imageId = blip.Attribute(R.embed).Value;
            //var xmlPart = _context.WordDocument.MainDocumentPart.GetPartById(imageId);
            //if (xmlPart is ImagePart)
            //{
            //    ImagePart imagePart = xmlPart as ImagePart;
            //    using (BinaryWriter writer = new BinaryWriter(imagePart.GetStream()))
            //    {
            //        writer.Write(field.Binary);
            //    }
            //}
        }
Esempio n. 46
0
        public void RemoveItem (IContentItem item) {
            if (!this.items.Remove (item))
                return;

            var next = item.Next;
            var prev = item.Prev;

            item.RemoveNextReference ();
            item.RemoveBackReference ();

            if (next == null || prev == null)
                return;

            prev.AddNextReference (next);
        }
Esempio n. 47
0
        public static void CompareAttachments(IContentItem original, IContentItem modified)
        {
            string temppath = Utils.GetTempPath();
            string originalFile = string.Empty;
            string modifiedFile = string.Empty;
            string cmdline = "";
			const int maxPathLength = 250; // Why not 256? : We have seen Lotus Notes etc screw up for 250+, so playing safe

            if (original != null)
            {
				originalFile = Path.Combine(temppath, "Original_" + GetValidFileName(original.DisplayName));
				if (originalFile.Length > maxPathLength)
				{
					// if length is bigger than MAXPATH, then generate a temp file name to shorten the path
					// NOTE: We are not dealing with path's itself being longer than MAXPATH. That should be
					//       dealt by using a UNC path and then calling GetShortFileName (alas, but DVw does
					//       not supports UNC paths and ShortFileName's for such longer paths!)
					string randomName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + Path.GetExtension(originalFile);
					originalFile = Path.Combine(temppath, randomName);
					Logger.LogInfo(string.Format("Ready Redline, Original path too long, shortening it to : {0}", originalFile));
				}
				
				original.SaveAsFile(originalFile);
				cmdline += string.Format("/original=\"{0}\"", originalFile);
            }

            if (modified != null)
            {
				modifiedFile = Path.Combine(temppath, "Modified_" + GetValidFileName(modified.DisplayName));
				if (modifiedFile.Length > maxPathLength)
				{
					string randomName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + Path.GetExtension(modifiedFile);
					modifiedFile = Path.Combine(temppath, randomName);
					Logger.LogInfo(string.Format("Ready Redline, Modified path too long, shortening it to : {0}", modifiedFile));
				}
				
				modified.SaveAsFile(modifiedFile);
				cmdline += string.Format(" /modified=\"{0}\"", modifiedFile);
            }

			Logger.LogInfo(string.Format("Ready Redline, Executing commandline: {0}", cmdline));
            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
            psi.Arguments = cmdline;
            psi.FileName = @"deltavw.exe";

            System.Diagnostics.Process.Start(psi);
        }
Esempio n. 48
0
        public void AddBackReference (IContentItem item) {
            if (this.Prev != null) {
                var iter = item;
                while (iter.HasPrev ())
                    iter = iter.Prev;
                var prev = this.Prev;

                this.Prev = item;
                (item as ContentItem).Next = this;

                (iter as ContentItem).Prev = prev;
                (prev as ContentItem).Next = iter;
            }

            this.Prev = item;
            (item as ContentItem).Next = this;
        }
Esempio n. 49
0
        public void AddNextReference (IContentItem item) {
            if (this.Next != null) {
                var iter = item;
                while (iter.HasNext ())
                    iter = iter.Next;
                var next = this.Next;

                this.Next = item;
                (item as ContentItem).Prev = this;

                (iter as ContentItem).Next = next;
                (next as ContentItem).Prev = iter;
            }

            this.Next = item;
            (item as ContentItem).Prev = this;
        }
		public ProcessResult AddItemToHandled(IContentItem handledItem)
		{
			if (!HandledItems.Contains(handledItem))
				HandledItems.Add(handledItem);

			var contentControlNotFoundErrors = Errors.OfType<ContentControlNotFoundError>()
				.Where(x => x.ContentItem.Equals(handledItem))
				.ToList();

			foreach (var error in contentControlNotFoundErrors)
			{
				_errors.Remove(error);
			}
			
			Handled = true;

			return this;
		}
		public ProcessResult FillContent(XElement contentControl, IContentItem item)
		{
			var processResult = ProcessResult.NotHandledResult; 

			if (!(item is ImageContent))
			{
				processResult = ProcessResult.NotHandledResult;
				return processResult;
			}

			var field = item as ImageContent;

			// If there isn't a field with that name, add an error to the error string,
			// and continue with next field.
			if (contentControl == null)
			{
				processResult.AddError(new ContentControlNotFoundError(field));
				return processResult;
			}


            var blip = contentControl.DescendantsAndSelf(A.blip).First();
            if (blip == null)
            {
                processResult.AddError(new CustomContentItemError(field, "doesn't contain an image for replace"));
                return processResult;
            }

            var imageId = blip.Attribute(R.embed).Value;

            var imagePart = (ImagePart)_context.Document.GetPartById(imageId);

			if (imagePart != null)
			{
				_context.Document.RemovePartById(imageId);
			}

			var imagePartId = _context.Document.AddImagePart(field.Binary);

			blip.Attribute(R.embed).SetValue(imagePartId);

			processResult.AddItemToHandled(item);
			return processResult;
		}
        public CompareAttachmentUserControl(IContentItem original, IContentItem modified)
        {
            InitializeComponent();

            _original = original;
            _modified = modified;

            lblDisplayName.Text = GetLabelText();

            if (AreAttachmentsMissing())
            {
                SetControlImage(Properties.Resources.redline_warning);
                SetAdditionalInformationText("Original document not found. Manual browsing for documents will be required.");
            }

            if (IsAttachmentRenamed())
            {
                SetAdditionalInformationText("The original document has been renamed.");
            }
        }
		public void FillContent(XElement contentControl, IContentItem item)
		{
			if (!(item is FieldContent))
			{
				_processResult = ProcessResult.NotHandledResult;
				return;
			}

			var field = item as FieldContent;

			// If there isn't a field with that name, add an error to the error string,
			// and continue with next field.
			if (contentControl == null)
			{
				_processResult.Errors.Add(String.Format("Field Content Control '{0}' not found.",
					field.Name));
				return;
			}
			contentControl.ReplaceContentControlWithNewValue(field.Value);

		}
Esempio n. 54
0
 public override int CompareTo(IContentItem other)
 {
     IMail mail = (other as IMail);
     if (mail != null)
     {
         foreach (IMailAttachment attachment in mail.Attachments)
         {
             if (IsAttachmentModified(attachment) == 0)
             {
                 return 0;
             }
         }
     }
     else if (other is IMailAttachment)
     {
         if (IsAttachmentModified(other as IMailAttachment) == 0)
         {
             return 0;
         }
     }
     return -1;
 }
Esempio n. 55
0
        public static List<IPolicyResponseAction> AssociateFilesWithActions(IContentItem contentItem)
        {
            List<IPolicyResponseAction> actions = new List<IPolicyResponseAction>();
            foreach (IPolicySetResponse policyset in contentItem.PolicySetCollection)
            {
                PolicySetResponse policySetInfo = policyset as PolicySetResponse;

                if ((null == policySetInfo) || (null == policySetInfo.PolicyReportCollection))
                    continue;

                foreach (PolicyResponse policyInfo in policySetInfo.PolicyReportCollection)
                {
                    if (policyInfo.ActionCollection == null)
                        continue;

                    foreach (IPolicyResponseAction ai in policyInfo.ActionCollection)
                    {
                        PolicyResponseAction actionInfo = ai as PolicyResponseAction;
                        if (null == actionInfo)
                            continue;

                        //if (!actionInfo.IsExceptionAction && actionInfo.Action.Blocking)
                        //    actionInfo.Processed = true;

                        for (int i = 0; i <= actions.Count; ++i)
                        {
                            if (i == actions.Count)
                                actions.Add(actionInfo);
                            else if (actionInfo.Type == ((PolicyResponseAction)actions[i]).Type)
                                actions.Insert(i, actionInfo);
                            else
                                continue;
                            break;
                        }
                    }
                }
            }
            return actions;
        }
		public ProcessResult FillContent(XElement contentControl, IContentItem item)
		{
			var processResult = ProcessResult.NotHandledResult; 
			if (!(item is FieldContent))
			{
				processResult = ProcessResult.NotHandledResult;
				return processResult;
			}

			var field = item as FieldContent;

			// If there isn't a field with that name, add an error to the error string,
			// and continue with next field.
			if (contentControl == null)
			{
				processResult.AddError(new ContentControlNotFoundError(field));
				return processResult;
			}
			contentControl.ReplaceContentControlWithNewValue(field.Value);

			processResult.AddItemToHandled(item);

			return processResult;
		}
Esempio n. 57
0
 public abstract int CompareTo(IContentItem other);
 private void AddCompareAttachmentControl(IContentItem original, IContentItem modified)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new MethodInvoker(() => AddCompareAttachmentControl(original, modified)));
         return;
     }
     
     var uc = new CompareAttachmentUserControl(original, modified);
     uc.Location = new Point(20, 10);
     uc.Visible = true;
     uc.Dock = DockStyle.Top;
     uc.OnClickedAttachmentsLocated += uc_OnClickedAttachmentsLocated;
     uc.OnClickedAttachmentsMissing += uc_OnClickedAttachmentsMissing;
     pnlReadyRedline.Controls.Add(uc);
 }
		public ProcessResult FillContent(XElement content, IContentItem data)
		{
			return FillContent(content, new List<IContentItem>{data});
		}
 public void UpdateContentItemInstallStatus(IContentItem[] contentItem)
 {
 }