Esempio n. 1
0
        private void UploadDocument()
        {
            var putDocumentParams = new PutDocumentParams(long.Parse(txtDocumentTypeId.Text));

            var compassNumberKWT = new KeywordType(136, "", typeof(string), "");
            var ssnKWT = new KeywordType(103, "", typeof(string), "");
            var firstNameKWT = new KeywordType(104, "", typeof(string), "");
            var lastNameKWT = new KeywordType(105, "", typeof(string), "");

            putDocumentParams.Keywords.Add(new Keyword(compassNumberKWT, txtCompassNumber.Text));
            putDocumentParams.Keywords.Add(new Keyword(ssnKWT, txtSSN.Text));
            putDocumentParams.Keywords.Add(new Keyword(firstNameKWT, txtFirstName.Text));
            putDocumentParams.Keywords.Add(new Keyword(lastNameKWT, txtLastName.Text));

            var multipartContent = new MultipartFormDataContent();

            var searlizedPutDocumentMetadata = JsonConvert.SerializeObject(putDocumentParams, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });

            multipartContent.Add(new StringContent(searlizedPutDocumentMetadata, Encoding.UTF8, "application/json"), "PutDocumentParams");

            var sw = new Stopwatch();
            sw.Start();

            var counter = 1;
            foreach (var fileName in Directory.GetFiles(txtImagesFolderPath.Text))
            {
                var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                multipartContent.Add(new StreamContent(fs), "File" + counter, Path.GetFileName(fileName));
                counter++;
            }

            try
            {
                using (var response = new HttpClient().PostAsync("http://localhost/CompassDataBroker/api/Document/UploadFile", multipartContent).Result)
                {
                    var responseContent = response.Content.ReadAsStringAsync().Result;

                    sw.Stop();

                    MessageBox.Show(String.Format("Document Id: {0} \nCompleted in {1} seconds", responseContent, sw.Elapsed.TotalSeconds));

                    Trace.Write(responseContent);
                }
            }
            catch (Exception ex)
            {
                sw.Stop();
                throw;
            }
        }
Esempio n. 2
0
        public string CreateDocument(PutDocumentParams @params, List<string> filePaths)
        {
            var storeDocProperties = App.Core.Storage.CreateStoreNewDocumentProperties(
                  App.Core.DocumentTypes.Find(@params.DocumentTypeId), App.Core.FileTypes.Find(ImageFileFormatId));

            @params.Keywords.OrEmptyIfNull().ForEach(x =>
                {
                    var hylandKeywordType = App.Core.KeywordTypes.Find(x.KeywordType.Id);
                    storeDocProperties.AddKeyword(HylandKeywordFrom(x, hylandKeywordType));
                });

            storeDocProperties.DocumentDate = DateTime.Now;
            storeDocProperties.Comment = "This is a comment";
            storeDocProperties.Options = StoreDocumentOptions.SkipWorkflow;

            return App.Core.Storage.StoreNewDocument(filePaths, storeDocProperties).ID.ToString();
        }
Esempio n. 3
0
 public string CreateDocument(PutDocumentParams @params, List<String> filePaths)
 {
     return _model.CreateDocument(@params, filePaths);
 }