/// <summary> /// 远程鉴权 /// </summary> /// <returns></returns> public bool AuthRemoteCode() { App.Current.Dispatcher.BeginInvoke(new Action(() => { lblAuthTips.Text = SystemLanguageManager.Instance.ResourceManager.GetString("Authenticating", SystemLanguageManager.Instance.CultureInfo); })); bool authflag = false; var values = new List <KeyValuePair <string, string> >(); string url = ConfigurationManager.AppSettings["AuthUrl"]; // string ukey = ConfigManager.Instance.Config.UKey; // string macaddrss = SystemInfoUtils.GetMacAddress(); string type = "facebook"; TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); long t = Convert.ToInt64(ts.TotalSeconds); string key = ConfigVals.AccessKey.Substring(8, 20); if (macaddrss == "" || key == "") { return(authflag); } MD5 md5 = new MD5CryptoServiceProvider(); byte[] result = Encoding.Default.GetBytes(ukey + macaddrss + type + t.ToString() + key); byte[] bytekey = md5.ComputeHash(result); string token = BitConverter.ToString(bytekey).Replace("-", ""); /*values.Add(new KeyValuePair<string, string>("ukey", ukey)); * values.Add(new KeyValuePair<string, string>("macadd", macaddrss)); * values.Add(new KeyValuePair<string, string>("time", t.ToString())); * values.Add(new KeyValuePair<string, string>("token", token));*/ HttpClientHelp httpClient = new HttpClientHelp(); var obj = new JObject() { { "ukey", ukey }, { "macadd", macaddrss }, { "type", type }, { "time", t.ToString() }, { "token", token.ToLower() } }; authflag = httpClient.PostFunction(url, obj.ToString(Formatting.None), macaddrss, key, ukey); return(authflag); }
/// <summary> /// 远程鉴权 /// </summary> /// <returns></returns> public bool AuthRemoteCode() { lab_authmsg.Text = "远程鉴权中……"; bool authflag = false; var values = new List <KeyValuePair <string, string> >(); string url = ConfigurationManager.AppSettings["AuthUrl"];; // string ukey = ConfigurationManager.AppSettings["UKey"];; // string macaddrss = SystemInfoUtils.GetMacAddress(); TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); long t = Convert.ToInt64(ts.TotalSeconds); string key = ConfigVals.AccessKey.Substring(8, 20); if (macaddrss == "" || key == "") { return(authflag); } MD5 md5 = new MD5CryptoServiceProvider(); byte[] result = Encoding.Default.GetBytes(ukey + macaddrss + t.ToString() + key); byte[] bytekey = md5.ComputeHash(result); string token = BitConverter.ToString(bytekey).Replace("-", ""); /*values.Add(new KeyValuePair<string, string>("ukey", ukey)); * values.Add(new KeyValuePair<string, string>("macadd", macaddrss)); * values.Add(new KeyValuePair<string, string>("time", t.ToString())); * values.Add(new KeyValuePair<string, string>("token", token));*/ HttpClientHelp httpClient = new HttpClientHelp(); var obj = new JObject() { { "ukey", ukey }, { "macadd", macaddrss }, { "time", t.ToString() }, { "token", token.ToLower() } }; authflag = httpClient.PostFunction(url, obj.ToString(Formatting.None)); return(authflag); }
protected void Page_Load(object sender, EventArgs e) { bool flag = !base.IsPostBack; if (flag) { string value = "0"; bool flag2 = base.Request.Params["FMDID"] != null; if (flag2) { value = base.Request.Params["FMDID"].ToString(); } int mdid = 0; bool flag3 = string.IsNullOrWhiteSpace(value); if (flag3) { mdid = value.ToInt(); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Clear(); List <TimMenu> children = FuncModelUtils.FilterUserMenu(FuncModelUtils.GetFuncModelMenu(mdid), LogicContext.Current.UserId).Children; foreach (TimMenu current in children) { bool flag4 = current.Type != ModuleType.C; if (!flag4) { stringBuilder.Append("<li>"); stringBuilder.Append("<a href='#'><span>"); stringBuilder.Append(" <img src='images/menu_icon1.png'/></span>" + current.Name + "</a>"); List <TimMenu> children2 = FuncModelUtils.FilterUserMenu(FuncModelUtils.GetFuncModelMenu(current.Id), LogicContext.Current.UserId).Children; stringBuilder.Append("<ul>"); foreach (TimMenu current2 in children2) { stringBuilder.Append(string.Concat(new object[] { "<li><a onclick=\"f_addTab(", current2.Id, ", '", current2.Name, "', '", current2.Url, "');\">", current2.Name, "</a></li>" })); } stringBuilder.Append("</ul>"); stringBuilder.Append("</li>"); } } this._Menu = stringBuilder.ToString(); } LogicContext current3 = LogicContext.Current; bool flag5 = current3 != null; if (flag5) { this._UserName = current3.UserName; SystemInfo systemInfo = SystemInfoUtils.GetSystemInfo(); this._ConpanyName = systemInfo.Name; } }
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); base.Title = SystemInfoUtils.GetSystemInfo().Name; }
protected override object doGet(IOwinContext context) { switch (context.Request.Query["type"]) { case "user": return(new { user = context.GetSession()[LoginMiddleware.LOGINED_USER_KEY] }); case "info": return(new { time = Convert.ToInt64(TimeUtils.GetTime(DateTime.Now)), basic = new { computer_name, os_name, process_run_time = (DateTime.Now - Process.GetCurrentProcess().StartTime).ToString(@"dd\.hh\:mm\:ss") } }); case "cpu": return(new { time = Convert.ToInt64(TimeUtils.GetTime(DateTime.Now)), cpu = new { used = SystemInfoUtils.GetCpuUsage(), temp = SystemInfoUtils.GetCpuTempature() } }); case "memory": return(new { memory = new { total = SystemInfoUtils.GetTotalMemory(), free = SystemInfoUtils.GetFreeMemory(), } }); case "disk": return(System.IO.DriveInfo.GetDrives().Where(t => t.IsReady && t.TotalSize > 0).Select(t => new { name = t.Name, totalSize = t.TotalSize, totalSizeString = storageUnitStringConverting.GetString(t.TotalSize), totalUsed = t.TotalSize - t.TotalFreeSpace, totalUsedString = storageUnitStringConverting.GetString(t.TotalSize - t.TotalFreeSpace), driveFormat = t.DriveFormat })); case "regex": { var content = "0.233081"; var regex = new System.Text.RegularExpressions.Regex(@"^\s*(?'value'.*?)\s*$"); var match = regex.Match(content); if (match == null || !match.Success) { return(null); } var value = match.Groups["value"].Value; return(new { value }); } case "process": { var process = new Process(); var psi = process.StartInfo; psi.FileName = "bash"; psi.Arguments = "-c \"grep 'cpu ' /proc/stat| awk '{value=($2+$4)*100/($2+$4+$5)} END {print value}'\""; psi.UseShellExecute = false; psi.RedirectStandardOutput = true; process.Start(); var content = process.StandardOutput.ReadToEnd(); process.WaitForExit(); return(new { content }); } } return(null); }
public IndexApiController() { computer_name = SystemInfoUtils.GetComputerName(); os_name = SystemInfoUtils.GetOsName(); }