protected BPWorkflowRepository() { if (_api == null) { _api = IoC.Instance.Resolve <WmsAPI>(); } }
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(); } }
private SdclConnectInfo GetSdclConnectInfo(string clientCode, SdclConnectInfo lastSdclConnectInfo) { if (_api == null) { _api = IoC.Instance.Resolve <WmsAPI>(); } var result = _api.GetSdclEndPoint(clientCode, lastSdclConnectInfo == null ? null : lastSdclConnectInfo.Code); return(result); }
//[Ignore("Разобраться. Получаем ошибку из БД.")] public void Test4() { 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 WmsOWB owb; DateTime expectedDate; YMgRoute mgrRoute; PopulateTestData(session, out owb, out expectedDate, out mgrRoute); #endregion // запускаем var api = new WmsAPI(mockSessionFactory.Object, _container.Resolve <IWmsXmlConverter>(), _container.Resolve <IWorkflowLoader>()); var res = api.ChangeOwbRoute(owb.OWBID, null, null, true, true); // перечитываем накладную session.Refresh(owb); // проверяем маршрут owb.OWBRoutePlan.Should().HaveValue(); var route = session.Get <YRoute>(owb.OWBRoutePlan.Value); route.Should().NotBeNull(); route.RouteDate.ShouldBeEquivalentTo(expectedDate); route.RouteNumber.ShouldBeEquivalentTo(mgrRoute.MgRouteNumber); route.MgRoute.ShouldBeEquivalentTo(mgrRoute); route.Partner.ShouldBeEquivalentTo(owb.Partner); // проверяем дату owb.OWBOutDatePlan.Should().HaveValue(); owb.OWBOutDatePlan.ShouldBeEquivalentTo(expectedDate); res.ShouldBeEquivalentTo(string.Format("Накладная с ID = {0} включена в маршрут {1} отгрузкой {2:dd.MM.yyyy HH:mm}", owb.OWBID, owb.OWBRoutePlan.Value, owb.OWBOutDatePlan.Value)); // должен прописаться груз owb.WmsCargoOWB_List.Should().HaveCount(1); var cargo = owb.WmsCargoOWB_List.Single(); cargo.Route.ShouldBeEquivalentTo(route); transaction.Rollback(); //transaction.Commit(); } }
public void EchoPerformanceMultiThreadsTest() { var api = new WmsAPI(_manager); var taskList = new List <Task <long> >(); var totalSw = Stopwatch.StartNew(); for (int i = 0; i < 10; i++) { var task = Task <long> .Factory.StartNew(() => CalcPerformance(() => { DoEcho(api); })); taskList.Add(task); } Task.WaitAll(taskList.ToArray()); totalSw.Stop(); long totalCount = taskList.Sum(i => i.Result); Console.WriteLine("Total: Time={0};Calls={1};Speed={2} call/s", totalSw.Elapsed, totalCount, totalCount / totalSw.Elapsed.TotalSeconds); }
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(); } }
public void GetAvailablePickListCountTest() { var api = new WmsAPI(_manager); var res = api.GetAvailablePickListCountAsync("FORK194").Result; }
public void EchoPerformanceTest() { var api = new WmsAPI(_manager); CalcPerformance(() => { DoEcho(api); }); }
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(); } } }
public TTaskMenuViewModel() { _api = IoC.Instance.Resolve <WmsAPI>(); }
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(); } }
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(); } }
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(); } }
public MainMenuTileViewModel() { _api = IoC.Instance.Resolve <WmsAPI>(); }
public void GetAvailableTransportTaskCountTest() { var api = new WmsAPI(_manager); var res = api.GetAvailableTransportTaskCountAsync(65792).Result; }
private void DoEcho(WmsAPI api = null) { var res = api.Echo("test message"); res.ShouldBeEquivalentTo("test message"); }
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(); } }