// </snippet_calls>

    // <snippet_getcontent_call>
    private static async Task GetContent(
        FormRecognizerClient recognizerClient, string invoiceUri)
        {
        Response<FormPageCollection> formPages = await recognizerClient
            .StartRecognizeContentFromUri(new Uri(invoiceUri))
            .WaitForCompletionAsync();
        // </snippet_getcontent_call>

        // <snippet_getcontent_print>
        foreach (FormPage page in formPages.Value)
        {
            Console.WriteLine($"Form Page {page.PageNumber} has {page.Lines.Count}" + 
                $" lines.");
        
            for (int i = 0; i < page.Lines.Count; i++)
            {
                FormLine line = page.Lines[i];
                Console.WriteLine($"    Line {i} has {line.Words.Count}" + 
                    $" word{(line.Words.Count > 1 ? "s" : "")}," +
                    $" and text: '{line.Text}'.");
            }
        
            for (int i = 0; i < page.Tables.Count; i++)
            {
                FormTable table = page.Tables[i];
                Console.WriteLine($"Table {i} has {table.RowCount} rows and" +
                    $" {table.ColumnCount} columns.");
                foreach (FormTableCell cell in table.Cells)
                {
                    Console.WriteLine($"    Cell ({cell.RowIndex}, {cell.ColumnIndex})" +
                        $" contains text: '{cell.Text}'.");
                }
            }
        }
    }
