internal static string CacheDownloadedFile(string url, string post_parameters, string response_url, string text, int page_count, string cycle_identifier, WebRoutineStatus state) { string file = SaveDownloadedFile(text, page_count, cycle_identifier); if (!Properties.Log.Default.LogPostRequestParameters) post_parameters = null; Cache.AddFile2CacheMap(url, post_parameters, file, response_url, state, true); return file; }
/// <summary> /// Cache downloaded file to current download dir /// </summary> /// <param name="content_is_text"></param> /// <param name="url"></param> /// <param name="response_url"></param> /// <param name="page">string to be saved</param> /// <param name="page_count">number of page within current bot cycle</param> /// <param name="cycle_identifier">identifier of current bot cycle</param> internal static string CacheDownloadedFile(bool content_is_text, string url, string post_parameters, string response_url, byte[] binary, int page_count, string cycle_identifier, WebRoutineStatus state) { string file = SaveDownloadedFile(content_is_text, binary, page_count, cycle_identifier); if (!Settings.Web.LogPostRequestParameters) post_parameters = null; Cache.AddFile2CacheMap(url, post_parameters, file, response_url, state, false); return file; }
internal void init_loading_progress(string url) { if (url != null) { Log.Write("Downloading:" + url); } show_progress(100, 0); if (url != null) { delay(url); if (Visible && OnLoading != null) { OnLoading.Invoke("URL:" + url); } } web_routine_status = WebRoutineStatus.UNDEFINED; }
internal static void AddFile2CacheMap(string url, string post_parameters, string path, string response_url, WebRoutineStatus file_mark, bool text) { if (path == null) return; try { lock (static_lock_variable) { if (cache_map_writer == null) { cache_map_writer = new XmlTextWriter(Log.DownloadDir + "\\" + CACHE_MAP_FILE_NAME, Encoding.UTF8); cache_map_writer.Formatting = Formatting.Indented; cache_map_writer.WriteStartDocument(); cache_map_writer.WriteStartElement("CacheMap"); if (cache_map == null) cache_map = new Dictionary<string, CacheInfo>(); } } lock (cache_map_writer) { cache_map_writer.WriteStartElement("File"); url = get_url_with_post(url, post_parameters); cache_map_writer.WriteAttributeString("url", url); if (url != response_url && string.IsNullOrEmpty(post_parameters)//POST request response does not used! ) cache_map_writer.WriteAttributeString("response_url", response_url); cache_map_writer.WriteAttributeString("path", Path.GetFileName(path)); if (file_mark != WebRoutineStatus.OK) cache_map_writer.WriteAttributeString("error", file_mark.ToString()); cache_map_writer.WriteAttributeString("text", text.ToString()); cache_map_writer.WriteEndElement(); cache_map_writer.Flush(); } add2cache_map(url, path, response_url); } catch (Exception e) { LogMessage.Exit(e); } }
internal void init_loading_progress(string url) { if (url != null) Log.Write("Downloading:" + url); show_progress(100, 0); if (url != null) { delay(url); if (Visible && OnLoading != null) OnLoading.Invoke("URL:" + url); } web_routine_status = WebRoutineStatus.UNDEFINED; }
internal static void AddFile2CacheMap(string url, string post_parameters, string path, string response_url, WebRoutineStatus file_mark, bool text) { if (path == null) { return; } try { lock (static_lock_variable) { if (cache_map_writer == null) { cache_map_writer = new XmlTextWriter(Log.DownloadDir + "\\" + CACHE_MAP_FILE_NAME, Encoding.UTF8); cache_map_writer.Formatting = Formatting.Indented; cache_map_writer.WriteStartDocument(); cache_map_writer.WriteStartElement("CacheMap"); if (cache_map == null) { cache_map = new Dictionary <string, CacheInfo>(); } } } lock (cache_map_writer) { cache_map_writer.WriteStartElement("File"); url = get_url_with_post(url, post_parameters); cache_map_writer.WriteAttributeString("url", url); if (url != response_url && string.IsNullOrEmpty(post_parameters) //POST request response does not used! ) { cache_map_writer.WriteAttributeString("response_url", response_url); } cache_map_writer.WriteAttributeString("path", Path.GetFileName(path)); if (file_mark != WebRoutineStatus.OK) { cache_map_writer.WriteAttributeString("error", file_mark.ToString()); } cache_map_writer.WriteAttributeString("text", text.ToString()); cache_map_writer.WriteEndElement(); cache_map_writer.Flush(); } add2cache_map(url, path, response_url); } catch (Exception e) { LogMessage.Exit(e); } }
/// <summary> /// Cache downloaded file to current download dir /// </summary> /// <param name="content_is_text"></param> /// <param name="url"></param> /// <param name="response_url"></param> /// <param name="page">string to be saved</param> /// <param name="page_count">number of page within current bot cycle</param> /// <param name="cycle_identifier">identifier of current bot cycle</param> internal static string CacheDownloadedFile(bool content_is_text, string url, string post_parameters, string response_url, byte[] binary, int page_count, string cycle_identifier, WebRoutineStatus state) { string file = SaveDownloadedFile(content_is_text, binary, page_count, cycle_identifier); if (!Properties.Log.Default.LogPostRequestParameters) { post_parameters = null; } Cache.AddFile2CacheMap(url, post_parameters, file, response_url, state, false); return(file); }
public static string CacheFile(string url, string post_parameters, string response_url, string text, string name, WebRoutineStatus state) { string file = SaveFile(text, name); Cache.AddFile2CacheMap(url, post_parameters, file, response_url, state, true); return(file); }
internal static string CacheDownloadedFile(string url, string post_parameters, string response_url, string text, int page_count, string cycle_identifier, WebRoutineStatus state) { string file = SaveDownloadedFile(text, page_count, cycle_identifier); if (!Settings.Web.LogPostRequestParameters) { post_parameters = null; } Cache.AddFile2CacheMap(url, post_parameters, file, response_url, state, true); return(file); }
internal static void AddFile2CacheMap(string url, string post_parameters, string path, string response_url, WebRoutineStatus file_mark, bool text) { if (path == null) { return; } try { lock (static_lock_variable) { if (cache_map_writer == null) { cache_map_writer = new StreamWriter(CacheDir + "\\" + CACHE_MAP_FILE_NAME, true, Encoding.UTF8); if (cache_map == null) { cache_map = new Dictionary <string, CacheInfo>(); } } } lock (cache_map_writer) { Dictionary <string, object> d = new Dictionary <string, object>(); d["url"] = url; if (url != response_url && string.IsNullOrEmpty(post_parameters) //POST request response does not used! ) { d.Add("response_url", response_url); } d.Add("path", Path.GetFileName(path)); if (file_mark != WebRoutineStatus.OK) { d.Add("error", file_mark); } d.Add("text", text); cache_map_writer.WriteLine(serializer.Serialize(d)); cache_map_writer.Flush(); } add2cache_map(url, path, response_url); } catch (Exception e) { LogMessage.Exit(e); } }
public static string CacheFile(string url, string post_parameters, string response_url, string text, string name, WebRoutineStatus state) { string file = SaveFile(text, name); Cache.AddFile2CacheMap(url, post_parameters, file, response_url, state, true); return file; }