Ejemplo n.º 1
0
            public MCard(IDCard iCard)
            {
                this.sid = "Vk7Tc-PJx";

                this.idnumber = iCard.IDNumber;

                this.name = iCard.Name;

                this.gender = iCard.Sex;

                string birth = "";

                birth += iCard.BirthDay.Substring(0, 4);
                birth += "-";

                birth += iCard.BirthDay.Substring(4, 2);
                birth += "-";

                birth += iCard.BirthDay.Substring(6, 2);

                this.dateofbirth = birth;

                this.other = iCard.Address;

                this.address = new Address
                {
                    province = "",
                    city     = "",
                    district = "",
                    other    = ""
                };
            }
Ejemplo n.º 2
0
        private void CheckDoorAccess(IDCard cardID, DoorController doorController, GameObject originator)
        {
            Debug.Log("been here!");
            if (cardID.accessSyncList.Contains((int)doorController.restriction))
            {
// has access
                allowInput = false;
                if (!doorController.IsOpened)
                {
                    PlayerManager.LocalPlayerScript.playerNetworkActions.CmdTryOpenDoor(gameObject, originator);
                }
                else
                {
                    PlayerManager.LocalPlayerScript.playerNetworkActions.CmdTryCloseDoor(gameObject);
                }

                Debug.Log(doorController.restriction + " access granted");
                StartCoroutine(DoorInputCoolDown());
            }
            else
            {
// does not have access
                Debug.Log(doorController.restriction + " no access");
                allowInput = false;
                StartCoroutine(DoorInputCoolDown());
                PlayerManager.LocalPlayerScript.playerNetworkActions.CmdRestrictDoorDenied(gameObject);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Try to get player IDcard
        /// </summary>
        /// <param name="idCard">player id card if found</param>
        /// <returns>true if player has id card</returns>
        private bool TryFindIDCard(out IDCard idCard)
        {
            foreach (var slot in readableIDslots)
            {
                ItemSlot itemSlot = script.ItemStorage.GetNamedItemSlot(slot);
                if (itemSlot.IsOccupied)
                {
                    // if item is ID card
                    if (itemSlot.ItemObject.TryGetComponent <IDCard>(out idCard))
                    {
                        return(true);
                    }

                    // if item is PDA and IDCard is not null
                    if (itemSlot.ItemObject.TryGetComponent <PDALogic>(out PDALogic pdaLogic) && pdaLogic.IDCard != null)
                    {
                        idCard = pdaLogic.IDCard;
                        return(true);
                    }
                }
            }

            idCard = null;
            return(false);
        }
Ejemplo n.º 4
0
        private void CheckDoorAccess(IDCard cardID, DoorController doorController)
        {
            if (cardID.accessSyncList.Contains((int)doorController.restriction))
            {
                // has access
                allowInput = false;
                //Server only here but it is a cmd for the input trigger (opening with mouse click from client)
                if (CustomNetworkManager.Instance._isServer)
                {
                    doorController.CmdTryOpen(gameObject);
                }

                StartCoroutine(DoorInputCoolDown());
            }
            else
            {
                // does not have access
                allowInput = false;
                StartCoroutine(DoorInputCoolDown());
                //Server only here but it is a cmd for the input trigger (opening with mouse click from client)
                if (CustomNetworkManager.Instance._isServer)
                {
                    doorController.CmdTryDenied();
                }
            }
        }
Ejemplo n.º 5
0
 private IDCard ReadCard()
 {
     try
     {
         iConnectionState = IC.InitComm();
         if (iConnectionState == 1)
         {
             int iResult = 0;
             while (iResult != 2)
             {
                 iResult = IC.ReadCardContent();
                 Thread.Sleep(100);
             }
         }
         else
         {
             IC = null;
         }
     }
     catch (Exception ex)
     {
         IC = null;
         //LogImpl.Error(string.Format("{0}{2}{1}", ex.StackTrace, ex.Message, System.Environment.NewLine));
     }
     return(IC);
 }
Ejemplo n.º 6
0
        public void ReadIDCard()
        {
            StringBuilder Name        = new StringBuilder(31);
            StringBuilder Gender      = new StringBuilder(3);
            StringBuilder Folk        = new StringBuilder(10);
            StringBuilder BirthDay    = new StringBuilder(9);
            StringBuilder Code        = new StringBuilder(19);
            StringBuilder Address     = new StringBuilder(71);
            StringBuilder Agency      = new StringBuilder(31);
            StringBuilder ExpireStart = new StringBuilder(9);
            StringBuilder ExpireEnd   = new StringBuilder(9);

            //读身份证信息
            int intReadBaseInfosRet = ReadBaseInfos(Name, Gender, Folk, BirthDay, Code, Address, Agency, ExpireStart, ExpireEnd);

            if (intReadBaseInfosRet == 1)
            {
                IDCard CardData = new IDCard();
                CardData.Code        = Code.ToString().Trim();
                CardData.Name        = Name.ToString().Trim();
                CardData.Gender      = Gender.ToString().Trim();
                CardData.Flok        = Folk.ToString().Trim();
                CardData.BirthDay    = BirthDay.ToString().Trim();
                CardData.Address     = Address.ToString().Trim();
                CardData.Agency      = Agency.ToString().Trim();
                CardData.ExpireStart = ExpireStart.ToString().Trim();
                CardData.ExpireEnd   = ExpireEnd.ToString().Trim();
                //CardData.PhotoDirectory +=  "//photo.bmp";
                receivedID?.Invoke(CardData);
            }
        }
Ejemplo n.º 7
0
 private void btn_idAdd_ok_Click(object sender, EventArgs e)
 {
     if (!checkDGV())
     {
         MyMessageBox msg = new MyMessageBox("单次最多添加20人!");
         msg.ShowDialog();
         //MessageBox.Show("单次最多添加20人");
         return;
     }
     if (checkIDNum(tb_idNum.Text))
     {
         IDCard idInfo = new IDCard()
         {
             Code = tb_idNum.Text
         };
         var result = addDGVRow(idInfo);
         if (result)
         {
             //MyMessageBox msg = new MyMessageBox("添加成功");
             //msg.Show();
             //MessageBox.Show("添加成功");
         }
         tb_idNum.Clear();
     }
     else
     {
         MyMessageBox msg = new MyMessageBox("请输入正确身份证号");
         msg.ShowDialog();
         //MessageBox.Show();
     }
 }
Ejemplo n.º 8
0
        private async void KeepgetIdCard()
        {
            ValueSet vs = new ValueSet();

            vs.Add("Command", "IDCard");
            AppServiceConnection connection = App.Connection;

            if (connection != null)
            {
                await Task.Run(async() =>
                {
                    while (keepReading)
                    {
                        var vss  = await connection.SendMessageAsync(vs);
                        var arry = vss.Message.ToArray();
                        if (vss.Message.Keys.Count >= 1)
                        {
                            await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                            {
                                CurrentCard = Newtonsoft.Json.JsonConvert.DeserializeObject <IDCard>(arry[0].Value as String);
                                IDCardReceived?.Invoke(this, null);
                            });
                        }

                        Thread.Sleep(800);
                    }
                });
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Updates the ID on the MainMenu
        /// </summary>
        public void UpdateId()
        {
            if (!controller.Pda)
            {
                return;
            }
            IDCard idCard = controller.Pda.IdCard;

            // Not "Optimized" by rider for readability
            //Checks to see if the ID card is not null, if so then display the owner of the ID and their job
            if (idCard != null)
            {
                cachedidText = $"{idCard.RegisteredName},{idCard.JobType}";
                idLabel.SetValueServer(cachedidText);
            }
            else
            {
                cachedidText = "<No ID Inserted>";
                idLabel.SetValueServer(cachedidText);
            }
            //Checks to see if the PDA has a registered name, if it does make that the Desktop name
            if (controller.Pda.PdaRegisteredName != null)
            {
                string editedString = controller.Pda.PdaRegisteredName.Replace(" ", "_");
                cachedMachineLabelText = $"/home/{editedString}/Desktop";
                machineLabel.SetValueServer(cachedMachineLabelText);
            }
            else
            {
                cachedMachineLabelText = "/home/Guest/Desktop";
                machineLabel.SetValueServer(cachedMachineLabelText);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Try to get player IDcard
        /// </summary>
        /// <param name="idCard">player id card if found</param>
        /// <returns>true if player has id card</returns>
        private bool TryFindIDCard(out IDCard idCard)
        {
            foreach (var slot in readableIDslots)
            {
                foreach (var itemSlot in script.DynamicItemStorage.GetNamedItemSlots(slot))
                {
                    if (itemSlot.IsOccupied == false)
                    {
                        continue;
                    }
                    // if item is ID card
                    if (itemSlot.ItemObject.TryGetComponent(out idCard))
                    {
                        return(true);
                    }

                    // if item is PDA and IDCard is not null
                    if (itemSlot.ItemObject.TryGetComponent <PDALogic>(out var pdaLogic) == false ||
                        pdaLogic.IDCard == null)
                    {
                        continue;
                    }

                    idCard = pdaLogic.IDCard;
                    return(true);
                }
            }

            idCard = null;
            return(false);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 读取身份证信息
 /// </summary>
 /// <param name="card">正确读卡时,返回身份证信息</param>
 /// <param name="msg">出错时,返回错误信息</param>
 /// <returns></returns>
 public bool ReadIDCard(out IDCard card, out string msg)
 {
     msg  = "";
     card = new IDCard();
     try
     {
         if (!OpenDevice())
         {
             msg = "读卡器未连接";
             return(false);
         }
         int n   = Authenticate();
         int res = Read_Content(2);
         if (res != 1)
         {
             msg = "读卡错误";
             return(false);
         }
         ReadWZFile(ref card);
         CloseDevice();
         return(true);
     }
     catch (Exception ex)
     {
         msg = ex.Message;
     }
     return(false);
 }
Ejemplo n.º 12
0
        public void VerifyTest()
        {
            var idcard = "440304198511212612";
            var card   = IDCard.Verify(idcard);

            Assert.AreEqual("1985-11-21", card.DayOfBirth.ToString("yyyy-MM-dd"));
            Assert.AreEqual("男", card.Gender);
            Assert.AreEqual(true, card.IsVerifyPass);
            Assert.AreEqual("华南地区", card.Region);
            Assert.AreEqual("广东省", card.Province);
            Assert.AreEqual("福田区", card.City);

            var idcard2 = "440304198511212611";
            var card2   = IDCard.Verify(idcard2);

            Assert.AreEqual(false, card2.IsVerifyPass);

            var idcard3 = "440304851121261";
            var card3   = IDCard.Verify(idcard3);

            Assert.AreEqual("1985-11-21", card3.DayOfBirth.ToString("yyyy-MM-dd"));
            Assert.AreEqual("男", card3.Gender);
            Assert.AreEqual("华南地区", card3.Region);
            Assert.AreEqual("广东省", card3.Province);
            Assert.AreEqual("福田区", card3.City);
        }
Ejemplo n.º 13
0
 public void SetIDCard(IDCard card)
 {
     this.txtName.Text       = card.Name;
     this.txtIdCard.Text     = card.IDC;
     this.txtAddress.Text    = card.ADDRESS;
     this.dateBirthday.Value = card.BIRTH;
     this.cbSex.Text         = IDCardHelper.GetSexName(card.IDC);
 }
Ejemplo n.º 14
0
        private IDCard GetRandomCard()
        {
            Random random      = new Random();
            int    randomValue = random.Next(0, (cards.Count() - 1));
            IDCard c           = cards[randomValue];

            return(c);
        }
 /// <summary>
 /// Insert some ID into console and update login details.
 /// Will spit out currently inserted ID card.
 /// </summary>
 ///<param name="cardToInsert">Card you want to insert</param>
 private void InsertID(IDCard cardToInsert)
 {
     if (IdCard)
     {
         RemoveID();
     }
     IdCard = cardToInsert;
 }
	/// <summary>
	/// Spits out ID card from console and updates login details.
	/// </summary>
	public void RemoveID()
	{
		ObjectBehaviour objBeh = IdCard.GetComponentInChildren<ObjectBehaviour>();
		Vector3Int pos = gameObject.RegisterTile().WorldPosition;
		CustomNetTransform netTransform = objBeh.GetComponent<CustomNetTransform>();
		netTransform.AppearAtPosition(pos);
		netTransform.AppearAtPositionServer(pos);
		IdCard = null;
	}
Ejemplo n.º 17
0
 public void SetUpAssign(GUI_IdConsoleOld consoleOldToSet, IDCard idToSet, Occupation occupationToSet)
 {
     isAssignment           = true;
     console                = consoleOldToSet;
     idCard                 = idToSet;
     occupation             = occupationToSet;
     displayedName.SetValue = occupationToSet.JobType.JobString();
     CheckIsSet();
 }
Ejemplo n.º 18
0
 public void SetUpAssign(GUI_IdConsole consoleToSet, IDCard idToSet, JobOutfit jobToSet)
 {
     isAssignment           = true;
     console                = consoleToSet;
     idCard                 = idToSet;
     jobOutfit              = jobToSet;
     displayedName.SetValue = jobOutfit.jobType.JobString();
     CheckIsSet();
 }
Ejemplo n.º 19
0
    /// <summary>
    /// Spits out ID card from console and updates login details.
    /// </summary>
    /// <param name="cardToEject">Card you want to eject</param>
    public void EjectCard(IDCard cardToEject)
    {
        ObjectBehaviour    objBeh       = cardToEject.GetComponentInChildren <ObjectBehaviour>();
        Vector3Int         pos          = gameObject.RegisterTile().WorldPosition;
        CustomNetTransform netTransform = objBeh.GetComponent <CustomNetTransform>();

        netTransform.AppearAtPosition(pos);
        netTransform.AppearAtPositionServer(pos);
        UpdateGUI();
    }
Ejemplo n.º 20
0
 public void SetUpAccess(GUI_IdConsoleOld consoleToSet, IDCard idToSet, IdAccess accessToSet, IdAccessCategory categoryToSet)
 {
     isAssignment           = false;
     console                = consoleToSet;
     idCard                 = idToSet;
     access                 = accessToSet.RelatedAccess;
     category               = categoryToSet;
     displayedName.SetValue = accessToSet.AccessName;
     CheckIsSet();
 }
Ejemplo n.º 21
0
            protected override bool VerifyNumber()
            {
                long n;

                if (long.TryParse(IDCard.Remove(17), out n) == false || n < Math.Pow(10, 16) || long.TryParse(IDCard.Replace('x', '0').Replace('X', '0'), out n) == false)
                {
                    return(false);//数字验证
                }
                return(true);
            }
Ejemplo n.º 22
0
 private void AfterReadIdCard(IDCard card)
 {
     //TODO,所属地区代码的实现
     this.txtName.Text   = card.Name;
     this.txtIdCard.Text = card.IDC;
     this.InitByIdCard(this.txtIdCard.Text);
     this.txtRegAddress.Text = this.txtConnAddress.Text = card.ADDRESS;
     this.dateBirthday.Value = card.BIRTH;
     this.cbSex.Text         = IDCardHelper.GetSexName(card.IDC);
 }
Ejemplo n.º 23
0
            protected override bool VerifyBrithDay()
            {
                string   birth = IDCard.Substring(6, 8).Insert(6, "-").Insert(4, "-");
                DateTime time  = new DateTime();

                if (DateTime.TryParse(birth, out time) == false)
                {
                    return(false);//生日验证
                }
                return(true);
            }
Ejemplo n.º 24
0
 void reader_ReadICCardComplete(IDCard card)
 {
     this.txtName.Text      = card.Name;
     this.txtSex.Text       = card.Sex_CName;
     this.txtRace.Text      = card.NATION_CName;
     this.txtBirthday.Text  = card.BIRTH.ToShortDateString();
     this.txtAddress.Text   = card.ADDRESS;
     this.txtDateBegin.Text = card.STARTDATE.ToShortDateString();
     this.txtDateEnd.Text   = card.ENDDATE.ToShortDateString();
     this.txtNewData.Text   = card.Period_Of_Validity_CName;
     this.pictureBox1.Image = card.PIC_Image;
 }
Ejemplo n.º 25
0
 private void ProcessIdChange(IDCard newId = null)
 {
     UpdateIdTexts();
     if (newId != null)
     {
         LogIn();
     }
     else
     {
         LogOut();
     }
 }
Ejemplo n.º 26
0
 private void ProcessIdChange(IDCard newId = null)
 {
     UpdateIdTexts();
     if (newId != null || IsAIInteracting() == true)
     {
         LogIn();
     }
     else
     {
         LogOut();
     }
 }
Ejemplo n.º 27
0
    /// <summary>
    /// Gets name and jobtype from ID card worn in ID slot if any.
    /// </summary>
    /// <param name="namedSlot"></param>
    /// <returns></returns>
    public String GetIdentityFromID()
    {
        IDCard card = ItemSlot.GetNamed(itemStorage, NamedSlot.id)?.Item?.GetComponent <IDCard>();

        if (card != null)
        {
            return(card.RegisteredName + " " + (card.Occupation ? $" ({ card.Occupation.DisplayName })" : ""));
        }
        else
        {
            return("Unknown");
        }
    }
Ejemplo n.º 28
0
        private static void ReadIdCard(IDCard idcard)
        {
            string path = Application.StartupPath + "//success.wav";

            SystemDefine.PlaySound(path, 0, SystemDefine.SND_ASYNC | SystemDefine.SND_FILENAME);//播放音乐
            SendKeys.SendWait(idcard.IDC.ToUpper());
            IDCardConfig config = StaticCacheManager.GetConfig <IDCardConfig>();

            if (config.AddReturn)
            {
                SendKeys.SendWait("{ENTER}");
            }
        }
Ejemplo n.º 29
0
    /* Example Spawn:
     *
     * //Only client side spawn, not network. For things that are just eye candy like bullets, sparks etc
     * public void SpawnSomeItem(float ItemStatAmt, Vector2 position){
     *
     *  GameObject itemObj = PoolManager.PoolClientInstantiate(Instance.someItem, position, Quaternion.identity);
     *  ItemThingy iT = itemObj.GetComponent<ItemThingy>();
     *  iT.DoStuff(ItemStatAmt);
     * }
     *
     * Example of a network pool spawn:
     * GameObject networkedObj = PoolManager.PoolNetworkInstantiate(prefabObj, Vector2.zero, Quaternion.identity);
     */

    /// <summary>
    ///     For spawning new ID cards, mostly used on new player spawn
    /// </summary>
    public GameObject SpawnIDCard(IDCardType idCardType, JobType jobType, List <Access> allowedAccess, string name)
    {
        //No need to pool it but doesn't hurt (and requires less lines)
        GameObject idObj = PoolManager.Instance.PoolNetworkInstantiate(idCard, Vector2.zero, Quaternion.identity);
        IDCard     ID    = idObj.GetComponent <IDCard>();

        //Set all the synced properties for the card
        ID.RegisteredName = name;
        ID.jobTypeInt     = (int)jobType;
        ID.idCardTypeInt  = (int)idCardType;
        ID.AddAccessList(allowedAccess);
        return(idObj);
    }
Ejemplo n.º 30
0
    /* Example Spawn:
     *
     * //Only client side spawn, not network. For things that are just eye candy like bullets, sparks etc
     * public void SpawnSomeItem(float ItemStatAmt, Vector2 position){
     *
     *  GameObject itemObj = PoolManager.PoolClientInstantiate(Instance.someItem, position, Quaternion.identity);
     *  ItemThingy iT = itemObj.GetComponent<ItemThingy>();
     *  iT.DoStuff(ItemStatAmt);
     * }
     *
     * Example of a network pool spawn:
     * GameObject networkedObj = PoolManager.PoolNetworkInstantiate(prefabObj, Vector2.zero, Quaternion.identity);
     */

    /// <summary>
    ///     For spawning new ID cards, mostly used on new player spawn
    /// </summary>
    public GameObject SpawnIDCard(IDCardType idCardType, JobType jobType, List <Access> allowedAccess, string name, Transform parent)
    {
        //No need to pool it but doesn't hurt (and requires less lines)
        GameObject idObj = SpawnItem(idCard, parent);
        IDCard     ID    = idObj.GetComponent <IDCard>();

        //Set all the synced properties for the card
        ID.RegisteredName = name;
        ID.jobTypeInt     = (int)jobType;
        ID.idCardTypeInt  = (int)idCardType;
        ID.AddAccessList(allowedAccess);
        return(idObj);
    }