/// <summary> /// Validates this instance. /// </summary> /// <exception cref="System.ArgumentException"> /// InstanceName must be set /// or /// AppId must be set /// or /// AppId must be set /// or /// TenantId must be set /// or /// SubscriptionId must be set /// or /// SharedAccessPolicy must be set /// </exception> /// <exception cref="ArgumentException">InstanceName must be set and AppId must be set and AppId must be set and /// TenantId must be set and SubscriptionId must be set and SharedAccessPolicy must be set /// and ReceiverEntity OR SenderEntity must be set.</exception> /// <inheritdoc /> public override void Validate() { if (InstanceName.IsNullOrEmpty()) { throw new ArgumentException("InstanceName must be set"); } if (AppId.IsNullOrEmpty()) { throw new ArgumentException("AppId must be set"); } if (AppSecret.IsNullOrEmpty()) { throw new ArgumentException("AppSecret must be set"); } if (TenantId.IsNullOrEmpty()) { throw new ArgumentException("TenantId must be set"); } if (SubscriptionId.IsNullOrEmpty()) { throw new ArgumentException("SubscriptionId must be set"); } if (SharedAccessPolicyName.IsNullOrEmpty()) { throw new ArgumentException("SharedAccessPolicy must be set"); } base.Validate(); }
public void Initialize(AppPlatform platform, AppSecret appSecret) { _platform = platform; _appName = string.Empty; _appSecret = appSecret.Value; _versionLabel = string.Empty; _versionChangelog = string.Empty; _publishOnUpload = true; _overwriteDraftVersion = true; try { _appName = Core.Api.GetAppInfo(appSecret).Name; } catch (ApiConnectionException e) { _appName = "(cannot connect to the API)"; Debug.LogWarning(e); } catch (ApiResponseException e) { Debug.LogWarning(e); Config.UnlinkApp(_platform); } }
public CronDetailsController( ICronDetailService cronDetailService, IMapper mapper, IOptions <AppSecret> appSettings) { this._cronDetailService = cronDetailService; this._mapper = mapper; this._appSecret = appSettings.Value; }
public AuthController(IOptions <AppSecret> appSecret, IUserAppService userAppService) { _appSecret = appSecret.Value ?? throw new ArgumentNullException(nameof(_appSecret)); _userAppService = userAppService ?? throw new ArgumentNullException(nameof(userAppService)); }
public UsersController( IUserService userService, IMapper mapper, IOptions <AppSecret> appSettings) { this._userService = userService; this._mapper = mapper; this._appSecret = appSettings.Value; }
/// <summary> /// 获取token按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TokenButton_OnClick(object sender, RoutedEventArgs e) { if (AppId.IsNotNullOrEmpty() && AppSecret.IsNotNullOrEmpty()) { CurrentToken = AccessTokenContainer.TryGetAccessToken(AppId, AppSecret); } else { MessageBox.Show(this, "请输入AppId和AppSecret!"); } }
private void RefeshToken() { WpfTask.FactoryStartNew(() => { while (true) { if (AppId.IsNotNullOrEmpty() && AppSecret.IsNotNullOrEmpty()) { var token = AccessTokenContainer.TryGetAccessToken(AppId, AppSecret); UiThread.Invoke(() => { CurrentToken = token; }); } Thread.Sleep(1000 * 60); //一分钟刷新一次 } }); }
public void Initialize(AppPlatform platform, AppSecret appSecret) { _platform = platform; _appName = string.Empty; _appSecret = appSecret.Value; _versionLabel = string.Empty; _versionChangelog = string.Empty; _publishOnUpload = true; _overwriteDraftVersion = true; _removePdbFiles = true; try { var appInfo = Core.Api.GetAppInfo(appSecret); _appName = appInfo.name; if (appInfo.removed) { Dispatch( () => { EditorUtility.DisplayDialog( "Game Not Found", "This game does no longer exist on your PatchKit account.\n\n", "OK"); Config.UnlinkApp(_platform); }); } } catch (ApiConnectionException e) { _appName = "(cannot connect to the API)"; Debug.LogWarning(e); } catch (ApiResponseException e) { Debug.LogWarning(e); Dispatch(() => Config.UnlinkApp(_platform)); } }
public void Refresh(int AppID, string Secret, DateTime RefreshTime, DateTime OutTime) { lock (objlock) { using (DBXAppContext context = new DBXAppContext()) { var app = context.AppSecret.Where(T => T.ID == AppID).FirstOrDefault(); if (app == null) { app = new AppSecret() { ID = AppID, RefreshTime = DateTime.Now, SecretPre = Secret, Secret = Secret }; context.Entry <AppSecret>(app).State = Microsoft.EntityFrameworkCore.EntityState.Added; } else { context.Entry <AppSecret>(app).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } app.PreTime = app.RefreshTime; app.SecretPre = app.Secret; app.RefreshTime = RefreshTime; app.Secret = Secret; app.TimeOutTime = OutTime; AppSecretLog log = new AppSecretLog() { AppID = AppID, Secret = Secret, InputTime = DateTime.Now }; context.AppSecretLog.Add(log); context.SaveChanges(); } } }
public UserRepository(IOptions <AppSecret> appSecret) { _appSecret = appSecret.Value; }
/// <summary>处理Span集合。默认输出日志,可重定义输出控制台</summary> protected override void ProcessSpans(ISpanBuilder[] builders) { if (builders == null) { return; } // 剔除项 if (Excludes != null) { builders = builders.Where(e => !Excludes.Any(y => y.IsMatch(e.Name))).ToArray(); } builders = builders.Where(e => !e.Name.EndsWithIgnoreCase("/Trace/Report")).ToArray(); if (builders.Length == 0) { return; } // 初始化 Init(); // 构建应用信息 var info = new AppInfo(_process); try { // 调用WindowApi获取进程的连接数 var tcps = NetHelper.GetAllTcpConnections(); if (tcps != null && tcps.Length > 0) { var pid = Process.GetCurrentProcess().Id; info.Connections = tcps.Count(e => e.ProcessId == pid); } } catch { } // 发送,失败后进入队列 var model = new TraceModel { AppId = AppId, AppName = AppName, ClientId = ClientId, Version = _version, Info = info, Builders = builders }; try { // 检查令牌 if (!AppSecret.IsNullOrEmpty()) { CheckAuthorize(); } var rs = Client.Invoke <TraceResponse>("Trace/Report", model); // 处理响应参数 if (rs != null) { if (rs.Period > 0) { Period = rs.Period; } if (rs.MaxSamples > 0) { MaxSamples = rs.MaxSamples; } if (rs.MaxErrors > 0) { MaxErrors = rs.MaxErrors; } if (rs.Timeout > 0) { Timeout = rs.Timeout; } if (rs.Excludes != null) { Excludes = rs.Excludes; } } } catch (ApiException ex) { Log?.Error(ex + ""); } catch (Exception ex) { //XTrace.WriteException(ex); Log?.Error(ex + ""); //throw; if (_fails.Count < MaxFails) { _fails.Enqueue(model); } return; } // 如果发送成功,则继续发送以前失败的数据 while (_fails.Count > 0) { model = _fails.Dequeue(); try { Client.Invoke <Object>("Trace/Report", model); } catch (ApiException ex) { Log?.Error(ex + ""); } catch (Exception ex) { XTrace.WriteLine("二次上报失败,放弃该批次采样数据,{0}", model.Builders.FirstOrDefault()?.StartTime.ToDateTime()); XTrace.WriteException(ex); //Log?.Error(ex + ""); // 星尘收集器上报,二次失败后放弃该批次数据,因其很可能是错误数据 //_fails.Enqueue(model); break; } } }
internal static DaprComponentData DeserializeDaprComponentData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <string> componentType = default; Optional <string> version = default; Optional <bool> ignoreErrors = default; Optional <string> initTimeout = default; Optional <IList <AppSecret> > secrets = default; Optional <IList <DaprMetadata> > metadata = default; Optional <IList <string> > scopes = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("componentType")) { componentType = property0.Value.GetString(); continue; } if (property0.NameEquals("version")) { version = property0.Value.GetString(); continue; } if (property0.NameEquals("ignoreErrors")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } ignoreErrors = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("initTimeout")) { initTimeout = property0.Value.GetString(); continue; } if (property0.NameEquals("secrets")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <AppSecret> array = new List <AppSecret>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(AppSecret.DeserializeAppSecret(item)); } secrets = array; continue; } if (property0.NameEquals("metadata")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <DaprMetadata> array = new List <DaprMetadata>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(DaprMetadata.DeserializeDaprMetadata(item)); } metadata = array; continue; } if (property0.NameEquals("scopes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } scopes = array; continue; } } continue; } } return(new DaprComponentData(id, name, type, systemData, componentType.Value, version.Value, Optional.ToNullable(ignoreErrors), initTimeout.Value, Optional.ToList(secrets), Optional.ToList(metadata), Optional.ToList(scopes))); }
/// <summary> /// Returns a <see cref="string" /> that represents this instance. /// </summary> /// <returns> /// A <see cref="string" /> that represents this instance. /// </returns> public override string ToString() { return($"AppId: {AppId}, AppSecret: {(AppSecret.IsNullOrEmpty() ? "Not Set" : "Set")}, TenantId: {TenantId}, SubscriptionId: {SubscriptionId}, Blob storage InstanceName: {InstanceName}, LockInSeconds: {LockInSeconds}, CreateIfNotExists: {CreateFolderIfNotExists}"); }