Here are the examples of the csharp api string.IsNullOrEmpty() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
598 Examples
19
Source : AppInfo.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IDictionary<String, String> ReadWmic(String type, String where, params String[] keys)
{
var dic = new Dictionary<String, String>(StringComparer.OrdinalIgnoreCase);
var args = $"{type} where {where} get {keys.Join(",")} /format:list";
var str = Execute("wmic", args)?.Trim();
if (str.IsNullOrEmpty()) return dic;
var ss = str.Split(Environment.NewLine);
foreach (var item in ss)
{
var ks = item.Split("=");
if (ks != null && ks.Length >= 2)
{
var k = ks[0].Trim();
var v = ks[1].Trim();
if (dic.TryGetValue(k, out var val))
dic[k] = val + "," + v;
else
dic[k] = v;
}
}
// 排序,避免多个磁盘序列号时,顺序变动
foreach (var item in dic)
{
if (item.Value.Contains(','))
dic[item.Key] = item.Value.Split(',').OrderBy(e => e).Join();
}
return dic;
}
19
Source : StarTracer.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static StarTracer Register(String server = null)
{
if (server.IsNullOrEmpty())
{
var set = Setting.Current;
server = set.Server;
}
if (server.IsNullOrEmpty())
{
var local = new LocalStarClient();
var inf = local.GetInfo();
server = inf?.Server;
if (!server.IsNullOrEmpty()) XTrace.WriteLine("星尘探测:{0}", server);
}
if (server.IsNullOrEmpty()) return null;
if (Instance is StarTracer tracer && tracer.Client is ApiHttpClient) return tracer;
tracer = new StarTracer(server) { Log = XTrace.Log };
tracer.AttachGlobal();
return tracer;
}
19
Source : Upgrade.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public virtual async Task<Boolean> Download()
{
var url = Url;
if (url.IsNullOrEmpty()) return false;
var fileName = Path.GetFileName(url);
// 即使更新包存在,也要下载
var file = UpdatePath.CombinePath(fileName).GetBasePath();
if (File.Exists(file)) File.Delete(file); ;
WriteLog("准备下载 {0}", url);
var sw = Stopwatch.StartNew();
var web = CreateClient();
//await web.DownloadFileAsync(url, file);
file = await DownloadFileAsync(web, url, file);
sw.Stop();
WriteLog("下载完成!{2} 大小{0:n0}字节,耗时{1:n0}ms", file.AsFile().Length, sw.ElapsedMilliseconds, file);
SourceFile = file;
return true;
}
19
Source : Upgrade.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public Boolean CheckFileHash(String hash)
{
if (hash.IsNullOrEmpty()) return false;
var fi = SourceFile.AsFile();
if (!fi.Exists) return false;
var md5 = fi.MD5().ToHex();
return md5.EqualIgnoreCase(hash);
}
19
Source : Upgrade.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public void Run(String cmd)
{
if (cmd.IsNullOrEmpty()) return;
WriteLog("执行命令:{0}", cmd);
var args = "";
var p = cmd.IndexOf(' ');
if (p > 0)
{
args = cmd.Substring(p + 1);
cmd = cmd.Substring(0, p);
}
RunShell(cmd, args);
}
19
Source : Upgrade.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static async Task<String> DownloadFileAsync(HttpClient client, String address, String fileName)
{
var request = new HttpRequestMessage(HttpMethod.Get, address);
var rs = await client.SendAsync(request);
rs.EnsureSuccessStatusCode();
var file2 = rs.Content.Headers?.ContentDisposition?.FileName;
if (!file2.IsNullOrEmpty()) fileName = Path.GetDirectoryName(fileName).CombinePath(file2);
fileName.EnsureDirectory(true);
var ms = rs.Content;
using var fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
await ms.CopyToAsync(fs);
return fileName;
}
19
Source : WeiXinClient.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public void SendMarkDown(String content)
{
if (content.IsNullOrEmpty()) return;
// 超长阶段
if (content.Length > 2048) content = content.Substring(0, 2048);
WriteLog(content);
var msg = new
{
msgtype = "markdown",
markdown = new
{
content,
},
};
PostAsync(msg).Wait();
}
19
Source : LocalStarClient.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public Boolean KillAndRestartMySelf()
{
Init();
var p = Process.GetCurrentProcess();
var fileName = p.MainModule.FileName;
var args = Environment.CommandLine.TrimStart(Path.ChangeExtension(fileName, ".dll")).Trim();
// 发起命令
var rs = _client.Invoke<String>("KillAndStart", new
{
processId = p.Id,
delay = 3,
fileName,
arguments = args,
workingDirectory = Environment.CurrentDirectory,
});
// 本进程退出
//p.Kill();
return !rs.IsNullOrEmpty();
}
19
Source : LocalStarClient.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public Boolean ProbeAndInstall(String url = null, String version = null, String target = null)
{
//if (url.IsNullOrEmpty()) throw new ArgumentNullException(nameof(url));
if (url.IsNullOrEmpty())
{
var set = NewLife.Setting.Current;
if (Environment.Version.Major >= 5)
url = set.PluginServer.CombinePath("staragent50.zip");
else if (Environment.Version.Major >= 4)
url = set.PluginServer.CombinePath("staragent45.zip");
else
url = set.PluginServer.CombinePath("staragent31.zip");
}
// 尝试连接,获取版本
try
{
var info = GetInfo();
// 比目标版本高,不需要安装
if (String.Compare(info.Version, version) >= 0) return true;
if (!info.FileName.IsNullOrEmpty()) info.FileName = info.FileName.TrimEnd(" (deleted)");
if (target.IsNullOrEmpty()) target = Path.GetDirectoryName(info.FileName);
XTrace.WriteLine("StarAgent在用版本 v{0},低于目标版本 v{1}", info.Version, version);
}
catch (Exception ex)
{
XTrace.WriteLine("没有探测到StarAgent,{0}", ex.GetTrue().Message);
}
if (target.IsNullOrEmpty())
{
// 在进程中查找
var p = Process.GetProcesses().FirstOrDefault(e => e.ProcessName == "StarAgent");
if (p != null)
{
try
{
target = Path.GetDirectoryName(p.MainModule.FileName);
}
catch
{
target = Path.GetDirectoryName(p.MainWindowreplacedle);
}
XTrace.WriteLine("发现进程StarAgent,ProcessId={0},target={1}", p.Id, target);
}
}
// 准备安装,甭管是否能够成功重启,先覆盖了文件再说
{
if (target.IsNullOrEmpty()) target = "..\\staragent";
target = target.GetFullPath();
target.EnsureDirectory(false);
XTrace.WriteLine("目标:{0}", target);
var ug = new Upgrade
{
SourceFile = Path.GetFileName(url).GetFullPath(),
DestinationPath = target,
Log = XTrace.Log,
};
XTrace.WriteLine("下载:{0}", url);
var client = new HttpClient();
client.DownloadFileAsync(url, ug.SourceFile).Wait();
ug.Update();
File.Delete(ug.SourceFile);
}
{
// 在进程中查找
var info = Info;
var p = info != null && info.ProcessId > 0 ?
Process.GetProcessById(info.ProcessId) :
Process.GetProcesses().FirstOrDefault(e => e.ProcessName == "StarAgent");
// 在Linux中设置执行权限
var fileName = info?.FileName ?? target.CombinePath(Runtime.Linux ? "StarAgent" : "StarAgent.exe");
if (File.Exists(fileName) && Runtime.Linux) Process.Start("chmod", $"+x {fileName}");
// 重启目标
if (p != null)
{
try
{
p.Kill();
}
catch (Win32Exception) { }
catch (Exception ex)
{
XTrace.WriteException(ex);
}
}
if (File.Exists(fileName))
{
if (info?.Arguments == "-s")
{
Process.Start(fileName, "-start");
}
else
{
var si = new ProcessStartInfo(fileName, "-run")
{
WorkingDirectory = Path.GetDirectoryName(fileName),
UseShellExecute = true
};
Process.Start(si);
}
}
}
return true;
}
19
Source : RpcServer.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public override void Start()
{
if (NameSpace.IsNullOrEmpty()) throw new ArgumentNullException(nameof(NameSpace));
var star = Star;
if (star == null) throw new ArgumentNullException(nameof(Star));
//// 上报
//ReportAsync().Wait();
base.Start();
}
19
Source : StarClient.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public LoginInfo GetLoginInfo()
{
var di = GetNodeInfo();
var ext = new LoginInfo
{
Code = Code,
Secret = Secret.IsNullOrEmpty() ? null : Secret.MD5(),
Node = di,
};
return ext;
}
19
Source : StarFactory.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
private Boolean Valid()
{
//if (Server.IsNullOrEmpty()) throw new ArgumentNullException(nameof(Server));
//if (AppId.IsNullOrEmpty()) throw new ArgumentNullException(nameof(AppId));
if (Server.IsNullOrEmpty() || AppId.IsNullOrEmpty()) return false;
if (_client == null)
{
if (!AppId.IsNullOrEmpty()) _tokenFilter = new TokenHttpFilter
{
UserName = AppId,
Preplacedword = Secret,
};
_client = new ApiHttpClient(Server) { Filter = _tokenFilter };
var set = Setting.Current;
if (set.Debug) _client.Log = XTrace.Log;
}
return true;
}
19
Source : StarFactory.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
private void Init()
{
Local = new LocalStarClient();
// 读取本地appsetting
if (Server.IsNullOrEmpty() && File.Exists("appsettings.Development.json".GetFullPath()))
{
using var json = new JsonConfigProvider { FileName = "appsettings.Development.json" };
json.LoadAll();
Server = json["StarServer"];
}
if (Server.IsNullOrEmpty() && File.Exists("appsettings.json".GetFullPath()))
{
using var json = new JsonConfigProvider { FileName = "appsettings.json" };
json.LoadAll();
Server = json["StarServer"];
}
if (Server.IsNullOrEmpty())
{
try
{
var inf = Local.GetInfo();
var server = inf?.Server;
if (!server.IsNullOrEmpty())
{
Server = server;
XTrace.WriteLine("星尘探测:{0}", server);
}
}
catch (Exception ex)
{
//XTrace.WriteException(ex);
XTrace.Log.Error("星尘探测失败!{0}", ex.Message);
}
}
// 如果探测不到本地应用,则使用配置
var set = Setting.Current;
if (Server.IsNullOrEmpty()) Server = set.Server;
if (AppId.IsNullOrEmpty()) AppId = set.AppKey;
if (Secret.IsNullOrEmpty()) Secret = set.Secret;
var asm = replacedemblyX.Entry;
if (asm != null)
{
if (AppId.IsNullOrEmpty()) AppId = asm.Name;
if (AppName.IsNullOrEmpty()) AppName = asm.replacedle;
}
XTrace.WriteLine("星尘分布式服务 Server={0} AppId={1}", Server, AppId);
}
19
Source : 应用依赖.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppQuote> Search(Int32 appId, Int32 targetAppId, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (targetAppId >= 0) exp &= _.TargetAppId == targetAppId;
if (!key.IsNullOrEmpty()) exp &= _.CreateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 应用规则.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static String CheckScope(Int32 appid, String ip)
{
if (appid == 0 || ip.IsNullOrEmpty()) return null;
var list = Meta.Cache.Enreplacedies.FindAll(e => e.Enable);
list = list.Where(e =>
!e.Rule.IsNullOrEmpty() && e.Rule.StartsWithIgnoreCase("IP=") &&
!e.Result.IsNullOrEmpty() && e.Result.StartsWithIgnoreCase("Scope="))
.OrderByDescending(e => e.Priority)
.ToList();
if (list.Count == 0) return null;
var rule = list.Where(e => e.Match(ip)).OrderByDescending(e => e.Priority).ThenByDescending(e => e.Id).FirstOrDefault();
if (rule == null) return null;
var rs = rule.Result;
return rs.Substring(rs.IndexOf('=') + 1);
}
19
Source : 应用规则.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public Boolean Match(String ip)
{
var dic = Rule.SplitAsDictionary("=", ";");
var rules = dic.ToDictionary(e => e.Key, e => e.Value.Split(","), StringComparer.OrdinalIgnoreCase);
// 没有使用该规则,直接过
if (rules.TryGetValue("ip", out var vs))
{
if (ip.IsNullOrEmpty() || !vs.Any(e => e.IsMatch(ip))) return false;
}
return true;
}
19
Source : 应用配置.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static AppConfig FindByName(String name)
{
if (name.IsNullOrEmpty()) return null;
// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
return Find(_.Name == name);
}
19
Source : 配置历史.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<ConfigHistory> Search(Int32 appId, String action, Boolean? success, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!action.IsNullOrEmpty()) exp &= _.Action == action;
if (success != null) exp &= _.Success == success;
exp &= _.CreateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Remark.Contains(key) | _.CreateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 配置历史.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static ConfigHistory Add(Int32 appId, String action, Boolean success, String remark)
{
if (appId == 0) throw new ArgumentNullException(nameof(appId));
if (action.IsNullOrEmpty()) throw new ArgumentNullException(nameof(action));
var hi = new ConfigHistory
{
AppId = appId,
Action = action,
Success = success,
Remark = remark,
};
hi.Insert();
return hi;
}
19
Source : 配置在线.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<ConfigOnline> Search(Int32 appId, String client, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!client.IsNullOrEmpty()) exp &= _.Client == client;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Category.Contains(key) | _.Name.Contains(key) | _.ProcessName.Contains(key) | _.UserName.Contains(key) | _.Version.Contains(key) | _.Creator.Contains(key) | _.CreateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 配置数据.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<ConfigData> FindAllByKey(String key)
{
key = key?.Trim();
if (key.IsNullOrEmpty()) return new List<ConfigData>();
if (Meta.Count < 1000) return Meta.Cache.FindAll(e => e.Key.EqualIgnoreCase(key));
return FindAll(_.Key == key);
}
19
Source : 配置数据.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<ConfigData> Search(Int32 appId, String name, String scope, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!name.IsNullOrEmpty()) exp &= _.Key == name;
if (!scope.IsNullOrEmpty()) exp &= _.Scope == scope;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Value.Contains(key) | _.CreateIP.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
return FindAll(exp, page);
}
19
Source : 配置数据.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static ConfigData Acquire(AppConfig app, String key, String scope)
{
var locals = app.LastRelease;
locals = locals.Where(_ => _.Key.EqualIgnoreCase(key)).ToList();
//locals = SelectVersion(locals, app.Version);
// 混合应用配置表
var qs = app.GetQuotes();
var shares = new List<ConfigData>();
foreach (var item in qs)
{
var list = item.LastRelease;
list = list.Where(_ => _.Key.EqualIgnoreCase(key)).ToList();
//list = SelectVersion(list, item.Version);
if (list.Count > 0) shares.AddRange(list);
}
if (locals.Count == 0 && shares.Count == 0) return null;
// 如果未指定作用域
if (scope.IsNullOrEmpty())
{
// 优先空作用域
var cfg = locals.FirstOrDefault(_ => _.Scope.IsNullOrEmpty());
if (cfg != null) return cfg;
// 共享应用空作用域
cfg = shares.FirstOrDefault(_ => _.Scope.IsNullOrEmpty());
if (cfg != null) return cfg;
// 任意作用域,最新优先
if (locals.Count > 0) return locals.OrderByDescending(_ => _.Id).FirstOrDefault();
if (shares.Count > 0) return shares.OrderByDescending(_ => _.Id).FirstOrDefault();
}
else
{
// 优先匹配作用域
var cfg = locals.FirstOrDefault(_ => _.Scope.EqualIgnoreCase(scope));
if (cfg != null) return cfg;
// 共享应用该作用域
cfg = shares.FirstOrDefault(_ => _.Scope.EqualIgnoreCase(scope));
if (cfg != null) return cfg;
// 没有找到匹配作用域,使用空作用域
cfg = locals.FirstOrDefault(_ => _.Scope.IsNullOrEmpty());
if (cfg != null) return cfg;
// 共享应用空作用域
cfg = shares.FirstOrDefault(_ => _.Scope.IsNullOrEmpty());
if (cfg != null) return cfg;
}
// 都没有就返回空,要求去配置
return null;
}
19
Source : 应用节点.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppDeployNode> Search(Int32 appId, Int32 nodeId, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (nodeId >= 0) exp &= _.NodeId == nodeId;
if (!key.IsNullOrEmpty()) exp &= _.CreateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 应用部署.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static AppDeploy FindByName(String name)
{
if (name.IsNullOrEmpty()) return null;
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
return Find(_.Name == name);
}
19
Source : 应用部署.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppDeploy> Search(String category, Boolean? enable, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (!category.IsNullOrEmpty()) exp &= _.Category == category;
if (enable != null) exp &= _.Enable == enable;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.FileName.Contains(key) | _.Arguments.Contains(key) | _.WorkingDirectory.Contains(key) | _.CreateIP.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
return FindAll(exp, page);
}
19
Source : 部署历史.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppDeployHistory> Search(Int32 appId, String action, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!action.IsNullOrEmpty()) exp &= _.Action == action;
if (!key.IsNullOrEmpty()) exp &= _.Remark.Contains(key) | _.CreateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 部署在线.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppDeployOnline> Search(Int32 appId, Int32 nodeId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (nodeId >= 0) exp &= _.NodeId == nodeId;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.IP.Contains(key) | _.CreateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 部署版本.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppDeployVersion> Search(Int32 appId, String version,Boolean? enable, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!version.IsNullOrEmpty()) exp &= _.Version == version;
if (enable != null) exp &= _.Enable == enable;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Url.Contains(key) | _.CreateIP.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
return FindAll(exp, page);
}
19
Source : 应用历史.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppHistory> Search(Int32 appId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
exp &= _.Id.Between(start, end, Meta.Factory.Snow);
if (!key.IsNullOrEmpty()) exp &= _.Action == key;
return FindAll(exp, page);
}
19
Source : 应用性能.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppMeter> Search(Int32 appId, String clientId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!clientId.IsNullOrEmpty() && clientId != "null") exp &= _.ClientId == clientId;
exp &= _.Id.Between(start, end, Meta.Factory.Snow);
if (!key.IsNullOrEmpty()) exp &= _.ClientId.Contains(key) | _.Data.Contains(key) | _.Creator.Contains(key) | _.CreateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 应用日志.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppLog> Search(Int32 appId, String clientId, Int32 threadId, DateTime start, DateTime end, String key, PageParameter page)
{
//if (appId <= 0) throw new ArgumentNullException(nameof(appId));
//if (start.Year < 2000) throw new ArgumentNullException(nameof(start));
//if (end.Year < 2000) throw new ArgumentNullException(nameof(end));
if (appId <= 0 || start.Year < 2000) return new List<AppLog>();
// 分表
//using var split = Meta.CreateSplit($"AppLog_{start:yyyyMMdd}", $"AppLog_{appId}");
//using var split = Meta.AutoSplit(new AppLog { AppId = appId, CreateTime = start });
var exp = new WhereExpression();
//// 按天分表,只有具体时间才过滤
//if (start == start.Date) start = DateTime.MinValue;
exp &= _.Id.Between(start, end, Meta.Factory.Snow);
if (appId >= 0) exp &= _.AppId == appId;
if (!clientId.IsNullOrEmpty()) exp &= _.ClientId == clientId;
if (threadId > 0) exp &= _.ThreadId == threadId;
if (!key.IsNullOrEmpty()) exp &= _.Message.Contains(key) | _.ClientId == key;
return FindAll(exp, page);
}
19
Source : 应用服务.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppService> Search(Int32 appId, Int32 serviceId, Boolean? enable, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (serviceId > 0) exp &= _.ServiceId == serviceId;
if (enable != null) exp &= _.Enable == enable;
if (!key.IsNullOrEmpty()) exp &= _.ServiceName.Contains(key) | _.Client.Contains(key) | _.Address.Contains(key) | _.Tag.Contains(key);
return FindAll(exp, page);
}
19
Source : 应用服务.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public Boolean Match(String minVersion, String scope, String[] tags)
{
if (!minVersion.IsNullOrEmpty() && String.Compare(Version, minVersion) < 0) return false;
// 应用服务没有Scope时,谁都可以消费,否则必须匹配
if (!Scope.IsNullOrEmpty() && Scope != scope) return false;
if (tags != null && tags.Length > 0)
{
if (Tag.IsNullOrEmpty()) return false;
var ts = Tag.Split(",");
if (tags.Any(e => !ts.Contains(e))) return false;
}
return true;
}
19
Source : 应用消费.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppConsume> Search(Int32 appId, Int32 serviceId, Boolean? enable, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (serviceId > 0) exp &= _.ServiceId == serviceId;
if (enable != null) exp &= _.Enable == enable;
if (!key.IsNullOrEmpty()) exp &= _.ServiceName.Contains(key) | _.Client.Contains(key) | _.Tag.Contains(key);
return FindAll(exp, page);
}
19
Source : 应用系统.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static App FindByName(String name)
{
if (name.IsNullOrEmpty()) return null;
// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
// 单对象缓存
//return Meta.SingleCache.GereplacedemWithSlaveKey(name) as App;
return Find(_.Name == name);
}
19
Source : 应用系统.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<App> Search(String category, Boolean? enable, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (!category.IsNullOrEmpty()) exp &= _.Category == category;
if (enable != null) exp &= _.Enable == enable;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.DisplayName.Contains(key);
return FindAll(exp, page);
}
19
Source : 服务信息.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<Service> Search(String name, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.DisplayName.Contains(key) | _.Category.Contains(key) | _.Remark.Contains(key) | _.CreateUser.Contains(key) | _.CreateIP.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 告警历史.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AlarmHistory> Search(Int32 groupId, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (groupId >= 0) exp &= _.GroupId == groupId;
exp &= _.Id.Between(start, end, Meta.Factory.Snow);
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.Category.Contains(key) | _.Action.Contains(key) | _.Content.Contains(key) | _.Creator.Contains(key) | _.CreateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 告警组.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static AlarmGroup FindByName(String name)
{
if (name.IsNullOrEmpty()) return null;
// 实体缓存
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
// 单对象缓存
//return Meta.SingleCache.GereplacedemWithSlaveKey(name) as AlarmGroup;
return Find(_.Name == name);
}
19
Source : 告警组.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AlarmGroup> Search(String name, Boolean? enable, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
if (enable != null) exp &= _.Enable == enable;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.WebHook.Contains(key) | _.CreateUser.Contains(key) | _.CreateIP.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 应用跟踪器.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<AppTracer> Search(String category, Boolean? enable, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (!category.IsNullOrEmpty()) exp &= _.Category == category;
if (enable != null) exp &= _.Enable == enable.Value;
exp &= _.UpdateTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.DisplayName.Contains(key) | _.Category.Contains(key) | _.CreateUser.Contains(key) | _.CreateIP.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key);
return FindAll(exp, page);
}
19
Source : 应用跟踪器.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public void AddExclude(String value)
{
if (value.IsNullOrEmpty()) return;
var es = new List<String>();
var ss = Excludes?.Split(",");
if (ss != null) es.AddRange(ss);
if (!es.Contains(value))
{
es.Add(value);
Excludes = es.Distinct().Join();
}
}
19
Source : 跟踪分钟统计.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<TraceMinuteStat> Search(Int32 appId, String name, Int32 minError, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
if (minError > 0) exp &= _.Errors >= minError;
exp &= _.StatTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key);
return FindAll(exp, page);
}
19
Source : 跟踪小时统计.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<TraceHourStat> Search(Int32 appId, String name, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
exp &= _.StatTime.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key);
return FindAll(exp, page);
}
19
Source : 跟踪数据.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<TraceData> Search(Int32 appId, String name, String kind, Int32 minError, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
if (!key.IsNullOrEmpty()) exp &= _.ClientId == key | _.Name == key;
if (minError > 0) exp &= _.Errors >= minError;
if (appId > 0 && start.Year > 2000)
{
var fi = kind switch
{
"day" => _.StatDate,
"hour" => _.StatHour,
"minute" => _.StatMinute,
_ => _.StatDate,
};
if (start == end)
exp &= fi == start;
else
exp &= fi.Between(start, end);
}
19
Source : 跟踪数据.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<TraceData> Search(Int32 appId, String name, String kind, DateTime time, Int32 count)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
var fi = kind switch
{
"day" => _.StatDate,
"hour" => _.StatHour,
"minute" => _.StatMinute,
_ => _.StatDate,
};
19
Source : 跟踪每日统计.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<TraceDayStat> Search(Int32 appId, String name, String type, DateTime start, DateTime end, String key, PageParameter page)
{
var exp = new WhereExpression();
if (appId >= 0) exp &= _.AppId == appId;
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
if (!type.IsNullOrEmpty()) exp &= _.Type == type;
if (start.Year > 2000 && start == end)
exp &= _.StatDate == start;
else
exp &= _.StatDate.Between(start, end);
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key);
return FindAll(exp, page);
}
19
Source : 采样数据.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<SampleData> Search(Int64 dataId, String traceId, DateTime start, DateTime end, PageParameter page)
{
var exp = new WhereExpression();
if (dataId > 0) exp &= _.DataId == dataId;
if (!traceId.IsNullOrEmpty()) exp &= _.TraceId == traceId;
//// 搜索最近一段时间
//for (var dt = end; dt >= start; dt = dt.AddDays(-1))
//{
// var model = (Meta.ShardPolicy as TimeShardPolicy2).Get(dt);
// using var split = Meta.CreateSplit(model.ConnName, model.TableName);
// var list = FindAll(exp, page);
// if (list.Count > 0) return list;
//}
//return new List<SampleData>();
return Meta.AutoShard(end.AddSeconds(1), start, () => FindAll(exp, page)).FirstOrDefault(e => e.Count > 0) ?? new List<SampleData>();
}
19
Source : 采样数据2.Biz.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
public static IList<SampleData2> Search(String traceId, String key, PageParameter page)
{
var exp = new WhereExpression();
if (!traceId.IsNullOrEmpty()) exp &= _.TraceId == traceId;
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.SpanId.Contains(key) | _.ParentId.Contains(key) | _.Tag.Contains(key) | _.Error.Contains(key) | _.CreateIP.Contains(key);
return FindAll(exp, page);
}
See More Examples