Esempio n. 1
0
 /// <summary>
 /// Модель схемы данных для генерации списков xml
 /// </summary>
 /// <param name="usercontrolmass">Массив UserControl для добавления</param>
 public void AddShemeUse(UserControl[] usercontrolmass)
 {
     Shemefulllist.Add(new ShemeProperty()
     {
         Document = AddDocument.DocumentSnuOneForm(ExampleXaml.SnuOneForm), Nameshemes = "Формирование СНУ (ИНН)", Shemes = "SnuOneForm", UserContr = usercontrolmass[0]
     });
     Shemefulllist.Add(new ShemeProperty()
     {
         Document = AddDocument.DocumentSnuOneForm(ExampleXaml.TreatmentFpd), Nameshemes = "Обработка ФПД", Shemes = "TreatmentFpd", UserContr = usercontrolmass[1]
     });
     Shemefulllist.Add(new ShemeProperty()
     {
         Document = AddDocument.DocumentSnuOneForm(ExampleXaml.CollectionInn), Nameshemes = "Формирование СНУ Массово", Shemes = "FullInnCount", UserContr = usercontrolmass[2]
     });
     Shemefulllist.Add(new ShemeProperty()
     {
         Document = AddDocument.DocumentSnuOneForm(ExampleXaml.ZemlyOrImyShestvoFid), Nameshemes = "ФИД факта владения земля имущество", Shemes = "FidZorI", UserContr = usercontrolmass[0]
     });
     Shemefulllist.Add(new ShemeProperty()
     {
         Document = AddDocument.DocumentSnuOneForm(ExampleXaml.FaceFid), Nameshemes = "Фид лица", Shemes = "FidFace", UserContr = usercontrolmass[0]
     });
     Shemefulllist.Add(new ShemeProperty()
     {
         Document = AddDocument.DocumentSnuOneForm(ExampleXaml.VisualIdentId), Nameshemes = "УН запроса на визуальную идентификацию", Shemes = "IdZaprosVisual", UserContr = usercontrolmass[0]
     });
 }
        public IDocument ConvertToDocument(Page page, string domain)
        {
            var doc = new AddDocument()
            {
                Id = page.Id, Domain = domain
            };

            doc.Fields.Add(new Field("Url", page.Url.AbsoluteUri));
            doc.Fields.Add(new Field("Domain", domain));
            doc.Fields.Add(new Field("Depth", page.Depth.ToString()));
            doc.Fields.Add(new Field("Host", page.Url.Host));
            using (var memoryStream = new MemoryStream((page as BinaryPage).Data))
            {
                var extractedDoc =
                    _textExtractorService.ExtractText(new BinaryDocumentStream(page.Url.ToString(), domain, memoryStream));

                if (extractedDoc.TextExtractionException != null)
                {
                    doc.Fields.Add(new Field("ErrorMessage", extractedDoc.TextExtractionException.Message));
                    doc.Fields.Add(new Field("ErrorStackTrace", extractedDoc.TextExtractionException.StackTrace));
                }
                if (extractedDoc.ResultingDocument == null)
                {
                    return(doc);
                }
                foreach (var field in (extractedDoc.ResultingDocument as AddDocument).Fields)
                {
                    doc.Fields.Add(field);
                }
            }
            return(doc);
        }
