public void ResetSeverities() { foreach (Severity severity in Enum.GetValues(typeof(Severity))) { Severities.Add(severity); } }
private async System.Threading.Tasks.Task SetSeverities() { try { var severities = await _issuesAPI .GetSeveritiesAsync(Xamarin.Forms.Application.Current.Properties["token"].ToString()); foreach (var item in severities) { SeverityTitle = item.SeverityTitle; Severities.Add(new SeverityView { Id = item.Id, SeverityTitle = item.SeverityTitle }); } } catch (System.Net.Http.HttpRequestException ex) { // await MainPage.DisplayAlert("Internet", "Chack your internet connection", "Ok"); } catch (Exception ex) { // await MainPage.DisplayAlert("Exeption", ex.Message + "/n " + Convert.ToString(ex.Data), "Ok"); } }
/// <summary> /// /// </summary> /// <param name="itemType"></param> /// <param name="value"></param> private void AddItem(ItemType itemType, object value) { if (value.ToString().Length == 0) { return; } switch (itemType) { case ItemType.IpAddress: var ipAddresses = from ipAddress in IpAddresses where ipAddress.Text.ToUpper() == ((string)value).ToUpper() select ipAddress; if (ipAddresses.Count() == 0) { IpAddress ipAddress = new IpAddress(); ipAddress.Text = (string)value; IpAddresses.Add(ipAddress); } break; case ItemType.HostName: var hosts = from host in HostNames where host.ToUpper() == ((string)value).ToUpper() select host; if (hosts.Count() == 0) { HostNames.Add((string)value); } break; case ItemType.Port: var ports = from port in Ports where port == (int)value select port; if (ports.Count() == 0) { Ports.Add((int)value); } break; case ItemType.Protocol: var protocols = from protocol in Protocols where protocol.ToUpper() == ((string)value).ToUpper() select protocol; if (protocols.Count() == 0) { Protocols.Add(((string)value).ToUpper()); } break; case ItemType.Service: var services = from service in Services where service.ToUpper() == ((string)value).ToUpper() select service; if (services.Count() == 0) { Services.Add((string)value); } break; case ItemType.State: var states = from state in States where state.ToUpper() == ((string)value).ToUpper() select state; if (states.Count() == 0) { States.Add((string)value); } break; case ItemType.Severities: var severities = from severity in Severities where severity.ToUpper() == ((string)value).ToUpper() select severity; if (severities.Count() == 0) { Severities.Add((string)value); } break; case ItemType.PluginFamily: var pluginFamilies = from pluginFamily in PluginFamilys where pluginFamily.ToUpper() == ((string)value).ToUpper() select pluginFamily; if (pluginFamilies.Count() == 0) { PluginFamilys.Add((string)value); } break; case ItemType.PluginId: var pluginIds = from pluginId in PluginIds where pluginId.ToString().ToUpper() == ((string)value).ToUpper() select pluginId; if (pluginIds.Count() == 0) { PluginIds.Add(int.Parse(value.ToString())); } break; case ItemType.PluginName: var pluginNames = from pluginName in PluginNames where pluginName.ToUpper() == ((string)value).ToUpper() select pluginName; if (pluginNames.Count() == 0) { PluginNames.Add((string)value); } break; case ItemType.Product: var products = from product in Products where product.ToUpper() == ((string)value).ToUpper() select product; if (products.Count() == 0) { Products.Add((string)value); } break; case ItemType.Versions: var versions = from version in Versions where version.ToUpper() == ((string)value).ToUpper() select version; if (versions.Count() == 0) { Versions.Add((string)value); } break; case ItemType.ExploitAvailable: var exploitAvailable = from e in ExploitAvailable where e.ToUpper() == ((string)value).ToUpper() select e; if (exploitAvailable.Count() == 0) { ExploitAvailable.Add((string)value); } break; default: break; } }