예제 #1
0
        public void Load(long periodId, long?UnitId, long?parentId, ActionType actionTypeParam)
        {
            this.parentId = parentId;
            actionType    = actionTypeParam;
            preLoad(periodId, UnitId);

            if (UnitId.HasValue) // modify Unit
            {
                Units = new List <UnitInPeriodDTO>();
                ShowBusyIndicator("در حال دریافت اطلاعات...");
                UnitInPeriodService.GetUnitInPeriod((res, exp) => appController.BeginInvokeOnDispatcher(() =>
                {
                    HideBusyIndicator();
                    if (exp == null)
                    {
                        Units.Add(res);
                        SelectedUnitInPeriod = res;
                    }
                }), periodId, UnitId.Value);
            }
            else // add new Unit => action is  ActionType.AddUnitInPrdField
            {
                ShowBusyIndicator();
                UnitInPeriodService.GetAllUnitInPeriod((UnitInPeriodListRes, exp) => appController.BeginInvokeOnDispatcher(() =>
                {
                    if (exp == null)
                    {
                        UnitService.GetAllUnits((UnitsRes, UnitsExp) => appController.BeginInvokeOnDispatcher(() =>
                        {
                            HideBusyIndicator();

                            if (UnitsExp == null)
                            {
                                var jList = UnitsRes.Where(r => !UnitInPeriodListRes.Select(jip => jip.UnitId).Contains(r.Id)).ToList();
                                Units     = jList.Select(
                                    j => new UnitInPeriodDTO()
                                {
                                    Name = j.Name, UnitId = j.Id, CustomFields = new List <CustomFieldDTO>()
                                }).ToList();
                            }
                            else
                            {
                                appController.HandleException(UnitsExp);
                            }
                        }));
                    }
                    else
                    {
                        appController.HandleException(exp);
                    }
                }), periodId);
            }
        }
예제 #2
0
파일: UnitListVM.cs 프로젝트: mehabadi/HPMS
 public void Load()
 {
     ShowBusyIndicator("در حال دریافت اطلاعات...");
     unitService.GetAllUnits(
         (res, exp) => appController.BeginInvokeOnDispatcher(() =>
     {
         HideBusyIndicator();
         if (exp == null)
         {
             Units.SourceCollection = res.Result;
             Units.TotalItemCount   = res.TotalCount;
             Units.PageIndex        = Math.Max(0, res.CurrentPage - 1);
             HideBusyIndicator();
         }
         else
         {
             HideBusyIndicator();
             appController.HandleException(exp);
         }
     }), units.PageSize, units.PageIndex + 1);
 }