예제 #2
0
        public IActionResult Create(int formId)
        {
            var form = _db.Forms
                       .Include(x => x.DbTable)
                       .ThenInclude(x => x.Fields)
                       .SingleOrDefault(x => x.Id == formId);

            if (form == null)
            {
                return(NotFound());
            }

            var tables = _db.DbTables
                         .Where(x => x.DbId == form.DbTable.DbId)
                         .ToList();

            var data = tables.Select(table => new SelectListItem($"[{table.Name}] {table.Title}", table.Id.ToString())).ToList();

            ViewBag.Tables = data;
            ViewBag.Fields = form.DbTable.Fields.Select(x => new SelectListItem($"[{x.Field}] {x.Title}", x.Field)).ToList();

            var entity = new FormTable {
                FormId = formId
            };

            ViewBag.Form = form.Title;

            return(View(entity));
        }
      // </snippet_trainlabels_response>
      // <snippet_analyze>
      // Analyze PDF form data
      private static async Task AnalyzePdfForm(
      FormRecognizerClient recognizerClient, Guid modelId, string formUrl) {
        RecognizedFormCollection forms = await recognizeClient.StartRecognizeCustomFormsFromUri(modelId, new Uri(invoiceUri)).WaitForCompletionAsync();
        // </snippet_analyze>
        // <snippet_analyze_response>
        foreach(RecognizedForm form in forms) {
          Console.WriteLine($ "Form of type: {form.FormType}");
          foreach(FormField field in form.Fields.Values) {
            Console.WriteLine($ "Field '{field.Name}: ");

            if (field.LabelData != null) {
              Console.WriteLine($ "    Label: '{field.LabelData.Text}");
            }

            Console.WriteLine($ "    Value: '{field.ValueData.Text}");
            Console.WriteLine($ "    Confidence: '{field.Confidence}");
          }
          Console.WriteLine("Table data:");
          foreach(FormPage page in form.Pages.Values) {
            for (int i = 0; i < page.Tables.Count; i++) {
              FormTable table = page.Tables[i];
              Console.WriteLine($ "Table {i} has {table.RowCount} rows and {table.ColumnCount} columns.");
              foreach(FormTableCell cell in table.Cells) {
                Console.WriteLine($ "    Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains {(cell.IsHeader ? "
                header " : "
                text ")}: '{cell.Text}'");
              }
            }
          }
        }
      }
        private static async Task RecognizeContent(FormRecognizerClient recognizerClient, string formUrl)
        {
            FormPageCollection formPages = await recognizerClient
                                           .StartRecognizeContentFromUri(new Uri(formUrl))
                                           .WaitForCompletionAsync();

            foreach (FormPage page in formPages)
            {
                //lines
                for (int i = 0; i < page.Lines.Count; i++)
                {
                    FormLine line = page.Lines[i];

                    //returnString += $"{line.Text}{Environment.NewLine}";
                    returnString += $"    Line {i} has {line.Words.Count} word{(line.Words.Count > 1 ? "s" : "")}, and text: '{line.Text}'.{Environment.NewLine}";
                }
                //tables
                for (int i = 0; i < page.Tables.Count; i++)
                {
                    FormTable table = page.Tables[i];
                    foreach (FormTableCell cell in table.Cells)
                    {
                        //returnString += $"{cell.Text} ";
                        returnString += $"    Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains text: '{cell.Text}'.{Environment.NewLine}";
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// |date|가 대상 대시보드의 실적 업로드 기간에 해당되는지 여부를 반환한다.
        /// </summary>
        public static bool IsInUploadInterval(FormTable form, DateTimeOffset date)
        {
            bool result = true;

            switch (form.UploadInterval)
            {
            case DataUploadInterval.Daily:
                break;

            case DataUploadInterval.Weekly:

                // 업로드 요일을 비교한다.
                if (form.UploadDayOfWeek != DataUploadDayOfWeek.All)
                {
                    result = (DayOfWeek)form.UploadDayOfWeek == date.DayOfWeek;
                }
                break;

            case DataUploadInterval.Monthly:

                // 업로드 주차를 비교한다.
                result = date.WeekRangeOfMonth(DayOfWeek.Wednesday).Week == form.UploadWeekOfMonth;

                if (result && (form.UploadDayOfWeek != DataUploadDayOfWeek.All))
                {
                    result = (DayOfWeek)form.UploadDayOfWeek == date.DayOfWeek;
                }
                break;
            }

            return(result);
        }
        // GET: FormTable
        public ActionResult Index()
        {
            FormTable        ObjTable        = new FormTable();
            List <FormTable> ListOfFormTable = ObjTable.TableList();

            return(View(ListOfFormTable));
        }
예제 #7
0
        private void ShowTableWindow()
        {
            FormTable table_form = new FormTable();

            table_form.OutPutRezultPlanPosition();
            table_form.ShowDialog();
        }
예제 #8
0
        /// <summary>
        /// 대시보드 테이블 아이템을 반환한다.
        /// </summary>
        public FormTable SelectFormTable(Guid formId)
        {
            string procCommandName = "up_FormTable_Select";

            try
            {
                var command = Connection.GetStoredProcCommand(procCommandName);
                Connection.AddInParameter(command, "FormID", DbType.Guid, formId);

                using (DataSet ds = Connection.ExecuteDataSet(command))
                {
                    ValidateTableCount(ds, 2);

                    // 1. 대시보드 테이블
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        var form = FormTable.ParseFrom(ds.Tables[0].Rows[0]);

                        // 2. 대시보드 테이블 양식
                        if (ds.Tables[1].Rows.Count > 0)
                        {
                            form.HtmlTemplate = FormHtmlTemplate.ParseFrom(ds.Tables[1].Rows[0]);
                        }

                        return(form);
                    }

                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex);
            }
        }
예제 #9
0
        /// <summary>
        /// 대시보드 테이블을 업데이트한다.
        /// </summary>
        public bool UpdateFormTable(FormTable formTable)
        {
            formTable.ThrowIfNull(nameof(formTable));

            string procCommandName = "up_FormTable_Update";

            try
            {
                var command = Connection.GetStoredProcCommand(procCommandName);
                Connection.AddInParameter(command, "FormID", DbType.Guid, formTable.FormId);
                Connection.AddInParameter(command, "HtmlTemplateID", DbType.Guid, formTable.HtmlTemplateId);
                Connection.AddInParameter(command, "Name", DbType.String, formTable.Name);
                Connection.AddInParameter(command, "Description", DbType.String, formTable.Description);
                //Connection.AddInParameter(command, "UploadInterval", DbType.String, formTable.UploadInterval.ToEnumMemberString());
                Connection.AddInParameter(command, "UploadWeekOfMonth", DbType.Int32, formTable.UploadWeekOfMonth);
                Connection.AddInParameter(command, "UploadDayOfWeek", DbType.String, formTable.UploadDayOfWeek.ToEnumMemberString());
                Connection.AddInParameter(command, "IsEnabled", DbType.Boolean, formTable.IsEnabled);
                Connection.AddInParameter(command, "UpdatedDate", DbType.DateTimeOffset, formTable.UpdatedDate);

                return((int)Connection.ExecuteNonQuery(command) > 0);
            }
            catch (Exception ex)
            {
                throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex);
            }
        }
    // </snippet_auth_training>

    // <snippet_getcontent_call>
    private static async Task RecognizeContent(FormRecognizerClient recognizerClient)
    {
        var invoiceUri = "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/simple-invoice.png";
        FormPageCollection formPages = await recognizerClient
                                       .StartRecognizeContentFromUri(new Uri(invoiceUri))
                                       .WaitForCompletionAsync();

        // </snippet_getcontent_call>

        // <snippet_getcontent_print>
        foreach (FormPage page in formPages)
        {
            Console.WriteLine($"Form Page {page.PageNumber} has {page.Lines.Count} lines.");

            for (int i = 0; i < page.Lines.Count; i++)
            {
                FormLine line = page.Lines[i];
                Console.WriteLine($"    Line {i} has {line.Words.Count} word{(line.Words.Count > 1 ? "s" : "")}, and text: '{line.Text}'.");
            }

            for (int i = 0; i < page.Tables.Count; i++)
            {
                FormTable table = page.Tables[i];
                Console.WriteLine($"Table {i} has {table.RowCount} rows and {table.ColumnCount} columns.");
                foreach (FormTableCell cell in table.Cells)
                {
                    Console.WriteLine($"    Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains text: '{cell.Text}'.");
                }
            }
        }
    }
        public async Task RecognizeContentFromFile()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            string invoiceFilePath = FormRecognizerTestEnvironment.CreatePath("Invoice_1.pdf");

            using (FileStream stream = new FileStream(invoiceFilePath, FileMode.Open))
            {
                FormPageCollection formPages = await client.StartRecognizeContent(stream).WaitForCompletionAsync();

                foreach (FormPage page in formPages)
                {
                    Console.WriteLine($"Form Page {page.PageNumber} has {page.Lines.Count} lines.");

                    for (int i = 0; i < page.Lines.Count; i++)
                    {
                        FormLine line = page.Lines[i];
                        Console.WriteLine($"    Line {i} has {line.Words.Count} word{(line.Words.Count > 1 ? "s" : "")}, and text: '{line.Text}'.");
                    }

                    for (int i = 0; i < page.Tables.Count; i++)
                    {
                        FormTable table = page.Tables[i];
                        Console.WriteLine($"Table {i} has {table.RowCount} rows and {table.ColumnCount} columns.");
                        foreach (FormTableCell cell in table.Cells)
                        {
                            Console.WriteLine($"    Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains text: '{cell.Text}'.");
                        }
                    }
                }
            }
        }
예제 #12
0
        private static async Task RecognizeContent(FormRecognizerClient recognizerClient)
        {
            var invoiceUri = "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/master/sdk/formrecognizer/azure-ai-formrecognizer/tests/sample_forms/forms/Invoice_1.pdf";
            FormPageCollection formPages = await recognizerClient
                                           .StartRecognizeContentFromUri(new Uri(invoiceUri))
                                           .WaitForCompletionAsync();

            foreach (FormPage page in formPages)
            {
                Console.WriteLine($"Form Page {page.PageNumber} has {page.Lines.Count} lines.");

                for (int i = 0; i < page.Lines.Count; i++)
                {
                    FormLine line = page.Lines[i];
                    Console.WriteLine($"    Line {i} has {line.Words.Count} word{(line.Words.Count > 1 ? "s" : "")}, and text: '{line.Text}'.");
                }

                for (int i = 0; i < page.Tables.Count; i++)
                {
                    FormTable table = page.Tables[i];
                    Console.WriteLine($"Table {i} has {table.RowCount} rows and {table.ColumnCount} columns.");
                    foreach (FormTableCell cell in table.Cells)
                    {
                        Console.WriteLine($"    Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains text: '{cell.Text}'.");
                    }
                }
            }
        }
예제 #13
0
        private void Delete_Click(object sender, EventArgs e)
        {
            TableLayoutPanelCellPosition position = FormTable.GetPositionFromControl((sender as Control).Parent);
            int    row      = position.Row;
            string formname = FormTable.GetControlFromPosition(0, row).Text;

            DeleteForm(formname, row);
        }
        public IActionResult FileMediaCreate(FormTable f, IList <IFormFile> FilePicture, IFormFile FileDownload)
        {
            foreach (var FilePath in FilePicture)
            {
                if (FilePath != null)
                {
                    string     extention   = Path.GetExtension(FilePath.FileName);
                    string     filenewname = DateTime.Now.ToString("ddmmyyyyhhmmsstt") + "pfn";
                    string     finalpath   = "/fpicpath/" + filenewname + extention;
                    FileStream FN          = new FileStream(IHEN.WebRootPath + finalpath, FileMode.Create);
                    FilePath.CopyTo(FN);
                    FN.Close();
                    f.FilePath      = finalpath;
                    ViewBag.Message = "media file successful save path in online database";
                }
            }
            if (FileDownload != null)
            {
                string     extention   = Path.GetExtension(FileDownload.FileName);
                string     filenewname = DateTime.Now.ToString("ddmmyyyyhhmmsstt") + "dld";
                string     finalpath   = "/fpicpath/" + filenewname + extention;
                FileStream FN          = new FileStream(IHEN.WebRootPath + finalpath, FileMode.Create);
                FileDownload.CopyTo(FN);
                FN.Close();
                f.FileDownload  = finalpath;
                ViewBag.Message = "media file successful save path in online database";

                try
                {
                    //Email flow ............write Here.......
                    MailMessage oEmial = new MailMessage();
                    oEmial.To.Add(f.Email);
                    oEmial.From = new MailAddress("*****@*****.**");
                    oEmial.Bcc.Add("*****@*****.**");
                    oEmial.Subject = "CV this is the  subject of EMAIL" + f.Name;
                    oEmial.Body    = "THIS IS THE Body of Email " + f.Name;

                    oEmial.Attachments.Add(new Attachment(IHEN.WebRootPath + finalpath));

                    //SMTPClind.......Servie use for Email sending.......
                    SmtpClient oSmtp = new SmtpClient();
                    oSmtp.Credentials = new System.Net.NetworkCredential("sialkotem@gmail", "sialkot7868");
                    oSmtp.EnableSsl   = true;
                    oSmtp.Port        = 465;//587//25
                    oSmtp.Host        = "SMTP.Gmail.com";
                    oSmtp.Send(oEmial);
                }
                catch (Exception e)
                {
                    ViewBag.Message = "Error Emial Portion" + e.Message;
                    return(View());
                }
            }

            ORM.FormTable.Add(f);
            ORM.SaveChanges();
            return(View());
        }
예제 #15
0
        public async Task RecognizeContentFromFile()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            string filePath = FormRecognizerTestEnvironment.CreatePath("Invoice_1.pdf");

            #region Snippet:FormRecognizerRecognizeFormContentFromFile
            //@@ string filePath = "filePath";
            using var stream = new FileStream(filePath, FileMode.Open);

            Response <FormPageCollection> response = await client.StartRecognizeContentAsync(stream).WaitForCompletionAsync();

            FormPageCollection formPages = response.Value;

            foreach (FormPage page in formPages)
            {
                Console.WriteLine($"Form Page {page.PageNumber} has {page.Lines.Count} lines.");

                for (int i = 0; i < page.Lines.Count; i++)
                {
                    FormLine line = page.Lines[i];
                    Console.WriteLine($"  Line {i} has {line.Words.Count} {(line.Words.Count == 1 ? "word" : "words")}, and text: '{line.Text}'.");

                    Console.WriteLine("    Its bounding box is:");
                    Console.WriteLine($"    Upper left => X: {line.BoundingBox[0].X}, Y= {line.BoundingBox[0].Y}");
                    Console.WriteLine($"    Upper right => X: {line.BoundingBox[1].X}, Y= {line.BoundingBox[1].Y}");
                    Console.WriteLine($"    Lower right => X: {line.BoundingBox[2].X}, Y= {line.BoundingBox[2].Y}");
                    Console.WriteLine($"    Lower left => X: {line.BoundingBox[3].X}, Y= {line.BoundingBox[3].Y}");
                }

                for (int i = 0; i < page.Tables.Count; i++)
                {
                    FormTable table = page.Tables[i];
                    Console.WriteLine($"  Table {i} has {table.RowCount} rows and {table.ColumnCount} columns.");
                    foreach (FormTableCell cell in table.Cells)
                    {
                        Console.WriteLine($"    Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains text: '{cell.Text}'.");
                    }
                }

                for (int i = 0; i < page.SelectionMarks.Count; i++)
                {
                    FormSelectionMark selectionMark = page.SelectionMarks[i];
                    Console.WriteLine($"  Selection Mark {i} is {selectionMark.State}.");
                    Console.WriteLine("    Its bounding box is:");
                    Console.WriteLine($"      Upper left => X: {selectionMark.BoundingBox[0].X}, Y= {selectionMark.BoundingBox[0].Y}");
                    Console.WriteLine($"      Upper right => X: {selectionMark.BoundingBox[1].X}, Y= {selectionMark.BoundingBox[1].Y}");
                    Console.WriteLine($"      Lower right => X: {selectionMark.BoundingBox[2].X}, Y= {selectionMark.BoundingBox[2].Y}");
                    Console.WriteLine($"      Lower left => X: {selectionMark.BoundingBox[3].X}, Y= {selectionMark.BoundingBox[3].Y}");
                }
            }

            #endregion
        }