Esempio n. 3
0
 /// <summary>
 /// Генерация схем и списков для моделей
 /// </summary>
 public void GenerateSchemes()
 {
     SchemesFullDocument.Add(new GenerateSchemesAutoModel()
     {
         Document = AddDocument.DocumentSnuOneForm(ExampleXaml.TaxArrears), SchemesName = "Схема списка для запуска БП: Взыскание задолженности", NameSchemes = "TaxArrears", DescriptionMemo = new [] { "ИНН", "КПП" }, TypeObject = typeof(TaxArrears)
     });
 }
        public void Can_add_and_patch_document()
        {
            var service  = new SolrIntegrationService(new SolrSettings());
            var document = new AddDocument("Patch_Me", "test")
            {
                Fields = new List <Field>()
                {
                    new Field("document_id", "Patch_Me"),
                    new Field("title", "Patch catch"),
                    new Field("source", "green")
                }
            };

            service.CanConnect().Should().BeTrue();
            service.HandleDocuments(new List <IDocument>()
            {
                document
            });
            var patchDoc = new PatchDocument("Patch_Me", "test")
            {
                Fields = new List <Field>()
                {
                    new Field("document_id", "Patch_Me"),
                    new Field("title", "4life"),
                    new Field("source", "red")
                }
            };

            service.HandleDocuments(new List <IDocument> {
                patchDoc
            });
        }
Esempio n. 5
0
        public ActionResult Add(AddDocument postDoc, HttpPostedFileBase DocumentPath)
        {
            if (ModelState.IsValid && (DocumentPath != null && DocumentPath.ContentLength > 0))
            {
                Document newDoc = new Document();

                newDoc.DocumentTitle = postDoc.DocumentTitle;
                newDoc.UploadDate    = DateTime.Now;
                newDoc.CompanyId     = AppSettings.CurrentCompany;
                newDoc.PageId        = (int)PagesEnum.Documents;

                /*Сохранение фото*/
                var fileName   = Path.GetFileName(DocumentPath.FileName);
                var savingPath = Path.Combine(HttpContext.Server.MapPath(priceUploadDirectory), fileName);
                DocumentPath.SaveAs(savingPath);
                newDoc.DocumentPath = VirtualPathUtility.ToAbsolute(Path.Combine(priceUploadDirectory, fileName));

                documentRepository.Insert(newDoc);
                documentRepository.SaveChanges();

                return(RedirectToAction("GetAll"));
                //throw new HttpException(403, "Forbidden");
            }
            else
            {
                return(View(postDoc));
            }
        }
        public async Task <IActionResult> UploadTemporaryFileAsync()
        {
            var         file    = HttpContext.Request.Form.Files[0];
            var         guid    = HttpContext.Request.Form["Guid"];
            AddDocument command = null;

            using (var ms = new MemoryStream())
            {
                file.CopyTo(ms);
                command = new AddDocument(file.FileName, ms.ToArray(), guid);
            }

            return(await SendAsync(command.BindId(c => c.Id), resourceId : command.Id, resource : "documents"));
        }
Esempio n. 7
0
        public static void MergeWithDocuments(this AddDocument mainDocument, IList <AddDocument> candidates, KeyValuePair <string, string> relation, string prefix)
        {
            var documentsToMerge = SelectRelevantForeignDocuments(candidates, relation.Value, mainDocument.GetFieldValue(relation.Key));
            int i = 0;

            foreach (var document in documentsToMerge)
            {
                foreach (var field in document.Fields)
                {
                    mainDocument.Fields.Add(new Field($"{prefix}{i}_{field.Name}", field.Value));
                }
                i++;
            }
        }
        public async Task return_expected_result()
        {
            //Arrange
            var document = new Document(_guid, null, null, _guid);
            var command  = new AddDocument(_guid, null, null, _guid);

            _documentRepository.Setup(r => r.AddAsync(document)).Returns(Task.CompletedTask);

            //Act
            var handler = new AddDocumentHandler(_busPublisher.Object, _documentRepository.Object, _logger.Object);
            await handler.HandleAsync(command, _context.Object);

            //Assert
            _documentRepository.Verify();
            _busPublisher.Verify();
        }
