static void ApplicationService(string Name) { try { TrimClient trimClient = new TrimClient(serviceapi); trimClient.Credentials = System.Net.CredentialCache.DefaultCredentials; // Locations request = new Locations(); request.q = "me"; request.Properties = new List<string>() { "SortName" }; var Loc = trimClient.Get<LocationsResponse>(request); Console.WriteLine("Logged onto Eddie as " + Loc.Results[0].SortName); JsonSerializer s = new JsonSerializer(); 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) { Console.WriteLine("T1 export file processed."); if (t1.EddieUri == 0) { Record record = new Record(); record.RecordType = new RecordTypeRef() { Uri = 1 }; record.Title = t1.PropertyTitle + " - " + DateTime.Now.ToString(); record.Classification = new ClassificationRef() { Uri=2598 }; record.SetCustomField("PropertyNumber", t1.PropertyNumber); record.SetCustomField("ApplicationNumber", t1.ApplicationNumber); record.SetCustomField("PropertyAddress", t1.PropertyAddress); RecordsResponse response = trimClient.Post<RecordsResponse>(record); if(response.Results.Count==1) { Console.WriteLine("New property container created in Eddie - RM Uri: " + response.Results.First().Uri.ToString()); } // FileInfo f = new FileInfo(t1.documentLoc); if (f.Exists) { Record doc = new Record(); doc.Properties = new List<string>() { "Number" , "Url"}; doc.RecordType = new RecordTypeRef() { Uri = 2 }; doc.Container = new RecordRef() { Uri = response.Results.First().Uri }; doc.Title= t1.ApplicationTitle + " - " + DateTime.Now.ToString(); doc.SetCustomField("PropertyNumber", t1.PropertyNumber); doc.SetCustomField("ApplicationNumber", t1.ApplicationNumber); RecordsResponse response11= trimClient.PostFileWithRequest<RecordsResponse>(f, doc); if(response11.Results.Count==1) { Record rr = response11.Results.First(); Console.WriteLine("New application document created in Eddie - RM Uri: " + rr.Uri.ToString()); t1.EddieUri = rr.Uri; t1.EddieRecordNumber = rr.Number; t1.EddieRecordUrl = rr.Url; } } } else { //Add amend function } 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 (ServiceStack.ServiceClient.Web.WebServiceException ex) //{ // Console.WriteLine("Service stack error: "+ex.ErrorMessage); //} catch (Exception exp) { Console.WriteLine("General error: " + exp.Message.ToString()); throw; } }