Ejemplo n.º 1
0
        //public bool ConflictRackChange
        //{
        //    get { return conflictrackchange; }
        //    set
        //    {
        //        if (conflictrackchange != value)
        //        {
        //            conflictrackchange = value;
        //            OnPropertyChanged(nameof(ConflictRackChange));
        //        }
        //    }
        //} bool conflictrackchange;

        public MasterRackNewViewModel(RackViewModel rvm, bool createmode1) : base(rvm.Navigation)
        {
            NewModel              = rvm;
            IsSaveToNAVEnabled    = false;
            RackSectionSeparator  = Settings.DefaultRackSectionSeparator;
            SectionLevelSeparator = Settings.DefaultSectionLevelSeparator;
            LevelDepthSeparator   = Settings.DefaultLevelDepthSeparator;

            Sections        = rvm.Sections;
            Levels          = rvm.Levels;
            Depth           = rvm.Depth;
            RackOrientation = rvm.RackOrientation;
            LocationCode    = rvm.LocationCode;
            ZoneCode        = rvm.ZoneCode;

            CreateMode = createmode1;

            Step1Command = new Command(Step1);
            Step2Command = new Command(Step2);
            Step3Command = new Command(async() => await Step3().ConfigureAwait(true));

            State              = ModelState.Undefined;
            Changed            = false;
            IsSaveToNAVEnabled = true;
        }
Ejemplo n.º 2
0
 private void FillModel(List <Rack> racks)
 {
     if (racks.Count > 0)
     {
         RackViewModels.Clear();
         State = ModelState.Normal;
         foreach (Rack rack in racks)
         {
             RackViewModel rvm = new RackViewModel(Navigation, rack);
             rvm.OnTap += Rvm_OnTap;
             RackViewModels.Add(rvm);
         }
         UpdateMinSizes();
         Rebuild(true);
         if (UDSLastResults.Count > 0)
         {
             FillRackViewModelsByUDSList(UDSLastResults);
             MessagingCenter.Send(this, "UDSRunIsDone");
         }
     }
     else
     {
         State = ModelState.NoData;
     }
 }
Ejemplo n.º 3
0
 public MasterRackNewViewModel(RackViewModel rvm) : base(rvm.Navigation)
 {
     NewModel     = rvm;
     Step1Command = new Command(Step1);
     Step2Command = new Command(Step2);
     Step3Command = new Command(async() => await Step3().ConfigureAwait(true));
     State        = ModelState.Undefined;
 }