Esempio n. 9
0
        public object AddDocument(AddDocument adddoc)
        {
            dynamic TBAddDocumentResult;
            int     str = -1;

            try
            {
                AddDocResult Result = DocumentSafe.createDocument(adddoc);

                if (!string.IsNullOrEmpty(Result.ImgName))
                {
                    str = GlobalFuns.uploadDocs(adddoc.grpID, Result.ImgName, "documentsafe");
                }
                else
                {
                    str = 0;
                }

                if (Result != null)
                {
                    if (str == 0)
                    {
                        TBAddDocumentResult = new { status = "0", message = "success" };

                        //== Commented by Nandu on 01-03-2017 Task-> Cron set on server(notifiy on publish date)

                        //string url = ConfigurationManager.AppSettings["imgPath"] + "php/AddDocument.php?DocID=" + Result.docID;
                        //GroupMaster.Send(url);
                    }
                    else
                    {
                        TBAddDocumentResult = new { status = "1", message = "failed" }
                    };
                }
                else
                {
                    TBAddDocumentResult = new { status = "0", message = "Record not found" };
                }
            }
            catch
            {
                TBAddDocumentResult = new { status = "1", message = "failed" };
            }

            return(new { TBAddDocumentResult });
        }
        public void Can_add_document()
        {
            var service  = new SolrIntegrationService(new SolrSettings());
            var document = new AddDocument("magnus", "test")
            {
                Fields = new List <Field>()
                {
                    new Field("Kite", "4life")
                }
            };

            service.CanConnect().Should().BeTrue();
            service.HandleDocuments(new List <IDocument>()
            {
                document
            });
        }
    protected void OnNewActionActivated(object sender, EventArgs e)
    {
        AddDocument nd = new AddDocument(registry);

        nd.Icon         = programIcon;
        nd.TransientFor = this;
        ResponseType resp = (ResponseType)nd.Run();

        if (resp == ResponseType.Ok)
        {
            UpdateTreeView();
            UpdateCategoryComboBox();
            registry.Write();
        }

        nd.Destroy();
    }
        private void HandleAddDocument(AddDocument document)
        {
            var binaryFields = document.Fields.Where(x => x is BinaryField)
                               .Cast <BinaryField>()
                               .ToArray();

            foreach (var binaryField in binaryFields)
            {
                var extractedFields = ExtractFields(document.Id, binaryField, document.Domain);
                binaryField.Data  = new byte[0];
                binaryField.Value = "";
                foreach (var extractedField in extractedFields)
                {
                    document.Fields.Add(extractedField);
                }
            }
        }
Esempio n. 13
0
 private void HandleAddDocument(AddDocument document)
 {
     for (int index = 0; index < document.Fields.Count; index++)
     {
         var             field = document.Fields[index];
         ForeignKeyField foreignKeyField;
         if (_foreignKeys.TryGetValue(field.Name, out foreignKeyField))
         {
             document.Fields.Add(
                 new Field(ForeignKeyName, string.Format(foreignKeyField.MappingFormat, field.Value)));
             if (!string.IsNullOrWhiteSpace(foreignKeyField.JoinTargetFieldName))
             {
                 document.Fields.Add(
                     new Field(foreignKeyField.JoinTargetFieldName, string.Format(foreignKeyField.MappingFormat, field.Value)));
             }
         }
     }
 }
        private AddDocument DataRowToDocument(SqlDataReader reader, string idColumnName, string configJobName)
        {
            int idOrdinal;

            try
            {
                idOrdinal = reader.GetOrdinal(idColumnName);
            }
            catch (IndexOutOfRangeException)
            {
                Log.Logger.Error($"Encountered a data row lacking the required id column {idColumnName} ");
                return(null);
            }

            var id = reader.GetValue(idOrdinal).ToString();
            //var document = new Document(string.Format("{0}_{1}", jobSettings.DataViewSettings.ViewName, id), jobSettings.JobGroup);
            var document = new AddDocument(id, configJobName);

            for (int i = 0; i < reader.FieldCount; i++)
            {
                if (reader.IsDBNull(i))
                {
                    continue;
                }

                if (reader.GetFieldType(i).Name == "Byte[]")
                {
                    document.Fields.Add(new BinaryField(reader.GetName(i), reader.GetValue(i) as byte[]));
                }
                else if (reader.GetFieldType(i).Name == "DateTime")
                {
                    var strValue = string.IsNullOrEmpty(_commonSettings.DateTimeFormat)
                        ? reader.GetDateTime(i).ToString(CultureInfo.InvariantCulture)
                        : reader.GetDateTime(i).ToString(_commonSettings.DateTimeFormat);
                    document.Fields.Add(new Field(reader.GetName(i), strValue));
                }
                else
                {
                    document.Fields.Add(new Field(reader.GetName(i), Convert.ToString(reader.GetValue(i), CultureInfo.InvariantCulture)));
                }
            }
            return(document);
        }
