internal async Task RemovePerson(Person person)
 {
     if (null != person)
     {
         await faceServiceClient.DeletePersonAsync(personGroupId, person.PersonId);
     }
 }
示例#2
0
        private async void btndelete_Click(object sender, RoutedEventArgs e)
        {
            Guid personid;

            Person[] persons = await fClient.ListPersonsAsync("smartapp");

            foreach (Person person in persons)
            {
                if (person.Name == lvpersons.SelectedItem.ToString())
                {
                    personid = person.PersonId;
                }
            }
            if (personid != null)
            {
                await fClient.DeletePersonAsync("smartapp", personid);
            }
            persons = await fClient.ListPersonsAsync("smartapp");

            lvpersons.Items.Clear();
            foreach (Person person in persons)
            {
                lvpersons.Items.Add(person.Name);
            }
        }
示例#3
0
        public async Task <bool> DeletePersonAsync(Guid personId)
        {
            try
            {
                await _client.DeletePersonAsync(_groupId, personId);

                await _client.TrainPersonGroupAsync(_groupId);

                var trained = false;

                while (!trained)
                {
                    await Task.Delay(1000);

                    var status = await _client.GetPersonGroupTrainingStatusAsync(_groupId);

                    switch (status.Status)
                    {
                    case Status.Succeeded:
                        trained = true;
                        break;

                    case Status.Failed:
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
        public async Task Delete(string MemberId) // Delete a member
        {
            FaceServiceClient faceClient    = new FaceServiceClient(Configuration.Get("AppSettings:OxfordSubscriptionKeyPrimary"));
            string            memberGroupId = Configuration.Get("AppSettings:OxfordSubscriptionKeyPrimary");
            await faceClient.DeletePersonAsync(memberGroupId, new Guid(MemberId));

            return;
        }
示例#5
0
        public async Task DeletePerson(Guid ID)
        {
            PowerAppsCMSEntities db = new PowerAppsCMSEntities();
            var getPerson           = db.Users.Find(ID);

            Guid guidPersonID = new Guid(getPerson.PersonID.Replace(" ", string.Empty));

            await faceServiceClient.DeletePersonAsync(PERSON_GROUP_ID, guidPersonID);
        }
示例#6
0
        /// <summary>
        /// 刪除人員的動作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnDeletePerson_Click(object sender, EventArgs e)
        {
            string strPersonGroupId = ((Models.CognitiveModels.ListItem)lbxPersonGroup.SelectedItem).Value;
            string strPersonId      = ((Models.CognitiveModels.ListItem)lbxPerson.SelectedItem).Value;
            await face.DeletePersonAsync(strPersonGroupId, Guid.Parse(strPersonId));

            this.BindPersons();
            btnDeletePerson.Enabled   = false;
            btnPersonEditFace.Enabled = false;
        }
 public void DeletePerson(Person person)
 {
     try
     {
         Task.Run(() => Api.DeletePersonAsync(person?.GroupName.ToLowerInvariant(), person?.Id ?? System.Guid.Empty)).GetAwaiter().GetResult();
     }
     catch (FaceAPIException ex)
     {
         throw new FaceApiException(ex.ErrorMessage);
     }
 }
示例#8
0
        public async Task MemberDelete(string MemberId)
        {
            try
            {
                await faceclient.DeletePersonAsync(ConfigurationManager.AppSettings["MemberGroupId"], new Guid(MemberId));
            }
            catch (Exception ex)
            { }
            MemberInfo memberresult = db.MemberInfos.Find(new Guid(MemberId));

            db.MemberInfos.Remove(memberresult);
            db.SaveChanges();
            return;
        }
示例#9
0
        public async Task <bool> DeletePerson(Guid personId)
        {
            try
            {
                await _faceClient.DeletePersonAsync(_miriotPersonGroupId, personId);

                await _faceClient.TrainPersonGroupAsync(_miriotPersonGroupId);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#10
0
        public async Task <IActionResult> deleteIdentity([FromBody] CustReq req)
        {
            Claim oid      = User.Claims.FirstOrDefault(x => x.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier");
            var   personId = await _userFunctions.getPersonIdAsync(oid.Value);

            if (personId == null)
            {
                return(Json(new { message = "No identity linked to your account..." }));
            }

            await _faceClient.DeletePersonAsync(_configuration["personGroupId"], Guid.Parse(personId));

            await _userFunctions.setPersonIdAsync(oid.Value, null);

            return(Json(new { message = "Identity deleted..." }));
        }
        private async void DeletePerson(object obj)
        {
            try
            {
                await _faceServiceClient.DeletePersonAsync(SelectedPersonGroup.PersonGroupId, SelectedPerson.PersonId);

                StatusText = $"Deleted {SelectedPerson.Name} from {SelectedPersonGroup.Name}";

                GetPersons();
            }
            catch (FaceAPIException ex)
            {
                StatusText = $"Could not delete {SelectedPerson.Name}: {ex.ErrorMessage}";
            }
            catch (Exception ex)
            {
                StatusText = $"Could not delete {SelectedPerson.Name}: {ex.Message}";
            }
        }
示例#12
0
        private void MemberService_Deleting(IMemberService sender, DeleteEventArgs <IMember> deleteEventArgs)
        {
            var faceServiceClient = new FaceServiceClient(_faceApiKey, _faceApiUrl);

            foreach (IMember member in deleteEventArgs.DeletedEntities)
            {
                if (!string.IsNullOrWhiteSpace(member.GetValue <string>("personId")))
                {
                    try
                    {
                        var personId = Guid.Parse(member.GetValue <string>("personId"));
                        AsyncHelpers.RunSync(() => faceServiceClient.DeletePersonAsync(_faceApiGroup, personId));
                    }
                    catch
                    {
                        // ignored
                    }
                }
            }
        }
        private async void DeleteButtonClick()
        {
            Person[] persons = await faceServiceClient.GetPersonsAsync(GroupName);

            Person person;
            Guid   personId;

            try
            {
                person   = persons.Where(item => item.Name == personName).First();
                personId = person.PersonId;
                await faceServiceClient.DeletePersonAsync(GroupName, personId);

                TestText += "\nPerson deleted successfuly";
            }
            catch
            {
                TestText += "\nPerson doesnt exist in the list";
            }
        }
示例#14
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string roll = Roll.Text;
            Guid   value;

            Person[] y;
            //Person d = null;
            int p = -1;

            y = await faceServiceClient.ListPersonsAsync("student");

            for (int i = 0; i < y.Length; i++)
            {
                if (y[i].Name == roll)
                {
                    p     = 0;
                    value = y[i].PersonId;
                    // d = y[i];
                    break;
                }
            }
            if (p == -1)
            {
                Roll.Text = "Cannot delete as given roll number does not exist";
            }
            else
            {
                /*if (d == null)
                 *  return;
                 *
                 * for(int i =0; i < d.PersistedFaceIds.Length; i++)
                 * {
                 *  await faceServiceClient.DeleteFaceFromFaceListAsync(d.Name, d.PersistedFaceIds[i]);
                 * }*/

                await faceServiceClient.DeletePersonAsync("student", value);

                Roll.Text = "Deleted Successfully";
            }
        }
示例#15
0
        private async static void DeletePersons()
        {
            Console.WriteLine("Enter the Person Group Id");
            string personGroupId = Console.ReadLine();
            var    persons       = await _faceServiceClient.GetPersonsAsync(personGroupId);

            if (!persons.Any())
            {
                Console.WriteLine("No Persons Registered");
                return;
            }

            Console.WriteLine($"Deleting {persons.Count()} person(s)");
            Console.WriteLine();
            foreach (var person in persons)
            {
                Console.WriteLine($"Deleting {person.Name} with PersonId: {person.PersonId}...");
                Console.WriteLine("===================================");
                await _faceServiceClient.DeletePersonAsync(personGroupId, person.PersonId);
            }
            Console.WriteLine();
            Console.WriteLine("Finished Deleting all persons");
        }
示例#16
0
 public async Task DeletePersonAsync(string personGroupId, Guid personId)
 {
     await RunTaskWithAutoRetryOnQuotaLimitExceededError(() => faceClient.DeletePersonAsync(personGroupId, personId));
 }
示例#17
0
        private void MemberService_Saving(IMemberService sender, SaveEventArgs <IMember> e)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);

            var faceServiceClient = new FaceServiceClient(_faceApiKey, _faceApiUrl);

            foreach (IMember member in e.SavedEntities)
            {
                var profileImage = member.GetValue <string>("profilePicture");

                if (!string.IsNullOrWhiteSpace(profileImage))
                {
                    var profileImageUdi   = Udi.Parse(profileImage);
                    var profileImageMedia = umbracoHelper.TypedMedia(profileImageUdi);

                    string fullPath = _fs.GetFullPath(profileImageMedia.Url);

                    /* Stap 2  -> Face API: Delete the person if exists */
                    if (!string.IsNullOrWhiteSpace(member.GetValue <string>("personId")))
                    {
                        try
                        {
                            var personId = Guid.Parse(member.GetValue <string>("personId"));
                            AsyncHelpers.RunSync(() => faceServiceClient.DeletePersonAsync(_faceApiGroup, personId));
                        }
                        catch
                        {
                            // ignored
                        }
                    }

                    /* Stap 3 -> Face API: Detect face and attributes */
                    using (Stream imageFileStream = _fs.OpenFile(fullPath))
                    {
                        Face[] detectface = AsyncHelpers.RunSync(
                            () => faceServiceClient.DetectAsync(imageFileStream,
                                                                false, false, new[]
                        {
                            FaceAttributeType.Age,
                            FaceAttributeType.Gender,
                            FaceAttributeType.Glasses,
                            FaceAttributeType.Makeup,
                            FaceAttributeType.Hair,
                        }));

                        // Getting values and setting the properties on the member
                        string age       = detectface.First().FaceAttributes.Age.ToString();
                        string gender    = detectface.First().FaceAttributes.Gender;
                        string glasses   = detectface.First().FaceAttributes.Glasses.ToString();
                        bool   eyeMakeup = detectface.First().FaceAttributes.Makeup.EyeMakeup;
                        bool   lipMakeup = detectface.First().FaceAttributes.Makeup.LipMakeup;

                        member.SetValue("Age", age);
                        member.SetValue("Gender", gender);
                        member.SetValue("glasses", glasses);
                        member.SetValue("eyeMakeup", eyeMakeup);
                        member.SetValue("lipMakeup", lipMakeup);
                    }

                    // ==> Stap 4 -> Create a person in the persongroup
                    CreatePersonResult person = AsyncHelpers.RunSync(() => faceServiceClient.CreatePersonAsync(_faceApiGroup, member.Name));

                    member.SetValue("personId", person.PersonId.ToString());

                    // ==> Stap 5 -> Add face to person and make persistent
                    using (Stream imageFileStream = _fs.OpenFile(fullPath))
                    {
                        AddPersistedFaceResult result = AsyncHelpers.RunSync(() => faceServiceClient.AddPersonFaceAsync(_faceApiGroup, person.PersonId, imageFileStream));
                        member.SetValue("faceId", result.PersistedFaceId.ToString());
                    }
                }
            }

            // ==> Stap 6 -> Train the facegroup
            AsyncHelpers.RunSync(() => faceServiceClient.TrainPersonGroupAsync(_faceApiGroup));
        }
示例#18
0
 public async Task DeletePerson(string personGroupId, string personId)
 {
     await faceServiceClient.DeletePersonAsync(personGroupId, personId.ToGuid());
 }
示例#19
0
        private async void GroupTest()
        {
            var photodir = await KnownFolders.PicturesLibrary.GetFileAsync(PHOTO_FILE_NAME);

            string photo = photodir.Path;

            string picdir = photo.Substring(0, photo.Length - 9);



            try
            {
                await faceServiceClient.CreatePersonGroupAsync(personGroupId, "FaceGroup");


                //tbl_status.Text = "Group created";
            }
            catch
            {
                //tbl_status.Text = "Group exists";
            }

            try
            {
                var persons = await faceServiceClient.ListPersonsAsync(personGroupId);

                foreach (var person in persons)
                {
                    if (person.PersistedFaceIds.Count() == 0)
                    {
                        personlist.Add(person.PersonId.ToString());
                    }
                }
                var lists = personlist;
                for (int i = 0; i < personlist.Count; i++)
                {
                    await faceServiceClient.DeletePersonAsync(personGroupId, Guid.Parse(personlist[i]));
                }
                await faceServiceClient.TrainPersonGroupAsync(personGroupId);

                TrainingStatus trainingStatus = null;
                while (true)
                {
                    trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId);

                    if (trainingStatus.Status.ToString() != "running")
                    {
                        break;
                    }

                    await Task.Delay(1000);
                }


                string testImageFile = photo;



                using (Stream s = File.OpenRead(await GetPhoto()))
                {
                    var faces = await faceServiceClient.DetectAsync(s, returnFaceLandmarks : true,
                                                                    returnFaceAttributes : requiredFaceAttributes);

                    foreach (var faceinfo in faces)
                    {
                        var id          = faceinfo.FaceId;
                        var attributes  = faceinfo.FaceAttributes;
                        var age         = attributes.Age;
                        var gender      = attributes.Gender;
                        var smile       = attributes.Smile;
                        var facialHair  = attributes.FacialHair;
                        var headPose    = attributes.HeadPose;
                        var glasses     = attributes.Glasses;
                        var emotion     = attributes.Emotion;
                        var emotionlist = emotion;
                        int i           = 0;
                        int max         = 0;

                        /*foreach (var kvp in emotionlist.ToRankedList())
                         * {
                         *  if(kvp.Value > max)
                         *  {
                         *      maxemotion = i;
                         *  }
                         *  object[] item = new object[2];
                         *  item[0] = kvp.Key;
                         *  item[1] = kvp.Value;
                         *  i++;
                         * }
                         * Infostring = "Mood: " + list[maxemotion][0].ToString();*/
                        // emo = emotionlist.Max().Value;
                        // emotionstring = emotion.Happiness.ToString();
                        if (glasses.ToString().ToUpper() != "NOGLASSES")
                        {
                            activeId += " Gleraugnaglámur";
                        }
                        Infostring = "ID: " + id.ToString() + "," + "Age: " + age.ToString() + "," + "Gender: " + gender.ToString() + "," + "Glasses: " + glasses.ToString();
                    }

                    //emo.ToString();

                    var faceIds = faces.Select(face => face.FaceId).ToArray();
                    var results = await faceServiceClient.IdentifyAsync(personGroupId, faceIds);


                    foreach (var identifyResult in results)
                    {
                        //  tbl_status.Text = ("Result of face: " + identifyResult.FaceId);
                        if (identifyResult.Candidates.Length == 0)
                        {
                            //tbl_status.Text = ("No one identified, i will add you now, your new name is Bill");
                            CreatePersonResult friend1 = await faceServiceClient.CreatePersonAsync(
                                // Id of the person group that the person belonged to
                                personGroupId,
                                // Name of the person
                                "Hlini"
                                );

                            for (int z = 0; z < 6; z++)
                            {
                                Random r = new Random();
                                photostorage = await KnownFolders.PicturesLibrary.CreateFileAsync((z + PHOTO_FILE_NAME), CreationCollisionOption.ReplaceExisting);

                                ImageEncodingProperties imageProperties = ImageEncodingProperties.CreateJpeg();
                                await mediaCapture.CapturePhotoToStorageFileAsync(imageProperties, photostorage);

                                var friend1ImageDir = await KnownFolders.PicturesLibrary.GetFileAsync(z + PHOTO_FILE_NAME);

                                string imagePath = friend1ImageDir.Path;

                                using (Stream k = File.OpenRead(imagePath))
                                {
                                    await faceServiceClient.AddPersonFaceAsync(
                                        personGroupId, friend1.PersonId, k);
                                }
                            }


                            await faceServiceClient.TrainPersonGroupAsync(personGroupId);

                            trainingStatus = null;
                            while (true)
                            {
                                trainingStatus = await faceServiceClient.GetPersonGroupTrainingStatusAsync(personGroupId);

                                if (trainingStatus.Status.ToString() != "running")
                                {
                                    break;
                                }

                                await Task.Delay(1000);
                            }
                            Task t = Task.Run(() => { CheckFace(); });
                        }
                        else
                        {
                            // Get top 1 among all candidates returned
                            var candidateId = identifyResult.Candidates[0].PersonId;
                            var person      = await faceServiceClient.GetPersonAsync(personGroupId, candidateId);

                            //tbl_status.Text = ("Identified as " + person.Name);
                            //activeId = person.Name.ToString();
                            //await faceServiceClient.UpdatePersonAsync(personGroupId, person.PersonId, "Ólafur Jón");
                            activeId = person.Name.ToString();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                activeId = "Main: " + activeId + " " + Infostring;
            }
        }
示例#20
0
 /// <summary>
 /// Removes a person by personId
 /// </summary>
 /// <param name="personId"></param>
 /// <param name="faceId"></param>
 /// <returns></returns>
 public async Task RemovePersonAsync(Guid personId, Guid faceId)
 {
     await _faceApiClient.DeletePersonAsync(MAGIC_MIRROR_GROUP, personId);
 }
示例#21
0
 public async Task DeletePerson(string personGroupId, string personId)
 {
     var id = new Guid(personId);
     await _faceServiceClient.DeletePersonAsync(personGroupId, id);
 }
示例#22
0
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>

        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                Activity        reply     = activity.CreateReply();
                //Trace.TraceInformation(JsonConvert.SerializeObject(reply, Formatting.Indented));

                if (activity.Attachments?.Count > 0 && activity.Attachments.First().ContentType.StartsWith("image"))
                {
                    //user傳送一張照片
                    ImageTemplate(reply, activity.Attachments.First().ContentUrl);
                }
                else if (activity.Text == "help_user")
                {
                    reply.Text =
                        "1.新增使用者\n\n請輸入「新增名稱+『欲使用名稱』」\n\n" +
                        "例如:新增名稱王大明\n\n" +
                        "2.為使用者新增照片\n\n請輸入" +
                        "「上傳照片+『使用者名稱』」\n\n" +
                        "例如:上傳照片王大明\n\n" +
                        "若出現請上傳照片,即可傳圖片上傳\n\n" +
                        "3.刪除使用者\n\n請輸入「刪除使用者+『使用者名稱』」\n\n" +
                        "例如:刪除使用者王大明\n\n" +
                        "注意:刪除功能為不可逆功能。";
                }
                else if (activity.Text == "help_res")
                {
                    reply.Text =
                        "1.如需預約,請輸入\n\n「名稱+@+開始時間+@+結束時間」\n\n" +
                        "例如:名稱@王大明@2017/12/25-9:00@2017/12/25-10:00\n\n" +
                        "注意:時間格式請以yy/mm/dd-HH:MM輸入\n\n預約時間亦不可超過五小時\n\n" +
                        "如需超過五小時請分段預約\n\n" +
                        "2.如需取消預約,請輸入\n\n" +
                        "「刪除預約+名稱」\n\n" +
                        "例如:刪除預約王大明\n\n";
                }
                else if (activity.Text == "help_search")
                {
                    reply.Text =
                        "如需查詢使用紀錄\n\n" +
                        "可使用此漢堡選單之快速查詢功能\n\n" +
                        "如需查詢特定使用者使用紀錄\n\n請輸入" +
                        "「查詢+本日/本周/本月+指定使用者+『欲查詢名稱』」\n\n" +
                        "例如:查詢本日指定使用者王大明\n\n";
                }
                else if (activity.Text == "subscription")
                {
                    string  ChanData = activity.ChannelData.ToString();
                    dynamic json     = JValue.Parse(ChanData);
                    SQL_Fb_id(json.sender.id, reply);
                }
                else if (activity.Text == "last")
                {
                    SQLCollectTimeOne(reply);
                }
                else if (activity.Text == "RECENT_TODAY_PAYLOAD")
                {
                    string timefinish = DateTime.UtcNow.AddHours(32).ToShortDateString();
                    string timestart  = DateTime.UtcNow.AddHours(8).ToShortDateString();
                    SQLCollectTime(timestart, timefinish, reply);
                }
                else if (activity.Text == "RECENT_WEEK_PAYLOAD")
                {
                    string timefinish = DateTime.UtcNow.AddHours(32).ToShortDateString();
                    string timestart  = DateTime.UtcNow.AddDays(-7).ToShortDateString();
                    SQLCollectTime(timestart, timefinish, reply);
                }
                else if (activity.Text.StartsWith("delete"))
                {
                    string    searchid = activity.Text.Trim("delete".ToCharArray());
                    string [] strs     = searchid.Split(new string[] { "~" }, StringSplitOptions.RemoveEmptyEntries);
                    DateTime  dateValue_start;
                    DateTime  dateValue_finish;
                    if (strs.Length == 2)
                    {
                        if (DateTime.TryParse(strs[0], out dateValue_start))
                        {
                            if (DateTime.TryParse(strs[1], out dateValue_finish))
                            {
                                SQLReserveTimeDelete(dateValue_start.ToString(), reply);
                            }
                        }
                    }
                }
                else
                {
                    //if(activity.ChannelId == "emulator")
                    if (activity.ChannelId == "facebook")
                    {
                        string      nametest     = activity.Text;
                        bool        delete_user  = nametest.StartsWith("刪除使用者");
                        bool        keyin        = nametest.StartsWith("新增名稱");
                        bool        upload       = nametest.StartsWith("上傳照片");
                        bool        Test         = nametest.StartsWith("測試");
                        bool        res_time     = nametest.StartsWith("預約");
                        bool        res_delete   = nametest.StartsWith("刪除預約");
                        bool        recent_day   = nametest.StartsWith("查詢本日指定使用者");
                        bool        recent_week  = nametest.StartsWith("查詢本周指定使用者");
                        bool        recent_month = nametest.StartsWith("查詢本月指定使用者");
                        StateClient stateClient  = activity.GetStateClient();
                        var         fbData       = JsonConvert.DeserializeObject <FBChannelModel>(activity.ChannelData.ToString());
                        if (fbData.postback != null)
                        {
                            var url = fbData.postback.payload.Split('>')[1];

                            if (fbData.postback.payload.StartsWith("Face>"))
                            {
                                try
                                {
                                    FaceServiceClient client          = new FaceServiceClient("6ef41877566d45d68b93b527f187fbfa", "https://westcentralus.api.cognitive.microsoft.com/face/v1.0");
                                    Guid result_Person                = Global.P_id;
                                    AddPersistedFaceResult result_add = await client.AddPersonFaceAsync("security", result_Person, url);

                                    await client.TrainPersonGroupAsync("security");

                                    TrainingStatus result = await client.GetPersonGroupTrainingStatusAsync("security");

                                    reply.Text = $"使用者照片已綁定";
                                }
                                catch (FaceAPIException f)
                                {
                                    reply.Text = "照片無法辨識,請重新上傳臉部清晰照片";
                                }
                                //faceAPI
                            }
                            else if (fbData.postback.payload.StartsWith("TypeIn"))
                            {
                            }
                            else
                            {
                                reply.Text = $"無法辨識的指令,可使用下側選單選取幫助查詢指令";
                            }
                        }
                        else if (keyin)
                        {
                            Global.userid = activity.Text.Trim("新增名稱".ToCharArray()); //移除"名稱"
                            if (!SQLUserNameCheck(Global.userid))
                            {
                                try
                                {
                                    FaceServiceClient  client        = new FaceServiceClient("6ef41877566d45d68b93b527f187fbfa", "https://westcentralus.api.cognitive.microsoft.com/face/v1.0");
                                    CreatePersonResult result_Person = await client.CreatePersonAsync("security", Global.userid);

                                    Global.P_id = result_Person.PersonId;
                                    SQLNameRegister(Global.userid, result_Person.PersonId.ToString(), reply);
                                    reply.Text = $"user create as:{Global.userid}";
                                }
                                catch (FaceAPIException f)
                                {
                                    reply.Text = "" + f.ErrorMessage + "";
                                }
                            }
                            else
                            {
                                reply.Text = "name has been registry,select another name.";
                            }
                        }
                        else if (delete_user)
                        {
                            string username = activity.Text.Trim("刪除使用者".ToCharArray());
                            Guid   PersonID = new Guid(SQLSelectId(username));
                            if (SQLSelectId(username) != "error")
                            {
                                FaceServiceClient client = new FaceServiceClient("6ef41877566d45d68b93b527f187fbfa", "https://westcentralus.api.cognitive.microsoft.com/face/v1.0");
                                try
                                {
                                    await client.DeletePersonAsync("security", PersonID);

                                    SQLDeleteRes(username);
                                    SQLPersonDelete(PersonID.ToString(), reply);
                                }
                                catch (FaceAPIException f)
                                {
                                    reply.Text = "delete failed," + f.ErrorMessage + "";
                                }
                            }
                            else
                            {
                                reply.Text = "can't find user";
                            }

                            //SQLDELETENAME select  personid where username == username
                        }
                        //else if (Test)
                        //{
                        //    string ChanData = activity.ChannelData.ToString();
                        //    dynamic json = JValue.Parse(ChanData);
                        //    reply.Text = json.sender.id;
                        //}
                        else if (res_time)
                        {
                            string   searchid = activity.Text.Trim("預約".ToCharArray());
                            string[] strs     = { };
                            DateTime dateValue_start;
                            DateTime dateValue_finish;
                            strs = searchid.Split(new string[] { "@" }, StringSplitOptions.None);
                            System.Text.StringBuilder sb = new System.Text.StringBuilder();
                            if (strs.Length == 3)
                            {
                                if (DateTime.TryParse(strs[1], out dateValue_start))
                                {
                                    if (DateTime.TryParse(strs[2], out dateValue_finish))
                                    {
                                        double s = new TimeSpan(dateValue_finish.Ticks - dateValue_start.Ticks).TotalMinutes;
                                        if ((dateValue_finish > dateValue_start) && (s <= 300))
                                        {
                                            if (SQLUserNameCheck(strs[0]))
                                            {
                                                if (!SQLReserveTimeIsConflict(dateValue_start, dateValue_finish, strs[0]))
                                                {
                                                    SQLReserveTimeInsert(dateValue_start, dateValue_finish, strs[0], reply);
                                                }
                                                else
                                                {
                                                    reply.Text = "指定時間已被預約,請重新選擇。";
                                                }
                                            }
                                            else
                                            {
                                                reply.Text = "使用者不在資料庫中,請先註冊再做預約。";
                                            }
                                        }
                                        else
                                        {
                                            reply.Text = "開始時間晚於結束時間或輸入時間大於5小時,請重新輸入。";
                                        }
                                    }
                                    else
                                    {
                                        reply.Text = ("日期格式錯誤,請參照範例格式。");
                                    }
                                }
                                else
                                {
                                    reply.Text = ("日期格式錯誤,請參照範例格式。");
                                }
                            }
                            else
                            {
                                reply.Text = "請輸入格式:名稱@起始時間@結束時間";
                            }
                        }
                        else if (res_delete)
                        {
                            string searchid = activity.Text.Trim("刪除預約".ToCharArray());
                            //reply.Text = SQLReserveTimeDelete(searchid);
                            CreateButtonOne(reply, searchid);
                        }
                        else if (recent_day)
                        {
                            string searchid   = activity.Text.Trim("查詢本日指定使用者".ToCharArray());
                            string timefinish = DateTime.UtcNow.AddHours(32).ToShortDateString();
                            string timestart  = DateTime.UtcNow.AddHours(8).ToShortDateString();
                            SQLCollectTimeName(timestart, timefinish, searchid, reply);
                            //得到最近的時間
                        }
                        else if (recent_week)
                        {
                            string searchid   = activity.Text.Trim("查詢本周指定使用者".ToCharArray());
                            string timefinish = DateTime.UtcNow.AddHours(32).ToShortDateString();
                            string timestart  = DateTime.UtcNow.AddDays(-7).ToShortDateString();
                            SQLCollectTimeName(timestart, timefinish, searchid, reply);
                            //得到最近的時間
                        }
                        else if (recent_month)
                        {
                            string searchid   = activity.Text.Trim("查詢本月指定使用者".ToCharArray());
                            string timefinish = DateTime.UtcNow.AddHours(32).ToShortDateString();
                            string timestart  = DateTime.UtcNow.AddDays(-30).ToShortDateString();
                            SQLCollectTimeName(timestart, timefinish, searchid, reply);
                            //得到最近的時間
                        }
                        else if (upload)
                        {
                            string uploadname = activity.Text.Trim("上傳照片".ToCharArray());
                            if (SQLSelectId(uploadname) != "error")
                            {
                                Guid guid = new Guid(SQLSelectId(uploadname));
                                Global.P_id = guid;
                                reply.Text  = "請上傳照片";
                            }
                            else
                            {
                                reply.Text = "無使用者資料,請先註冊";
                            }
                        }
                        else
                        {
                            reply.Text = $"nope";
                        }
                    }
                }
                await connector.Conversations.ReplyToActivityAsync(reply);
            }

            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }