private static void ForceLoadModel() { if (LingvisticsWorkInProcessorHelper.IsCreated) { return; } Task.Factory.StartNew(() => { lock ( _SyncLockForceLoadModel ) { if (LingvisticsWorkInProcessorHelper.IsCreated) { return; } try { //---Log.Info( "start 'ForceLoadModel'" ); var result = LingvisticsWorkInProcessorHelper.ProcessText(LocalParams.CreateLingvisticsTextInput4TextDummy()); Console.WriteLine(((result.IsNotNull() && result.RDF.IsNotNull()) ? result.RDF.Length : 0)); //---Log.Info( "end 'ForceLoadModel', IsCreated: " + LingvisticsWorkInProcessorHelper.IsCreated ); } catch (Exception ex) { Log.Error("error 'ForceLoadModel'", ex); } } }, TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness); }
public static ICollection <ISolrQuery> GetSolrNetFilters(Query query, out string facetExclusion) { facetExclusion = null; if (query.Filters != null && query.Filters.Any()) { var filters = new List <ISolrQuery>(); for (int i = 0; i < query.Filters.Count(); i++) { var filter = query.Filters.ElementAt(i); ISolrQuery solrQuery = new SolrQueryInList(filter.Name, filter.Values); if (i == query.Filters.Count() - 1) { var localParams = new LocalParams(new Dictionary <string, string> { { "tag", DefaultSettings.DefaultExcludePrefix + filter.Name } }); solrQuery = new LocalParams.LocalParamsQuery(solrQuery, localParams); facetExclusion = filter.Name; } filters.Add(solrQuery); } return(filters); } return(null); }
private void SetIsUploading(bool uploading) { LocalParams.InvokeIfRequired(c => c.Enabled = !uploading); RemoteParams.InvokeIfRequired(c => c.Enabled = !uploading); DoUpload.InvokeIfRequired(c => c.Enabled = !uploading); UploadProgress.InvokeIfRequired(c => c.Visible = uploading); }
/// <summary> /// Return the top <see cref="RESULTS" /> results for a given natural language query in a channel. /// </summary> public List <CodeDoc> NaturalLangQuery(string search, string channelId) { ISolrOperations <CodeDoc> solr = ServiceLocator.Current.GetInstance <ISolrOperations <CodeDoc> >(); var opts = new QueryOptions(); var lang = GetLanguageRequest(search); if (!string.IsNullOrEmpty(lang)) { opts.AddFilterQueries(new SolrQueryByField("prog_language", lang)); } opts.AddFilterQueries(new SolrQueryByField("channel", channelId)); opts.Rows = RESULTS; var query = new LocalParams { { "type", "boost" }, { "b", "recip(ms(NOW,author_date),3.16e-11,-1,1)" } } +(new SolrQuery("patch:\"" + search + "\"") || new SolrQuery("commit_message:\"" + search + "\"")); var codeQuery = solr.Query(query, opts); List <CodeDoc> results = new List <CodeDoc>(); foreach (CodeDoc doc in codeQuery) { results.Add(doc); } return(results); }
public static int BatchExec(List <string> list) { LocalParams lp = new LocalParams(); List <string> relist = SqlHelper.BatchExec(lp.SqlConnStr, list); return(relist.Count); }
public static FacetParameters GetSolrNetFacetParameters(Query query, string facetNameToExclude = null) { if (query.Facets != null && query.Facets.Any()) { var facetParams = new FacetParameters { Queries = new List <ISolrFacetQuery>() }; foreach (var facet in query.Facets) { string facetName = facet.FieldName; if (!string.IsNullOrEmpty(facetNameToExclude) && facet.FieldName == facetNameToExclude) { facetName = new LocalParams { { "ex", DefaultSettings.DefaultExcludePrefix + facetNameToExclude } } +facetNameToExclude; } facetParams.Queries.Add(new SolrFacetFieldQuery(facetName) { MinCount = facet.MinCount ?? 1 }); } return(facetParams); } return(null); }
public void NullValueThrows() { var p = new LocalParams { {"a", null} }; p.ToString(); }
public override string GetScript() { ShardMapManagerDatabaseNameSuffix = TaskOptions["ShardMapManagerDatabaseNameSuffix"]; Shard0DatabaseNameSuffix = TaskOptions["Shard0DatabaseNameSuffix"]; Shard1DatabaseNameSuffix = TaskOptions["Shard1DatabaseNameSuffix"]; UserName = LocalParams.FirstOrDefault(p => p.Name == "SqlCollectionUser")?.Value; Password = LocalParams.FirstOrDefault(p => p.Name == "SqlCollectionPassword")?.Value; DatabasePrefix = LocalParams.FirstOrDefault(p => p.Name == "SqlDbPrefix")?.Value; ServerInstance = GlobalParams.FirstOrDefault(p => p.Name == "SqlServer")?.Value; SqlAdminUser = GlobalParams.FirstOrDefault(p => p.Name == "SqlAdminUser")?.Value; SqlAdminPassword = GlobalParams.FirstOrDefault(p => p.Name == "SqlAdminPassword")?.Value; string baseScript = base.GetScript(); if (UnInstall) { return(baseScript); } //This script isn't invoked during uninstall. It's Ok. return(baseScript += scriptTemaplate .Replace("$(ServerInstance)", ServerInstance) .Replace("$(SqlAdminUser)", SqlAdminUser) .Replace("$(SqlAdminPassword)", SqlAdminPassword) .Replace("$(UserName)", UserName) .Replace("$(Password)", Password) .Replace("$(DatabasePrefix)", DatabasePrefix) .Replace("$(ShardMapManagerDatabaseNameSuffix)", ShardMapManagerDatabaseNameSuffix) .Replace("$(Shard0DatabaseNameSuffix)", Shard0DatabaseNameSuffix) .Replace("$(Shard1DatabaseNameSuffix)", Shard1DatabaseNameSuffix)); }
public void NullValueThrows() { var p = new LocalParams { { "a", null } }; p.ToString(); }
public void NullValueThrows() { var p = new LocalParams { { "a", null } }; Assert.Throws <SolrNetException>(() => p.ToString()); }
public void OperatorPlus() { var p = new LocalParams { {"type", "spatial"}, }; var q = new SolrQueryByField("field", "value"); var qq = p + q; Assert.AreEqual("{!type=spatial}field:(value)", SerializeQuery(qq)); }
public CodegenMethod AddParam(IList<CodegenNamedParam> @params) { if (LocalParams.IsEmpty()) { LocalParams = new List<CodegenNamedParam>(@params.Count); } LocalParams.AddAll(@params); return this; }
public CodegenMethod AddParam(CodegenNamedParam param) { if (LocalParams.IsEmpty()) { LocalParams = new List<CodegenNamedParam>(); } LocalParams.Add(param); return this; }
public virtual string GetSerializedParameters(IEnumerable <string> excludeList) { if (LocalParams.Count == 0) { return(null); } return(JsonConvert.SerializeObject(LocalParams.Where(p => !excludeList.Contains(p.Name)))); }
public void OperatorPlus_multiple_queries() { var p = new LocalParams { {"type", "spatial"}, }; var q = new SolrQueryByField("field", "value"); var q2 = new SolrQueryByRange<decimal>("price", 100m, 200m); var qq = p + (q + q2); Assert.AreEqual("{!type=spatial}(field:(value) price:[100 TO 200])", SerializeQuery(qq)); }
public void OperatorPlus() { var p = new LocalParams { { "type", "spatial" }, }; var q = new SolrQueryByField("field", "value"); var qq = p + q; Assert.AreEqual("{!type=spatial}field:(value)", SerializeQuery(qq)); }
public void OperatorPlus_multiple_queries() { var p = new LocalParams { { "type", "spatial" }, }; var q = new SolrQueryByField("field", "value"); var q2 = new SolrQueryByRange <decimal>("price", 100m, 200m); var qq = p + (q + q2); Assert.AreEqual("{!type=spatial}(field:(value) price:[100 TO 200])", SerializeQuery(qq)); }
public CodegenMethod AddParam( string typeName, string name) { if (LocalParams.IsEmpty()) { LocalParams = new List<CodegenNamedParam>(4); } LocalParams.Add(new CodegenNamedParam(typeName, name)); return this; }
public static void Error(ref LocalParams lp, Exception ex) { try { var message = string.Format("IP: '{0}', TYPE: '{1}', TEXT: '{2}'", (lp.Context.Request.UserHostName ?? lp.Context.Request.UserHostAddress), lp.ProcessType, lp.Text); LogManager.GetLogger(string.Empty).Error(message, ex); } catch { ; } }
public void SerializeWithLocalParams() { var q = new SolrFacetIntervalQuery("state"); var lp = new LocalParams(); lp.Add("key", "arizonatopen"); q.Sets.Add(new FacetIntervalSet(new FacetIntervalSetValue("az", false), new FacetIntervalSetValue("pa", false), lp)); var r = Serialize(q); Assert.Contains(KV.Create("facet.interval", "state"), r); Assert.Contains(KV.Create("f.state.facet.interval.set", "{!key=arizonatopen}(az,pa)"), r); }
private static string GetResultHtml(LocalParams lp) { var lingvisticsInput = new LingvisticsTextInput() { Text = lp.Text, AfterSpellChecking = false, BaseDate = DateTime.Now, Mode = SelectEntitiesMode.Full, GenerateAllSubthemes = false, }; #region [.result.] switch (lp.ProcessType) { case ProcessTypeEnum.Digest: #region [.code.] { lingvisticsInput.Options = LingvisticsResultOptions.OpinionMiningWithTonality; var lingvisticResult = _LingvisticsServer.Value.ProcessText(lingvisticsInput); var html = ConvertToHtml(lp.Context, lingvisticResult.OpinionMiningWithTonalityResult); return(html); } #endregion case ProcessTypeEnum.TonalityMarking: #region [.code.] { lingvisticsInput.TonalityMarkingInput = new TonalityMarkingInputParams4InProcess(); if (!lp.InquiryText.IsNullOrWhiteSpace()) { lingvisticsInput.TonalityMarkingInput.InquiriesSynonyms = lp.InquiryText.ToTextList(); } lingvisticsInput.ObjectAllocateMethod = lp.ObjectAllocateMethod.GetValueOrDefault(ObjectAllocateMethod.FirstVerbEntityWithRoleObj); lingvisticsInput.Options = LingvisticsResultOptions.Tonality; var lingvisticResult = _LingvisticsServer.Value.ProcessText(lingvisticsInput); var html = ConvertToHtml(lp.Context, lingvisticResult.TonalityResult, lp.OutputType); return(html); } #endregion default: throw (new ArgumentException(lp.ProcessType.ToString())); } #endregion }
private void FmSet_Load(object sender, EventArgs e) { lp = new LocalParams(); if (lp != null) { this.tbcron1.Text = lp.CronExpression1; this.tbcron2.Text = lp.CronExpression2; this.tbsqlconnstr.Text = lp.SqlConnStr; this.tbcronTaocan.Text = lp.CronExpressionTaocan; this.tbcronTaocanClose.Text = lp.CronExpressionTaocanClose; this.tbEpridBnetaccount.Text = lp.EprIdBnetAccount; this.tbUid.Text = lp.UID; this.tbPwd.Text = lp.PWD; } }
private static string GetResultHtml(LocalParams lp) { switch (lp.ProcessType) { case ProcessTypeEnum.Digest: #region [.code.] { var inputParams = new DigestInputParams(lp.Text, InputTextFormat.PlainText) { ExecuteTonalityMarking = true }; if (!lp.InquiryText.IsNullOrWhiteSpace()) { inputParams.InquiriesSynonyms = lp.InquiryText.ToTextList(); } if (lp.ObjectAllocateMethod.HasValue) { inputParams.ObjectAllocateMethod = lp.ObjectAllocateMethod.Value; } var html = GetDigestResultHtml(lp.Context, inputParams); return(html); } #endregion case ProcessTypeEnum.TonalityMarking: #region [.code.] { var inputParams = new TonalityMarkingInputParams(lp.Text); if (!lp.InquiryText.IsNullOrWhiteSpace()) { inputParams.InquiriesSynonyms = lp.InquiryText.ToTextList(); } if (lp.ObjectAllocateMethod.HasValue) { inputParams.ObjectAllocateMethod = lp.ObjectAllocateMethod.Value; } var html = GetTonalityMarkingResultHtml(lp.Context, inputParams, lp.OutputType); return(html); } #endregion default: throw (new ArgumentException(lp.ProcessType.ToString())); } }
public static object ExecuteScalar(string sql) { LocalParams lp = new LocalParams(); try { object obj = SqlHelper.ExecuteScalar(lp.SqlConnStr, System.Data.CommandType.Text, sql, null); return(obj); } catch (Exception ex) { model.MyDelegateFunc.WriteFmLog("SQLbll=>ExecuteScalar:ExceptionSQL:" + sql); model.MyDelegateFunc.WriteFmLog("SQLbll=>ExecuteScalar:ExceptionSQL:" + lp.SqlConnStr); model.MyDelegateFunc.WriteFmLog("SQLbll=>ExecuteScalar:Exception:" + ex); } return(null); }
public static bool MyShowDialog(List <Inline> message, string title, string showkey, Window owner = null, bool startUpCenterOwner = true, string okButtonText = null) { var isok = true; DispatcherEx.xInvoke(() => { if (LocalParams.GetWndNotTipAgainNeedShow(showkey)) { var wnd = new WndNotTipAgain(message, title, showkey, okButtonText); wnd.xSetOwner(owner); wnd.xSetStartUpLocation(startUpCenterOwner); var dlgRlt = wnd.ShowDialog(); isok = dlgRlt.HasValue && dlgRlt.Value; } }); return(isok); }
public static bool MyShowDialog(string message, string title = null, string showkey = null, Window owner = null, bool startUpCenterOwner = true) { var isok = true; DispatcherEx.xInvoke(() => { if (!string.IsNullOrEmpty(showkey)) { if (LocalParams.GetWndNotTipAgainNeedShow(showkey)) { var wnd = new WndNotTipAgain(message, title, showkey); wnd.xSetOwner(owner); wnd.xSetStartUpLocation(startUpCenterOwner); var dlgRlt = wnd.ShowDialog(); isok = dlgRlt.HasValue && dlgRlt.Value; } } }); return(isok); }
public static void MyShow(string message, string title = null, string showkey = null, bool showCancelButton = true, Action <bool, bool> callback = null, Window owner = null, bool startUpCenterOwner = true, string okButtonText = null) { DispatcherEx.xInvoke(() => { if (LocalParams.GetWndNotTipAgainNeedShow(showkey)) { var wnd = new WndNotTipAgain(message, title, showkey, showCancelButton); wnd.xSetOwner(owner); wnd.xSetStartUpLocation(startUpCenterOwner); wnd.xShowFirstTime(); wnd.IsShowed = true; wnd.Closed += (sender, e) => { callback(false, wnd.IsOkClicked); }; } else { callback(false, true); } }); }
/// <summary> /// Queries Solr and looks for exact matches /// </summary> /// <param name="search"></param> /// <param name="channelId"></param> /// <returns></returns> private List <CodeDoc> BasicQuery(string search, string channelId) { ISolrOperations <CodeDoc> solr = ServiceLocator.Current.GetInstance <ISolrOperations <CodeDoc> >(); List <ISolrQuery> filter = new List <ISolrQuery>(); var opts = new QueryOptions(); var lang = GetLanguageRequest(search); if (!string.IsNullOrEmpty(lang)) { filter.Add(new SolrQueryByField("prog_language", lang)); } filter.Add(new SolrQueryByField("channel", channelId)); foreach (var filt in filter) { opts.AddFilterQueries(filt); } // return top n results opts.Rows = RESULTS; var query = new LocalParams { { "type", "boost" }, { "b", "recip(ms(NOW,author_date),3.16e-11,-1,1)" } } +new SolrQuery("unindexed_patch:\"" + search + "\""); var codeQuery = solr.Query(query, opts); List <CodeDoc> results = new List <CodeDoc>(); foreach (CodeDoc doc in codeQuery) { results.Add(doc); } return(results); }
public void ProcessRequest(HttpContext context) { try { #region [.anti-bot.] var antiBot = context.ToAntiBot(); if (antiBot.IsNeedRedirectOnCaptchaIfRequestNotValid()) { antiBot.SendGotoOnCaptchaJsonResponse(); return; } #endregion var lp = new LocalParams(context) { Text = context.GetRequestStringParam("text", Config.MAX_INPUTTEXT_LENGTH), ProcessType = context.Request["processType"].TryConvert2Enum <ProcessTypeEnum>().GetValueOrDefault(ProcessTypeEnum.TonalityMarking), OutputType = (context.Request["splitBySentences"].TryToBool(false) ? OutputTypeEnum.Html_FinalTonalityDividedSentence : OutputTypeEnum.Html_FinalTonality), InquiryText = context.GetRequestStringParam("inquiryText", Config.MAX_INPUTTEXT_LENGTH), ObjectAllocateMethod = context.Request["objectAllocateMethod"].TryToEnum <ObjectAllocateMethod>(), }; #region [.anti-bot.] antiBot.MarkRequestEx(lp.Text); #endregion var sw = Stopwatch.StartNew(); var html = GetResultHtml(lp); sw.Stop(); context.Response.SendJson(html, sw.Elapsed); } catch (Exception ex) { context.Response.SendJson(ex); } }
/// <summary> /// Initializes a new instance of the <see cref="ExtendedCompositeQuery"/> class. /// </summary> /// <param name="query">The query.</param> /// <param name="filterQuery">The filter query.</param> /// <param name="methods">The methods.</param> /// <param name="virtualFieldProcessors">The virtual field processors.</param> /// <param name="facetQueries">The facet queries.</param> /// <param name="options">The options.</param> /// <param name="localParams">The local parameters.</param> public ExtendedCompositeQuery(AbstractSolrQuery query, AbstractSolrQuery filterQuery, IEnumerable<Sitecore.ContentSearch.Linq.Methods.QueryMethod> methods, IEnumerable<IFieldQueryTranslator> virtualFieldProcessors, IEnumerable<FacetQuery> facetQueries, QueryOptions options, LocalParams localParams = null) : base(query, filterQuery, methods, virtualFieldProcessors, facetQueries) { QueryOptions = options; LocalParams = localParams; }
//启动 private void toolStripBtnStart_Click(object sender, EventArgs e) { lp = new LocalParams(); if (lp == null) { MessageBox.Show("LocalParams为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(lp.CronExpression1) || string.IsNullOrEmpty(lp.CronExpression2)) { MessageBox.Show("请设置QZ运行表达示。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(lp.SqlConnStr)) { MessageBox.Show("请设置数据库连接字符串。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!SQLbll.IsConn(lp.SqlConnStr)) { MessageBox.Show("数据库连接字符串无效。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CreateJob cjob = new CreateJob(); if (!cjob.CheckCronExpression(lp.CronExpression1)) { MessageBox.Show(string.Format("表达试[{0}]无效", lp.CronExpression1), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!cjob.CheckCronExpression(lp.CronExpression2)) { MessageBox.Show(string.Format("表达试[{0}]无效", lp.CronExpression2), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } /* * if (!cjob.CheckCronExpression(lp.CronExpressionTaocan)) * { * MessageBox.Show(string.Format("表达试[{0}]无效", lp.CronExpressionTaocan), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } * * if (!cjob.CheckCronExpression(lp.CronExpressionTaocanClose)) * { * MessageBox.Show(string.Format("表达试[{0}]无效", lp.CronExpressionTaocanClose), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } * */ // [秒] [分] [小时] [日] [月] [周] [年],日和周必须互斥,不能都指明特定的数字或*,必须有一个是?; *号就是每的意思;?代表不确定; - 表示区间; ,表示多个值 // 0 58 9 23 * ?,每年每月23号9点58分0秒执行 // 0 0/1 * * * ?,第分钟执行一次 // 0 0 * * * ?,每小时一次 // 0 15 10 15 * ? 每月15日上午10:15触发 // 0 15 10 L * ? 每月最后一天的10点15分触发 string cron = "0 28 15 * * ?"; IScheduler sched = cjob.CreateSched(lp.CronExpression1, "trigger1", "group1", typeof(CreateBillJob)); if (sched != null) { schList.Add(sched); sched.Start(); } else { MessageBox.Show(string.Format("表达试[{0}] CreateBillJob初始化失败!", lp.CronExpression1), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IScheduler sched2 = cjob.CreateSched(lp.CronExpression2, "trigger2", "group2", typeof(CreateEmptyBillJob)); if (sched2 != null) { schList.Add(sched2); sched2.Start(); } else { MessageBox.Show("提示", string.Format("表达试[{0}] CreateBillJob初始化失败!", lp.CronExpression2), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } /* * IScheduler sched3 = cjob.CreateSched(lp.CronExpressionTaocan, "trigger3", "group3", typeof(CreateTaoCanBillJob)); * if (sched3 != null) * { * schList.Add(sched3); * sched3.Start(); * } * else * { * MessageBox.Show("提示", string.Format("表达试[{0}] CreateTaoCanBillJob初始化失败!", lp.CronExpressionTaocan), MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } */ /* * IScheduler sched4 = cjob.CreateSched(lp.CronExpressionTaocanClose, "trigger4", "group4", typeof(CreateTaoCanCloseBillJob)); * if (sched4 != null) * { * schList.Add(sched4); * sched4.Start(); * } * else * { * MessageBox.Show("提示", string.Format("表达试[{0}] CreateTaoCanCloseBillJob初始化失败!", lp.CronExpressionTaocanClose), MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } */ this.toolStripBtnStart.Enabled = false; this.toolStripStatusLabel2.Text = DateTime.Now.ToString("yyyy/MM/dd H:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);// string.Format("{0:yyyy\\/MM\\/dd HH:mm:ss}", DateTime.Now);//2005/11/5 14:23:20 这种格式更适合老外的格式; }
public EprInfoDAL() { lp = new LocalParams(); MySqlHelper.ConnectionstringLocalTransaction = lp.SqlConnStr; }
private static string GetResultHtml(LocalParams lp) { var lingvisticsInput = new LingvisticsTextInput() { Text = lp.Text, AfterSpellChecking = false, BaseDate = DateTime.Now, Mode = SelectEntitiesMode.Full, GenerateAllSubthemes = false, }; if (lingvisticsInput.Text.IsNullOrWhiteSpace()) { return("<div style='text-align: center; border: 1px silver solid; border-radius: 2px; background: lightgray; color: darkgray; padding: 15px;'>[INPUT TEXT IS EMPTY]</div>"); } try { var html = default(string); #region [.result.] switch (lp.ProcessType) { case ProcessTypeEnum.Digest: #region [.code.] { lingvisticsInput.Options = LingvisticsResultOptions.OpinionMiningWithTonality; var lingvisticResult = LingvisticsWorkInProcessorHelper.ProcessText(lingvisticsInput); html = ConvertToHtml(lp.Context, lingvisticResult.OpinionMiningWithTonalityResult); } #endregion break; case ProcessTypeEnum.TonalityMarking: #region [.code.] { lingvisticsInput.TonalityMarkingInput = new TonalityMarkingInputParams4InProcess(); if (!lp.InquiryText.IsNullOrWhiteSpace()) { lingvisticsInput.TonalityMarkingInput.InquiriesSynonyms = lp.InquiryText.ToTextList(); } lingvisticsInput.ObjectAllocateMethod = lp.ObjectAllocateMethod.GetValueOrDefault(ObjectAllocateMethod.FirstVerbEntityWithRoleObj); lingvisticsInput.Options = LingvisticsResultOptions.Tonality; var lingvisticResult = LingvisticsWorkInProcessorHelper.ProcessText(lingvisticsInput); html = ConvertToHtml(lp.Context, lingvisticResult.TonalityResult, lp.OutputType); } #endregion break; default: throw (new ArgumentException(lp.ProcessType.ToString())); } #endregion if (!lp.IsTextDummy) { Log.Info(ref lp); } return(html); } catch (Exception ex) { Log.Error(ref lp, ex); throw; } }
public void ProcessRequest(HttpContext context) { try { #region [.anti-bot.] var antiBot = context.ToAntiBot(); if (antiBot.IsNeedRedirectOnCaptchaIfRequestNotValid()) { antiBot.SendGotoOnCaptchaJsonResponse(); return; } #endregion #region [.force load 'LingvisticsWorkInProcess-with-OM-TM'.] var forceLoadModel = context.Request["forceLoadModel"].TryToBool(false); if (forceLoadModel) { ForceLoadModel(); context.Response.SendJson("bull-shit-mother-f***a", TimeSpan.Zero); return; } #endregion #region [.log.] #region [.view.] var viewLog = context.Request["viewLog"].TryToBool(false); if (viewLog) { //context.Response.SendText( Log.Read( context.Server, true ) ); context.Response.SendTextFile(context.Server.MapPath("~/(logs)/all.txt")); return; } #endregion #region [.delete.] var deleteLog = context.Request["deleteLog"].TryToBool(false); if (deleteLog) { Directory.Delete(context.Server.MapPath("~/(logs)"), true); context.Response.SendJson("bull-shit-mother-f***a", TimeSpan.Zero); return; } #endregion #endregion var lp = new LocalParams(context) { Text = context.GetRequestStringParam("text", Config.MAX_INPUTTEXT_LENGTH), ProcessType = context.Request["processType"].TryConvert2Enum <ProcessTypeEnum>().GetValueOrDefault(ProcessTypeEnum.TonalityMarking), OutputType = (context.Request["splitBySentences"].TryToBool(false) ? OutputTypeEnum.Html_FinalTonalityDividedSentence : OutputTypeEnum.Html_FinalTonality), InquiryText = context.GetRequestStringParam("inquiryText", Config.MAX_INPUTTEXT_LENGTH), ObjectAllocateMethod = context.Request["objectAllocateMethod"].TryToEnum <ObjectAllocateMethod>(), }; #region [.anti-bot.] antiBot.MarkRequestEx(lp.Text); #endregion var sw = Stopwatch.StartNew(); var html = GetResultHtml(lp); sw.Stop(); context.Response.SendJson(html, sw.Elapsed); } catch (Exception ex) { context.Response.SendJson(ex); } }