コード例 #1
0
        public static IoQueueIn GetQueueIn_NonValidOwbState(ISession session)
        {
            var tstMandant = GetTstMandant(session);

            _newOwb = new WmsOWB
            {
                Partner        = tstMandant,
                OWBName        = "Sample Name",
                OWBProductNeed = "NOACTIVATE",
                OWBType        = "OWBTYPENORMAL",
                Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_COMPLETED")
            };
            session.Save(_newOwb);

            return(new IoQueueIn
            {
                Mandant = tstMandant,
                QueueMessageType = session.Query <IoQueueMessageType>().First(i => i.Code == QueueMessageTypeCode),
                QueueMessageState = QueueMessageStates.Processing,
                Message = null,
                Data = SerializationHelper.SerializeToBytes(new UniversalCommandMessage()
                {
                    CommandList = new List <Command>
                    {
                        new Command {
                            Name = "OWBName", Value = _newOwb.OWBName
                        }
                    }
                })
            });
        }
コード例 #2
0
        public void Test1()
        {
            using (var session = _sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    var fakeSession = new SessionDecorator(session)
                    {
                        DoNotDispose        = true,
                        ExternalTransaction = new TransactionDecorator(transaction)
                        {
                            DisableActions = true
                        }
                    };
                    var mockSessionFactory = new Mock <ISessionFactory>();
                    mockSessionFactory.Setup(i => i.OpenSession()).Returns(fakeSession);

                    var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == "TST");

                    var owb = new WmsOWB
                    {
                        Partner        = tstMandant,
                        OWBName        = "Owb for testing change owner",
                        OWBProductNeed = "NOACTIVATE",
                        OWBType        = "OWBTYPENORMAL",
                        Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_CREATED")
                    };

                    session.Save(owb);

                    // запускаем
                    var api = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>());
                    api.IntegrationInSetOrderReserve(owb.OWBID);

                    //Ищем сообшение
                    var ins =
                        session.Query <IoQueueIn>()
                        .Where(
                            p =>
                            p.Mandant == tstMandant && p.QueueMessageType.Code == "SET_ORDER_RESERVE" &&
                            p.QueueMessageState == QueueMessageStates.Ready && p.DateIns >= DateTime.Now.Date)
                        .ToArray();

                    var testresult = new List <bool>();
                    foreach (var que in ins)
                    {
                        var message = SerializationHelper.Deserialize <UniversalCommandMessage>(que.Data);
                        if (message.CommandList.FirstOrDefault(p => p.Name == "OWBId" && p.Value == owb.OWBID.ToString()) !=
                            null)
                        {
                            testresult.Add(true);
                        }
                    }

                    testresult.Should().HaveCount(1);

                    transaction.Rollback();
                }
        }
コード例 #3
0
        public static IoQueueIn GetQueueIn(ISession session)
        {
            var partnerCode          = "TST";
            var queueMessageTypeCode = "SET_ORDER_RESERVE";

            var partner = session.Query <WmsMandant>().Single(o => o.PartnerCode == partnerCode);

            var owb = new WmsOWB()
            {
                Partner        = partner,
                OWBOwner       = partner,
                OWBName        = OwbName,
                OWBPriority    = 1,
                Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_CREATED"),
                OWBProductNeed = "NOACTIVATE",
                OWBType        = "OWBTYPENORMAL"
            };

            session.Save(owb);

            return(new IoQueueIn
            {
                Mandant = partner,
                QueueMessageType = session.Query <IoQueueMessageType>().First(i => i.Code == queueMessageTypeCode),
                QueueMessageState = QueueMessageStates.Processing,
                Message = null,
                Data = SerializationHelper.SerializeToBytes(new UniversalCommandMessage()
                {
                    CommandList = new List <Command>()
                    {
                        new Command()
                        {
                            Name = "OWBName", Value = OwbName
                        },
                        new Command()
                        {
                            Name = "OWBId", Value = owb.OWBID.ToString()
                        }
                    }
                })
            });
        }
コード例 #4
0
        public void Test1()
        {
            using (var session = _sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    var fakeSession = new SessionDecorator(session)
                    {
                        DoNotDispose        = true,
                        ExternalTransaction = new TransactionDecorator(transaction)
                        {
                            DisableActions = true
                        }
                    };
                    var mockSessionFactory = new Mock <ISessionFactory>();
                    mockSessionFactory.Setup(i => i.OpenSession()).Returns(fakeSession);

                    var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == "TST");

                    var owb = new WmsOWB
                    {
                        Partner        = tstMandant,
                        OWBName        = "Owb for testing change owner",
                        OWBProductNeed = "NOACTIVATE",
                        OWBType        = "OWBTYPENORMAL",
                        Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_CREATED")
                    };

                    session.Save(owb);

                    // запускаем
                    var    api    = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>());
                    Action action = () => { api.ChangeOwnerByOwb(owb.OWBID, "OP_OPERATOR_OWBPROCESSING", "TEST", null); };

                    action.ShouldThrow <Exception>().Which.Message.Should().Contain("в статусе 'OWB_CREATED' запрещена");

                    transaction.Rollback();
                }
        }
