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 Keywords GetKeywords(string documentId)
        {
            var keywords = new Keywords();

            var uDocument = App.Core.GetDocumentByID(long.Parse(documentId));

            foreach (KeywordRecord uKeywordRecord in uDocument.KeywordRecords.Where(x => x.KeywordRecordType.RecordType != RecordType.MultiInstance))
            {
                foreach (Keyword uKeyword in uKeywordRecord.Keywords)
                {
                    var keywordType = new KeywordType(uKeyword.KeywordType.ID,
                                                      uKeyword.KeywordType.Name,
                                                      GetSystemTypeFromUnityType(uKeyword.KeywordType.DataType),
                                                      uKeyword.KeywordType.DefaultValue);
                    ObjectLibrary.Keyword keyword = null;
                    switch (uKeyword.KeywordType.DataType)
                    {
                    case KeywordDataType.AlphaNumeric:
                        keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.AlphaNumericValue);
                        break;

                    case KeywordDataType.Currency:
                    case KeywordDataType.SpecificCurrency:
                        keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.CurrencyValue);
                        break;

                    case KeywordDataType.Date:
                    case KeywordDataType.DateTime:
                        keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.DateTimeValue);
                        break;

                    case KeywordDataType.FloatingPoint:
                        keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.FloatingPointValue);
                        break;

                    case KeywordDataType.Numeric20:
                        keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.Numeric20Value);
                        break;

                    case KeywordDataType.Numeric9:
                        keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.Numeric9Value);
                        break;
                    }
                    keywords.Add(keyword);
                }
            }

            return(keywords);
        }
Esempio n. 3
0
        public Keywords GetKeywords(string documentId)
        {
            var keywords = new Keywords();

            var uDocument = App.Core.GetDocumentByID(long.Parse(documentId));
            foreach (KeywordRecord uKeywordRecord in uDocument.KeywordRecords.Where(x => x.KeywordRecordType.RecordType != RecordType.MultiInstance))
            {
                foreach (Keyword uKeyword in uKeywordRecord.Keywords)
                {
                    var keywordType = new KeywordType(uKeyword.KeywordType.ID,
                                                                    uKeyword.KeywordType.Name,
                                                                    GetSystemTypeFromUnityType(uKeyword.KeywordType.DataType),
                                                                    uKeyword.KeywordType.DefaultValue);
                    ObjectLibrary.Keyword keyword = null;
                    switch (uKeyword.KeywordType.DataType)
                    {
                        case KeywordDataType.AlphaNumeric:
                            keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.AlphaNumericValue);
                            break;
                        case KeywordDataType.Currency:
                        case KeywordDataType.SpecificCurrency:
                            keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.CurrencyValue);
                            break;
                        case KeywordDataType.Date:
                        case KeywordDataType.DateTime:
                            keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.DateTimeValue);
                            break;
                        case KeywordDataType.FloatingPoint:
                            keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.FloatingPointValue);
                            break;
                        case KeywordDataType.Numeric20:
                            keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.Numeric20Value);
                            break;
                        case KeywordDataType.Numeric9:
                            keyword = new ObjectLibrary.Keyword(keywordType, uKeyword.Numeric9Value);
                            break;
                    }
                    keywords.Add(keyword);
                }
            }

            return keywords;
        }
Esempio n. 4
0
 public Keyword(KeywordType keywordType, decimal value)
 {
     KeywordType = keywordType;
     DecimalValue = value;
 }
Esempio n. 5
0
 public Keyword(KeywordType keywordType, double value)
 {
     KeywordType = keywordType;
     DoubleValue = value;
 }
Esempio n. 6
0
 public Keyword(KeywordType keywordType, long value)
 {
     KeywordType = keywordType;
     LongValue = value;
 }
Esempio n. 7
0
 public Keyword(KeywordType keywordType, int value)
 {
     KeywordType = keywordType;
     IntValue = value;
 }
Esempio n. 8
0
 public Keyword(KeywordType keywordType, DateTime value)
 {
     KeywordType = keywordType;
     DateTimeValue = value;
 }
Esempio n. 9
0
 public Keyword(KeywordType keywordType, string value)
 {
     KeywordType = keywordType;
     StringValue = value;
 }
Esempio n. 10
0
        private void DisplayKeywordType(KeywordType kwt)
        {
            txtResult.Clear();

            txtResult.Text += String.Format("Id: {0}, Name: {1}, Data Type:{2}, Default Value: {3}{4}", kwt.Id, kwt.Name, kwt.DataTypeString, kwt.DefaultValue, Environment.NewLine);
        }
Esempio n. 11
0
 public Keyword(KeywordType keywordType, decimal value)
 {
     KeywordType  = keywordType;
     DecimalValue = value;
 }
Esempio n. 12
0
 public Keyword(KeywordType keywordType, double value)
 {
     KeywordType = keywordType;
     DoubleValue = value;
 }
Esempio n. 13
0
 public Keyword(KeywordType keywordType, long value)
 {
     KeywordType = keywordType;
     LongValue   = value;
 }
Esempio n. 14
0
 public Keyword(KeywordType keywordType, int value)
 {
     KeywordType = keywordType;
     IntValue    = value;
 }
Esempio n. 15
0
 public Keyword(KeywordType keywordType, DateTime value)
 {
     KeywordType   = keywordType;
     DateTimeValue = value;
 }
Esempio n. 16
0
 public Keyword(KeywordType keywordType, string value)
 {
     KeywordType = keywordType;
     StringValue = value;
 }