示例#1
0
        private async Task UpdateMetaControls()
        {
            Storage.RemoveByLabel(CollectionControlsLabel);
            var controls = CreateCollectionControlsCrate();

            AddFileDescriptionToStorage(Storage, controls.Get <StandardConfigurationControlsCM>().Controls.Where(a => a.Type == ControlTypes.FilePicker).ToList());
            Storage.Add(controls);

            await HubCommunicator.SaveActivity(ActivityContext.ActivityPayload, true);

            string launchUrl = GetLaunchUrl();
            await _planService.ConfigureAsApp(ActivityId, launchUrl, ActivityContext.ActivityPayload.Label);

            await _pushNotificationService.PushUserNotification(MyTemplate, "App Builder URL Generated", "This Plan can be launched with the following URL: " + launchUrl);
        }
        public override async Task Run()
        {
            ActivityUI.RestoreCustomFields(Storage);

            var issueInfo = ExtractIssueInfo();
            await _atlassianService.CreateIssue(issueInfo, AuthorizationToken);

            var credentialsDTO = JsonConvert.DeserializeObject <CredentialsDTO>(AuthorizationToken.Token);
            var jiraUrl        = $"{credentialsDTO.Domain}/browse/{issueInfo.Key}";


            Payload.Add(Crate.FromContent("jira issue", new StandardPayloadDataCM(new KeyValueDTO()
            {
                Key = "jira issue key", Value = issueInfo.Key
            })));
            Payload.Add(Crate.FromContent("jira issue", new StandardPayloadDataCM(new KeyValueDTO()
            {
                Key = "jira domain", Value = credentialsDTO.Domain
            })));
            await _pushNotificationService.PushUserNotification(MyTemplate, "Jira Issue Created", $"Created new jira issue: {jiraUrl}");

            Payload.Add(Crate <KeyValueListCM> .FromContent(RuntimeCrateLabel, new KeyValueListCM(
                                                                new KeyValueDTO(JiraIdField, issueInfo.Key),
                                                                new KeyValueDTO(JiraUrlField, jiraUrl))));
        }
        public override async Task Run()
        {
            var token = JsonConvert.DeserializeObject <BoxAuthTokenDO>(AuthorizationToken.Token);
            var desiredCrateDescription = ActivityUI.FileChooser.CrateDescriptions.Single(x => x.Selected);
            var tableCrate = Payload.CratesOfType <StandardTableDataCM>()
                             .FirstOrDefault(x => x.Label == desiredCrateDescription.Label &&
                                             x.ManifestType.Type == desiredCrateDescription.ManifestType);

            if (tableCrate == null)
            {
                RaiseError($"Selected crate {desiredCrateDescription.Label} doesn't contains table data");
                return;
            }
            var    fileName = ActivityUI.Filename.Value.Trim();
            var    service  = new BoxService(token);
            string fileId;

            using (var stream = new MemoryStream())
            {
                CreateWorkbook(stream, tableCrate);
                // Need to reset stream before saving it to box.
                stream.Seek(0, SeekOrigin.Begin);
                fileId = await service.SaveFile($"{fileName}.xlsx", stream);
            }
            var downloadLink = await service.GetFileLink(fileId);

            await _pushNotificationService.PushUserNotification(MyTemplate, "File Download URL Generated", "File was upload to Box. You can download it using this url: " + downloadLink);
        }
 private async Task PushLaunchURLNotification(string url)
 {
     await _pushNotificationService.PushUserNotification(MyTemplate, "Excel File URL Generated", $"The Excel file can be downloaded by navigating to this URL: {new Uri(url).AbsoluteUri}");
 }