Last active
August 29, 2015 14:27
-
-
Save margusmartsepp/6fbd4e8c2976aa246d42 to your computer and use it in GitHub Desktop.
IB filename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string fullPath = Server.MapPath(FileUploadHelper.formFullPath(id.ToString(), fileUploadType, filename)); | |
| public static string formFullPath(Object id, FileUploadType type, Object fileName) | |
| { | |
| return formFullPath(id, type, fileName, false, null); | |
| } | |
| public static string formFullPath(Object id, FileUploadType type, Object fileName, bool needsMapping, HttpServerUtility server) | |
| { | |
| String fullPath = null; | |
| switch (type) | |
| { | |
| case FileUploadType.BusinessYearReport : fullPath = Constants.DirPaths.BusinessYearReport; break; | |
| } | |
| if (fullPath != null) | |
| { | |
| string path = fullPath + GetIdPath(id) + "\\" + fileName; | |
| if (needsMapping) | |
| { | |
| if (File.Exists(server.MapPath(path))) | |
| { | |
| return path; | |
| } | |
| else | |
| { | |
| BusinessYearReport byr = new BusinessYearReport(); | |
| businessyearreportEntityCollection ents = byr.GetBusinessYearReportByReportFile(fileName.ToString(), Convert.ToDecimal(id)); | |
| if (ents == null) return ""; | |
| foreach(businessyearreportEntity ent in ents) | |
| { | |
| path = fullPath + GetIdPath(ent.Id) + "\\" + fileName; | |
| if(File.Exists(server.MapPath(path))) | |
| { | |
| return path; | |
| } | |
| } | |
| return ""; | |
| } | |
| } | |
| return path; | |
| } | |
| return ""; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static string GetIdPath(Object id) | |
| { | |
| int n = 2; | |
| Stack<char> s = new Stack<char>(id.ToString().ToCharArray()); | |
| System.Text.StringBuilder idpath = new System.Text.StringBuilder(); | |
| while (s.Count > 0) | |
| { | |
| int counter = 0; | |
| if (s.Count % 2 == 1) | |
| { | |
| counter = n - 1; | |
| } | |
| else | |
| { | |
| counter = n; | |
| } | |
| System.Text.StringBuilder tempStr = new System.Text.StringBuilder(); | |
| for (int i = 0; i < counter; i++) | |
| { | |
| tempStr.Append(s.Pop()); | |
| } | |
| idpath.Append("\\").Append(tempStr.ToString()); | |
| } | |
| return idpath.ToString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment