Beispiel #1
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.CardProgramFail)
            {
                this.View.Visibility = Visibility.Visible;
                VMReturnData.NavigationBar_Active = false;

                if (OkButtonPressed)
                {
                    OkButtonPressed = false;
                    VMReturnData.CardProgramFail = false;
                }

                if (RetryButtonPressed)
                {
                    RetryButtonPressed           = false;
                    VMReturnData.CardProgramFail = false;
                    VMReturnData.App_datareset();
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.CardFormatError)
            {
                this.View.Visibility = Visibility.Visible;
                VMReturnData.NavigationBar_Active = false;

                if (OkButtonPressed)
                {
                    VMReturnData.NewCardAccess_Active = true;
                    OkButtonPressed = false;
                    VMReturnData.CardFormatError = false;
                }

                if (RetryButtonPressed)
                {
                    RetryButtonPressed           = false;
                    VMReturnData.CardFormatError = false;
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #3
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.CardProramed_done)
            {
                this.View.Visibility = Visibility.Visible;
                VMReturnData.NavigationBar_Active = false;

                if (!splash)
                {
                    splash = true;
                    LFtagLost_Splash.Start();
                }

                if (splash_done)
                {
                    VMReturnData.CardProramed_done = false;
                    splash_done = false;
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
                splash = false;
            }
        }
Beispiel #4
0
        public App() : base()
        {
            #region MernokAssets
            mernokAssetFile  = MernokAssetManager.ReadMernokAssetFile();
            mernokClientFile = MernokClientManager.ReadMernokClientFile();


            foreach (MernokAsset item in mernokAssetFile.mernokAssetList)
            {
                TagTypesL.MernokAssetType.Add(item);
            }

            var MernokAssetGroups   = TagTypesL.MernokAssetType.Select(t => t.Group).Distinct().ToList();
            var MernokAssetGroupStr = TagTypesL.MernokAssetType.Select(t => t.GroupName).Distinct().ToList();
            int indx = 0;
            foreach (var item in MernokAssetGroupStr)
            {
                TagTypesL.MernokAssetGroups.Add(new AssetGroups {
                    GroupNumber = MernokAssetGroups[indx], GroupName = item
                });
                indx++;
            }

            TagTypesL.MernokAssetGroups = TagTypesL.MernokAssetGroups.OrderBy(t => t.GroupNumber).ToList();
            #endregion

            //Console.WriteLine();
            ////  <-- Keep this information secure! -->
            //Console.WriteLine("MachineName: {0}", Environment.MachineName);

            //Start main
            SystemVMReturnData = new ViewModelReturnData();

            RunMainSequence();
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.AdvancedPWMenu_Active)
            {
                this.View.Visibility = Visibility.Visible;
                VMReturnData.NavigationBar_Active = false;

                if (OkButtonPressed)
                {
                    OkButtonPressed = false;
                    if (MernokPW == "Mp123456")
                    {
                        VMReturnData.AdvancedMenu_Active   = true;
                        VMReturnData.AdvancedPWMenu_Active = false;
                    }
                    else
                    {
                        MernokPW = "Wrong password, try again!";
                    }
                }

                if (RetryButtonPressed)
                {
                    RetryButtonPressed = false;
                    VMReturnData.AdvancedPWMenu_Active = false;
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.ExitPromtView_Active)
            {
                this.View.Visibility = Visibility.Visible;
                VMReturnData.NavigationBar_Active = false;

                if (OkButtonPressed)
                {
                    OkButtonPressed = false;
                    Application.Current.Shutdown();
                }

                if (NoButtonPressed)
                {
                    NoButtonPressed = false;
                    VMReturnData.ExitPromtView_Active = false;
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #7
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.MenuView_Active)
            {
                VMReturnData.OptionsPressed = true;
                this.View.Visibility        = Visibility.Visible;
                //               VMReturnData.NavigationBar_Active = false;
                EditCardVis  = VMReturnData.MenuEditBtnEnabled;
                IssueCardVis = VMReturnData.MenuIssueBtnEnabled;


                if (AboutBtnPressed)
                {
                    AboutBtnPressed = false;
                    VMReturnData.AboutWindow_Active = true;
                }



                if (_AdvancedSet)
                {
                    _AdvancedSet = false;
                    VMReturnData.AdvancedPWMenu_Active = true;
                }

                if (IssuerCardBtnPressed)
                {
                    IssuerCardBtnPressed = false;
                    VMReturnData.NewIssuerPresent_Active = true;
                    VMReturnData.NewIssuerCard           = true;
                    VMReturnData.MenuView_Active         = false;
                }

                if (IssuerFileCardBtnPressed)
                {
                    IssuerFileCardBtnPressed          = false;
                    VMReturnData.NewCardIssuer_Active = true;
                    //                   VMReturnData.MenuView_Active = false;
                }


                #region Exit button
                else if (_buttonExitPressed)
                {
                    _buttonExitPressed           = false;
                    VMReturnData.MenuView_Active = false;
                }
                #endregion
            }
            else
            {
                VMReturnData.OptionsPressed = false;
                this.View.Visibility        = Visibility.Collapsed;
            }
        }
Beispiel #8
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.NewIssuerPresent_Active)
            {
                this.View.Visibility = Visibility.Visible;
                #region navigation bar details
                VMReturnData.NavigationBar_Active = true;
                VMReturnData.ViewTitle            = "Issuer Card";
                VMReturnData.SubTitle             = "Issuer select";
                VMReturnData.MenuButtonEnabled    = Visibility.Hidden;
                VMReturnData.HelpButtonEnabled    = Visibility.Visible;
                VMReturnData.BackButtonEnabled    = true;
                #endregion

                if (VMReturnData.NewCardWindow < 1)
                {
                    if (VMReturnData.CardInField)
                    {
                        cardInfoRead.UID = VMReturnData.UID;
                        formated         = cardInfoRead.Block1Info();
                        UID = cardInfoRead.UIDtoString(VMReturnData.UID);
                        if (formated)
                        {
                            CardImage      = new BitmapImage(new Uri(@"/Resources/Images/CardFormatError.png", UriKind.Relative));
                            WarningMessage = "Card formated, present unformated card.";
                            MessageColour  = Brushes.OrangeRed;
                        }
                        else
                        {
                            CardImage = new BitmapImage(new Uri(@"/Resources/Images/CardValid.png", UriKind.Relative));
                            VMReturnData.NextButtonEnabled = true;
                            MessageColour  = Brushes.White;
                            WarningMessage = "Card VALID: Click next to continue";
                        }
                    }
                    else
                    {
                        ClearDetails();
                        VMReturnData.NextButtonEnabled = false;
                    }
                }
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                View.Visibility            = Visibility.Collapsed;
                VMReturnData.NewIssuerCard = false;
                VMReturnData.NewIssuerUID  = 0;
            }
        }
 public override void Update(ViewModelReturnData VMReturnData)
 {
     if (this.View.Visibility == System.Windows.Visibility.Visible)
     {
         //Only update this viewModel when this view is visible
     }
     else
     {
         //View is not visible, do not update
         //Stop any animations on this vieModel
     }
 }
Beispiel #10
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (!VMReturnData.RWD_connected)
            {
                this.View.Visibility = Visibility.Visible;
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #11
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.EditCardWarn_Active)
            {
                RFIDCardInfoRead rFIDCardInfoRead = new RFIDCardInfoRead();
                this.View.Visibility = Visibility.Visible;
                EditUID = rFIDCardInfoRead.UIDtoString(VMReturnData.EditCardUID);
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #12
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.AboutWindow_Active)
            {
                this.View.Visibility = Visibility.Visible;
                VMReturnData.NavigationBar_Active = false;

                if (OkButtonPressed)
                {
                    OkButtonPressed = false;
                    VMReturnData.AboutWindow_Active = false;
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.CardStillIssuer_Active)
            {
                this.View.Visibility = Visibility.Visible;
                VMReturnData.NavigationBar_Active = false;

                if (OkButtonPressed)
                {
                    OkButtonPressed = false;
                    VMReturnData.CardStillIssuer_Active = false;

                    if (VMReturnData.CardInfoWrite.WriteInfoToCard(VMReturnData.VMCardDetails, VMReturnData.CardType) == 100)
                    {
                        VMReturnData.CardProramed_done = true;
                        VMReturnData.App_datareset();
                    }
                    else
                    {
                        VMReturnData.CardProgramFail = true;
                    }
                }
                if (RetryButtonPressed)
                {
                    RetryButtonPressed = false;
                    VMReturnData.CardStillIssuer_Active = false;
                    //                   VMReturnData.App_datareset();
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.MernokCardPresent_active)
            {
                RFIDCardInfoRead rFIDCardInfoRead = new RFIDCardInfoRead();
                this.View.Visibility = Visibility.Visible;
                if (VMReturnData.CardInField)
                {
                    VMReturnData.NewMernokUID             = VMReturnData.UID;
                    VMReturnData.NewMernokCard            = true;
                    VMReturnData.NewCardWindow            = 1;
                    VMReturnData.NavigationBar_Active     = true;
                    VMReturnData.NewCardDetail_Active     = true;
                    VMReturnData.MernokCardPresent_active = false;
                    VMReturnData.AdvancedMenu_Active      = false;
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.NewCardVID_Active)
            {
                this.View.Visibility = Visibility.Visible;
                //Only update this viewModel when this view is visible
                #region Navigation Bar details
                VMReturnData.ViewTitle         = "New Card";
                VMReturnData.SubTitle          = "Vehicle ID details";
                VMReturnData.CurrentPageNumber = 3;
                VMReturnData.TotalPageNumber   = 4;
                VMReturnData.MenuButtonEnabled = Visibility.Collapsed;
                VMReturnData.HelpButtonEnabled = Visibility.Visible;
                #endregion

                if (!OneTimeRead)
                {
                    DisplayVehicleList = new ObservableCollection <string>();
                    VehicleIDInfoList  = new ObservableCollection <string>();
                    OneTimeRead        = true;
                    index = 0;
                }

                if (Bypassed)
                {
                    DisplayVehicleList = new ObservableCollection <string> {
                        "All Vehicle Serials"
                    };
                    ByEnabled = BtnAddEnabled = false;
                    VMReturnData.VMCardDetails.VID        = Enumerable.Repeat(UInt16.MaxValue, 30).ToArray();
                    VMReturnData.VMCardDetails.ByPassBits = VMReturnData.VMCardDetails.ByPassBits | 0x04;
                    VMReturnData.NextButtonEnabled        = true;
                }
                else
                {
                    DisplayVehicleList = VehicleIDInfoList;
                    for (int i = 0; i < index; i++)
                    {
                        VMReturnData.VMCardDetails.VID[i] = Convert.ToUInt16(VehicleIDInfoList[i]);
                    }

                    if (VehicleIDInfoList.Count < 15 && VehicleID != "")
                    {
                        ByEnabled = BtnAddEnabled = true;
                    }
                    else
                    {
                        ByEnabled = BtnAddEnabled = false;
                    }

                    VMReturnData.NextButtonEnabled        = VehicleIDInfoList.Count() > 0 ? true : false;
                    VMReturnData.VMCardDetails.ByPassBits = (uint)(VMReturnData.VMCardDetails.ByPassBits & ~0b00000100);
                }

                if (AddbtnPressed)
                {
                    AddbtnPressed = false;
                    if ((index < 15) && (VehicleID != "") && int.TryParse(VehicleID, out int i))
                    {
                        VMReturnData.VMCardDetails.VID[index] = Convert.ToUInt16(VehicleID);
                        VehicleIDInfoList.Add(VehicleID);
                        VehicleID = "";
                        index++;
                    }
                    else
                    {
                        BtnAddEnabled = false;
                    }

                    VehicleID = "";
                }

                if (RemovebtnPressed)
                {
                    RemovebtnPressed = false;
                    if (VehicleIDInfoList.Count() > 0)
                    {
                        BtnremoveEnabled = true;
                        index--;
                        VMReturnData.VMCardDetails.VID[index] = 0;
                        VehicleIDInfoList.RemoveAt(VehicleIDInfoList.Count - 1);
                    }
                }

                if (VehicleIDInfoList.Count() > 0)
                {
                    BtnremoveEnabled = true;
                }
                else
                {
                    BtnremoveEnabled = false;
                }
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                this.View.Visibility = Visibility.Collapsed;
                OneTimeRead          = false;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //List<string> ports = PortFromVIDPID.ComPortNames(VID, PID);
            //if(ports.Count != VMReturnData.NumberofRWD)
            //{
            //    if (RFID.MernokRFID.OpenRFID(RFID.Mode.Mifare))
            //    {
            //        VMReturnData.RWD_connected = true;
            //    }
            //    else
            //    {
            //        VMReturnData.RWD_connected = false;
            //    }
            //    VMReturnData.NumberofRWD = ports.Count;
            //}

            //

            if (!RFID.MernokRFID.IsOpen())
            {
                if (RFID.MernokRFID.OpenRFID(RFID.Mode.Mifare))
                {
                    VMReturnData.RWD_connected = true;
                }
                else
                {
                    VMReturnData.RWD_connected = false;
                }
            }
            else
            {
                VMReturnData.UID = BitConverter.ToUInt64(RFID.MernokRFID_interface.read_UID(), 0);
                if (VMReturnData.UID != 0)
                {
                    VMReturnData.CardInField = true;

                    if (RFID.MernokRFID_interface.read_Status() == 0x86)
                    {
                        VMReturnData.CardType = 1;
                    }
                    else if (RFID.MernokRFID_interface.read_Status() == 0x96)
                    {
                        VMReturnData.CardType = 4;
                    }
                }
                else
                {
                    VMReturnData.CardInField = false;
                }

                if (VMReturnData.EditCard && !VMReturnData.NewIssuerCard && VMReturnData.EditCardUID != VMReturnData.UID && VMReturnData.NewCardWindow >= 1)
                {
                    VMReturnData.EditCardWarn_Active = true;
                }
                else
                {
                    VMReturnData.EditCardWarn_Active = false;
                }

                if (!VMReturnData.EditCard && !VMReturnData.NewIssuerCard && VMReturnData.NewCardUID != VMReturnData.UID && VMReturnData.NewCardWindow >= 1)
                {
                    VMReturnData.NewCardWarn_Active = true;
                }
                else
                {
                    VMReturnData.NewCardWarn_Active = false;
                }

                //if (!VMReturnData.EditCard && VMReturnData.NewIssuerCard && VMReturnData.NewIssuerUID != VMReturnData.UID && VMReturnData.NewCardWindow >= 1)
                //{
                //    VMReturnData.NewCardWarn_Active = true;
                //}
                //else
                //    VMReturnData.NewCardWarn_Active = false;
            }

            VMReturnData.StartUpView_Active = VMReturnData.RWD_connected;

            #region Navigation Bar Button Setter

            if (VMReturnData.LicenceView_Active)
            {
                VMReturnData.NavigationBar_Active = true;
            }
            else if (VMReturnData.NewCardDetail_Active)
            {
                VMReturnData.NavigationBar_Active = true;
            }
            else if (VMReturnData.NewCardAccess_Active)
            {
                VMReturnData.NavigationBar_Active = true;
            }
            else if (VMReturnData.NewIssuerPresent_Active)
            {
                VMReturnData.NavigationBar_Active = true;
            }
            else if (VMReturnData.NewCardIssuer_Active)
            {
                VMReturnData.NavigationBar_Active = true;
            }
            else
            {
                VMReturnData.NavigationBar_Active = false;
            }

            VMReturnData.CurrentPageNumber = VMReturnData.NewCardWindow + 1;
            VMReturnData.TotalPageNumber   = 4;

            #endregion


            if (NextbtnPressed)
            {
                VMReturnData.NextWindow();
                NextbtnPressed = false;
            }
            if (BackbtnPressed)
            {
                VMReturnData.BackWindow();
                BackbtnPressed = false;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.AdvancedMenu_Active)
            {
                VMReturnData.OptionsPressed = true;
                this.View.Visibility        = Visibility.Visible;


                if (_HotflagBtnPressed)
                {
                    CardDetails WriteCardDetails = new CardDetails()
                    {
                        Hotflaged_status = true, HotFlagedDate = DateTime.Now, HotFlagedVID = 123
                    };
                    RFIDCardInfoWrite rFIDCardInfoWrite = new RFIDCardInfoWrite();
                    _HotflagBtnPressed = false;
                    byte[] temp = rFIDCardInfoWrite.Block9(WriteCardDetails);
                    if (MernokRFID_interface.Mifare_Write_Block(Mifare_key.A, 0, WriteCardDetails.Block9_Addr, temp))
                    {
                    }

                    VMReturnData.CardProramed_done = true;
                    VMReturnData.App_datareset();
                }

                if (_mernokcardBtnPressed)
                {
                    _mernokcardBtnPressed = false;
                    VMReturnData.MernokCardPresent_active = true;
                    VMReturnData.NewMernokCard            = true;
                }

                if (_FormatbtnPressed)
                {
                    _FormatbtnPressed = false;
                    RFIDCardInfoWrite rFIDCardInfoWrite = new RFIDCardInfoWrite();
                    CardDetails       WriteCardDetails  = new CardDetails()
                    {
                        cardUID          = 0,
                        AccessLevel      = 0,
                        ByPassBits       = 0,
                        Client_Group     = 0,
                        Client_Site      = 0,
                        EngineerName     = "",
                        EngineerUID      = 0,
                        Expiry_Date      = DateTime.MinValue,
                        HotFlagedDate    = DateTime.MinValue,
                        HotFlagedVID     = 0,
                        Hotflaged_status = false,
                        IssuerUID        = 0,
                        Issue_Date       = DateTime.MinValue,
                        OperationalArea  = 0,
                        OperatorName     = "",
                        Options          = 0,
                        ProductCode      = 0,
                        Training_Date    = DateTime.MinValue,
                        VehicleGroup     = Enumerable.Repeat((byte)0, 16).ToArray(),
                        VID                = Enumerable.Repeat((UInt16)0, 16).ToArray(),
                        VehicleNames       = Enumerable.Repeat("", 16).ToArray(),
                        VehicleLicenceType = Enumerable.Repeat((uint)0, 32).ToArray(),
                        Warning_Date       = DateTime.MinValue
                    };
                    rFIDCardInfoWrite.WriteInfoToCard(WriteCardDetails, VMReturnData.CardType);

                    VMReturnData.CardProramed_done = true;
                    VMReturnData.App_datareset();
                }


                #region Exit button
                else if (_buttonExitPressed)
                {
                    _buttonExitPressed = false;
                    VMReturnData.AdvancedMenu_Active = false;
                }
                #endregion
            }
            else
            {
                VMReturnData.OptionsPressed = false;
                this.View.Visibility        = Visibility.Collapsed;
            }
        }
Beispiel #18
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.NewCardDetail_Active)
            {
                this.View.Visibility = Visibility.Visible;

                #region Navigation bar
                VMReturnData.ViewTitle = VMReturnData.EditCard ? "Edit Card" : "New Card";
                if (VMReturnData.NewMernokCard)
                {
                    VMReturnData.SubTitle = "Engineer details";
                }
                else
                {
                    VMReturnData.SubTitle = "Operator details";
                }
                //VMReturnData.CurrentPageNumber = 2;
                //VMReturnData.TotalPageNumber = 4;
                VMReturnData.MenuButtonEnabled = Visibility.Collapsed;
                VMReturnData.BackButtonEnabled = true;
                VMReturnData.HelpButtonEnabled = Visibility.Visible;
                #endregion

                //Only update this viewModel when this view is visible
                //if (VMReturnData.CardInField)
                //{
                //    UID = rFIDCardInfoRead.UIDtoString(VMReturnData.UID);
                //    CardImage = new BitmapImage(new Uri(@"/Resources/Images/CardValid.png", UriKind.Relative));
                //}
                //else
                //{
                //    UID = "Card not in field";
                //    CardImage = new BitmapImage(new Uri(@"/Resources/Images/PresentCard.png", UriKind.Relative));
                //}

                //if (VMReturnData.VMCardDetails.IssuerUID == VMReturnData.UID)
                //{
                //    VMReturnData.CardStillIssuer = true;
                //    UID = "Issuer Card in field";
                //}
                //else
                //{
                //    VMReturnData.CardStillIssuer = false;
                //}
                if (AboutTypeBtnPressed)
                {
                    AboutTypeBtnPressed = false;
                    VMReturnData.VehicleAccessLevelHelp = true;
                    VMReturnData.HelpButton();
                }

                if (AboutBtnPressed)
                {
                    AboutBtnPressed = false;
                    VMReturnData.AccessLevelHelp = true;
                    VMReturnData.HelpButton();
                }

                if (!onetimeread)
                {
                    ClientCode        = new ObservableCollection <string>();
                    ClientSite        = new ObservableCollection <string>();
                    AccessLevelList   = new ObservableCollection <string>();
                    VehicleAccessList = new ObservableCollection <string>();
                    ProductCode       = new ObservableCollection <string>();

                    foreach (RFIDCardInfoRead.AccessLevel_enum item in Enum.GetValues(typeof(RFIDCardInfoRead.AccessLevel_enum)))
                    {
                        string Level = item.ToString().Replace("_", " ");

                        if (((char)VMReturnData.IssuerAccess == 'C' || (VMReturnData.IssuerAccess == 9)) && (Level == "Operator" || Level == "Temporary Operator" || Level == "Trainee Operator" || Level == "Electrician" || Level == "Foreman" || Level == "Shift Boss" || Level == "Maintenance" || Level == "Field Technician"))
                        {
                            //AccessLevelList.Where(t => t.Equals("Operator") || t.Equals("Temporary Operator") || t.Equals("Trainee Operator")).ToList();
                            AccessLevelList.Add(Level);
                        }
                        else if ((char)VMReturnData.IssuerAccess == 'Z' || VMReturnData.NewMernokCard)
                        {
                            AccessLevelList.Add(Level);
                        }
                        else if (VMReturnData.NewIssuerCard)
                        {
                            if (!Level.Contains("Mernok"))
                            {
                                AccessLevelList.Add(Level);
                            }
                        }
                    }
                    AccessLevelnum = 0;

                    foreach (RFIDCardInfoRead.VehicleAccessType item in Enum.GetValues(typeof(RFIDCardInfoRead.VehicleAccessType)))
                    {
                        VehicleAccessList.Add(item.ToString().Replace("_", " "));
                    }
                    VehicleAccessType_ret = 0;

                    ClientCode      = mernokClientFile.mernokClientList.Select(l => l.ClientGroupName).Distinct().ToList();
                    ClientCodenum   = 0;
                    ClientSite      = mernokClientFile.mernokClientList.Where(l => l.Group == ClientCodenum).Select(t => t.ClientSiteName).ToList();
                    ClientSitenum   = 0;
                    ProductCode     = mernokProductFile.mernokProductList.Select(t => t.ProductName).ToList();
                    ProductList_ret = 0;
                    if (((char)VMReturnData.IssuerAccess == 'Z') || VMReturnData.NewIssuerCard || VMReturnData.NewMernokCard || ((char)VMReturnData.IssuerAccess == 13))
                    {
                        ClientEdit = true;
                        AccessEdit = true;
                    }
                    else if ((char)VMReturnData.IssuerAccess == 'C' || ((char)VMReturnData.IssuerAccess == 9))
                    {
                        ClientEdit    = false;
                        ClientCodenum = (int)VMReturnData.VMCardDetails.Client_Group;
                        ClientSitenum = Math.Abs(ClientSite.IndexOf(ClientSite.Where(T => T == mernokClientFile.mernokClientList[(int)VMReturnData.VMCardDetails.Client_Site].ClientSiteName).First()));
                    }

                    VMReturnData.VMCardDetails.Issue_Date = DateTime.Now;
                    ExpiryDate      = DateTime.Now;
                    WarningDate     = DateTime.Now;
                    TrainDate       = DateTime.Now;
                    TrainWarnDate   = DateTime.Now;
                    TrainExpDate    = DateTime.Now;
                    MedicalDate     = DateTime.Now;
                    MedicalWarnDate = DateTime.Now;
                    MedicalExpDate  = DateTime.Now;
                    DoverDate       = DateTime.Now;
                    DoverWarnDate   = DateTime.Now;
                    DoverExpDate    = DateTime.Now;
                    onetimeread     = true;
                    OperatorName    = "";
                    OperatorID      = "";
                    OperatorSurname = "";
                    OperationalArea = "";
                }

                if (VMReturnData.EditCard && !onetimeWrite)
                {
                    OperatorName          = VMReturnData.CopiedVMCardDetails.OperatorName.Replace(" ", "");
                    OperatorID            = VMReturnData.CopiedVMCardDetails.OperatorID.Replace(" ", "");
                    OperatorSurname       = VMReturnData.CopiedVMCardDetails.OperatorSurname.Replace(" ", "");
                    ClientCodenum         = (int)VMReturnData.CopiedVMCardDetails.Client_Group;
                    ClientSitenum         = Math.Abs(ClientSite.IndexOf(ClientSite.Where(T => T == mernokClientFile.mernokClientList[(int)VMReturnData.CopiedVMCardDetails.Client_Site].ClientSiteName).First()));
                    ProductList_ret       = (int)VMReturnData.CopiedVMCardDetails.ProductCode;
                    OperationalArea       = VMReturnData.CopiedVMCardDetails.OperationalArea.ToString();
                    TrainDate             = VMReturnData.CopiedVMCardDetails.Training_Date;
                    TrainWarnDate         = VMReturnData.CopiedVMCardDetails.Training_Warn_Date;
                    TrainExpDate          = VMReturnData.CopiedVMCardDetails.Training_Exp_Date;
                    MedicalDate           = VMReturnData.CopiedVMCardDetails.Medical_Date;
                    MedicalWarnDate       = VMReturnData.CopiedVMCardDetails.Medical_Warn_Date;
                    MedicalExpDate        = VMReturnData.CopiedVMCardDetails.Medical_Exp_Date;
                    DoverDate             = VMReturnData.CopiedVMCardDetails.Dover_Date;
                    DoverWarnDate         = VMReturnData.CopiedVMCardDetails.Dover_Warn_Date;
                    DoverExpDate          = VMReturnData.CopiedVMCardDetails.Dover_Exp_Date;
                    AccessLevelnum        = (int)Math.Abs(AccessLevelList.IndexOf(((RFIDCardInfoRead.AccessLevel_enum)VMReturnData.CopiedVMCardDetails.AccessLevel).ToString().Replace("_", " ")));
                    VehicleAccessType_ret = VMReturnData.CopiedVMCardDetails.Options;
                    ExpiryDate            = VMReturnData.CopiedVMCardDetails.Expiry_Date;
                    WarningDate           = VMReturnData.CopiedVMCardDetails.Warning_Date;
                    onetimeWrite          = true;
                }

                if (VMReturnData.NewMernokCard && !onetimeWrite2)
                {
                    OperatorName          = "Mernok";
                    OperatorID            = "";
                    OperatorSurname       = "";
                    ClientCodenum         = 18;
                    ClientSitenum         = 0;
                    ProductList_ret       = 0;
                    OperationalArea       = 1.ToString();
                    TrainDate             = DateTime.Now.AddDays(-1);
                    TrainWarnDate         = DateTime.Now.AddDays(-1);
                    TrainExpDate          = DateTime.Now.AddDays(-1);
                    MedicalDate           = DateTime.Now.AddDays(-1);
                    MedicalWarnDate       = DateTime.Now.AddDays(-1);
                    MedicalExpDate        = DateTime.Now.AddDays(-1);
                    DoverDate             = DateTime.Now.AddDays(-1);
                    DoverWarnDate         = DateTime.Now.AddDays(-1);
                    DoverExpDate          = DateTime.Now.AddDays(-1);
                    AccessLevelnum        = (int)Math.Abs(AccessLevelList.IndexOf((RFIDCardInfoRead.AccessLevel_enum.Mernok_Engineer.ToString().Replace("_", " "))));
                    VehicleAccessType_ret = VMReturnData.CopiedVMCardDetails.Options;
                    ExpiryDate            = DateTime.Now.AddMonths(1).AddDays(1);
                    WarningDate           = DateTime.Now.AddMonths(1);
                    onetimeWrite2         = true;
                    VMReturnData.VMCardDetails.EngineerName     = "Mernok Electronik";
                    VMReturnData.VMCardDetails.Issue_Date       = DateTime.Now;
                    VMReturnData.VMCardDetails.IssuerUID        = VMReturnData.NewMernokUID;
                    VMReturnData.VMCardDetails.EngineerUID      = 045;
                    VMReturnData.VMCardDetails.Hotflaged_status = false;
                }

                if (Conditioning())
                {
                    VMReturnData.NextButtonEnabled                = true;
                    VMReturnData.VMCardDetails.OperatorName       = OperatorName;
                    VMReturnData.VMCardDetails.OperatorID         = OperatorID;
                    VMReturnData.VMCardDetails.OperatorSurname    = OperatorSurname;
                    VMReturnData.VMCardDetails.Client_Group       = (uint)ClientCodenum;
                    VMReturnData.VMCardDetails.Client_Site        = (uint)ClientSitenum;
                    VMReturnData.VMCardDetails.ProductCode        = (uint)ProductList_ret;
                    VMReturnData.VMCardDetails.Client_Site        = mernokClientFile.mernokClientList.Where(t => t.ClientSiteName == ClientSite[ClientSitenum]).First().Client;
                    VMReturnData.VMCardDetails.OperationalArea    = Convert.ToUInt16(OperationalArea);
                    VMReturnData.VMCardDetails.Warning_Date       = WarningDate;
                    VMReturnData.VMCardDetails.Training_Date      = TrainDate;
                    VMReturnData.VMCardDetails.Training_Warn_Date = TrainWarnDate;
                    VMReturnData.VMCardDetails.Training_Exp_Date  = TrainExpDate;
                    VMReturnData.VMCardDetails.Medical_Date       = MedicalDate;
                    VMReturnData.VMCardDetails.Medical_Warn_Date  = MedicalWarnDate;
                    VMReturnData.VMCardDetails.Medical_Exp_Date   = MedicalExpDate;
                    VMReturnData.VMCardDetails.Dover_Date         = DoverDate;
                    VMReturnData.VMCardDetails.Dover_Warn_Date    = DoverWarnDate;
                    VMReturnData.VMCardDetails.Dover_Exp_Date     = DoverExpDate;
                    VMReturnData.VMCardDetails.Expiry_Date        = ExpiryDate;
                    VMReturnData.VMCardDetails.AccessLevel        = (byte)(RFIDCardInfoRead.AccessLevel_enum)Enum.Parse(typeof(RFIDCardInfoRead.AccessLevel_enum), AccessLevelList[(int)AccessLevelnum].Replace(" ", "_"));
                    VMReturnData.VMCardDetails.Options            = VehicleAccessType_ret;
                    VMReturnData.VMCardDetails.Hotflaged_status   = false;
                }
                else
                {
                    VMReturnData.NextButtonEnabled = false;
                }
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                this.View.Visibility = Visibility.Collapsed;
                onetimeread          = false;
                onetimeWrite         = false;
                onetimeWrite2        = false;
            }
        }
Beispiel #19
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.LicenceView_Active)
            {
                View.Visibility = Visibility.Visible;

                #region NavigationBar details
                //               VMReturnData.ViewTitle = "Licence Details";
                VMReturnData.ViewTitle         = VMReturnData.cardInfoRead.UIDtoString(VMReturnData.prevUID);
                VMReturnData.SubTitle          = "Licence Details";
                VMReturnData.CurrentPageNumber = 1;
                VMReturnData.TotalPageNumber   = 1;
                VMReturnData.MenuButtonEnabled = Visibility.Visible;
                VMReturnData.HelpButtonEnabled = Visibility.Hidden;
                VMReturnData.NextButtonEnabled = false;
                VMReturnData.BackButtonEnabled = false;
                #endregion

                #region menu buttons
                VMReturnData.MenuEditBtnEnabled  = Visibility.Visible;
                VMReturnData.MenuIssueBtnEnabled = Visibility.Collapsed;
                #endregion

                //Only update this viewModel when this view is visible

                #region populate view
                if (!CardRead_Done)
                {
                    CardRead_Done = true;
                    VehicleInfoList.Clear();
                    switch (VMReturnData.cardInfoRead.cardDetails.Options)
                    {
                    case 3:
                        foreach (byte item in VMReturnData.cardInfoRead.cardDetails.VehicleGroup)
                        {
                            AccessType = "Group";
                            if (item != 0 && item != 255)
                            {
                                VehicleInfoList.Add(new VehicleInfoClass {
                                    VehicleInfo = TagTypesL.MernokAssetGroups[item - 1].GroupName, ImagePath = "/Resources/Images/53272.jpg"
                                });
                            }
                            if (item == 255 && VehicleInfoList.Count == 0)
                            {
                                VehicleInfoList.Add(new VehicleInfoClass
                                {
                                    VehicleInfo = "All Vehicle Groups",
                                    ImagePath   = ("/Resources/Images/TagTypes/Fleet.jpg")
                                });
                            }
                        }
                        break;

                    case 1:
                        foreach (uint item in VMReturnData.cardInfoRead.cardDetails.VID)
                        {
                            if (item != 0 && item != UInt16.MaxValue)
                            {
                                VehicleInfoList.Add(new VehicleInfoClass {
                                    VehicleInfo = item.ToString("X"), ImagePath = "/Resources/Images/53272.jpg"
                                });
                            }
                            if (item == UInt16.MaxValue && VehicleInfoList.Count == 0)
                            {
                                VehicleInfoList.Add(new VehicleInfoClass
                                {
                                    VehicleInfo = "All Vehicle Serails",
                                    ImagePath   = ("/Resources/Images/TagTypes/Fleet.jpg")
                                });
                            }
                            AccessType = "Serial";
                        }
                        break;

                    case 2:
                        foreach (string item in VMReturnData.cardInfoRead.cardDetails.VehicleNames)
                        {
                            if (item != null && item != "                " && item != "")
                            {
                                VehicleInfoList.Add(new VehicleInfoClass {
                                    VehicleInfo = item, ImagePath = " / Resources/Images/53272.jpg"
                                });
                            }
                            if (item == "                " && VehicleInfoList.Count == 0)
                            {
                                VehicleInfoList.Add(new VehicleInfoClass
                                {
                                    VehicleInfo = "All Vehicle Names",
                                    ImagePath   = ("/Resources/Images/TagTypes/Fleet.jpg")
                                });
                            }
                            AccessType = "Name";
                        }
                        break;

                    case 0:
                        foreach (uint item in VMReturnData.cardInfoRead.cardDetails.VehicleLicenceType)
                        {
                            if (item != 0 && item != 255)
                            {
                                VehicleInfoList.Add(new VehicleInfoClass
                                {
                                    VehicleInfo = TagTypesL.MernokAssetType[(int)item - 1].TypeName,
                                    ImagePath   = ("/Resources/Images/TagTypes/" + TagTypesL.MernokAssetType[(int)item - 1].Type.ToString() + ".png")
                                });
                            }
                            if (item == 255 && VehicleInfoList.Count == 0)
                            {
                                VehicleInfoList.Add(new VehicleInfoClass
                                {
                                    VehicleInfo = "All Vehicle Types",
                                    ImagePath   = ("/Resources/Images/TagTypes/Fleet.jpg")
                                });
                            }

                            AccessType = "Type";
                        }
                        break;


                    default:
                        break;
                    }

                    OperatorName    = VMReturnData.cardInfoRead.cardDetails.OperatorName;
                    OperatorID      = VMReturnData.cardInfoRead.cardDetails.OperatorID;
                    OperatorSurname = VMReturnData.cardInfoRead.cardDetails.OperatorSurname;
                    ProductCode     = mernokProductFile.mernokProductList.Where(t => t.Product == VMReturnData.cardInfoRead.cardDetails.ProductCode).First().ProductName;
                    //ClientGroup = (VMReturnData.cardInfoRead.cardDetails.Client_Group).ToString().Replace("_", " ");
                    ClientGroup         = mernokClientFile.mernokClientList.Where(t => t.Group == VMReturnData.cardInfoRead.cardDetails.Client_Group).First().ClientGroupName;
                    AccessLevel         = ((AccessLevel_enum)VMReturnData.cardInfoRead.cardDetails.AccessLevel).ToString().Replace("_", " ");
                    ExpireDate          = VMReturnData.cardInfoRead.cardDetails.Expiry_Date.ToShortDateString();
                    WarningDate         = VMReturnData.cardInfoRead.cardDetails.Warning_Date.ToShortDateString();
                    TrainingDate        = VMReturnData.cardInfoRead.cardDetails.Training_Date.ToShortDateString();
                    TrainingWarningDate = VMReturnData.cardInfoRead.cardDetails.Training_Warn_Date.ToShortDateString();
                    TrainingExpiryDate  = VMReturnData.cardInfoRead.cardDetails.Training_Exp_Date.ToShortDateString();
                    MedicalDate         = VMReturnData.cardInfoRead.cardDetails.Medical_Date.ToShortDateString();
                    MedicalWarningDate  = VMReturnData.cardInfoRead.cardDetails.Medical_Warn_Date.ToShortDateString();
                    MedicalExpiryDate   = VMReturnData.cardInfoRead.cardDetails.Medical_Exp_Date.ToShortDateString();
                    DoverDate           = VMReturnData.cardInfoRead.cardDetails.Dover_Date.ToShortDateString();
                    DoverWarningDate    = VMReturnData.cardInfoRead.cardDetails.Dover_Warn_Date.ToShortDateString();
                    DoverExpiryDate     = VMReturnData.cardInfoRead.cardDetails.Dover_Exp_Date.ToShortDateString();
                    IssueDate           = VMReturnData.cardInfoRead.cardDetails.Issue_Date.ToShortDateString();
                    IssuerUID           = VMReturnData.cardInfoRead.UIDtoString(VMReturnData.cardInfoRead.cardDetails.IssuerUID);
                    EngineerName        = VMReturnData.cardInfoRead.cardDetails.EngineerName;
                    EngineerUID         = VMReturnData.cardInfoRead.UIDtoString(VMReturnData.cardInfoRead.cardDetails.EngineerUID);
                    HotFlag             = VMReturnData.cardInfoRead.cardDetails.Hotflaged_status;
                    if (HotFlag)
                    {
                        HotFlagDate = VMReturnData.cardInfoRead.cardDetails.HotFlagedDate.ToShortDateString();
                        HotFlagUID  = VMReturnData.cardInfoRead.cardDetails.HotFlagedVID.ToString();
                    }
                    else
                    {
                        HotFlagDate = "";
                        HotFlagUID  = "";
                    }

                    //ClientCode = ((ClientSite)VMReturnData.cardInfoRead.cardDetails.Client_Site + " " + VMReturnData.cardInfoRead.cardDetails.OperationalArea).Replace("_", " ");
                    ClientCode = mernokClientFile.mernokClientList.Where(t => t.Client == VMReturnData.cardInfoRead.cardDetails.Client_Site).First().ClientSiteName + " " + VMReturnData.cardInfoRead.cardDetails.OperationalArea;

                    if (VMReturnData.cardInfoRead.cardDetails.Expiry_Date < DateTime.Now)
                    {
                        ExpColour = Brushes.Red;
                    }
                    else
                    {
                        ExpColour = null;
                    }

                    if (VMReturnData.cardInfoRead.cardDetails.Warning_Date < DateTime.Now)
                    {
                        WarnColor = Brushes.OrangeRed;
                    }
                    else
                    {
                        WarnColor = null;
                    }
                }



                #endregion
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                View.Visibility = Visibility.Collapsed;
                CardRead_Done   = false;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.NewCardAccess_Active)
            {
                this.View.Visibility = Visibility.Visible;
                #region navigation bar details
                VMReturnData.ViewTitle         = VMReturnData.EditCard ? "Edit Card" : "New Card";
                VMReturnData.SubTitle          = "Issuer details";
                VMReturnData.CurrentPageNumber = 1;
                VMReturnData.TotalPageNumber   = 4;
                VMReturnData.MenuButtonEnabled = Visibility.Hidden;
                VMReturnData.HelpButtonEnabled = Visibility.Visible;
                VMReturnData.BackButtonEnabled = false;
                #endregion

                #region menu buttons
                VMReturnData.MenuEditBtnEnabled  = Visibility.Collapsed;
                VMReturnData.MenuIssueBtnEnabled = Visibility.Visible;
                MessageColour = Brushes.OrangeRed;
                #endregion



                if (VMReturnData.CardInField && ((VMReturnData.UID != VMReturnData.EditCardUID && VMReturnData.EditCard) || VMReturnData.UID != VMReturnData.NewCardUID))
                {
                    if (!onetimeread)
                    {
                        CardinFieldUID = VMReturnData.UID;
                        cardInfoRead.cardDetails.IssuerUID = CardinFieldUID;
                        if (cardInfoRead.ReadIssuer(CardinFieldUID))
                        {
                            #region Warning messages
                            MessageColour = Brushes.OrangeRed;
                            if ((char)cardInfoRead.cardDetails.AccessLevel == 9 || (char)cardInfoRead.cardDetails.AccessLevel == 13 || (char)cardInfoRead.cardDetails.AccessLevel == 14 || (char)cardInfoRead.cardDetails.AccessLevel == 'C' || (char)cardInfoRead.cardDetails.AccessLevel == 'Z')
                            {
                                Accesslevel_good          = true;
                                VMReturnData.IssuerAccess = cardInfoRead.cardDetails.AccessLevel;
                            }
                            else
                            {
                                Accesslevel_good = false;
                                WarningMessage   = "Issuer Card has insufficient access";
                            }

                            if (cardInfoRead.cardDetails.EngineerName != "")
                            {
                                EngineerName_good = true;
                            }
                            else
                            {
                                EngineerName_good = false;
                                WarningMessage    = "Issuer name is undefined";
                            }

                            if (cardInfoRead.cardDetails.IssuerUID != 0)
                            {
                                EngineerUID_good = true;
                            }
                            else
                            {
                                EngineerUID_good = false;
                                WarningMessage   = "Issuer UID undefined";
                            }

                            if (cardInfoRead.cardDetails.EngineerUID != 0)
                            {
                                EngineerUID_good = true;
                            }
                            else
                            {
                                EngineerUID_good = false;
                                WarningMessage   = "Engineer UID undefined";
                            }

                            if ((lastYear < cardInfoRead.cardDetails.Issue_Date) && (cardInfoRead.cardDetails.Expiry_Date > DateTime.Now))
                            {
                                Issuer_WarnDate_good = true;
                            }
                            else
                            {
                                Issuer_WarnDate_good = false;
                                WarningMessage       = "Issuer Card has expired";
                            }
                            #endregion
                            CardImage   = new BitmapImage(new Uri(@"/Resources/Images/CArdInvalid.png", UriKind.Relative));
                            onetimeread = true;
                        }
                        else
                        {
                            ClearDetails();
                            WarningMessage = "Issuer Card not formatted";
                            CardImage      = new BitmapImage(new Uri(@"/Resources/Images/CardFormatError.png", UriKind.Relative));
                        }
                    }
                    if (onetimeread)
                    {
                        IssueDate    = cardInfoRead.cardDetails.Issue_Date.ToShortDateString();
                        IssuerUID    = cardInfoRead.UIDtoString(CardinFieldUID);
                        EngineerName = cardInfoRead.cardDetails.EngineerName;
                        EngineerUID  = cardInfoRead.UIDtoString(cardInfoRead.cardDetails.EngineerUID);
                        AccessLevel  = ((AccessLevel_enum)cardInfoRead.cardDetails.AccessLevel).ToString().Replace("_", " ");

                        if (EngineerName_good && EngineerUID_good && Issuer_WarnDate_good && Accesslevel_good && VMReturnData.NewCardWindow < 1)
                        {
                            VMReturnData.NextButtonEnabled = true;
                            MessageColour  = Brushes.White;
                            WarningMessage = "Card VALID: Click next to continue";
                            CardImage      = new BitmapImage(new Uri(@"/Resources/Images/CardValid.png", UriKind.Relative));
                            VMReturnData.VMCardDetails.EngineerName = cardInfoRead.cardDetails.EngineerName;
                            VMReturnData.VMCardDetails.IssuerUID    = cardInfoRead.cardDetails.IssuerUID;
                            VMReturnData.VMCardDetails.EngineerUID  = cardInfoRead.cardDetails.EngineerUID;
                            VMReturnData.VMCardDetails.Client_Group = cardInfoRead.cardDetails.Client_Group;
                            VMReturnData.VMCardDetails.Client_Site  = cardInfoRead.cardDetails.Client_Site;
                        }
                        else
                        {
                            //WarningMessage = "Issuer Card has expired";
                        }
                    }
                }
                else
                {
                    ClearDetails();
                    VMReturnData.NextButtonEnabled = false;
                    onetimeread = false;
                }
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                View.Visibility = Visibility.Collapsed;
                onetimeread     = false;
                VMReturnData.NextButtonEnabled = false;
            }
        }
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible
            if (VMReturnData.StartUpView_Active)
            {
                this.View.Visibility = Visibility.Visible;
                #region Startup operation
                CardPresent = formated & VMReturnData.CardInField;
                if (VMReturnData.CardInField && !VMReturnData.OptionsPressed && !VMReturnData.NewIssuerCard)
                {
                    if (VMReturnData.prevUID == 0)
                    {
                        VMReturnData.prevUID = VMReturnData.UID;
                        readVis = Visibility.Collapsed;
                    }
                    else if (VMReturnData.prevUID != VMReturnData.UID)
                    {
                        VMReturnData.cardChanged     = true;
                        VMReturnData.CardFormatError = false;
                        oneRead = false;
                        VMReturnData.prevUID = VMReturnData.UID;
                    }

                    if (VMReturnData.cardChanged && VMReturnData.LicenceView_Active && VMReturnData.EditCard != true)
                    {
                        VMReturnData.BackApp();
                        VMReturnData.cardChanged = false;
                    }
                    else if (VMReturnData.NewCardWindow < 1 && formated && !VMReturnData.NewCardAccess_Active)
                    {
                        VMReturnData.cardChanged = false;
                        if (!oneRead)
                        {
                            ReadCardInfoHandler();
                            readVis = Visibility.Visible;
                            oneRead = true;
                        }
                    }
                    else if (VMReturnData.NewCardWindow < 1 && !formated && !VMReturnData.NewCardAccess_Active)
                    {
                        VMReturnData.cardChanged = false;
                        if (!oneRead)
                        {
                            NewCardInfoHandler();
                            readVis = Visibility.Visible;
                            oneRead = true;
                        }
                    }

                    UID = RFIDCardInfoRead.UIDtoString(VMReturnData.UID);
                    RFIDCardInfoRead.UID = VMReturnData.UID;
                    formated             = RFIDCardInfoRead.Block1Info();

                    if (formated)
                    {
                        CardImage = new BitmapImage(new Uri(@"/Resources/Images/CardValid.png", UriKind.Relative));
                    }
                    else
                    {
                        CardImage = new BitmapImage(new Uri(@"/Resources/Images/CardFormatError.png", UriKind.Relative));

                        //readVis = Visibility.Collapsed;
                    }
                    VMReturnData.cardInfoRead.formatted = formated;


                    if (ReadCardPressed == true)
                    {
                        ReadCardPressed = false;
                        doneProgress    = false;
                        ProgressBarTimer.Start();
                        VMReturnData.cardInfoRead.ReadInfo(VMReturnData.UID);
                    }

                    if (NewCardPressed == true)
                    {
                        //VMReturnData.NewCardAccess_Active = true;
                        ReadCardInfoHandler();
                        VMReturnData.EditCard      = false;
                        VMReturnData.EditCardUID   = 0;
                        VMReturnData.NewCardWindow = 0;
                        VMReturnData.NewCardUID    = VMReturnData.UID;
                        NewCardPressed             = false;
                    }
                }
                else
                {
                    UID = "Present RFID card";
                    ProgressBarValue = 0;
                    ReadProgress     = default_max;
                    doneProgress     = false;
                    oneRead          = false;
                    this.CardImage   = new BitmapImage(new Uri(@"/Resources/Images/PresentCard.png", UriKind.Relative));
                    ProgressBarTimer.Stop();
                    readVis = Visibility.Collapsed;
                }

                if (OptionsPressed)
                {
                    OptionsPressed = false;
                    VMReturnData.MenuView_Active = true;
                }

                if (doneProgress)
                {
                    if (!VMReturnData.cardInfoRead.formatted)
                    {
                        VMReturnData.CardFormatError = true;
                    }
                    else
                    {
                        VMReturnData.LicenceView_Active = true;
                    }

                    doneProgress     = false;
                    ProgressBarValue = 2;
                    ReadProgress     = default_max;
                }
                #endregion

                #region Exit button
                else if (_buttonExitPressed)
                {
                    _buttonExitPressed = false;
                    VMReturnData.ExitPromtView_Active = true;
                }
                #endregion
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #22
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.NavigationBar_Active)
            {
                View.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                View.Visibility = System.Windows.Visibility.Collapsed;
            }

            if (this.View.Visibility == System.Windows.Visibility.Visible)
            {
                //RuleTitle = VMReturnData.Rule_Managers.Complete_Group_info_List.ElementAt(_currentPageNumber).Group_Name;
                //TotalPageNumber = VMReturnData.Rule_Managers.PD_Rule_List.Count;

                ViewTitle         = VMReturnData.ViewTitle;
                RuleTitle         = VMReturnData.SubTitle;
                PageProgress      = VMReturnData.NavBarProgress;
                CurrentPageNumber = VMReturnData.CurrentPageNumber;
                TotalPageNumber   = VMReturnData.TotalPageNumber;
                PageProgress      = (int)(((float)CurrentPageNumber / (float)(TotalPageNumber)) * 100);

                NextVisible     = (Visibility)Convert.ToInt16(!VMReturnData.NextButtonEnabled);
                PreviousVisible = (Visibility)Convert.ToInt16(!VMReturnData.BackButtonEnabled);
                MenuVisable     = VMReturnData.MenuButtonEnabled;
                HelpVisable     = VMReturnData.HelpButtonEnabled;

                if (_buttonBackPressed)
                {
                    _buttonBackPressed = false;
                    VMReturnData.BackApp();

                    //VMReturnData.Temp_Page_Number = 0;
                    //VMReturnData.View_Changed = true;
                    //VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.Main_Menu_View_Selected] = true;
                    //VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected] = false;
                    //VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected] = false;
                    //VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.Rule_Template_View_Selected] = false;
                }

                else if (_buttonNextPagePressed && VMReturnData.NextButtonEnabled)
                {
                    _buttonNextPagePressed = false;
                    VMReturnData.NextWindow();
                    //VMReturnData.Temp_Page_Number++;
                    //VMReturnData.View_Changed = true;

                    //if (VMReturnData.Temp_Page_Number == VMReturnData.Rule_Managers.PD_Rule_List.Count && VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected])
                    //{
                    //    VMReturnData.Temp_Page_Number = 0;
                    //    VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected] = false;
                    //    VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected] = true;
                    //}
                    //else if (VMReturnData.Temp_Page_Number == VMReturnData.Rule_Managers.PD_Rule_List.Count && VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected])
                    //{
                    //    VMReturnData.Temp_Page_Number = 0;
                    //    VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected] = true;
                    //    VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected] = false;
                    //}
                }

                else if (_buttonPreviousPagePressed && VMReturnData.BackButtonEnabled)
                {
                    _buttonPreviousPagePressed = false;
                    VMReturnData.BackWindow();
                    //VMReturnData.Temp_Page_Number--;
                    //VMReturnData.View_Changed = true;

                    //if (VMReturnData.Temp_Page_Number < 0 && VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected])
                    //{
                    //    VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected] = false;
                    //    VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected] = true;
                    //    VMReturnData.Temp_Page_Number = VMReturnData.Rule_Managers.PD_Rule_List.Count - 1;
                    //}
                    //else if (VMReturnData.Temp_Page_Number < 0 && VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected])
                    //{
                    //    VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected] = true;
                    //    VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected] = false;
                    //    VMReturnData.Temp_Page_Number = VMReturnData.Rule_Managers.PD_Rule_List.Count - 1;
                    //}
                }

                else if (_buttonRuleMenuPressed)
                {
                    _buttonRuleMenuPressed = false;
                    VMReturnData.MenuButton();
                    //VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.Rule_Menu_View_Selected] = true;
                }
                else if (_buttonHelpPressed)
                {
                    _buttonHelpPressed = false;
                    VMReturnData.HelpButton();
                }

                //if (VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected])
                //{
                //    ViewTitle = "Vehicle to Vehicle Rules";

                //}
                //if (VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected])
                //{
                //    ViewTitle = "Vehicle to Static Rules";
                //}


                //    if (VMReturnData.Temp_Page_Number == 0)
                //    {
                //        if (VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected])
                //        {
                //            PreviousTitle = "Vehicle to Vehicle Rules";
                //            NextTitle = VMReturnData.Rule_Managers.Complete_Group_info_List.ElementAt(VMReturnData.Temp_Page_Number + 2).Group_Name;

                //        }
                //        if (VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected])
                //        {
                //            PreviousTitle = "Vehicle to Static Rules";
                //            NextTitle = VMReturnData.Rule_Managers.Complete_Group_info_List.ElementAt(VMReturnData.Temp_Page_Number + 2).Group_Name;
                //        }
                //    }
                //    else if (VMReturnData.Temp_Page_Number == VMReturnData.Rule_Managers.PD_Rule_List.Count)
                //    {
                //        if (VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.PDRules_View_Selected])
                //        {
                //            NextTitle = "Vehicle to Vehicle Rules";
                //            PreviousTitle = VMReturnData.Rule_Managers.Complete_Group_info_List.ElementAt(VMReturnData.Temp_Page_Number).Group_Name;

                //        }
                //        if (VMReturnData.View_Selected[(int)ViewModelReturnData.View_Selected_Enum.System_Specific_View_Selected])
                //        {
                //            NextTitle = "Vehicle to Static Rules";
                //            PreviousTitle = VMReturnData.Rule_Managers.Complete_Group_info_List.ElementAt(VMReturnData.Temp_Page_Number).Group_Name;
                //        }
                //    }
                //    else
                //    {
                //        NextTitle = VMReturnData.Rule_Managers.Complete_Group_info_List.ElementAt(VMReturnData.Temp_Page_Number + 2).Group_Name;
                //        PreviousTitle = VMReturnData.Rule_Managers.Complete_Group_info_List.ElementAt(VMReturnData.Temp_Page_Number).Group_Name;
                //    }

                //    CurrentPageNumber = VMReturnData.Temp_Page_Number + 1;
                //    PageProgress = (int)(((float)CurrentPageNumber / (float)(VMReturnData.Rule_Managers.PD_Rule_List.Count)) * 100);
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
            }
        }
