コード例 #1
0
        private void Refresh()
        {
            try
            {
                if (App.CroppedImage != null)
                {
                    Stream stream = new MemoryStream(App.CroppedImage);

                    imagetosave         = new MemoryStream(App.CroppedImage).ToArray();
                    Imagecropped.Source = ImageSource.FromStream(() => stream);

                    idInfo = new IdInfo
                    {
                        comments  = coments,
                        Image     = _imageSource,
                        ImageByte = imagetosave,
                    };



                    createImage(path, idInfo);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
コード例 #2
0
        bool SelectItem(string id)
        {
            if (id == null)
            {
                return(false);
            }

            IdInfo info = IdInfo.Parse(id);

            foreach (ListViewItem item in this.listView_tags.Items)
            {
                if (info.Prefix == "pii")
                {
                    string current_pii = ListViewUtil.GetItemText(item, COLUMN_PII);
                    if (current_pii == info.Text)
                    {
                        ListViewUtil.SelectLine(item, true);
                        return(true);
                    }
                }

                if (info.Prefix == "uid")
                {
                    string current_uid = ListViewUtil.GetItemText(item, COLUMN_UID);
                    if (current_uid == info.Text)
                    {
                        ListViewUtil.SelectLine(item, true);
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #3
0
 public async Task <IActionResult> AddIdentityNumber(IdsDto idsDto)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(idsDto.idNumbers))
         {
             return(BadRequest("No identity numbers in request"));
         }
         //split identity numbers from request
         var idNumbers = idsDto.idNumbers.Trim()
                         .Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
         //Get the valid and invalid id information if they exist.
         IdInfo idInfo = _identityNumberService.ExtractIdInformation(idNumbers, _identityNumberValidator);
         // Save to data store: In case as a csv file
         if (idInfo.validIdInfos.Any())
         {
             await _dataRepository.Save(idInfo.validIdInfos);
         }
         if (idInfo.InvalidIdInfos.Any())
         {
             await _dataRepository.Save(idInfo.InvalidIdInfos);
         }
         return(NoContent());
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message, e);
         return(StatusCode(500, e.Message));
     }
 }
コード例 #4
0
ファイル: OdbCache.cs プロジェクト: Myvar/Eclang
        public void SavePositionOfObjectWithOid(OID oid, long objectPosition)
        {
            if (oid == null)
            {
                throw new OdbRuntimeException(NDatabaseError.CacheNullOid);
            }

            var idInfo = new IdInfo(objectPosition, IDStatus.Active);

            _objectPositionsByIds[oid] = idInfo;
        }
コード例 #5
0
        public void PrototypeTest()
        {
            const int    originalAge       = 42;
            var          originalBirthDate = Convert.ToDateTime("1977-01-01");
            const string originalName      = "Jack Daniels";
            const int    originalIdNumber  = 666;
            var          originalId        = new IdInfo(originalIdNumber);

            var p1 = new Person
            {
                Age       = originalAge,
                BirthDate = originalBirthDate,
                Name      = originalName,
                IdInfo    = originalId
            };

            // Perform a shallow copy of p1 and assign it to p2.
            var p2 = p1.ShallowCopy();
            // Make a deep copy of p1 and assign it to p3.
            var p3 = p1.DeepCopy();

            // Original values of p1, p2, p3
            p1.Should().BeEquivalentTo(p2);
            p2.Should().BeEquivalentTo(p3);

            const int    newAge       = 32;
            var          newBirthDate = Convert.ToDateTime("1900-01-01");
            const string newName      = "Frank";
            const int    newIdNumber  = 7878;

            // Change the value of p1 properties and display the values of p1,
            // p2 and p3.
            p1.Age             = newAge;
            p1.BirthDate       = newBirthDate;
            p1.Name            = newName;
            p1.IdInfo.IdNumber = newIdNumber;

            p1.Age.Should().Be(newAge);
            p1.BirthDate.Should().Be(newBirthDate);
            p1.Name.Should().Be(newName);
            p1.IdInfo.IdNumber.Should().Be(newIdNumber);

            // p2 reference values have changed
            p2.Age.Should().Be(originalAge);
            p2.BirthDate.Should().Be(originalBirthDate);
            p2.Name.Should().Be(originalName);
            p2.IdInfo.IdNumber.Should().Be(newIdNumber);

            // p3 reference values have not changed
            p3.Age.Should().Be(originalAge);
            p3.BirthDate.Should().Be(originalBirthDate);
            p3.Name.Should().Be(originalName);
            p3.IdInfo.IdNumber.Should().Be(originalIdNumber);
        }
コード例 #6
0
            public static IdInfo Parse(string text)
            {
                IdInfo info = new IdInfo();

                if (text.IndexOf(":") == -1)
                {
                    info.Prefix = "pii";
                    info.Text   = text;
                    return(info);
                }
                List <string> parts = StringUtil.ParseTwoPart(text, ":");

                info.Prefix = parts[0];
                info.Text   = parts[1];
                return(info);
            }
コード例 #7
0
        private async void createImage(string path, IdInfo idInfob)
        {
            using (UserDialogs.Instance.Loading(Translator.getText("Loading"), null, null, true, MaskType.Black))
            {
                byte[] imagetosave = ImageManager.ConvertToBytes(path);

                if (CalledFrom == Constants.ForIdPics)
                {
                    if (ViewModels.IdInfos.Count < 3)
                    {
                        ViewModels.id_document_type = 1;
                        ViewModels.addIdInfo(idInfob);

                        MessagingCenter.Send <StepThreePage, byte[]>(this, "Photos", imagetosave);
                    }
                    else
                    {
                        await DisplayAlert("Error", Translator.getText("Only3"), "OK");
                    }
                }
                else
                {
                    if (CalledFrom == Constants.ForUserPic)
                    {
                        ViewModels.id_document_type = 2;
                        idInfob.name = Translator.getText("UserPhoto");
                        MessagingCenter.Send <StepThreePage, byte[]>(this, "UserPhoto", imagetosave);
                    }
                    if (CalledFrom == Constants.ForProductPic)
                    {
                        ViewModels.id_document_type = 3;
                        idInfob.name = Translator.getText("ProductPhoto");
                        MessagingCenter.Send <StepThreePage, byte[]>(this, "ProductPhoto", imagetosave);
                    }


                    if (ViewModels.IdInfos.Count == 0)
                    {
                        ViewModels.addIdInfo(idInfob);
                    }
                    else
                    {
                        await DisplayAlert("Error", Translator.getText("OnlyOnePick"), "OK");
                    }
                }
            }
        }
コード例 #8
0
        public void Person_Case_1()
        {
            int    age       = 30;
            var    birthDate = new DateTime(1990, 05, 31);
            var    name      = "Jack";
            var    lastName  = "Parra";
            var    idNumber  = 1016123654;
            IdInfo idInfo    = new IdInfo(idNumber);

            var jack = new Domain.Person(age, birthDate, name, lastName, idInfo);

            Assert.Equal(age, jack.Age);
            Assert.Equal(birthDate, jack.BirthDate);
            Assert.Equal(name, jack.Name);
            Assert.Equal(lastName, jack.LastName);
            Assert.Equal(idNumber, jack.IdInfo.IdNumber);
        }
コード例 #9
0
ファイル: OdbCache.cs プロジェクト: Myvar/Eclang
        public void MarkIdAsDeleted(OID oid)
        {
            if (oid == null)
            {
                throw new OdbRuntimeException(NDatabaseError.CacheNullOid);
            }

            IdInfo idInfo;

            _objectPositionsByIds.TryGetValue(oid, out idInfo);
            if (idInfo != null)
            {
                idInfo.Status = IDStatus.Deleted;
            }
            else
            {
                idInfo = new IdInfo(-1, IDStatus.Deleted);
                _objectPositionsByIds[oid] = idInfo;
            }
        }
コード例 #10
0
        async Task TakePicturemethod()
        {
            Setup();

            _imageSource = null;
            byte[] imageAsByte;
            try
            {
                using (UserDialogs.Instance.Loading(Translator.getText("AdjustingImage"), null, null, true, MaskType.Black))
                {
                    var mediaFile = await this._mediaPicker.TakePhotoAsync(new StoreCameraMediaOptions
                    {
                        DefaultCamera = CameraDevice.Front
                    });


                    _imageSource = ImageSource.FromStream(mediaFile.GetStream);

                    var memoryStream = new MemoryStream();
                    await mediaFile.GetStream().CopyToAsync(memoryStream);

                    imageAsByte = memoryStream.ToArray();

                    idInfo = new IdInfo
                    {
                        comments  = coments,
                        Image     = _imageSource,
                        ImageByte = ImageManager.ConvertToBytes(mediaFile.Path),
                    };

                    path = mediaFile.Path;
                }
                await Navigation.PushModalAsync(new CropView(imageAsByte, Refresh));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
コード例 #11
0
        public IdInfo ExtractIdInformation(string[] idNumbers, IIdentityNumberValidator identityNumberValidator)
        {
            var idInfo = new IdInfo();

            foreach (var idnum in idNumbers)
            {
                // validate the identity number
                var result = identityNumberValidator.Validate(idnum);
                if (result.Isvalid)
                {
                    ValidIDInfo validIdInfo = ExtractValidIdInformation(idnum);
                    idInfo.validIdInfos.Add(validIdInfo);
                }
                else
                {
                    var invalidIdInfo = new InvalidIDInfo(idnum, result.ErrorMessage);
                    idInfo.InvalidIdInfos.Add(invalidIdInfo);
                }
            }

            return(idInfo);
        }
コード例 #12
0
        private async Task RetrieveIdInfoAsync(string id)
        {
            // Note: Expired AccessTokens are not handled here because the Id request is made as part of the authentication response handler.
            HttpClient         httpClient = new HttpClient();
            HttpRequestMessage request    = new HttpRequestMessage(HttpMethod.Get, id);

            request.Headers.Authorization = new AuthenticationHeaderValue(Constants.Header_OAuth, this.Authentication.AccessToken);
            HttpResponseMessage response = await httpClient.SendAsync(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                string content = await response.Content.ReadAsStringAsync();

                IdInfo idInfo = JsonConvert.DeserializeObject <IdInfo>(content);
                this.Authentication.UserName           = idInfo.UserName;
                this.Authentication.MetadataServiceUrl = idInfo.Urls.Metadata;
            }
            else
            {
                throw new InvalidOperationException(
                          Resources.AuthenticationHelper_UnableToConnectToSalesforce.FormatCurrentCulture(request, response));
            }
        }
コード例 #13
0
        public async Task <IActionResult> GetIds()
        {
            try
            {
                var validIdInfo = await _dataRepository.Read <ValidIDInfo>();

                var invalidInfo = await _dataRepository.Read <InvalidIDInfo>();

                var idInfo = new IdInfo();
                // select only distinct Ids
                idInfo.validIdInfos.AddRange(validIdInfo.GroupBy(x => x.IdentityNumber)
                                             .Select(x => new ValidIDInfo(x.First().IdentityNumber, x.First().BirthDate,
                                                                          x.First().Gender, x.First().Cizitenship)).Reverse());
                idInfo.InvalidIdInfos.AddRange(invalidInfo.GroupBy(x => x.IdentityNumber)
                                               .Select(x => new InvalidIDInfo(x.First().IdentityNumber,
                                                                              x.First().ReasonsFailed)).Reverse());
                return(Ok(idInfo));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message, e);
                return(StatusCode(500, e.Message));
            }
        }
コード例 #14
0
        public StepThreePage(string calledfrom)
        {
            InitializeComponent();
            CalledFrom                 = calledfrom;
            BindingContext             = ViewModels = new StepThreeViewModel(CalledFrom);
            ViewModels.NoRegisterCall += () => ShowResult();

            ViewModels.VerifyProfile += async() => await GoToLoginAsync();

            switch (CalledFrom)
            {
            case "ForUserPic":
                coments       = Translator.getText("UserPhoto");
                CamTitle.Text = Translator.getText("UserPhoto");
                break;

            case "ForIdPics":
                coments       = Translator.getText("IdPhoto");
                CamTitle.Text = Translator.getText("TextIdents");
                break;

            case "ForProductPic":
                coments       = Translator.getText("ProductPhoto");
                CamTitle.Text = Translator.getText("ProductPhoto");
                break;

            case "ForIdTrav":
                coments       = Translator.getText("IdPhoto");
                CamTitle.Text = Translator.getText("IdPhoto");
                break;
            }

            TakePicture.Clicked += async(sender, args) =>
            {
                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
                {
                    await DisplayAlert("No Camera", ":( No camera available.", "OK");

                    return;
                }

                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    Directory          = "Sample",
                    Name               = "test.jpg",
                    PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Small,
                    CompressionQuality = 90,
                    AllowCropping      = true
                });

                if (file == null)
                {
                    return;
                }

                using (UserDialogs.Instance.Loading(Translator.getText("Loading"), null, null, true, MaskType.Black))
                {
                    idInfo = new IdInfo
                    {
                        comments = coments,
                        Image    = ImageSource.FromStream(() =>
                        {
                            var stream = file.GetStream();
                            return(stream);
                        }),
                        ImageByte = ImageManager.ConvertToBytes(file.Path),
                    };
                }

                createImage(file.Path, idInfo);
            };

            SelectPicture.Clicked += async(sender, args) =>
            {
                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    await DisplayAlert("No Camera", ":( No camera available.", "OK");

                    return;
                }

                var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Medium,
                    CompressionQuality = 90,
                });

                if (file == null)
                {
                    return;
                }

                //await DisplayAlert("File Location", file.Path, "OK");


                using (UserDialogs.Instance.Loading(Translator.getText("Loading"), null, null, true, MaskType.Black))
                {
                    idInfo = new IdInfo
                    {
                        comments = coments,
                        Image    = ImageSource.FromStream(() =>
                        {
                            var stream = file.GetStream();
                            return(stream);
                        }),
                        ImageByte = ImageManager.ConvertToBytes(file.Path),
                    };
                }

                createImage(file.Path, idInfo);
            };


            lb_BackFunc();
            void lb_BackFunc()
            {
                try
                {
                    Back.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(async() =>
                        {
                            Navigation.PopModalAsync();
                        }
                                              )
                    });
                }
                catch (Exception ex) { Debug.WriteLine(ex); }
            }
        }
