public string GetFullPathInboundFax(string fax) { string fullPath = string.Empty; List<InBoundFaxes> inBoundFaxesList = new List<InBoundFaxes>(); List<OutboundFaxDocument> outboundFaxDocumentList = new List<OutboundFaxDocument>(); string name = string.Empty; try { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { const string query = "SELECT [ID],[ActiveDirectoyUser],[Path],[Name]" + " FROM [PostOfficeFoldersByUser]" + " where [ActiveDirectoyUser] = @ActiveDirectoyUser"; inBoundFaxesList = db.Query<InBoundFaxes>(query, new { @ActiveDirectoyUser = Utility.GetUserName() }).ToList(); for (int i = 0; i < inBoundFaxesList.Count; i++) { OutboundFaxDocument outboundFaxDocument = new OutboundFaxDocument(); string[] filePaths = Directory.GetFiles(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] == fax) { return fullPath = inBoundFaxesList[i].Path + "\\" + fax; } } } } return ""; } } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return ""; } }
public List<OutboundFaxDocument> GetOutboundFaxes() { List<OutboundFaxDocument> outboundFaxDocumentList = new List<OutboundFaxDocument>(); OutboundFaxDocument outboundFaxDocument = new OutboundFaxDocument(); string[] filePaths = Directory.GetFiles(ConfigurationValues.OutboundFaxDirectory + "\\" + Utility.GetUserName()); for (int i = 0; i < filePaths.Length; i++) { string[] fileName = filePaths[i].Split('\\'); outboundFaxDocument = new OutboundFaxDocument(); outboundFaxDocument.ID = filePaths[i]; outboundFaxDocument.DocumentName = fileName[fileName.Length - 1]; outboundFaxDocumentList.Add(outboundFaxDocument); } return outboundFaxDocumentList; }
public List<OutboundFaxDocument> GetOutboundFaxes() { List<OutboundFaxDocument> outboundFaxDocumentList = new List<OutboundFaxDocument>(); OutboundFaxDocument outboundFaxDocument = new OutboundFaxDocument(); string[] filePaths = Directory.GetFiles(ConfigurationValues.OutboundFaxDirectory + "\\" + Utility.GetUserName()); for (int i = 0; i < filePaths.Length; i++) { string[] fileName = filePaths[i].Split('\\'); outboundFaxDocument = new OutboundFaxDocument(); outboundFaxDocument.id = fileName[fileName.Length - 1]; outboundFaxDocument.text = fileName[fileName.Length - 1]; outboundFaxDocument.expanded = true; outboundFaxDocument.spriteCssClass = ""; outboundFaxDocumentList.Add(outboundFaxDocument); } //JsonConvert.DeserializeObject<List<OutboundFaxDocument>> return outboundFaxDocumentList; //Movie m = JsonConvert.DeserializeObject<Movie>(json); }
public void MoveFileToFolder(MoveFile moveFile) { //1. Move the file to the new folder //2 Insert record giving folder that and name of document moveFile.FileName = moveFile.FileName.Replace("\n",""); moveFile.FilePath = moveFile.FilePath.Replace("\n", ""); moveFile.Folder = moveFile.Folder.Replace("\n", ""); List<InBoundFaxes> inBoundFaxesList = new List<InBoundFaxes>(); List<OutboundFaxDocument> outboundFaxDocumentList = new List<OutboundFaxDocument>(); string name = string.Empty; try { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { const string query = "SELECT PostOfficeFoldersByUser.ActiveDirectoyUser," + " PostOfficeFoldersByUser.Path,PostOfficeFoldersByUser.Name" + " FROM [PostOfficeFoldersByUser]" //+ " INNER JOIN HoldFolders" //+ " ON HoldFolders.ActiveDirectoyUser = PostOfficeFoldersByUser.ActiveDirectoyUser" + " where PostOfficeFoldersByUser.ActiveDirectoyUser = @ActiveDirectoyUser"; inBoundFaxesList = db.Query<InBoundFaxes>(query, new { @ActiveDirectoyUser = Utility.GetUserName() }).ToList(); for (int i = 0; i < inBoundFaxesList.Count; i++) { OutboundFaxDocument outboundFaxDocument = new OutboundFaxDocument(); string[] filePaths = Directory.GetFiles(inBoundFaxesList[i].Path); if (filePaths.Length > 0) { for (int j = 0; j < filePaths.Length; j++) { string[] fileName = filePaths[j].Split('\\'); if (moveFile.FileName == fileName[fileName.Length - 1]) { try { moveFile.ID = GetMoveFileId(moveFile.Folder, Utility.GetUserName(), moveFile.DocumentType); moveFile.FilePath = System.Configuration.ConfigurationManager.AppSettings["holdFolder"] + Utility.GetUserName() + "\\" + moveFile.FileNewName; System.IO.Directory.CreateDirectory(System.Configuration.ConfigurationManager.AppSettings["holdFolder"] + Utility.GetUserName()); AddFileToFolder(moveFile); string s2 = System.Configuration.ConfigurationManager.AppSettings["holdFolder"] + "\\" + moveFile.FileName; //moveFile.FileName = moveFile.FileName.Replace(" ", "_"); Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Moving file from " + filePaths[j] + " to " + System.Configuration.ConfigurationManager.AppSettings["holdFolder"] + "\\" + moveFile.FileName); File.Move(filePaths[j], moveFile.FilePath); Logging.LogErrors(ConfigurationValues.ErrorLogPath, "File successfully moved"); } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); } } } } } } } catch (Exception er) { string s1 = er.ToString(); //return outboundFaxDocumentList; } }