예제 #16
0
        /// <summary>
        /// 대시보드 테이블을 추가한다.
        /// </summary>
        public bool AddFormTable(FormTable formTable)
        {
            using (var repo = new FormTableRepository())
            {
                if (!formTable.HasHtmlTemplate)
                {
                    throw new ArgumentNullException($"대시보드에 해당하는 HTML양식을 찾을 수 없습니다. 대시보드: {formTable.Name}"
                                                    + $"\r\n"
                                                    + $"대시보드 ID: {formTable.FormId}");
                }

                repo.BeginTransaction();

                try
                {
                    if (repo.InsertFormTable(formTable))
                    {
                        if (repo.InsertFormHtmlTemplate(formTable.HtmlTemplate))
                        {
                            repo.CommitTransaction();

                            logger.Info($"새 대시보드를 추가하였습니다. 대시보드: \"{formTable.Name}\""
                                        + $"\r\n\r\n"
                                        + $"{formTable}");

                            return(true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, $"대시보드 추가 중 알 수 없는 오류가 발생하였습니다. 대시보드: \"{formTable.Name}\""
                                 + $"\r\n\r\n"
                                 + $"{formTable}");

                    try
                    {
                        repo.RollBackTransaction();
                    }
                    catch (Exception rex)
                    {
                        logger.Fatal(ex, $"대시보드 추가 함수에서 롤백 실행중 치명적인 에러가 발생했습니다. 대시보드: \"{formTable.Name}\""
                                     + $"\r\n\r\n"
                                     + $"{formTable}");

                        ExceptionDispatchInfo.Capture(rex).Throw();
                        // not reached
                    }

                    ExceptionDispatchInfo.Capture(ex).Throw();
                    return(false); // not reached
                }

                return(false);
            }
        }
예제 #17
0
파일: Program.cs 프로젝트: slaner/Utils
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            FormTable.Register <Form1>();
            FormTable.Register <Form2>();

            Application.Run(FormTable.Get <Form1>());
        }
예제 #18
0
        //public IList<FormTable> Get()
        //{
        //    FormTable ObjTable = new FormTable();
        //    IList<FormTable> ListOfFormTable = ObjTable.TableList();
        //    return ListOfFormTable;
        //}
        public JObject Get()
        {
            JObject          Jobj            = new JObject();
            FormTable        ObjTable        = new FormTable();
            List <FormTable> ListOfFormTable = ObjTable.TableList();

            Jobj["User"] = JArray.FromObject(ListOfFormTable.Select(x => new { x.FormName, x.FormType, x.FormJavaScript }));

            return(Jobj);
        }
예제 #19
0
        public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageForm(bool useStream)
        {
            var client  = CreateFormRecognizerClient();
            var options = new RecognizeCustomFormsOptions()
            {
                IncludeFieldElements = true
            };
            RecognizeCustomFormsOperation operation;

            await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels : false, ContainerType.MultipageFiles);

            if (useStream)
            {
                using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipage);
                using (Recording.DisableRequestBodyRecording())
                {
                    operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
                }
            }
            else
            {
                var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipage);
                operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
            }

            RecognizedFormCollection recognizedForms = await operation.WaitForCompletionAsync();

            Assert.AreEqual(2, recognizedForms.Count);

            for (int formIndex = 0; formIndex < recognizedForms.Count; formIndex++)
            {
                var recognizedForm     = recognizedForms[formIndex];
                var expectedPageNumber = formIndex + 1;

                ValidateModelWithNoLabelsForm(
                    recognizedForm,
                    trainedModel.ModelId,
                    includeFieldElements: true,
                    expectedFirstPageNumber: expectedPageNumber,
                    expectedLastPageNumber: expectedPageNumber);
            }

            // Basic sanity test to make sure pages are ordered correctly.

            FormPage  firstFormPage  = recognizedForms[0].Pages.Single();
            FormTable firstFormTable = firstFormPage.Tables.Single();

            Assert.True(firstFormTable.Cells.Any(c => c.Text == "Gold Sponsor"));

            FormField secondFormFieldInPage = recognizedForms[1].Fields.Values.Where(field => field.LabelData.Text.Contains("Company Name:")).FirstOrDefault();

            Assert.IsNotNull(secondFormFieldInPage);
            Assert.IsNotNull(secondFormFieldInPage.ValueData);
            Assert.AreEqual("Southridge Video", secondFormFieldInPage.ValueData.Text);
        }