コード例 #15
0
        // 自动修复 EAS
        void AutoFixEas()
        {
            string strError = "";

            IdInfo info = IdInfo.Parse(this.SelectedID);

            foreach (ListViewItem item in this.listView_tags.Items)
            {
                string uid = ListViewUtil.GetItemText(item, COLUMN_UID);

                ItemInfo item_info = (ItemInfo)item.Tag;
                var      tag_info  = item_info.OneTag.TagInfo;
                if (tag_info == null)
                {
                    continue;
                }
                LogicChip chip = LogicChip.From(tag_info.Bytes,
                                                (int)tag_info.BlockSize);
                string pii = chip.FindElement(ElementOID.PII)?.Text;
                if ((info.Prefix == "pii" && pii == info.Text) ||
                    (info.Prefix == "uid" && uid == info.Text))
                {
                    // 获得册记录的外借状态。
                    // return:
                    //      -1  出错
                    //      0   没有被外借
                    //      1   在外借状态
                    int nRet = GetCirculationState(item_info.Xml,
                                                   out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }

                    // 便于观察
                    // Application.DoEvents();
                    // Thread.Sleep(2000);

                    // 检测 EAS 是否正确
                    NormalResult result = null;
                    // TODO: 这里发现不一致的时候,是否要出现明确提示,让操作者知晓?
                    if (nRet == 1 && tag_info.EAS == true)
                    {
                        result = SetEAS(_rfidChannel, "*", "uid:" + tag_info.UID, false, out strError);
                    }
                    else if (nRet == 0 && tag_info.EAS == false)
                    {
                        result = SetEAS(_rfidChannel, "*", "uid:" + tag_info.UID, true, out strError);
                    }
                    else
                    {
                        continue;
                    }

                    if (result.Value == -1)
                    {
                        strError = $"{result.ErrorInfo}, error_code={result.ErrorCode}";
                        goto ERROR1;
                    }

                    this.EasFixed = true;
                }
            }

            if (this._mode == "auto_fix_eas" && this.EasFixed)
            {
                this.Close();
            }
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
コード例 #16
0
 public void addIdInfo(IdInfo idInfo)
 {
     idinfos.Add(idInfo);
 }
コード例 #17
0
ファイル: Client.cs プロジェクト: zackszhu/UnityExercises
    public JsonData poll_info()
    {
        var info = new IdInfo();
        info.id = clientID;

        var content = JsonMapper.ToJson(info);
        Debug.Log(content);
        string response = post(_server_url + poll_url, content);

        JsonData res = JsonMapper.ToObject(response);
        Debug.Log(res["alive"]);
        return res;
    }
コード例 #18
0
ファイル: RfidToolForm.cs プロジェクト: keji56/dp2
        bool SelectItem(string id)
        {
            if (id == null)
            {
                return(false);
            }

            IdInfo info = IdInfo.Parse(id);
            List <ListViewItem> level1_items = new List <ListViewItem>();
            List <ListViewItem> level2_items = new List <ListViewItem>();

            // List<ItemAndWeight> results = new List<ItemAndWeight>();
            foreach (ListViewItem item in this.listView_tags.Items)
            {
                if (info.Prefix == "pii")
                {
                    // string current_pii = ListViewUtil.GetItemText(item, COLUMN_PII);
                    string current_pii = GetItemPII(item);
                    if (current_pii == info.Text)
                    {
                        level1_items.Add(item);
                        //ListViewUtil.SelectLine(item, true);
                        //return true;
                    }
                    else if (StringUtil.IsInList("auto_or_blankPII", this.AutoSelectCondition) && string.IsNullOrEmpty(current_pii) == true)
                    {
                        level2_items.Add(item);
                    }
                }

                if (info.Prefix == "uid")
                {
                    string current_uid = ListViewUtil.GetItemText(item, COLUMN_UID);
                    if (current_uid == info.Text)
                    {
                        level1_items.Add(item);
                        // ListViewUtil.SelectLine(item, true);
                        // return true;
                    }
                }
            }

            if (level1_items.Count > 0)
            {
                ListViewUtil.SelectLine(level1_items[0], true);
                return(true);
            }

            // 只有当 level2 命中精确为一个时才选中。命中多了则无法选择
            if (level2_items.Count == 1)
            {
                ListViewUtil.SelectLine(level2_items[0], true);
                return(true);
            }

            // 触发提示
            if (this.AskTag != null)
            {
                AskTagEventArgs e = new AskTagEventArgs();
                this.AskTag(this, e);
                this.ShowMessage(e.Text, "green", true);
            }

            return(false);
        }
コード例 #19
0
ファイル: BackendlessPlugin.cs プロジェクト: aharit/.NET-SDK
    void Awake()
    {
        // This is needed so that the Unity client cannot connect to Backendless RT
        // Also, it is needed on Android, so it can communicate via HTTPS
        ServicePointManager.ServerCertificateValidationCallback = (p1, p2, p3, p4) => true;

        DontDestroyOnLoad(this);
        if (_instance == null)
        {
            _instance = this;
        }
        else
        {
            DestroyImmediate(this.gameObject); // avoid duplicate BackendlessPlugin GameObjects
            return;
        }

        Backendless.URL = "https://api.backendless.com";

        // This redirects any logging inside of the Backendless SDK into Unity's Debug.log
        Weborb.Util.Logging.Log.addLogger("unitylogger", new BackendlessPlugin.UnityLogger());

        // Initialize Backendless
        Backendless.InitApp(applicationId, APIKey);

        // Default network timeout (this must be set after Backendless.InitApp)
        Backendless.Timeout = 30000; // 30 secs

        // Backendless.Data.MapTableToType("Devices", typeof(/* type of a class that models one of your tables on Backendless and inherits Backendless Entity */));

#if ENABLE_PUSH_PLUGIN
        Backendless.Messaging.SetUnityRegisterDevice(UnityRegisterDevice, UnityUnregisterDevice);
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        activity = jc.GetStatic <AndroidJavaObject>("currentActivity");
        activity.Call("setUnityGameObject", this.gameObject.name);
#elif (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR
        setListenerGameObject(this.gameObject.name);
#endif
#endif

#if UNITY_IOS || UNITY_TVOS || UNITY_ANDROID
        /* In order to use the .NET SDK we needed some hardcoded logic here to make sure some of its code was properly compiled for AOT on iOS.
         * We'd get errors like the following when trying to delete the a record from a table.
         *
         * Error: Code = , Message = Attempting to call method 'Weborb.Client.HttpEngine::SendRequest<System.Int64>' for which no ahead of time (AOT) code was generated., Detail =
         * UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
         * UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
         * UnityEngine.Logger:Log(LogType, Object)
         * UnityEngine.Debug:LogError(Object)
         * <FinalizeSellItem>c__AnonStoreyA5:<>m__C1(BackendlessFault)
         * BackendlessAPI.Async.ErrorHandler:Invoke(BackendlessFault)
         * BackendlessAPI.Engine.Invoker:InvokeAsync(String, String, Object[], Boolean, AsyncCallback`1)
         * BackendlessAPI.Engine.Invoker:InvokeAsync(String, String, Object[], AsyncCallback`1)
         * BackendlessAPI.Service.PersistenceService:Remove(T, AsyncCallback`1)
         * BackendlessAPI.Data.DataStoreImpl`1:Remove(T, AsyncCallback`1)
         * <FinalizeSellItem>c__AnonStoreyA5:<>m__BF()
         * System.Action:Invoke()
         * Loom:Update()
         */

        try {
            IdInfo     idInfo     = new IdInfo();
            HttpEngine httpEngine = new Weborb.Client.HttpEngine("http://api.backendless.com", idInfo);
            httpEngine.SendRequest <Boolean>(null, null, null, null, null);
            httpEngine.SendRequest <Int64>(null, null, null, null, null);
        } catch (Exception e) {
            // ignore
        }
#endif
    }
コード例 #20
0
ファイル: Context.cs プロジェクト: rgatkinson/nadir
 IdInfo InfoOf(IEnumerable<int> ids)
 // Lookup by both the given ids and the ids that the complement of this list of ids would have.
 // In that way both will resolve to the same IdInfo
     {
     List<int> key = new List<int>(ids);
     IdInfo result;
     if (!this.mpIdListToIdInfo.TryGetValue(key, out result))
         {
         if (!this.mpIdListToIdInfo.TryGetValue(ComplementOf(key), out result))
             {
             result = new IdInfo(key);
             this.mpIdListToIdInfo.Add(key, result);
             }
         }
     return result;
     }