示例#1
0
        static void Main(string[] args)
        {
            // выбераем сертификат
            var cert = GetCert();

            if (cert == null)
            {
                return;
            }

            Console.WriteLine("Укажите pin ЭЦП");
            string pin = string.Empty;//Console.ReadLine();

            var config = new ClientConfig {
                UseTunnel             = false,
                IsPPAK                = false,
                CertificateThumbprint = cert.Item2,
                OrgPPAGUID            = "b14c8b87-6d0d-4854-a97c-74d34e1a8ca1",
                OrgEntityGUID         = "c3ffd8b6-cda3-4eb5-9696-30fee607c8b3",
                Role = Globals.OrganizationRole.UK
            };

            // иницализируем менеджер конечных точек
            ServicePointConfig.InitConfig(cert.Item2, pin, cert.Item1);

            var story  = new MessageStory();
            var broker = new MessageBroker(config, story);


            broker.AddHanbler(typeof(exportAccountResultType), ExportAccountResultHandler);
            broker.AddHanbler(typeof(exportHouseResultType), ExportHouseResultHandler);

            BuilderOption opt = new BuilderOption();

            opt.IsOperator = false;
            opt.Direction  = Framework.Enums.RequestDirection.Export;
            opt.Params.Add(Framework.Enums.ParametrType.OrgPPAGUID, "b14c8b87-6d0d-4854-a97c-74d34e1a8ca1");
            opt.Params.Add(Framework.Enums.ParametrType.FIASHouseGUID, "7263796e-1d5a-4535-8def-93315e8975db");

            var builder = new RequestBuilderFactory();

            builder.BuildError += Factory_BuildError;
            builder.Add <exportHouseDataRequest, ExportHouse>(opt);
            builder.Add <exportAccountDataRequest, ExportAccount>(opt);

            exportHouseDataRequest      request  = null;
            exportAccountDataRequest    request2 = null;
            exportStatusCAChDataRequest request3 = null;

            if (builder.TryBuild(opt, out request3))
            {
            }

            if (builder.TryBuild(opt, out request))
            {
                Console.WriteLine("Добавляем сообщения в очередь");
                for (int i = 0; i < 10; i++)
                {
                    request.RequestHeader.MessageGUID = Guid.NewGuid().ToString().ToLower();
                    broker.CreateMessage(request, EndPoints.HouseManagementAsync);
                }

                broker.CreateMessage(request, EndPoints.HouseManagementAsync);
            }
            if (builder.TryBuild(opt, out request2))
            {
                broker.CreateMessage(request2, EndPoints.HouseManagementAsync);
            }

            broker.SendMessage();
            Console.WriteLine("Отправлено");

            broker.CheckResult();

            Console.WriteLine("Обработка");
            broker.Process();

            Console.ReadKey();
        }