Example #1
0
        private void save()
        {
            if (SelectedUnitInPeriod == null || !SelectedUnitInPeriod.Validate())
            {
                return;
            }

            ShowBusyIndicator();
            if (actionType == ActionType.AddUnitInPeriod)
            {
                SelectedUnitInPeriod.ParentId = parentId;
                UnitInPeriodService.AddUnitInPeriod((res, exp) => appController.BeginInvokeOnDispatcher(() =>
                {
                    HideBusyIndicator();
                    if (exp != null)
                    {
                        appController.HandleException(exp);
                    }
                    else
                    {
                        finalizeAction();
                    }
                }), Period.Id, SelectedUnitInPeriod);
            }
            else if (actionType == ActionType.ModifyUnitInPeriod)
            {
                UnitInPeriodService.UpdateUnitInPeriod((res, exp) => appController.BeginInvokeOnDispatcher(() =>
                {
                    HideBusyIndicator();
                    if (exp != null)
                    {
                        appController.HandleException(exp);
                    }
                    else
                    {
                        finalizeAction();
                    }
                }), Period.Id, SelectedUnitInPeriod);
            }
        }
Example #2
0
        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());
        }