예제 #20
0
        /// <summary>
        /// 대시보드의 특정 날짜 데이터 파일을 모두 확인 처리 한다.
        /// </summary>
        private bool ConfirmFormTableDataInternal(DashboardRepository repo, FormTable form, DateTimeOffset sourceDate)
        {
            // 날짜 범위에 해당하는 데이터를 모두 조회하기 위해 날짜 계산
            var dateRange = form.GetDateRangeByUploadInterval(sourceDate);

            var list = repo.SelectDataFileSourceListBySourceDateRange(form.FormId, dateRange.BeginDate, dateRange.EndDate)
                       .Where(o => !o.IsConfirmed)
                       .ToList();

            if (list.Any())
            {
                Guid htmlTemplateId = form.HtmlTemplateId;

                // 1. 대시보드 양식 html 사본을 생성한다.
                if (AppSettings.AppSetting <bool>("FormHtmlTemplate.CopyIfConfirmed"))
                {
                    htmlTemplateId = Guid.NewGuid();

                    using (var formRepo = new FormTableRepository())
                    {
                        var htmlTemplate = FormHtmlTemplate.CopyFrom(form.HtmlTemplate, htmlTemplateId);
                        formRepo.InsertFormHtmlTemplate(htmlTemplate);

                        logger.Info($"대상 대시보드의 양식이 사본 처리되었습니다. 대시보드: \"{form.Name}\""
                                    + $"\r\n\r\n"
                                    + $"대시보드 정보:"
                                    + $"{form}"
                                    + $"\r\n\r\n"
                                    + $"이전 양식 정보:"
                                    + $"{form.HtmlTemplate}"
                                    + $"\r\n\r\n"
                                    + $"신규 양식 정보:"
                                    + $"{htmlTemplate}");
                    }
                }

                // 2. 데이터 파일 소스 컨펌 처리
                foreach (var fileSource in list)
                {
                    repo.UpdateDataFileSourceAsConfirmed(form.FormId, fileSource.FileSourceId, htmlTemplateId, CurrentUser.UserId, DateTimeOffset.Now, fileSource.SourceDate);
                }

                logger.Info($"대상 대시보드의 실적 데이터 파일들을 확인 처리했습니다. 대시보드: \"{form.Name}\", 실적 기준일: \"{sourceDate.ToString("yyyy-MM-dd")}\""
                            + $"\r\n\r\n"
                            + $"대상 데이터 파일({list.Count}개): [\r\n"
                            + string.Join("\r\n", list.Select(o => "\t" + o.ToString()))
                            + $"\r\n"
                            + $"]");

                return(true);
            }

            return(false);
        }
