public async Task HandleAsync(CapabilityCreatedDomainEvent domainEvent) { var createChannelResponse = await _slackFacade.CreateChannel(domainEvent.Payload.CapabilityName); UserGroupDto userGroup = null; try { userGroup = await _slackService.EnsureUserGroupExists(domainEvent.Payload.CapabilityName); } catch (SlackFacadeException ex) { _logger.LogError($"Issue with Slack API during CreateUserGroup: {ex} : {ex.Message}"); } var channelName = createChannelResponse?.Channel?.Name; if (createChannelResponse.Ok) { var channelId = new ChannelId(createChannelResponse?.Channel?.Id); _logger.LogInformation($"Slack channel '{channelName}' for capability '{domainEvent.Payload.CapabilityName}' created with ID: {channelId}"); var userGroupId = userGroup?.Id; // Save even without user group. var capability = Capability.Create( id: domainEvent.Payload.CapabilityId, name: domainEvent.Payload.CapabilityName, slackChannelId: channelId, slackUserGroupId: userGroupId); _logger.LogInformation($"Capability id: '{capability.Id}' name: '{capability.Name}' slackChannelId: '{capability.SlackChannelId}', userGroupId: '{capability.SlackUserGroupId}'"); await _capabilityRepository.Add(capability); // Notify channel about handle. var sendNotificationResponse = await _slackFacade.SendNotificationToChannel( channelIdentifier : channelId.ToString(), message : $"Thank you for creating capability '{capability.Name}'.\n" + $"This channel along with handle @{userGroup.Handle} has been created.\n" + "Use the handle to notify capability members.\n" + $"If you want to define a better handle, you can do this in the '{userGroup.Name}'"); // Pin message. await _slackFacade.PinMessageToChannel(channelId.ToString(), sendNotificationResponse.TimeStamp); } else { _logger.LogError($"Error creating Slack channel '{channelName}', Error: '{createChannelResponse.Error}'"); } }
public override string ToString() { var sb = new StringBuilder("ChannelIdWithLastUpdated("); bool __first = true; if (ChannelId != null && __isset.channelId) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ChannelId: "); ChannelId.ToString(sb); } if (__isset.lastUpdated) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("LastUpdated: "); LastUpdated.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
/* * /// <summary> * /// Returns the hash code for this session channel. * /// </summary> * public override int GetHashCode() * { * return _id.GetHashCode(); * } * * /// <summary> * /// Returns a value indicating whether this session channel * /// is equal to a specified object. * /// </summary> * public override bool Equals(object obj) * { * IChannel ch = obj as IChannel; * if (ch != null) * return _id.Equals(ch.ChannelId); * * return base.Equals(obj); * } */ /// <summary> /// Used to debug. /// </summary> public override string ToString() { #if DEBUG StringBuilder sb = new StringBuilder(); sb.AppendFormat(CultureInfo.InvariantCulture, "{{{0} Id: {1}", Environment.NewLine, _id); sb.Append(Environment.NewLine).Append(" Listeners: ["); for (int i = 0; i < _listeners.Count; i++) { sb.Append(Environment.NewLine).Append(" +- "); sb.Append(_listeners[i]); } sb.AppendFormat(CultureInfo.InvariantCulture, "{0} ]{0} Subscriptions: [", Environment.NewLine); for (int i = 0; i < _subscriptions.Count; i++) { sb.Append(Environment.NewLine).Append(" +- "); sb.Append(_subscriptions[i]); } sb.AppendFormat(CultureInfo.InvariantCulture, "{0} ]{0}}}", Environment.NewLine); return(sb.ToString()); #else return(_id.ToString()); #endif }
public async Task HandleAsync(AWSContextAccountCreatedDomainEvent domainEvent) { var addUserCmd = $"Get-ADUser \"CN=IT BuildSource DevEx,OU=DFDS AS,OU=Mailboxes,OU=Accounts,OU=DFDS,DC=dk,DC=dfds,DC=root\" | Set-ADUser -Add @{{proxyAddresses=\"smtp:{domainEvent.Payload.RoleEmail}\"}}"; var installToolsCmd = $"Get-WindowsCapability -Online | ? {{$_.Name -like 'Rsat.ActiveDirectory.DS-LDS.Tools*'}} | Add-WindowsCapability -Online"; var addDeployCredentials = $"ROOT_ID={domainEvent.Payload.CapabilityRootId} ACCOUNT_ID={domainEvent.Payload.AccountId} ./kube-config-generator.sh"; var sb = new StringBuilder(); sb.AppendLine($"An AWS Context account has been created for ContextId: {domainEvent.Payload.ContextId}"); sb.AppendLine($"Please execute the following command:"); sb.AppendLine(addUserCmd); sb.AppendLine($"Should you not have RSAT tools installed, please do so with command:"); sb.AppendLine(installToolsCmd); sb.AppendLine("---"); sb.AppendLine($"Please execute the following script in K8s root and AWS prime context for this repo https://github.com/dfds/ded-toolbox/tree/master/k8s-service-account-config-to-ssm:"); sb.AppendLine(addDeployCredentials); var hardCodedDedChannelId = new ChannelId("GFYE9B99Q"); await _slackFacade.SendNotificationToChannel(hardCodedDedChannelId.ToString(), sb.ToString()); // Send message to Capability Slack channel var capabilities = await _capabilityRepository.GetById(domainEvent.Payload.CapabilityId); foreach (var capability in capabilities) { await _slackFacade.SendNotificationToChannel(capability.SlackChannelId.ToString(), $"Status update\n{SlackContextAddedToCapabilityDomainEventHandler.CreateTaskTable(true, false, false)}"); } }
protected override async Task OnInitAsync() { var value = await _ccuValue.ReadAsync(); MessageHub.SendMessage(new ChannelHandlerValueChangedMessage(ChannelId.ToString(), value)); _eventHandler = _mediator.RegisterAsyncHandler <HomeMaticEventMessage>(this, OnEvent); }
public override string ToString() { var sb = new StringBuilder("ChannelNotificationSetting("); bool __first = true; if (ChannelId != null && __isset.channelId) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ChannelId: "); ChannelId.ToString(sb); } if (Name != null && __isset.name) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Name: "); Name.ToString(sb); } if (__isset.notificationReceivable) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("NotificationReceivable: "); NotificationReceivable.ToString(sb); } if (__isset.messageReceivable) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("MessageReceivable: "); MessageReceivable.ToString(sb); } if (__isset.showDefault) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ShowDefault: "); ShowDefault.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
public override string ToString() { var sb = new StringBuilder("CoinUseReservation("); bool __first = true; if (ChannelId != null && __isset.channelId) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ChannelId: "); ChannelId.ToString(sb); } if (ShopOrderId != null && __isset.shopOrderId) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ShopOrderId: "); ShopOrderId.ToString(sb); } if (__isset.appStoreCode) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("AppStoreCode: "); AppStoreCode.ToString(sb); } if (Items != null && __isset.items) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Items: "); Items.ToString(sb); } if (Country != null && __isset.country) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Country: "); Country.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
public async Task CacheAsync() { var channelTask = GuildId == null ? Client.Cache.Channels.SetNullableAsync(Channel) : Client.Cache.GuildChannels.SetNullableAsync(Channel as CoreGuildChannel, GuildId.ToString()); var authorTask = Client.Cache.Users.SetNullableAsync(Author); var memberTask = Client.Cache.GuildMembers.SetNullableAsync(Member, GuildId.ToString()); var messageTask = Client.Cache.Messages.SetAsync(this, ChannelId.ToString()); await Task.WhenAll(channelTask, authorTask, memberTask, messageTask); }
private Task OnEvent(HomeMaticEventMessage msg) { if (msg.Address != _channelAddress || msg.ValueKey != _valueKey) { return(Task.CompletedTask); } MessageHub.SendMessage(new ChannelHandlerValueChangedMessage(ChannelId.ToString(), msg.Value)); return(Task.CompletedTask); }
public async Task HandleAsync(CapabilityDeletedDomainEvent domainEvent) { var hardCodedDedChannelId = new ChannelId("GFYE9B99Q"); var messageForDed = $":x: Capability with Id: '{domainEvent.Payload.CapabilityId}' & name : '{domainEvent.Payload.CapabilityName}' have been deleted" + Environment.NewLine + "Please Do the needfull"; await _slackFacade.SendNotificationToChannel( hardCodedDedChannelId.ToString(), messageForDed ); }
public override string ToString() { var sb = new StringBuilder("FriendChannelMatrix("); bool __first = true; if (ChannelId != null && __isset.channelId) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ChannelId: "); ChannelId.ToString(sb); } if (RepresentMid != null && __isset.representMid) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("RepresentMid: "); RepresentMid.ToString(sb); } if (__isset.count) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Count: "); Count.ToString(sb); } if (__isset.point) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Point: "); Point.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
public async ValueTask <string> GetChannelNameWithCacheAsync(ChannelId channelId) { var strChannelId = channelId.ToString(); var cached = _channelNameCacheRepository.FindById(strChannelId); if (cached == null) { var info = await GetChannelInfo(channelId); cached = new ChannelEntity() { ChannelId = strChannelId, ScreenName = info.ScreenName }; _channelNameCacheRepository.UpdateItem(cached); } return(cached.ScreenName); }
public async Task HandleAsync(ContextAddedToCapabilityDomainEvent domainEvent) { var capabilities = await _capabilityRepository.GetById(domainEvent.Payload.CapabilityId); var message = CreateMessage(domainEvent, _externalEventMetaDataStore.XCorrelationId); var hardCodedDedChannelId = new ChannelId("GFYE9B99Q"); await _slackFacade.SendNotificationToChannel(hardCodedDedChannelId.ToString(), message); // Send message to Capability Slack channels foreach (var capability in capabilities) { await _slackFacade.SendNotificationToChannel( capability.SlackChannelId.ToString(), $"We're working on setting up your environment. Currently the following resources are being provisioned and are awaiting status updates" + $"\n" + $"{CreateTaskTable(false, false, false)}"); } }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = "img"; output.TagMode = TagMode.SelfClosing; string imagePath = $"/images/TvChannel_Logos/{ChannelId.ToString()}.gif"; if (_fileProvider.GetFileInfo("/wwwroot" + imagePath).Exists) { output.Attributes.SetAttribute("src", imagePath); } else { output.Attributes.SetAttribute("src", "/images/TvChannel_Logos/nologo.gif"); } output.Attributes.SetAttribute("alt", ChannelName); }
public async Task <Message> SendAsync(SendableMessage data) { // Cache the string values var id = Id.ToString(); var channel = ChannelId.ToString(); // Retrieve the previous message var previous = await Client.Cache.EditableMessages.GetAsync(id, channel); Message response; // If a previous message exists... if (previous != null) { // Then we check whether or not it's editable (has no attachments), and we're not sending attachments if (Attachments.Length == 0 && data.File == null) { // We update the message and return. response = From(Client, await Client.Rest.Channels[channel] .Messages[previous.OwnMessageId.ToString()] .PatchAsync <Spectacles.NET.Types.Message>(data)); response.GuildId = GuildId; return(response); } // Otherwise we delete the previous message and do a fallback. await Client.Rest.Channels[channel].Messages[previous.OwnMessageId.ToString()].DeleteAsync(); } // Send a message to Discord, receive a Message back. response = From(Client, await Client.Rest.Channels[channel].Messages.PostAsync <Spectacles.NET.Types.Message>(data)); response.GuildId = GuildId; // Store the message into Redis for later processing. await Client.Cache.EditableMessages.SetAsync( new EditableMessage(Client, Id, response.Id), channel); // Return the response. return(response); }
public async Task HandleAsync(AWSContextAccountCreatedDomainEvent domainEvent) { var addUserCmd = $"Get-ADUser \"CN=IT BuildSource DevEx,OU=DFDS AS,OU=Mailboxes,OU=Accounts,OU=DFDS,DC=dk,DC=dfds,DC=root\" | Set-ADUser -Add @{{proxyAddresses=\"smtp:{domainEvent.Payload.RoleEmail}\"}}"; var installToolsCmd = $"Get-WindowsCapability -Online | ? {{$_.Name -like 'Rsat.ActiveDirectory.DS-LDS.Tools*'}} | Add-WindowsCapability -Online"; var addDeployCredentialsBash = $"AWS_ROLE_CLOUD_ADMIN=\"[Cloud Administrator Role ARN]\"\\\n" + $"AWS_ROLE_ADFS_ADMIN=\"[ADFS Administrator Role ARN]\"\\\n" + $"poetry run python ./kube_config_generator.py -r {domainEvent.Payload.CapabilityRootId} -a {domainEvent.Payload.AccountId}"; var addDeployCredentialsPS = $"$ENV:AWS_ROLE_CLOUD_ADMIN=\"[Cloud Administrator Role ARN]\"\\\n" + $"$ENV:AWS_ROLE_ADFS_ADMIN=\"[ADFS Administrator Role ARN]\"\\\n" + $"poetry run python .\\kube_config_generator.py -r {domainEvent.Payload.CapabilityRootId} -a {domainEvent.Payload.AccountId}"; // poetry run python kube_config_generator.py -r {domainEvent.Payload.CapabilityRootId} -a {domainEvent.Payload.AccountId} var sb = new StringBuilder(); sb.AppendLine($"*An AWS Context account has been created for ContextId: {domainEvent.Payload.ContextId}*"); sb.AppendLine("\n_Add email address to shared mailbox_"); sb.AppendLine("Execute the following Powershell command:"); sb.AppendLine($"`{addUserCmd}`"); // sb.AppendLine($"Should you not have RSAT tools installed, please do so with command:"); // sb.AppendLine(installToolsCmd); sb.AppendLine($"\n_Generate k8s service account_"); sb.AppendLine($"Execute the Python script from github.com/dfds/ce-toolbox/k8s-service-account-config-to-ssm. Please ensure that the two environment variables are modified to include the correct Role ARNs."); sb.AppendLine($"Bash:\n```{addDeployCredentialsBash}```"); sb.AppendLine($"Powershell:\n```{addDeployCredentialsPS}```"); var hardCodedDedChannelId = new ChannelId("GFYE9B99Q"); await _slackFacade.SendNotificationToChannel(hardCodedDedChannelId.ToString(), sb.ToString()); // Send message to Capability Slack channel var capabilities = await _capabilityRepository.GetById(domainEvent.Payload.CapabilityId); foreach (var capability in capabilities) { await _slackFacade.SendNotificationToChannel(capability.SlackChannelId.ToString(), $"Status update\n{SlackContextAddedToCapabilityDomainEventHandler.CreateTaskTable(true, false, false)}"); } }
public void Write(DbCommand cmd) { cmd.CommandText = InsertReminder; cmd.Parameters.Add(new SQLiteParameter("@InstantUnix", System.Data.DbType.String) { Value = TriggerTime.UnixTimestamp() }); cmd.Parameters.Add(new SQLiteParameter("@ChannelId", System.Data.DbType.String) { Value = ChannelId.ToString() }); cmd.Parameters.Add(new SQLiteParameter("@Prelude", System.Data.DbType.String) { Value = Prelude }); cmd.Parameters.Add(new SQLiteParameter("@Message", System.Data.DbType.String) { Value = Message }); cmd.Parameters.Add(new SQLiteParameter("@UserId", System.Data.DbType.String) { Value = UserId.ToString() }); }
protected override IIncrementalSource <ChannelVideoListItemViewModel> GenerateIncrementalSource() { return(new ChannelVideoLoadingSource(ChannelId?.ToString() ?? RawChannelId, ChannelProvider)); }
public override string ToString() { return($"{{Type: {typeof(TransportChannelCloseHeader).Name}, {nameof(ChannelId)}: {ChannelId.ToString()}, {nameof(Completion)}: {Completion.ToString()}}}"); }
public IAsyncResult BeginAccountArchiveQuery(DateTime?timeStart, DateTime?timeEnd, string searchText, AccountId userId, ChannelId channel, uint max, string afterId, string beforeId, int firstMessageIndex, AsyncCallback callback) { AssertLoggedIn(); if (userId != null && channel != null) { throw new ArgumentException($"{GetType().Name}: Parameters {nameof(userId)} and {nameof(channel)} cannot be used at the same time"); } if (afterId != null && beforeId != null) { throw new ArgumentException($"{GetType().Name}: Parameters {nameof(afterId)} and {nameof(beforeId)} cannot be used at the same time"); } if (max > 50) { throw new ArgumentException($"{GetType().Name}: {nameof(max)} cannot be greater than 50"); } var ar = new AsyncNoResult(callback); var request = new vx_req_account_archive_query_t { account_handle = _accountHandle, max = max, after_id = afterId, before_id = beforeId, first_message_index = firstMessageIndex }; if (timeStart != null && timeStart != DateTime.MinValue) { request.time_start = timeStart?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"); } if (timeEnd != null && timeEnd != DateTime.MaxValue) { request.time_end = timeEnd?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"); } request.search_text = searchText; if (userId != null) { request.participant_uri = userId.ToString(); } else if (channel != null) { request.participant_uri = channel.ToString(); } VxClient.Instance.BeginIssueRequest(request, result => { vx_resp_account_archive_query_t response; try { response = VxClient.Instance.EndIssueRequest(result); _accountArchiveResult = new ArchiveQueryResult(response.query_id); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(AccountArchiveResult))); ar.SetComplete(); } catch (Exception e) { VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}"); ar.SetComplete(e); if (VivoxDebug.Instance.throwInternalExcepetions) { throw; } return; } }); return(ar); }
/* ------------------------------------------------------------ */ public override string ToString() { return(_id.ToString()); }
public async Task <CoreGuildChannel?> GetChannelAsync() { return(await Client.Cache.GuildChannels.GetAsync(ChannelId.ToString())); }
public override string ToString() { return($"{{Type: {typeof(TransportFrameHeader).Name}, {nameof(ChannelId)}: {ChannelId.ToString()}, {nameof(Length)}: {Length.ToString()}, {nameof(HasMore)}: {HasMore.ToString()}}}"); }
public void Login(string login, string password) { lock (loginLock) { LoggedIn = false; if (loginWC.gotCookies(cookieForTest, mainDomain)) { LoggedIn = true; return; } String content = String.Empty; try { content = loginWC.DownloadString(loginUrl); } catch (Exception e) { Debug.Print("Sc2tv login error: {0}", e.Message); } if (String.IsNullOrEmpty(content)) { return; } string formBuildId = Re.GetSubString(content, reHiddenFormId, 1); if (String.IsNullOrEmpty(formBuildId)) { Debug.Print("Can't find Form Build ID. Check RE"); return; } else if (formBuildId != null) { try { string loginParams = "name=" + HttpUtility.UrlEncode(login) + "&pass="******"&form_build_id=" + formBuildId + "&form_id=user_login_block"; loginWC.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded; charset=UTF-8"; loginWC.UploadString(loginUrl, loginParams); if (loginWC.gotCookies(cookieForTest, mainDomain)) { loginWC.setCookie("chat-img", "1", "chat.sc2tv.ru"); loginWC.setCookie("chat_channel_id", ChannelId.ToString(), "chat.sc2tv.ru"); loginWC.setCookie("chat-on", "1", "chat.sc2tv.ru"); loginWC.DownloadString(chatTokenUrl); loginWC.setCookie("chat_token", loginWC.CookieValue("chat_token", chatDomain + "/gate.php"), "chat.sc2tv.ru"); LoggedIn = true; settingsWC.Cookies = loginWC.Cookies; OnLogon(new Sc2Event()); } } catch { Debug.Print("Exception in Sc2 Login()"); } } } }
protected override Task WriteValueAsync(object value) { MessageHub.SendMessage(new ChannelHandlerValueChangedMessage(ChannelId.ToString(), value)); return(Task.CompletedTask); }
protected override Task OnInitAsync() { MessageHub.SendMessage(new ChannelHandlerValueChangedMessage(ChannelId.ToString(), 100)); return(Task.CompletedTask); }
public async Task <object> ReactAsync(string reaction) { return(await Client.Rest.Channels[ChannelId.ToString()].Messages[Id.ToString()].Reactions[reaction]["@me"] .PutAsync <object>(null)); }
public async Task <Message> DeleteAsync(string?reason) { await Client.Rest.Channels[ChannelId.ToString()].Messages[Id.ToString()].DeleteAsync(reason); return(this); }
public async Task <Message> EditAsync(SendableMessage data) { return(From(Client, await Client.Rest.Channels[ChannelId.ToString()].Messages[Id.ToString()] .PatchAsync <Spectacles.NET.Types.Message>(data))); }
public async Task <Channel?> GetChannelAsync() { return(Channel ??= GuildId == null ? await Client.Cache.Channels.GetAsync(ChannelId.ToString()) : await Client.Cache.GuildChannels.GetAsync(ChannelId.ToString(), GuildId.ToString())); }