public string Validate(int numeral) { SLogger.LogInfoFormat("Validating {0}", numeral); ValidationResult result = this.arabicNumeralValidator.Validate(numeral); return(this.Validate(result)); }
/// <summary> /// 最简单的Http请求(操作类)应答处理函数,需要自己扩展 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="control"></param> /// <param name="response"></param> /// <param name="context"></param> public static void CommOpResponseCommHandler <T>(this Control control, HttpResponse response, object context) where T : BaseOpResult { control.Dispatcher.BeginInvoke(new Action <HttpResponse>((result) => { var strHandleMsg = ""; try { var requestUrl = response.RequestMessage?.RequestUri; if (null == result) { strHandleMsg = string.Format("服务处理{0}失败,应答数据为空!", requestUrl?.AbsolutePath); WaitingDialog.ChangeStateMsg(strHandleMsg); SLogger.Err(result.ToString()); //MessageBox.Show(string.Format("服务处理{0}失败,应答数据为空!", requestUrl?.AbsolutePath)); return; } if (result.StatusCode == HttpStatusCode.OK) { var opResult = JsonHelper.DeserializeTo <T>(result.ResponseContent); if (opResult.ResultCode != QueryResultCode.Succeed) { // 操作失败 //MessageBox.Show(string.Format("服务{0}处理失败,原因:{1}", requestUrl?.AbsolutePath, opResult.RetMsg)); strHandleMsg = string.Format("服务{0}处理失败,原因:{1}", requestUrl?.AbsolutePath, opResult.RetMsg); WaitingDialog.ChangeStateMsg(strHandleMsg); SLogger.Err(result.ToString()); return; } else { // 操作成功 var succeedMsg = opResult.RetMsg; WaitingDialog.ChangeStateMsg(succeedMsg); } } else { strHandleMsg = string.Format("后台请求失败,原因:{0}", result.ResponseContent); WaitingDialog.ChangeStateMsg(strHandleMsg); SLogger.Err(result.ToString()); return; } } catch (Exception ex) { strHandleMsg = string.Format("软件处理出错,msg:{0}", ex.Message); WaitingDialog.ChangeStateMsg(strHandleMsg); SLogger.Err(result.ToString(), ex); return; } }), DispatcherPriority.DataBind, new object[] { response }); }
protected override Result ParseJson(string json) { Result result = base.ParseJson(json); byte[] imgData = webClient.DownloadData(result.Link); SLogger.Info(this, "Converting"); result.ImageMemoryStream = new MemoryStream(imgData); SLogger.Info(this, "Converted"); return(result); }
public static void Init() { SLogger.Info("OFM", "Open Fx loading"); SLogger.Info("OFM", "Injecting API"); FxLoader.LoadBase(new AutumnBox_GUI_Calller()); SLogger.Info("OFM", "Injected API"); SLogger.Info("OFM", "Loading extensions"); FxLoader.LoadExtensions(); SLogger.Info("OFM", "Loaded extensions"); }
public static void Start(string className) { try { AtmbContext.Instance.NewExtensionThread(className)?.Start(); } catch (Exception e) { SLogger.Warn(nameof(ExtensionBridge), "extension not found", e); } }
public string GetProductValue(string content, int lineNumber) { if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content)) { SLogger.LogWarnFormat("Line number {0} does not have a valid product value. Skipping...", lineNumber); return(string.Empty); } int creditsIndex = -1; if (this.DoesContentContainArabicNumerals(content, out creditsIndex) && creditsIndex > 0) { // Assuming that Credits is the last text in the content. if (!(content.Reverse().ToString().StartsWith(CREDITS_TEXT.Reverse().ToString()))) { SLogger.LogWarn("Credits text is not the last word of the content. Skipping..."); return(string.Empty); } // Assuming that Credits are linked to Arabic Numerals int number = 0; string numberString = content.Substring(0, creditsIndex - 1).Trim(); int.TryParse(numberString, out number); string error = this.validator.Validate(number); if (!string.IsNullOrEmpty(error)) { SLogger.LogWarnFormat("Validation issue found for arabic numeric value: {0} \nError: {1} on Line Number: {2}. Skipping...", numberString, error, lineNumber); return(string.Empty); } return(number.ToString()); } else { // Else, the value is in Roman numeral representation string romanNumeral = content.Trim(); string error = this.validator.Validate(content.Trim()); if (!string.IsNullOrEmpty(error)) { SLogger.LogWarnFormat("Validation issue found for roman numberal: {0} \nError: {1} on Line Number: {2}. Skipping...", romanNumeral, error, lineNumber); return(string.Empty); } return(romanNumeral); } }
static public string Translate(string content, string companyAdminUserID) { try { var sUsers = SDefines.ApplicationContainer.Resolve <SCompaniesAdminUsersService>(); //LanguageCode languageCode = sUsers.GetLanguageCode(userID); //if (languageCode == LanguageCode.English) return content; //return TranslateToLanguageCode(content, languageCode); } catch (Exception ex) { SLogger.Error(ex); } return(content); }
protected void _OpenGoUrl(object para) { var goPre = App.Current.Resources["UrlGoPrefix"] as string; try { Process.Start(goPre + para); } catch (Exception e) { SLogger.Warn(this, $"can not open url {para}", e); } }
private void DisplayTextAd(IXCardsManager xCardsManager) { try { var jsonString = webClient.DownloadString(TEXTAD); var card = JsonSerializer.Deserialize <TextADCard>(jsonString); xCardsManager.Register(card); } catch (Exception e) { SLogger <EAutumnBoxAdFetcher> .Warn(e); } }
private void InterpretProduct <T>(IDictionary <string, T> productCache, string product, T productValue) { if (!productCache.ContainsKey(product)) { productCache.Add(product, productValue); } else { SLogger.LogDebugFormat("ProductCache:{0} already contains the product:{1} with value:{2}. New value that missed update:{3}" + "\n This can possibly be a false positive due to Intergalactic Products being 'Tagged' with Earthy Products.", productCache.GetType(), product, productCache[product], productValue); } }
public void SubmitJobThrowsContractException506() { try { Owner owner; Dictionary<Owner, List<Job>> dictionary; List<Job> list; Dictionary<JobType, List<Job>> dictionary1_; Dictionary<JobType, uint> dictionary2_; BenchmarkSystem.Scheduler scheduler; SBenchmarkSystem sBenchmarkSystem; SLogger sLogger; BenchmarkSystem benchmarkSystem; owner = PexInvariant.CreateInstance<Owner>(); PexInvariant.SetField<string>((object)owner, "<Name>k__BackingField", "\0"); PexInvariant.CheckInvariant((object)owner); dictionary = new Dictionary<Owner, List<Job>>(0); dictionary[owner] = (List<Job>)null; Job[] jobs = new Job[0]; list = new List<Job>((IEnumerable<Job>)jobs); dictionary1_ = new Dictionary<JobType, List<Job>>(4); dictionary1_[JobType.SHORT] = (List<Job>)null; dictionary2_ = new Dictionary<JobType, uint>(1); dictionary2_[JobType.SHORT] = 0u; scheduler = PexInvariant.CreateInstance<BenchmarkSystem.Scheduler>(); PexInvariant.SetField<uint>((object)scheduler, "_shortJobsRunning", 0u); PexInvariant.SetField<uint>((object)scheduler, "_longJobsRunning", 0u); PexInvariant.SetField<uint>((object)scheduler, "_veryLongJobsRunning", 0u); PexInvariant.SetField<List<Job>>((object)scheduler, "_shortList", list); PexInvariant.SetField<List<Job>>((object)scheduler, "_longList", list); PexInvariant.SetField<List<Job>>((object)scheduler, "_veryLongList", list); PexInvariant.SetField<List<Job>>((object)scheduler, "_jobSequence", list); PexInvariant.SetField<Dictionary<JobType, List<Job>>> ((object)scheduler, "_listByJobtype", dictionary1_); PexInvariant.SetField<Dictionary<JobType, uint>> ((object)scheduler, "_counterByJobtype", dictionary2_); PexInvariant.SetField<EventHandler> ((object)scheduler, "JobDone", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)scheduler, "JobFailed", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)scheduler, "JobTerminated", (EventHandler)null); PexInvariant.CheckInvariant((object)scheduler); sBenchmarkSystem = new SBenchmarkSystem(); sLogger = new SLogger((BenchmarkSystem)sBenchmarkSystem); benchmarkSystem = PexInvariant.CreateInstance<BenchmarkSystem>(); PexInvariant.SetField<BenchmarkSystem.Scheduler> ((object)benchmarkSystem, "_scheduler", scheduler); PexInvariant.SetField<Logger> ((object)benchmarkSystem, "_logger", (Logger)sLogger); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobSubmitted", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobCancelled", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobRunning", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobTerminated", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobFailed", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobDone", (EventHandler)null); PexInvariant.SetField<List<Job>>((object)benchmarkSystem, "_threads", list); PexInvariant.SetField<Dictionary<Owner, List<Job>>> ((object)benchmarkSystem, "_jobs", dictionary); PexInvariant.SetField<bool>((object)benchmarkSystem, "_isFinishing", false); PexInvariant.SetField<BSStatus> ((object)benchmarkSystem, "<Status>k__BackingField", BSStatus.Ready); PexInvariant.CheckInvariant((object)benchmarkSystem); this.SubmitJob(benchmarkSystem, (Job)null); throw new AssertFailedException("expected an exception of type ContractException"); } catch(Exception ex) { if (!PexContract.IsContractException(ex)) throw ex; } }
public void FinishCurrentJobs249() { Owner owner; Dictionary<Owner, List<Job>> dictionary; List<Job> list; Dictionary<JobType, List<Job>> dictionary1_; Dictionary<JobType, uint> dictionary2_; BenchmarkSystem.Scheduler scheduler; SBenchmarkSystem sBenchmarkSystem; SLogger sLogger; BenchmarkSystem benchmarkSystem; owner = PexInvariant.CreateInstance<Owner>(); PexInvariant.SetField<string>((object)owner, "<Name>k__BackingField", "\0"); PexInvariant.CheckInvariant((object)owner); dictionary = new Dictionary<Owner, List<Job>>(0); dictionary[owner] = (List<Job>)null; Job[] jobs = new Job[0]; list = new List<Job>((IEnumerable<Job>)jobs); dictionary1_ = new Dictionary<JobType, List<Job>>(4); dictionary1_[JobType.SHORT] = (List<Job>)null; dictionary2_ = new Dictionary<JobType, uint>(1); dictionary2_[JobType.SHORT] = 0u; scheduler = PexInvariant.CreateInstance<BenchmarkSystem.Scheduler>(); PexInvariant.SetField<uint>((object)scheduler, "_shortJobsRunning", 0u); PexInvariant.SetField<uint>((object)scheduler, "_longJobsRunning", 0u); PexInvariant.SetField<uint>((object)scheduler, "_veryLongJobsRunning", 0u); PexInvariant.SetField<List<Job>>((object)scheduler, "_shortList", list); PexInvariant.SetField<List<Job>>((object)scheduler, "_longList", list); PexInvariant.SetField<List<Job>>((object)scheduler, "_veryLongList", list); PexInvariant.SetField<List<Job>>((object)scheduler, "_jobSequence", list); PexInvariant.SetField<Dictionary<JobType, List<Job>>> ((object)scheduler, "_listByJobtype", dictionary1_); PexInvariant.SetField<Dictionary<JobType, uint>> ((object)scheduler, "_counterByJobtype", dictionary2_); PexInvariant.SetField<EventHandler> ((object)scheduler, "JobDone", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)scheduler, "JobFailed", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)scheduler, "JobTerminated", (EventHandler)null); PexInvariant.CheckInvariant((object)scheduler); sBenchmarkSystem = new SBenchmarkSystem(); sLogger = new SLogger((BenchmarkSystem)sBenchmarkSystem); benchmarkSystem = PexInvariant.CreateInstance<BenchmarkSystem>(); PexInvariant.SetField<BenchmarkSystem.Scheduler> ((object)benchmarkSystem, "_scheduler", scheduler); PexInvariant.SetField<Logger> ((object)benchmarkSystem, "_logger", (Logger)sLogger); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobSubmitted", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobCancelled", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobRunning", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobTerminated", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobFailed", (EventHandler)null); PexInvariant.SetField<EventHandler> ((object)benchmarkSystem, "JobDone", (EventHandler)null); PexInvariant.SetField<List<Job>>((object)benchmarkSystem, "_threads", list); PexInvariant.SetField<Dictionary<Owner, List<Job>>> ((object)benchmarkSystem, "_jobs", dictionary); PexInvariant.SetField<bool>((object)benchmarkSystem, "_isFinishing", false); PexInvariant.SetField<BSStatus> ((object)benchmarkSystem, "<Status>k__BackingField", BSStatus.Ready); PexInvariant.CheckInvariant((object)benchmarkSystem); this.FinishCurrentJobs(benchmarkSystem); Assert.IsNotNull((object)benchmarkSystem); Assert.AreEqual<BSStatus>(BSStatus.Stopped, benchmarkSystem.Status); }