예제 #21
0
        /// <summary>
        /// 페이징 처리된 대시보드 테이블 리스트를 반환한다.
        /// </summary>
        public PagedModel <FormTable> SelectFormTablePagedList(PagingOption option)
        {
            string procCommandName = "up_FormTable_SelectPagedList";

            try
            {
                var command = Connection.GetStoredProcCommand(procCommandName);
                Connection.AddInParameter(command, "PageNumber", DbType.Int32, option.PageNumber);
                Connection.AddInParameter(command, "PageCount", DbType.Int32, option.PageCount);
                Connection.AddInParameter(command, "SortBy", DbType.String, option.SortBy);
                Connection.AddInParameter(command, "OrderBy", DbType.String, option.OrderBy.ToEnumMemberString());

                using (DataSet ds = Connection.ExecuteDataSet(command))
                {
                    ValidateTableCount(ds, 2);

                    var result = new PagedModel <FormTable>(option)
                    {
                        PagingOption = option
                    };
                    int totalCount = 0;

                    // 1. 대시보드 테이블 리스트
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        var form = FormTable.ParseFrom(dr, out totalCount);
                        result.Items.Add(form);
                    }

                    // 2. 대시보드 테이블 양식 리스트
                    foreach (DataRow dr in ds.Tables[1].Rows)
                    {
                        var template = FormHtmlTemplate.ParseFrom(dr);
                        var forms    = result.Items.FindAll(o => o.FormId == template.FormId && o.HtmlTemplateId == template.HtmlTemplateId);
                        if (forms.Any())
                        {
                            forms.ForEach(o =>
                            {
                                o.HtmlTemplate = template;
                            });
                        }
                    }

                    result.TotalCount = totalCount;

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex);
            }
        }
