protected override async Task <MessagingExtensionActionResponse> OnTeamsMessagingExtensionSubmitActionAsync(ITurnContext <IInvokeActivity> turnContext, MessagingExtensionAction action, CancellationToken cancellationToken) { var taskModuleOutput = JsonConvert.DeserializeObject <TaskModuleSubmitDataDeserializer>(turnContext.Activity.Value.ToString()); if (taskModuleOutput.data.SubmittedByMail == null) { action.CommandId = taskModuleOutput.commandId; var task = await OnTeamsMessagingExtensionFetchTaskAsync(turnContext, action, cancellationToken); return(task); } if (taskModuleOutput.commandId == Constants.MessageExtensionCommandId) { var member = await TeamsInfo.GetMemberAsync(turnContext, taskModuleOutput.data.AssignedTo.objectId, cancellationToken); taskModuleOutput.data.AssignedTo.objectId = member.Id; var blobId = await BlobHelper.UploadToBlob(taskModuleOutput, turnContext); var blobData = BlobHelper.GetBlob(blobId, null).Result; var cardResponse = CardHelper.CreateAdaptiveCardAttachment(Status.BaseCard, blobData, "msteams", out string cardJsonstring); var messageResponse = await turnContext.SendActivityAsync(MessageFactory.Attachment(cardResponse), cancellationToken); string messageId = messageResponse.Id; BlobHelper.GetBlob(blobId, null, messageId); //Send Mail await OutlookConnector.SendMailAsync(Constants.SenderEmail, blobData.assignedToMail, cardJsonstring, Constants.MailSubject); } return(new MessagingExtensionActionResponse()); }
public async Task <ActionResult <string> > LoadViewDetails(string reqID) { var blobData = BlobHelper.GetBlob(reqID, null).Result; var serializeResponse = JsonConvert.SerializeObject(blobData); var response = JsonConvert.SerializeObject(serializeResponse); return(response); }
static int Main(string[] args) { if (args.Length != 1) { string usage = "Usage: GetBlob container/blob"; Trace.TraceInformation(usage); Console.WriteLine(usage); return(Settings.SUCCESS); } string blobPath = args[0]; string[] fields = blobPath.Split('/'); string containerName = fields[0]; string blobName = fields[1]; BlobHelper blobHelper = new BlobHelper(); blobHelper.GetBlob(containerName, blobName, blobName); return(Settings.SUCCESS); }
private static List <Airport> LoadAirportData(out string errmsg) { var errors = new StringBuilder( ); try { if (_airports != null && _airports.Count > 0) { errmsg = ""; return(_airports); } var key = "get-airport-data"; var obj = CacheHelper.GetCachedItem(key); if (obj == null) { var arr = BlobHelper.GetBlob(Invariables.SwitchStorageConnection, "airportdata.csv", "system-defaults"); var lines = Encoding.ASCII.GetString(arr).Split('\n'); var i = 0; foreach (var line in lines) { try { if (i != 0) { var tokens = StringSplit(line.Replace("\r", "")); if (tokens.Length > 0) { if (_airports == null) { _airports = new List <Airport>( ); } _airports.Add(new Airport { Code = tokens[0], AirportName = tokens[1], Latitude = double.Parse(tokens[2]), Longitude = double.Parse(tokens[3]), Area = tokens[4] }); } } } catch (Exception) { errors.AppendLine("Error line # " + i + Environment.NewLine); Logger.ErrorLog("WeatherUtility", "LoadAirportData", "Error line # " + i); } finally { i++; } } if (_airports != null && _airports.Count > 0) { CacheHelper.AddToCache(key, _airports); } if (_airports != null) { Logger.LocalLog("WeatherUtility", "LoadAirportData", "LogMessage", "Loaded " + _airports.Count + " airports"); errmsg = errors.Length > 5 ? errors.ToString() : ""; return(_airports); } errmsg = ""; return(_airports); } errmsg = ""; _airports = (List <Airport>)obj; return(_airports); } catch (Exception exception) { errmsg = "Error: " + exception; Logger.ErrorLog("DataHelper", "LoadAirportData", exception.ToString( )); return(null); } }
protected override async Task <InvokeResponse> OnInvokeActivityAsync(ITurnContext <IInvokeActivity> turnContext, CancellationToken cancellationToken) { if (Constants.ComposeExtensionFetch.Equals(turnContext.Activity.Name)) { MessagingExtensionAction action = new MessagingExtensionAction(); var actionJson = JsonConvert.DeserializeObject <MessagingExtensionActionDeserializer>(turnContext.Activity.Value.ToString()); action.CommandId = actionJson.commandId; var task = await this.OnTeamsMessagingExtensionFetchTaskAsync(turnContext, action, cancellationToken); return(CreateInvokeResponse(task)); } else if (Constants.ComposeExtensionSubmit.Equals(turnContext.Activity.Name)) { MessagingExtensionAction action = new MessagingExtensionAction(); var task = await this.OnTeamsMessagingExtensionSubmitActionAsync(turnContext, action, cancellationToken); return(CreateInvokeResponse(task)); } else if (Constants.TaskModuleFetch.Equals(turnContext.Activity.Name)) { var actionJson = JsonConvert.DeserializeObject <ActionBase>(turnContext.Activity.Value.ToString()); var task = await ReturnViewDetails(actionJson.data.reqId); return(CreateInvokeResponse(task)); } else if (Constants.AdaptiveCardAction.Equals(turnContext.Activity.Name)) { var data = JsonConvert.DeserializeObject <ActionType>(turnContext.Activity.Value.ToString()); string channel = turnContext.Activity.ChannelId; string verb = data.action.verb; var blobInfo = BlobHelper.GetBlob(data.action.data.reqId, verb).Result; string cardJsonString; if (Status.Refresh.Equals(verb) && Status.Pending.Equals(blobInfo.status)) { CardHelper.CreateAdaptiveCardAttachment(blobInfo.status, blobInfo, channel, out cardJsonString); var cardResponse = JObject.Parse(cardJsonString); var res = new AdaptiveCardInvokeResponse() { StatusCode = 200, Type = AdaptiveCard.ContentType, Value = cardResponse }; return(CreateInvokeResponse(res)); } else { var adaptiveCardAttachment = CardHelper.CreateAdaptiveCardAttachment(blobInfo.status, blobInfo, channel, out cardJsonString); UpdateCardInTeams(blobInfo, adaptiveCardAttachment); var cardResponse = JObject.Parse(cardJsonString); var res = new AdaptiveCardInvokeResponse() { StatusCode = 200, Type = AdaptiveCard.ContentType, Value = cardResponse }; return(CreateInvokeResponse(res)); } } return(null); }