Beispiel #1
0
        public void InstantiateDocumentFieldWithSelectionMarkAndNoValue()
        {
            var field = new DocumentField(DocumentFieldType.SelectionMark);

            Assert.AreEqual(DocumentFieldType.SelectionMark, field.ValueType);
            Assert.Throws <InvalidOperationException>(() => field.AsSelectionMarkState());
        }
Beispiel #2
0
        public bool IsDuplicableTo(Guid documentTypeId)
        {
            DocumentField df         = DictionaryMapper.Instance.GetDocumentField(this.DocumentFieldId);
            DocumentType  dstDocType = DictionaryMapper.Instance.GetDocumentType(documentTypeId);

            return(df.DuplicateAction != DuplicatedAttributeAction.NoDuplicate && dstDocType.CanHaveAttribute(df.Name, df.Id.Value));
        }
Beispiel #3
0
        public void InstantiateDocumentFieldWithSignatureTypeAndNoValue()
        {
            var field = new DocumentField(DocumentFieldType.Signature);

            Assert.AreEqual(DocumentFieldType.Signature, field.ValueType);
            Assert.Throws <InvalidOperationException>(() => field.AsSignatureType());
        }
Beispiel #4
0
        private KeyValuePair <string, object> GenerateField(DocumentField fieldSchema)
        {
            var field = new KeyValuePair <string, object>();

            switch (fieldSchema.FieldType)
            {
            case FieldType.String:
                var stringField = (StringField)fieldSchema;
                field = new KeyValuePair <string, object>(stringField.FieldName, GenerateString(stringField.Length, stringField.PossibleValues));
                break;

            case FieldType.Integer:
                var integerField = (IntegerField)fieldSchema;
                field = new KeyValuePair <string, object>(integerField.FieldName, GenerateInteger(integerField.Min, integerField.Max));
                break;

            case FieldType.Float:
                var floatField = (FloatField)fieldSchema;
                field = new KeyValuePair <string, object>(floatField.FieldName, GenerateFloat(floatField.Min, floatField.Max));
                break;

            case FieldType.Date:
                var dateField = (DateField)fieldSchema;
                field = new KeyValuePair <string, object>(dateField.FieldName, GenerateDate(dateField.Lower, dateField.Upper));
                break;
            }

            return(field);
        }
        /// <summary>
        /// Saves changes of current <see cref="BusinessObject"/> to the operations list.
        /// </summary>
        /// <param name="document">Xml document containing operation list to execute.</param>
        public override void SaveChanges(XDocument document)
        {
            if (this.Id == null)
            {
                this.GenerateId();
            }

            if (this.Status != BusinessObjectStatus.Unchanged && this.Status != BusinessObjectStatus.Unknown)
            {
                DocumentField field = DictionaryMapper.Instance.GetDocumentField(this.DocumentFieldId);

                string parentIdColumnName = null;

                if (this.Parent.BOType == BusinessObjectType.CommercialDocumentLine)
                {
                    parentIdColumnName = "commercialDocumentLineId";
                }
                else if (this.Parent.BOType == BusinessObjectType.WarehouseDocumentLine)
                {
                    parentIdColumnName = "warehouseDocumentLineId";
                }

                Dictionary <string, object> forcedToSave = new Dictionary <string, object>();

                forcedToSave.Add(parentIdColumnName, this.Parent.Id.ToUpperString());

                BusinessObjectHelper.SaveBusinessObjectChanges(this, document, forcedToSave, field.Metadata.Element("dataType").Value);
            }
        }
        private DocumentViewTypeViewModel BuildFieldViewModel(DocumentViewTypeViewModel model, Document selected, string name)
        {
            DocumentField field = selected.Fields.Where(f => HtmlHelper.RouteFriendlyName(f.FieldName) == name).FirstOrDefault();

            if (field == null)
                return null;

            model.TypeName = field.FieldName;
            model.Value = field.Value;
            model.ShortDescription = field.ShortDescription;
            model.LongDescription = field.LongDescription;
            model.Summary = field.Summary;

            foreach (DocumentExample item in field.Examples)
            {
                model.ExampleUseage += $"<p>{item.Text}</p>";
            }

            foreach (DocumentException exception in field.Exception)
            {
                model.Exceptions += $"<p>{exception.ExceptionName}<br />{exception.Summary}";
            }

            model.Remarks = field.Remarks;

            return model;
        }
