public bool LoadLinksFromFile(string vsPath) { try { cFile oLogger = new cFile("Error.txt"); oLogger.Write("++++++++++++++++++++++++++"); oLogger.Write(vsPath); oLogger.Write("++++++++++++++++++++++++++"); cFile oFile = new cFile(vsPath); //oFile.FileName = ; List <String> sNewUrlList = oFile.ReadList(); for (int iCnt1 = 0; iCnt1 < sNewUrlList.Count(); iCnt1++) { oLogger.Write("-----" + iCnt1.ToString() + "-----"); string sUrl1 = sNewUrlList[iCnt1]; oLogger.Write(sUrl1); oLogger.Write("-----" + iCnt1.ToString() + "-----"); if (sUrl1.Length >= 28) { sUrl1 = FixFFdotNet(sUrl1); } if (sUrl1.Length >= 5) { msUrlList.Add(sUrl1);; } } return(true); } catch (Exception ex) { throw ex; } //throw new NotImplementedException(); }
private void AddDirectory(string directory) { DirectoryInfo di = new DirectoryInfo(directory); List <string> lstFile = new List <string>(); FileInfo[] fi = di.GetFiles(); foreach (FileInfo t in fi) { AddFile(t.FullName, ref lstFile); } foreach (string file in lstFile) { cFile cf = new cFile() { fileId = fileCount++, filename = file }; _fileCollection.Add(cf); } _updateFileCount?.Invoke(fileCount); DirectoryInfo[] diChild = di.GetDirectories(); foreach (DirectoryInfo t in diChild) { AddDirectory(t.FullName); } }
public bool LoadLinksFromFileToList(string vsPath) { try { cFile oLogger = new cFile("Error.txt"); oLogger.Write("++++++++++++++++++++++++++"); oLogger.Write(vsPath); oLogger.Write("++++++++++++++++++++++++++"); cFile oFile = new cFile(vsPath); //oFile.FileName = ; string pattern = "\r\n|\n"; String sNewUrlList = oFile.Read(); string[] sTs = Regex.Split(sNewUrlList, pattern); foreach (string sT in sTs) { } for (int iCnt1 = 0; iCnt1 < sTs.Count(); iCnt1++) { oLogger.Write("-----" + iCnt1.ToString() + "-----"); string sUrl1 = sTs[iCnt1]; oLogger.Write(sUrl1); oLogger.Write("-----" + iCnt1.ToString() + "-----"); CheckLink(sUrl1); } return(true); } catch (Exception ex) { throw ex; } //throw new NotImplementedException(); }
//importSortTextFileLinks private void MergeLinkFiles() { cFile oFile = new cFile("FilesLoaded"); try { string startupPath = Application.StartupPath; using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { // string folder = dialog.SelectedPath; lblOutput.Text = "started"; oMerge.ExportedLinkPath = "Merge.txt"; oMerge.GetLinks("C:\\Users\\joshua\\Desktop\\ff-links"); lblOutput.Text = "outputting"; oMerge.WriteLinks(); // oMerge.WriteLinks(); lblOutput.Text = "done"; } lblOutput.Text = "done"; } catch (Exception exc) { MessageBox.Show("Import failed because " + exc.Message + " , please try again later."); } }
public void ProcFiles() { fileCount = 0; List <string> lstFile = new List <string>(); foreach (string t in _file) { if (File.Exists(t)) { AddFile(t, ref lstFile); } } foreach (string file in lstFile) { cFile cf = new cFile() { fileId = fileCount++, filename = file }; _fileCollection.Add(cf); } _updateFileCount?.Invoke(fileCount); foreach (string t in _file) { if (Directory.Exists(t)) { AddDirectory(t); } } _processFileEndCallBack?.Invoke(-1, 0, TrrntZipStatus.Unknown); }
public bool LoadLinksFromFile(string vsPath) { cFile oLogger = new cFile("LoadLinksFromFile.Log"); try { // oLogger.Write("++++++++++++++++++++++++++"); // oLogger.Write(vsPath); // oLogger.Write("++++++++++++++++++++++++++"); cFile oFile = new cFile(vsPath); //oFile.FileName = ; List <String> sNewUrlList = oFile.ReadList(); Parallel.For(0, sNewUrlList.Count, x => { string sUrl1 = sNewUrlList[x]; // oLogger.Write(sUrl1); // oLogger.Write("-----" + iCnt1.ToString() + "-----"); msUrlList.Add(sUrl1);; }); return(true); } catch (Exception ex) { oLogger.WriteLog(ex.Message, "LoadLinksFromFileError.log"); throw ex; } //throw new NotImplementedException(); }
public bool SortLinks(string vsPath) { try { cFile oFile = new cFile(vsPath); string sFFdef1 = "http://m.fanfiction.net/s/"; string sFFdef2 = "https://m.fanfiction.net/s/"; //oFile.FileName = ; List <String> sUrlList = oFile.ReadList(); for (int iCnt = 0; iCnt < sUrlList.Count(); iCnt++) { // if (sUrlList[iCnt].Substring(0, 26) == "http://m.fanfiction.net/s/") // { if ((sUrlList[iCnt].Substring(0, 26) == sFFdef1) || (sUrlList[iCnt].Substring(0, 27) == sFFdef2)) { // } } return(true); } } catch (Exception ex) { throw ex; } return(false); }
public bool WriteLinks() { cFile oFile = new cFile(msExportedLinkPath); try { string sOutput = "" + msUrlList[0]; //oFile.FileName = msExportedLinkPath; for (int i = 1; i < msUrlList.Count; i++) { sOutput += Environment.NewLine + msUrlList[i]; } oFile.Write(sOutput); Parallel.For(0, sFileList.Count, x => { oFile.FileName = sFileList[x]; oFile.Delete(); }); return(true); } catch (Exception ex) { oFile.WriteLog(ex.Message, "WriteLinksError.log"); return(false); throw ex; } }
public bool GetLinks(string vsPath) { cFile oFile = new cFile(vsPath); cFile oLogger = new cFile("GetLinksErrorFilePaths.txt"); List <String> sUrlList = new List <string>(); try { sFileList = oFile.AllFileList(vsPath); Parallel.For(0, sFileList.Count, x => { string sFilePath = sFileList[x]; LoadLinksFromFile(sFilePath); _iFilesExtracted = _iFilesExtracted + 1; }); //throw new NotImplementedException(); return(true); } catch (Exception ex) { oFile.WriteLog(ex.Message, "GetLinksError.log"); throw ex; } }
public List <string> IdentifyLinks(string vsfileName) { cFile oFile = new cFile("ExtractedLinks"); List <string> oLinks = new List <string>(); StreamReader sr = new StreamReader(vsfileName); string input; string pattern = @"<A[^>]*?HREF\s*=\s*""([^""]+)""[^>]*?>([\s\S]*?)<\/A>"; Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase); while (sr.Peek() >= 0) { input = sr.ReadLine(); MatchCollection matches = rgx.Matches(input); if (matches.Count > 0) { foreach (Match match in matches) { oLinks.Add(match.Value); oFile.Write(match.Value); } } } sr.Close(); return(oLinks); }
public bool test3(string vsURL) { cWeb oWeb = new cWeb(); string htmlContent = oWeb.GrabPageToString(vsURL); // Obtain the document interface IHTMLDocument2 htmlDocument = (IHTMLDocument2) new mshtml.HTMLDocument(); // Construct the document htmlDocument.write(htmlContent); //htmlDocument. List <IHTMLElement> oOut = new List <IHTMLElement>(); // Extract all elements IHTMLElementCollection allElements = htmlDocument.all; cFile oFile = new cFile("ele.txt"); // Iterate all the elements and display tag names foreach (IHTMLElement element in allElements) { oFile.Write(element.tagName); } return(false); }
private static void ProcessError(string vsErrorType, string result) { cFile oFile = new cFile("error.txt"); oFile.Write("___________"); oFile.Write(vsErrorType + " Failed got back: " + result); oFile.Write("___________"); }
public List <String> GetLinksFromFile(string vsPath) { cFile oFile = new cFile(vsPath); //oFile.FileName = ; List <String> sUrlList = oFile.ReadList(); return(sUrlList); //throw new NotImplementedException(); }
public void SaveLinks() { cFile oFile = new cFile(output); foreach (var sUrl in oUrListList) { oFile.Write(sUrl); } }
public bool Save(string vsFileName) { try { cFile oFiler = new cFile(vsFileName); oFiler.Write(mstrName + "|" + mstrFileName + "|" + mstrLinkDefine); return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// Creates a cFile object. It will be saved in permanent storage only /// on calling Save() /// </summary> /// <returns>cFile object</returns> public static cFile Create() { cFile oObj = new cFile(); SecurityCheck((int)enFile_Action.Create); // Create an object in memory, will be saved to storage on calling Save() oObj.m_bCreating = true; oObj.m_bInvalid = false; return(oObj); }
/// <summary> /// Ensures that an object with the specified name exists, while creating other properties are set to their default values /// </summary> /// <param name="i_sName">Name</param> /// <returns>cFile object</returns> public static cFile CreateIfRequiredAndGet(string i_sName) { cFile oObj = cFile.Get_Name(i_sName); if (oObj == null) { oObj = cFile.Create(); oObj.sName = i_sName; oObj.Save(); } return(oObj); }
public bool Load() { if (File.Exists(msFileName)) { string[] oLinkCatRecord = null; cFile oFile = new cFile(msFileName); try { string sInput = oFile.Read(); // oLinkCatRecord = sInput.Split(Convert.ToChar(Constants.vbCrLf)); oLinkCatRecord = sInput.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string linkRow in oLinkCatRecord) { if (linkRow.Trim().Length > 3) { // Process a student record cLinkCategory oLinkCategory = new cLinkCategory(); string[] sLinkFields = null; sLinkFields = linkRow.Split('|'); var _with3 = oLinkCategory; _with3.Name = sLinkFields[0]; _with3.FileName = sLinkFields[1]; _with3.LinkDefine = sLinkFields[2]; oCatagories.Add(oLinkCategory); // Add(oLinkCategory); } } return(true); } catch (Exception ex) { //MessageBox.Show(ex.Message); cFile oLog = new cFile("error.log"); oLog.Write(ex.Message); } } else { File.Create("LinkCategories.txt"); Load(); } return(false); }
public bool GetLinkFilesFromFile(string spath) { try { cFile oFile = new cFile(spath); oFilesList = oFile.ReadList(); return(true); } catch (Exception) { return(false); } return(false); }
public bool ReadLinksFromTextFiles() { foreach (var sFile in oFilesList) { try { cFile oFile = new cFile(sFile); oUrListList.AddRange(oFile.ReadList()); } catch (Exception) { return(false); } } return(true); }
public bool SaveLinks(string vsFilePath) { try { var oFile = new cFile(vsFilePath); foreach (var sUrl in oUrListList) { oFile.Write(sUrl); } } catch (Exception) { return(false); } return(true); }
private async Task GetLinkValues(string folder, cFile oFile) { List <Task> oTasks = new List <Task>(); foreach (string fileName in Directory.GetFiles(folder, "*.txt", SearchOption.AllDirectories)) { Task oTask = ProcessFile(fileName); oTask.Start(); lblOutput.Text = fileName; oTasks.Add(oTask); oFile.Write(fileName); //SQLGenerator.GenerateSQLTransactions(Path.GetFullPath(fileName)); } await oTasks[0]; }
public void writeChildren(HtmlNode vNode) { cFile oFile = new cFile("nodes.txt"); foreach (HtmlNode link in vNode.ChildNodes) { oFile.Write("--"); oFile.Write("-----------------------------"); oFile.Write("-----------------------------"); oFile.Write("--"); oFile.Write(link.Name.ToString()); oFile.Write(link.XPath.ToString()); oFile.Write(link.InnerHtml); // writeChildren(link); } }
public ActionResult DevelopmentPlan(List <HttpPostedFileBase> file) { try { int loginID = Convert.ToInt32(HttpContext.User.Identity.Name); //FIle Upload:- if (file.Count > 0) { foreach (var item in file) { if (item != null) { cFile objfile = cFile.Create(); string filename = Path.GetFileNameWithoutExtension(item.FileName) + DateTime.Now.ToString().Replace('/', '_').Replace(':', '_') + Path.GetExtension(item.FileName); item.SaveAs((FilePath + filename)); objfile.sFileName = filename; objfile.objEmpLogin.iObjectID = loginID; objfile.objCareerDevelopmentPlan.iObjectID = 0; objfile.Save(); } } } string DevopmentPlan = Request.QueryString["DevelopmentPlan"]; List <Data> list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Data> >(DevopmentPlan); int LoginId = Convert.ToInt32(HttpContext.User.Identity.Name); for (var i = 0; i < list.Count; i++) { cCareerDevelopmentPlan objDevPlan = cCareerDevelopmentPlan.Create(); objDevPlan.sDevGoalName = list[i].GoalName; objDevPlan.sActionRequired = list[i].Action; objDevPlan.sTracking = list[i].Tracking; objDevPlan.sManagerComment = list[i].ManagerComment; objDevPlan.objStatus.iObjectID = list[i].StatusList; objDevPlan.objEmpLogin.iObjectID = LoginId; objDevPlan.Save(); } } catch (Exception ex) { throw ex; } return(RedirectToAction("DevelopmentGoals", "QuadrantMeasures")); //return View(objQuadrantMeasure); }
public bool ReadLinksFromHtmlFiles() { foreach (var sFile in oFilesList) { try { ReadHtmlFile(sFile); } catch (Exception ex) { cFile oFile = new cFile("error.log"); oFile.Write(sFile); oFile.Write(ex.Message); } } return(true); }
public bool Save() { // Delete the output file cFile oFile = new cFile(); oFile.Delete(); oFile = null; //foreach (cLinkCategory oLinkCategory in this) foreach (cLinkCategory oLinkCategory in oCatagories) { oLinkCategory.Save(msFileName); } return(true); }
private void importSortTextFileLinks() { cFile oFile = new cFile("FilesLoaded"); try { string startupPath = Application.StartupPath; using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = "Open a folder which contains the xml output"; // dialog.ShowNewFolderButton = false; // dialog.RootFolder = Environment.SpecialFolder.MyComputer; if (dialog.ShowDialog() == DialogResult.OK) { string folder = dialog.SelectedPath; lblOutput.Text = dialog.SelectedPath; foreach (string fileName in Directory.GetFiles(folder, "*.txt", SearchOption.AllDirectories)) { oTool.ExportedLinkPath = "Input.txt"; List <string> sUrls = oTool.GetLinksFromFile(fileName); oTool.WriteLinks(sUrls); oTool.AddUrlList(sUrls); oFile.Write(fileName); //SQLGenerator.GenerateSQLTransactions(Path.GetFullPath(fileName)); } oTool.Sort(); } } //using (OpenFileDialog dialog = new OpenFileDialog()) //{ // dialog.Filter = "xml files (*.xml)|*.xml"; // dialog.Multiselect = false; // dialog.InitialDirectory = "."; // dialog.Title = "Select file (only in XML format)"; // if (dialog.ShowDialog() == DialogResult.OK) // { // SQLGenerator.GenerateSQLTransactions(Application.StartupPath + Settings.Default.xmlFile); // } //} lblOutput.Text = "done"; } catch (Exception exc) { MessageBox.Show("Import failed because " + exc.Message + " , please try again later."); } }
public bool ReadHtmlFile(string vsFile) { //Read bookmarks from file try { cFile oFile = new cFile(vsFile); var bookmarks = oHtmlReader.Read(oFile.ReadFileStream()); foreach (var b in bookmarks.AllLinks) { oUrListList.Add(b.Url); } } catch (Exception) { return(false); } return(true); }
public FileResult Download(string id) { try { int fid = Convert.ToInt32(id); cFile objFile = cFile.Get_ID(fid); if (!String.IsNullOrEmpty(objFile.sFileName)) { HttpContext.Response.AddHeader("content-disposition", "attachment; filename=" + objFile.sFileName); } string path = FilePath + objFile.sFileName; HttpContext.Response.TransmitFile(path); return(File(path, System.Net.Mime.MediaTypeNames.Application.Octet)); } catch (Exception ex) { throw ex; } }
public bool WriteLinks() { try { cFile oFile = new cFile(msExportedLinkPath); //oFile.FileName = msExportedLinkPath; for (int iCnt = 0; iCnt < msUrlList.Count(); iCnt++) { oFile.Write(msUrlList[iCnt]); } return(true); } catch (Exception ex) { return(false); throw ex; } }
using System;