Esempio n. 15
0
        public static AddDocResult createDocument(AddDocument doc)
        {
            string subgrpIDs = "";

            try
            {
                if (doc.isSubGrpAdmin == "1" && doc.docType == "0")
                {
                    subgrpIDs = SubGroupDirectory.GetAdminSubGroupList(doc.grpID, doc.memID);
                }

                MySqlParameter[] param = new MySqlParameter[12];
                param[0] = new MySqlParameter("?docID", string.IsNullOrEmpty(doc.docID) ? "0" : doc.docID);
                param[1] = new MySqlParameter("?documentType", doc.docType);
                param[2] = new MySqlParameter("?documentTitle", doc.docTitle);

                param[3] = new MySqlParameter("?docAccessType", doc.docAccessType);

                param[4] = new MySqlParameter("?memID", doc.memID);
                param[5] = new MySqlParameter("?grpID", doc.grpID);
                param[6] = new MySqlParameter("?memprofileIDs", string.IsNullOrEmpty(doc.inputIDs) ? "" : doc.inputIDs);

                param[7] = new MySqlParameter("?documentFileId", string.IsNullOrEmpty(doc.documentFileId) ? "0" : doc.documentFileId);
                param[8] = new MySqlParameter("?isSubGrpAdmin", string.IsNullOrEmpty(doc.isSubGrpAdmin)?"0":doc.isSubGrpAdmin);
                param[9] = new MySqlParameter("?subgrpIDs", subgrpIDs);

                param[10] = new MySqlParameter("?publishDate", doc.publishDate);
                param[11] = new MySqlParameter("?expiryDate", doc.expiryDate);

                using (TouchBaseWebAPI.Data.row_productionEntities context = new TouchBaseWebAPI.Data.row_productionEntities())
                {
                    context.Connection.Open();
                    var Result = context.ExecuteStoreQuery <AddDocResult>("CALL V6_USPAddDocument(?docID,?documentType,?documentTitle,?docAccessType,?memID,?grpID,?memprofileIDs,?documentFileId,?isSubGrpAdmin,?subgrpIDs,?publishDate,?expiryDate)", param).SingleOrDefault();
                    return(Result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="documentRootElementName">By default Document</param>
        /// <returns></returns>
        private AddDocument ParseDocumentElement(XElement element)
        {
            var id     = element.Attribute("Id");
            var domain = element.Attribute("Domain");

            if (id == null || domain == null)
            {
                return(null);
            }
            var document = new AddDocument(id.Value, domain.Value);
            var fields   = new List <Field>();

            foreach (var fieldElement in element.Descendants())
            {
                var fieldName  = fieldElement.Name.LocalName;
                var fieldValue = fieldElement.Value;
                fields.Add(new Field(fieldName, fieldValue));
            }

            document.Fields = fields;
            return(document);
        }
Esempio n. 17
0
        public IDocument ConvertToDocument(Page page, string category)
        {
            var webPage = page as WebPage;
            var doc     = new AddDocument()
            {
                Id = page.Id, Domain = category
            };

            doc.Fields.Add(new Field("Url", page.Url.AbsoluteUri));
            doc.Fields.Add(new Field("Domain", category));
            doc.Fields.Add(new Field("Host", page.Url.Host));
            doc.Fields.Add(new Field("Depth", page.Depth.ToString()));
            doc.Fields.Add(new Field("Html", webPage.Html));
            //foreach (var field in webPage.Metadata)
            //{
            //    field.Name = $"meta_{field.Name}";
            //    doc.Fields.Add(field);
            //}
            //doc.Fields.Add(new Field("Body",webPage.Body));

            return(doc);
        }
Esempio n. 18
0
        public static DocumentDto ToDto(this AddDocument document)
        {
            if (document == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(document.Id))
            {
                throw new MissingFieldException("A Document with no Id was passed!");
            }
            if (string.IsNullOrEmpty(document.Domain))
            {
                throw new MissingFieldException("A Document with no Domain was passed!");
            }

            return(new DocumentDto
            {
                Id = document.Id,
                Domain = document.Domain,
                Fields = document.Fields.Select(ToDto).ToList()
            });
        }
        private static XElement AddXmlElement(AddDocument document)
        {
            var doc            = new XElement("doc");
            var idFieldElement = new XElement("field", document.Id);

            idFieldElement.Add(new XAttribute("name", "id"));
            doc.Add(idFieldElement);
            foreach (var field in document.Fields)
            {
                //Solr does not handle empty fields
                if (String.IsNullOrWhiteSpace(field.Value))
                {
                    continue;
                }

                var fieldElement = new XElement("field", XmlUtils.ReplaceHexadecimalSymbols(field.Value));
                fieldElement.Add(new XAttribute("name", XmlUtils.ReplaceInvalidElementNameChars(field.Name)));
                fieldElement.Add(new XAttribute("update", "set"));
                doc.Add(fieldElement);
            }

            return(doc);
        }
        public IHttpActionResult AddADocument([FromUri] string user_email, [FromBody] AddDocument document)
        {
            if (IsTokenValid() && authenticationService.IsAllowedToAddDocument(GetTokenUserEmail(), user_email))
            {
                try
                {
                    Document     newDocument      = documentManagementService.Add(user_email, AddDocument.ToEntity(document));
                    BaseDocument modelNewDocument = BaseDocument.ToModel(newDocument);
                    documentLogger.LogModificationToDocument(modelNewDocument.Id);

                    return(CreatedAtRoute("AddDocument", new { useremail = user_email, documentid = modelNewDocument.Id }, modelNewDocument));
                }
                catch (MissingUserException e)
                {
                    return(BadRequest(e.Message));
                }
                catch (Exceptions e)
                {
                    return(BadRequest(e.Message));
                }
            }

            return(Unauthorized());
        }
        private IDocument HandleAddDocument(AddDocument document)
        {
            var softDeleteField = document.Fields.FirstOrDefault(f =>
                                                                 _hardCodedSoftDeleteNames.Any(n => n.Equals(f.Name, StringComparison.CurrentCultureIgnoreCase))
                                                                 );

            if (softDeleteField == null)
            {
                return(document);
            }
            if (string.IsNullOrEmpty(softDeleteField.Value))
            {
                return(document);
            }
            if (!_hardCodedSoftDeleteValues.Any(
                    val => val.Equals(softDeleteField.Value, StringComparison.CurrentCultureIgnoreCase)))
            {
                return(document);
            }

            Log.Debug(
                $"SoftDeletePipelineStep identified a document ({document.Id}) as soft deleted due to field '{softDeleteField.Name}'='{softDeleteField.Value}'");
            return(new DeleteDocument("IDontKnowMyDeleteFieldName_FixMePlz_WorksForHadesThough", document.Id));
        }
        public void Can_add_and_delete_document()
        {
            var service  = new SolrIntegrationService(new SolrSettings());
            var document = new AddDocument("Im_gone", "test")
            {
                Fields = new List <Field>()
                {
                    new Field("Kite", "4life")
                }
            };

            service.CanConnect().Should().BeTrue();
            service.HandleDocuments(new List <IDocument>()
            {
                document
            });

            var delDoc = new DeleteDocument(document.Id, document.Domain);

            service.HandleDocuments(new List <IDocument>()
            {
                delDoc
            });
        }