コード例 #5
0
        public void Test()
        {
            var sessionShareExtention = new SessionShareExtention();

            var mockWfStorage = new Mock <IWorkflowStorage>();

            mockWfStorage.Setup(i => i.Load(_wfIdentity)).Returns(_wf);
            var wfAppFactory = new WorkflowApplicationFactory(null as InstanceStore, mockWfStorage.Object);

            using (var childContainer = _container.CreateChildContainer())
            {
                childContainer.RegisterInstance <IWorkflowApplicationFactory>(wfAppFactory);
                childContainer.RegisterInstance(sessionShareExtention, new ContainerControlledLifetimeManager());

                using (var session = _sessionFactory.OpenSession())
                    using (var transaction = session.BeginTransaction())
                    {
                        var sessionDecorator = new SessionDecorator(session)
                        {
                            DoNotDispose        = true,
                            ExternalTransaction = new TransactionDecorator(transaction)
                            {
                                DisableActions = true
                            }
                        };

                        var sessionFactoryMock = new Mock <ISessionFactory>();
                        sessionFactoryMock.Setup(i => i.OpenSession()).Returns(sessionDecorator);
                        sessionFactoryMock.Setup(i => i.OpenSession(It.IsAny <IInterceptor>())).Returns(sessionDecorator);

                        #region prepare data

                        var mandant = session.Query <WmsMandant>().FirstOrDefault(o => o.PartnerCode == MandantCode);
                        if (mandant == null)
                        {
                            throw new Exception(string.Format("Отсутствует тестовый мандант с кодом '{0}'", MandantCode));
                        }

                        var eventKind = session.Query <WmsEventKind>().FirstOrDefault(o => o.EventKindCode == EventKindCode);
                        if (eventKind == null)
                        {
                            throw new Exception(string.Format("Отсутствует вид события с кодом '{0}'", EventKindCode));
                        }

                        var partner = new WmsPartner
                        {
                            PartnerCode         = _testName,
                            PartnerName         = _testName,
                            PartnerLink2Mandant = mandant,
                            PartnerHostRef      = _testName
                        };
                        session.Save(partner);

                        var owb = new WmsOWB
                        {
                            OWBName        = _testName,
                            OWBType        = "OWBTYPENORMAL",
                            OWBPriority    = 500,
                            Status         = session.Query <WmsOWBStatus>().FirstOrDefault(o => o.StatusCode == "OWB_ACTIVATED"),
                            Partner        = mandant,
                            OWBProductNeed = "NOACTIVATE",
                            OWBCarrier     = partner
                        };
                        session.Save(owb);

                        var iwb = new WmsIWB
                        {
                            IWBName     = _testName,
                            IWBType     = "IWBTYPENORMAL",
                            IWBPriority = 500,
                            Status      = session.Query <WmsIWBStatus>().FirstOrDefault(o => o.StatusCode == "IWB_COMPLETED"),
                            Partner     = mandant
                        };
                        session.Save(iwb);

                        #region Product

                        var tetype = new WmsTEType
                        {
                            TETypeCode      = _testName,
                            TETypeName      = _testName,
                            TETypeLength    = 1000,
                            TETypeWidth     = 1000,
                            TETypeHeight    = 1000,
                            TETypeMaxWeight = 1000,
                        };
                        session.Save(tetype);

                        var placeType = new WmsPlaceType
                        {
                            PlaceTypeCode      = _testName,
                            PlaceTypeName      = _testName,
                            PlaceTypeCapacity  = 100,
                            PlaceTypeLength    = 10000,
                            PlaceTypeWidth     = 10000,
                            PlaceTypeHeight    = 10000,
                            PlaceTypeMaxWeight = 10000,
                        };
                        session.Save(placeType);

                        var placeClass = new WmsPlaceClass
                        {
                            PlaceClassCode = _testName,
                            PlaceClassName = _testName
                        };
                        session.Save(placeClass);

                        var receiveArea = new WmsReceiveArea
                        {
                            ReceiveAreaCode = _testName,
                            ReceiveAreaName = _testName
                        };
                        session.Save(receiveArea);

                        var supplyArea = new WmsSupplyArea
                        {
                            SupplyAreaCode = _testName,
                            SupplyAreaName = _testName
                        };
                        session.Save(supplyArea);

                        var motionArea = new WmsMotionArea
                        {
                            MotionAreaCode = _testName,
                            MotionAreaName = _testName
                        };
                        session.Save(motionArea);

                        var segmentType = new WmsSegmentType
                        {
                            SegmentTypeCode = _testName,
                            SegmentTypeName = _testName
                        };
                        session.Save(segmentType);

                        var areaType = new WmsAreaType
                        {
                            AreaTypeCode = _testName,
                            AreaTypeName = _testName
                        };
                        session.Save(areaType);

                        var warehouse = new WmsWarehouse
                        {
                            WarehouseCode = _testName,
                            WarehouseName = _testName
                        };
                        session.Save(warehouse);

                        var area = new WmsArea
                        {
                            AreaCode  = _testName,
                            AreaName  = _testName,
                            AreaType  = areaType,
                            Warehouse = warehouse
                        };
                        session.Save(area);

                        var segment = new WmsSegment
                        {
                            SegmentCode   = _testName,
                            SegmentNumber = _testName,
                            SegmentName   = _testName,
                            SegmentType   = segmentType,
                            Area          = area
                        };
                        session.Save(segment);

                        var place = new WmsPlace
                        {
                            PlaceCode        = _testName,
                            Segment          = segment,
                            PlaceS           = 1,
                            PlaceX           = 1,
                            PlaceY           = 1,
                            PlaceZ           = 1,
                            PlaceCapacityMax = 100,
                            PlaceCapacity    = 100,
                            Status           = session.Query <WmsPlaceStatus>().FirstOrDefault(o => o.StatusCode == "PLC_FREE"),
                            PlaceName        = _testName,
                            PlaceType        = placeType,
                            PlaceClass       = placeClass,
                            PlaceSortA       = 1,
                            PlaceSortB       = 1,
                            PlaceSortC       = 1,
                            PlaceSortD       = 1,
                            PlaceSortPick    = 1,
                            ReceiveArea      = receiveArea,
                            MotionArea       = motionArea,
                            SupplyArea       = supplyArea,
                            PlaceWeight      = 10000,
                            PlaceWeightGroup = 10000
                        };
                        session.Save(place);

                        var te = new WmsTE
                        {
                            TECode          = _testName,
                            TEType          = tetype,
                            TECurrentPlace  = place,
                            TECreationPlace = place.PlaceCode,
                            TELength        = 1000,
                            TEWidth         = 1000,
                            TEHeight        = 1000,
                            Status          = session.Query <WmsTEStatus>().FirstOrDefault(o => o.StatusCode == "TE_FREE"),
                            TEPackStatus    = "TE_PKG_NONE",
                            TEWeight        = 1000,
                            TEMaxWeight     = 10000,
                            TETareWeight    = 1000,
                        };
                        session.Save(te);

                        var art = new WmsArt
                        {
                            ArtCode         = _testName,
                            ArtName         = _testName,
                            Partner         = mandant,
                            ArtABCD         = 'A',
                            ArtTempMin      = 1,
                            ArtTempMax      = 1000,
                            ArtDeleted      = false,
                            ArtManufacturer = mandant,
                            ArtType         = _testName
                        };
                        session.Save(art);

                        var measureType = new WmsMeasureType
                        {
                            MeasureTypeCode = _testName,
                            MeasureTypeName = _testName
                        };
                        session.Save(measureType);

                        var measure = new WmsMeasure
                        {
                            MeasureCode      = _testName,
                            MeasureType      = measureType,
                            MeasurePrimary   = true,
                            MeasureFactor    = 1,
                            MeasureDefault   = true,
                            MeasureShortName = "Test",
                            MeasureName      = _testName,
                        };
                        session.Save(measure);

                        var sku = new WmsSKU
                        {
                            Art            = art,
                            Measure        = measure,
                            SKUCount       = 1,
                            SKUPrimary     = true,
                            SKUClient      = false,
                            SKUIndivisible = true,
                            SKUParent      = null,
                            SKUName        = _testName
                        };
                        session.Save(sku);

                        var qlfDetail = new WmsQLFDetail
                        {
                            QLFDetailCode = _testName,
                            QLFDetailName = _testName
                        };
                        session.Save(qlfDetail);

                        var iwbPos = new WmsIWBPos
                        {
                            IWB             = iwb,
                            IWBPosNumber    = 1,
                            SKU             = sku,
                            IWBPosCount     = 1,
                            IWBPosCount2SKU = 1,
                            Status          = session.Query <WmsIWBPosStatus>().SingleOrDefault(o => o.StatusCode == "IWBPOS_CREATED"),
                            QLF             = session.Query <WmsQLF>().Single(o => o.QLFCode == "QLFNORMAL"),
                            IWBPosOwner     = mandant
                        };
                        session.Save(iwbPos);

                        var owbPos = new WmsOWBPos
                        {
                            OWB             = owb,
                            OWBPosNumber    = 1,
                            SKU             = sku,
                            OWBPosCount     = 1,
                            OWBPosCount2SKU = 1,
                            OWBPosReserved  = 1,
                            Status          = session.Query <WmsOWBPosStatus>().SingleOrDefault(o => o.StatusCode == "OWBPOS_ACTIVATED"),
                            QLF             = session.Query <WmsQLF>().Single(o => o.QLFCode == "QLFNORMAL"),
                            OWBPosOwner     = mandant
                        };
                        session.Save(owbPos);

                        var factory = new WmsFactory
                        {
                            FactoryCode      = "TST",
                            FactoryName      = _testName,
                            Partner          = mandant,
                            FactoryBatchCode = _testName
                        };
                        session.Save(factory);

                        var product = new WmsProduct
                        {
                            TE                     = te,
                            SKU                    = sku,
                            ProductCountSKU        = 1,
                            ProductCount           = 2,
                            ProductTTEQuantity     = 3,
                            QLF                    = session.Query <WmsQLF>().Single(o => o.QLFCode == "QLFNORMAL"),
                            QLFDetail              = qlfDetail,
                            ProductInputDate       = DateTime.Now,
                            ProductInputDateMethod = session.Query <SYSENUM_ART_FIFO>().Single(i => i.EnumKey == "FIFO" && i.EnumValue == "YEAR"),
                            ProductDate            = DateTime.Now,
                            ProductPack            = "Pack",
                            ProductPackCountSKU    = 4,
                            ProductExpiryDate      = DateTime.Now,
                            ProductBatch           = "Batch",
                            ProductLot             = "Lot",
                            ProductSerialNumber    = "Number",
                            ProductColor           = "Color",
                            ProductTone            = "Tone",
                            ProductSize            = "Size",
                            Art                    = art,
                            Partner                = mandant,
                            ProductOwner           = mandant,
                            IWBPos                 = iwbPos,
                            OWBPos                 = owbPos,
                            Factory                = factory,
                            Status                 = session.Query <WmsProductStatus>().SingleOrDefault(i => i.StatusCode == "PRODUCT_BUSY"),
                            ProductBatchCode       = "BatchCode",
                            ProductBoxNumber       = "BoxNumber",
                            ProductHostRef         = "HostRef",
                            ProductKitArtName      = "KitArtName",
                            ProductRoot            = 5,
                            ProductPriority        = 6,
                            Country                = session.Query <IsoCountry>().SingleOrDefault(i => i.CountryCode == "RUS"),
                            ProductGTD             = "GTD",
                            TransportTaskID_r      = null
                        };
                        session.Save(product);

                        var ehPrd = new WmsEventHeader
                        {
                            Partner                      = mandant,
                            EventKind                    = session.Query <WmsEventKind>().FirstOrDefault(o => o.EventKindCode == "PRD_INPUT"),
                            Status                       = session.Query <WmsEventHeaderStatus>().FirstOrDefault(o => o.StatusCode == "EVENT_CREATED"),
                            ClientType                   = session.Query <SysClientType>().FirstOrDefault(o => o.ClientTypeCode == "DCL"),
                            EventHeaderBillStatus        = session.Query <EventHeaderBillStatus>().FirstOrDefault(o => o.StatusCode == "EVENT_BILL_OPEN"),
                            EventHeaderOperationBusiness = session.Query <SYSENUM_OPERATION_BUSINESS>().FirstOrDefault(p => p.EnumGroup == "OPERATION" && p.EnumKey == "BUSINESS"),
                            Operation                    = session.Query <BillOperation>().First(),
                            EventHeaderInstance          = "none"
                        };

                        var edPrd = new wmsEventDetailPRD
                        {
                            PARTNERID_R     = mandant.PartnerID,
                            PRODUCTID_R     = product.ProductID,
                            OLDPRODUCTID_R  = product.ProductID,
                            EVENTKINDCODE_R = "PRD_INPUT"
                        };
                        #endregion

                        session.Flush();

                        var eventHeader = new WmsEventHeader
                        {
                            Partner                      = mandant,
                            EventKind                    = session.Query <WmsEventKind>().FirstOrDefault(o => o.EventKindCode == EventKindCode),
                            Status                       = session.Query <WmsEventHeaderStatus>().FirstOrDefault(o => o.StatusCode == "EVENT_CREATED"),
                            ClientType                   = session.Query <SysClientType>().FirstOrDefault(o => o.ClientTypeCode == "DCL"),
                            EventHeaderBillStatus        = session.Query <EventHeaderBillStatus>().FirstOrDefault(o => o.StatusCode == "EVENT_BILL_OPEN"),
                            EventHeaderOperationBusiness = session.Query <SYSENUM_OPERATION_BUSINESS>().FirstOrDefault(p => p.EnumGroup == "OPERATION" && p.EnumKey == "BUSINESS"),
                            Operation                    = session.Query <BillOperation>().First(),
                            EventHeaderInstance          = "none"
                        };

                        var eventDetailOwb = new wmsEventDetailOWB {
                            OWBID_r = owb.OWBID, OWBName = owb.OWBName
                        };

                        var api = new WmsAPI(sessionFactoryMock.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>());
                        api.RegEvent(session.GetSession(EntityMode.Poco), ehPrd, edPrd, null);
                        api.RegEvent(session.GetSession(EntityMode.Poco), eventHeader, eventDetailOwb, null);

                        var array =
                            session.Query <wmsEventDetailOWB>()
                            .Where(i => i.EventHeader.Partner.PartnerCode == MandantCode &&
                                   i.EventHeader.EventKind.EventKindCode == EventKindCode &&
                                   i.EventHeader.Status.StatusCode == "EVENT_CREATED" &&
                                   i.EventHeader.DateIns >= DateTime.Today.AddDays(-1) &&
                                   !session.Query <IoLaunchControl>()
                                   .Any(
                                       j =>
                                       j.EventHeader == i.EventHeader &&
                                       j.QueueMessageType.Code == EventKindCode &&
                                       j.Mandant.PartnerCode == MandantCode))
                            .ToArray();

                        if (!array.Any())
                        {
                            throw new Exception("Нет данных для теста");
                        }

                        #endregion

                        sessionShareExtention.SharedSession = sessionDecorator;

                        var inputs = new Dictionary <string, object>
                        {
                            { "ROUTE", "ROUTE=OMS" },
                            { "MandantCode", MandantCode },
                            { "BatchSize", "1" }
                        };

                        var service = childContainer.Resolve <WorkflowService>();
                        service.Run(_wfIdentity, inputs);

                        var lan = session.Query <IoLaunchControl>().FirstOrDefault(i => i.EventHeader != null && i.EventHeader.EventHeaderID == eventHeader.EventHeaderID);
                        lan.Should().NotBeNull("Не создали LanchControl");

                        var qout = session.Query <IoQueueOut>()
                                   .Where(i => i.Uri == string.Format("ENTITYKEY={0}; ENTITY = OWB", owb.OWBName) && i.QueueMessageType.Code == QueueMessageTypeCode)
                                   .OrderByDescending(i => i.DateIns)
                                   .First();
                        var data = SerializationHelper.Deserialize <WHSOWBCommandMessage>(qout.Data);
                        data.OWBList[0].ProductList.Count.ShouldBeEquivalentTo(1);
                        data.OWBList[0].ProductList[0].ID.ShouldBeEquivalentTo(product.ProductID);
                        data.OWBList[0].CargoSpaceList.Count().ShouldBeEquivalentTo(1);
                        data.OWBList[0].CargoSpaceList[0].Code.ShouldBeEquivalentTo(te.TECode);

                        transaction.Rollback();
                    }
            }
        }
