private void btnCancel_Click(object sender, EventArgs e)
        {
            var query = new DataAccess.RequestCollection();

            query += DataAccess.DataQuery.Create("Docs", "ws_DOC_Answers_UpdateRespondentStatus", new
            {
                AnswerID,
                RespondentStatus = "Cancel"
            });
            var ds = Services.Execute(query);

            if (ds == null)
            {
                UI.ShowError(Services.LastError);
                return;
            }

            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 2
0
        private async Task SaveData()
        {
            try
            {
                var query = new DataAccess.RequestCollection();

                if (CheckValidateInput() == false)
                {
                    return;
                }

                string selectedfacelistID = FindFaceListID();
                if (dtFaceList._FindIndex("faceListId", selectedfacelistID) < 0)
                {
                    WriteLog("Vui lòng liên hệ tạo face list trước khi đồng bộ hình");
                    UI.ShowError("Vui lòng liên hệ tạo face list trước khi đồng bộ hình");
                    return;
                }

                AddPersistedFaceResult ressultaddFacetoList;

                query += DataAccess.DataQuery.Create("Docs", "ws_DOC_Answers_SupQuanlReUpdate", new
                {
                    AnswerID,
                    GreenID = txtRespondentNo.Text,
                    ProjectID,
                    RespondentFullName        = txtName.Text.Trim().ToUpper(),
                    RespondentAddressLandmark = txtAddress.Text.Trim().ToUpper(),
                    RespondentStreet          = txtStreet.Text.Trim().ToUpper(),
                    RespondentWard            = (txtWard.EditValue == null || txtWard.EditValue.ToString().IsEmpty()) ? "" : txtWard.Text.ToString().Trim(),
                    RespondentDistrict        = (txtDistrict.EditValue == null || txtDistrict.EditValue.ToString().IsEmpty()) ? "" : txtDistrict.Text.ToString(),
                    RespondentCity            = rCity.EditValue.ToString(),
                    RespondentTelephone       = txtTelephone.Text.Trim(),
                    RespondentGender          = rGender.EditValue == null ? "" : rGender.EditValue.ToString(),
                    RespondentStatus          = rStatus.EditValue.ToString(),
                    RespondentYoB             = dateDOB.Text.Trim(),
                    RecruitCode  = txtRecruit.EditValue.ToString(),
                    EmailAddress = txtEmail.Text.Trim(),
                    UserID       = Services.GetInformation("UserID")
                });

                foreach (Control ctr in flowQuota.Controls)
                {
                    if (ctr.GetType() == typeof(QuotaGroup))
                    {
                        if ((ctr as QuotaGroup).QuotaFieldValue == null || (ctr as QuotaGroup).QuotaFieldValue.IsEmpty())
                        {
                            UI.ShowError("Vui lòng chọn đầy đủ thông tin quota của đáp viên");
                            return;
                        }
                        query += DataAccess.DataQuery.Create("Docs", "ws_DOC_QuotaControlValues_Save", new
                        {
                            AnswerID,
                            ProjectID,
                            FieldName  = (ctr as QuotaGroup).QuotaFieldName,
                            FieldValue = (ctr as QuotaGroup).QuotaFieldValue,
                            UserID     = Services.GetInformation("UserID")
                        });
                    }
                }

                Image  img       = FacePhoto.Image;
                string name      = txtName.Text.Trim();
                string temp_Path = _pathImage;
                string ID        = AnswerID;

                //ClearOldData();

                if (temp_Path.IsNotEmpty())
                {
                    try
                    {
                        WriteLog(String.Format("Đã gửi yêu cầu lưu thông tin của đáp viên {0}", name));
                        FileStream streamfile = File.OpenRead(temp_Path);

                        MessageBox.Show(String.Format("Đã gửi yêu cầu lưu thông tin của đáp viên {0}", name));
                        WriteLog(String.Format("Resquest AddtoFaceList "));
                        ressultaddFacetoList = await faceServiceClient.AddFaceToFaceListAsync(selectedfacelistID, streamfile, ProjectNo + "_" + name);

                        WriteLog(String.Format("Complted Resquest AddtoFaceList "));
                        var Data = img.ImageToStringBase64();

                        query = DataAccess.DataQuery.Create("KadenceDB", "ws_FaceList_Save", new
                        {
                            ID         = ID,
                            FaceID     = ressultaddFacetoList.PersistedFaceId,
                            FaceListId = selectedfacelistID,
                            Image      = Data,
                            FullName   = name,
                            ProjectNo  = ProjectNo,
                            UserID     = Services.GetInformation("UserID")
                        }) + query;
                    }
                    catch (FaceAPIException ex)
                    {
                        WriteLog(String.Format("Lỗi {0}", ex.ErrorMessage));
                        UI.ShowError(String.Format("Lỗi {0}", ex.ErrorMessage));
                        return;
                    }
                }


                var ds = Services.Execute(query);
                if (ds == null)
                {
                    WriteLog(Services.LastError);
                    MessageBox.Show(Services.LastError);
                    return;
                }
                WriteLog(String.Format("Đã lưu thành công thông tin của đáp viên {0} {1}", name, ID));
                MessageBox.Show(String.Format("Đã lưu thành công thông tin của đáp viên {0}", name));
            }

            catch (Exception ex)
            {
                WriteLog(string.Format(ex.Message));
                UI.ShowError(ex.Message);
                return;
            }
        }
Ejemplo n.º 3
0
        private async Task NhanDien()
        {
            gFaceDetection.Text = "Face Detection ( FD ) đang nhận diện";

            flowLayoutPanel2.Controls.Clear();

            Confidence = Properties.Settings.Default.Confidence;
            if (FacePhoto.Image == null)
            {
                OpenFileDialogToPickImage();
            }
            if (FacePhoto.Image == null)
            {
                gFaceDetection.Text = "Face Detection ( FD )";
                return;
            }
            try
            {
                var ms = new MemoryStream();
                FacePhoto.Image.Save(ms, ImageFormat.Png);
                var m = Serializer.Compress(ms);
                // If you're going to read from the stream, you may need to reset the position to the start
                ms.Position = 0;

                var watch = System.Diagnostics.Stopwatch.StartNew();
                // the code that you want to measure comes here
                WriteLog(string.Format("Resquest DetectAsync"));
                var faces = await faceServiceClient.DetectAsync(m);

                watch.Stop();

                WriteLog(string.Format("Response: Success. Detected {0} face(s) in {1} seconds", faces.Length, watch.Elapsed.TotalSeconds));

                var personSimilarResultFace = new PersonSimilarResults();

                flowLayoutPanel2.Controls.Clear();

                foreach (var f in faces)
                {
                    var faceId = f.FaceId;
                    WriteLog(String.Format("Request: Finding similar faces in Face Match Mode for face {0}", faceId));

                    foreach (DataRow row in dtFaceList.Rows)
                    {
                        try
                        {
                            var personSimilarResults = await faceServiceClient.FindSimilarAsync(faceId, row.Item("faceListId"), FindSimilarMatchMode.matchFace, 4);

                            foreach (var personSimilarResult in personSimilarResults)
                            {
                                if (personSimilarResult.Confidence >= Confidence)
                                {
                                    personSimilarResultFace.Add(personSimilarResult.PersistedFaceId, personSimilarResult.Confidence);
                                }
                            }
                            WriteLog(String.Format("Response: Success FindSimilarAsync {0}- {1}", faceId, row.Item("faceListId")));
                        }
                        catch (FaceAPIException ex)
                        {
                            WriteLog(String.Format("Error FindSimilarAsync {0}- {1}:{2}", faceId, row.Item("faceListId"), ex.ErrorMessage));
                        }
                    }
                }
                if (personSimilarResultFace.Data.Count == 0)
                {
                    WriteLog(String.Format("Không tìm thấy khuôn mặt giống khuôn mặt đáp viên {0}", txtName.Text));
                    MessageBox.Show(String.Format("Không tìm thấy khuôn mặt giống khuôn mặt đáp viên {0}", txtName.Text));
                    gFaceDetection.Text = "Face Detection ( FD )";
                    return;
                }
                else
                {
                    //MessageBox.Show(
                }

                var items = from pair in personSimilarResultFace.Data
                            orderby pair.Value ascending
                            select pair;

                var query = new DataAccess.RequestCollection();

                string ids = "";
                foreach (KeyValuePair <string, double> item in items)
                {
                    ids += item.Key + ",";
                }

                query = DataAccess.DataQuery.Create("KadenceDB", "ws_FaceList_List", new
                {
                    FaceIDs = ids
                });
                var ds = this.Services.Execute(query);
                if (ds == null)
                {
                    MessageBox.Show(Services.LastError);
                    return;
                }

                foreach (DataRow row in ds.FirstTable().Rows)
                {
                    var faceRespondent = new FaceFaceSimilarUnit();
                    faceRespondent.Conf = personSimilarResultFace.Data[row.Item("FaceID")];

                    faceRespondent.ProjectNameFullName = row.Item("ProjectNo") + "_" + row.Item("FullName");
                    byte[] byteImage = Convert.FromBase64String(row.Item("Image"));

                    Image imageProfile;
                    using (MemoryStream memorysteam = new MemoryStream(byteImage))
                    {
                        imageProfile = Image.FromStream(memorysteam);
                    }
                    faceRespondent.ImageRespondent = imageProfile;


                    faceRespondent.Height = flowLayoutPanel2.Height - 10;
                    faceRespondent.Width  = faceRespondent.Height;
                    flowLayoutPanel2.Controls.Add(faceRespondent);
                }

                UI.ShowError(String.Format("Đã tìm thấy {1} khuôn mặt giống khuôn mặt đáp viên {0}", txtName.Text, ds.FirstTable().Rows.Count));
            }
            catch (FaceAPIException ex)
            {
                MessageBox.Show(ex.Message);
                gFaceDetection.Text = "Face Detection ( FD )";
                return;
            }

            gFaceDetection.Text = "Face Detection ( FD )";
        }
        async Task LoadData()
        {
            //danh sach phieu Ok


            using (UserDialogs.Instance.Loading("Đang lấy dữ liệu quota"))
            {
                try
                {
                    var CityHandle   = Services.GetInformation("CityHandle");
                    var query        = new DataAccess.RequestCollection();
                    int checkChecked = 0;
                    int TypeView     = 0;
                    if (rRercuit.Checked == true)
                    {
                        TypeView = 1;

                        checkChecked += 1;
                    }
                    if (rCLTRercuit.Checked == true)
                    {
                        TypeView = 2;

                        checkChecked += 1;
                    }

                    if (rQC.Checked == true)
                    {
                        TypeView = 3;

                        checkChecked += 1;
                    }
                    if (rInterview.Checked == true)
                    {
                        TypeView = 4;

                        checkChecked += 1;
                    }

                    if (checkChecked != 1)
                    {
                        await DisplayAlert("Lỗi check option", Services.LastError, "Ok");

                        return;
                    }
                    //data  quota value
                    //query += DataAccess.DataQuery.Create("Docs", "ws_DOC_QuotaControl_List", new
                    //{
                    //    ProjectID

                    //});
                    ////data quota field name
                    //query += DataAccess.DataQuery.Create("Docs", "ws_DOC_QuotaControlValues_List", new
                    //{
                    //    ProjectID
                    //});
                    //query += DataAccess.DataQuery.Create("Docs", "ws_DOC_QuotaConditionExpression_ListWithCityHandle", new
                    //{
                    //    ProjectID,
                    //    CityHandle=Services.GetInformation("CityHandle")
                    //});
                    query = DataAccess.DataQuery.Create("Docs", "ws_DOC_Answers_ListCalculateQuotaWithCity", new
                    {
                        ProjectID,
                        TypeView,
                        CityHandle = CityHandle,
                        IsAll      = IsAll
                    });
                    var ds = Services.Execute(query);
                    if (DependencyService.Get <IDataSetExtension>().IsNull(ds) == true)
                    {
                        await DisplayAlert("Lỗi load dữ liệu", Services.LastError, "Ok");

                        return;
                    }

                    gData.ItemsSource = ds.Tables[0];
                    //var tblProfile = ds.Tables[0];
                    //var tblQuotaValue = ds.Tables[2];
                    //var tblQuotaField = ds.Tables[1];
                    //var tblExpression = ds.Tables[3];

                    //foreach (DataRow row in tblQuotaField.Rows)
                    //{
                    //    tblProfile.Columns.Add(row["FieldName"].ToString().ToUpper(), typeof(String));

                    //}

                    //foreach (DataRow row in tblProfile.Rows)
                    //{
                    //    for (int i = 0; i < row.ItemArray.Length; i++)
                    //    {
                    //        string AnswerID = row["AnswerID"].ToString();
                    //        string columnName = row.Table.Columns[i].ColumnName.ToString().ToUpper();
                    //        if (IsFieldQuota(columnName, tblQuotaField) == true)
                    //        {
                    //            row[i] = FindValue(tblQuotaValue, AnswerID, "FieldName", columnName, "FieldValue");
                    //        }

                    //    }
                    //}

                    //foreach (DataRow row in tblExpression.Rows)
                    //{
                    //    string queryCondition = row["ConditionExpression"].ToString();
                    //    var items = DependencyService.Get<IDataTableExtension>().SelectQuery(tblProfile, queryCondition);

                    //    int currentCount = items.Length;
                    //    row["CurrentCount"] = currentCount;

                    //    int minValue = (int)row["MinValue"];
                    //    int maxValue = (int)row["MaxValue"];

                    //    if (currentCount <= minValue && minValue != maxValue)
                    //        row["NeedQty"] = String.Format("Còn {0}-{1}", minValue - currentCount, maxValue - currentCount);

                    //    if (currentCount <= minValue && minValue == maxValue)
                    //        row["NeedQty"] = String.Format("Còn {0}", minValue - currentCount);

                    //    if (currentCount > minValue && minValue == maxValue)
                    //        row["NeedQty"] = String.Format("Dư {0}", currentCount - minValue);

                    //    if (currentCount > minValue && minValue != maxValue && currentCount <= maxValue)
                    //        row["NeedQty"] = String.Format("Dư +{0}", maxValue - currentCount);

                    //    if (currentCount > minValue && minValue != maxValue && currentCount > maxValue)
                    //        row["NeedQty"] = String.Format("Dư +{0}", currentCount - maxValue);



                    //}
                    //gData.ItemsSource = tblExpression;
                }
                catch (Exception ex)
                {
                    await DisplayAlert(ex.StackTrace.ToString(), ex.Message, "Ok");

                    return;
                }
            }
        }
Ejemplo n.º 5
0
        public async void btnSave_Clicked(object sender, EventArgs args)
        {
            using (UserDialogs.Instance.Loading("Đang lưu thông tin"))
            {
                if (ValidateForm().Result == false)
                {
                    return;
                }

                string RecruitCode = FindRecruitCode();

                var query = new DataAccess.RequestCollection();
                query += DataAccess.DataQuery.Create("Docs", "ws_DOC_Answers_SupUpdate", new
                {
                    AnswerID,
                    GreenID = txtGreenID.Text.Trim().ToUpper(),
                    ProjectID,
                    RespondentFullName        = txtFullName.Text.Trim().ToUpper(),
                    RespondentAddressLandmark = txtAddress.Text.Trim().ToUpper(),
                    RespondentStreet          = txtStreet.Text.Trim().ToUpper(),
                    RespondentWard            = txtWard.SelectedItem == null ? "" : txtWard.SelectedItem.ToString(),
                    RespondentDistrict        = txtDistrict.SelectedItem == null ? "" : txtDistrict.SelectedItem.ToString(),
                    RespondentCity            = tblHanhChanh.Rows[0]["City"].ToString(),
                    RespondentTelephone       = txtTelephone.Text.Trim(),
                    RespondentGender          = txtGender.SelectedItem == null ? "" : txtGender.SelectedItem.ToString(),
                    RespondentYoB             = txtYoB.SelectedItem.ToString(),
                    RespondentStatus          = txtStatus.SelectedItem == null ? "" : txtStatus.SelectedItem.ToString(),
                    RecruitCode  = FindRecruitCode(),
                    RecruitName  = "",
                    EmailAddress = txtEmail.Text,
                    UserID       = Services.GetInformation("UserID")
                });

                foreach (var ctr in this.layoutQuota.Children)

                {
                    if (ctr.GetType() == typeof(QuotaControl))
                    {
                        if ((ctr as QuotaControl).QuotaFieldValue == null || (ctr as QuotaControl).QuotaFieldValue.ToString().Trim().Length == 0)
                        {
                            await DisplayAlert("Lỗi nhập dữ liệu quota", "Nhập đầy đủ thông tin quota", "Ok");

                            return;
                        }
                        query += DataAccess.DataQuery.Create("Docs", "ws_DOC_QuotaControlValues_Save", new
                        {
                            AnswerID,
                            ProjectID,
                            FieldName  = (ctr as QuotaControl).QuotaFieldName,
                            FieldValue = (ctr as QuotaControl).QuotaFieldValue,
                            UserID     = Services.GetInformation("UserID")
                        });
                    }
                }

                query += DataAccess.DataQuery.Create("Docs", "ws_DOC_Answers_GetForWaitingMobile", new
                {
                    ProjectID,
                    UserID = Services.GetInformation("UserID").ToString()
                });
                var ds = Services.Execute(query);

                if (DependencyService.Get <IDataSetExtension>().IsNull(ds) == true)
                {
                    await DisplayAlert("Lỗi load dữ liệu", Services.LastError, "Ok");

                    return;
                }
                tblResult = ds.Tables[ds.Tables.Count - 1];

                if (Saved != null)
                {
                    Saved(this, null);
                }

                await Application.Current.MainPage.Navigation.PopAsync();
            }
        }
Ejemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //save
            try
            {
                var query = new DataAccess.RequestCollection();

                if (CheckValidateInput() == false)
                {
                    return;
                }

                query += DataAccess.DataQuery.Create("Docs", "ws_DOC_Answers_SupReUpdate", new
                {
                    AnswerID,
                    GreenID = txtGreenID.Text.Trim(),
                    ProjectID,
                    RespondentFullName        = txtName.Text.Trim().ToUpper(),
                    RespondentAddressLandmark = txtAddress.Text.Trim().ToUpper(),
                    RespondentStreet          = txtStreet.Text.Trim().ToUpper(),
                    RespondentWard            = (txtWard.EditValue == null || txtWard.EditValue.ToString().IsEmpty()) ? "" : txtWard.Text.ToString().Trim(),
                    RespondentDistrict        = (txtDistrict.EditValue == null || txtDistrict.EditValue.ToString().IsEmpty()) ? "" : txtDistrict.Text.ToString(),
                    RespondentCity            = rCity.EditValue.ToString(),
                    RespondentTelephone       = txtTelephone.Text.Trim(),
                    RespondentGender          = rGender.EditValue == null ? "" : rGender.EditValue.ToString(),
                    RespondentStatus          = rStatus.EditValue.ToString(),
                    RespondentYoB             = dateDOB.Text.Trim(),
                    RecruitCode  = txtRecruit.EditValue.ToString(),
                    EmailAddress = txtEmail.Text.Trim(),
                    UserID       = Services.GetInformation("UserID")
                });

                foreach (Control ctr in flowQuota.Controls)
                {
                    if (ctr.GetType() == typeof(QuotaGroup))
                    {
                        query += DataAccess.DataQuery.Create("Docs", "ws_DOC_QuotaControlValues_Save", new
                        {
                            AnswerID,
                            ProjectID,
                            FieldName  = (ctr as QuotaGroup).QuotaFieldName,
                            FieldValue = (ctr as QuotaGroup).QuotaFieldValue,
                            UserID     = Services.GetInformation("UserID")
                        });
                    }
                }
                var ds = Services.Execute(query);
                if (ds == null)
                {
                    WriteLog(Services.LastError);
                    MessageBox.Show(Services.LastError);
                    return;
                }
                WriteLog(String.Format("Đã lưu thành công thông tin của đáp viên {0} {1}", txtRespondentNo.Text, AnswerID));

                UI.InformationSaved();
                ClearOldData();
            }

            catch (Exception ex)
            {
                WriteLog(string.Format(ex.Message));
                UI.ShowError(ex.Message);
                return;
            }
        }