﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;


namespace TestWcfClient
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceReference1.Service1Client host = new ServiceReference1.Service1Client();
            //host.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            Console.WriteLine("Initialized....");
            string[] templates= host.GetTemplateList();
            
            Console.WriteLine("Fecthing templates....");
            Console.WriteLine("====== All templates on RMS Server =====");

            for(int i=0;i<templates.Length;i++)
            {
                Console.WriteLine((i+1).ToString()+" : "+templates[i]);
            }
            Console.WriteLine("===== Total : "+templates.Length+" templates =====");

            Console.WriteLine("Please input a number to choose a template,e.g. 1 ");
            int chosenIndex = -1;
            while (!int.TryParse(Console.ReadLine(), out chosenIndex) || chosenIndex<1 || chosenIndex>templates.Length)
            {
                Console.WriteLine("Input error, please check and try again!");            
            }
            ////encrypt
            host.EncryptFile(templates[chosenIndex - 1]);
            Console.WriteLine("Encryption success. Template used is " + templates[chosenIndex-1]);
            Console.ReadKey();        

        }
    }
}
