Exemple #1
0
        private RbMessage DeleteFace(RbHeader rbh, JObject appInfo, JObject jo_input)
        {
            var storageAccount   = (appInfo["StorageAccount"] ?? "").ToString();
            var storageKey       = (appInfo["StorageKey"] ?? "").ToString();
            var storageContainer = (appInfo["StorageContainer"] ?? "").ToString();
            var faceApiKey       = (appInfo["FaceApiKey"] ?? "").ToString();

            AppBody appbody = new AppBody();

            appbody.PersonId      = (jo_input["PersonId"] ?? "").ToString();
            appbody.PersonGroupId = (jo_input["PersonGroupId"] ?? "").ToString();

            var facePerson         = new HwsMicrosoftFaceApi.Person.Client(faceApiKey);
            var personDeleteResult = facePerson.Delete(appbody.PersonGroupId, appbody.PersonId);

            if (personDeleteResult.apiResult.IsSuccessStatusCode)
            {
                var personGroup = new HwsMicrosoftFaceApi.PersonGroup.Client(faceApiKey);
                personGroup.Train(appbody.PersonGroupId);

                PersonInfoModel.Find(appbody.PersonId).Delete();
            }
            else
            {
                appbody.Code = ERROR_CODE;
            }

            return(GetRbMessage(rbh, appbody));
        }
Exemple #2
0
        private AppBody ResisterFace(JObject _appInfo, AppBody _appbody, byte[] _faceImageBuffer, JToken _faceRectangle)
        {
            var storageAccount   = (_appInfo["StorageAccount"] ?? "").ToString();
            var storageKey       = (_appInfo["StorageKey"] ?? "").ToString();
            var storageContainer = (_appInfo["StorageContainer"] ?? "").ToString();
            var faceApiKey       = (_appInfo["FaceApiKey"] ?? "").ToString();

            var facePerson      = new HwsMicrosoftFaceApi.Person.Client(faceApiKey);
            var personAddResult = facePerson.Add(_faceImageBuffer, _appbody.PersonGroupId, _appbody.PersonId);

            if (personAddResult.apiResult.IsSuccessStatusCode)
            {
                _appbody.PersonInfos[0].PersonId       = _appbody.PersonId;
                _appbody.PersonInfos[0].PersonName     = _appbody.PersonName;
                _appbody.PersonInfos[0].PersonNameYomi = _appbody.PersonNameYomi;
                CreateOrUpdatePersonInfo(_appbody);

                var addFaceResult   = JsonConvert.DeserializeObject <JObject>(personAddResult.apiResult.Result);
                var persistedFaceId = (addFaceResult["persistedFaceId"] ?? "").ToString();
                var faceFileName    = _appbody.PersonId + "_" + persistedFaceId;

                var personGroup = new HwsMicrosoftFaceApi.PersonGroup.Client(faceApiKey);
                personGroup.Train(_appbody.PersonGroupId);
            }

            return(_appbody);
        }