public ActionResult CatalogSearch(string searchString, ServiceCatalog type) { searchString = searchString?.ToLower(); //compare everything in lowercase CatalogModel model = new CatalogModel { Catalog = type }; model.Controls = new CatalogControlsModel { CatalogType = type }; ServiceCatalogSearcher searcher = new ServiceCatalogSearcher(_catalogController); List <ICatalogPublishable> searchresults = searcher.Search(type, searchString, UserId); //pagination if (searchresults.Count > _pageSize) { model.Controls.TotalPages = (searchresults.Count + _pageSize - 1) / _pageSize; searchresults = (searchresults.Skip(0).Take(_pageSize)).ToList(); } model.CatalogItems = searchresults; return(View("ServiceCatalogGeneral", model)); }
private async Task UpdateCatalogFromConsul() { var catalog = new ServiceCatalog(); using (var client = new HttpClient()) { var response = await client.GetAsync("http://localhost:8500/v1/agent/services"); var responseDictionary = await response.Content.ReadAsAsync <Dictionary <string, object> >(); foreach (var item in responseDictionary) { try { var serviceName = item.Key; var service = (item.Value as JObject).ToObject <ConsulService>(); if (service.Tags.Contains(Tag)) { catalog.AddServiceInfo("Consul", service.Service, service.Address, service.Port); } } catch { //LOG SOMETHING! } } } Catalog = catalog; }
/// <summary> /// Gets the endpoint for the specified identity and region. /// </summary> /// <param name="serviceType">The provider specific service type to look for in the service catalog</param> /// <param name="userAccess">The user access instance.</param> /// <param name="defaultIdentity">The cloud identity.</param> /// <param name="region">The endpoint region.</param> /// <param name="useInternalUrl">if set to <c>true</c> [use internal URL].</param> /// <returns></returns> /// <exception cref="OpenStack.UserAuthenticationException"> /// The user does not have access to the service or it does not exist. /// or /// The user does not have access to the service endpoint in the specified region. /// </exception> /// <exception cref="RegionRequiredException">No region was specified and the service does not provide a region-independent endpoint.</exception> public static string GetEndpoint(string serviceType, UserAccess userAccess, CloudIdentity defaultIdentity, string region, bool useInternalUrl) { ServiceCatalog service = userAccess.ServiceCatalog.FirstOrDefault(sc => string.Equals(sc.Type, serviceType, StringComparison.OrdinalIgnoreCase)); if (service == null) { throw new UserAuthenticationException("The user does not have access to the {0} service or it does not exist.", serviceType); } Endpoint endpoint = service.Endpoints .Where(e => string.Equals(e.Region, region, StringComparison.OrdinalIgnoreCase)) .OrderByDescending(e => e.Region) .FirstOrDefault(); if (string.IsNullOrEmpty(region) && endpoint == null) { throw new RegionRequiredException("No region was specified and the {0} service does not provide a region-independent endpoint.", serviceType); } if (endpoint == null) { throw new UserAuthenticationException("The user does not have access to the {0} endpoint in the {1} region.", serviceType, region); } return(useInternalUrl ? endpoint.InternalURL : endpoint.PublicURL); }
public ActionResult CatalogSearch(string searchString, ServiceCatalog type, int pageId) { searchString = searchString?.ToLower() ?? ""; //compare everything in lowercase var model = new CatalogModel { Catalog = type, Controls = new CatalogControlsModel { CatalogType = type, PageNumber = pageId } }; var searcher = new ServiceCatalogSearcher(_catalogController); var searchresults = searcher.Search(type, searchString, UserId); //pagination if (searchresults.Count > _pageSize) { model.Controls.TotalPages = (searchresults.Count + _pageSize - 1) / _pageSize; searchresults = (searchresults.Skip(_pageSize * pageId).Take(_pageSize)).ToList(); } model.CatalogItems = searchresults; return(View("ServiceCatalogGeneral", model)); }
public ActionResult DeleteConfirmed(int id) { ServiceCatalog service = db.Services.Find(id); db.Services.Remove(service); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Return View of an option /// </summary> /// <param name="catalog"></param> /// <param name="type"></param> /// <param name="id"></param> /// <returns></returns> public ActionResult Details(ServiceCatalog catalog, CatalogableType type, int id) { int serviceId = 0; switch (type) { case CatalogableType.Option: serviceId = _portfolioService.GetServiceOptionCategory(UserId, _portfolioService.GetServiceOption(UserId, id).ServiceOptionCategoryId).ServiceId; break; case CatalogableType.Category: serviceId = _portfolioService.GetServiceOptionCategory(UserId, id).ServiceId; break; case CatalogableType.Service: serviceId = id; break; } var service = _portfolioService.GetService(serviceId); if (service != null) { OptionModel model = new OptionModel { Catalog = catalog }; //pack a list of options and categories if (type == CatalogableType.Category) { model.Option = service.ServiceOptionCategories.FirstOrDefault(o => o.Id == id); } else if (type == CatalogableType.Option) { model.Option = (ICatalogPublishable)service.ServiceOptions.FirstOrDefault(s => s.Id == id); } model.ServiceId = service.Id; model.ServiceName = service.Name; //add data List <ICatalogPublishable> options = (from o in service.ServiceOptionCategories select(ICatalogPublishable) o).ToList(); //build list of options & categories if (service.ServiceOptions != null) { //options.AddRange(from o in service.ServiceOptions select (ICatalogPublishable)o); //sort by name } options = options.OrderBy(o => o.Name).ToList(); model.Options = options; //now create the controls model model.Controls = new CatalogControlsModel { CatalogType = catalog }; return(View(model)); } return(View()); //not sure how you got here... }
static void Main(string[] args) { ServiceStudent st = new ServiceStudent(new XMLRepoStudent(new ValidatorStudent(), "C:\\Users\\Deus\\documents\\visual studio 2015\\Projects\\Lab7Map\\Lab7Map\\XMLdata\\Studenti.xml")); ServiceTema tm = new ServiceTema(new XMLRepoTema(new ValidatorTema(), "C:\\Users\\Deus\\documents\\visual studio 2015\\Projects\\Lab7Map\\Lab7Map\\XMLdata\\Teme.xml")); ServiceNota nt = new ServiceNota(new XMLRepoNota(new ValidatorNota(), "C:\\Users\\Deus\\documents\\visual studio 2015\\Projects\\Lab7Map\\Lab7Map\\XMLdata\\Note.xml")); ServiceCatalog catalog = new ServiceCatalog(st, tm, nt); var ui = new UI.UI(catalog); ui.runMainMenu(); }
public ActionResult Edit([Bind(Include = "Id")] ServiceCatalog service) { if (ModelState.IsValid) { db.Entry(service).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(service)); }
static void Main(string[] args) { S4ServiceClient s4 = new S4ServiceClient(ServiceCatalog.getItem("news"), "<api-key>", "<api-pass>"); // System.Console.Write(s4.annotateDocumentFromUrl(new Uri("http://www.bbc.com/news/uk-politics-29784493"), SupportedMimeType.HTML).text); Stream st = s4.annotateDocumentAsStream("We will always remember the courage of those who served on our behalf.", SupportedMimeType.PLAINTEXT, ResponseFormat.GATE_XML); StreamReader str = new StreamReader(st); Console.WriteLine(str.ReadToEnd()); Console.Read(); }
public ActionResult Create([Bind(Include = "Id")] ServiceCatalog service) { if (ModelState.IsValid) { db.Services.Add(service); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(service)); }
// GET: Services/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServiceCatalog service = db.Services.Find(id); if (service == null) { return(HttpNotFound()); } return(View(service)); }
/// <summary> /// Returns View of all options for a Service /// </summary> /// <param name="type"></param> /// <param name="serviceId"></param> /// <returns></returns> public ActionResult ServiceOptions(ServiceCatalog type, int serviceId) { var model = new ServiceOptionsModel { Catalog = type, ServiceId = serviceId }; model.Controls = new CatalogControlsModel(); IList <IServiceDto> services = null; if (type == ServiceCatalog.Business || type == ServiceCatalog.Business) //create list of available services to view { services = _catalogController.RequestBusinessCatalog(UserId).ToList(); } else if (type == ServiceCatalog.Technical || type == ServiceCatalog.Technical) { services = _catalogController.RequestSupportCatalog(UserId).ToList(); } if (services != null) { var service = services.FirstOrDefault(s => s.Id == serviceId); model.ServiceName = service.Name; //fill in the services list model.ServiceBusinessValue = service.BusinessValue; model.ServiceNames = from s in services select new Tuple <int, string>(s.Id, s.Name); List <ICatalogPublishable> options = new List <ICatalogPublishable>(); if (service.ServiceOptionCategories != null) { options = (from o in service.ServiceOptionCategories select(ICatalogPublishable) o).ToList(); } model.Options = options.OrderByDescending(o => o.Popularity); } return(View(model)); }
static void Main(string[] args) { IValidator <Student> validatorS = new ValidareStudent(); IValidator <Tema> validatorT = new ValidareTema(); IValidator <Inregistrare> validatorN = new ValidatorNota(); ICrudRepository <int, Student> repoS = new InMemoryRepository <int, Student>(validatorS); ICrudRepository <int, Tema> repoT = new InMemoryRepository <int, Tema>(validatorT); ICrudRepository <int, Inregistrare> repoN = new InMemoryRepository <int, Inregistrare>(validatorN); string filenameS = "D://Facultate Anul II//Metode Avansate de Programare//Laborator12-13//Laborator12-13//Date//Studenti.txt"; string filenameT = "D://Facultate Anul II//Metode Avansate de Programare//Laborator12-13//Laborator12-13//Date//Teme.txt"; string filenameC = "D://Facultate Anul II//Metode Avansate de Programare//Laborator12-13//Laborator12-13//Date//Catalog.txt"; ICrudRepository <int, Student> repoSF = new StudentInFileRepository(validatorS, filenameS); ICrudRepository <int, Tema> repoTF = new TemeInFileRepository(validatorT, filenameT); ICrudRepository <int, Inregistrare> repoNF = new NoteInFileRepository(validatorN, filenameC); ServiceStudent serviceS = new ServiceStudent(repoSF); ServiceTema serviceT = new ServiceTema(repoTF); ServiceCatalog serviceC = new ServiceCatalog(repoNF, repoTF, repoSF); Controler controller = new Controler(serviceC, serviceS, serviceT); controller.run(); }
/// <summary> /// 数据服务自动编目 /// </summary> /// <param name="dbsid"></param> /// <returns></returns> public bool ServiceAutoCatalog(string dbsid, string serviceType = "DBSInfo") { var serviceCatalog = new ServiceCatalog() { Id = Guid.NewGuid().ToString(), ServiceId = dbsid, ServiceType = serviceType, ClassifyId = ClassifyIdDefault, CatalogId = CatalogIdDefault, CreateDate = DateTime.Now }; using (SqlConnection connDB = new SqlConnection(conn)) { try { connDB.Open(); var result = connDB.Execute(@"insert into ServiceCatalog(Id, ServiceId, ServiceType, ClassifyId, CatalogId, BZ, CreateDate) VALUES (@Id, @ServiceId, @ServiceType, @ClassifyId, @CatalogId, @BZ, @CreateDate)", serviceCatalog); if (result > 0) { return(true); } } catch (Exception ex) { return(false); } finally { connDB.Close(); } } return(false); }
public static void Main(string[] args) { object registerLock = new object(); List <ServiceEntry> entries = new List <ServiceEntry>(); Server server = new Server { Services = { ServiceRegistration.BindService(new ServiceRegistrationImpl(registerLock, entries)), ServiceCatalog.BindService(new ServiceCatalogImpl(registerLock, entries)) }, Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Greeter server listening on port " + Port); Console.WriteLine("Press any key to stop the server..."); Console.ReadKey(); server.ShutdownAsync().Wait(); }
/// <summary> /// Constructs an {@link IS4ClassificationClientImpl} to be used with the text classification service ('news-classifier') /// </summary> /// <param name="apiKey">Your S4 Api Key</param> /// <param name="keySecret">Your S4 Key Secret</param> /// <returns>An {@link IS4ClassificationClientImpl} to access the S4 'news-classifier' service</returns> public static IS4ClassificationClientImpl createClassificationClient(String apiKey, String keySecret) { return(new S4ClassificationClientImpl(ServiceCatalog.getItem("news-classifier"), apiKey, keySecret)); }
/// <summary> /// Constructs an {@link IS4AnnotationClientImpl} to be used with the text annotation services ('news', 'news-de', 'sbt', 'twitie', etc.) /// </summary> /// <param name="service">The service name to be used </param> /// <param name="apiKey">Your S4 API Key</param> /// <param name="keySecret">Your S4 Key Secret</param> /// <returns> An {@link IS4AnnotationClientImpl} to access the S4 text annotation services</returns> public static IS4AnnotationClientImpl createAnnotationClient(String service, String apiKey, String keySecret) { return(createAnnotationClient(ServiceCatalog.getItem(service), apiKey, keySecret)); }
public Controler(ServiceCatalog servC, ServiceStudent servS, ServiceTema servT) { this.servC = servC; this.servS = servS; this.servT = servT; }
public UiCommands(ServiceCatalog service) { this.service = service; }
/// <summary> /// Service Catalog Index, either business, technical, or both /// </summary> /// <param name="type"></param> /// <param name="id"></param> /// <returns></returns> public ActionResult Index(ServiceCatalog type = ServiceCatalog.Business, int id = 0) { CatalogModel model = new CatalogModel { Catalog = type, CatalogItems = new List <ICatalogPublishable>() }; model.Controls = new CatalogControlsModel { SearchString = "", CatalogType = type }; //setup info for the controls IEnumerable <IServiceDto> services; //lazy loaded data for filtering and use later if (type == ServiceCatalog.Both || type == ServiceCatalog.Business) //add things from the business catalog { services = (from s in _catalogController.RequestBusinessCatalog(UserId) select s).ToList(); foreach (var service in services) //add services to the catalog model { var i = new ServiceSummary { Name = service.Name, Id = service.Id, BusinessValue = service.Description, Options = new List <ICatalogPublishable>() }; if (service.ServiceOptionCategories != null) { i.Options.AddRange((from o in service.ServiceOptionCategories select(ICatalogPublishable) o).ToList()); //find the top 3 items } if (service.ServiceOptions != null) { //i.Options.AddRange((from o in service.ServiceOptions select (ICatalogPublishable) o).ToList()); removed upon request } int take; try { take = ConfigHelper.GetScTopAmount(); } catch (Exception) { take = 3; } i.Options = i.Options.OrderByDescending(o => o.Popularity).Take(take).ToList(); model.CatalogItems.Add(i); } } if (type == ServiceCatalog.Both || type == ServiceCatalog.Technical) //add things from the tech catalog { services = (from s in _catalogController.RequestSupportCatalog(UserId) select s).ToList(); foreach (var service in services) //add services to the catalog model { var i = new ServiceSummary { Name = service.Name, Id = service.Id, BusinessValue = service.Description, Options = new List <ICatalogPublishable>() }; i.Options.AddRange((from o in service.ServiceOptionCategories select(ICatalogPublishable) o).ToList()); //find the top 3 items //i.Options.AddRange((from o in service.ServiceOptions select (ICatalogPublishable)o).ToList()); i.Options = i.Options.OrderByDescending(o => o.Popularity).Take(ConfigHelper.GetScTopAmount()).ToList(); model.CatalogItems.Add(i); } } model.CatalogItems = model.CatalogItems.OrderByDescending(x => x.Popularity).ToList(); if (model.CatalogItems != null && model.CatalogItems.Count > _pageSize) { model.Controls.TotalPages = (model.CatalogItems.Count + _pageSize - 1) / _pageSize; model.CatalogItems = (List <ICatalogPublishable>)model.CatalogItems.Skip(_pageSize * id).Take(_pageSize); } return(View("ServiceCatalog", model)); }
public static void main(String[] args) { if (args == null || args.Length == 0) { printUsageAndTerminate(null); } Parameters parameters = new Parameters(args); String serviceID = parameters.getValue("service"); if (serviceID == null) { printUsageAndTerminate("No service name provided"); } ServiceDescriptor service = null; try { service = ServiceCatalog.getItem(serviceID); } catch (NotSupportedException nse) { printUsageAndTerminate("Unsupported service '" + serviceID + '\''); Console.WriteLine(nse.Message); } SupportedMimeType mimetype = SupportedMimeType.PLAINTEXT; if (parameters.getValue("dtype") != null) { try { mimetype = NumToEnum <SupportedMimeType>(parameters.getValue("dtype").ToString()); } catch (ArgumentException ae) { printUsageAndTerminate("Unsupported document type (dtype) : " + parameters.getValue("dtype")); Console.WriteLine(ae.Message); } } String inFile = parameters.getValue("file"); String url = parameters.getValue("url"); String outFile = parameters.getValue("out", "result.txt"); if (inFile != null) { if (false == new FileStream(inFile, FileMode.OpenOrCreate).CanRead) { printUsageAndTerminate("Input file is not found : " + inFile); } } else { if (url == null) { printUsageAndTerminate("Neither input file, nor remote URL provided"); } } Dictionary <String, String> creds = readCredentials(parameters); if (false == creds.ContainsKey("apikey") || false == creds.ContainsKey("secret")) { printUsageAndTerminate("No credentials details found"); } S4ServiceClient client = new S4ServiceClient(service, creds["apikey"], creds["secret"]); try { Stream resultData = (inFile != null) ? client.annotateFileContentsAsStream(new FileStream(inFile, FileMode.OpenOrCreate), CharSet.Unicode.ToString(), mimetype, ResponseFormat.JSON) : client.annotateDocumentFromUrlAsStream(new Uri(url), mimetype, ResponseFormat.JSON); FileStream outStream = new FileStream(outFile, FileMode.Create); resultData.CopyTo(outStream); outStream.Close(); resultData.Close(); } catch (IOException ioe) { Console.WriteLine(ioe.Message); Environment.Exit(1); } }
public UI(ServiceCatalog service) { this.service = service; cmds = new UiCommands(service); setCommands(); }