// Token: 0x0600107C RID: 4220 RVA: 0x0005C95E File Offset: 0x0005AB5E
 public Attachment16Data(AttachmentAction changeType)
 {
     this.ChangeType  = changeType;
     this.ContentType = string.Empty;
     this.ClientId    = null;
     this.Content     = null;
 }
    public static void Main()
    {
        bool             deleteLocationAfterResolve = true;                  // True to delete the folder location after it has been resolved
        AttachmentAction attachmentAction           = AttachmentAction.Copy; // Set the attachment action for the files in the directory. Note that for cloud and sql server project this will always be resetted to Copy.

        int counter = 0;

        try
        {
            foreach (Location location in Program.ActiveProjectShell.Project.AllLocations.ToList())
            {
                if (location.IsExistingFolderLocation)
                {
                    counter++;

                    location.ResolveFolderLocation(attachmentAction);

                    if (deleteLocationAfterResolve)
                    {
                        location.Reference.Locations.Remove(location);
                    }
                }
            }
            MessageBox.Show("Resolved " + counter.ToString() + " locations");
        }
        catch (Exception x)
        {
            MessageBox.Show(x.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
Beispiel #3
0
 private static SlackAttachmentAction MapAction(AttachmentAction action)
 {
     return(new SlackAttachmentAction
     {
         Text = action.Text,
         Url = action.Url,
         Style = action.Style,
         Type = action.Type
     });
 }
Beispiel #4
0
    public static void Main()
    {
        if (Program.ProjectShells.Count == 0)
        {
            return;                                                     //no project open
        }
        if (IsBackupAvailable() == false)
        {
            return;                                                             //user wants to backup his/her project first
        }
        int counter = 0;

        try
        {
            string sourcePath;

            FolderBrowserDialog folderDialog = new FolderBrowserDialog();
            folderDialog.Description = "Select a root folder for the PDF files to be imported ...";
            DialogResult folderResult = folderDialog.ShowDialog();
            if (folderResult == DialogResult.OK)
            {
                sourcePath = folderDialog.SelectedPath;
            }
            else
            {
                return;
            }

            AttachmentAction action = AttachmentAction.Link;             //suggested: .Link or .Copy

            DirectoryInfo   dir       = new DirectoryInfo(sourcePath);
            List <FileInfo> fileInfos = Path2.GetFilesSafe(dir, "*.pdf", SearchOption.AllDirectories).ToList();

            List <Reference>             newReferences = new List <Reference>();
            SwissAcademic.Citavi.Project activeProject = Program.ActiveProjectShell.Project;

            List <string> filePaths = fileInfos.Select <FileInfo, string>(info => info.FullName).ToList();
            foreach (string filePath in filePaths)
            {
                DebugMacro.WriteLine("START IMPORT: " + filePath);
                List <Reference> referencesFromFile = new FileImportSupport().ImportFiles(activeProject, activeProject.Engine.TransformerManager, new List <string>()
                {
                    filePath
                }, action);

                if (referencesFromFile != null && referencesFromFile.Any())
                {
                    var referencesFromFileAdded = activeProject.References.AddRange(referencesFromFile);

                    var fileName = Path.GetFileName(filePath);
                    AddCategories(referencesFromFileAdded, filePath.Substring(sourcePath.Length, filePath.Length - sourcePath.Length - fileName.Length));
                    DebugMacro.WriteLine("SUCCESS");
                    counter++;
                }
                else
                {
                    DebugMacro.WriteLine("ERROR importing file");
                }
            }
        }         //end try

        finally
        {
            MessageBox.Show(string.Format("Macro has finished execution.\r\n{0} changes were made.", counter.ToString()), "Citavi", MessageBoxButtons.OK, MessageBoxIcon.Information);
        } //end finally
    }     //end main()
Beispiel #5
0
        // Token: 0x06000F4E RID: 3918 RVA: 0x0005793C File Offset: 0x00055B3C
        private Attachment16Data ParseAttachmentsData(XmlNode parentNode, AttachmentAction action)
        {
            Attachment16Data attachment16Data = new Attachment16Data(action);

            foreach (object obj in parentNode)
            {
                XmlNode xmlNode = (XmlNode)obj;
                string  name;
                switch (name = xmlNode.Name)
                {
                case "FileReference":
                    attachment16Data.FileReference = HttpUtility.UrlDecode(xmlNode.InnerText);
                    continue;

                case "ContentId":
                    attachment16Data.ContentId = xmlNode.InnerText;
                    continue;

                case "ContentLocation":
                    attachment16Data.ContentLocation = xmlNode.InnerText;
                    continue;

                case "Method":
                    attachment16Data.Method = Convert.ToByte(xmlNode.InnerText);
                    continue;

                case "DisplayName":
                    attachment16Data.DisplayName = xmlNode.InnerText;
                    continue;

                case "IsInline":
                    if (string.IsNullOrEmpty(xmlNode.InnerText))
                    {
                        attachment16Data.IsInline = true;
                        continue;
                    }
                    if (xmlNode.InnerText.Equals("1"))
                    {
                        attachment16Data.IsInline = true;
                        continue;
                    }
                    if (xmlNode.InnerText.Equals("0"))
                    {
                        attachment16Data.IsInline = false;
                        continue;
                    }
                    throw new ConversionException("Airsync16AttachmentProperty:ParseAttachmentsData. Invalid value passed in 'IsInline' Node.");

                case "Content":
                {
                    AirSyncBlobXmlNode airSyncBlobXmlNode = xmlNode as AirSyncBlobXmlNode;
                    if (airSyncBlobXmlNode == null)
                    {
                        continue;
                    }
                    if (airSyncBlobXmlNode.ByteArray != null)
                    {
                        attachment16Data.Content = airSyncBlobXmlNode.ByteArray;
                        continue;
                    }
                    if (airSyncBlobXmlNode.Stream != null && airSyncBlobXmlNode.Stream.CanSeek && airSyncBlobXmlNode.Stream.CanRead)
                    {
                        attachment16Data.Content = new byte[airSyncBlobXmlNode.Stream.Length];
                        airSyncBlobXmlNode.Stream.Seek(0L, SeekOrigin.Begin);
                        airSyncBlobXmlNode.Stream.Read(attachment16Data.Content, 0, (int)airSyncBlobXmlNode.Stream.Length);
                        continue;
                    }
                    throw new ConversionException("Airsync16AttachmentProperty:ParseAttachmentsData. Invalid value passed in 'Data' Node.");
                }

                case "ContentType":
                    attachment16Data.ContentType = xmlNode.InnerText;
                    continue;

                case "ClientId":
                    attachment16Data.ClientId = xmlNode.InnerText;
                    continue;
                }
                throw new ConversionException(string.Format("Airsync16AttachmentProperty:ParseAttachmentsData. invalid node {0}.", xmlNode.Name));
            }
            return(attachment16Data);
        }