Beispiel #7
0
        public void InstantiateDocumentFieldWithInt64AndNoValue()
        {
            var field = new DocumentField(DocumentFieldType.Int64);

            Assert.AreEqual(DocumentFieldType.Int64, field.ValueType);
            Assert.Throws <InvalidOperationException>(() => field.AsInt64());
        }
        protected void ValidateDocumentFields(Document document, DocumentFields documentFields)
        {
            foreach (Signer signer in document.Signers)
            {
                foreach (Field field in signer.Fields)
                {
                    // assert that all fields from all signers in document (document.getSigners()) can be found
                    // in documentFields.getDocumentFields()
                    DocumentField documentField = FindDocumentField(field.ApiId, documentFields);
                    Assert.NotNull(documentField);
                    // and all their attributes are equal
                    Assert.Equal(field.Page, documentField.Page);
                    Assert.Equal(field.Type, documentField.Type);
                    Assert.Equal(field.Label, documentField.Label);
                    Assert.Equal(field.Required, documentField.Required);
                    Assert.Equal(field.GroupId, documentField.GroupId);
                    Assert.Equal(field.ReadOnly, documentField.ReadOnly);
                    Assert.Equal(field.Content, documentField.Content);
                }

                foreach (ExistingField field in signer.ExistingFields)
                {
                    DocumentField documentField = FindDocumentField(field.ApiId, documentFields);
                    Assert.NotNull(documentField);
                    // and all their attributes are equal
                    Assert.Equal(field.Label, documentField.Label);
                    Assert.Equal(field.Required, documentField.Required);
                    Assert.Equal(field.ReadOnly, documentField.ReadOnly);
                    Assert.Equal(field.Content, documentField.Content);
                }
            }
        }
        public void SaveDocumentField(DocumentField documentField)
        {
            var session = GetSession();

            session.BeginTransaction();
            session.SaveOrUpdate(documentField);
            session.Transaction.Commit();
        }
 /// <summary>
 /// Converts the document field to field result.
 /// </summary>
 /// <param name="docField">The doc field.</param>
 /// <returns></returns>
 private static FieldResult ConvertDocumentFieldToFieldResult(DocumentField docField)
 {
     var newField = new FieldResult
     {
         Name = docField.FieldName,
         Value = docField.Value,
         ID = Convert.ToInt32(docField.Id),
         DataTypeId = Convert.ToInt32(docField.Type)
     };
     return newField;
 }
Beispiel #11
0
        public void CreateDocumentField(int documentId, int fieldId)
        {
            var document = DocumentService.GetdocumentById(documentId);
            var field    = FieldService.GetFieldById(fieldId);

            DocumentField documentField = new DocumentField();

            documentField.Document = document;
            documentField.Field    = field;

            DocumentFieldDataAccess.SaveDocumentField(documentField);
        }
Beispiel #12
0
        /// <summary>
        /// Converts the document field to field result.
        /// </summary>
        /// <param name="docField">The doc field.</param>
        /// <returns></returns>
        private static FieldResult ConvertDocumentFieldToFieldResult(DocumentField docField)
        {
            var newField = new FieldResult
            {
                Name       = docField.FieldName,
                Value      = docField.Value,
                ID         = Convert.ToInt32(docField.Id),
                DataTypeId = Convert.ToInt32(docField.Type)
            };

            return(newField);
        }
        private void PushSelected(DocumentField field, Tuple <PointF, PointF, PointF, PointF> box)
        {
            if (field == DocumentField.NULL)
            {
                return;
            }

            if (!this._boxes.ContainsKey(field))
            {
                this._boxes.Add(field, box);
            }
        }
Beispiel #14
0
 /// <summary>
 /// Recursively creates new children (BusinessObjects) and loads settings from provided xml.
 /// </summary>
 /// <param name="element">Xml element to attach.</param>
 public override void Deserialize(XElement element)
 {
     base.Deserialize(element);
     #region Add current datetime for booldate attributes with '?' value
     if (this.Value == null || System.String.IsNullOrEmpty(this.Value.Value) || this.Value.Value == "?")
     {
         DocumentField df = DictionaryMapper.Instance.GetDocumentField(this.DocumentFieldId);
         if (df.DataType == DataType.BoolDate)
         {
             this.Value.Value = SessionManager.VolatileElements.CurrentDateTime.ToIsoString();
         }
     }
     #endregion
 }
