有谁知道一个好的.NET库规则库(理想情况下是开源的)?我需要的东西,可以做嵌套的逻辑表达式,如(A和B)和(B或C或d).我需要对对象属性进行比较,例如A.P1和B.P1.(理想情况下,我可以比较任何属性 - A.P1和B.P2).
它应该将规则存储在数据库中(我有很多简单的可配置逻辑).它应该有一个规则创建/管理API.管理工具必须检查实例以确定哪些属性可用以及存在哪些约束.
谢谢!
哦,还有一件事.作为规则引擎,我需要包含Actions(Commands)的概念.这些是表达式返回时执行的操作:
If (expression.Evaluation) { actions.Execute(); }
Run Code Online (Sandbox Code Playgroud)
所以我看到一条规则如下:
class Rule
{
Expression Exp;
Actions[] Actions;
Run()
{
if(Exp.Evaluate())
{
foreach(action in Actions)
{
action.Execute();
}
}
}
}
Run Code Online (Sandbox Code Playgroud) I have a running-state .php script that hits a URL and uploads a single/multiple files .csv type with a unique token sent with them (in the body AFAIK). Below is the working snippet:
PHP:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$ch = curl_init('http://demo.schooling.net/school/attendance');
$DirPath = "E:/Uploads/";
$ZKFiles=array();
if ($dh = opendir($DirPath))
{
while (($file = readdir($dh)) !== false)
{
if ($file == '.' || $file == '..')
{
continue;
}
$ZKFiles[]='@'.$DirPath.$file;
}
closedir($dh);
}
if(!empty($ZKFiles))
{
// Assign POST data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, …Run Code Online (Sandbox Code Playgroud) 想要解压缩从 API 获取的 GZipped 响应。尝试了下面的代码,它总是返回类似:-
\n\n\\u001f\xef\xbf\xbd\\b\\0\\0\\0\\0\\0\\0\\0\xef\xbf\xbdY]o........\nRun Code Online (Sandbox Code Playgroud)\n\n我的代码是:
\n\n private string GetResponse(string sData, string sUrl)\n {\n try\n {\n string script = null;\n try\n {\n string urlStr = @"" + sUrl + "?param=" + sData;\n\n Uri url = new Uri(urlStr, UriKind.Absolute);\n\n HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);\n request.Method = "GET";\n request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;\n\n using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())\n using (StreamReader reader = new StreamReader(response.GetResponseStream()))\n {\n script = reader.ReadToEnd();\n } \n }\n catch (System.Net.Sockets.SocketException)\n {\n // The remote site is currently …Run Code Online (Sandbox Code Playgroud) 我有一些简单的代码使用TTS生成一个wave文件,然后播放它:
public void TestSpeech()
{
SpeechSynthesizer synth = new SpeechSynthesizer();
using (MemoryStream stream = new MemoryStream())
{
synth.SetOutputToWaveStream(stream);
synth.Speak("Hello world");
stream.Seek(0, SeekOrigin.Begin);
IWaveSource source = new WaveFileReader(stream);
EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
var soundOut = new WasapiOut();
soundOut.Initialize(source);
soundOut.Stopped += (s, e) => waitHandle.Set();
soundOut.Play();
waitHandle.WaitOne();
soundOut.Dispose();
source.Dispose();
}
}
Run Code Online (Sandbox Code Playgroud)
一切都工作正常,但我想知道在我开始播放wave文件之前会持续多长时间.有没有计算这个的方法,或者它可以在某个地方使用?
如果它在某处可用,它是如何计算的?我假设它与流中的数据量有关,但是如何?
在Log-in.php中我有
$email=$_POST['email'];
$pass=$_POST['pass'];
$_SESSION['type'] = 'user';
$_SESSION['email'] = $email;
$_SESSION['pass']=$pass;
header('location:./connect.php');
Run Code Online (Sandbox Code Playgroud)
我收到的错误就像undefined index email其他用户登录一样
,另一方面我可以在这里以管理员身份登录..
我有一个登录表单,看看这是什么样的登录,并在此connect.php会话中传递该类型,检查它是什么类型,然后继续它运行良好,但不幸的是得到错误可以'再修改一下.
登录表单是用户,管理员和代理的一种形式,我可以以管理员身份登录,但我无法登录,因为其他显示错误
if(empty($_SESSION))
{
session_regenerate_id();
session_start();
}
@mysql_connect('localhost','root','') or die("ERROR in SERVER");
@mysql_select_db('module') or die("ERROR IN DATABASE");
$_SESSION['start'] = time(); // taking now logged in time
if(!isset($_SESSION['expire'])){
$_SESSION['expire'] = $_SESSION['start'] + (60* 60) ; // ending a session in 30 seconds
}
$now = time(); // checking the time now when home page starts
if($now > $_SESSION['expire'])
{
session_destroy(); …Run Code Online (Sandbox Code Playgroud) 当我在Visual Studio中创建一个新的空白应用程序(XAML)项目时,我得到以下错误:
一些引用的开头是不正确的.它应该在新的解决方案中真的像这样吗?(还没有写任何东西)如果我试图建立在这一点我得到:
无法解析Windows元数据
所以我想我会解决名称空间问题.这是通过添加对Window的引用并添加命名空间Windows.UI.XAML; 之后我得到超过3000(3136)个错误,其中一些是:
- .winmd文件'Windows.winmd'包含类型'Windows.Globalization.ILanguageStatics'.保留使用Windows命名空间.
- .winmd文件'Windows.winmd'包含类型'Windows.Globalization.ICalendarFactory'.保留使用Windows命名空间.
- .winmd文件'Windows.winmd'包含类型'Windows.Globalization.IGeographicRegion'.保留使用Windows命名空间.
- .winmd文件'Windows.winmd'包含类型'Windows.Globalization.DayOfWeek'.保留使用Windows命名空间.
- 等等
到目前为止我尝试过的
适用于Windows 8的Windows软件开发工具包(SDK)
我还要补充一点,我已将Windows 7升级到Windows 8.
有人对如何解决这个问题有任何建议吗?
只是无法通过datepicker验证获得它.我有datepicker From和datepicker To,所以我想阻止用户做一些功夫和seting datepicker 从比datepicker To更大,我碰到了一些问题但找不到答案,所以我尝试做最简单的我能想到的方式:
设置MaxDate属性datepicker 来自于form_load事件
private void Form1_Load(object sender, EventArgs e)
{
datepickerFrom.MaxDate = datepickerFrom.Value;
}
Run Code Online (Sandbox Code Playgroud)
然后为value_changed事件做同样的事情
private void datepickerFrom_ValueChanged(object sender, EventArgs e)
{
datepickerFrom.MaxDate = datepickerFrom.Value;
}
Run Code Online (Sandbox Code Playgroud)
这很简单,只有几行代码,而且我只需要datepickerFrom_ValueChanged事件,但最近我尝试输入日期datepicker来选择它,然后一切都崩溃了.所以我找到了一些验证解决方案,而不是设置MaxDate属性,我试过这个.
private void dtFrom_ValueChanged(object sender, EventArgs e)
{
DateTime from = datepickerFrom.Value;
DateTime to = datepickerTo.Value;
int year= from.Year > to.Year ? …Run Code Online (Sandbox Code Playgroud) 我在为扩展方法获取调用方时遇到了一些问题。
搜索了互联网,但找不到与我的问题类似的任何东西。 这个问题是一个紧急电话...
我有一个扩展方法:
public static void TabToNextField(this FrameworkElement i, FrameworkElement nextField)
{
i.KeyPress(Keys.Tab);
var isNextFieldFocused = nextField.GetProperty<bool>("IsFocused");
if (!isNextFieldFocused)
{
//Taborder is incorrect. Next field wasn't focused!
//This wont work since 'this' can't be used in a static context.
var currentProcedure = this.GetType().Name;
var fromField = i.AutomationId;
var toField = nextField.AutomationId;
//Log to file..
}
}
Run Code Online (Sandbox Code Playgroud)
这用于一些自动化测试,以验证nextfield是否具有焦点并且制表符顺序正确。但是对于应该记录的错误,我想获取调用方的类名称,以获取准确的报告,我们可以直接查看错误在应用程序中的位置。
由于所有控件都使用AutomationId,因此控件易于识别。
所以问题是:如何从该扩展方法中获取调用者方法?
嘿家伙我有这个问题,我只是不能让我的敌人旋转我的角色我已经尝试了几天,但周围没有问过什么,所以如果你能给我一些想法它会很棒.
这是我的敌人类现在在这个代码这里一切正常它做我想要的,但它面向鼠标而不是我的角色
class Class1
{
Character character = new Character();
EnemyShip blah = new EnemyShip();
Texture2D texture;
Rectangle rectangle;
public Vector2 origin;
public Vector2 velocity;
public Vector2 position;
float rotation;
const float forwardvelocity = 1f;
float friction = 0.1f;
public Vector2 distance;
public void LoadContent(ContentManager Content)
{
texture = Content.Load<Texture2D>("Ships/WarShip");
position = new Vector2(800, 300);
}
public void Update(GameTime gameTime)
{
MouseState mouse = Mouse.GetState();
distance.X = mouse.X - position.X; // these two line are the one i want to …Run Code Online (Sandbox Code Playgroud) 当出现异常时,我想确保在创建阅读器后关闭阅读器。所以我想在这个 try and catch 中包含一个 finally 括号。但是我不能在 finally 括号中关闭它,除非我在 try 括号上方声明了读者。但是如果我这样做了,我在创建阅读器时就不会捕捉到任何异常。我不确定是否关闭读者有多重要。
XmlSerializer xmlSr = new XmlSerializer(typeof(List<ProjectObject>));
try
{
FileStream reader = new FileStream(mTextFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
List<ProjectObject> addProjects = (List<ProjectObject>)xmlSr.Deserialize(reader);
mSharedDriveLocalProjects = addProjects;
reader.Close();
}
catch
{
MessageBox.Show("Failed to load XML file");
}
Run Code Online (Sandbox Code Playgroud)
以上是我的代码。用这种方式更好吗?
XmlSerializer xmlSr = new XmlSerializer(typeof(List<ProjectObject>));
FileStream reader = new FileStream(mTextFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
try
{
List<ProjectObject> addProjects = (List<ProjectObject>)xmlSr.Deserialize(reader);
mSharedDriveLocalProjects = addProjects;
}
catch
{
MessageBox.Show("Failed to load XML file");
}
finally
{
reader.Close();
}
Run Code Online (Sandbox Code Playgroud) c# ×9
.net ×2
php ×2
.net-core ×1
asp.net-mvc ×1
compression ×1
cscore ×1
datepicker ×1
get ×1
gzip ×1
httpclient ×1
logic ×1
request ×1
rule-engine ×1
session ×1
try-catch ×1
webclient ×1
winforms ×1
xna ×1