コード例 #6
0
ファイル: SetOrderDS.cs プロジェクト: zaharvsb52/My.MLC.Wms
        public static IoQueueIn GetQueueIn(ISession session)
        {
            const string queueMessageTypeCode = "SET_ORDER_DS";
            const string defaultName          = "TestSetOrderDS";

            var mandant = session.Query <WmsMandant>().FirstOrDefault(o => o.PartnerCode == _mandantCode);

            if (mandant == null)
            {
                throw new Exception(string.Format("Отсутствует тестовый мандант с кодом {0}", _mandantCode));
            }

            //var arr = new[] { "OWB_NONE", "OWB_CANCELED", "OWB_COMPLETED" };
            var status = session.Query <WmsOWBStatus>().FirstOrDefault(o => o.StatusCode == "OWB_ACTIVATED");

            if (status == null)
            {
                throw new Exception(string.Format("Отсутствует статус с кодом  OWB_COMPLETED"));
            }

            var partner = new WmsPartner
            {
                PartnerLink2Mandant = mandant,
                PartnerName         = _partnerName
            };

            session.SaveOrUpdate(partner);

            var owbTest = new WmsOWB
            {
                Partner        = mandant,
                OWBName        = _owbName,
                OWBType        = "OWBTYPENORMAL",
                OWBProductNeed = "PRODUCTNEED",
                Status         = status
            };

            session.SaveOrUpdate(owbTest);

            session.Flush();

            return(new IoQueueIn
            {
                Mandant = mandant,
                QueueMessageType = session.Query <IoQueueMessageType>().First(i => i.Code == queueMessageTypeCode),
                QueueMessageState = QueueMessageStates.Ready,
                Message = null,
                Data = SerializationHelper.SerializeToBytes(new DSState()
                {
                    OWBName = _owbName,
                    PartnerOrder = defaultName,
                    DeliveryServiceRef = _partnerName,
                    CommandList = new List <Command>()
                    {
                        new Command()
                        {
                            Name = "CommandName", Value = "CommandValue"
                        }
                    }
                })
            });
        }