Beispiel #15
0
        private static List <XElement> ShiftDuplicableAttributesList(XElement shiftDbXml)
        {
            List <XElement> result = new List <XElement>();

            foreach (XElement documentAttrValueElement in shiftDbXml.Element("documentAttrValue").Elements("entry"))
            {
                DocumentField df = DictionaryMapper.Instance.GetDocumentField(new Guid(documentAttrValueElement.Element(XmlName.DocumentFieldId).Value));
                if (df.ShiftDuplicateAction != DuplicatedAttributeAction.NoDuplicate)
                {
                    result.Add(DuplicableAttributeFactory.ConvertAttributeFromDbToBoXmlFormat(documentAttrValueElement, df.DataType));
                }
            }
            return(result);
        }
        public static Tuple <float, float, float, float> GetFieldDimension(DocumentField field)
        {
            switch (field)
            {
            //case DocumentField.NULL:
            //    break;
            case DocumentField.TEM_CPF:
                return(new Tuple <float, float, float, float>(5f, 4f, 0f, 0f));

            case DocumentField.ESTRANGEIRO:
                return(new Tuple <float, float, float, float>(2f, 4f, 0f, 0f));

            case DocumentField.PROFISSIONAL_SAUDE:
                return(new Tuple <float, float, float, float>(5f, 4f, -3f, 0f));

            case DocumentField.PROFISSIONAL_SEGURANCA:
                return(new Tuple <float, float, float, float>(4f, 4f, -2f, 0f));

            case DocumentField.SEXO:
                return(new Tuple <float, float, float, float>(8f, 4f, 0f, 0f));

            case DocumentField.RACA:
                return(new Tuple <float, float, float, float>(9.4f, 4f, 0f, 0f));

            case DocumentField.SINTOMAS:
                return(new Tuple <float, float, float, float>(5.4f, 4f, 0f, 0f));

            case DocumentField.CONDICOES:
                return(new Tuple <float, float, float, float>(12.0f, 5f, 0f, 0f));

            case DocumentField.ESTADO_TESTE:
                return(new Tuple <float, float, float, float>(5f, 8f, -1.9f, 0f));

            case DocumentField.TIPO_TESTE:
                return(new Tuple <float, float, float, float>(7f, 8f, -1.9f, 0f));

            case DocumentField.RESULTADO_TESTE:
                return(new Tuple <float, float, float, float>(2f, 5f, 0f, 0f));

            case DocumentField.CLASSIFICACAO_FINAL:
                return(new Tuple <float, float, float, float>(6f, 6f, 0f, 0f));

            case DocumentField.EVOLUCAO_CASO:
                return(new Tuple <float, float, float, float>(5f, 6f, 0f, 0f));

            default:
                break;
            }
            return(new Tuple <float, float, float, float>(1f, 1f, 0f, 0f));
        }
Beispiel #17
0
 public object Deserialize(string str)
 {
     stackVariable0 = new DocumentField();
     if (!String.IsNullOrEmpty(str))
     {
         stackVariable5 = new Guid?(new Guid(str));
     }
     else
     {
         V_0            = null;
         stackVariable5 = V_0;
     }
     stackVariable0.set_Id(stackVariable5);
     return(stackVariable0);
 }
Beispiel #18
0
        //istniejący obiekt
        public static void DuplicateShiftAttributes(XElement source, Document destination)
        {
            var attrsToDuplicate = DuplicableAttributeFactory.ShiftDuplicableAttributesList(source);

            if (attrsToDuplicate.Count > 0)
            {
                foreach (XElement attrToDuplicate in attrsToDuplicate)
                {
                    string            documentFieldId   = attrToDuplicate.Element(XmlName.DocumentFieldId).Value;
                    DocumentField     documentField     = DictionaryMapper.Instance.GetDocumentField(new Guid(documentFieldId));
                    DocumentFieldName documentFieldName = documentField.TypeName;
                    DocumentAttrValue destAttr          = destination.Attributes.GetOrCreateNew(documentFieldName);
                    destAttr.Value = new XElement(XmlName.Value, attrToDuplicate.Element(XmlName.Value).Nodes());
                }
            }
        }