예제 #22
0
        public Result Create(FormTable entity)
        {
            if (ModelState.IsValid)
            {
                _db.FormTables.Add(entity);
                _db.SaveChanges();

                return(ResultUtil.Success());
            }

            return(ResultUtil.Fail());
        }
        private static async Task AnalyzeDynamicCustomForm(FormRecognizerClient recognizerClient, string trainingFileUrl, string formUrl)
        {
            RecognizeCustomFormsOptions options = new RecognizeCustomFormsOptions();

            //train model
            FormTrainingClient trainingClient = new FormTrainingClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
            CustomFormModel    model          = await trainingClient.StartTrainingAsync(new Uri(trainingFileUrl), useTrainingLabels : false,
                                                                                        $"VIS-Dynamic-Model-{DateTime.Now.ToShortDateString()}-{DateTime.Now.ToLongTimeString()}").WaitForCompletionAsync();

            //string modelId = inModelID;
            string modelId = model.ModelId;

            //recognize form
            RecognizeCustomFormsOperation operation = await recognizerClient.StartRecognizeCustomFormsFromUriAsync(modelId, new Uri(formUrl));

            Response <RecognizedFormCollection> operationResponse = await operation.WaitForCompletionAsync();

            RecognizedFormCollection forms = operationResponse.Value;

            foreach (RecognizedForm form in forms)
            {
                returnString += $"Form of type: {form.FormType}{Environment.NewLine}";
                foreach (FormField field in form.Fields.Values)
                {
                    returnString += $"Field '{field.Name}: ";

                    if (field.LabelData != null)
                    {
                        returnString += $"    Label: '{field.LabelData.Text}";
                    }

                    returnString += $"    Value: '{field.ValueData.Text}";
                    returnString += $"    Confidence: '{field.Confidence}{Environment.NewLine}";
                }
                returnString += $"Table data:{Environment.NewLine}";
                foreach (FormPage page in form.Pages)
                {
                    for (int i = 0; i < page.Tables.Count; i++)
                    {
                        FormTable table = page.Tables[i];
                        //Console.WriteLine($"Table {i} has {table.RowCount} rows and {table.ColumnCount} columns.");
                        foreach (FormTableCell cell in table.Cells)
                        {
                            returnString += $"    Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains {(cell.IsHeader ? "header" : "text")}: '{cell.Text}'{Environment.NewLine}";
                        }
                    }
                }
            }
            // Delete the model on completion to clean environment.
            await trainingClient.DeleteModelAsync(model.ModelId);
        }
예제 #24
0
        public void ShowTable()
        {
            FormTable ft = new FormTable(thisChart);

            ft.ShowDialog();

            thisChart = ft.Chart;


            if (chartTree.SelectedChartNode is ChartModel)
            {
                customChart.Draw(thisChart);
            }
        }
예제 #25
0
        /// <summary>
        /// 페이징 처리된 메뉴 리스트를 반환한다.
        /// </summary>
        public PagedModel <MenuItem> SelectMenuPagedList(PagingOption option)
        {
            string procCommandName = "up_Menu_SelectPagedList";

            try
            {
                var command = Connection.GetStoredProcCommand(procCommandName);
                Connection.AddInParameter(command, "PageNumber", DbType.Int32, option.PageNumber);
                Connection.AddInParameter(command, "PageCount", DbType.Int32, option.PageCount);
                Connection.AddInParameter(command, "SortBy", DbType.String, option.SortBy);
                Connection.AddInParameter(command, "OrderBy", DbType.String, option.OrderBy.ToEnumMemberString());

                using (DataSet ds = Connection.ExecuteDataSet(command))
                {
                    ValidateTableCount(ds, 2);

                    var result = new PagedModel <MenuItem>(option)
                    {
                        PagingOption = option
                    };
                    int totalCount = 0;

                    // 메뉴 정보
                    foreach (DataRow dr1 in ds.Tables[0].Rows)
                    {
                        var menu = MenuItem.ParseFrom(dr1, out totalCount);
                        result.Items.Add(menu);

                        // 메뉴와 매핑된 대시보드 테이블 정보
                        foreach (DataRow dr2 in ds.Tables[1].Rows)
                        {
                            var formTableMenuId = dr2.Get <Guid>("MenuId");
                            if (formTableMenuId == menu.MenuId)
                            {
                                menu.FormTables.Add(FormTable.ParseFrom(dr2));
                            }
                        }
                    }

                    result.TotalCount = totalCount;

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex);
            }
        }