Ejemplo n.º 4
0
        public async void RunUDS(UserDefinedSelectionViewModel udsvm)
        {
            if (NotNetOrConnection)
            {
                return;
            }

            try
            {
                udsvm.State = ModelState.Loading;
                List <UserDefinedSelectionResult> list = await NAV.RunUDS(Zone.LocationCode, Zone.Code, udsvm.ID, ACD.Default).ConfigureAwait(true);

                if (list is List <UserDefinedSelectionResult> )
                {
                    foreach (RackViewModel rvm in RackViewModels)
                    {
                        rvm.UDSSelects.RemoveAll(x => x.FunctionID == udsvm.ID);
                    }

                    foreach (UserDefinedSelectionResult udsr in list)
                    {
                        RackViewModel rvm = RackViewModels.ToList().Find(x => x.No == udsr.RackNo);

                        if (rvm is RackViewModel)
                        {
                            SubSchemeSelect sss = new SubSchemeSelect()
                            {
                                FunctionID = udsr.FunctionID,
                                Section    = udsr.Section,
                                Level      = udsr.Level,
                                Depth      = udsr.Depth,
                                Value      = udsr.Value,
                                HexColor   = udsr.HexColor
                            };
                            rvm.UDSSelects.Add(sss);
                        }
                    }
                }
                MessagingCenter.Send(this, "UDSRunIsDone");
            }
            catch (OperationCanceledException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                ErrorText     = e.Message;
                LoadAnimation = false;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
            udsvm.State = ModelState.Normal;
        }
Ejemplo n.º 5
0
        public async Task EditRack(object obj)
        {
            RackViewModel rvm = (RackViewModel)obj;

            Rack rack = new Rack();

            rvm.SaveFields(rack);

            RackViewModel editrvm = new RackViewModel(Navigation, rack);

            editrvm.IsEditMode = true;
            editrvm.BinsViewModel.IsEditMode = true;

            await Navigation.PushAsync(new RackEditPage(editrvm));
        }
 private void FillModel(List <Rack> racks)
 {
     if (racks.Count > 0)
     {
         ObservableCollection <RackViewModel> nlist = new ObservableCollection <RackViewModel>();
         foreach (Rack rack in racks)
         {
             RackViewModel rvm = new RackViewModel(Navigation, rack, false);
             nlist.Add(rvm);
         }
         RackViewModels = nlist;
         State          = ModelState.Normal;
     }
     else
     {
         State = ModelState.NoData;
     }
 }
Ejemplo n.º 7
0
 public async Task NewRack()
 {
     Rack newrack = new Rack
     {
         Sections      = Settings.DefaultRackSections,
         Levels        = Settings.DefaultRackLevels,
         Depth         = Settings.DefaultRackDepth,
         SchemeVisible = true,
     };
     RackViewModel rvm = new RackViewModel(Navigation, newrack, true)
     {
         LocationCode             = Zone.LocationCode,
         ZoneCode                 = Zone.Code,
         CanChangeLocationAndZone = false
     };
     RackNewPage rnp = new RackNewPage(rvm);
     await Navigation.PushAsync(rnp);
 }
Ejemplo n.º 8
0
 private void FillRackViewModelsByUDSList(List <UserDefinedSelectionResult> list)
 {
     foreach (UserDefinedSelectionResult udsr in list)
     {
         RackViewModel rvm = RackViewModels.ToList().Find(x => x.ID == udsr.RackID);
         if (rvm is RackViewModel)
         {
             SubSchemeSelect sss = new SubSchemeSelect()
             {
                 FunctionID = udsr.FunctionID,
                 Section    = udsr.Section,
                 Level      = udsr.Level,
                 Depth      = udsr.Depth,
                 Value      = udsr.Value,
                 HexColor   = udsr.HexColor
             };
             rvm.UDSSelects.Add(sss);
         }
     }
 }
Ejemplo n.º 9
0
        public async Task NewRack()
        {
            Rack newrack = new Rack
            {
                Sections      = Settings.DefaultRackSections,
                Levels        = Settings.DefaultRackLevels,
                Depth         = Settings.DefaultRackDepth,
                SchemeVisible = true,
            };

            RackViewModel rvm = new RackViewModel(Navigation, newrack)
            {
                LocationCode = Zone.LocationCode,
                ZoneCode     = Zone.Code,
            };

            MasterRackNewViewModel mrnvm = new MasterRackNewViewModel(rvm);
            MasterNewRackPage      mnrp  = new MasterNewRackPage(mrnvm);

            await Navigation.PushAsync(mnrp);
        }
Ejemplo n.º 10
0
 private void FillModel(List <Rack> racks)
 {
     if (racks.Count > 0)
     {
         RackViewModels.Clear();
         State = ModelState.Normal;
         foreach (Rack rack in racks)
         {
             RackViewModel rvm = new RackViewModel(Navigation, rack, false);
             rvm.OnTap += Rvm_OnTap;
             RackViewModels.Add(rvm);
         }
         UpdateMinSizes();
         Rebuild(true);
     }
     else
     {
         State     = ModelState.Error;
         ErrorText = "No Data";
     }
 }
Ejemplo n.º 11
0
 private async void Rvm_OnTap(RackViewModel rvm)
 {
     if (!IsEditMode)
     {
         await Navigation.PushAsync(new RackCardPage(rvm));
     }
     else
     {
         foreach (RackViewModel rv in RackViewModels)
         {
             if (rv != rvm)
             {
                 rv.Selected = false;
             }
         }
         rvm.Selected = !rvm.Selected;
         if (rvm.Selected)
         {
             rvm.EditMode = SchemeElementEditMode.Move;
         }
     }
 }
Ejemplo n.º 12
0
        public async Task DeleteRack(object obj)
        {
            if (NotNetOrConnection)
            {
                return;
            }

            RackViewModel rvm = (RackViewModel)obj;

            string variant1 = String.Format(AppResources.RacksPlanViewModel_DeleteRack, rvm.No);
            string variant2 = String.Format(AppResources.RacksPlanViewModel_DeleteRack2, rvm.No);
            string variant3 = String.Format(AppResources.RacksPlanViewModel_DeleteRackAndBins, rvm.No);

            var action = await App.Current.MainPage.DisplayActionSheet(
                AppResources.RacksPlanViewModel_DeleteQuestion,
                AppResources.RacksPlanViewModel_DeleteCancel,
                null,
                variant1,
                variant2,
                variant3);

            if ((action != null) && (action != AppResources.RacksPlanViewModel_DeleteCancel))
            {
                if (action == variant1)
                {
                    try
                    {
                        await rvm.SaveToRackSchemeVisible(false);
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                        ErrorText = e.Message;
                        State     = ModelState.Error;
                    }
                }

                if (action == variant2)
                {
                    try
                    {
                        await NAV.DeleteRack(rvm.ID, ACD.Default).ConfigureAwait(true);
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                        ErrorText = e.Message;
                        State     = ModelState.Error;
                    }
                }

                if (action == variant3)
                {
                    try
                    {
                        State         = ModelState.Loading;
                        LoadAnimation = true;

                        await NAV.DeleteRack(rvm.ID, ACD.Default).ConfigureAwait(true);

                        NAVFilter navfilter = new NAVFilter
                        {
                            LocationCodeFilter = rvm.LocationCode,
                            ZoneCodeFilter     = rvm.ZoneCode,
                            RackIDFilter       = rvm.ID.ToString()
                        };

                        string     bindeleteerrors = "";
                        List <Bin> binsinrack      = await NAV.GetBinList(navfilter, ACD.Default).ConfigureAwait(true);

                        if (NotDisposed)
                        {
                            foreach (Bin bin in binsinrack)
                            {
                                try
                                {
                                    LoadingText = bin.Code;
                                    await NAV.DeleteBin(bin.LocationCode, bin.Code, ACD.Default).ConfigureAwait(true);
                                }
                                catch (Exception exp)
                                {
                                    bindeleteerrors += bin.Code + " : " + exp.InnerException.Message + Environment.NewLine + Environment.NewLine;
                                }
                            }
                        }

                        if (string.IsNullOrEmpty(bindeleteerrors))
                        {
                            State = ModelState.Normal;
                        }
                        else
                        {
                            ErrorText = AppResources.RacksPlanViewModel_DeleteBinErrors + "  " + Environment.NewLine + bindeleteerrors;
                            State     = ModelState.Error;
                        }
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                        ErrorText = e.Message;
                        State     = ModelState.Error;
                    }
                }
                await Load();
            }
        }
        public void DeleteRack(object obj)
        {
            RackViewModel rvm = (RackViewModel)obj;

            ErrorText = "";
        }