コード例 #7
0
        public void Tes2()
        {
            using (var session = _sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    var fakeSession = new SessionDecorator(session)
                    {
                        DoNotDispose        = true,
                        ExternalTransaction = new TransactionDecorator(transaction)
                        {
                            DisableActions = true
                        }
                    };
                    var mockSessionFactory = new Mock <ISessionFactory>();
                    mockSessionFactory.Setup(i => i.OpenSession()).Returns(fakeSession);

                    const string testName = "TestName";

                    var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == "TST");

                    var owb = new WmsOWB
                    {
                        Partner        = tstMandant,
                        OWBName        = "Owb for testing change owner",
                        OWBProductNeed = "NOACTIVATE",
                        OWBType        = "OWBTYPENORMAL",
                        OWBOwner       = tstMandant,
                        Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_ACTIVATED")
                    };
                    session.Save(owb);

                    #region data

                    var warehouse = new WmsWarehouse
                    {
                        WarehouseCode = testName,
                        WarehouseName = testName
                    };
                    session.Save(warehouse);


                    var areaType = new WmsAreaType
                    {
                        AreaTypeCode = testName,
                        AreaTypeName = testName
                    };
                    session.Save(areaType);

                    session.Save(new SysGlobalParamValue
                    {
                        GParamVal2Entity = "AREATYPE",
                        GlobalParam      = session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "AreaDestination"),
                        GParamValKey     = areaType.AreaTypeCode,
                        GParamValValue   = "OUT"
                    });

                    var area = new WmsArea
                    {
                        AreaCode  = testName,
                        AreaName  = testName,
                        Warehouse = warehouse,
                        AreaType  = areaType
                    };
                    session.Save(area);

                    var segmentType = new WmsSegmentType
                    {
                        SegmentTypeCode = testName,
                        SegmentTypeName = testName
                    };
                    session.Save(segmentType);

                    var segment = new WmsSegment
                    {
                        SegmentCode   = testName,
                        SegmentName   = testName,
                        SegmentNumber = testName,
                        Area          = area,
                        SegmentType   = segmentType
                    };
                    session.Save(segment);

                    var placeType = new WmsPlaceType
                    {
                        PlaceTypeCode      = testName,
                        PlaceTypeName      = testName,
                        PlaceTypeMaxWeight = 200000,
                        PlaceTypeHeight    = 200000,
                        PlaceTypeLength    = 200000,
                        PlaceTypeWidth     = 200000,
                        PlaceTypeCapacity  = 200
                    };
                    session.Save(placeType);

                    var placeClass = new WmsPlaceClass
                    {
                        PlaceClassCode = testName,
                        PlaceClassName = testName
                    };
                    session.Save(placeClass);

                    var teType = new WmsTEType
                    {
                        TETypeCode      = testName,
                        TETypeName      = testName,
                        TETypeWidth     = 10000,
                        TETypeHeight    = 10000,
                        TETypeLength    = 10000,
                        TETypeMaxWeight = 100000
                    };
                    session.Save(teType);

                    session.Save(new SysGlobalParamValue
                    {
                        GParamVal2Entity = "TETYPE",
                        GlobalParam      =
                            session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "TETypeSequence2TENumber"),
                        GParamValKey   = teType.TETypeCode,
                        GParamValValue = "SQ_TE"
                    });

                    session.Save(new WmsTEType2Mandant
                    {
                        TEType  = teType,
                        Partner = tstMandant
                    });

                    session.Save(new WmsTEType2PlaceClass
                    {
                        TEType     = teType,
                        PlaceClass = placeClass
                    });

                    var truckType = new WmsTruckType
                    {
                        TruckTypeCode      = testName,
                        TruckTypeName      = testName,
                        TruckTypeWeightMax = 100000,
                        TruckTypePickCount = 100
                    };
                    session.Save(truckType);

                    session.Save(new WmsTeType2TruckType
                    {
                        TruckType             = truckType,
                        TEType                = teType,
                        TeType2TruckTypeCount = 100
                    });

                    var receiveArea = new WmsReceiveArea
                    {
                        ReceiveAreaCode = testName,
                        ReceiveAreaName = testName
                    };
                    session.Save(receiveArea);

                    var placeStart = new WmsPlace
                    {
                        PlaceCode        = testName,
                        PlaceName        = testName,
                        Segment          = segment,
                        PlaceS           = 1,
                        PlaceX           = 1,
                        PlaceY           = 1,
                        PlaceZ           = 1,
                        PlaceType        = placeType,
                        PlaceClass       = placeClass,
                        PlaceCapacity    = 9,
                        PlaceCapacityMax = 10,
                        PlaceWeight      = 20000,
                        PlaceHeight      = 20000,
                        PlaceLength      = 20000,
                        PlaceWidth       = 20000,
                        Status           = session.Query <WmsPlaceStatus>().Single(i => i.StatusCode == "PLC_FREE"),
                    };
                    session.Save(placeStart);

                    var art = new WmsArt
                    {
                        Partner            = tstMandant,
                        ArtName            = testName,
                        ArtCode            = testName,
                        ArtInputDateMethod =
                            session.Query <SYSENUM_ART_FIFO>().Single(i => i.EnumKey == "FIFO" && i.EnumValue == "YEAR"),
                        ArtType = "PRODUCT",
                        ArtABCD = 'A'
                    };
                    session.Save(art);

                    var measureType = new WmsMeasureType
                    {
                        MeasureTypeCode = testName
                    };
                    session.Save(measureType);

                    var measure = new WmsMeasure
                    {
                        MeasureCode   = testName,
                        MeasureType   = measureType,
                        MeasureFactor = 1
                    };
                    session.Save(measure);

                    var sku = new WmsSKU
                    {
                        SKUName        = testName,
                        Measure        = measure,
                        SKUCount       = 1,
                        Art            = art,
                        SKUPrimary     = true,
                        SKUClient      = true,
                        SKUDefault     = true,
                        SKUIndivisible = true,
                        SKUWeight      = 10,
                        SKUHeight      = 10,
                        SKULength      = 10,
                        SKUWidth       = 10,
                        SKUVolume      = 10
                    };
                    session.Save(sku);

                    session.Save(new WmsSKU2TTE
                    {
                        SKU                = sku,
                        TEType             = teType,
                        SKU2TTEDefault     = true,
                        SKU2TTEQuantity    = 1000,
                        SKU2TTEQuantityMax = 1000,
                        SKU2TTEMaxWeight   = 10000
                    });

                    var te = new WmsTE
                    {
                        TECode          = testName,
                        TEType          = session.Query <WmsTEType>().Single(i => i.TETypeCode == testName),
                        TECurrentPlace  = placeStart,
                        TECreationPlace = placeStart.PlaceCode,
                        TELength        = 1000,
                        TEHeight        = 1000,
                        TEWeight        = 1000,
                        TEWidth         = 1000,
                        Status          = session.Query <WmsTEStatus>().Single(i => i.StatusCode == "TE_FREE"),
                        TEPackStatus    = "TE_PKG_NONE",
                        TEMaxWeight     = 1000
                    };
                    session.Save(te);

                    var owbPos = new WmsOWBPos
                    {
                        SKU             = sku,
                        OWBPosCount     = 1,
                        OWBPosCount2SKU = 1,
                        OWBPosOwner     = tstMandant,
                        OWB             = owb,
                        QLF             = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"),
                        Status          = session.Query <WmsOWBPosStatus>().Single(i => i.StatusCode == "OWBPOS_CREATED")
                    };
                    session.Save(owbPos);

                    session.Save(new WmsProduct
                    {
                        TE                     = te,
                        SKU                    = session.Query <WmsSKU>().Single(i => i.SKUName == testName),
                        ProductCountSKU        = 1,
                        ProductCount           = 1,
                        ProductTTEQuantity     = 1,
                        QLF                    = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"),
                        ProductInputDate       = DateTime.Now,
                        ProductInputDateMethod = art.ArtInputDateMethod,
                        Art                    = art,
                        Partner                = tstMandant,
                        ProductOwner           = tstMandant,
                        Status                 = session.Query <WmsProductStatus>().Single(i => i.StatusCode == "PRODUCT_FREE"),
                        ProductTone            = testName,
                        ProductLot             = testName,
                        OWBPos                 = owbPos
                    });

                    #endregion data

                    session.Flush();

                    // запускаем
                    var    api    = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>());
                    Action action = () => { api.ChangeOwnerByOwb(owb.OWBID, "OP_OPERATOR_OWBPROCESSING", "TEST", null); };

                    action.ShouldThrow <Exception>().Which.Message.Should().Contain("смена владельца не требуется");

                    transaction.Rollback();
                }
        }