예제 #26
0
        public async Task RecognizeContentFromUri()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            Uri invoiceUri = FormRecognizerTestEnvironment.CreateUri("Invoice_1.pdf");

            #region Snippet:FormRecognizerSampleRecognizeContentFromUri

            FormPageCollection formPages = await client.StartRecognizeContentFromUriAsync(invoiceUri).WaitForCompletionAsync();

            foreach (FormPage page in formPages)
            {
                Console.WriteLine($"Form Page {page.PageNumber} has {page.Lines.Count} lines.");

                for (int i = 0; i < page.Lines.Count; i++)
                {
                    FormLine line = page.Lines[i];
                    Console.WriteLine($"    Line {i} has {line.Words.Count} word{(line.Words.Count > 1 ? "s" : "")}, and text: '{line.Text}'.");
                }

                for (int i = 0; i < page.Tables.Count; i++)
                {
                    FormTable table = page.Tables[i];
                    Console.WriteLine($"Table {i} has {table.RowCount} rows and {table.ColumnCount} columns.");
                    foreach (FormTableCell cell in table.Cells)
                    {
                        Console.WriteLine($"    Cell ({cell.RowIndex}, {cell.ColumnIndex}) contains text: '{cell.Text}'.");
                    }
                }

                for (int i = 0; i < page.SelectionMarks.Count; i++)
                {
                    FormSelectionMark selectionMark = page.SelectionMarks[i];
                    Console.WriteLine($"Selection Mark {i} is {selectionMark.State.ToString()}.");
                    Console.WriteLine("        Its bounding box is:");
                    Console.WriteLine($"        Upper left => X: {selectionMark.BoundingBox[0].X}, Y= {selectionMark.BoundingBox[0].Y}");
                    Console.WriteLine($"        Upper right => X: {selectionMark.BoundingBox[1].X}, Y= {selectionMark.BoundingBox[1].Y}");
                    Console.WriteLine($"        Lower right => X: {selectionMark.BoundingBox[2].X}, Y= {selectionMark.BoundingBox[2].Y}");
                    Console.WriteLine($"        Lower left => X: {selectionMark.BoundingBox[3].X}, Y= {selectionMark.BoundingBox[3].Y}");
                }
            }

            #endregion
        }
        public ActionResult AddForm(Form form)
        {
            try
            {
                using (myDB1Entities db = new myDB1Entities())
                {
                    FormTable Fdb = new FormTable
                    {
                        ID             = form.ID,
                        Date           = DateTime.Now,
                        FirstName      = form.FirstName,
                        LastName       = form.LastName,
                        Email          = form.Email,
                        AreaOfInterest = form.AreaOfInterest,
                        Phone          = form.Phone,
                        Message        = form.Message
                    };

                    db.FormTable.Add(Fdb);

                    SmtpClient smtpClient = new SmtpClient();
                    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    mail.To.Add(new MailAddress(Fdb.Email));
                    mail.From    = new MailAddress("*****@*****.**", "2MD_FORM_SzSz");
                    mail.Subject = Fdb.AreaOfInterest;
                    mail.Body    = Fdb.Message + " - " + Fdb.FirstName + " " + Fdb.LastName;

                    smtpClient.Send(mail);
                    db.SaveChanges();
                    ModelState.Clear();

                    ViewBag.SuccessMessage = "Your form has been successfully submitted!";
                }
            }
            catch (Exception e)
            {
                ViewBag.SuccessMessage = "There was an error submitting your form.";
                ViewBag.Details        = e.Message;
                //throw e;
            }



            return(View("SubmitForm"));
        }
예제 #28
0
        /// <summary>
        /// 메뉴 아이템을 반환한다.
        /// </summary>
        public MenuItem SelectMenu(Guid menuId)
        {
            string procCommandName = "up_Menu_Select";

            try
            {
                var command = Connection.GetStoredProcCommand(procCommandName);
                Connection.AddInParameter(command, "MenuID", DbType.Guid, menuId);

                using (DataSet ds = Connection.ExecuteDataSet(command))
                {
                    ValidateTableCount(ds, 2);

                    MenuItem menu = null;

                    // 메뉴 정보
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        menu = MenuItem.ParseFrom(ds.Tables[0].Rows[0]);

                        // 메뉴와 매핑된 대시보드 테이블 정보
                        foreach (DataRow dr in ds.Tables[1].Rows)
                        {
                            var formTable       = FormTable.ParseFrom(dr);
                            var formTableMenuId = dr.Get <Guid>("MenuId");
                            if (formTableMenuId == menu.MenuId)
                            {
                                menu.FormTables.Add(formTable);
                            }
                            else
                            {
                                logger.Warn($"대상 메뉴 ID와 대시보드 테이블이 매핑된 메뉴의 ID가 서로 일치하지 않습니다."
                                            + $"\r\n* 대상 메뉴: {menu}"
                                            + $"\r\n* 대상 대시보드 테이블: {formTable}"
                                            + $"\r\n* 대상 대시보드 테이블이 매핑된 메뉴 ID: '{formTableMenuId}'");
                            }
                        }
                    }

                    return(menu);
                }
            }
            catch (Exception ex)
            {
                throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex);
            }
        }
        private string[,] FormatCellsToBidimensionalArray(FormTable table, int rows, int columns)
        {
            int index = 0;

            string[,] twoDimensionalArray = new string[rows, columns];

            for (int x = 0; x < rows; x++)
            {
                for (int y = 0; y < columns; y++)
                {
                    twoDimensionalArray[x, y] = table.Cells[index].Text;
                    index++;
                }
            }

            return(twoDimensionalArray);
        }
예제 #30
0
        public ActionResult CreatePost(FormTable formTable)
        {
            if (formTable.TableNameID == 0)
            {
                int FormId = formTable.Save();
                if (FormId > 0 && formTable.FormType == "FORMWITHTABLE")
                {
                    formTable.CreateTable();
                }
            }
            else
            {
                formTable.Save();
            }

            return(RedirectToAction("index"));
        }
