public string processDailyTasks(string pathToTempDir, bool useSeperateThread, IMessageCallback msg) { this.myPathToTempDir = pathToTempDir; string retval = ""; string platform = ""; platform = utility.getParameter("platform"); if (platform == "localhost" | platform == "admin_production") { //not possible right now because DTS package can not be changed //if(Request.QueryString["requestor"] != null) //{ //start task expiration emails send_expiration_emails(); msg.AppendLine("expiration emails sent<br>"); ////start task scheduled reporting queue_scheduled_reports(useSeperateThread); msg.AppendLine("scheduled reports sent<br>"); //start task scheduled Master reporting queue_scheduled_masterreports(useSeperateThread); msg.AppendLine("scheduled Master reports sent<br>"); //start task crm_responses process_crm_records(); msg.AppendLine("crm records processed<br>"); //start task delete-archive empty campaigns delete_archive_empty_campaigns(); msg.AppendLine("delete-archive empty campaigns processed<br>"); //start task cid_responses //process_cid_records(); //} //start task cache_hpframes if (cache_hpframes(msg, useSeperateThread)) msg.AppendLine("caching hpframes finished<br>"); else msg.AppendLine("caching some or all hpframes failed!<br>"); } //Added by Phani on 16-04-2009 for RFG 1.9.2 release CaliberRM #PR126953 delete_old_temp_files(myPathToTempDir); msg.AppendLine("temp folder cleaned up<br>"); retval = msg.ToString(); return retval; }
public bool cache_hpframes(IMessageCallback msg, bool useSeparateThread) { try { bool success = true; List<CountryLanguageDto> countryLanguages = HpFramesFacade.GetListOfCountryLanguages(); Dictionary<string, Pair<string, string>> hpFrameChanges = new Dictionary<string, Pair<string, string>>(); int prevMsgIndex = msg.ToString().Length; foreach (CountryLanguageDto item in countryLanguages) { HpFramesDto hpFrames = HpFramesFacade.GetHpFramesFromService(item.CountryFK, item.LanguageFK); if ((hpFrames != null) && HpFramesFacade.StoreHpFramesToCache(hpFrames, hpFrameChanges)) { msg.AppendLine(String.Format("cached frameparts for ({0}-{1})<br>", item.CountryFK, item.LanguageFK)); } else { msg.AppendLine(String.Format("failed: frameparts for ({0}-{1})<br>", item.CountryFK, item.LanguageFK)); if (!string.IsNullOrEmpty(hpFrames.HeaderError)) { msg.AppendLine(String.Format("{0}<br>", hpFrames.HeaderError)); } if (!string.IsNullOrEmpty(hpFrames.FooterError)) { msg.AppendLine(String.Format("{0}<br>", hpFrames.FooterError)); } msg.AppendLine("<br>"); success = false; } } string cachingLog = msg.ToString().Substring(prevMsgIndex); // sent with E-Mail string path = Path.Combine(this.myPathToTempDir, "hpFrames\\"); if (Directory.Exists(path)) { Directory.Delete(path, true); } msg.AppendLine(String.Format("{0} changes found in frameparts.<br>", hpFrameChanges.Count)); StringCollection files = new StringCollection(); foreach (KeyValuePair<string, Pair<string, string>> item in hpFrameChanges) { string FileName = item.Key + ".txt"; string FileNameOld = item.Key + "_old.txt"; string pathFileName = Path.Combine(path, FileName); string pathFileNameOld = Path.Combine(path, FileNameOld); createDir(Path.GetDirectoryName(pathFileName)); string contentOld = fixHtml(item.Value.First); string contentNew = fixHtml(item.Value.Second); using (StreamWriter sw = File.CreateText(pathFileNameOld)) sw.Write(contentOld); msg.AppendLine(String.Format("create temp file: {0}.<br>", pathFileNameOld)); using (StreamWriter sw = File.CreateText(pathFileName)) sw.Write(contentNew); msg.AppendLine(String.Format("create temp file: {0}.<br>", pathFileName)); files.Add(FileNameOld); files.Add(FileName); } try { mailthread.generate_framepartsemail(path, files, cachingLog, useSeparateThread); msg.AppendLine("frameparts change-notification sent!<br>"); } catch (Exception e) { msg.AppendLine(String.Format("frameparts change-notification failed!<br>" + System.Environment.NewLine + "{0}<br>", e.Message)); } return success; } catch (Exception ex) // We do not throw this exception, as access to frameparts webservice may fail due to changes in webservice - this part is not vital for daily business, so it should not interrupt, just notify... { msg.AppendLine(String.Format("caching frameparts failed completely!<br>" + System.Environment.NewLine + "{0}<br>", ex.Message)); return false; } }