Beispiel #1
0
        /**/

        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                new Program();
            }
            else if (args[0].Contains("-"))
            {
                new Program(args);
            }
            else
            {
                Configuration conf = DFSHelper.GetAppConfiguration(args[0]);
                Logger.loadConfig(conf);
                Logger.log("start");
                new Program(conf);
                Logger.log("end");
            }
        }
Beispiel #2
0
        public Program(String[] args)
        {
            Program.conf = DFSHelper.GetAppConfiguration("configuration.xml");
            Logger.loadConfig();
            controller = new Controller();
            switch (args[0])
            {
            case "-allcerts":
                // testing crypto etc.
                testCrypto();
                break;

            case "-infocert":
                ExCert cert = null;
                try
                {
                    cert = controller.GetExCertificate(args[1]);
                    Console.WriteLine("certificate info:");
                    Console.WriteLine(cert.ToString());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                break;

            case "-testcert":
                String sign       = null;
                String base64data = Utils.Base64DecodeToString(Encoding.GetEncoding("UTF-8").GetBytes("somedata"), "UTF-8");
                try
                {
                    sign = controller.Sign(args[1], base64data);
                    if (sign != null)
                    {
                        Console.WriteLine("signing O.K.");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                break;

            case "-testrestFULLDEBUG":
                AuthorizeRequest debugReq = new AuthorizeRequest(conf.Login, conf.Api_pass);
                Console.WriteLine("request body:");
                Console.WriteLine(Utils.ToJson(debugReq));
                AuthorizeResponse debugResp = (AuthorizeResponse)Http2.post <AuthorizeResponse>("https://api-service.edi.su/Api/Dixy/Index/Authorize", debugReq);
                Console.WriteLine("response body:");
                Console.WriteLine(Utils.ToJson(debugResp));
                if (debugResp != null)
                {
                    Console.WriteLine("rest O.K.");
                }
                break;

            case "-testrest":
                AuthorizeResponse response = (AuthorizeResponse)Http2.post <AuthorizeResponse>("https://api-service.edi.su/Api/Dixy/Index/Authorize", new AuthorizeRequest(conf.Login, conf.Api_pass));
                if (response != null)
                {
                    Console.WriteLine("rest O.K.");
                }
                break;

            case "-testsoap":
                GetListRequest req = new GetListRequest();
                req.user       = new User();
                req.user.login = conf.Login;
                req.user.pass  = Utils.GetMD5String(conf.Soap_pass);
                GetListResponse resp = (GetListResponse)Soap.GetList <GetListResponse>(req);
                if (resp != null)
                {
                    Console.WriteLine("soap O.K.");
                }
                break;
            }
        }