コード例 #8
0
        public void Test6()
        {
            using (var session = _sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    var fakeSession = new SessionDecorator(session)
                    {
                        DoNotDispose = true
                    };
                    var mockSessionFactory = new Mock <ISessionFactory>();
                    mockSessionFactory.Setup(i => i.OpenSession()).Returns(fakeSession);

                    const string testName    = "TestName";
                    const string mandantCode = "TST";

                    var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == mandantCode);

                    // создаем маршрут
                    var route = new YRoute
                    {
                        Partner     = tstMandant,
                        RouteDate   = DateTime.Today.AddDays(3), // через 3 дня
                        RouteNumber = "AutoTestRoute"
                    };
                    session.Save(route);

                    var cargo = new WmsCargoOWB
                    {
                        Route = route
                    };
                    session.Save(cargo);

                    // создаем накладную с плановой датой отгрузки
                    var owb = new WmsOWB
                    {
                        Partner        = tstMandant,
                        OWBName        = "Owb for testing routes",
                        OWBProductNeed = "NOACTIVATE",
                        OWBType        = "OWBTYPENORMAL",
                        OWBOutDatePlan = route.RouteDate,
                        Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_NONE")
                    };
                    owb.WmsCargoOWB_List.Add(cargo);
                    session.Save(owb);

                    #region . CreatePlaceProductTE .

                    var warehouse = new WmsWarehouse
                    {
                        WarehouseCode = testName,
                        WarehouseName = testName
                    };
                    session.Save(warehouse);


                    var areaType = new WmsAreaType
                    {
                        AreaTypeCode = testName,
                        AreaTypeName = testName
                    };
                    session.Save(areaType);

                    session.Save(new SysGlobalParamValue
                    {
                        GParamVal2Entity = "AREATYPE",
                        GlobalParam      = session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "AreaDestination"),
                        GParamValKey     = areaType.AreaTypeCode,
                        GParamValValue   = "OUT"
                    });

                    var area = new WmsArea
                    {
                        AreaCode  = testName,
                        AreaName  = testName,
                        Warehouse = warehouse,
                        AreaType  = areaType
                    };
                    session.Save(area);

                    var segmentType = new WmsSegmentType
                    {
                        SegmentTypeCode = testName,
                        SegmentTypeName = testName
                    };
                    session.Save(segmentType);

                    var segment = new WmsSegment
                    {
                        SegmentCode   = testName,
                        SegmentName   = testName,
                        SegmentNumber = testName,
                        Area          = area,
                        SegmentType   = segmentType
                    };
                    session.Save(segment);

                    var placeType = new WmsPlaceType
                    {
                        PlaceTypeCode      = testName,
                        PlaceTypeName      = testName,
                        PlaceTypeMaxWeight = 200000,
                        PlaceTypeHeight    = 200000,
                        PlaceTypeLength    = 200000,
                        PlaceTypeWidth     = 200000,
                        PlaceTypeCapacity  = 200
                    };
                    session.Save(placeType);

                    var placeClass = new WmsPlaceClass
                    {
                        PlaceClassCode = testName,
                        PlaceClassName = testName
                    };
                    session.Save(placeClass);

                    var teType = new WmsTEType
                    {
                        TETypeCode      = testName,
                        TETypeName      = testName,
                        TETypeWidth     = 10000,
                        TETypeHeight    = 10000,
                        TETypeLength    = 10000,
                        TETypeMaxWeight = 100000
                    };
                    session.Save(teType);

                    session.Save(new SysGlobalParamValue
                    {
                        GParamVal2Entity = "TETYPE",
                        GlobalParam      =
                            session.Query <SysGlobalParam>().Single(i => i.GlobalParamCode == "TETypeSequence2TENumber"),
                        GParamValKey   = teType.TETypeCode,
                        GParamValValue = "SQ_TE"
                    });

                    session.Save(new WmsTEType2Mandant
                    {
                        TEType  = teType,
                        Partner = tstMandant
                    });

                    session.Save(new WmsTEType2PlaceClass
                    {
                        TEType     = teType,
                        PlaceClass = placeClass
                    });

                    var truckType = new WmsTruckType
                    {
                        TruckTypeCode      = testName,
                        TruckTypeName      = testName,
                        TruckTypeWeightMax = 100000,
                        TruckTypePickCount = 100
                    };
                    session.Save(truckType);

                    session.Save(new WmsTeType2TruckType
                    {
                        TruckType             = truckType,
                        TEType                = teType,
                        TeType2TruckTypeCount = 100
                    });

                    var receiveArea = new WmsReceiveArea
                    {
                        ReceiveAreaCode = testName,
                        ReceiveAreaName = testName
                    };
                    session.Save(receiveArea);

                    var placeStart = new WmsPlace
                    {
                        PlaceCode        = testName,
                        PlaceName        = testName,
                        Segment          = segment,
                        PlaceS           = 1,
                        PlaceX           = 1,
                        PlaceY           = 1,
                        PlaceZ           = 1,
                        PlaceType        = placeType,
                        PlaceClass       = placeClass,
                        PlaceCapacity    = 9,
                        PlaceCapacityMax = 10,
                        PlaceWeight      = 20000,
                        PlaceHeight      = 20000,
                        PlaceLength      = 20000,
                        PlaceWidth       = 20000,
                        Status           = session.Query <WmsPlaceStatus>().Single(i => i.StatusCode == "PLC_FREE"),
                    };
                    session.Save(placeStart);

                    var art = new WmsArt
                    {
                        Partner            = tstMandant,
                        ArtName            = testName,
                        ArtCode            = testName,
                        ArtInputDateMethod =
                            session.Query <SYSENUM_ART_FIFO>().Single(i => i.EnumKey == "FIFO" && i.EnumValue == "YEAR"),
                        ArtType = "PRODUCT",
                        ArtABCD = 'A'
                    };
                    session.Save(art);

                    var measureType = new WmsMeasureType
                    {
                        MeasureTypeCode = testName
                    };
                    session.Save(measureType);


                    var measure = new WmsMeasure
                    {
                        MeasureCode   = testName,
                        MeasureType   = measureType,
                        MeasureFactor = 1
                    };
                    session.Save(measure);

                    var sku = new WmsSKU
                    {
                        SKUName        = testName,
                        Measure        = measure,
                        SKUCount       = 1,
                        Art            = art,
                        SKUPrimary     = true,
                        SKUClient      = true,
                        SKUDefault     = true,
                        SKUIndivisible = true,
                        SKUWeight      = 10,
                        SKUHeight      = 10,
                        SKULength      = 10,
                        SKUWidth       = 10,
                        SKUVolume      = 10
                    };
                    session.Save(sku);

                    session.Save(new WmsSKU2TTE
                    {
                        SKU                = sku,
                        TEType             = teType,
                        SKU2TTEDefault     = true,
                        SKU2TTEQuantity    = 1000,
                        SKU2TTEQuantityMax = 1000,
                        SKU2TTEMaxWeight   = 10000
                    });

                    var te = new WmsTE
                    {
                        TECode          = testName,
                        TEType          = session.Query <WmsTEType>().Single(i => i.TETypeCode == testName),
                        TECurrentPlace  = placeStart,
                        TECreationPlace = placeStart.PlaceCode,
                        TELength        = 1000,
                        TEHeight        = 1000,
                        TEWeight        = 1000,
                        TEWidth         = 1000,
                        Status          = session.Query <WmsTEStatus>().Single(i => i.StatusCode == "TE_FREE"),
                        TEPackStatus    = "TE_PKG_NONE",
                        TEMaxWeight     = 1000
                    };
                    session.Save(te);

                    var owbPos = new WmsOWBPos
                    {
                        SKU             = sku,
                        OWBPosCount     = 1,
                        OWBPosCount2SKU = 1,
                        OWBPosOwner     = tstMandant,
                        OWB             = owb,
                        QLF             = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"),
                        Status          = session.Query <WmsOWBPosStatus>().Single(i => i.StatusCode == "OWBPOS_CREATED")
                    };
                    session.Save(owbPos);

                    session.Save(new WmsProduct
                    {
                        TE                     = te,
                        SKU                    = session.Query <WmsSKU>().Single(i => i.SKUName == testName),
                        ProductCountSKU        = 1,
                        ProductCount           = 1,
                        ProductTTEQuantity     = 1,
                        QLF                    = session.Query <WmsQLF>().Single(i => i.QLFCode == "QLFNORMAL"),
                        ProductInputDate       = DateTime.Now,
                        ProductInputDateMethod = art.ArtInputDateMethod,
                        Art                    = art,
                        Partner                = tstMandant,
                        ProductOwner           = tstMandant,
                        Status                 = session.Query <WmsProductStatus>().Single(i => i.StatusCode == "PRODUCT_FREE"),
                        ProductTone            = testName,
                        ProductLot             = testName,
                        OWBPos                 = owbPos
                    });

                    #endregion

                    session.Flush();

                    try
                    {
                        // запускаем
                        var api = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>());
                        api.ChangeOwbRoute(owb.OWBID, route.RouteID, null, false, true);
                    }
                    catch (OracleException oraex)
                    {
                        if (!string.IsNullOrEmpty(oraex.Message))
                        {
                            var errorText = oraex.Message.Split(new[] { "\n" }, StringSplitOptions.None);
                            errorText[0].Should().NotBe(string.Format("ORA-20800: По накладной с ID = {0} имеется товар на воротах отгрузки", owb.OWBID));
                        }
                        else
                        {
                            // Все OK
                        }
                    }
                    catch (Exception ex)
                    {
                        // Все OK
                    }
                    transaction.Rollback();
                }
        }
