Пример #1
0
        static void Main(string[] args)
        {
            try
            {

                PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps = new PerSecurityWSDL.PerSecurityWS();

                /*Required for the VS2003 or older versions
                 X509Certificate clientCert = X509Certificate.CreateFromCertFile("C:\\DLCert.cer");*/

                X509Certificate2 clientCert = new X509Certificate2("C:\\DLWSCert.p12", "PASSWORD");
                ps.ClientCertificates.Add(clientCert);
                Boolean flag = true;
                do
                {
                    Console.WriteLine("Please enter the number to choose the request Type: ");
                    Console.WriteLine("1)Get Data Request\n2)Get Data Request with Pricing Source Header" +
                        "\n3)Schedule Request   \n4)Bulk Request \n5)Get Data Macro Request \n6)History Request"
                        + "\n7)History Macro Request   \n8)History request with Pricing source header  \n9)Fundamentals Request" +
                        "\n10)Get Company Request \n11)Get Quotes Request \n12)Get Actions Request" + 
                        "\n13)Cancel Request \n14)PortFolio Validation Request \n15)Get Data Request with Fieldset" + 
                        "\n16)Get All Quotes Request \n17)GetCompany Request with Fieldset"
                        +"\n18)Exit");

                    String read = Console.ReadLine();
               
                    int reqType = int.Parse(read);
                    switch (reqType)
                    {
                                            
                        case 1:
                            // Making request for non-bulk fields
                            Console.WriteLine("\n**********Sending simple request");
                            SimpleGetDataRequest smpReq = new SimpleGetDataRequest();
                            smpReq.run(ps);
                            break;

                        case 2:
                            //Making GetData request with a Pricing Source in header
                            Console.WriteLine("\n**********\nSending getdata request with Pricing source header");
                            PricingSourceHeaderRequest getDataPricingSrcHdrReq = new PricingSourceHeaderRequest();
                            getDataPricingSrcHdrReq.run(ps);
                            break;

                        case 3:
                            // Making scheduled request
                            Console.WriteLine("\n**********\nSending Scheduled request");
                            ScheduledRequest schReq = new ScheduledRequest();
                            schReq.run(ps);
                            break;

                        case 4:
                            // Making request for bulk fields
                            Console.WriteLine("\n**********\nSending Bulk request");
                            BulkRequest blkReq = new BulkRequest();
                            blkReq.run(ps);
                            break;

                        case 5:
                            // Making request for Macro requests
                            Console.WriteLine("\n**********\nSending getdata macro request");
                            GetDataMacroRequest mcroReq = new GetDataMacroRequest();
                            mcroReq.run(ps);
                            break;

                        case 6:
                            // Making History request
                            Console.WriteLine("\n**********\nSending History request");
                            HistoryRequest histReq = new HistoryRequest();
                            histReq.run(ps);
                            break;

                        case 7:
                            // Making History request with a macro
                            Console.WriteLine("\n**********\nSending History Macro request");
                            HistoryMacroRequest histMacrReq = new HistoryMacroRequest();
                            histMacrReq.run(ps);
                            break;

                        case 8:
                            //Making History request with a Pricing Source in header
                            Console.WriteLine("\n**********\nSending History request with Pricing source header");
                            GetHistPricingSourceHeaderRequest pricingSrcHdrReq = new GetHistPricingSourceHeaderRequest();
                            pricingSrcHdrReq.run(ps);
                            break;

                        case 9:
                            // Making Fundamentals request
                            Console.WriteLine("\n**********\nSending Fundamentals request");
                            FundamentalsRequest getFundsReq = new FundamentalsRequest();
                            getFundsReq.run(ps);
                            break;

                        case 10:
                            // Making a Get Company request
                            Console.WriteLine("\n**********\nSending Get Company request");
                            GetCompany getCompReq = new GetCompany();
                            getCompReq.run(ps);
                            break;

                        case 11:
                            // Making a Get Quotes request
                            Console.WriteLine("\n**********\nSending Get Quotes request");
                            GetQuotesRequest getQuotesReq = new GetQuotesRequest();
                            getQuotesReq.run(ps);
                            break;

                        case 12:
                            // Making a Get Actions request
                            Console.WriteLine("\n**********\nSending Get Actions request");
                            GetActionsRequest getActionsReq = new GetActionsRequest();
                            getActionsReq.run(ps);
                            break;

                        case 13:
                            // Making a Cancel request
                            Console.WriteLine("\n**********\nSending Cancel request");
                            CancelAllRequest cancelReq = new CancelAllRequest();
                            cancelReq.run(ps);
                            break;

                        case 14:
                            // Making a get portfolio validation request
                            Console.WriteLine("\n**********\nSending portfolio validation request");
                            PortFolioValidation portFolioVldtn = new PortFolioValidation();
                            portFolioVldtn.run(ps);
                            break;

                        case 15:
                            // Making a getdata request with fieldset
                            Console.WriteLine("\n**********\nSending getdata request with fieldset");
                            GetDataFieldSetRequest GtDtFldStReq = new GetDataFieldSetRequest();
                            GtDtFldStReq.run(ps);
                            break;

                        case 16:
                            // Making a getallquotes request
                            Console.WriteLine("\n**********\nSending getallquotes request");
                            GetAllQuotesRequest GtAllQtsReq = new GetAllQuotesRequest();
                            GtAllQtsReq.run(ps);
                            break;

                        case 17:
                            // Making a getcompany fieldset request
                            Console.WriteLine("\n**********\nSending getcompany request with fieldset");
                            GetCompanyFieldSet getCmpnyFldSet = new GetCompanyFieldSet();
                            getCmpnyFldSet.run(ps);
                            break;
                        case 18:
                            flag = false;
                            break;
                        default:
                            break;

                        
                    }
                    Console.WriteLine("");
                } while (flag);
                
                


            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //			

        }
Пример #2
0
        private static void Main(string[] args)
        {
            try
            {
                ProgramFlag programFlag = default(ProgramFlag);
                string      sampleName  = string.Empty;

                Dictionary <string, ProgramFlag> programFlagRef = new Dictionary <string, ProgramFlag>();
                programFlagRef.Add("adhoc", ProgramFlag.adhoc);
                programFlagRef.Add("scheduled", ProgramFlag.oneshot);

                Parser.Default.ParseArguments <Options>(args)
                .WithParsed <Options>(opts =>
                {
                    if (!programFlagRef.ContainsKey(opts.ProgramFlag))
                    {
                        Console.WriteLine("Unrecognized programFlag " + opts.ProgramFlag + "\n");
                        Console.WriteLine(Options.ProgramFlagHelpText);
                        Environment.Exit(1);
                    }
                    programFlag = programFlagRef[opts.ProgramFlag];
                    sampleName  = opts.SampleName;
                })
                .WithNotParsed <Options>(opts =>
                {
                    Environment.Exit(1);
                });

                string           clientCertFilePath = ConfigurationManager.AppSettings["clientCertFilePath"];
                string           clientCertPassword = ConfigurationManager.AppSettings["clientCertPassword"];
                X509Certificate2 clientCert         = new X509Certificate2(clientCertFilePath, clientCertPassword);

                PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWSClient ps = new PerSecurityWSClient("PerSecurityWSPort");
                ps.ClientCredentials.ClientCertificate.Certificate = clientCert;

                /*Add following lines for proxy
                 * NetworkCredential nc = new NetworkCredential("username", "password", "domain");
                 * WebProxy proxy = new WebProxy("http//webproxyserver:80");
                 * proxy.Credentials = nc;
                 * ps.Proxy = proxy;
                 */
                switch (sampleName)
                {
                case "GetData":
                    // Making request for non-bulk fields
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetData smpReq = new GetData();
                    smpReq.run(ps);
                    break;

                case "GetDataPricingSourceHeader":
                    // Making GetData request with a Pricing Source in header
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetDataPricingSourceHeader getDataPricingSrcHdrReq = new GetDataPricingSourceHeader();
                    getDataPricingSrcHdrReq.run(ps);
                    break;

                case "Scheduled":
                    // Making scheduled request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    Scheduled schReq = new Scheduled();
                    schReq.run(ps);
                    break;

                case "GetDataBulkFields":
                    // Making GetData request with bulk fields
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetDataBulkFields blkReq = new GetDataBulkFields();
                    blkReq.run(ps);
                    break;

                case "GetDataMacro":
                    // Making request for Macro requests
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetDataMacro mcroReq = new GetDataMacro();
                    mcroReq.run(ps);
                    break;

                case "GetHistory":
                    // Making History request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetHistory histReq = new GetHistory();
                    histReq.run(ps);
                    break;

                case "GetHistoryMacro":
                    // Making History request with a macro
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetHistoryMacro histMacrReq = new GetHistoryMacro();
                    histMacrReq.run(ps);
                    break;

                case "GetHistoryPricingSourceHeader":
                    // Making History request with a Pricing Source in header
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetHistoryPricingSourceHeader pricingSrcHdrReq = new GetHistoryPricingSourceHeader();
                    pricingSrcHdrReq.run(ps);
                    break;

                case "GetCompany":
                    // Making a Get Company request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetCompany getCompReq = new GetCompany();
                    getCompReq.run(ps);
                    break;

                case "GetQuotes":
                    // Making a Get Quotes request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetQuotes getQuotesReq = new GetQuotes();
                    getQuotesReq.run(ps, programFlag);
                    break;

                case "GetActions":
                    // Making a Get Actions request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetActions getActionsReq = new GetActions();
                    getActionsReq.run(ps);
                    break;

                case "Cancel":
                    // Making a Cancel request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    Cancel cancelReq = new Cancel();
                    cancelReq.run(ps);
                    break;

                case "PortfolioValidation":
                    // Making a get portfolio validation request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    PortfolioValidation portFolioVldtn = new PortfolioValidation();
                    portFolioVldtn.run(ps);
                    break;

                case "GetDataFieldSet":
                    // Making a getdata request with fieldset
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetDataFieldSet gtDtFldStReq = new GetDataFieldSet();
                    gtDtFldStReq.run(ps);
                    break;

                case "GetAllQuotes":
                    // Making a getallquotes request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetAllQuotes gtAllQtsReq = new GetAllQuotes();
                    gtAllQtsReq.run(ps, programFlag);
                    break;

                case "GetCompanyFieldSet":
                    // Making a getcompany fieldset request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetCompanyFieldSet gtCmpnyFldSet = new GetCompanyFieldSet();
                    gtCmpnyFldSet.run(ps);
                    break;

                case "GetDataOverrides":
                    // Making a simple getdata request with overrides
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetDataOverrides smpReqOvr = new GetDataOverrides();
                    smpReqOvr.run(ps);
                    break;

                case "GetFields":
                    // Making a getFields request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetFields sbmtGtFldsReq = new GetFields();
                    sbmtGtFldsReq.run(ps);
                    break;

                case "GetCorrections":
                    // Making a getCorrections request
                    Console.WriteLine("\n**********Running " + sampleName + " sample**********\n");
                    GetCorrections sbmtGtCorrReq = new GetCorrections();
                    sbmtGtCorrReq.run(ps);
                    break;

                default:
                    Console.WriteLine("Unrecognized sampleName " + sampleName + "\n");
                    Console.WriteLine(Options.SampleNameHelpText);
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }