zoukankan      html  css  js  c++  java
  • 使用OfficialFile webservice 进行管理规则上传文档到放置库归档

    using System;
    using System.Collections.Generic;
    using System.IO;
    using RecordsAdmission.OfficialFileService;

    namespace RecordsAdmission
    {
    class Program
    {
    static void Main(string[] args)
    {
    string filePath = @"c:contoso.docx";

    RecordsRepository repository = new RecordsRepository();
    repository.Url = "http://contoso/recordscenter/_vti_bin/officialfile.asmx";
    repository.UseDefaultCredentials = true;
    byte[] fileContent = File.ReadAllBytes(filePath);

    List<OfficialFileService.RecordsRepositoryProperty> properties =
    new List<OfficialFileService.RecordsRepositoryProperty>();
    properties.Add(new OfficialFileService.RecordsRepositoryProperty()
    { Name = "Title", Type = "Text", Value = "ctypetest" });
    properties.Add(new OfficialFileService.RecordsRepositoryProperty()
    { Name = "Name", Type = "Text", Value = "contosofs.docx" });
    properties.Add(new OfficialFileService.RecordsRepositoryProperty()
    { Name = "Customer", Type = "Text", Value = "Contoso" });
    properties.Add(new OfficialFileService.RecordsRepositoryProperty()
    { Name = "ContentType", Type = "Text", Value = "Sales Proposal" });

    string sourceUrl = filePath;
    string userName = @"sharepointadministrator";

    string result = repository.SubmitFile(fileContent, properties.ToArray(),
    null, sourceUrl, userName);
    Console.WriteLine(result);
    Console.ReadLine();
    }
    }
    }

    创建规则

    using System;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Taxonomy;
    using Microsoft.Office.RecordsManagement.RecordsRepository;

    namespace ContentOrganizerRules
    {
    class CreateRule
    {
    static void Main(string[] args)
    {
    string absoluteSiteUrl = "http://contoso/recordscenter/";
    string ruleName = "Woodgrove Sales Proposals";
    string ruleDescription = "Sample rule to organize documents";
    string ruleLibraryName = "Sales Proposals";
    string ruleFolderUrl = "Sales Proposals/Woodgrove";
    string ruleContentTypeName = "Sales Proposal";

    string conditionFieldId = "90d69139-483c-4872-8ce0-5884bd370513"; // SPField.Id
    string conditionFieldInternalName = "Customer"; //SPField.InternalName
    string conditionFieldTitle = "Customer"; //SPField.Title

    string conditionOperator = "Equal";
    string conditionFieldValue = "Woodgrove";

    // Build the conditionSettings XML from the constants above.
    string conditionXml =
    String.Format(@"<Condition Column=""{0}|{1}|{2}"" Operator=""{3}"" Value=""{4}"" />",
    conditionFieldId, conditionFieldInternalName, conditionFieldTitle,
    conditionOperator,
    conditionFieldValue);
    string conditionsXml = String.Format("<Conditions>{0}</Conditions>", conditionXml);

    // Grab the SPWeb object and the rules library.
    using (SPSite contentOrganizerSiteCollection = new SPSite(absoluteSiteUrl))
    {
    SPWeb contentOrganizerSite = contentOrganizerSiteCollection.OpenWeb();
    EcmDocumentRoutingWeb contentOrganizerSiteWrapper =
    new EcmDocumentRoutingWeb(contentOrganizerSite);
    SPContentType ruleContentType = contentOrganizerSite.ContentTypes[ruleContentTypeName];
    SPList ruleLibrary = contentOrganizerSite.Lists[ruleLibraryName];

    if (ruleLibrary.ContentTypes.BestMatch(ruleContentType.Id) == null)
    {
    throw new ArgumentException(String.Format(
    "Ensure that the library {0} contains content type {1} before creating the rule",
    ruleLibraryName,
    ruleContentTypeName));
    }

    // Create a blank rule.
    EcmDocumentRouterRule organizeDocument = new EcmDocumentRouterRule(contentOrganizerSite);

    // Configure the rule.
    organizeDocument.Name = ruleName;
    organizeDocument.Description = ruleDescription;
    organizeDocument.ContentTypeString = ruleContentType.Name;
    organizeDocument.RouteToExternalLocation = false;
    organizeDocument.Priority = "5";
    organizeDocument.TargetPath =
    contentOrganizerSite.GetFolder(absoluteSiteUrl + ruleFolderUrl).ServerRelativeUrl;
    organizeDocument.ConditionsString = conditionsXml;

    // Update the rule and commit changes.
    organizeDocument.Update();
    }
    }
    }
    }

  • 相关阅读:
    ES6-Object
    ES6-Iterator
    ES6-Generator
    ES6-fetch
    ES6-Function
    ES6-Array
    ES6-Class
    SQLite使用事务更新—by command
    交款功能代码
    SQLite本地事务处理
  • 原文地址:https://www.cnblogs.com/xdanny/p/12717686.html
Copyright © 2011-2022 走看看