コード例 #9
0
        public void Test1()
        {
            using (var session = _sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    var fakeSession = new SessionDecorator(session)
                    {
                        DoNotDispose = true
                    };
                    var mockSessionFactory = new Mock <ISessionFactory>();
                    mockSessionFactory.Setup(i => i.OpenSession()).Returns(fakeSession);

                    var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == "TST");

                    // создаем маршрут
                    var route = new YRoute
                    {
                        Partner     = tstMandant,
                        RouteDate   = DateTime.Today.AddDays(3), // через 3 дня
                        RouteNumber = "AutoTestRoute"
                    };
                    session.Save(route);

                    // создаем накладную с плановой датой отгрузки
                    var owb = new WmsOWB
                    {
                        Partner        = tstMandant,
                        OWBName        = "Owb for testing routes",
                        OWBProductNeed = "NOACTIVATE",
                        OWBType        = "OWBTYPENORMAL",
                        OWBOutDatePlan = route.RouteDate,
                        Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_NONE")
                    };
                    session.Save(owb);

                    session.Flush();

                    // груза еще не должно быть
                    var cargo = session.Query <WmsCargoOWB>().FirstOrDefault(i => i.Route == route);
                    cargo.Should().BeNull();

                    // запускаем
                    var api = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>());
                    var res = api.ChangeOwbRoute(owb.OWBID, route.RouteID, null, false, true);

                    res.ShouldBeEquivalentTo(string.Format("Накладная с ID = {0} включена в маршрут {1} отгрузкой {2:dd.MM.yyyy HH:mm}", owb.OWBID, route.RouteID, route.RouteDate));

                    // перечитываем накладную
                    session.Refresh(owb);

                    // должен проставиться маршрут
                    owb.OWBRoutePlan.Should().Be(route.RouteID);

                    // должен создаться груз
                    cargo = session.Query <WmsCargoOWB>().FirstOrDefault(i => i.Route == route);
                    cargo.Should().NotBeNull();

                    // должен прописаться груз
                    owb.WmsCargoOWB_List.Should().HaveCount(1);
                    owb.WmsCargoOWB_List.Should().ContainSingle(i => i == cargo);

                    transaction.Rollback();
                }
        }
