/// <summary> /// Получить пакет данных trSostav /// </summary> /// <param name="id_sostav"></param> /// <returns></returns> public trSostav GetSostav(int id_sostav) { // Определим класс данных состав MTSostav sost = mtc.Get_MTSostav(id_sostav); // Определим код станции по справочникам int?codecs_in = refRW.GetCodeCSStations(int.Parse(sost.CompositionIndex.Substring(9, 4)) * 10); int?codecs_from = refRW.GetCodeCSStations(int.Parse(sost.CompositionIndex.Substring(0, 4)) * 10); // Определим класс данных вагоны List <trWagon> list_wag = new List <trWagon>(); list_wag = GetListWagonInArrival(mtc.Get_MTListToSostav(id_sostav), codecs_in, mtc.GetMTConsignee(tMTConsignee.AMKR)); List <MTSostav> list_mt = mtc.GetOperationMTSostavDestinct(sost.IDMTSostav); trSostav sostav = new trSostav() { id = sost.IDMTSostav, codecs_in_station = codecs_in, codecs_from_station = codecs_from, //FileName = sost.FileName, //CompositionIndex = sost.CompositionIndex, DateTime_on = list_mt.Count > 0 ? list_mt.Last().DateTime : sost.DateTime, DateTime_from = sost.DateTime, //Operation = sost.Operation, //Create = sost.Create, //Close = sost.Close, ParentID = sost.ParentID, Wagons = list_wag != null?list_wag.ToArray() : null, }; return(sostav); }
public void Test_MT_Helpers_MT_ArrivalToRailWayAll() { MT mts = new MT(); MTContent mt = new MTContent(); foreach (MTSostav sos in mt.Get_MTSostav()) { int v = mts.ArrivalToRailWay(sos.IDMTSostav); if (v > 0) { Console.WriteLine("Состав {0} - вагонов {1}", sos.CompositionIndex, v); } } }
private int ArrivalToRailWay(int id_sostav) { try { KIS_RC_Transfer rc_transfer = new KIS_RC_Transfer(); // Перенос в системе RailCars KIS_RW_Transfer rw_transfer = new KIS_RW_Transfer(); // Перенос в системе RailWay MTContent mtc = new MTContent(); ReferenceRailway refRW = new ReferenceRailway(); SAP_Transfer saptr = new SAP_Transfer(); // Определим класс данных состав MTSostav sost = mtc.Get_MTSostav(id_sostav); // Определим код станции по справочникам int?codecs_in = refRW.GetCodeCSStations(int.Parse(sost.CompositionIndex.Substring(9, 4)) * 10); int?codecs_from = refRW.GetCodeCSStations(int.Parse(sost.CompositionIndex.Substring(0, 4)) * 10); // Определим класс данных вагоны List <trWagon> list_wag = new List <trWagon>(); list_wag = GetListWagonInArrival(mtc.Get_MTListToSostav(id_sostav), codecs_in, mtc.GetMTConsignee(tMTConsignee.AMKR)); trSostav sostav = new trSostav() { id = sost.IDMTSostav, codecs_in_station = codecs_in, codecs_from_station = codecs_from, //FileName = sost.FileName, //CompositionIndex = sost.CompositionIndex, DateTime_from = sost.DateTime, //Operation = sost.Operation, //Create = sost.Create, //Close = sost.Close, ParentID = sost.ParentID, Wagons = list_wag != null?list_wag.ToArray() : null, }; // Поставим вагоны в систему RailCars int res_arc; try { //res_arc = rc_transfer.PutInArrival(sostav); res_arc = saptr.PutInSapIncomingSupply(sostav); if (res_arc < 0) { //LogRW.LogError(String.Format("[MT.ArrivalToRailWay] :Ошибка переноса состава в прибытие системы RailCars, состав: {0}, код ошибки: {1}.", sostav.id, res_arc), this.eventID); } } catch (Exception e) { //LogRW.LogError(String.Format("[MT.ArrivalToRailWay] :Ошибка переноса состава в прибытие системы RailCars, состав: {0}. Подробно: (источник: {1}, № {2}, описание: {3})", sostav.id, e.Source, e.HResult, e.Message), this.eventID); res_arc = -1; } // Поставим вагоны в систему RailWay // TODO: Выполнить код постановки вагонов в систему RailWay (прибытие из КР) // .................. } catch (AggregateException agex) { agex.Handle(ex => { //LogRW.LogError(String.Format("[MT.ArrivalToRailWay]: Общая ошибка переноса состава в прибытие системы RailWay (источник: {0}, № {1}, описание: {2})", ex.Source, ex.HResult, ex.Message), this.eventID); return(true); }); return(-1); } return(0);//TODO: исправить возврат }
public void Read_Sostav() { // Arrange - create the mock repository mock_mt.Setup(m => m.MTSostav).Returns(new MTSostav[] { new MTSostav() { IDMTSostav = 1, FileName = "regl_8701-058-4670_2016082212254.xml", CompositionIndex = "8701-058-4670", DateTime = DateTime.Parse("2016-08-22 12:25:00.000"), Operation = 1, Create = DateTime.Parse("2016-09-07 15:07:45.000"), Close = DateTime.Parse("2016-09-07 15:07:45.697"), ParentID = null }, new MTSostav() { IDMTSostav = 2, FileName = "regl_8701-058-4670_2016082212353.xml", CompositionIndex = "8701-058-4670", DateTime = DateTime.Parse("2016-08-22 12:35:00.000"), Operation = 2, Create = DateTime.Parse("2016-09-07 15:07:45.000"), Close = null, ParentID = 1 }, new MTSostav() { IDMTSostav = 3, FileName = "regl_4670-731-4672_2016082214000.xml", CompositionIndex = "4670-731-4672", DateTime = DateTime.Parse("2016-08-22 14:00:00.000"), Operation = 1, Create = DateTime.Parse("2016-09-07 15:07:46.000"), Close = null, ParentID = null }, }.AsQueryable()); // Arrange - create the controller MTContent target = new MTContent(mock_mt.Object); // Act // Проверка MTSostav mts = target.Get_MTSostav(1); MTSostav mts_null = target.Get_MTSostav(0); List <MTSostav> list_ci = target.Get_MTSostav("8701-058-4670").ToList(); List <MTSostav> list_all = target.Get_MTSostav().ToList(); bool sostav_exist = target.IsExistSostav("regl_8701-058-4670_2016082212353.xml"); bool sostav_not_exist = target.IsExistSostav("1regl_8701-058-4670_2016082212353.xml"); MTSostav mts_notClose = target.Get_NoCloseMTSostav("8701-058-4670", DateTime.Parse("2016-08-23 12:35:00.000")); MTSostav mts_notClose_null = target.Get_NoCloseMTSostav("8701-058-4670", DateTime.Parse("2016-08-21 12:35:00.000")); // Assert // Assert.AreEqual("regl_8701-058-4670_2016082212254.xml", mts.FileName); Assert.AreEqual("8701-058-4670", mts.CompositionIndex); Assert.AreEqual("2016-08-22 12:25:00.000", mts.DateTime.ToString("yyyy-MM-dd HH:mm:ss.000")); Assert.AreEqual(1, mts.Operation); Assert.AreEqual("2016-09-07 15:07:45.000", mts.Create.ToString("yyyy-MM-dd HH:mm:ss.000")); Assert.AreEqual("2016-09-07 15:07:45.697", ((DateTime)mts.Close).ToString("yyyy-MM-dd HH:mm:ss.697")); Assert.AreEqual(null, mts.ParentID); Assert.AreEqual(null, mts_null); Assert.AreEqual(2, list_ci.Count()); Assert.AreEqual(1, list_ci[0].IDMTSostav); Assert.AreEqual(2, list_ci[1].IDMTSostav); Assert.AreEqual(3, list_all.Count()); Assert.AreEqual(true, sostav_exist); Assert.AreEqual(false, sostav_not_exist); Assert.AreEqual(2, mts_notClose.IDMTSostav); Assert.AreEqual(null, mts_notClose_null); }