public string getRelativePath(SIEEDocument doc) { switch (mySettings.FolderHandling) { case SPOSettings.FolderHandlingType.Folder: return(normalizePath(mySettings.FolderName)); case SPOSettings.FolderHandlingType.Field: { SIEEField f = doc.Fieldlist.Where(n => n.Name == mySettings.FieldName).FirstOrDefault(); if (f != null) { return(normalizePath(f.Value)); } f = doc.AuxFields.Where(n => n.Name == mySettings.FieldName).FirstOrDefault(); if (f != null) { return(normalizePath(f.Value)); } throw new Exception($"Could not find field: {mySettings.FieldName}"); } case SPOSettings.FolderHandlingType.Auto: return(normalizePath(getAutoPath())); case SPOSettings.FolderHandlingType.None: default: return(string.Empty); } }
public override void ExportDocument(SIEESettings settings, SIEEDocument document, string name, SIEEFieldlist fieldlist) { List <SqlColumn> columns = new List <SqlColumn>(); foreach (ColumnDescription colDes in mySettings.Columns.Where(n => n.SqlTypeName != null)) { SqlColumn col = new SqlColumn() { Name = colDes.Name, SqlType = SqlTypes.GetSqlType(colDes.SqlTypeName), IsDocument = colDes.IsDocument, }; if (colDes.IsDocument) { col.ValueString = document.PDFFileName; } else { SIEEField f = fieldlist.Where(n => n.ExternalId == colDes.Name).FirstOrDefault(); col.ValueString = f == null ? null : f.Value; } columns.Add(col); } try { sqlClient.SetObjectValues(columns); } catch (Exception e) { document.NonRecoverableError = true; throw e; } sqlClient.Insert(columns); }
private object convert(CMISSettings settings, SIEEField field) { List <CMISProperty> props = settings.Properties.Where(n => n.Id == field.ExternalId).ToList(); if (props == null || props.Count == 0) { return(field.Value); } return(props.First().ConvertValue(field, clientCulture)); }
public object ConvertValue(SIEEField field, CultureInfo cultureInfo) { switch (Type) { case CMISClientType.Boolean: { return(convert <bool>(convertBool, field, cultureInfo)); } case CMISClientType.DateTime: { return(convert <DateTime>(convertDateTime, field, cultureInfo)); } case CMISClientType.Decimal: { return(convert <Decimal>(convertDecimal, field, cultureInfo)); } case CMISClientType.Integer: { return(convert <Int32>(convertInteger, field, cultureInfo)); } default: { return(convert <string>(convertString, field, cultureInfo)); } } }
private SIEEBatch createBatch(string filename, string docName) { SIEEField field = new SIEEField() { Name = "SomeField", ExternalId = "SomeField", Value = "SomeValue" }; SIEEFieldlist fieldlist = new SIEEFieldlist(); fieldlist.Add(field); SIEEDocument document = new SIEEDocument(); document.PDFFileName = filename; document.InputFileName = docName; document.BatchId = "4711"; document.DocumentId = "0"; document.Fieldlist = fieldlist; SIEEBatch batch = new SIEEBatch(); batch.Add(document); return(batch); }
private object convert <T>(converType converter, SIEEField field, CultureInfo cultureInfo) { List <T> resultList = new List <T>(); if (!IsMulti) { return(converter(field.Value, cultureInfo)); } if (field.Cardinality == 0 || field.ValueList.Count == 0) { resultList.Add((T)converter(field.Value, cultureInfo)); } else { foreach (string s in field.ValueList) { resultList.Add((T)converter(s, cultureInfo)); } } return(resultList); }
public void T09_PropertyConverter() { CultureInfo ci = new CultureInfo("en-US"); object o; CMISProperty prop = new CMISProperty(); prop.Type = CMISClientType.Integer; SIEEField field = new SIEEField(); field.Value = "42"; List <string> valueList = new List <string>() { "2", "", "3", null }; field.ValueList = valueList; // Default, take value o = prop.ConvertValue(field, ci); Assert.IsTrue(o is Int32); Assert.AreEqual(42, o); // IsMulti alone, no list prop.IsMulti = true; field.ValueList = new List <string>(); o = prop.ConvertValue(field, ci); Assert.IsTrue(o is List <Int32>); Assert.AreEqual(1, (o as List <Int32>).Count); Assert.AreEqual(42, (o as List <Int32>)[0]); // IsMulti with list field.ValueList = valueList; o = prop.ConvertValue(field, ci); Assert.IsTrue(o is List <Int32>); Assert.AreEqual(1, (o as List <Int32>).Count); Assert.AreEqual(42, (o as List <Int32>)[0]); // Now create list field.Cardinality = -1; o = prop.ConvertValue(field, ci); Assert.IsTrue(o is List <Int32>); Assert.AreEqual(4, (o as List <Int32>).Count); Assert.AreEqual(2, (o as List <Int32>)[0]); Assert.AreEqual(0, (o as List <Int32>)[1]); Assert.AreEqual(3, (o as List <Int32>)[2]); Assert.AreEqual(0, (o as List <Int32>)[3]); // Check Boolean prop.IsMulti = false; prop.Type = CMISClientType.Boolean; field.Value = "true"; o = prop.ConvertValue(field, ci); Assert.AreEqual(true, o); field.Value = null; o = prop.ConvertValue(field, ci); Assert.AreEqual(false, o); // Check DateTime prop.IsMulti = false; prop.Type = CMISClientType.DateTime; DateTime dt = DateTime.Now; field.Value = dt.ToString(ci); o = prop.ConvertValue(field, ci); Assert.AreEqual(dt.ToString(), o.ToString()); field.Value = null; o = prop.ConvertValue(field, ci); Assert.AreEqual(dt.ToString(), o.ToString()); // Check Decimal prop.IsMulti = false; prop.Type = CMISClientType.Decimal; field.Value = "5.6"; o = prop.ConvertValue(field, ci); Assert.AreEqual((Decimal)5.6, o); field.Value = null; o = prop.ConvertValue(field, ci); Assert.AreEqual((Decimal)0.0, o); }