コード例 #10
0
        public void Test5()
        {
            using (var session = _sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    var fakeSession = new SessionDecorator(session)
                    {
                        DoNotDispose = true
                    };
                    var mockSessionFactory = new Mock <ISessionFactory>();
                    mockSessionFactory.Setup(i => i.OpenSession()).Returns(fakeSession);

                    #region populate test data

                    var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == "TST");

                    // создаем менеджер маршрутов
                    var mgrRoute = new YMgRoute
                    {
                        Partner            = tstMandant,
                        MgRouteCreateRoute = false,
                        MgRouteName        = "Mgr for autotests",
                        MgRouteNumber      = "AutoTestRouteNumber"
                    };
                    session.Save(mgrRoute);

                    // создаем маршрут
                    var route = new YRoute()
                    {
                        Partner     = tstMandant,
                        MgRoute     = mgrRoute,
                        RouteDate   = DateTime.Now,
                        RouteNumber = mgrRoute.MgRouteNumber
                    };
                    session.Save(route);

                    // создаем маршрут
                    var routeChange = new YRoute()
                    {
                        Partner     = tstMandant,
                        MgRoute     = mgrRoute,
                        RouteDate   = route.RouteDate.AddDays(1),
                        RouteNumber = "TestRoute"
                    };
                    session.Save(routeChange);

                    // создаем накладную с плановой датой отгрузки
                    var owb = new WmsOWB
                    {
                        Partner        = tstMandant,
                        OWBName        = "Owb for testing routes",
                        OWBProductNeed = "NOACTIVATE",
                        OWBType        = "OWBTYPENORMAL",
                        OWBRoutePlan   = route.RouteID,
                        OWBOutDatePlan = route.RouteDate,
                        Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_NONE")
                    };
                    session.Save(owb);

                    session.Flush();

                    #endregion

                    try
                    {
                        // запускаем
                        var api = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>());
                        api.ChangeOwbRoute(owb.OWBID, routeChange.RouteID, route.RouteDate, false, true);
                    }
                    catch (OracleException ex)
                    {
                        if (!string.IsNullOrEmpty(ex.Message))
                        {
                            var errorText = ex.Message.Split(new[] { "\n" }, StringSplitOptions.None);
                            errorText[0].ShouldBeEquivalentTo(string.Format("ORA-20801: В накладной с ID = {0} уже проставлен маршрут и он отличается от переданного/расчитанного({1})", owb.OWBID, routeChange.RouteID));
                        }
                        else
                        {
                            throw (ex);
                        }
                    }
                    transaction.Rollback();
                }
        }