Beispiel #23
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.NewCardVNames_Active)
            {
                View.Visibility = Visibility.Visible;
                #region Navigationbar Details
                VMReturnData.ViewTitle         = "New Card";
                VMReturnData.SubTitle          = "Vehicle Name details";
                VMReturnData.CurrentPageNumber = 3;
                VMReturnData.TotalPageNumber   = 4;
                VMReturnData.MenuButtonEnabled = Visibility.Collapsed;
                VMReturnData.HelpButtonEnabled = Visibility.Visible;
                //Only update this viewModel when this view is visible
                #endregion

                if (!OneTimeRead)
                {
                    VehicleInfoList    = new ObservableCollection <string>();
                    DisplayVehicleList = new ObservableCollection <string>();
                    OneTimeRead        = true;
                    VehicleName        = "";
                    index = 0;
                }

                if (Bypassed)
                {
                    DisplayVehicleList = new ObservableCollection <string> {
                        "All Vehicle Serials"
                    };
                    ByEnabled = BtnAddEnabled = false;
                    VMReturnData.VMCardDetails.VehicleNames = Enumerable.Repeat("", 15).ToArray();
                    VMReturnData.VMCardDetails.ByPassBits   = VMReturnData.VMCardDetails.ByPassBits | 0x04;
                    VMReturnData.NextButtonEnabled          = true;
                }
                else
                {
                    DisplayVehicleList = VehicleInfoList;
                    for (int i = 0; i < index; i++)
                    {
                        VMReturnData.VMCardDetails.VehicleNames[i] = VehicleInfoList[i];
                    }
                    if (VehicleInfoList.Count < 15 && VehicleName != "")
                    {
                        ByEnabled = BtnAddEnabled = true;
                    }
                    else
                    {
                        ByEnabled = BtnAddEnabled = false;
                    }
                    VMReturnData.NextButtonEnabled        = VehicleInfoList.Count() > 0 ? true : false;
                    VMReturnData.VMCardDetails.ByPassBits = (uint)(VMReturnData.VMCardDetails.ByPassBits & ~0b00000100);
                }


                if (AddbtnPressed)
                {
                    if (index < 15 && VehicleName != "")
                    {
                        VMReturnData.VMCardDetails.VehicleNames[index] = VehicleName;
                        VehicleInfoList.Add(VehicleName);
                        index++;
                    }
                    else
                    {
                        BtnAddEnabled = false;
                    }

                    for (int i = index; i < 15; i++)
                    {
                        VMReturnData.VMCardDetails.VehicleNames[index] = null;
                    }

                    VehicleName   = "";
                    AddbtnPressed = false;
                }

                if (RemovebtnPressed)
                {
                    RemovebtnPressed = false;
                    if (VehicleInfoList.Count() > 0)
                    {
                        BtnremoveEnabled = true;
                        index--;
                        VMReturnData.VMCardDetails.VehicleNames[index] = null;
                        VehicleInfoList.RemoveAt(VehicleInfoList.Count - 1);
                    }
                }

                if (VehicleInfoList.Count() > 0)
                {
                    BtnremoveEnabled = true;
                }
                else
                {
                    BtnremoveEnabled = false;
                }
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                View.Visibility = Visibility.Collapsed;
                OneTimeRead     = false;
            }
        }
