public async System.Threading.Tasks.Task <IList <RecordDocument> > Get() { string userUPN = await GetUser(); List <RecordDocument> records = new List <RecordDocument>(); using (Database db = getDatabase(userUPN)) { TrimMainObjectSearch search = new TrimMainObjectSearch(db, BaseObjectTypes.Record); search.SetSearchString("recExtension:docx"); //TrimSearchClause clause = new TrimSearchClause(db, BaseObjectTypes.Record, SearchClauseIds.Favorite); //search.AddSearchClause(clause); //TrimSearchClause extClause = new TrimSearchClause(db, BaseObjectTypes.Record, SearchClauseIds.RecordExtension); //extClause.SetCriteriaFromString("docx"); //search.AddSearchClause(extClause); //search.And(); foreach (Record record in search) { records.Add(new RecordDocument(record)); } return(records); } }
private static void CreateRMRecord(FileInfo f) { // msg. //LoadMessage(@"C:\Docs\TestMail.eml"); var strmessageId = findmessagid(f); //Console.WriteLine("message id: " + strmessageId); using (Database db = new Database()) { db.Connect(); TrimMainObjectSearch objs = new TrimMainObjectSearch(db, BaseObjectTypes.Record); //objs.SetSearchString("messageId = " + strmessageId); objs.SetSearchString("messageId= *[email protected]*"); if(objs.FastCount>0) { Console.WriteLine("Found a record with the same message ID"); } else { Console.WriteLine("Did not find a message id"); } //RecordType rt = new RecordType(db,3); //Record r = new Record(rt); //r.Container = new Record(db, 172693); //r.Title = f.Name; //r.Save(); //Console.WriteLine("New RM email record: " + r.Number); //Record r = new Record(db, 172736); } }
public override void ExecuteLink(int cmdId, TrimMainObjectSearch forTaggedObjects) { //throw new NotImplementedException(); //Loggitt("Record Uri: " + forTaggedObjects.SkipToUri.ToString(), "Record Lifecycle test: ExecuteLink(int cmdId, TrimMainObjectSearch forTaggedObjects)"); MessageBox.Show("forTaggedObjects: " + forTaggedObjects.SkipToUri.ToString()); }
private void Button_Click_1(object sender, RoutedEventArgs e) { TrimMainObjectSearch search = new TrimMainObjectSearch(_database, BaseObjectTypes.Record); search.SelectAll(); ObjectSelector.DisplayResults(GetDesktopWindow(), search); }
static void Main(string[] args) { TrimApplication.Initialize(); using (Database db = new Database()) { TrimMainObjectSearch objS = new TrimMainObjectSearch(db, BaseObjectTypes.Record); objS.SetSearchString(""); } }
public override void ExecuteLink(int cmdId, TrimMainObjectSearch forTaggedObjects) { m_errorMsg.Remove(0, m_errorMsg.Length); writeToLog("Executed sample menu link for objects matching {0} (command id {1}):", forTaggedObjects.Title, cmdId); foreach (TrimMainObject obj in forTaggedObjects) { writeToLog("\t{0} ({1}): {2}", obj.TrimType, obj.Uri, obj.NameString); } }
public static void RemoveOcrRenditions(TrimMainObjectSearch forTaggedObjects) { foreach (var result in forTaggedObjects) { HP.HPTRIM.SDK.Record record = result as HP.HPTRIM.SDK.Record; if ((HP.HPTRIM.SDK.Record)record != null) { RemoveOcrRendition(record); } } }
public IEnumerable<RecordData> RetrieveRecords(DateTime lastUpdated) { Logger.InfoFormat("Retrieving records from {0:dd/MM/yyyy h:mm tt}", lastUpdated); using (var records = new TrimMainObjectSearch(Db, BaseObjectTypes.Record)) { /* records.SetSearchString(@"acl:""View Document"",[""INTEL-INVEST""]"); records.And(); var trimSearchClause = new TrimSearchClause(BaseObjectTypes.Record, Db, SearchClauseIds.Updated); trimSearchClause.SetCriteriaFromDateComparison(ComparisonType.GreaterThanOrEqualTo, new TrimDateTime(lastUpdated)); records.AddSearchClause(trimSearchClause); records.And(); var extensionSearchClause = new TrimSearchClause(BaseObjectTypes.Record, Db, SearchClauseIds.RecordExtension); extensionSearchClause.SetCriteriaFromString("*"); records.AddSearchClause(extensionSearchClause); records.SetFilterString("type:document"); */ records.SetSearchString(String.Format(@"acl:""View Document"",[""INTEL-INVEST""] and type:document and extension: * and updated >= {0:dd/MM/yyyy h:mm tt} and not (disposition:Inactive,Destroyed)", lastUpdated)); records.AddSortItemAscending(SearchClauseIds.Updated); int recordsReturned = 0; foreach (Record resultRecord in records) { Logger.DebugFormat("{0:dd MMM yyyy HH:mm:ss} - {1}", resultRecord.LastUpdatedOn.ToDateTime(), resultRecord.NameString); var data = new RecordData {RecordNumber = resultRecord.Uri}; data.Metadata.Add("name", resultRecord.NameString); if (!String.IsNullOrEmpty(resultRecord.Notes)) { data.Metadata.Add("notes", resultRecord.Notes); } using (ExtractDocument extractDocument = resultRecord.GetExtractDocument()) { data.Metadata.Add("filename", extractDocument.FileName); } data.Acls = RetrieveSecurity(resultRecord).ToList(); yield return data; if (++recordsReturned == 100) { Logger.Info("Returning only 100 records"); LastRecordUpdatedDate = resultRecord.LastUpdatedOn.ToDateTime(); yield break; } } } }
public IEnumerator <Record> GetEnumerator() { search = new TrimMainObjectSearch(database, BaseObjectTypes.Record); search.SetSearchString(_query); search.PagingMode = true; search.LimitOnRowsReturned = limitOnRowsReturned; search.SkipCount = skipCount; foreach (Record record in search) { yield return(record); } }
private static void TestSearch(Database database) { TrimMainObjectSearch search = new TrimMainObjectSearch(database, BaseObjectTypes.Record); search.SetSearchString("recElectronic"); FieldDefinition speadField = new FieldDefinition(database, "Speed"); foreach (Record record in search) { Console.WriteLine($"Uri: {record.Uri}, Title: {record.Title}, Owner: {record.OwnerLocation.NameString}, Speed: {getField(speadField, record)}"); } }
private void Origin_Chooser_Button_Click(object sender, RoutedEventArgs e) { // First filter the Origins to select from and then allow the user to choose an Origin TrimMainObjectSearch search = new TrimMainObjectSearch(Database, BaseObjectTypes.Origin); search.SetSearchString(string.Format("ognType:{0}", OriginType.WindowsFolder)); SelectedOrigin = ObjectSelector.SelectOne(GetDesktopWindow(), search) as Origin; if (string.IsNullOrEmpty(SourceFolder)) { SourceFolder = SelectedOrigin.OriginLocation; } }
public IEnumerable <OneDriveDocument> GetDeleteableDocuments() { TrimMainObjectSearch search = new TrimMainObjectSearch(database, BaseObjectTypes.Record); search.AddDeleteNowSearchClause(); Console.WriteLine($"Found records: {search.FastCount}"); foreach (Record record in search) { yield return(new OneDriveDocument() { Id = record.GetDriveId(), LinkFileName = record.GetFileName("trim"), Uri = record.Uri, DateModified = record.DateModified }); } }
public override void ExecuteLink(int cmdId, TrimMainObjectSearch forTaggedObjects) { switch (cmdId) { case MenuLinks.UpdateOcrRendition.LINK_ID: RecordController.UpdateOcrRenditions(forTaggedObjects); break; case MenuLinks.RemoveOcrRendition.LINK_ID: RecordController.RemoveOcrRenditions(forTaggedObjects); break; default: break; } }
private static int nextnumber() { TrimApplication.Initialize(); using (Database db = new Database()) { int intChildCnt = 0; int intChildLast = 0; List<int> classNumb = new List<int>(); List<Classification> cl = new List<Classification>(); TrimMainObjectSearch obj = new TrimMainObjectSearch(db, BaseObjectTypes.Classification); obj.SetSearchString("parent:" + 9144); obj.SetSortString("numberx"); int icnt = 1; if (obj.FastCount > 0) { foreach (Classification c in obj) { if (icnt > 98) { var sdsd = icnt; } cl.Add(c); var sdsdsd = c.LevelNumberUncompressed; var kkkk = c.LevelNumberUncompressed.Remove(0, 1); classNumb.Add(Convert.ToInt32(kkkk)); icnt++; } //classNumb.Sort(x=>x) //cl.Max(x => x.Uri); intChildCnt = classNumb.Max(); intChildLast = classNumb.Last(); } else { intChildCnt = 0; } Console.WriteLine(" Container count: " + obj.FastCount.ToString() + " Max number: " + (intChildCnt + 10).ToString() + " Last number: " + (intChildLast + 10).ToString()); return intChildLast + 10; } }
private static Record GetFolderUri(string p1, string p2, Database db) { Record r = null; Classification c = (Classification)db.FindTrimObjectByName(BaseObjectTypes.Classification, "zz Legacy T1 ECM - Business Folders - " + p1); if(c!=null) { TrimMainObjectSearch mso = new TrimMainObjectSearch(db, BaseObjectTypes.Record); //string ss = "title:" + reader.GetString(7) + " and classification:zz Legacy T1 ECM - Business Folders - " + reader.GetString(6); mso.SetSearchString("classification:"+c.Uri); foreach(Record rec in mso) { if(rec.Title==p2) { r = rec; } } } return r; }
private static void TestStreamSearch(Database database) { TrimMainObjectSearch search = new TrimMainObjectSearch(database, BaseObjectTypes.Record); search.SetSearchString("recElectronic"); TrimSearchDataStream searchStream = search.GetDataStream(new PropertyOrFieldDefList() { new PropertyOrFieldDef(PropertyIds.RecordOwnerLocation, database), new PropertyOrFieldDef(new FieldDefinition(database, "Speed")), new PropertyOrFieldDef(PropertyIds.RecordTitle, database) }); while (searchStream.MoveNext()) { var searchItem = searchStream.Current(); Console.WriteLine(searchItem.GetAsJSONString()); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { TrimMainObjectSearch search = new TrimMainObjectSearch(_database, BaseObjectTypes.Record); TrimSearchClause recentClause = new TrimSearchClause(_database, BaseObjectTypes.Record, SearchClauseIds.RecordMyDocuments); search.AddSearchClause(recentClause); search.SetPurpose((int)RecordPurposes.FindTemplate, (int)AllEnumerations.WordOpenFileTypes); var selectedSearch = ObjectSelector.SelectOne(GetDesktopWindow(), search); if (selectedSearch != null) { string gg = selectedSearch.Uri.ToString(); } }
static void Main(string[] args) { using (Database db = new Database()) { TrimMainObjectSearch objs = new TrimMainObjectSearch(db, BaseObjectTypes.Record); objs.SetSearchString("type:16 and not ECMSTDJobNo:\"\""); //type:16 and not ECMSTDJobNo:"" //ECMInfringementInfringementID: FieldDefinition fdFrom = new FieldDefinition(db, 91); FieldDefinition fdTo = new FieldDefinition(db, 510); foreach (Record r in objs) { Console.WriteLine("Record: {0}", r.Uri.ToString()); string iFrom = (string)r.GetFieldValue(fdFrom).ToDotNetObject(); string iTo = (string)r.GetFieldValue(fdTo).ToDotNetObject(); if(string.IsNullOrWhiteSpace(iTo)) { try { if (r.DateRegistered <= r.DateReceived) { //If the date registered and date recieved are in the wrong order RM gets cranky. we check and save if needed, this is a data vallidation issue from the migration. DateTime tdtDateReceived = r.DateReceived; r.DateRegistered = (TrimDateTime)tdtDateReceived.AddHours(1); r.Save(); Console.WriteLine("Record date registered updated"); } r.SetFieldValue(fdTo, new UserFieldValue(Convert.ToString(iFrom))); r.Save(); Console.WriteLine("Record UDF field updated"); } catch (Exception exp) { Console.WriteLine("Error: {0}",exp.Message.ToString()); } } } } }
public override void ExecuteLink(int cmdId, TrimMainObjectSearch forTaggedObjects) { if (links[0].MenuID == cmdId) { FolderBrowserDialog directorySelector = new FolderBrowserDialog() { Description = "Select a directory to place the electronic documents", ShowNewFolderButton = true }; if (directorySelector.ShowDialog() == DialogResult.OK) { foreach (var taggedObject in forTaggedObjects) { HP.HPTRIM.SDK.Record record = taggedObject as HP.HPTRIM.SDK.Record; if ((HP.HPTRIM.SDK.Record)record != null) { string outputPath = Path.Combine(directorySelector.SelectedPath, $"{record.Number}.{record.Extension}"); record.GetDocument(outputPath, false, string.Empty, string.Empty); } } } } }
static void Main(string[] args) { int iCount = 0; TrimApplication.Initialize(); using (Database db = new Database()) { Console.WriteLine("Change date recieved: Y/N"); string dr = Console.ReadLine(); TrimMainObjectSearch objS = new TrimMainObjectSearch(db, BaseObjectTypes.Record); objS.SetSearchString("type:16"); foreach(Record r in objS) { if (r.DateRegistered <= r.DateReceived) { iCount++; Console.WriteLine("Record with a date issue: " + r.Number); if (dr == "Y") { //if (r.Number == "805639") //{ r.DateReceived = r.DateRegistered; //DateTime tdtDateReceived = reccheck.DateReceived; //reccheck.DateRegistered = (TrimDateTime)tdtDateReceived.AddHours(1); try { r.Save(); Console.WriteLine("Changed ok"); } catch (Exception exp) { Console.WriteLine("Error: " + exp.Message.ToString()); } //} } } } } Console.WriteLine("Date issue count: " + iCount.ToString()); }
private void Button_Click(object sender, RoutedEventArgs e) { using (Database database = new Database()) { database.Id = _databaseId; database.Connect(); TrimMainObjectSearch search = new TrimMainObjectSearch(database, BaseObjectTypes.Record); search.SetSearchString(string.Format("unkUri: {0}", _recordUris)); string msg = string.Empty; foreach (Record record in search) { msg += record.Title + "\n"; } MessageBox.Show(msg, "Record Titles"); } // ((App)Application.Current) }
private static Record GetFolderUri(string function, string activity, Database db) { Record r = null; //For tfr to SCC //zz legacy T1 ECM - Business Folders - Information Management - Projects //Local //zz Legacy T1 ECM - Business Folders string ClassSearch = "zz legacy T1 ECM - Business Folders - " + function; Classification c = (Classification)db.FindTrimObjectByName(BaseObjectTypes.Classification, "zz legacy T1 ECM - Business Folders - " + function); if (c != null) { TrimMainObjectSearch mso = new TrimMainObjectSearch(db, BaseObjectTypes.Record); //string ss = "title:" + reader.GetString(7) + " and classification:zz Legacy T1 ECM - Business Folders - " + reader.GetString(6); mso.SetSearchString("classification:" + c.Uri); foreach (Record rec in mso) { if (rec.Title == activity) { r = rec; } } } return r; }
public async Task <object> Get(RegisterFile request) { var log = LogManager.GetLogger(typeof(RegisterFileService)); log.Debug("GET start"); RegisterFileResponse response = new RegisterFileResponse(); log.Debug("getToken"); string token = await getToken(); log.Debug("gotToken"); string driveId = getDriveIdFromTrim(request); log.Debug("got Drive ID"); OneDriveItem fileResult = null; try { if (!string.IsNullOrWhiteSpace(request.WebUrl) && new string[] { "https://", "http://" } .Any(s => request.WebUrl.StartsWith(s, StringComparison.InvariantCultureIgnoreCase))) { log.Debug("GetItem"); var fullOneDriveItemsUrl = GraphApiHelper.GetOneDriveShareUrl(request.WebUrl); fileResult = await ODataHelper.GetItem <OneDriveItem>(fullOneDriveItemsUrl, token, null); log.Debug("GotItem"); } else if (!string.IsNullOrWhiteSpace(driveId)) { fileResult = await ODataHelper.GetItem <OneDriveItem>(GraphApiHelper.GetOneDriveItemIdUrl(driveId), token, null); } } catch { throw; } RegisterdFileResponse registeredFile = new RegisterdFileResponse(); if (fileResult != null) { registeredFile.Id = fileResult?.getDriveAndId(); registeredFile.DriveItem = fileResult; TrimMainObjectSearch search = new TrimMainObjectSearch(this.Database, BaseObjectTypes.Record); TrimSearchClause clause = new TrimSearchClause(this.Database, BaseObjectTypes.Record, SearchClauseIds.RecordSpURL); clause.SetCriteriaFromString(fileResult.getDriveAndId()); search.AddSearchClause(clause); var uris = search.GetResultAsUriArray(2); if (uris.Count == 1) { updateFromRecord(registeredFile, new Record(this.Database, uris[0])); } //if (request.Uri > 0) //{ // Record record = new Record(this.Database, request.Uri); // response.RecordTitle = record.Title; // response.Name = this.Database.CurrentUser.FormattedName; //} } response.Results = new List <RegisterdFileResponse>() { registeredFile }; log.Debug("Finished"); return(response); }
private static Record CheckSubFolderAlreadyExists(long folder, string p, Database db) { Record rec = null; TrimMainObjectSearch objS = new TrimMainObjectSearch(db, BaseObjectTypes.Record); objS.SetSearchString("container:" + folder); foreach (Record r in objS) { if (r.Title == p.Trim()) { rec = r; } } return rec; }
private static int FindStartingNumber(long toplevelUri, Database db) { int intChildLast = 0; List<int> classNumb = new List<int>(); List<Classification> cl = new List<Classification>(); TrimMainObjectSearch obj = new TrimMainObjectSearch(db, BaseObjectTypes.Classification); obj.SetSearchString("parent:" + toplevelUri); obj.SetSortString("uri"); if (obj.FastCount > 0) { foreach (Classification c in obj) { cl.Add(c); var kkkk = c.LevelNumberUncompressed.Remove(0, 1); classNumb.Add(Convert.ToInt32(kkkk)); } intChildLast= classNumb.Last(); } Console.WriteLine("Calculating next folder number: "+toplevelUri.ToString()+" Container count: "+obj.FastCount.ToString()+ " Last number: "+(intChildLast+10).ToString()); return intChildLast + 10; }
private static Record CheckifFolderAlreadyExists(Classification cl3, string p, Database db) { Record rec = null; TrimMainObjectSearch objS = new TrimMainObjectSearch(db, BaseObjectTypes.Record); objS.SetSearchString("classification:" + cl3.Uri); foreach (Record r in objS) { if (r.Title == p.Trim()) { rec = r; } } return rec; }
public static void AddDeleteNowSearchClause(this TrimMainObjectSearch search) { TrimSearchClause clause = new TrimSearchClause(search.Database, BaseObjectTypes.Record, new FieldDefinition(search.Database, "DeleteNow")); search.AddSearchClause(clause); }
public async Task <object> Get(RegisterFile request) { var log = LogManager.GetLogger(typeof(RegisterFileService)); log.Debug("GET start"); RegisterFileResponse response = new RegisterFileResponse(); log.Debug("getToken"); string token = await getToken(); log.Debug("gotToken"); string driveId = getDriveIdFromTrim(request); log.Debug("got Drive ID"); OneDriveItem fileResult = null; long recordUri = 0; RegisterdFileResponse registeredFile = new RegisterdFileResponse(); try { if (request.IsEmail) { recordUri = await getEmailLinkUri(request.WebUrl, token); //var mailResult = await ODataHelper.GetItem<MailItem>(GraphApiHelper.GetMailItemURL(request.WebUrl), token, null); //if (mailResult != null && mailResult.SingleValueExtendedProperties != null) //{ // foreach (var prop in mailResult.SingleValueExtendedProperties) // { // if (prop.Id.Equals(GraphApiHelper.IDPropName(), StringComparison.InvariantCultureIgnoreCase)) // { // long.TryParse(prop.Value.Split('/').Last(), out recordUri); // } // } //} } if (request.IsEmail && recordUri == 0) { var emailUrl = GraphApiHelper.GetEMLUrl(request.WebUrl); string userFolder = Path.Combine("ForUser", this.Database.CurrentUser.Uri.ToString()); string fullUserFolder = Path.Combine(this.ServiceDefaults.UploadBasePath, userFolder); Directory.CreateDirectory(fullUserFolder); string fileName = Path.ChangeExtension(request.WebUrl, "eml"); string filePath = Path.Combine(fullUserFolder, fileName); await ODataHelper.GetItem <string>(emailUrl, token, filePath); registeredFile.EmailPath = Path.Combine(userFolder, fileName);; } else if (!string.IsNullOrWhiteSpace(request.WebUrl) && new string[] { "https://", "http://" } .Any(s => request.WebUrl.StartsWith(s, StringComparison.InvariantCultureIgnoreCase))) { log.Debug("GetItem"); var fullOneDriveItemsUrl = GraphApiHelper.GetOneDriveShareUrl(request.WebUrl); fileResult = await ODataHelper.GetItem <OneDriveItem>(fullOneDriveItemsUrl, token, null); log.Debug("GotItem"); } else if (!string.IsNullOrWhiteSpace(driveId) && !request.IsEmail) { fileResult = await ODataHelper.GetItem <OneDriveItem>(GraphApiHelper.GetOneDriveItemIdUrl(driveId), token, null); } } catch { throw; } DroppedFilesUserOptions fileOptions = new DroppedFilesUserOptions(this.Database); var options = new TrimOptions(); if (fileOptions.UseDefaultRecordTypeInOffice == true) { options.DefaultDocumentRecordType = fileOptions.RecordType.Uri; } registeredFile.Options = options; var enumItems = new List <MyEnumItem>(); HP.HPTRIM.SDK.Enum relationshipEnum = new HP.HPTRIM.SDK.Enum(AllEnumerations.RecordRelationshipType, this.Database); foreach (var relEnum in relationshipEnum.GetItemArray(new int[] { (int)RecordRelationshipType.InSharepointSite, (int)RecordRelationshipType.IsInSeries, (int)RecordRelationshipType.IsRootPart, (int)RecordRelationshipType.IsTempCopy, (int)RecordRelationshipType.IsVersion, (int)RecordRelationshipType.RedactionOf }, true).OrderBy(ei => ei.Caption)) { enumItems.Add(new MyEnumItem() { Name = relEnum.Name, Caption = relEnum.Caption }); } Dictionary <string, IList <MyEnumItem> > enumDetails = new Dictionary <string, IList <MyEnumItem> >(); enumDetails.Add("RecordRelationshipType", enumItems); registeredFile.Enums = enumDetails; if (fileResult != null) { registeredFile.Id = fileResult?.getDriveAndId(); registeredFile.DriveItem = fileResult; TrimMainObjectSearch search = new TrimMainObjectSearch(this.Database, BaseObjectTypes.Record); search.AddSearchClause(fileResult.getDriveAndId().GetDriveIdSearchClause(this.Database)); var uris = search.GetResultAsUriArray(2); if (uris.Count == 1) { updateFromRecord(registeredFile, new Record(this.Database, uris[0])); } } else if (request.IsEmail && recordUri > 0) { updateFromRecord(registeredFile, new Record(this.Database, recordUri)); } response.Results = new List <RegisterdFileResponse>() { registeredFile }; log.Debug("Finished"); return(response); }
static void Main(string[] args) { if (!TrimApplication.HasBeenInitialized) { TrimApplication.Initialize(); } TrimApplication.HasUserInterface = true; // List<Sheets> myMessage = JsonConvert.DeserializeObject<List<Sheets>>(File.ReadAllText(@"C:\temp\SSprocess.json")); List<RM> lstRm = new List<RM>(); using (Database db = new Database()) { db.Connect(); //10030-Westview Cres NAMBOUR //var p = "10030-Westview Cres NAMBOURR"; Record rec = null; TrimMainObjectSearch objS = new TrimMainObjectSearch(db, BaseObjectTypes.Record); objS.SetSearchString("classification:7726"); //if (objS.FastCount == 0) //Console.WriteLine("No results for this folder under the class: " + cl3.Title + "/" + p); foreach (Record r in objS) { RM rm = new RM(); rm.Uri = r.Uri; rm.title = r.Title; lstRm.Add(rm); //Console.WriteLine("Loop through folders under class:" + p + "/" + r.Title); //if (r.Title == p.Trim()) //{ // rec = r; //} } //if (rec != null) //{ // Console.WriteLine("Found record:" + rec.Uri); //} //else //{ // Console.WriteLine("Record is null"); //} } Console.WriteLine("Record count: " + lstRm.Count().ToString()); Console.ReadLine(); foreach (var file in myMessage) { //file.Rows.Skip(9880).Take(30) //file.Rows.Where(x => x.RMuri == "0" && x.Error == null).Take(30) //.Where(x=>x.Error==null && x.RMuri=="0") Console.WriteLine("SS row count: " + file.Rows.Count().ToString()); foreach (Rows r in file.Rows.Where(x => x.Folder !=null && x.RMuri == "0").Take(30)) { //.Trim() var d = r.Folder.Trim(); var h = "Not found"; if(lstRm.Exists(x=>x.title.Contains(d))) { h = lstRm.Find(x=>x.title==d).title; } Console.WriteLine("Process test: " + r.Folder + " / "+ h); // (x => x.title == d).FirstOrDefault().title); } } Console.ReadLine(); }
static void Main(string[] args) { using (Database db = new Database()) { TrimMainObjectSearch objs = new TrimMainObjectSearch(db, BaseObjectTypes.Record); objs.SetSearchString("not ApplicationNumber:\"\""); //not RequestNumber:"" //PropertyNumber:88 to 2446699 //not ApplicationNumber:"" // //503 app number string //504 Prop number number //505 request number string // //type:16 and not ECMSTDJobNo:\"\" //type:16 and not ECMSTDJobNo:"" //ECMInfringementInfringementID: FieldDefinition fdApplicationList = new FieldDefinition(db, 1002); FieldDefinition fdPropertyList = new FieldDefinition(db, 1003); FieldDefinition fdRequestNumber = new FieldDefinition(db, 505); FieldDefinition fdPropertyNumber = new FieldDefinition(db, 504); FieldDefinition fdApplicationNumber = new FieldDefinition(db, 503); Console.WriteLine("Count: " + objs.FastCount.ToString()); foreach (Record r in objs) { Console.WriteLine("Record: " + r.Uri.ToString()); //if (r.Uri == 496206) //{ try { string sApplicationList = (string)r.GetFieldValue(fdPropertyList).ToDotNetObject(); Console.WriteLine("Record field: App list {0} ", sApplicationList); int sRequestNumber = (int)r.GetFieldValue(fdPropertyNumber).ToDotNetObject(); Console.WriteLine("Record field: App list {0}, request {1} ", sApplicationList, sRequestNumber); string sNewValue; if (!string.IsNullOrEmpty(sApplicationList)) { sNewValue = sApplicationList + " " + sRequestNumber.ToString(); } else { sNewValue = sRequestNumber.ToString(); } Console.WriteLine("Record field: App list {0}, request {1}, new value {2} ", sApplicationList, sRequestNumber, sNewValue); r.SetFieldValue(fdApplicationList, new UserFieldValue(sNewValue)); r.Save(); Console.WriteLine("Record updated"); //Console.ReadLine(); } catch (Exception exp) { Console.WriteLine("Error: " + exp.Message.ToString()); //Console.ReadLine(); } //} //string sApplicationNumbert = (string)r.GetFieldValue(fdApplicationNumber).ToDotNetObject(); //if (sApplicationList == ";") //{ // r.SetFieldValue(fdApplicationList, new UserFieldValue()); //} //string sPropertyList = (string)r.GetFieldValue(fdPropertyList).ToDotNetObject(); //if (sPropertyList == ";") //{ // rk // r.SetFieldValue(fdPropertyList, new UserFieldValue()); //} } } }
static void Main(string[] args) { List<ACL> lstAcl = new List<ACL>(); using (SqlConnection con = new SqlConnection("Data Source=Cl1025;Initial Catalog=StagingMove;Integrated Security=True")) { con.Open(); using (SqlCommand command = new SqlCommand("SELECT [ECMClass],[EddieAcl] FROM [StagingMove].[dbo].[SetAcl] where Run = 1", con)) { //DataTable dt = new DataTable(); //SqlDataAdapter da = new SqlDataAdapter(); //da.SelectCommand = command; //da.Fill(dt); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ACL acl = new ACL(); acl.EcmClass = reader.GetString(0).Trim(); acl.RMlocation = reader.GetString(1).Trim(); lstAcl.Add(acl); } } } } Console.WriteLine("What is the origin uri?"); int iOuri = Convert.ToInt32(Console.ReadLine()); foreach (ACL acl in lstAcl) { try { using (Database db = new Database()) { //Console.WriteLine("Enter ECM class name"); TrimMainObjectSearch sObj = new TrimMainObjectSearch(db, BaseObjectTypes.Record); //ECMSTDClassName:"Confidential Transition" and type:16 //string str = @""+Console.ReadLine()+""; //sObj.SetSearchString("ECMSTDClassName:\"" + acl.EcmClass + "\" and type:16 and updated>9/03/2016"); sObj.SetSearchString("ECMSTDClassName:\"" + acl.EcmClass + "\" and type:16 and originRun:"+iOuri); Console.WriteLine(sObj.SearchString); Console.WriteLine("Record count: " + sObj.FastCount.ToString()); if (sObj.FastCount > 0) { FieldDefinition fdDocDate = new FieldDefinition(db, 85); LocationList lstLoc = new LocationList(); Location l = new Location(db, acl.RMlocation); lstLoc.Add(l); foreach (Record r in sObj) { if(r.DateRegistered<=r.DateReceived) { DateTime tdtDateReceived = r.DateReceived; r.DateRegistered = (TrimDateTime)tdtDateReceived.AddHours(1); } r.Save(); //TrimDateTime rmDt = (TrimDateTime)r.GetFieldValue(fdDocDate).ToDotNetObject(); //r.DateReceived = rmDt; //r.DateCreated = rmDt; //r.Save(); // TrimAccessControlList lstacl = r.AccessControlList; lstacl.set_AccessLocations((int)RecordAccess.ViewRecord, lstLoc); lstacl.set_AccessLocations((int)RecordAccess.ViewDocument, lstLoc); r.AccessControlList = lstacl; try { r.Save(); Console.WriteLine("ACL applied to " + r.Number); } catch (Exception exp) { Console.WriteLine("ACL failed, Error: " + exp.Message.ToString()); } } } } } catch (Exception exp) { Console.WriteLine("Error: " + exp.Message.ToString()); } } Console.ReadLine(); }
private void button4_Click(object sender, EventArgs e) { using (Database TrimDb = new Database()) { TrimMainObjectSearch baseSearch = new TrimMainObjectSearch(TrimDb, BaseObjectTypes.Record); // to be replaced by saved search baseSearch.SetSearchString("uri:"+textBox1.Text); //baseSearch.SetSortString("id"); //MessageBox.Show("Check baseSearch: " + baseSearch.FastCount, "", MessageBoxButtons.OK); //TrimMainObjectSearch resultSearch = ObjectSelector.SelectOne(this.Handle, baseSearch); //(this.Handle, baseSearch); TrimMainObject tmo = ObjectSelector.SelectOne(this.Handle, baseSearch); if (tmo != null) { if (tmo.TrimType == BaseObjectTypes.Record) { //Classification cl = (Classification)tmo; Record r = (Record)tmo; //label3.Text = cl.Title + "(" + cl.Uri.ToString() + ")"; label3.Text = r.Title + "(" + r.Number + ")"; } else { MessageBox.Show("You need to select a folder"); } } else { MessageBox.Show("Uri not found"); } // } }
private static void ReadUdfs() { TrimApplication.Initialize(); using (Database db = new Database()) { // TrimMainObjectSearch s = new TrimMainObjectSearch(db, BaseObjectTypes.FieldDefinition) // { //if(db.FindTrimObjectByName(BaseObjectTypes.FieldDefinition,"dfdfd")!= null) // { // } //FieldDefinition fdJobNo = new FieldDefinition(db, "ECM STD:JobNo"); //recordFields[8] = new PropertyOrFieldValue(fdJobNo); TrimMainObjectSearch objs = new TrimMainObjectSearch(db, BaseObjectTypes.FieldDefinition); string txtUdfObjectSet = null; string txtUdfClass = null; string txtSql = null; string txtPopClass = null; string txtAddtoUdf = null; string txtAddsdkUdf = null; //try{}catch { Console.WriteLine("Data convert problem with "+)} int cnt = 5; objs.SelectByPrefix("ECM "); foreach(FieldDefinition fd in objs) { string fdName = "fd_" + fd.Name.Replace(" ", "").Replace(":","").Replace("[","").Replace("]",""); string className = fd.Name.Replace(" ", "").Replace(":", "").Replace("[", "").Replace("]", ""); Console.WriteLine("UDF: " + fdName); txtUdfObjectSet = txtUdfObjectSet + "FieldDefinition " + fdName + "= new FieldDefinition(db, \""+ fd.Name+"\");"+Environment.NewLine+"recordFields["+cnt+"] = new PropertyOrFieldValue("+ fdName + ");"+Environment.NewLine+Environment.NewLine; // txtUdfClass = txtUdfClass + "public "+ fd.Format +" " +className+" { get; set; }"+Environment.NewLine; // //int STDDocumentDescription = reader.GetOrdinal("STD:DocumentDescription"); txtSql = txtSql + "int "+className+" = reader.GetOrdinal(\""+ fd.Name.Remove(0,4) + "\");"+Environment.NewLine; // //ecm.DocSetID = reader.GetInt32(ECMSTDDocumentSetID).ToString(); //ecm.ECMDescription = reader.GetString(ECMSTDDocumentDescription); switch(fd.Format) { case UserFieldFormats.String: txtPopClass = txtPopClass + "try{if(reader.IsDBNull(" + className + ") == false){ecm." + className + " = reader.GetString("+ className + ");}}catch { Console.WriteLine(\"Data convert problem with "+className+"\");}" + Environment.NewLine; break; case UserFieldFormats.Text: txtPopClass = txtPopClass + "try{if(reader.IsDBNull(" + className + ") == false){ecm." + className + " = reader.GetString(" + className + ");}}catch { Console.WriteLine(\"Data convert problem with " + className + "\");}" + Environment.NewLine; break; case UserFieldFormats.Datetime: txtPopClass = txtPopClass + "try{if(reader.IsDBNull(" + className + ") == false){ecm." + className + " = reader.GetDateTime(" + className + ");}}catch { Console.WriteLine(\"Data convert problem with " + className + "\");}" + Environment.NewLine; break; case UserFieldFormats.Number: txtPopClass = txtPopClass + "try{if(reader.IsDBNull(" + className + ") == false){ecm." + className + " = reader.GetInt32(" + className + ");}}catch { Console.WriteLine(\"Data convert problem with " + className + "\");}" + Environment.NewLine; break; default: txtPopClass = txtPopClass + "try{Not covered: " + fd.Format.ToString() + Environment.NewLine; break; } txtAddtoUdf = txtAddtoUdf + "if (h."+className+" != null) { recordFields["+cnt+"].SetValue(h."+className+"); } else { recordFields["+cnt+"].ClearValue(); }//"+className+Environment.NewLine; ////if (h.InfringementNo != null) { recordFields[6].SetValue(h.InfringementNo); } else { recordFields[6].ClearValue(); }//InfringementNo //txtPopClass = txtPopClass + ""; txtAddsdkUdf = txtAddsdkUdf + "rec.SetFieldValue(fd_" + className + ", UserFieldValue.FromDotNetObject(ecm." + className + "));" + Environment.NewLine; cnt++; } //File.WriteAllText(@"D:\Users\WyldLynx\Documents\BuildMigrationSetUdfObject.txt", txtUdfObjectSet); //File.WriteAllText(@"D:\Users\WyldLynx\Documents\BuildMigrationClass.txt", txtUdfClass); //File.WriteAllText(@"D:\Users\WyldLynx\Documents\BuildMigrationSQL.txt", txtSql); //File.WriteAllText(@"D:\Users\WyldLynx\Documents\BuildMigrationPopClass.txt", txtPopClass); //File.WriteAllText(@"D:\Users\WyldLynx\Documents\BuildMigrationAddtoUdf.txt", txtAddtoUdf); File.WriteAllText(@"D:\Users\WyldLynx\Documents\BuildMigrationSDFUDF.txt", txtAddsdkUdf); } }
static void Main(string[] args) { using (Database db = new Database()) { TrimMainObjectSearch objs = new TrimMainObjectSearch(db, BaseObjectTypes.Record); //792378 //First check to see if anything comes back //With more time this search should have been defined into manageable chunks objs.SetSearchString("type:16"); //Limit to the record type that I know is relevent //Initial attempts to manage the chunk runs //Console.WriteLine("Enter row limit"); //objs.LimitOnRowsReturned = Convert.ToInt64(Console.ReadLine()); // limit to 1000 out of 3.6 mill //Console.WriteLine("Enter row skip"); //objs.SkipCount = Convert.ToInt64(Console.ReadLine()); //objs.SetSearchString("number:792378"); //Changed to grab the entire set as an array of record uri's, so I can manage this in chunks by using a skip and take. Tried the RM Limitonrowsreturns and skipcount but I wasnt confident that it was working properly. Not enough time to invetigate and confirm. Each record type return is 3.6 mill records. long[] auri = objs.GetResultAsUriArray(); //db.FindTrimObjectByUri(BaseObjectTypes.fi) FieldDefinition fdNotes = new FieldDefinition(db, 42); var iCount = 0; var iTotal = objs.FastCount; //Im changing this for each compile and moving it to a prod WG server to run, doing 4 at a time which takes about 3 hours. 1 mill over 3 hours. foreach(var lUri in auri.Skip(1826354).Take(23646)) { //find the record from the looped uri try { Record rec = (Record)db.FindTrimObjectByUri(BaseObjectTypes.Record, lUri); if (rec != null) { iCount++; //Grab notes from the user defined field var sNotes = rec.GetFieldValue(fdNotes).ToString(); //grab the normal record system notes var sExistingNotes = rec.Notes; //Check for and exclude the custom notes field if empty, it would be nice if I could do this search as part of the original setsearchstring as about 50% of the 3.6 are empty but have a related db row. if (!string.IsNullOrWhiteSpace(sNotes)) { //Display something that maks me feel like its actually working Console.WriteLine("Processing {0} - {1} of 23646", rec.Number, iCount.ToString()); //Ive had a couple of runs at this using different methods and NO SORTING so there is the possibility that the notes have already been copied. if (!sExistingNotes.Contains(sNotes)) { if (rec.DateRegistered <= rec.DateReceived) { //If the date registered and date recieved are in the wrong order RM gets cranky. we check and save if needed, this is a data vallidation issue from the migration. DateTime tdtDateReceived = rec.DateReceived; rec.DateRegistered = (TrimDateTime)tdtDateReceived.AddHours(1); rec.Save(); } try { rec.Save(); Console.WriteLine("Notes transfered from udf to record notes"); } catch (Exception exp) { Console.WriteLine("Error saving notes. " + exp.Message.ToString()); } } else { Console.WriteLine("User defined notes already in Record notes"); } } else { Console.WriteLine("User defined notes empty"); } } else { Console.WriteLine("Uri {0} not found", lUri.ToString()); } } catch (Exception exp) { Console.WriteLine("Error: {0}", exp.Message.ToString()); } } } }
private static Record CheckifFolderAlreadyExists(Classification cl3, string p, Database db) { Record rec = null; TrimMainObjectSearch objS = new TrimMainObjectSearch(db, BaseObjectTypes.Record); objS.SetSearchString("classification:" + cl3.Uri); //if (objS.FastCount == 0) // Console.WriteLine("No results for this folder under the class: " + cl3.Title + "/" + p); foreach (Record r in objS) { //Console.WriteLine("Loop through folders under class:"+p+"/"+r.Title); if (r.Title == p.Trim()) { rec = r; } } if (rec != null) { Console.WriteLine("Found record:" + rec.Uri); } else { Console.WriteLine("Record is null"); } return rec; }
public async Task <object> Get(RegisterFile request) { RegisterFileResponse response = new RegisterFileResponse(); //string[] addinScopes = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/scope").Value.Split(' '); string token = await getToken(); string driveId = getDriveIdFromTrim(request); OneDriveItem fileResult = null; try { if (!string.IsNullOrWhiteSpace(request.WebUrl)) { var driveDetails = await ODataHelper.GetItem <OneDriveDrive>(GraphApiHelper.GetMyOneDriveUrl(), token); string filePath = request.WebUrl.Substring(driveDetails.WebUrl.Length); var fullOneDriveItemsUrl = GraphApiHelper.GetOneDriveItemPathsUrl(filePath); fileResult = await ODataHelper.GetItem <OneDriveItem>(fullOneDriveItemsUrl, token); } else if (!string.IsNullOrWhiteSpace(driveId)) { fileResult = await ODataHelper.GetItem <OneDriveItem>(GraphApiHelper.GetOneDriveItemIdUrl(driveId), token); } } catch { throw; } var registeredFile = new RegisterdFileResponse() { Id = fileResult?.Id, DriveItem = fileResult }; TrimMainObjectSearch search = new TrimMainObjectSearch(this.Database, BaseObjectTypes.Record); TrimSearchClause clause = new TrimSearchClause(this.Database, BaseObjectTypes.Record, SearchClauseIds.RecordExternal); clause.SetCriteriaFromString(fileResult.Id); search.AddSearchClause(clause); var uris = search.GetResultAsUriArray(2); if (uris.Count == 1) { updateFromRecord(registeredFile, new Record(this.Database, uris[0])); } //if (request.Uri > 0) //{ // Record record = new Record(this.Database, request.Uri); // response.RecordTitle = record.Title; // response.Name = this.Database.CurrentUser.FormattedName; //} response.Results = new List <RegisterdFileResponse>() { registeredFile }; return(response); }
private static int FindStartingNumber(long toplevelUri, Database db) { int intChildCnt = 0; List<int> classNumb = new List<int>(); TrimMainObjectSearch obj = new TrimMainObjectSearch(db, BaseObjectTypes.Classification); obj.SetSearchString("parent:" + toplevelUri); if (obj.FastCount > 0) { foreach (Classification c in obj) { var kkkk = c.LevelNumberUncompressed.Remove(0, 2); classNumb.Add(Convert.ToInt32(kkkk)); } intChildCnt = classNumb.Max(); } else { intChildCnt = 0; } return intChildCnt + 10; }
public override void ExecuteLink(int cmdId, TrimMainObjectSearch forTaggedObjects) { }
private void ManageCheckInStyle(Database db, TrimEvent evt) { try { Activity activity = new Activity(db, evt.ObjectUri); if (activity != null && activity.AssignedTo != null) { log.Debug($"Activity Uri {evt.ObjectUri}"); Workflow workflow = activity.Workflow; if (workflow != null && (workflow.Initiator != null && workflow.Initiator.RecordType.UsualBehaviour == RecordBehaviour.Folder)) { if (workflow.IsComplete) { log.Debug($"Workflow Uri {workflow.Uri} Is Completed"); // when no other assigned activities for this container TrimMainObjectSearch activitySearch = new TrimMainObjectSearch(db, BaseObjectTypes.Activity) { SearchString = $"workflow:[initiator:{workflow.Initiator.Number}] assignee:{activity.AssignedTo.Uri} not done" }; if (activitySearch.Count == 0) { // there are no other assigned activities TrimMainObjectSearch styleSearch = new TrimMainObjectSearch(db, BaseObjectTypes.CheckinStyle) { SearchString = $"owner:{activity.AssignedTo.Uri} container:{workflow.Initiator.Number}" }; foreach (CheckinStyle style in styleSearch) { style.Delete(); } } } else { log.Debug($"Workflow Uri {workflow.Uri} not completed"); // ensure that there is a check-in style for this container TrimMainObjectSearch styleSearch = new TrimMainObjectSearch(db, BaseObjectTypes.CheckinStyle) { SearchString = $"owner:{activity.AssignedTo.Uri} container:{workflow.Initiator.Number}" }; if (styleSearch.Count == 0) { log.Debug($"Creating new check-in style"); CheckinStyle style = new CheckinStyle(workflow.Initiator); style.RecordType = new RecordType(db, "Document"); style.Name = workflow.Initiator.Title; style.StyleOwner = activity.AssignedTo; style.MoveToDeletedItems = false; style.Save(); } else { log.Info("Check-in style already exists"); } } } } } catch (TrimException ex) { log.Error($"Exception: {ex.Message}", ex); } finally { } }