コード例 #11
0
        public static void PopulateTestData(ISession session, out WmsOWB owb, out DateTime expectedDate, out YMgRoute mgrRoute)
        {
            var tstMandant = session.Query <WmsMandant>().Single(i => i.PartnerCode == "TST");

            // создаем накладную с плановой датой отгрузки
            owb = new WmsOWB
            {
                Partner        = tstMandant,
                OWBName        = "Owb for testing routes",
                OWBProductNeed = "NOACTIVATE",
                OWBType        = "OWBTYPENORMAL",
                Status         = session.Query <WmsOWBStatus>().Single(i => i.StatusCode == "OWB_CREATED")
            };
            session.Save(owb);

            // проверяем если ли записи календаря на даты расчета (+2 дня)
            var exprectedTime    = TimeSpan.FromHours(15);
            int timeToPrepare    = 2880; //min
            int tmpTimeToPrepare = timeToPrepare;
            var dateIdx          = 0;

            while (tmpTimeToPrepare > 0)
            {
                var tmpDate = GetOrAddCalendarDate(owb.DateIns.Value.Date.AddDays(dateIdx), session);
                // для первой даты вычитаем кол-во минут оставшегося раб.дня
                if (dateIdx == 0)
                {
                    if (owb.DateIns.Value < tmpDate.CalendarTimeTill)
                    {
                        tmpTimeToPrepare -= (int)(tmpDate.CalendarTimeTill - owb.DateIns.Value).TotalMinutes;
                    }
                }
                else
                {
                    tmpTimeToPrepare -= (int)(tmpDate.CalendarTimeTill - tmpDate.CalendarTimeFrom).TotalMinutes;
                }
                dateIdx++;
            }

            expectedDate = owb.DateIns.Value.AddDays(--dateIdx);

            //TODO: Разаобраться зачем нужен код внизу
            //if (expectedDate > expectedDate.Date.Add(exprectedTime))
            //{
            //    var tmpDate = GetOrAddCalendarDate(expectedDate.Date.AddDays(dateIdx), session);
            //    expectedDate = expectedDate.AddDays(1);
            //}
            //else
            //    expectedDate = expectedDate.Date.Add(exprectedTime);

            // создаем выбор даты
            // пока работаем с имеющимся, когда появится возможность работать с CPV - перейти на создание здесь
            var routeDateSelect = new YMgRouteDateSelect
            {
                Partner = tstMandant,
                MgRouteDateSelectDateSource = MgRouteDateSelectDateSources.OwbDateIns,
                Priority = 1
            };

            session.Save(routeDateSelect);

            // добавляем CPV
            var cpvRouteDSL1 = new YMgRouteDateSelectCPV()
            {
                CustomParam       = session.Get <WmsCustomParam>("RouteDSL1"),
                MGROUTEDATESELECT = routeDateSelect
            };

            session.Save(cpvRouteDSL1);

            var cpvRouteDSUseWeekendL2 = new YMgRouteDateSelectCPV
            {
                CustomParam       = session.Get <WmsCustomParam>("RouteDSUseWeekendL2"),
                MGROUTEDATESELECT = routeDateSelect,
                Parent            = cpvRouteDSL1,
                CPVValue          = "0"
            };

            session.Save(cpvRouteDSUseWeekendL2);

            var cpvRouteDSTimeConstL2 = new YMgRouteDateSelectCPV
            {
                CustomParam       = session.Get <WmsCustomParam>("RouteDSTimeConstL2"),
                MGROUTEDATESELECT = routeDateSelect,
                Parent            = cpvRouteDSL1,
                CPVValue          = expectedDate.ToString("yyyyMMdd HH:mm:ss")
            };

            session.Save(cpvRouteDSTimeConstL2);

            var cpvRouteDSIncrementL2 = new YMgRouteDateSelectCPV
            {
                CustomParam       = session.Get <WmsCustomParam>("RouteDSIncrementL2"),
                MGROUTEDATESELECT = routeDateSelect,
                Parent            = cpvRouteDSL1,
                CPVValue          = timeToPrepare.ToString()
            };

            session.Save(cpvRouteDSIncrementL2);

            var cpvRouteDSDateSourceL2 = new YMgRouteDateSelectCPV
            {
                CustomParam       = session.Get <WmsCustomParam>("RouteDSDateSourceL2"),
                MGROUTEDATESELECT = routeDateSelect,
                Parent            = cpvRouteDSL1,
                CPVValue          = "DATEINS"
            };

            session.Save(cpvRouteDSDateSourceL2);

            // создаем менеджер маршрутов
            mgrRoute = new YMgRoute
            {
                Partner            = tstMandant,
                MgRouteCreateRoute = false,
                MgRouteName        = "Mgr for autotests",
                MgRouteNumber      = "AutoTestRouteNumber"
            };
            session.Save(mgrRoute);

            // создаем выбор менеджера маршрутов
            var routeSelect = new YMgRouteSelect
            {
                Partner  = tstMandant,
                MgRoute  = mgrRoute,
                Priority = 1
            };

            session.Save(routeSelect);


            // создаем маршрут (создание из API проверить не получится, т.к. там, для блокировки параллельного создания, используются атомарные транзакции
            var route = new YRoute()
            {
                Partner     = tstMandant,
                MgRoute     = mgrRoute,
                RouteDate   = expectedDate,
                RouteNumber = mgrRoute.MgRouteNumber // mgrRoute.MgRouteNumber
            };

            session.Save(route);

            session.Flush();

            // перечитываем DateSelect
            session.Refresh(routeDateSelect);
        }