Beispiel #19
0
            public object GetValueByOriName(string field)
            {
                if (curRow >= 0 && curRow < values.Count)
                {
                    if (DocumentField.Equals(field))
                    {
                        return(values[curRow]);
                    }
                    else if (IDField.Equals(field))
                    {
                        return(values[curRow][IDField]);
                    }
                }

                return(DBNull.Value);
            }
        private DocumentViewTypeViewModel BuildFieldViewModel(DocumentViewTypeViewModel model, Document selected, string name)
        {
            DocumentField field = selected.Fields.Where(f => HtmlHelper.RouteFriendlyName(f.FieldName) == name).FirstOrDefault();

            if (field == null)
            {
                return(null);
            }

            model.TypeName         = field.FieldName;
            model.Value            = field.Value;
            model.ShortDescription = field.ShortDescription;
            model.LongDescription  = field.LongDescription;
            model.Summary          = field.Summary;

            return(model);
        }
        private MLModels.ModelOutput AplicarModelosML(Document documento, DocumentField field, string model)
        {
            if (documento.CropedFields.ContainsKey(field))
            {
                var    id   = ObjectId.Parse(documento.CropedFields[field]);
                string path = CreateLocalFile(id);

                _logger.LogWarning($"Croped boxes loaded!");

                var result = this.Predict(new MLModels.ModelInput
                {
                    ImageSource = path
                }, model);
                return(result);
            }
            _logger.LogWarning($"No croped boxes found!");
            return(null);
        }
Beispiel #22
0
        /// <summary>
        /// Converts Fractus Attribute from db to bo xml format
        /// </summary>
        /// <param name="boAttributeElement">Result attributte element</param>
        /// <param name="srcAttrElement">Source attribute field element</param>
        /// <param name="srcAttrEntryElement">Source attributte entry</patram>
        public static XElement ConvertAttributeFromDbToBoXmlFormat(XElement boAttributeElement, XElement srcAttrElement, XElement srcAttrEntryElement)
        {
            if (!VariableColumnName.IsVariableColumnName(srcAttrElement.Name.LocalName))
            {
                boAttributeElement.Add(srcAttrElement);                 //auto-cloning
            }
            else
            {
                DocumentField cf = DictionaryMapper.Instance.GetDocumentField(new Guid(srcAttrEntryElement.Element(XmlName.DocumentFieldId).Value));

                string dataType = cf.DataType;

                if (dataType != DataType.Xml)
                {
                    boAttributeElement.Add(new XElement(XmlName.Value, BusinessObjectHelper.ConvertAttributeValueForSpecifiedDataType(srcAttrElement.Value, dataType)));
                }
                else
                {
                    boAttributeElement.Add(new XElement(XmlName.Value, srcAttrElement.Elements()));
                }
            }
            return(boAttributeElement);
        }
 public BaseResponse <DocumentField> AddDocumentFieldSystem(DocumentField model)
 {
     return(documentService.AddDocumentFieldSystem(model));
 }
 public BaseResponse <DocumentField> Update(DocumentField model)
 {
     return(documentService.UpdateDocumentField(model));
 }
        public static void SaveUpload(string NameField, string IsSearch, int CategoryId, string Category, string FailedMessageKey = null, string fileName = null)
        {
            //insert và upload documentField, documentAttribute.
            List <HttpPostedFileBase> listFile = new List <HttpPostedFileBase>();

            if (System.Web.HttpContext.Current.Session["file"] != null)
            {
                listFile = (List <HttpPostedFileBase>)System.Web.HttpContext.Current.Session["file"];
            }

            DocumentFieldRepository DocumentFieldRepository = new DocumentFieldRepository(new Domain.Staff.ErpStaffDbContext());

            DocumentAttributeRepository DocumentAttributeRepository = new DocumentAttributeRepository(new Domain.Staff.ErpStaffDbContext());

            if (listFile.Count > 0)
            {
                var DocumentField = new DocumentField();

                DocumentField.IsDeleted      = false;
                DocumentField.CreatedUserId  = WebSecurity.CurrentUserId;
                DocumentField.ModifiedUserId = WebSecurity.CurrentUserId;
                DocumentField.AssignedUserId = WebSecurity.CurrentUserId;
                DocumentField.CreatedDate    = DateTime.Now;
                DocumentField.ModifiedDate   = DateTime.Now;
                DocumentField.Name           = NameField;
                //  DocumentField.DocumentTypeId = DocumentTypeId;
                DocumentField.IsSearch   = IsSearch;
                DocumentField.Category   = Category;
                DocumentField.CategoryId = CategoryId;
                DocumentFieldRepository.InsertDocumentField(DocumentField);
                var prefix = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_DocumentField");
                DocumentField.Code = Erp.BackOffice.Helpers.Common.GetCode(prefix, DocumentField.Id);
                DocumentFieldRepository.UpdateDocumentField(DocumentField);
                int dem = 0;
                foreach (var item in listFile)
                {
                    dem = dem + 1;
                    var type              = item.FileName.Split('.').Last();
                    var FileName          = DocumentField.Name.Replace(" ", "_");
                    var name              = Erp.BackOffice.Helpers.Common.ChuyenThanhKhongDau(FileName).ToLower();
                    var DocumentAttribute = new DocumentAttribute();
                    DocumentAttribute.IsDeleted      = false;
                    DocumentAttribute.CreatedUserId  = WebSecurity.CurrentUserId;
                    DocumentAttribute.ModifiedUserId = WebSecurity.CurrentUserId;
                    DocumentAttribute.AssignedUserId = WebSecurity.CurrentUserId;
                    DocumentAttribute.CreatedDate    = DateTime.Now;
                    DocumentAttribute.ModifiedDate   = DateTime.Now;
                    DocumentAttribute.OrderNo        = dem;
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        DocumentAttribute.File = fileName + "(" + DocumentField.Id + "_" + DocumentAttribute.OrderNo + ")" + "." + type;
                    }
                    else
                    {
                        DocumentAttribute.File = name + "(" + DocumentField.Id + "_" + DocumentAttribute.OrderNo + ")" + "." + type;
                    }
                    DocumentAttribute.Size            = item.ContentLength.ToString();
                    DocumentAttribute.TypeFile        = type;
                    DocumentAttribute.DocumentFieldId = DocumentField.Id;
                    DocumentAttributeRepository.InsertDocumentAttribute(DocumentAttribute);
                    var  path     = System.Web.HttpContext.Current.Server.MapPath("~" + Helpers.Common.GetSetting(Category));
                    bool isExists = System.IO.Directory.Exists(path);
                    if (!isExists)
                    {
                        System.IO.Directory.CreateDirectory(path);
                    }
                    item.SaveAs(path + DocumentAttribute.File);
                }
            }
            else
            {
                FailedMessageKey = "Vui lòng chụp ảnh!";
            }
        }
