public List<InboundFaxDocument> GetHoldFolders(string folderType) { List<HoldFolders> holdFoldersList = new List<HoldFolders>(); InboundFaxDocument holdForTreeView = new InboundFaxDocument(); List<InboundFaxDocument> holdForTreeViewList = new List<InboundFaxDocument>(); try { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { string query = "SELECT [ID],[ActiveDirectoryUser],[FolderName]" + " FROM [HoldFolders]" + " where ActiveDirectoryUser = @ActiveDirectoryUser" + " and DocumentType = @DocumentType"; holdFoldersList = db.Query<HoldFolders>(query, new { @ActiveDirectoryUser = Utility.GetUserName(), @DocumentType = folderType }).ToList(); for(int i = 0; i< holdFoldersList.Count;i++) { holdForTreeView = new InboundFaxDocument(); holdForTreeView.Id = holdFoldersList[i].ID.ToString(); holdForTreeView.HasChildren = true; holdForTreeView.DocumentName = holdFoldersList[i].FolderName; holdForTreeViewList.Add(holdForTreeView); } return holdForTreeViewList; } } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return holdForTreeViewList; } }
public List<InboundFaxDocument> GetFilesInFolder(string holderFolderId) { List<HoldFolders> holdFoldersList = new List<HoldFolders>(); InboundFaxDocument holdForTreeView = new InboundFaxDocument(); List<InboundFaxDocument> holdForTreeViewList = new List<InboundFaxDocument>(); try { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { string query = "SELECT [ID],[HoldFolderID],[ActiveDirectoryUser],[FolderName],[FileName],[FilePath]" + " FROM [HoldFiles]" + " where HoldFolderID = @HoldFolderID"; holdFoldersList = db.Query<HoldFolders>(query, new { @HoldFolderID = holderFolderId }).ToList(); for (int i = 0; i < holdFoldersList.Count; i++) { holdForTreeView = new InboundFaxDocument(); holdForTreeView.FaxPath = holdFoldersList[i].FilePath; holdForTreeView.Id = holdFoldersList[i].ID; holdForTreeView.Expanded = true; holdForTreeView.DocumentName = holdFoldersList[i].FileName; holdForTreeViewList.Add(holdForTreeView); } return holdForTreeViewList; } } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return holdForTreeViewList; } }
public List<InboundFaxDocument> GetInboundFaxList() { List<InboundFaxDocument> inBoundFaxesList = new List<InboundFaxDocument>(); List<InboundFaxDocument> inboundFaxDocumentList = new List<InboundFaxDocument>(); try { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { string query = "SELECT [PostOfficeFoldersByUser].[ID],[PostOfficeFoldersByUser].[ActiveDirectoryUser]," + " [PostOfficeFolders].[FriendlyName] as Name,[PostOfficeFolders].[NewPath] as Path " + " FROM [PostOfficeFoldersByUser]" + " inner join [PostOfficeFolders]" + " on [PostOfficeFolders].id = [PostOfficeFoldersByUser].PostOfficeFoldersId" + " where [ActiveDirectoryUser] = @ActiveDirectoryUser"; inBoundFaxesList = db.Query<InboundFaxDocument>(query, new { @ActiveDirectoryUser = Utility.GetUserName() }).ToList(); Logging.LogErrors(ConfigurationValues.ErrorLogPath, inBoundFaxesList.Count.ToString()); for (int i = 0; i < inBoundFaxesList.Count; i++) { InboundFaxDocument inboundFaxDocument = new InboundFaxDocument(); Logging.LogErrors(ConfigurationValues.ErrorLogPath, ConfigurationValues.InboundFaxRoot + inBoundFaxesList[i].Path); string[] filePaths = Directory.GetFiles(ConfigurationValues.InboundFaxRoot + inBoundFaxesList[i].Path); if (filePaths.Length > 0) { for (int j = 0; j < filePaths.Length; j++) { string[] fileName = filePaths[j].Split('\\'); if (fileName[fileName.Length - 1] != "Thumbs.db") { inboundFaxDocument = new InboundFaxDocument(); //inboundFaxDocument.Id = ConfigurationValues.InboundFaxRoot + filePaths[j]; inboundFaxDocument.Id = filePaths[j]; inboundFaxDocument.DocumentName = fileName[fileName.Length - 1]; //inboundFaxDocument.FaxPath = ConfigurationValues.InboundFaxRoot + filePaths[j]; inboundFaxDocument.FaxPath = filePaths[j]; inboundFaxDocument.Expanded = true; inboundFaxDocument.DateUpdated = File.GetLastWriteTime(filePaths[j]); inboundFaxDocumentList.Add(inboundFaxDocument); } } } } List<InboundFaxDocument> sortedList = inboundFaxDocumentList.OrderByDescending(o => o.DateUpdated).ToList(); return sortedList; } } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return inboundFaxDocumentList; } }