private void save() { if (!unit.Validate()) { return; } ShowBusyIndicator(); unit.TransferId = Guid.NewGuid(); if (actionType == ActionType.AddUnit) { unitService.AddUnit((res, exp) => appController.BeginInvokeOnDispatcher(() => { HideBusyIndicator(); if (exp != null) { appController.HandleException(exp); } else { FinalizeAction(); } }), unit); } else if (actionType == ActionType.ModifyUnit) { unitService.UpdateUnit((res, exp) => appController.BeginInvokeOnDispatcher(() => { HideBusyIndicator(); if (exp != null) { appController.HandleException(exp); } else { FinalizeAction(); } }), unit); } }
private void convertUnit_Rec(UnitIntegrationDTO sourceUnitDTO, long periodId, long?unitParentIdParam) { var unit = unitService.GetByTransferId(sourceUnitDTO.TransferId); if (unit == null) { var desUnitDTO = createDestinationUnit(sourceUnitDTO); unit = unitService.AddUnit(desUnitDTO); } var unitInPriodAssignment = createDestinationUnitInPeriod(unit, unitParentIdParam); var res = unitInPeriodServiceWrapper.AddUnitInPeriod(periodId, unitInPriodAssignment); unitList.Add(unit); var unitDataChildIdList = unitDataProvider.GetChildIDs(sourceUnitDTO.ID); foreach (var unitDataChildId in unitDataChildIdList) { var unitdataChid = unitDataProvider.GetUnitDetail(unitDataChildId); convertUnit_Rec(unitdataChid, periodId, res.UnitId); } Console.WriteLine("Unit convert progress state: " + unitList.Count + " From " + totalUnitsCount.ToString()); }