Beispiel #26
0
        /// <summary>
        /// Validates the collection.
        /// </summary>
        public override void Validate()
        {
            //check for forbidden document featues
            foreach (DocumentAttrValue attribute in this.Children)
            {
                DocumentField df = DictionaryMapper.Instance.GetDocumentField(attribute.DocumentFieldId);

                if (df.Name.StartsWith("DocumentFeature_", StringComparison.Ordinal))
                {
                    DocumentType dt = DictionaryMapper.Instance.GetDocumentType(((Document)this.Parent).DocumentTypeId);

                    bool exists = false;

                    IEnumerable <XElement> allowedDocumentFeatures = null;

                    if (this.Parent.BOType == BusinessObjectType.CommercialDocument)
                    {
                        allowedDocumentFeatures = dt.CommercialDocumentOptions.DocumentFeatures.Elements();
                    }
                    else if (this.Parent.BOType == BusinessObjectType.WarehouseDocument)
                    {
                        allowedDocumentFeatures = dt.WarehouseDocumentOptions.DocumentFeatures.Elements();
                    }
                    else if (this.Parent.BOType == BusinessObjectType.FinancialDocument)
                    {
                        allowedDocumentFeatures = dt.FinancialDocumentOptions.DocumentFeatures.Elements();
                    }

                    if (allowedDocumentFeatures != null)
                    {
                        foreach (XElement id in allowedDocumentFeatures)
                        {
                            if (attribute.DocumentFieldId == new Guid(id.Value))
                            {
                                exists = true;
                                break;
                            }
                        }

                        if (!exists)
                        {
                            string featureName = BusinessObjectHelper.GetBusinessObjectLabelInUserLanguage(DictionaryMapper.Instance.GetDocumentField(attribute.DocumentFieldId)).Value;
                            throw new ClientException(ClientExceptionId.DocumentFeatureForbidden, null, "documentFeatureName:" + featureName);
                        }
                    }
                }

                var count = this.Children.Where(c => c.DocumentFieldId == attribute.DocumentFieldId && c != attribute).Count();

                if (count > 0)
                {
                    var field = DictionaryMapper.Instance.GetDocumentField(attribute.DocumentFieldId);

                    if (field.Metadata.Element("allowMultiple") == null)
                    {
                        throw new ClientException(ClientExceptionId.SingleAttributeMultipled, null, "name:" + BusinessObjectHelper.GetBusinessObjectLabelInUserLanguage(field).Value);
                    }
                }
            }

            base.Validate();
        }
