public object Post(CommitRequest request) { // Locate record by URI long uri = request.Uri; if (uri <= 0) { throw new ApplicationException($"Invalid URI: {uri}"); } Record record = new Record(Database, uri); Location trimUser = Database.CurrentUser; Location checkedOutTo = record.CheckedOutTo; string checkoutPath = record.CheckedOutPath; // Abort if not checked out to current user. if (checkedOutTo == null || (checkedOutTo != null && checkedOutTo.Uri != trimUser.Uri)) { throw new ApplicationException("Document is not checked out to requesting user."); } if (!checkoutPath.StartsWith(SHARED_DIR)) { throw new ApplicationException("Document is not checked out to the shared path."); } if (!System.IO.File.Exists(checkoutPath)) { throw new ApplicationException($"Document is already checked out to '{trimUser.Name}' but working copy can't be found in expected location '{checkoutPath}' on server."); } // Electronic document was found. Now update revision, check in document and return response. InputDocument inpDoc = new InputDocument(checkoutPath); inpDoc.CheckinAs = Path.GetFileName(record.ESource); // Preserve original file name when checking back in record.SetDocument(inpDoc, request.NewRevision, request.KeepCheckedOut, request.Comments); record.Save(); // Calling record.SetCheckedOutPath(WEBDAV_CHECKOUT_PATH) below prevents the new revision from being saved, so save the record first. if (request.KeepCheckedOut) { // SetDocument overrides checkedoutpath, so call this function to set it back to how we want it and save the record again // TODO - ask Rory why it works this way record.SetCheckedOutPath(checkoutPath); record.Save(); } // Remove document from webdav if checking back in if (!request.KeepCheckedOut) { File.Delete(checkoutPath); } return(new CommitResponse()); }
public void UpdateRecord() { Record r = this.table.NewRecord(); r[intColumn] = 1; r.Save(); r[intColumn] = 2; r.Save(); Assert.AreEqual(2, r[intColumn]); }
public void CommitTransaction() { Record r = this.table.NewRecord(); r[intColumn] = 1; r.Save(); Transaction trx = this.connection.BeginTransaction(); r[intColumn] = 2; r.Save(); trx.Commit(); Assert.AreEqual(2, r[intColumn]); }
public void AutomaticallyRollbackTransaction() { Record r = this.table.NewRecord(); r[intColumn] = 1; r.Save(); using (Transaction trx = this.connection.BeginTransaction()) { r[intColumn] = 2; r.Save(); } Assert.AreEqual(1, r[intColumn]); }
public void RollbackTransaction() { Record r = this.table.NewRecord(); r[intColumn] = 1; r.Save(); Transaction trx = this.connection.BeginTransaction(); r[intColumn] = 2; r.Save(); trx.Rollback(); Assert.AreEqual(1, r[intColumn]); }
internal void ResetDeleteNow(OneDriveDocument doc) { Record record = new Record(database, doc.Uri); record.SetDeleteNow(false); record.Save(); }
public static bool RemoveOcrRendition(this Record record) { bool removed = false; for (uint i = 0; i < record.ChildRenditions.Count; i++) { RecordRendition rendition = record.ChildRenditions.getItem(i) as RecordRendition; if ((RecordRendition)rendition != null && rendition.TypeOfRendition == RenditionType.Ocr) { Log.Debug($"Remove Rendition {rendition.Uri} from Record {record.Uri}"); rendition.Delete(); removed = true; } } if (removed) { record.Save(); Log.Info($"Removed Ocr rendition from record {record.Uri}"); } else { Log.Info($"No Ocr Rendition on record {record.Uri}"); } return(removed); }
public ActionResult Create(string newRecord, string newArtist) { Record firstRecord = new Record(newRecord, newArtist); firstRecord.Save(); return(RedirectToAction("Index")); }
public IActionResult NewRegistration() { Contacts contact = Regs.Contact; contact.DateOfBirth = DateTime.Now.AddYears(0 - Convert.ToInt32(contact.Age)); contact.Save(HttpContext); CommunityUnit unit = new CommunityUnit(); string[] tokens = Regs.Unit.Split(' '); if (!string.IsNullOrEmpty(Regs.Unit) && tokens.Length > 1) { int.TryParse(tokens[0], out int idnt); unit.Id = idnt; } Referee referee = new Referee(); tokens = Regs.Referee.Split(' '); if (!string.IsNullOrEmpty(Regs.Referee) && tokens.Length > 1) { int.TryParse(tokens[0], out int idnt); referee.Id = idnt; } Facility facility = new Facility(); tokens = Regs.Facility.Split(' '); if (!string.IsNullOrEmpty(Regs.Facility) && tokens.Length > 1) { int.TryParse(tokens[0], out int idnt); facility.Id = idnt; } Record record = Regs.Record; record.Contact = contact; record.Referee = referee; record.Unit = unit; record.Save(HttpContext); Screening screen = Regs.Screen; screen.Record = record; screen.Save(HttpContext); Appointment appointment = Regs.Appointment; appointment.Contact = contact; appointment.Facility = facility; appointment.Source = new AppointmentSource { Id = 1 }; appointment.Service = new AppointmentService { Id = 1 }; appointment.Save(HttpContext); return(LocalRedirect("/contacts/")); }
internal void ClearDriveId(OneDriveDocument doc) { Record record = new Record(database, doc.Uri); record.SetDriveId(""); record.Save(); }
public void Run() { _running = true; try { OriginHistory history = _origin.StartBatch(_folder); foreach (string file in scanFolder(_folder)) { Record record = _origin.NewRecord(history); // We need to call this to trigger the Origin functionality to create a new folder // and put this Record in the folder _origin.AllocateContainer(record); record.SetDocument(file); record.Save(); File.Delete(file); } } finally { _running = false; } }
public static async Task CheckinFromDrive(this Record record, string driveId, string token, bool saveRecord = false) { string downloadUrl = GraphApiHelper.GetOneDriveItemContentIdUrl(driveId); var fileResult = await ODataHelper.GetItem <OneDriveItem>(GraphApiHelper.GetOneDriveItemIdUrl(driveId), token, null); string filePath = Path.Combine(TrimApplication.WebServerWorkPath, fileResult.Name); await ODataHelper.GetItem <string>(downloadUrl, token, filePath); var inputDocument = new InputDocument(filePath); inputDocument.CheckinAs = record.SuggestedFileName; record.SetDocument(inputDocument, true, false, "checkin from Word Online"); string pdfPath = Path.Combine(TrimApplication.WebServerWorkPath, Path.ChangeExtension(fileResult.Name, "pdf")); string pdfUrl = GraphApiHelper.GetOneDriveItemContentIdUrl(driveId, "pdf"); await ODataHelper.GetItem <string>(pdfUrl, token, pdfPath); var rendition = record.ChildRenditions.NewRendition(pdfPath, RenditionType.Longevity, "Preview"); if (saveRecord) { record.Save(); File.Delete(filePath); File.Delete(pdfPath); } return; }
public void GetAllByArtist_JennyHancock_TwoRecords() { string recordTitle1 = "Thrust"; string recordArtist = "Herbie Hancock"; string recordTitle2 = "Save Me"; string recordArtist2 = "Jenny Hancock"; string recordTitle3 = "Save Me Again"; string recordArtist3 = "Jenny Hancock"; Record newRecord1 = new Record(recordTitle1, recordArtist); newRecord1.Save(); Record newRecord2 = new Record(recordTitle2, recordArtist2); newRecord2.Save(); Record newRecord3 = new Record(recordTitle3, recordArtist3); newRecord3.Save(); List <Record> expected = new List <Record> { newRecord2, newRecord3 }; List <Record> result = Record.GetAllByArtist("Jenny Hancock"); CollectionAssert.AreEqual(expected, result); }
public static bool RealRemove(List <string> packageList) { //start recorder var recorder = new Record(); recorder.Init(); foreach (var item in packageList) { Console.WriteLine(I18N.Core("Remove_Removing", item)); var res = ScriptInvoker.Core(Information.WorkPath.Enter("cache").Enter("installed").Enter(item).Path, ScriptInvoker.InvokeMethod.Remove, ""); if (!res.status) { ConsoleAssistance.WriteLine(I18N.Core("General_ScriptError"), ConsoleColor.Red); ConsoleAssistance.WriteLine(res.desc, ConsoleColor.Red); return(false); } Directory.Delete(Information.WorkPath.Enter("cache").Enter("installed").Enter(item).Path, true); recorder.Remove(item); Console.WriteLine(I18N.Core("Remove_Success", item)); } recorder.Save(); return(true); }
public void TestNonFluentUpdateInterface() { using (Connection connection = Esent.CreateDatabase(this.database)) using (Transaction transaction = connection.BeginTransaction()) { Table table = connection.CreateTable("mytable"); table.CreateColumn(new ColumnDefinition("autoinc", ColumnType.Int32) { IsAutoincrement = true }); table.CreateColumn(new ColumnDefinition("myint", ColumnType.Int32)); table.CreateColumn(new ColumnDefinition("mystring", ColumnType.Text) { MaxSize = 200 }); Record record = table.NewRecord(); record["myint"] = 5; record["mystring"] = "hello"; record.Save(); transaction.Commit(); } using (Connection connection = Esent.OpenDatabase(this.database, DatabaseOpenMode.ReadOnly)) { Table table = connection.OpenTable("mytable"); Record record = table.First(); Assert.AreEqual(1, record["autoinc"]); Assert.AreEqual(5, record["myint"]); Assert.AreEqual("hello", record["mystring"]); } }
public async System.Threading.Tasks.Task <RecordDocument> Post(RecordDocument recordDocument) { // string result = await Request.Content.ReadAsStringAsync(); string userUPN = await GetUser(); string fileName = Path.Combine("c:\\junk", "WordAddin", $"{Guid.NewGuid()}.docx"); using (var file = File.Create(fileName)) { file.Write(recordDocument.Data, 0, recordDocument.Data.Length); file.Close(); } long uri; if (Int64.TryParse(GetCustomProperty(fileName, "CM_Record_Uri"), out uri)) { using (Database db = getDatabase(userUPN)) { Record record = new Record(db, uri); // byte[] data = Convert.FromBase64String(result); record.SetDocument(new InputDocument(fileName), true, recordDocument.KeepBookedOut, null); record.Save(); File.Delete(fileName); return(new RecordDocument(record)); } } throw new ApplicationException($"Error with document"); }
public async Task <object> Post(DriveFileOperation request) { string token = await getToken(); RegisterFileResponse response = new RegisterFileResponse(); Record record = new Record(this.Database, request.Uri); string driveId = record.ExternalReference; var registeredFile = new RegisterdFileResponse() { Id = driveId }; request.Action = request.Action ?? ""; if (request.Action.IndexOf("AddToFavorites", StringComparison.InvariantCultureIgnoreCase) > -1) { record.AddToFavorites(); } if (request.Action.IndexOf("RemoveFromFavorites", StringComparison.InvariantCultureIgnoreCase) > -1) { record.RemoveFromFavorites(); } if (request.Action.IndexOf("checkin", StringComparison.InvariantCultureIgnoreCase) > -1) { var driveDetails = await ODataHelper.GetItem <string>(GraphApiHelper.GetOneDriveItemContentIdUrl(driveId), token); record.SetDocument(new InputDocument(driveDetails), true, false, "checkin from Word Online"); } if (request.Action.IndexOf("delete", StringComparison.InvariantCultureIgnoreCase) > -1) { await ODataHelper.DeleteWithToken(GraphApiHelper.GetOneDriveItemIdUrl(driveId), token); record.ExternalReference = ""; } if (request.Action.IndexOf("finalize", StringComparison.InvariantCultureIgnoreCase) > -1) { record.SetAsFinal(false); } record.Save(); updateFromRecord(registeredFile, record); response.Results = new List <RegisterdFileResponse>() { registeredFile }; return(response); }
public void SetLongColumnToMinValue() { Record r = this.table.NewRecord(); r["long"] = long.MinValue; r.Save(); Assert.AreEqual(long.MinValue, r["long"]); }
public void SetDoubleColumnFromString() { Record r = this.table.NewRecord(); r["double"] = Math.PI; r.Save(); Assert.AreEqual(Math.PI, r["double"]); }
public void SetFloatColumnToMinValue() { Record r = this.table.NewRecord(); r["float"] = float.MinValue; r.Save(); Assert.AreEqual(float.MinValue, r["float"]); }
private void Button_Click(object sender, RoutedEventArgs e) { Record record = new Record(_database, 9000000000); if (HP.HPTRIM.SDK.PropertyEditor.EditModal(GetDesktopWindow(), record)) { record.Save(); } }
/// <summary> /// Set and retrieve a null value in a column. /// </summary> /// <param name="column">The column to set.</param> private void SetAndRetrieveNullValue(string column) { Record r = this.table.NewRecord(); r[column] = null; r.Save(); Assert.IsNull(r[column]); }
public void SetBinaryColumnToZeroLengthArray() { Record r = this.table.NewRecord(); r["binary"] = new byte[0]; r.Save(); CollectionAssert.AreEqual(new byte[0], (byte[])r["binary"]); }
public void SetAsciiTextColumnToInt() { Record r = this.table.NewRecord(); r["asciitext"] = 123; r.Save(); Assert.AreEqual("123", r["asciitext"]); }
public void SetAsciiTextColumnToEmptyString() { Record r = this.table.NewRecord(); r["asciitext"] = string.Empty; r.Save(); Assert.AreEqual(string.Empty, r["asciitext"]); }
public void SetTextColumnToInt() { Record r = this.table.NewRecord(); r["text"] = 1024; r.Save(); Assert.AreEqual("1024", r["text"]); }
public void SetLongColumnFromString() { Record r = this.table.NewRecord(); r["long"] = "999"; r.Save(); Assert.AreEqual((long)999, r["long"]); }
public void SetDoubleColumnToMinValue() { Record r = this.table.NewRecord(); r["double"] = double.MinValue; r.Save(); Assert.AreEqual(double.MinValue, r["double"]); }
public void SetUintColumnFromString() { Record r = this.table.NewRecord(); r["uint"] = "999"; r.Save(); Assert.AreEqual((uint)999, r["uint"]); }
public async Task <object> Get(OpenFile request) { if (request.Uri < 1) { throw new Exception("Invalid Uri"); } var response = new OpenFileResponse(); var record = new Record(this.Database, request.Uri); string token = await getToken(); string driveId = record.ExternalReference; OneDriveItem fileResult = null; if (!string.IsNullOrWhiteSpace(driveId)) { fileResult = await ODataHelper.GetItem <OneDriveItem>(GraphApiHelper.GetOneDriveItemIdUrl(driveId), token, null); response.WebUrl = fileResult.WebUrl; } else if (record.IsElectronic) { string folderId = string.Empty; try { var documentFolder = await ODataHelper.PostFolder <OneDriveItem>(GraphApiHelper.GetOneDriveChildrenUrl(), token); folderId = documentFolder.Id; if (!record.IsDocumentInClientCache) { record.LoadDocumentIntoClientCache(); } var fileItem = await ODataHelper.PostFile <OneDriveItem>(GraphApiHelper.GetOneDriveFileUploadUrl(folderId, record.SuggestedFileName), token, record.DocumentPathInClientCache); record.ExternalReference = fileItem.Id; record.Save(); record.GetDocument(null, true, null, null); response.WebUrl = fileItem.WebUrl; } catch { throw; } } else { throw new Exception("Record is not a valid document."); } return(response); }
private static void AddRecord(Record record, CoubTarget target, string tempFile) { record.AddNew(); record.Classifications.Add(new Adam.Core.Classifications.ClassificationPath("/Cubus/Coub")); record.Fields.GetField<TextField>("Name").SetValue(target.Name); record.Fields.GetField<TextField>("Author").SetValue(target.Author); record.Fields.GetField<TextField>("Description").SetValue(target.Description); record.Files.AddFile(tempFile); record.Save(); }
private void ChangeClassification(Application app, Record record, string classificationPath, string ancestorName="MonkeysCast") { if (string.IsNullOrEmpty(classificationPath)) return; var classification = new Classification(app); string searchExpression = string.Format("Ancestor.Name = '{0}' AND Name='{1}'", ancestorName, classificationPath.Trim()); if (classification.TryLoad(new SearchExpression(searchExpression)) == TryLoadResult.Success) { record.Classifications.RemoveAll(); record.Classifications.Add(classification.Id); record.Save(); } }
private static void Migrate() { string connectionString = "Data Source=yfdev.cloudapp.net;Initial Catalog=SCC_ECM;Persist Security Info=True;User ID=EPL;Password=Password1!"; using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); using (SqlCommand command = new SqlCommand("SELECT top 25 * FROM View_1", con)) using (SqlDataReader reader = command.ExecuteReader()) { using (Database db = new Database()) { db.Id = "03"; db.Connect(); while (reader.Read()) { RecordType rt = new RecordType(db, 16); Record rCont = GetFolderUri(reader.GetString(6), reader.GetString(7), db); if (rCont != null) { Record r = new Record(rt); r.Container = rCont; r.LongNumber = reader.GetInt32(0).ToString(); r.Title = reader.GetString(1); r.DateCreated = (TrimDateTime)reader.GetDateTime(2); string loc = "D:\\" + reader.GetString(3); if (File.Exists(loc)) { InputDocument id = new InputDocument(loc); r.SetDocument(id, false, false, "Migrated from ECM t1"); } r.Save(); Console.WriteLine("Record Created: " + r.Number); } else { Console.WriteLine("Could not find folder"); } } } } } }
public override void ProcessEvent(Database db, TrimEvent evt) { if(evt.ObjectType == BaseObjectTypes.Record) { if (evt.EventType == Events.ObjectAdded) { try { Record rec = new Record(db, evt.ObjectUri); if (rec.IsElectronic) { var docdetails = rec.ESource; //string Location = "C:\\Program Files\\hello.txt"; string FileName = docdetails.Substring(docdetails.LastIndexOf('\\') + 1); // int fileExtPos = FileName.LastIndexOf("."); if (fileExtPos >= 0) FileName = FileName.Substring(0, fileExtPos); var rectitle = rec.Title; if (rectitle != FileName) { rec.Title = FileName; } rec.SetNotes("Notes added: DocDetails: " + FileName + " RecTitle: " + rectitle, NotesUpdateType.PrependWithNewLine); rec.Save(); db.LogExternalEvent("Successful template title change.", BaseObjectTypes.Record, evt.ObjectUri, true); } } catch (Exception exp) { db.LogExternalEvent("Template title change error - "+exp.Message.ToString(), BaseObjectTypes.Record, evt.ObjectUri, true); } } } }
static void BuildRMpersonalFolders(Location loc) { TrimApplication.Initialize(); try { using (Database db = new Database()) { db.Id = "03"; db.Connect(); RecordType rt = new RecordType(db, 7); Record r = new Record(rt); r.Client = loc; r.Title = "Personal Workspace"; //r.Assignee = loc; //r.HomeLocation = loc; TrimAccessControlList ackk = r.AccessControlList; ackk.SetPrivate((int)RecordAccess.ViewRecord, loc); r.AccessControlList = ackk; //Classification cl = new Classification(db, 501); //r.Classification = cl; // //r.SecurityProfile. r.Save(); //r.AddToFavorites(); } } catch(Exception exp) { Loggitt(exp.Message.ToString(), "Error creating Personal workspace - "+loc.Uri.ToString()); } }
private static object findmessagid(FileInfo f) { string msgid = null; using(Database db = new Database()) { RecordType rt = new RecordType(db, 3); Record r = new Record(rt); r.Container = new Record(db, 172739); r.Title = f.Name; r.SetDocument(f.FullName); r.Save(); msgid = r.MessageId; r.Delete(); } return msgid; }
private void AddRecord(string path, Guid clId, Dictionary<string, string> descriptions) { var record = new Record(app); record.AddNew(); record.Files.AddFile(path); record.Classifications.Add(clId); Language language = new Language(app); foreach(var item in descriptions) { language.Load(item.Key); Guid id = language.Id; record.Fields.GetField<TextField>("AlexanderChechet_multi", id).SetValue(item.Value); } record.Save(); }
private static long CreateNewRMSubFolder(long conturi, string str5, Database db) { long uri = 0; Record rCont = new Record(db, conturi); RecordType rtsub = new RecordType(db, 5); Record rsub = new Record(rtsub); rsub.Title = str5; rsub.Container = rCont; rsub.SetAssignee(rCont.Assignee); rsub.Save(); uri = rsub.Uri; return uri; }
private static long CreateNewRMfolder(string str4, long classification, Database db) { long uri = 0; Classification objclas = new Classification(db, classification); long clasUri = objclas.Uri; RecordType rt = new RecordType(db, 1); Record r = new Record(rt); Classification c = new Classification(db, clasUri); //Location lo = new Location(db, 5503); //r.OwnerLocation = lo; //r.SetAssignee(lo); r.Classification = c; r.Title = str4; r.Save(); uri = r.Uri; return uri; }
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; } } }
private static long CreateNewRMRecord(string FileLoc, long cont, Database db) { long uri = 0; string newtitle = null; try { if (File.Exists(FileLoc)) { RecordType rt = null; // Console.WriteLine("Document location: " + FileLoc); string strExt = Path.GetExtension(FileLoc); switch (strExt) { //Documents case ".PDF": case ".pdf": case ".DOC": case ".doc": case ".XLS": case ".xls": case ".DOCX": case ".docx": case ".XLSX": case ".xlsx": case ".ppt": case ".PPT": case ".pptx": case ".PPTX": case ".DOTX": case ".dotx": case ".TXT": case ".txt": case ".CSV": case ".csv": case ".PUB": case ".pub": case ".HTML": case ".html": case ".HTM": case ".htm": case ".DWG": case ".dwg": case ".RTF": case ".rtf": case ".XLSM": case ".xlsm": case ".MP4": case ".mp4": case ".DOT": case ".dot": case ".VSD": case ".vsd": case ".ZIP": case ".zip": case ".PSD": case ".psd": case ".RDL": case ".rdl": case ".XML": case ".xml": case ".INDD": case ".MHT": //NS case ".MPP": //NS case ".CFM": //NS case ".XLTM": //NS case ".SHX": //NS case ".PPSX": //NS case ".CSS": //NS case ".XLTX": //NS case ".JS": //NS" case ".OTF": //NS case ".VST": //NS case ".WMV": //NS case ".WMZ": //NS case ".OFT": //NS case ".MOV": //NS case ".PPS": //NS case ".MDB": //NS case ".EPS": //NS case ".XPS": //NS case ".XLSB": //NS case ".MID": //NS case ".THMX": //NS case ".TMP": //NS case ".TTF": //NS case ".MXD": //NS case ".ICS": //NS case ".DOCM": //NS case ".BPMN": //NS case ".AI": //NS case ".AVI": //NS case ".DXF": //NS case ".INI": //NS case ".LOG": //NS case ".LST": //NS case ".ODT": //NS case ".PARTIAL": //NS case ".POT": //NS case ".POTX": //NS case ".VSDX": //NS case ".SKP": //NS case ".SHS": //NS case ".RPT": //NS case ".XLA": //NS rt = new RecordType(db, 2); break; //Images case ".JPG": case ".TIF": case ".jpg": case ".tif": case ".PNG": case ".png": case ".JPEG": case ".jpeg": case ".GIF": case ".gif": case ".BMP": case ".bmp": case ".MPEG": case ".TIFF": rt = new RecordType(db, 14); break; //Mail case ".EML": case ".eml": case ".msg": case ".MSG": rt = new RecordType(db, 3); newtitle = SetEmailTitle(FileLoc); break; } Record rcont = new Record(db, cont); Record r = new Record(rt); Location lo = new Location(db, 5503); if (newtitle != null) r.Title = newtitle; r.SetDocument(FileLoc); r.SetAssignee(lo); r.SetOwnerLocation(lo); r.Container = rcont; r.Save(); uri = r.Uri; Console.WriteLine("Migrated document from: " + FileLoc + " and saved as " + r.Number); db.LogExternalEvent("Document migrated from: " + FileLoc, BaseObjectTypes.Record, uri, true); } else { Console.WriteLine("Document location does not exist: " + FileLoc); db.LogExternalEvent("Document location does not exist: "+FileLoc, BaseObjectTypes.Record, Convert.ToInt64(cont), true); } } catch (Exception exp) { Console.WriteLine("Error: " + exp.Message.ToString()); db.LogExternalEvent("Error migrating: " + FileLoc+" Error: "+exp.Message.ToString(), BaseObjectTypes.Record, Convert.ToInt64(cont), true); } return uri; }
static void ProcessApplication(string Name) { TrimApplication.Initialize(); using (Database db = new Database()) { db.Id = "10"; db.Connect(); JsonSerializer s = new JsonSerializer(); try { T1Application t1 = null; using (StreamReader sr = new StreamReader(Name)) { using (JsonTextReader reader = new JsonTextReader(sr)) { //T1Integration t1 = new T1Integration(); t1 = (T1Application)s.Deserialize(reader, typeof(T1Application)); } } if (t1 != null) { FieldDefinition fdPropertyAddress = new FieldDefinition(db, 502); if (t1.EddieUri == 0) { RecordType rt = new RecordType(db, 2); Record rec = new Record(rt); if (t1.PropertyNumber != 0) { Record cont = new Record(db, t1.PropertyNumber); rec.Container = cont; } //FieldDefinition fdPropertyNo = new FieldDefinition(db, 504); rec.Title = "Application - " + t1.ApplicationNumber; //rec.SetFieldValue(fdPropertyNo, new UserFieldValue(t1.PropertyNumber)); //rec.SetFieldValue(fdPropertyAddress, new UserFieldValue(t1.PropertyAddress)); //Classification c = new Classification(db, 2616); //rec.Classification = c; FileInfo f = new FileInfo(t1.documentLoc); if (f.Exists) { rec.SetDocument(new InputDocument(t1.documentLoc), false, false, ""); } rec.Save(); t1.EddieUri = rec.Uri; t1.EddieRecordUrl = rec.WebURL; Console.WriteLine("New application 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)); FileInfo f1 = new FileInfo(t1.documentLoc); if (f1.Exists) { rec.SetDocument(new InputDocument(t1.documentLoc), true, false, ""); } rec.Save(); //t1.EddieUri = rec.Uri; t1.EddieRecordUrl = rec.WebURL; Console.WriteLine("Application record upgrades - number: " + rec.Number); } using (StreamWriter sw = new StreamWriter(pathout + "T1 Application - " + t1.PropertyNumber.ToString() + ".txt")) { using (JsonWriter writer = new JsonTextWriter(sw)) { s.Serialize(writer, t1); Console.WriteLine("Application file returned"); } }; FileInfo f2 = new FileInfo(Name); if (f2.Exists) f2.Delete(); } } catch (Exception exp) { Console.WriteLine("Error: " + exp.Message.ToString()); throw; } } }