//public SimpleCompanyModel SimpleCompany //{ // get // { // if (null == _simpleCompany) // { // string code = this.GetCurrentCompanyCode(); // //ICacheHelper cacheHelper = new CacheHelper(BasicParam.SimpleCompanyModelKey); // var cacheContainer = CacheContainer.GetInstance(); // _simpleCompany = Enumerable.FirstOrDefault<SimpleCompanyModel>(cacheContainer.GetAllCompany(), i => string.Compare(i.Code, code, true) == 0); // if (null == _simpleCompany) // { // LogHelper.AddInfoLog("SimpleCompany is null and company code= '" + code + "'", "base.SimpleCompany"); // _simpleCompany = new SimpleCompanyModel(); // } // } // return _simpleCompany; // } //} //private SimpleCompanyModel _simpleCompany; //public List<SimpleCompanyModel> GetAllCompany() //{ // var cacheContainer = CacheContainer.GetInstance(); // return cacheContainer.GetAllCompany(); //} //public CompanyDisplayHelper GetCompanyDisplayAttribute() //{ // string code = this.GetCurrentCompanyCode(); // CompanyDisplayHelper company; // //ICacheHelper cacheHelper = new CacheHelper(BasicParam.CompanyDisplayAttributeKey); // var cacheContainer = CacheContainer.GetInstance(); // List<CompanyDisplayHelper> companyDisplayHelperList = cacheContainer.GetCompanyDisplayAttributeList();//cacheHelper.GetLinqCahce<CompanyDisplayHelper>(BaseBLL.GetCompanyDisplayAttributeList()); // company = companyDisplayHelperList.First(i => string.Compare(code, i.Code, true) == 0); // return company; //} //public void ClearCompanyDisplayHelper(string companyCode) //{ // var companyDisplayHelperList = (List<CompanyDisplayHelper>)HttpContext.Cache[BasicParam.CompanyDisplayAttributeKey] ?? new List<CompanyDisplayHelper>(); // var companyDisplay = companyDisplayHelperList.FirstOrDefault(c => c.Code == companyCode); // if (companyDisplay != null) // { // companyDisplayHelperList.Remove(companyDisplay); // HttpContext.Cache[BasicParam.CompanyDisplayAttributeKey] = companyDisplayHelperList; // } //} //public void ClearCompanyDisplayHelper(int companyId) //{ // var companyDisplayHelperList = (List<CompanyDisplayHelper>)HttpContext.Cache[BasicParam.CompanyDisplayAttributeKey] ?? new List<CompanyDisplayHelper>(); // var companyDisplay = companyDisplayHelperList.FirstOrDefault(c => c.Id == companyId); // if (companyDisplay != null) // { // companyDisplayHelperList.Remove(companyDisplay); // HttpContext.Cache[BasicParam.CompanyDisplayAttributeKey] = companyDisplayHelperList; // } //} //public void ClearCompanyDisplayHelper() //{ // string code = this.GetCurrentCompanyCode(); // ClearCompanyDisplayHelper(code); //} //public CompanyItemModel GetCurrentCompany() //{ // string code = this.GetCurrentCompanyCode(); // return BaseBLL.GetCurrentCompany(code); //} //public bool GetDisplayCreateOrUpdate() //{ // //bool result = true; // //int companyId = this.GetCurrentCompanyId(); // //if (companyId > 0) // //{ // // result = BaseBLL.GetCurrentCompanyDisplayCreateOrUpdate(companyId); // //} // //return result; // if (this.SimpleCompany == null) // return true; // else // return this.SimpleCompany.IsShowAdditionalField; //} //public bool GetDisplayCreateOrUpdate(int companyId) //{ // bool result = true; // //if (companyId > 0) // //{ // // result = BaseBLL.GetCurrentCompanyDisplayCreateOrUpdate(companyId); // //} // if (this.SimpleCompany != null) // { // result = this.SimpleCompany.IsShowAdditionalField; // } // return result; //} //public string GetCurrentCompanyName() //{ // //var company = this.GetCurrentCompany(); // //if (company == null || string.IsNullOrEmpty(company.Name)) // // return "Admin"; // //else // // return this.GetCurrentCompany().Name; // if (this.SimpleCompany == null || string.IsNullOrEmpty(this.SimpleCompany.Name)) // { // return "Admin"; // } // else // { // return this.SimpleCompany.Name; // } //} //public string GetCurrentCompanyDisplayName() //{ // //var company = this.GetCurrentCompany(); // //if (company == null || string.IsNullOrEmpty(company.Name)) // // return "Admin"; // //else // // return this.GetCurrentCompany().Name; // if (this.SimpleCompany == null || string.IsNullOrEmpty(this.SimpleCompany.DisplayName)) // { // return "Admin"; // } // else // { // return this.SimpleCompany.DisplayName; // } //} //public List<string> GetCurrentUserComapanyCodes(int userId) //{ // return BaseBLL.GetCurrentUserComapanyCodes(userId); //} //public List<string> GetAllCompanyCode() //{ // return BaseBLL.GetAllCompanyCode(); //} //public string GetCurrentCompanyCode() //{ // var company = this.ControllerContext.RouteData.Values["company"]; // string companyCode = company == null ? "" : company.ToString(); // return companyCode; //} //public string GetCompanyDateFormat() //{ // if (this.SimpleCompany == null) // { // return BasicParam.ShortDatetimeFormat; // } // if (!string.IsNullOrEmpty(this.SimpleCompany.DateFormatString)) // { // return this.SimpleCompany.DateFormatString; // } // else // { // return BasicParam.ShortDatetimeFormat; // } //} public DateTimeFormatInfo GetClientCultureDateFormate() { DateTimeFormatInfo dateTimeFormatInfo; try { var languages = Request.UserLanguages; if (languages == null && languages.Count() == 0) { //CultureInfo.InvariantCulture.DateTimeFormat dateTimeFormatInfo = Thread.CurrentThread.CurrentCulture.DateTimeFormat; } else { dateTimeFormatInfo = CultureInfo.GetCultureInfo(languages[0]).DateTimeFormat; } ViewBag.DateTimeFormatInfo = dateTimeFormatInfo; return(Thread.CurrentThread.CurrentCulture.DateTimeFormat); } catch (Exception ex) { LogHelper.AddErrorLog("Not support this culture.", this.ToString(), ex); dateTimeFormatInfo = Thread.CurrentThread.CurrentCulture.DateTimeFormat; ViewBag.DateTimeFormatInfo = dateTimeFormatInfo; return(Thread.CurrentThread.CurrentCulture.DateTimeFormat); } }
public static string GetAppSetting(string name) { string strSetting = string.Empty; if (ConfigurationManager.AppSettings.AllKeys.Contains(name)) { strSetting = ConfigurationManager.AppSettings[name]; } else { LogHelper.AddErrorLog("Missing element [" + name + "] in AppSetting section of WebConfig!", "WebConfig"); } return(strSetting); }
/// <summary> /// UI线程抛出全局异常事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { try { LogHelper.AddErrorLog(e.Exception.ToString()); MessageBox.Show("很抱歉,当前应用程序遇到一些问题,该操作已经终止,请进行重试,如果问题继续存在,请联系开发人员.", "意外的操作", MessageBoxButton.OK, MessageBoxImage.Information); e.Handled = true; } catch (Exception ex) { LogHelper.AddErrorLog(ex.ToString()); MessageBox.Show("应用程序发生不可恢复的异常,将要退出!"); } }
//public static SmtpSection GetMailSetting() //{ // SmtpSection netSmtpMailSection = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp"); // return netSmtpMailSection; //} public static string GetAppSetting(IConfiguration configuration, string name) { string strSetting = string.Empty; if (!string.IsNullOrEmpty(configuration.GetValue <string>(name))) { //ConfigurationHelper.GetAppSetting. strSetting = configuration.GetValue <string>(name); } else { LogHelper.AddErrorLog("Missing element [" + name + "] in AppSetting section of WebConfig!", "WebConfig"); } return(strSetting); }
/// <summary> /// 非UI线程抛出全局异常事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { var exception = e.ExceptionObject as Exception; if (exception != null) { LogHelper.AddErrorLog(exception.ToString()); } } catch (Exception ex) { LogHelper.AddErrorLog(ex.ToString()); MessageBox.Show("应用程序发生不可恢复的异常,将要退出!", "意外的操作", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void Log(object sendProcess, DataReceivedEventArgs output) { if (this.Dispatcher.CheckAccess()) { this.Dispatcher.Invoke(new ESBasic.CbGeneric <object, DataReceivedEventArgs>(Log), sendProcess, output); } else { this.Dispatcher.Invoke(new Action(delegate { if (!String.IsNullOrEmpty(output.Data)) { //Log LogHelper.AddErrorLog(output.Data); } })); } }
private void ThreadStart() { while (true) { if (ListQueue.Count > 0) { try { ScanQueue(); } catch (Exception ex) { LogHelper.AddErrorLog(ex.ToString()); } } else { //没有任务,休息3秒钟 //Thread.Sleep(3000); System.Threading.Thread.CurrentThread.Abort(); } } }
private void StartOnXml_OnClick(object sender, RoutedEventArgs e) { if (TabControl0.SelectedIndex == 2 && string.IsNullOrEmpty(waterMarkImg)) { System.Windows.Forms.MessageBox.Show("请选择要添加水印的图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //获取设置 cpuCount = AppConfigHelper.GetAppConfigInt("CpuCount"); threadCount = AppConfigHelper.GetAppConfigInt("ThreadCount"); //清空当前列表 ListQueue.Clear(); //清空进度条 this.pb.Maximum = 0; this.tb.Text = "0%"; this.pb.Value = 0; //先从根目录下查找xml XmlDocument xmldoc = new XmlDocument(); try { string xmlPath = System.AppDomain.CurrentDomain.BaseDirectory + "watermark.xml"; xmldoc.Load(xmlPath); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("xml文件加载出错", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LogHelper.AddErrorLog(ex.ToString()); return; } //获取节点列表 XmlNodeList topNode = xmldoc.DocumentElement.ChildNodes; foreach (XmlElement element in topNode) { var str = element.InnerText; var item = new VideoMp4(); var oldFilePath = str; // newFilePath.Substring(0,newFilePath.LastIndexOf(".")) var filename = oldFilePath.Substring(oldFilePath.LastIndexOf("\\")).Replace("\\", ""); var fileformat = filename.Substring(filename.LastIndexOf(".")); var newfilename = filename.Substring(0, filename.LastIndexOf(".")) + "_znykt_cnki" + fileformat; var newFilePath = oldFilePath.Substring(0, oldFilePath.LastIndexOf("\\")) + "\\" + newfilename; item.CmdString = string.Format(" -y -i \"{0}\" -vf \"movie={1},scale=170:60[watermark];[in][watermark]overlay=main_w-overlay_w-10:10[out]\" \"{2}\"", oldFilePath, waterMarkImg, newFilePath); item.NewFileName = newfilename; item.NewFilePath = newFilePath; item.OldFilePath = oldFilePath; item.OldfileName = filename; ListQueue.Enqueue(item); } if (ListQueue.Count == 0) { System.Windows.Forms.MessageBox.Show("该路径下未找到MP4格式的视频", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } LogTextBox.Clear(); LogTextBox.Text = "该目录下共找到 " + ListQueue.Count + " 个视频,开始进行转换......\n"; iAmount = ListQueue.Count; iCount = 0; iNow = 0; Thread thread = new Thread(ThreadStart); thread.IsBackground = true; thread.Start(); Select.IsEnabled = false; Start.IsEnabled = false; Select1.IsEnabled = false; Start1.IsEnabled = false; pb.Maximum = ListQueue.Count; }