Poznámka:
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
Sada File SDK podporuje operace popisování pro .msg soubory stejným způsobem jako jakýkoli jiný typ souboru, s tím rozdílem, že sada SDK potřebuje aplikaci k povolení příznaku funkce MSG. Tento stručný úvod ukazuje, jak tento příznak nastavit.
Jak je popsáno dříve, vytvoření instance IFileEngine vyžaduje FileEngineSettings objekt nastavení. Aplikace používá FileEngineSettings k předání vlastních nastavení pro určitou instanci. Vlastnost CustomSettings objektu FileEngineSettings nastaví příznak enable_msg_file_type tak, aby povolila zpracování souborů .msg.
Požadavky
Pokud jste to ještě neudělali, nezapomeňte před pokračováním dokončit následující požadavky:
- Dokončení rychlého startu: Nejprve inicializace aplikace sady File SDK (C#), která vytvoří počáteční Visual Studio řešení. Tento rychlý průvodce „Postup – zpracování souborů e-mailových zpráv .msg (C#)“ navazuje na předchozí.
- Projděte si koncepty e-mailových souborů MIP SDK.
- Volitelně: Projděte si moduly souborů v konceptech sady MIP SDK .
- Volitelně: Zkontrolujte obslužné rutiny souborů v konceptech sady MIP SDK .
Nastavení enable_msg_file_type a použití sady File SDK pro popisky .msg souboru
V návaznosti na rychlý úvod k inicializaci aplikace File API upravte kód pro vytvoření modulu souborů tak, aby nastavoval enable_msg_file_type flag, a pak pomocí modulu souborů označte soubor .msg štítkem.
Otevřete řešení Visual Studio, které jste vytvořili v předchozím rychlém startu: Inicializace aplikace sady File SDK (C#).
V Průzkumník řešení otevřete soubor .cs v projektu, který obsahuje implementaci
Main()metody. V rámci výchozího nastavení se použije stejný název jako projekt, který ho obsahuje a který jste zadali při vytváření projektu.Odeberte implementaci funkce
Main()z předchozího rychlého průvodce. Vložte doMain()těla následující kód. V následujícím bloku kódu je při vytváření souborového enginu nastaven příznakenable_msg_file_type.IFileHandlerobjekty vytvořené pomocí souborového stroje pak mohou zpracovat .msg soubor.static void Main(string[] args) { // Initialize Wrapper for File SDK operations. MIP.Initialize(MipComponent.File); // Create ApplicationInfo, setting the clientID from Azure AD App Registration as the ApplicationId. ApplicationInfo appInfo = new ApplicationInfo() { ApplicationId = clientId, ApplicationName = appName, ApplicationVersion = "1.0.0" }; // Instantiate the AuthDelegateImpl object, passing in AppInfo. AuthDelegateImplementation authDelegate = new AuthDelegateImplementation(appInfo); MipConfiguration mipConfiguration = new MipConfiguration(appInfo, "mip_data", LogLevel.Trace, false, CacheStorageType.OnDiskEncrypted); MipContext mipContext = MIP.CreateMipContext(mipConfiguration); // Initialize and instantiate the File Profile. // Create the FileProfileSettings object. // Initialize file profile settings to create/use local state. var profileSettings = new FileProfileSettings(mipContext, CacheStorageType.OnDiskEncrypted, new ConsentDelegateImplementation()); // Load the Profile async and wait for the result. var fileProfile = Task.Run(async () => await MIP.LoadFileProfileAsync(profileSettings)).Result; // Create a FileEngineSettings object, then use that to add an engine to the profile. var customSettings = new List<KeyValuePair<string, string>>(); customSettings.Add(new KeyValuePair<string, string>("enable_msg_file_type", "true")); // Create a FileEngineSettings object, then use that to add an engine to the profile. var engineSettings = new FileEngineSettings("user1@tenant.com", authDelegate, "", "en-US"); engineSettings.Identity = new Identity("user1@tenant.com"); //set custom settings for the engine engineSettings.CustomSettings = customSettings; //Add fileEngine to profile var fileEngine = Task.Run(async () => await fileProfile.AddEngineAsync(engineSettings)).Result; //Set file paths string inputFilePath = "<input-file-path>"; //.msg file to be labeled string actualFilePath = inputFilePath; string outputFilePath = "<output-file-path>"; //labeled .msg file string actualOutputFilePath = outputFilePath; //Create a file handler for original file var fileHandler = Task.Run(async () => await fileEngine.CreateFileHandlerAsync(inputFilePath, actualFilePath, true)).Result; // List labels available to the user and use one of them to label the MSG file. foreach (var label in fileEngine.SensitivityLabels) { Console.WriteLine(string.Format("{0} - {1}", label.Name, label.Id)); if (label.Children.Count > 0) { foreach (Label child in label.Children) { Console.WriteLine(string.Format("\t{0} - {1}", child.Name, child.Id)); } } } string labelId = "<label-id>"; //label retrieved using file engine LabelingOptions labelingOptions = new LabelingOptions() { AssignmentMethod = AssignmentMethod.Standard }; Label label = fileEngine.GetLabelById(labelId); fileHandler.SetLabel(label, labelingOptions, new ProtectionSettings()); // Commit changes, save as outputFilePath var result = Task.Run(async () => await fileHandler.CommitAsync(outputFilePath)).Result; // Create a new handler to read the labeled file metadata var handlerModified = Task.Run(async () => await fileEngine.CreateFileHandlerAsync(outputFilePath, actualOutputFilePath, true)).Result; Console.WriteLine(string.Format("Original file: {0}", inputFilePath)); Console.WriteLine(string.Format("Labeled file: {0}", outputFilePath)); Console.WriteLine(string.Format("Label applied to file: {0}", handlerModified.Label.Label.Name)); Console.WriteLine("Press a key to continue."); Console.ReadKey(); // Application Shutdown fileHandler = null; handlerModified = null; fileEngine = null; fileProfile = null; mipContext = null; }Další informace o operacích se soubory naleznete v části Koncepty obsluhy souborů.
Zástupné hodnoty ve zdrojovém kódu nahraďte následujícími hodnotami:
Placeholder Hodnota <cesta k vstupnímu souboru> Úplná cesta k souboru s testovací zprávou, například: c:\\Test\\message.msg.<cesta k výstupnímu souboru> Úplná cesta k výstupnímu souboru, což je označená kopie vstupního souboru, například: c:\\Test\\message_labeled.msg.<identifikátor štítku> ID štítku získané pomocí souborového enginu, například: 667466bf-a01b-4b0a-8bbf-a79a3d96f720.
Sestavení a otestování aplikace
K sestavení klientské aplikace použijte klávesu F6 (Build Solution). Pokud nemáte chyby sestavení, spusťte aplikaci pomocí klávesy F5 (Spustit ladění).
Original file: C:\Test.msg
Labeled file: C:\Test_Labeled.msg
Label applied to file: Confidential
Press a key to continue.