Beispiel #24
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.NewCardGroup_Active)
            {
                this.View.Visibility = Visibility.Visible;
                //Only update this viewModel when this view is visible

                #region Navigationbar details
                VMReturnData.ViewTitle         = "New Card";
                VMReturnData.SubTitle          = "Group details";
                VMReturnData.CurrentPageNumber = 3;
                VMReturnData.TotalPageNumber   = 4;
                VMReturnData.MenuButtonEnabled = Visibility.Collapsed;
                VMReturnData.HelpButtonEnabled = Visibility.Visible;
                #endregion

                if (!OneTimeRead)
                {
                    VehicleGroupList   = new ObservableCollection <string>();
                    VehiclegroupList2  = new ObservableCollection <string>();
                    DisplayVehicleList = new ObservableCollection <string>();
                    foreach (var item in TagTypesL.MernokAssetGroups)
                    {
                        VehicleGroupList.Add(item.GroupName);
                    }
                    OneTimeRead     = true;
                    VehicleGroupnum = 0;
                    index           = 0;
                }

                if (Bypassed)
                {
                    DisplayVehicleList = new ObservableCollection <string> {
                        "All Vehicle Groups"
                    };
                    ByEnabled = BtnAddEnabled = false;
                    VMReturnData.VMCardDetails.VehicleGroup = Enumerable.Repeat((byte)255, 30).ToArray();
                    VMReturnData.VMCardDetails.ByPassBits   = VMReturnData.VMCardDetails.ByPassBits | 0x04;
                    VMReturnData.NextButtonEnabled          = true;
                }
                else
                {
                    DisplayVehicleList = VehiclegroupList2;
                    for (int i = 0; i < index; i++)
                    {
                        VMReturnData.VMCardDetails.VehicleGroup[i] = (byte)(TagTypesL.MernokAssetGroups.IndexOf(TagTypesL.MernokAssetGroups.Where(p => p.GroupName == VehiclegroupList2[i]).FirstOrDefault()) + 1);
                    }
                    VMReturnData.NextButtonEnabled        = VehiclegroupList2.Count() > 0 ? true : false;
                    VMReturnData.VMCardDetails.ByPassBits = (uint)(VMReturnData.VMCardDetails.ByPassBits & ~0b00000100);
                }

                if (AddbtnPressed)
                {
                    if (VehiclegroupList2.Count() < 15 && VehicleGroupList.Count > 0)
                    {
                        VehiclegroupList2.Add(VehicleGroupList[VehicleGroupnum]);
                        VMReturnData.VMCardDetails.VehicleGroup[index] = (byte)(TagTypesL.MernokAssetGroups.IndexOf(TagTypesL.MernokAssetGroups.Where(p => p.GroupName == VehicleGroupList[VehicleGroupnum]).FirstOrDefault()) + 1);
                        index++;
                        AddbtnPressed = false;
                        VehicleGroupList.RemoveAt(VehicleGroupnum);
                        VehicleGroupnum = 0;
                    }
                }

                if (RemovebtnPressed)
                {
                    RemovebtnPressed = false;
                    if (VehiclegroupList2.Count() > 0)
                    {
                        BtnremoveEnabled = true;
                        index--;
                        VMReturnData.VMCardDetails.VehicleGroup[index] = 0;
                        VehicleGroupList.Add(VehiclegroupList2.Last());
                        VehiclegroupList2.RemoveAt(VehiclegroupList2.Count - 1);
                    }
                }

                if (VehicleGroupList.Count > 0)
                {
                    ByEnabled = BtnAddEnabled = true;
                }
                else
                {
                    BtnAddEnabled = false;
                }

                if (VehiclegroupList2.Count() > 0)
                {
                    BtnremoveEnabled = true;
                }
                else
                {
                    BtnremoveEnabled = false;
                }
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                OneTimeRead          = false;
                this.View.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #25
0
        public override void Update(ViewModelReturnData VMReturnData)
        {
            //Only update this view if visible

            if (VMReturnData.ProgramPromtView_Active)
            {
                this.View.Visibility = Visibility.Visible;

                if (VMReturnData.NewIssuerCard)
                {
                    ProgramPrompt = "Do you wish to save this card file?";
                }
                else
                {
                    ProgramPrompt = "Do you wish to Program this card?";
                }

                if (OkButtonPressed)
                {
                    OkButtonPressed = false;
                    VMReturnData.ProgramPromtView_Active = false;
                    if (!VMReturnData.NewIssuerCard)
                    {
                        if (VMReturnData.CardInfoWrite.WriteInfoToCard(VMReturnData.VMCardDetails, VMReturnData.CardType) == 100)
                        {
                            VMReturnData.CardProramed_done = true;
                            VMReturnData.App_datareset();
                        }
                        else
                        {
                            VMReturnData.CardProgramFail = true;
                            VMReturnData.NewCardWindow--;
                        }
                    }
                    else
                    {
                        CardDetailsFile cardDetailsFile = new CardDetailsFile();
                        cardDetailsFile.createdBy          = "N. Pretorius";
                        cardDetailsFile.dateCreated        = DateTime.Now;
                        cardDetailsFile.version            = 1;
                        VMReturnData.VMCardDetails.cardUID = VMReturnData.NewIssuerUID;
                        cardDetailsFile.FCardDetails       = VMReturnData.VMCardDetails;
                        CardDetailManager.CreateCardDetailFile(cardDetailsFile);

                        VMReturnData.CardProramed_done = true;
                        VMReturnData.App_datareset();
                    }
                }

                if (NoButtonPressed)
                {
                    NoButtonPressed = false;
                    VMReturnData.ProgramPromtView_Active = false;
                    VMReturnData.NewCardWindow--;
                }
            }
            else
            {
                this.View.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #26
0
 public abstract void Update(ViewModelReturnData VMReturnData);
        public override void Update(ViewModelReturnData VMReturnData)
        {
            if (VMReturnData.NewCardIssuer_Active)
            {
                this.View.Visibility = Visibility.Visible;

                #region Navigationbar details
                VMReturnData.ViewTitle = "New Issuer Card";
                VMReturnData.SubTitle  = "New Issuer details";
                //VMReturnData.CurrentPageNumber = 1;
                //VMReturnData.TotalPageNumber = 4;
                VMReturnData.MenuButtonEnabled = Visibility.Collapsed;
                VMReturnData.HelpButtonEnabled = Visibility.Visible;
                #endregion

                if (IssuerFileCardBtnPressed)
                {
                    IssuerFileCardBtnPressed = false;
                    MernokPasswordFile mernokPasswordFile = MernokPasswordManager.ReadMernokPasswordFile(V);
                    OpenFileDialog     openFileDialog1    = new OpenFileDialog();
                    openFileDialog1.Filter = "License Files|*.merlic";
                    openFileDialog1.Title  = "Select a Mernok Licnese File";
                    if (openFileDialog1.ShowDialog() == true)
                    {
                        // Assign the cursor in the Stream to the Form's Cursor property.
                        Console.WriteLine(Path.GetFullPath(openFileDialog1.FileName));
                        LicenseFilePath            = Path.GetFullPath(openFileDialog1.FileName);
                        CardDetailsFile            = CardDetailManager.ReadCardDetailFile(LicenseFilePath);
                        VMReturnData.VMCardDetails = CardDetailsFile.FCardDetails;
                        VMReturnData.NewCardUID    = CardDetailsFile.FCardDetails.cardUID;
                    }

                    //
                }

                if (CardDetailsFile.FCardDetails == null)
                {
                    WarningMessageF = "Please select a license file.";
                    CardUidPresVis  = Visibility.Collapsed;
                }
                else
                {
                    CardUidPresVis = Visibility.Visible;
                }

                if (!VMReturnData.CardInField)
                {
                    if (CardDetailsFile.FCardDetails != null)
                    {
                        WarningMessageI = "Present RFID card with UID: " + VMReturnData.cardInfoRead.UIDtoString(CardDetailsFile.FCardDetails.cardUID);
                    }
                    MessageColour = Brushes.OrangeRed;
                }
                else if (CardDetailsFile.FCardDetails != null && CardDetailsFile.FCardDetails.cardUID == VMReturnData.UID)
                {
                    VMReturnData.VMCardDetails.IssuerUID = CardinFieldUID = VMReturnData.UID;
                    MernokPasswordFile mernokPasswordFile = MernokPasswordManager.ReadMernokPasswordFile(V);
                    bool password = true;// PasswordFinder.FindPasswordinFile(AdminPassword, mernokPasswordFile);
                    if (password)
                    {
                        PassColour = Brushes.GreenYellow;

                        string[] IssuerDetails = { "1", "piet", "1", "2" };    //PasswordDecriptor.PasswordToDetails(AdminPassword);
                        VMReturnData.VMCardDetails.EngineerName = IssuerDetails[3];
                        VMReturnData.VMCardDetails.EngineerUID  = UInt32.Parse(IssuerDetails[0]);
                        VMReturnData.NextButtonEnabled          = true;
                        WarningMessageI = "Password good, click next to continue";
                        MessageColour   = Brushes.White;
                    }
                    else
                    {
                        MessageColour = Brushes.OrangeRed;
                        PassColour    = Brushes.OrangeRed;
                        VMReturnData.NextButtonEnabled = false;
                        if (AdminPassword == "")
                        {
                            WarningMessageI = "Enter your password";
                        }
                        else
                        {
                            WarningMessageI = "Enter correct password";
                        }
                    }
                }
            }
            else
            {
                //View is not visible, do not update
                //Stop any animations on this vieModel
                this.View.Visibility = Visibility.Collapsed;
                AdminPassword        = "";
            }
        }