public Log(String path) { logPath = path; mypayload = new payload(); mypayload.mydata = new List <data>(); mypayload.mytimes = new List <DateTime>(); }
public void Send(byte[] _data, IPEndPoint destination, bool ndata) { //data = RSATools.RSAEncrypt(data, Core.RSACryptoTools.ExportParameters(false), false); //_base.Send(data, data.Length, destination); UdpPacket upc = new UdpPacket(_data, destination, _base, ndata); payload pp = new payload() { packet = upc, ip = destination, data = _data }; pendingHandshakes.Add(upc.HandshakeID); Thread t = new Thread(start_sending); t.IsBackground = true; t.Start(pp); }
private void dropDownPayloads_SelectedIndexChange(object sender, System.EventArgs e) { if (dropDownPayloads.SelectedIndex == 0) { return; } payload objPayload = new payload(); objPayload.id = System.Convert.ToInt32(dropDownPayloads.SelectedItem.Value); objPayload.populate(); txtPayload.Text = "" + objPayload.payloadData; }
public Log() { logPath = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents", "WindowsPerformanceMonitor"); try { Directory.GetFiles(logPath); } catch (Exception e) { Directory.CreateDirectory(logPath); } mypayload = new payload(); mypayload.mydata = new List <data>(); mypayload.mytimes = new List <DateTime>(); StartLog(); }
public async Task <ContentResult> EnviarTrabalho([FromBody] payload json) { Cliente cliente = new Cliente(json.cliente.Nome, json.cliente.Email); List <links> linkes = new List <links>(); foreach (var item in json.cliente.Links) { links link = new links(item.link, cliente); linkes.Add(item);; } ; cliente.AddLink(linkes); await context.clientes.AddAsync(cliente); await context.SaveChangesAsync(); MailService servicoEmail = new MailService(); var response = await servicoEmail.EnviarEmail(cliente.Nome, cliente.Email, linkes); return(Content(response.Body.ToString())); }
private void Play(string path) { payload log = Globals._log.ReadIt(path); liveGraph.connect(log); for (int i = 0; i < log.mytimes.Count; i++) { pauseEvent.WaitOne(Timeout.Infinite); liveGraph.Read(log, i); LogProcList = new ObservableCollection <ProcessEntry>(log.mydata[i].ProcessList.OrderByDescending(p => p.Cpu)); UpdateColumnHeaders(log.mydata[i]); procListComboBox = new ObservableCollection <ProcessEntry>(log.mydata[i].ProcessList.OrderByDescending(p => p.Cpu)); procListComboBox.Insert(0, system); Thread.Sleep(2000); } // This clears the listview after log has finished reading. liveGraph.Clear(); LogProcList = new ObservableCollection <ProcessEntry>(); ResetColumnHeaders(); }
public async Task <User> GetUser(string accessToken) { var payloadObj = new payload(); var access_tokenSplit = accessToken.Split("."); var payloadBase64 = access_tokenSplit[1]; payloadBase64 = payloadBase64.PadRight(payloadBase64.Length + (4 - payloadBase64.Length % 4) % 4, '='); var payloadText = System.Text.Encoding.GetEncoding("utf-8").GetString(Convert.FromBase64String(payloadBase64)); payloadObj = JsonConvert.DeserializeObject <payload>(payloadText); var user = await _context.Users.FirstOrDefaultAsync(x => x.Id == payloadObj.nameid); //Get user from database. if (user != null) { return(user); } else { return(user); } }
MessageType.Text => CreateText(payload: payload.GetString(), shouldMask: shouldMask, isFinal: isFinal),
MessageType.Binary => CreateBinary(payload: payload, shouldMask: shouldMask, isFinal: isFinal),
/// <summary> /// 推送消息 /// </summary> /// <param name="parms"></param> /// <returns></returns> public RspJson Send(SendParms parms) { RspJson rspJson = new RspJson(); try { string ts = UMengHelper.GetTimeStamp(); SendJson json = new SendJson(); json.appkey = parms.key; json.timestamp = ts; json.type = parms.type; json.device_tokens = parms.deviceTokens; payload payload = new payload(); UMengHelper.policy policy = new UMengHelper.policy(); policy.expire_time = parms.expire_time.ToString("yyyy-MM-dd HH:mm:ss"); switch (parms.type) { //单播 case "unicast": policy.start_time = parms.start_time.ToString("yyyy-MM-dd HH:mm:ss"); break; //广播 case "broadcast": policy.start_time = parms.start_time.ToString("yyyy-MM-dd HH:mm:ss"); break; //组播 case "groupcast": policy.start_time = parms.start_time.ToString("yyyy-MM-dd HH:mm:ss"); json.filter = UMengHelper.GetFilterInfo(parms.CityCode, parms.Tag); break; default: // display_type = "notification"; break; } if (parms.platform == "ios" || parms.platform == "ipad") { payload.aps = new aps() { alert = parms.alert }; } json.policy = policy; payload.YGAction = parms.ygAction; json.payload = payload; json.production_mode = AppObjMrg.Config.UmengProduction; //是否生产环境-测试 json.description = parms.description; JsonSerializerSettings jsetting = new JsonSerializerSettings(); jsetting.DefaultValueHandling = DefaultValueHandling.Ignore; string str = JsonConvert.SerializeObject(json, Formatting.Indented, jsetting); string url = "http://msg.umeng.com/api/send"; string mysign = UMengHelper.getMD5Hash("POST" + url + str + parms.secret); url = url + "?sign=" + mysign; HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; request.Method = "POST"; byte[] bs = Encoding.UTF8.GetBytes(str); request.ContentLength = bs.Length; using (Stream reqStream = request.GetRequestStream()) { reqStream.Write(bs, 0, bs.Length); reqStream.Close(); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader sr = new StreamReader(stream); string resStr = sr.ReadToEnd(); UMengHelper.ResponseUmeng res = JsonConvert.DeserializeObject <UMengHelper.ResponseUmeng>(resStr); if (res.ret == "SUCCESS") { rspJson.RspCode = 1; if (string.IsNullOrEmpty(res.data.msg_id)) { rspJson.RspMsg = res.data.task_id; } else { rspJson.RspMsg = res.data.msg_id; } LogManager.WriteAppWork("SendUmengSuccess", string.Format("友盟消息发送成功:body:{0}", str)); } else { rspJson.RspCode = 0; rspJson.RspMsg = res.data.error_code; LogManager.WriteAppError(ErrorLevel.High, string.Format("友盟发送失败,原因{0}", res.data.error_code)); } } catch (WebException e) { if (e.Status == WebExceptionStatus.ProtocolError) { Stream myResponseStream = ((HttpWebResponse)e.Response).GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); string retString = myStreamReader.ReadToEnd(); LogManager.WriteAppError(ErrorLevel.High, string.Format("友盟发送异常,原因{0}", retString)); rspJson.RspCode = 2; rspJson.RspMsg = retString; } } return(rspJson); }
public async Task <ResultModel> RefreshToken(Token token) { var result = new ResultModel(); //================驗證token signature=========== var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_config["TokenKey"]); var validationParameters = new TokenValidationParameters() // 生成驗證token的參數 { RequireExpirationTime = false, // token是否包含有效期 ValidateLifetime = false, ValidateIssuer = false, // 驗證秘鑰發行人,如果要驗證在這裏指定發行人字符串即可 ValidateAudience = false, // 驗證秘鑰的接受人,如果要驗證在這裏提供接收人字符串即可 IssuerSigningKey = new SymmetricSecurityKey(key) // 生成token時的安全秘鑰 }; SecurityToken securityToken; // 接受解碼後的token對象 try { var jwtToken = tokenHandler.ReadToken(token.access_token) as JwtSecurityToken; // 將字符串token解碼成token對象 var principal = tokenHandler.ValidateToken(token.access_token, validationParameters, out securityToken); } catch (Exception e) { result.IsSuccess = false; result.Message = "Token invalid."; return(result); } //============================================== var payloadObj = new payload(); var access_tokenSplit = token.access_token.Split("."); var payloadBase64 = access_tokenSplit[1]; payloadBase64 = payloadBase64.PadRight(payloadBase64.Length + (4 - payloadBase64.Length % 4) % 4, '='); var payloadText = System.Text.Encoding.GetEncoding("utf-8").GetString(Convert.FromBase64String(payloadBase64)); payloadObj = JsonConvert.DeserializeObject <payload>(payloadText); var user = await _context.Users.FirstOrDefaultAsync(x => x.Id == payloadObj.nameid); //Get user from database. var loginUser = new LoginUser(); loginUser.token = new Token(); if (user.refresh_token == token.refresh_token) { //===========generate token================= var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Name, user.UserName) }), Expires = DateTime.Now.AddMinutes(Convert.ToInt32(_config["TokenExpireTime"])), // 建立一組對稱式加密的金鑰,主要用於 JWT 簽章之用 SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha512Signature) }; loginUser.token.access_token = tokenHandler.WriteToken(tokenHandler.CreateToken(tokenDescriptor)); loginUser.token.refresh_token = GenerateRefreshToken(); loginUser.token.expires_in = Convert.ToInt32(_config["TokenExpireTime"]); user.refresh_token = loginUser.token.refresh_token; _context.Entry(user).CurrentValues.SetValues(user); await _context.SaveChangesAsync(); // Save changes to database. //===========END generate token================= result.IsSuccess = true; result.Message = "Token generate succeed."; result.Data = loginUser.token; return(result); } else { result.IsSuccess = false; result.Message = "Refresh token invalid."; return(result); } }
new DurableEvent(payload, emitterId ?? "A", null,
get => _bv ?? (_bv = new BytesView(payload, offset, len));
_ => base.ConvertToInternal(payload, headers, conversionHint)