private bool CallEndpoint() { object results = null; using (var endpoint = ApiServiceFactory.CreateService <object>(Scenario.Endpoint, Scenario.Headers)) { switch (Scenario.Method) { case "GET": results = endpoint.Get().GetAwaiter().GetResult(); break; case "POST": results = endpoint.Post(Scenario.Payload).GetAwaiter().GetResult(); break; case "PUT": results = endpoint.Put(Scenario.Payload).GetAwaiter().GetResult(); break; case "DELETE": results = endpoint.Delete().GetAwaiter().GetResult(); break; } } if (results == null) { return(false); } File.WriteAllText(Scenario.Output, results.ToString()); return(File.Exists(Scenario.Output)); }
async void OnTimerTick(object state) { _timer.Change(TimeSpan.FromHours(10), TimeSpan.FromHours(10)); try { using (var service = ApiServiceFactory.CreateService <Component>()) { var items = await service.GetItems("components"); foreach (var item in items) { await service.RemoveItem(item, "Id"); } AddCodeComponents(items); } } catch (Exception) { } finally { _timer.Change(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(10)); } }
private async Task GetConfigurationData() { lock (_lock) { if (this.Configuration != null && this.Configuration.Platform.Any()) { return; } } if (DesignMode.DesignModeEnabled) { Uri dataUri = new Uri("ms-appx:///DataModel/interviewer.json"); StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri); string jsonText = await FileIO.ReadTextAsync(file); var ser = new DataContractJsonSerializer(typeof(configuration)); var stream = new MemoryStream(UTF8Encoding.UTF8.GetBytes(jsonText)); lock (_lock) { _configuration = (configuration)ser.ReadObject(stream); } } else { using (var client = ApiServiceFactory.CreateService()) { _configuration = await client.GetConfiguration(); } } }
public async Task <int> DeleteQuestion(Question item) { using (var client = ApiServiceFactory.CreateService(_apiBaseUrl)) { return(await client.AddItem(item)); } }
public async Task <int> DeleteKnowledgeArea(KnowledgeArea item) { using (var client = ApiServiceFactory.CreateService(_apiBaseUrl)) { return(await client.AddItem(item)); } }
public async Task <int> UpdateArea(Area item) { using (var client = ApiServiceFactory.CreateService(_apiBaseUrl)) { return(await client.UpdateItem(item)); } }
public async Task <int> InsertPlatform(Platform item) { using (var client = ApiServiceFactory.CreateService(_apiBaseUrl)) { return(await client.AddItem(item)); } }
private async void GetSummary() { using (var client = ApiServiceFactory.CreateService(_apiBaseUrl)) { IsBusy = true; _summary = await client.GetSummaryEntries(); OnPropertyChanged("Summary"); IsBusy = false; } }
private async void GetEntries() { using (var client = ApiServiceFactory.CreateService(_apiBaseUrl)) { IsBusy = true; _entries = (await client.GetEntries(eEventLevel.All)); OnPropertyChanged("Entries"); IsBusy = false; } }
private async void GetEntries() { //if (!DesignMode.DesignModeEnabled) //{ using (var client = ApiServiceFactory.CreateService(_apiBaseUrl)) { IsBusy = true; _entries = (await client.GetEntries(SelectedLevel)) .Where(x => !IgnoreValues.Contains(x.ShortMessage)); OnPropertyChanged("Entries"); IsBusy = false; } //} //else //{ // #region dummy entries // _entries = new List<LogEntry> // { // new LogEntry // { // TimeStamp = DateTime.UtcNow, // Message = "Error Can't serialize item. Error Exception at System.Xml.Serialization.XmlClass.cs line number: 170", // Computer = Environment.MachineName, // EventLevel = eEventLevel.Error, // User = Environment.UserName, // Source = "System" // }, // new LogEntry // { // TimeStamp = DateTime.UtcNow, // Message = "Item serialized.", // Computer = Environment.MachineName, // EventLevel = eEventLevel.Information, // User = Environment.UserName, // Source = "System" // }, // new LogEntry // { // TimeStamp = DateTime.UtcNow, // Message = "Item partially serialized. Some properties were not expected.", // Computer = Environment.MachineName, // EventLevel = eEventLevel.Warning, // User = Environment.UserName, // Source = "System" // } // }; // #endregion // OnPropertyChanged("Entries"); //} }
public async Task <configuration> LoadConfiguration() { if (!_isLoaded) { using (var client = ApiServiceFactory.CreateService(_apiBaseUrl)) { SelectedConfiguration = await client.GetConfiguration(); } RunQuestionsCommand.Execute(1); _isLoaded = true; } return(SelectedConfiguration); }
private async void GetSlideMarkdown(Action <string> action) { using (var service = ApiServiceFactory.CreateService <string>(Services.SettingsServices.SettingsService.Instance.CodeServicesUrl, useJson: false)) { var parser = ParserFactory.CreateSlideParser(service); var markDown = await parser.Parse(_currentSlide); if (!string.IsNullOrEmpty(markDown)) { markDown = XElement.Parse(markDown).Value; } if (action != null) { action.Invoke(markDown); } } }
public object ConvertBack(object value, Type targetType, object parameter, string language) { if (value is string && !string.IsNullOrEmpty(value.ToString())) { using (var service = ApiServiceFactory.CreateService <Slide>(Services.SettingsServices.SettingsService.Instance.CodeServicesUrl, useJson: false)) { var mdParser = ParserFactory.CreateParser("markdown"); var tokens = mdParser.Parse(value.ToString()); var pParser = ParserFactory.CreatePresentationParser(service); var presentation = pParser.Parse(tokens); if (null != presentation) { return(presentation.Slide.FirstOrDefault()); } } } return(null); }
public async Task <bool> ViewCode(IEnumerable <Component> components) { var list = new Components { Component = new ObservableCollection <Component>(components.Where(x => x.Action.Equals(ComponentAction.View))) }; using (var service = ApiServiceFactory.CreateService <Components>(Services.SettingsServices.SettingsService.Instance.CodeServicesUrl)) { var result = false; try { result = await service.AddItem(list); } catch (Exception) {; } if (!result) { await new DialogService().ShowAsync(string.Format("Make sure Services are installed and running at url {0}. See About page for details.", Services.SettingsServices.SettingsService.Instance.CodeServicesUrl), "Unsuccessful Operation"); } return(result); } }
private async void LoadPresentations(Action <ObservableCollection <Presentation> > action = null) { using (var service = ApiServiceFactory.CreateService <Presentation>()) { _presentations = new ObservableCollection <Presentation>(await service.GetItems("presentations")); if (!_presentations.Any()) { var defaultPresentation = await LoadDefaultPresentation(); if (defaultPresentation != null) { _presentations.Add(defaultPresentation); } } if (action != null) { action.Invoke(_presentations); } } }
private async void LoadStory(Story story) { if (!string.IsNullOrEmpty(story.Name)) { try { var baseUrl = Story.New().Url.ToString(); var flatter = Flatter.Get(); if (string.IsNullOrEmpty(flatter.Value)) { var creds = new Credentials(); if (creds.ShowDialog() == System.Windows.Forms.DialogResult.OK) { flatter = Flatter.Get(creds.User, creds.Password); } } var headers = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("Authorization", "Basic " + flatter.Value) }; using (var client = ApiServiceFactory.CreateService <string>(baseUrl, headers)) { var json = await client.GetItem("/" + story.Name).ConfigureAwait(false); var jiraStory = JsonConvert.DeserializeObject <JiraStory>(json); var description = jiraStory.fields.description; var acceptCrit = string.Empty; var developCrit = string.Empty; var descParts = description.Split(new[] { "Development Criteria", "Acceptance Criteria" }, StringSplitOptions.None); if (descParts.Length == 3) { story.Description = descParts[0]; developCrit = descParts[1]; acceptCrit = descParts[2]; } else if (descParts.Length == 2) { var acceptCritIdx = -1; var developCritIdx = -1; if (description.Contains("Acceptance Criteria") && (acceptCritIdx = description.IndexOf("Acceptance Criteria")) >= 0) { story.Description = descParts[acceptCritIdx > 0 ? 0 : 1]; acceptCrit = descParts[acceptCritIdx > 0 ? 1 : 0]; } else if (description.Contains("Development Criteria") && (developCritIdx = description.IndexOf("Development Criteria")) >= 0) { story.Description = descParts[developCritIdx > 0 ? 0 : 1]; developCrit = descParts[developCritIdx > 0 ? 1 : 0]; } } else { acceptCrit = description.Contains("Acceptance Criteria") ? descParts[0]: string.Empty; developCrit = description.Contains("Development Criteria") ? descParts[0] : string.Empty; story.Description = !description.Contains("Acceptance Criteria") && !description.Contains("Development Criteria") ? descParts[0] : string.Empty; } if (!string.IsNullOrEmpty(acceptCrit)) { story.AcceptanceCriteria = new ObservableCollection <StringValue>( acceptCrit.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) .Select(v => new StringValue(v, "AcceptanceCriteria"))); } if (!string.IsNullOrEmpty(developCrit)) { story.DeveloperCriteria = new ObservableCollection <StringValue>( developCrit.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) .Select(v => new StringValue(v, "DevelopmentCriteria"))); } story.Title = jiraStory.fields.summary; story.Url = new Uri(jiraStory.self); story.ParentStoryUrl = new Uri(jiraStory.fields.project.self); try { story.Attachments.Clear(); } catch (Exception) {; } foreach (var att in jiraStory.fields.attachment) { try { story.Attachments.Add(new StringValue(att.content, "Attachment")); } catch (Exception) {; } } try { story.SubTasks.Clear(); } catch (Exception) {; } foreach (var task in jiraStory.fields.subtasks) { try { story.SubTasks.Add(new SubTask { Name = task.key, Title = task.fields.summary, Url = new Uri(task.self), Status = task.fields.status.name }); } catch (Exception) {; } } try { MainViewModel.ViewModel.IsDirty = true; } catch (Exception) {; } try { MainViewModel.ViewModel.SaveStoryCommand.Execute(null); } catch (Exception) {; } } } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }