Exemple #1
0
        public void Setup()
        {
            UnityConfig.RegisterComponents(container =>
            {
                _container = container;

                container.RegisterType <IWmsEnvironmentInfoProvider, SvcWmsEnvironmentInfoProvider>(
                    new ContainerControlledLifetimeManager());
                container.RegisterType <ILocalData, ThreadStaticLocalData>(new ContainerControlledLifetimeManager());
                WmsEnvironment.Init(container.Resolve <IWmsEnvironmentInfoProvider>(), container.Resolve <ILocalData>());

                container.RegisterType <IExtensionsFactory, ExtensionsFactory>();
                container.RegisterType <IWorkflowChildContainerConfigurator, StubWorkflowChildContainerConfigurator>();

                _sessionFactory = _container.Resolve <ISessionFactory>();
            });
        }
Exemple #2
0
        public void TestWorkflowLoader()
        {
            UnityConfig.RegisterComponents(container =>
            {
                container.RegisterType <IWmsEnvironmentInfoProvider, SvcWmsEnvironmentInfoProvider>(new ContainerControlledLifetimeManager());
                container.RegisterType <ILocalData, ThreadStaticLocalData>(new ContainerControlledLifetimeManager());
                WmsEnvironment.Init(container.Resolve <IWmsEnvironmentInfoProvider>(), container.Resolve <ILocalData>());
                var path = Directory.GetCurrentDirectory();
                path     = path.Replace("MLC.Wms.Api.Tests\\bin\\Debug", "MLC.Wms.Workflows\\Wf_Data");

                container.RegisterType <IWorkflowLoader, FileWorkflowLoader>(new ContainerControlledLifetimeManager(), new InjectionFactory(c => new FileWorkflowLoader(path, true)));

                var api  = container.Resolve <WmsAPI>();
                var res1 = api.GetWorkflow("CLIENT", "PIN_CREATE", "1.0.0.0");
                res1.Should().NotBe("Can't get body WF Client.Pin_Create");
            });
        }
Exemple #3
0
        public void Setup()
        {
            // init log4net
            XmlConfigurator.Configure();

            UnityConfig.RegisterComponents(container =>
            {
                container.RegisterType <IWmsEnvironmentInfoProvider, ManualWmsEnvironmentInfoProvider>(
                    new ContainerControlledLifetimeManager());
                WmsEnvironment.Init(container.Resolve <IWmsEnvironmentInfoProvider>(), null);

                // запускаем wf
                WorkflowServicesUnityConfigurator.Configure(container, false);

                _container = container;
            });
        }
Exemple #4
0
        public void Setup()
        {
            try
            {
                UnityConfig.RegisterComponents(container =>
                {
                    var config  = (EpsConfigSection)ConfigurationManager.GetSection(EpsConfigSection.DefaultSectionName);
                    var mockCfg = new Mock <IEpsConfiguration>();

                    mockCfg.Setup(i => i.ArchPath).Returns(Path.Combine(TestContext.CurrentContext.TestDirectory, config.ArchPath));
                    mockCfg.Setup(i => i.ReportPath).Returns(Path.Combine(TestContext.CurrentContext.TestDirectory, config.ReportPath));
                    mockCfg.Setup(i => i.TmpPath).Returns(Path.Combine(TestContext.CurrentContext.TestDirectory, config.TmpPath));
                    mockCfg.Setup(i => i.OdacConnectionString).Returns(config.OdacConnectionString);
                    mockCfg.Setup(i => i.OdbcConnectionString).Returns(config.OdbcConnectionString);
                    //config.ReportPath = TestContext.CurrentContext.TestDirectory;

                    // конфигурируем окружение
                    var envInfoProvider = new SvcWmsEnvironmentInfoProvider();
                    envInfoProvider.SetUserName(AutoTestUser);
                    WmsEnvironment.Init(envInfoProvider, null);

                    // регистрируем нужное
                    container.RegisterInstance <IEpsConfiguration>(mockCfg.Object);
                    container.RegisterInstance <IEpsMailConfig>(config.MailSettings);
                    container.RegisterType <IEpsJobFactory, EpsJobFactory>();
                    container.RegisterType <IEpsTaskFactory, EpsTaskFactory>();
                    //container.RegisterType<IEpsReportFactory, EpsReportFactory>();
                    container.RegisterType <IReportExporterFactory, ReportExporterFactory>();
                    container.RegisterType <IMacroProcessor, MacroProcessor>(new PerResolveLifetimeManager());

                    _testReportFactory = container.Resolve <EpsTestReportFactory>();
                    container.RegisterInstance <IEpsReportFactory>(_testReportFactory);


                    _sessionFactory = container.Resolve <ISessionFactory>();

                    _container = container;
                });
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public void EnqueueTest()
        {
            UnityConfig.RegisterComponents(container =>
            {
                var svc     = container.Resolve <QueueService>();
                var factory = container.Resolve <ISessionFactory>();

                container.RegisterType <IWmsEnvironmentInfoProvider, SvcWmsEnvironmentInfoProvider>(new ContainerControlledLifetimeManager());
                container.RegisterType <ILocalData, ThreadStaticLocalData>(new ContainerControlledLifetimeManager());
                WmsEnvironment.Init(container.Resolve <IWmsEnvironmentInfoProvider>(), container.Resolve <ILocalData>());

                var request         = new EnqueueListRequest();
                request.PartnerCode = "TST";
                request.MessageList = new[]
                {
                    new QueueMessage
                    {
                        Data = "test data",
                        QueueMessageTypeCode = "TST"
                    }
                };

                var response = svc.EnqueueListIn(request);
                response.MessageList.Should().HaveCount(1);
                response.MessageList[0].ID.Should().HaveValue();
                response.MessageList[0].QueueMessageTypeCode.ShouldBeEquivalentTo(request.MessageList[0].QueueMessageTypeCode);
                response.MessageList[0].Data.ShouldBeEquivalentTo(request.MessageList[0].Data);

                using (var session = factory.OpenSession())
                    using (var transaction = session.BeginTransaction())
                    {
                        foreach (var message in response.MessageList)
                        {
                            var item = session.Get <IoQueueIn>(message.ID);
                            //TODO: проверка, что записалось правильно

                            // удалеям лишнее
                            session.Delete(item);
                        }
                        transaction.Commit();
                    }
            });
        }
Exemple #6
0
        public void Test()
        {
            UnityConfig.RegisterComponents(container =>
            {
                var factory = container.Resolve <ISessionFactory>();

                container.RegisterType <IWmsEnvironmentInfoProvider, SvcWmsEnvironmentInfoProvider>(new ContainerControlledLifetimeManager());
                container.RegisterType <ILocalData, ThreadStaticLocalData>(new ContainerControlledLifetimeManager());
                WmsEnvironment.Init(container.Resolve <IWmsEnvironmentInfoProvider>(), container.Resolve <ILocalData>());

                using (var session = factory.OpenSession())
                {
                    var qType = session.Query <IoQueueMessageType>().First(i => i.Code == "IP_LOAD_ART");
                    var q     =
                        session.Query <IoQueueIn>()
                        .Where(i => i.QueueMessageType == qType)
                        .OrderBy(i => i.DateIns)
                        .First();
                    var result = SerializationHelper.Deserialize <ArticleLoad>(q.Data);
                }
            });
        }
Exemple #7
0
        public void DoTest()
        {
            UnityConfig.RegisterComponents(container =>
            {
                //var factory = container.Resolve<ISessionFactory>();

                container.RegisterType <IWmsEnvironmentInfoProvider, SvcWmsEnvironmentInfoProvider>(new ContainerControlledLifetimeManager());
                container.RegisterType <ILocalData, ThreadStaticLocalData>(new ContainerControlledLifetimeManager());
                WmsEnvironment.Init(container.Resolve <IWmsEnvironmentInfoProvider>(), container.Resolve <ILocalData>());
                container.RegisterType <IWorkflowLoader, FileWorkflowLoader>(new ContainerControlledLifetimeManager(), new InjectionFactory(c => new FileWorkflowLoader(Directory.GetCurrentDirectory(), false)));

                //var classMetadata = factory.GetClassMetadata(typeof(WmsEventHeader).Name);
                //var userMetadata = classMetadata as NHibernate.Persister.Entity.AbstractEntityPersister;
                //if (userMetadata != null)
                //{
                //    var cols = userMetadata.KeyColumnNames;
                //    var table = userMetadata.TableName;

                //    //userMetadata.SubclassColumnClosure
                //    var t = userMetadata.GetSubclassPropertyColumnNames("EventKind");
                //}

                var api = container.Resolve <WmsAPI>();

                //api.ChangeOwnerByOwb(14249, "OP_OPERATOR_OWBPROCESSING", "WEB", null);

                //api.RegEvent(null, new WmsEventHeader(), new wmsEventDetailPRD(), null);
                //api.RegEvent(factory.OpenSession(), new WmsEventHeader(), new wmsEventDetailPRD(), null);

                //var prev = "SDCL_DEBUG";
                //var res = api.GetSdclEndPoint("P8Z77-002", prev, null);
                //var prev = "";
                //var res = api.GetSdclEndPoint("P8H61-047", prev, null);

                //var res = api.GetEntityMappingByWmsEntity("TE");

                //var eventHeader = new WmsEventHeader
                //{
                //    Partner = new WmsMandant { PartnerID = 5 },
                //    Operation = new BillOperation { OperationCode = "OP_OPERATOR_OWBOUTPUT" },
                //    EventKind = new WmsEventKind { EventKindCode = "PRD_OUTPUT" },
                //    EventHeaderStartTime = new DateTime(2014, 6, 18, 11, 17, 22), //18.06.2014 11:17:22
                //    ClientSession = null,
                //    ClientType = new SysClientType { ClientTypeCode = "DCL" },
                //    EventHeaderInstance = "WmsApi"
                //};
                //var eventDetail = new wmsEventDetailPRD
                //{
                //    ProductID_r = 22111 //17821
                //};

                //api.RegEvent(null, eventHeader, eventDetail, null);

                //var res = api.RegEventPl(5002, "OP_PICKING_TERM", "PRD_PICK", 72134, "RCL", null, null, 7150, 142484, "37GS2012031001003", null);
                //var res = api.ValidatePlace("41M25006018002004", "EU216074", true, true, null);

                //api.ReserveOwbList(new[] {1,2}, "OP_OPERATOR_OWBPROCESSING", null);

                //api.IntegrationInSetOrderReserve(14687);


                //Отчёты
                //api.ExecuteEpsJob("C_SENDAPP", "Test", null);
                //var res = api.GetDefaultPrinter("TListParams(TParam('REPORT_R','MX-1',null),TParam('HOST_R','B75M-001',null))");
                //api.PrintReport("CstReqCustoms_test1", "Glebachev_YV", null); //"http://localhost/epsapi/v1/eps/print"

                //var res = api.GetEpsConfig();
                //return;

                api.PrintReport("CstReqCustoms_test1", "Glebachev_YV", new Dictionary <string, object>
                {
                    {
                        "ResultReportFile",
                        "${SQL=select 'MO_OWB_Order_'||'{OWBID}'||'_'|| TO_CHAR(sysdate,'ddMMyyyy') from dual}"
                    },
                    { "OWBID", 171579 }
                }, null);
                //Отчёты
            });
        }
Exemple #8
0
        public void AppTest()
        {
            UnityConfig.RegisterComponents(container =>
            {
                var factory = container.Resolve <ISessionFactory>();

                container.RegisterType <IWmsEnvironmentInfoProvider, SvcWmsEnvironmentInfoProvider>(
                    new ContainerControlledLifetimeManager());
                container.RegisterType <ILocalData, ThreadStaticLocalData>(new ContainerControlledLifetimeManager());
                WmsEnvironment.Init(container.Resolve <IWmsEnvironmentInfoProvider>(), container.Resolve <ILocalData>());

                using (var session = factory.OpenSession())
                {
                    var intType    = OracleDbType.Int32;
                    var stringType = OracleDbType.Varchar2;
                    var dateType   = OracleDbType.Date;
                    var dataInt    = new int[] { 1, 2, 3 };
                    var dataString = new string[] { "test1", "test2", "test3" };
                    var dataDate   = new DateTime[] { DateTime.Now, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2) };

                    #region . OutParam .

                    var cmd         = (OracleCommand)session.Connection.CreateCommand();
                    cmd.CommandText = "pkgAppTest.bpTestOutParam";
                    cmd.CommandType = CommandType.StoredProcedure;

                    var pCount       = cmd.Parameters.Add("pCount", intType);
                    pCount.Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    var valueOut = cmd.Parameters[0].Value;

                    if (!(valueOut is OracleDecimal))
                    {
                        throw new Exception("Error bpTestOutParam");
                    }

                    var oraDecimal = (OracleDecimal)valueOut;
                    ((int)oraDecimal.Value).CompareTo(100);

                    #endregion

                    #region . IntArray .

                    cmd             = (OracleCommand)session.Connection.CreateCommand();
                    cmd.CommandText = "pkgAppTest.bpTestArrayIntParam";
                    cmd.CommandType = CommandType.StoredProcedure;

                    var pArray            = cmd.Parameters.Add("pArray", intType);
                    pArray.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                    pArray.Size           = dataInt.Length;
                    pArray.Value          = dataInt;
                    var pSum       = cmd.Parameters.Add("pSum", intType);
                    pSum.Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    var valueSum = cmd.Parameters[1].Value;

                    if (!(valueSum is OracleDecimal))
                    {
                        throw new Exception("Error bpTestArrayIntParam");
                    }

                    oraDecimal = (OracleDecimal)valueSum;
                    ((int)oraDecimal.Value).CompareTo(dataInt.Sum());

                    #endregion

                    #region . Array Other Type .

                    cmd             = (OracleCommand)session.Connection.CreateCommand();
                    cmd.CommandText = "pkgAppTest.bpTestArrayParam";
                    cmd.CommandType = CommandType.StoredProcedure;

                    var pInt            = cmd.Parameters.Add("pInt", intType);
                    pInt.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                    pInt.Size           = dataInt.Count();
                    pInt.Value          = dataInt;

                    var pString            = cmd.Parameters.Add("pString", stringType);
                    pString.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                    pString.Size           = dataString.Count();
                    pString.Value          = dataString;

                    var pDate            = cmd.Parameters.Add("pDate", dateType);
                    pDate.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                    pDate.Size           = dataString.Count();
                    pDate.Value          = dataDate;

                    var pCountParam       = cmd.Parameters.Add("pCountParam", intType);
                    pCountParam.Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    var valueCount = cmd.Parameters[3].Value;

                    if (!(valueCount is OracleDecimal))
                    {
                        throw new Exception("Error bpTestArrayParam");
                    }

                    oraDecimal = (OracleDecimal)valueCount;
                    ((int)oraDecimal.Value).CompareTo(dataInt.Count() + dataString.Count() + dataDate.Count());

                    #endregion
                }
            });
        }