コード例 #1
0
 public Guid ConvertDocuments(SPSite spSite, SPWeb spWeb, ArrayList files, DocSaveFormat docSaveFormat, DocSaveBehaviour docSaveBehaviour)
 {
     SaveFormat savFormat = GetSaveFormat(docSaveFormat);
     SaveBehavior savBehaviour = getSaveBehavior(docSaveBehaviour);
     const string wordAutomationServiceName = "Word Automation Services";
     var job = new ConversionJob(wordAutomationServiceName) {UserToken = spSite.UserToken};
     job.Settings.UpdateFields = true;
     job.Settings.OutputFormat = savFormat;
     job.Settings.OutputSaveBehavior = savBehaviour;
     job.Settings.AddThumbnail = true;
     foreach (string file in files)
     {
         job.AddFile(spWeb.Url + "/" + SourceLibrary + "/" + file, spWeb.Url + "/" + DestinationLibrary + "/" + Path.GetFileNameWithoutExtension(file) + Extension);
     }
     job.Start();
     _status = new ConversionJobStatus(wordAutomationServiceName, job.JobId, null);
     return job.JobId;
 }
コード例 #2
0
 private SaveBehavior getSaveBehavior(DocSaveBehaviour docSaveBehaviour)
 {
     var savBehavior = SaveBehavior.NeverOverwrite;
     switch (docSaveBehaviour)
     {
         case DocSaveBehaviour.AlwaysOverwrite:
             savBehavior = SaveBehavior.AlwaysOverwrite;
             break;
         case DocSaveBehaviour.AppendIfPossible:
             savBehavior = SaveBehavior.AppendIfPossible;
             break;
         case DocSaveBehaviour.AppendOnly:
             savBehavior = SaveBehavior.AppendOnly;
             break;
         case DocSaveBehaviour.NeverOverwrite:
             savBehavior = SaveBehavior.NeverOverwrite;
             break;
     }
     return savBehavior;
 }