Beispiel #27
0
        public void CreateLabourContract(vwLabourContract model)
        {
            // var branch = branchRepository.GetvwBranchById(model.StaffbranchId.Value);
            // var staff = staffRepository.GetStaffsById(model.StaffId.Value);
            // string filePath = Server.MapPath("~/Data/LabourContract.html");

            // string strOutput = System.IO.File.ReadAllText(filePath, Encoding.UTF8);
            //// thông tin bên A
            // strOutput = strOutput.Replace("#ApprovedUserName#", model.ApprovedUserName);
            // strOutput = strOutput.Replace("#ApprovedUserPositionName#", model.ApprovedUserPositionName);
            // strOutput = strOutput.Replace("#ApprovedBranchName#", model.ApprovedBranchName);
            // strOutput = strOutput.Replace("#ApprovedPhoneBranch#", branch.Phone);
            // strOutput = strOutput.Replace("#ApprovedBranchAddress#", branch.Address+" - "+branch.WardName+" - "+branch.DistrictName+" - " +branch.ProvinceName);
            // strOutput = strOutput.Replace("#StaffName#", model.StaffName);
            // strOutput = strOutput.Replace("#StaffBirthday#", model.StaffBirthday.Value.ToString("dd/MM/yyyy"));
            // strOutput = strOutput.Replace("#Job#", staff.Technique);
            // strOutput = strOutput.Replace("#StaffAddress#", model.StaffAddress);
            // strOutput = strOutput.Replace("#StaffWard#", model.StaffWard);
            // strOutput = strOutput.Replace("#StaffDistrict#", model.StaffDistrict);
            // strOutput = strOutput.Replace("#StaffProvince#", model.StaffProvince);
            // //thông tin bên B
            // strOutput = strOutput.Replace("#StaffIdCardNumber#", model.StaffIdCardNumber);
            // strOutput = strOutput.Replace("#StaffIdCardDate#", model.StaffIdCardDate.Value.ToString("dd/MM/yyyy"));
            // strOutput = strOutput.Replace("#StaffCardIssuedName#", model.StaffCardIssuedName);
            // strOutput = strOutput.Replace("#ContractTypeName#", model.ContractTypeName);
            // strOutput = strOutput.Replace("#EffectiveDate#", model.EffectiveDate.Value.ToString("dd/MM/yyyy"));
            // strOutput = strOutput.Replace("#ExpiryDate#", model.ExpiryDate.Value.ToString("dd/MM/yyyy"));
            // strOutput = strOutput.Replace("#FormWork#", model.FormWork);
            // strOutput = strOutput.Replace("#WageAgreement#", Erp.BackOffice.Helpers.Common.PhanCachHangNgan(model.WageAgreement));
            // strOutput = strOutput.Replace("#StaffPositionName#", model.StaffPositionName);
            // strOutput = strOutput.Replace("#Content#", model.Content);
            // strOutput = strOutput.Replace("#Code#", model.Code);
            // strOutput = strOutput.Replace("#SignedDay.Date#", model.SignedDay.Value.ToString("dd"));
            // strOutput = strOutput.Replace("#SignedDay.Month#", model.SignedDay.Value.ToString("MM"));
            // strOutput = strOutput.Replace("#SignedDay.Year#", model.SignedDay.Value.ToString("yyyy"));
            // strOutput = strOutput.Replace("#Name#", model.Name);
            //strOutput = strOutput.Replace("#Place#", contract.Place);
            //strOutput = strOutput.Replace("#Day#", contract.CreatedDate.Value.Day.ToString());
            //strOutput = strOutput.Replace("#Month#", contract.CreatedDate.Value.Month.ToString());
            //strOutput = strOutput.Replace("#Year#", contract.CreatedDate.Value.Year.ToString());

            //lưu thông tin dữ liệu vào database
            //lưu document field

            var DocumentField = new DocumentField();

            DocumentField.IsDeleted      = false;
            DocumentField.CreatedUserId  = WebSecurity.CurrentUserId;
            DocumentField.ModifiedUserId = WebSecurity.CurrentUserId;
            DocumentField.AssignedUserId = WebSecurity.CurrentUserId;
            DocumentField.CreatedDate    = DateTime.Now;
            DocumentField.ModifiedDate   = DateTime.Now;
            DocumentField.Name           = model.Code;
            DocumentField.DocumentTypeId = 9;
            // DocumentField.IsSearch = "";
            DocumentField.Category   = "LabourContract";
            DocumentField.CategoryId = model.Id;
            DocumentFieldRepository.InsertDocumentField(DocumentField);
            var prefix = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_DocumentField");

            DocumentField.Code = Erp.BackOffice.Helpers.Common.GetCode(prefix, DocumentField.Id);
            DocumentFieldRepository.UpdateDocumentField(DocumentField);
            // lưu dữ liệu thành file word
            var    originalDirectory = new DirectoryInfo(string.Format("{0}Files\\somefiles", System.Web.HttpContext.Current.Server.MapPath(@"\")));
            string pathString        = System.IO.Path.Combine(originalDirectory.ToString(), "DocumentAttribute");
            bool   isExists          = System.IO.Directory.Exists(pathString);

            if (!isExists)
            {
                System.IO.Directory.CreateDirectory(pathString);
            }
            var name = model.Code + "(" + DocumentField.Id + ")" + ".doc";
            var path = string.Format("{0}\\{1}", pathString, name);

            System.IO.File.WriteAllText(path, model.Content);
            //lưu documentAttribute
            var DocumentAttribute = new DocumentAttribute();

            DocumentAttribute.IsDeleted      = false;
            DocumentAttribute.CreatedUserId  = WebSecurity.CurrentUserId;
            DocumentAttribute.ModifiedUserId = WebSecurity.CurrentUserId;
            DocumentAttribute.AssignedUserId = WebSecurity.CurrentUserId;
            DocumentAttribute.CreatedDate    = DateTime.Now;
            DocumentAttribute.ModifiedDate   = DateTime.Now;
            DocumentAttribute.OrderNo        = 1;
            DocumentAttribute.File           = name;
            byte[] str = System.IO.File.ReadAllBytes(path);
            DocumentAttribute.Size            = str.Length.ToString();
            DocumentAttribute.TypeFile        = "doc";
            DocumentAttribute.DocumentFieldId = DocumentField.Id;
            DocumentAttributeRepository.InsertDocumentAttribute(DocumentAttribute);
        }
Beispiel #28
0
 private static string GetFacetLabel(DocumentField field)
 {
     return(StringResourceSystemFacade.ParseString(field.Label));
 }
Beispiel #29
0
        private void SaveDocument()
        {
            UpdateDocumentFieldsList();
            foreach (KeyValuePair <String, String> keyPair in documentFields)
            {
                DocumentField df = new DocumentField();
                df.FillData(GlobalVariables.CurrentCompany.CompanyGUID, CurrentDocumentGUID, keyPair.Key, keyPair.Value);
                df.Delete();
                df.Save();
            }

            if (CurrentDocument == null)
            {
                DocumentTemplate dt = documentTemplateList.Where(t => t.DocumentTemplateGUID == CurrentDocumentTemplateGUID).First();
                CurrentDocument = new Document();

                /*if (dt.DocumentEndDate == "Y")
                 * {
                 *  DocumentEndDateTimeChooser dedt = new DocumentEndDateTimeChooser(CurrentDocument);
                 *  dedt.ShowDialog();
                 * }*/
                if (fieldValueList.ContainsKey("DataWygasniecia"))
                {
                    foreach (KeyValuePair <String, String> keyVal in fieldValueList)
                    {
                        if (keyVal.Key == "DataWygasniecia" && keyVal.Value != null)
                        {
                            try
                            {
                                CurrentDocument.DocumentEndDateTime = DateTime.Parse(keyVal.Value);
                            }
                            catch { }
                        }
                    }
                    //CurrentDocument.DocumentEndDateTime = if(fieldValueList.TryGetValue("DataWygasniecia")
                }

                CurrentDocument.FillData(GlobalVariables.CurrentCompany.CompanyGUID
                                         , CurrentDocumentGUID
                                         , dt.DocumentName
                                         , dt.DocumentText
                                         , DateTime.Now
                                         , GlobalVariables.CurrentUser.UserGUID
                                         , DateTime.Now
                                         , GlobalVariables.CurrentUser.UserGUID
                                         , DateTime.Now
                                         , CurrentDocument.DocumentEndDateTime);

                CurrentDocument.Save();
            }
            else
            {
                if (CurrentDocument is Document)
                {
                    DocumentTemplate dt = documentTemplateList.Where(t => t.DocumentTemplateGUID == CurrentDocumentTemplateGUID).First();
                    if (dt.DocumentEndDate == "Y")
                    {
                        DocumentEndDateTimeChooser dedt = new DocumentEndDateTimeChooser(CurrentDocument);
                        dedt.ShowDialog();
                    }

                    ((Document)CurrentDocument).LastModifiedBy       = GlobalVariables.CurrentUser.UserGUID;
                    ((Document)CurrentDocument).LastModifiedDateTime = DateTime.Now;

                    CurrentDocument.Update();
                }
            }
            DocumentSaved = true;
        }
        public async Task AnalyzeWithCustomModelFromFileAsync()
        {
            string endpoint        = TestEnvironment.Endpoint;
            string apiKey          = TestEnvironment.ApiKey;
            Uri    trainingFileUri = new Uri(TestEnvironment.BlobContainerSasUrl);

            // Firstly, create a custom built model we can use to recognize the custom document. Please note
            // that models can also be built using a graphical user interface such as the Form Recognizer
            // Labeling Tool found here:
            // https://aka.ms/azsdk/formrecognizer/labelingtool

            var adminClient = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
            BuildModelOperation buildOperation = await adminClient.StartBuildModelAsync(trainingFileUri);

            await buildOperation.WaitForCompletionAsync();

            DocumentModel customModel = buildOperation.Value;

            // Proceed with the custom document recognition.

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

            #region Snippet:FormRecognizerAnalyzeWithCustomModelFromFileAsync
#if SNIPPET
            string modelId  = "<modelId>";
            string filePath = "<filePath>";
#else
            string filePath = DocumentAnalysisTestEnvironment.CreatePath("Form_1.jpg");
            string modelId  = customModel.ModelId;
#endif

            using var stream = new FileStream(filePath, FileMode.Open);

            AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentAsync(modelId, stream);

            await operation.WaitForCompletionAsync();

            AnalyzeResult result = operation.Value;

            Console.WriteLine($"Document was analyzed with model with ID: {result.ModelId}");

            foreach (AnalyzedDocument document in result.Documents)
            {
                Console.WriteLine($"Document of type: {document.DocType}");

                foreach (KeyValuePair <string, DocumentField> fieldKvp in document.Fields)
                {
                    string        fieldName = fieldKvp.Key;
                    DocumentField field     = fieldKvp.Value;

                    Console.WriteLine($"Field '{fieldName}': ");

                    Console.WriteLine($"  Content: '{field.Content}'");
                    Console.WriteLine($"  Confidence: '{field.Confidence}'");
                }
            }
            #endregion

            // Iterate over lines and selection marks on each page
            foreach (DocumentPage page in result.Pages)
            {
                Console.WriteLine($"Lines found on page {page.PageNumber}");
                foreach (var line in page.Lines)
                {
                    Console.WriteLine($"  {line.Content}");
                }

                Console.WriteLine($"Selection marks found on page {page.PageNumber}");
                foreach (var selectionMark in page.SelectionMarks)
                {
                    Console.WriteLine($"  Selection mark is '{selectionMark.State}' with confidence {selectionMark.Confidence}");
                }
            }

            // Iterate over the document tables
            for (int i = 0; i < result.Tables.Count; i++)
            {
                Console.WriteLine($"Table {i + 1}");
                foreach (var cell in result.Tables[i].Cells)
                {
                    Console.WriteLine($"  Cell[{cell.RowIndex}][{cell.ColumnIndex}] has content '{cell.Content}' with kind '{cell.Kind}'");
                }
            }

            // Delete the model on completion to clean environment.
            await adminClient.DeleteModelAsync(customModel.ModelId);
        }
Beispiel #31
0
 public void OnDDLFormDocumentUploadFailed(DocumentField p0, Java.Lang.Exception p1)
 {
     Android.Util.Log.Debug("DDLFormScreenlet", $"DDLForm document uploaded failed: {p0}");
 }