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 označování pro .msg soubory způsobem identickým s jakýmkoli jiným typem souboru, s tím rozdílem, že sada SDK potřebuje aplikaci k povolení příznaku funkce MSG. Zde se dozvíme, jak tento příznak nastavit.
Jak bylo popsáno dříve, vytvoření instance IFileEngine vyžaduje objekt nastavení , FileEngineSettings. FileEngineSettings lze použít k předání parametrů pro vlastní nastavení, které aplikace potřebuje nastavit pro konkrétní instanci.
CustomSettings property of the FileEngineSettings is used to set the flag for enable_msg_file_type to enable processing of .msg files.
Požadavky
Pokud jste to ještě neudělali, nezapomeňte před pokračováním dokončit následující požadavky:
- Complete Quickstart: File SDK application initialization (C#) first, which builds a starter Visual Studio solution. This "How to - process email message .msg files (C#)" quickstart builds on the previous one.
- Review Email files MIP SDK concepts.
- Optionally: Review File engines in the MIP SDK concepts.
- Volitelně: Zkontrolujte obslužné rutiny souborů v konceptech sady MIP SDK .
Set enable_msg_file_type and use File SDK for labeling .msg file
In continuation of File API application initialization quickstart, modify the file engine construction code to set enable_msg_file_type flag and then use the file engine to label a .msg file.
Open the Visual Studio solution you created in the previous "Quickstart: File SDK application initialization (C#)".
V Průzkumníku ř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.Remove the implementation of
Main()function from previous quickstart. Vložte doMain()těla následující kód. In below code blockenable_msg_file_typeflag is set during file engine creation, a .msg file can then be processed byIFileHandlerobjects created using the file engine.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); MipContext mipContext = MIP.CreateMipContext(appInfo,"mip_data",LogLevel.Trace,null,null); // 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 = options.AssignmentMethod }; fileHandler.SetLabel(labelId, 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.Name)); Console.WriteLine("Press a key to continue."); Console.ReadKey(); // Application Shutdown fileHandler = null; handlerModified = null; fileEngine = null; fileProfile = null; mipContext = null; }Další podrobnosti o operacích se soubory najdete v konceptech obslužné rutiny souborů.
Zástupné hodnoty ve zdrojovém kódu nahraďte následujícími hodnotami:
Placeholder Hodnota <input-file-path> Ú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ž bude označená kopie vstupního souboru, například: c:\\Test\\message_labeled.msg.<identifikátor štítku> The labelId retrieved using file engine, for example: 667466bf-a01b-4b0a-8bbf-a79a3d96f720.
Sestavení a otestování aplikace
K sestavení klientské aplikace použijte klávesu F6 (Build Solution). Pokud nemáte žádné 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.