private IRecord GetRecordFromTableRow(IRecordType recordType, object[] row, ISchema schema) { IRecord record = new Record(recordType); foreach (var field in recordType.Fields) { var column = schema.GetField(field.Name); if (column != null && column.Type == field.Type.UnterlyingDotNetType) { int fieldPosition = schema.GetFieldPosition(field.Name); IValue value = new TypedValue(field.Type, row[fieldPosition]); record.SetFieldValue(field.Name, value); } } return(record); }
public static void SetDeleteNow(this Record record, bool value = true) { record.SetFieldValue(new FieldDefinition(record.Database, "DeleteNow"), new UserFieldValue(value)); }
public static void SetDriveId(this Record record, string id) { record.SetFieldValue(new FieldDefinition(record.Database, "DriveID"), new UserFieldValue(id)); }
static void ProcessProperty(string Name) { TrimApplication.Initialize(); using (Database db = new Database()) { db.Id = "10"; //db.WorkgroupServerName = "https://SCDB98:9443"; db.Connect(); //Console.WriteLine("DB test: " + db.CurrentUser.Name); // JsonSerializer s = new JsonSerializer(); try { T1Property t1 = null; using (StreamReader sr = new StreamReader(Name)) { using (JsonTextReader reader = new JsonTextReader(sr)) { //T1Integration t1 = new T1Integration(); t1 = (T1Property)s.Deserialize(reader, typeof(T1Property)); } } if (t1 != null) { FieldDefinition fdPropertyAddress = new FieldDefinition(db, 502); if (t1.EddieUri == 0) { RecordType rt = new RecordType(db, 1); Record rec = new Record(rt); FieldDefinition fdPropertyNo = new FieldDefinition(db, 504); rec.Title = "Property folder - " + t1.PropertyNumber.ToString(); rec.SetFieldValue(fdPropertyNo, new UserFieldValue(t1.PropertyNumber)); rec.SetFieldValue(fdPropertyAddress, new UserFieldValue(t1.PropertyAddress)); Classification c = new Classification(db, 2616); rec.Classification = c; Location loc = new Location(db, 43); rec.SetAssignee(loc); //rec.assig rec.Save(); t1.EddieUri = rec.Uri; t1.EddieRecordUrl = rec.WebURL; Console.WriteLine("New property record created ok - number: " + rec.Number); } else { //RecordType rt = new RecordType(db, 2); Record rec = new Record(db, t1.EddieUri); //Record cont = new Record(db, t1.lEddieUri); //rec.Container = cont; //rec.Title = "Application - " + t1.ApplicationNo; //if (t1.propertyLoc != null) //{ // rec.SetDocument(t1.propertyLoc); //} rec.SetFieldValue(fdPropertyAddress, new UserFieldValue(t1.PropertyAddress)); rec.Save(); //t1.EddieUri = rec.Uri; t1.EddieRecordUrl = rec.WebURL; Console.WriteLine("Property record upgrades - number: " + rec.Number); } using (StreamWriter sw = new StreamWriter(pathout + "T1 property - "+t1.PropertyNumber.ToString()+".txt")) { using (JsonWriter writer = new JsonTextWriter(sw)) { s.Serialize(writer, t1); Console.WriteLine("Property file returned"); } }; FileInfo f = new FileInfo(Name); if (f.Exists) f.Delete(); } } catch (Exception exp) { Console.WriteLine("Error: " + exp.Message.ToString()); throw; } } }