예제 #31
0
        private void CreateDocument()
        {
            FormTable tL = new FormTable();
            tL.Columns = "50%;*";
            tL.Width = "100%";
            tL.CellPadding = 5;

            FormRow row1 = new FormRow();
            FormCell cell11 = new FormCell();
            cell11.ColSpan = 2;
            cell11.Name = "cell_11";
            row1.Cells.Add(cell11);
            tL.Rows.Add(row1);

            FormRow row2 = new FormRow();
            FormCell cell21 = new FormCell();
            FormCell cell22 = new FormCell();
            cell21.ColSpan = 1;
            cell22.ColSpan = 1;
            cell21.Name = "cell_21";
            cell22.Name = "cell_22";
            row2.Cells.Add(cell21);
            row2.Cells.Add(cell22);
            tL.Rows.Add(row2);

            FormRow row3 = new FormRow();
            FormCell cell31 = new FormCell();
            cell31.ColSpan = 2;
            cell31.Name = "cell_31";
            row3.Cells.Add(cell31);
            tL.Rows.Add(row3);

            FormSection sec1 = new FormSection();
            sec1.BorderType = 1;
            sec1.ItemIndex = 1;
            sec1.ShowLabel = true;
            sec1.Uid = "dd6acdd98240403984e561399d33d9a9";
            sec1.Labels.Add(new FormLabel("Sec1", Thread.CurrentThread.CurrentUICulture.Name));
            cell11.Sections.Add(sec1);

            FormSection sec2 = new FormSection();
            sec2.BorderType = 0;
            sec2.ItemIndex = 1;
            sec2.ShowLabel = true;
            sec2.Uid = "886cb9a3aae34e68ac8ef234d0ce8ce2";
            sec2.Labels.Add(new FormLabel("Sec2", Thread.CurrentThread.CurrentUICulture.Name));
            cell21.Sections.Add(sec2);

            FormSection sec3 = new FormSection();
            sec3.BorderType = 0;
            sec3.ItemIndex = 1;
            sec3.ShowLabel = true;
            sec3.Uid = "bb6acbb98240403784e561397b33d7a7";
            sec3.Labels.Add(new FormLabel("Sec3", Thread.CurrentThread.CurrentUICulture.Name));
            cell22.Sections.Add(sec3);

            FormSection sec4 = new FormSection();
            sec4.BorderType = 0;
            sec4.ItemIndex = 1;
            sec4.ShowLabel = true;
            sec4.Uid = Guid.NewGuid().ToString("N");
            sec4.Labels.Add(new FormLabel("Sec4", Thread.CurrentThread.CurrentUICulture.Name));
            cell31.Sections.Add(sec4);

            FormControl ctrl1 = new FormControl(FormController.SmartTableLayoutType);
            ctrl1.Columns = "50%;*";
            ctrl1.Width = "100%";
            ctrl1.CellPadding = 5;

            FormItem item1 = new FormItem();
            item1.LabelWidth = "120px";
            item1.ShowLabel = true;
            item1.Labels.Add(new FormLabel("test label1:", Thread.CurrentThread.CurrentUICulture.Name));
            item1.Uid = "9b3c4642e59b405faa2a1f38559a06cc";
            item1.RowIndex = 1;
            item1.CellIndex = 1;
            item1.RowSpan = 1;
            item1.ColSpan = 2;
            FormControl item1c = new FormControl(FormController.MetaPrimitiveControlType);
            item1c.Uid = Guid.NewGuid().ToString("N");
            item1c.Source = "Title";
            item1.Control = item1c;
            ctrl1.Items.Add(item1);

            FormItem item2 = new FormItem();
            item2.LabelWidth = "120px";
            item2.ShowLabel = true;
            item2.Labels.Add(new FormLabel("test label2:", Thread.CurrentThread.CurrentUICulture.Name));
            item2.Uid = "cafa725a31b74ad6a069e3b6446d89c0";
            item2.RowIndex = 2;
            item2.CellIndex = 1;
            item2.RowSpan = 1;
            item2.ColSpan = 1;
            FormControl item2c = new FormControl(FormController.MetaPrimitiveControlType);
            item2c.Uid = Guid.NewGuid().ToString("N");
            item2c.Source = "Priority";
            item2.Control = item2c;
            ctrl1.Items.Add(item2);

            FormItem item3 = new FormItem();
            item3.LabelWidth = "120px";
            item3.ShowLabel = true;
            item3.Labels.Add(new FormLabel("test label3:", Thread.CurrentThread.CurrentUICulture.Name));
            item3.Uid = "8d36be893c3f4cf1b5295be6853eb246";
            item3.RowIndex = 3;
            item3.CellIndex = 1;
            item3.RowSpan = 1;
            item3.ColSpan = 1;
            FormControl item3c = new FormControl(FormController.MetaPrimitiveControlType);
            item3c.Uid = Guid.NewGuid().ToString("N");
            item3c.Source = "Created";
            item3.Control = item3c;
            ctrl1.Items.Add(item3);

            FormItem item4 = new FormItem();
            item4.LabelWidth = "120px";
            item4.ShowLabel = true;
            item4.Labels.Add(new FormLabel("test label4:", Thread.CurrentThread.CurrentUICulture.Name));
            item4.Uid = "a5d87024cbf849cea5d273d77a292e6f";
            item4.RowIndex = 2;
            item4.CellIndex = 2;
            item4.RowSpan = 2;
            item4.ColSpan = 1;
            FormControl item4c = new FormControl(FormController.MetaPrimitiveControlType);
            item4c.Uid = Guid.NewGuid().ToString("N");
            item4c.Source = "Description";
            item4.Control = item4c;
            ctrl1.Items.Add(item4);

            sec1.Control = ctrl1;

            //FormDocument fd = new FormDocument();
            FormDocument fd = FormDocument.Load("Task", "[MC_BaseForm]");
            fd.MetaClassName = "Task";
            fd.Name = "[MC_BaseForm]";
            fd.FormTable = tL;
            fd.Save();
        }