/// <summary> /// Maps the given <see cref="IdeaPlugin"/> to a <see cref="Plugin"/>. /// </summary> /// <param name="this">The IdeaPlugin.</param> /// <param name="dbCategory">The plugin category.</param> /// <returns>The mapped plugin.</returns> public static Plugin ToEntity ( this IdeaPlugin @this, PluginCategory dbCategory ) { DateTime ParseDateFromMilliseconds(string value) { var millis = long.Parse(value); return(DateTimeOffset.FromUnixTimeMilliseconds(millis).UtcDateTime); } var result = new Plugin ( @this.Name, dbCategory, @this.ID, @this.Description, @this.Vendor.ToEntity() ); result.Tags = @this.Tags?.Split(';').ToList() ?? new List <string>(); result.Rating = @this.Rating; result.ProjectURL = @this.ProjectURL ?? string.Empty; result.UpdatedAt = ParseDateFromMilliseconds ( @this.UpdateDate ?? @this.UploadDate ?? throw new InvalidOperationException() ); return(result); }
public static Dictionary <String, BukgetPlugin> GetPluginsByCategory(string category, int amount) { PluginCategory cat = (PluginCategory)Enum.Parse(typeof(PluginCategory), category.Replace(" ", "_").Replace("-", "__")); string url = BukgetUrlBuilder.ConstructUrl(cat, BukgetUrlBuilder.FieldsSimple, amount); return(RetrieveParseStore(url)); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <param name="field">the fields to retrieve</param> /// <param name="sortField">the PluginInfoField to sort the results</param> /// <param name="negateSort">should the results list be reversed?</param> /// <param name="limit">the maximum amount or results</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl( PluginCategory pluginCategory, PluginInfoField[] field, PluginInfoField sortField, Boolean negateSort, int limit) { return(ConstructUrl(pluginCategory, field, limit) + GetSortUrlValue(sortField, negateSort)); }
/// <summary> /// Gets all the plugins available on at least 1 node. /// Multiple nodes having the same plugins won't generate duplicate entries here. /// </summary> public List <Plugin> GetDistinctAvailable(PluginCategory pluginType) { SqlExpressionVisitor <Plugin> ev = OrmLiteConfig.DialectProvider.ExpressionVisitor <Plugin>(); ev.Where(p => p.Category == pluginType); ev.SelectDistinct(pl => pl.Name); using (dbc = DAL.Instance.GetDb()){ return(dbc.Select(ev)); //return (from Plugin p in dbc.Select(ev) select p.Name).ToList(); } }
public List <Plugin> RequestResourceList(out bool fullyLoaded, PluginCategory category, int page = 1, PluginEnums.Sorting sort = PluginEnums.Sorting.RATING) { string url = BuildResourceCategoryURL(pageSize * 2, category, page, sort); string json = ResponseCache.Instance.UncacheResponse(url); if (json == null) { try { Uri uri = new Uri(url); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.UserAgent = ApplicationManager.UserAgent; using (var response = request.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { json = reader.ReadToEnd(); } ResponseCache.Instance.CacheResponse(url, json); } catch (WebException e) { ErrorLogger.Append(e); Console.WriteLine("Could not receive Spigot Plugins. (either spiget.org is down or your Internet connection is not working)\nRequest URL: " + url); fullyLoaded = true; return(new List <Plugin>()); } } var plugins = JsonConvert.DeserializeObject <List <Plugin> >(json); List <Plugin> toRemove = new List <Plugin>(); foreach (Plugin plugin in plugins) { if (plugin.premium) { toRemove.Add(plugin); continue; } plugin.author = RequestAuthor(plugin.author.id); plugin.category = RequestCategory(plugin.category.id); } foreach (Plugin plugin in toRemove) { plugins.Remove(plugin); } fullyLoaded = plugins.Count < pageSize * 2; return(plugins); }
private string BuildResourceCategoryURL(int pageSize, PluginCategory category, int page = 1, PluginEnums.Sorting sort = PluginEnums.Sorting.RATING) { string URL = baseURL + "categories/" + category.id + "/resources"; URL += "?size=" + pageSize; if (page != 1) { URL += "&page=" + page; } URL += "&sort=" + WebUtility.HtmlEncode(sort.APIName()); URL += "&fields=" + resourceFields; return(URL); }
private void btnShow_MouseClick(object sender, MouseEventArgs e) { if (this.ctCategory.SelectedNode == null) { return; } this.nodeViewItemTree1.NodeViewItems.Clear(); int iNum = 0; if (this.ctCategory.SelectedNode.Name == "CategoryIndex") { foreach (PluginCategory one in this.m_PluginCategoryDictionary) { GISShare.Controls.WinForm.WFNew.View.NodeViewItem nodeViewItem = new Controls.WinForm.WFNew.View.NodeViewItem ( one.CategoryIndex.ToString(), "目录索引(CategoryIndex):" + one.CategoryIndex + ";成员数(Count):" + one.PluginCollection.Count.ToString() ); foreach (IPlugin one2 in one.PluginCollection) { IPluginInfo pPluginInfo = one2 as IPluginInfo; if (pPluginInfo == null) { nodeViewItem.NodeViewItems.Add ( new Controls.WinForm.WFNew.View.NodeViewItem(one2.Name, "目录索引(CategoryIndex):" + one2.CategoryIndex + ";名称(Name):" + one2.Name) ); } else { nodeViewItem.NodeViewItems.Add ( new Controls.WinForm.WFNew.View.NodeViewItem(one2.Name, "目录索引(CategoryIndex):" + one2.CategoryIndex + ";描述(Describe):" + pPluginInfo.GetDescribe() + ";名称(Name):" + one2.Name) ); } iNum++; } this.nodeViewItemTree1.NodeViewItems.Add(nodeViewItem); } } else { int iIndex; if (int.TryParse(this.ctCategory.SelectedNode.Name, out iIndex)) { PluginCategory pluginCategory = this.m_PluginCategoryDictionary.GetPluginCategory(iIndex); if (pluginCategory != null) { GISShare.Controls.WinForm.WFNew.View.NodeViewItem nodeViewItem = new Controls.WinForm.WFNew.View.NodeViewItem ( pluginCategory.CategoryIndex.ToString(), "目录索引(CategoryIndex):" + pluginCategory.CategoryIndex + ";成员数(Count):" + pluginCategory.PluginCollection.Count.ToString() ); nodeViewItem.IsExpanded = true; foreach (IPlugin one in pluginCategory.PluginCollection) { IPluginInfo pPluginInfo = one as IPluginInfo; if (pPluginInfo == null) { nodeViewItem.NodeViewItems.Add ( new Controls.WinForm.WFNew.View.NodeViewItem(one.Name, "目录索引(CategoryIndex):" + one.CategoryIndex + ";名称(Name):" + one.Name) ); } else { nodeViewItem.NodeViewItems.Add ( new Controls.WinForm.WFNew.View.NodeViewItem(one.Name, "目录索引(CategoryIndex):" + one.CategoryIndex + ";描述(Describe):" + pPluginInfo.GetDescribe() + ";名称(Name):" + one.Name) ); } iNum++; } this.nodeViewItemTree1.NodeViewItems.Add(nodeViewItem); } } } this.lblNum.Text = "当前插件:" + iNum.ToString(); this.lblNum.Refresh(); }
public List <Plugin> GetPlugins(PluginCategory category) { return(new DAL.PluginDAO(sessionUser).GetDistinctAvailable(category)); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <param name="field">the fields to retrieve</param> /// <param name="sortField">the PluginInfoField to sort the results</param> /// <param name="negateSort">should the results list be reversed?</param> /// <param name="limit">the maximum amount or results</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl( PluginCategory pluginCategory, PluginInfoField[] field, PluginInfoField sortField, Boolean negateSort, int limit) { return ConstructUrl(pluginCategory, field, limit) + GetSortUrlValue(sortField, negateSort); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <param name="field">the fields to retrieve</param> /// <param name="limit">the maximum amount or results</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl(PluginCategory pluginCategory, PluginInfoField[] field, int limit) { return ConstructUrl(pluginCategory, field) + GetLimitUrlValue(limit); }
private static string GetCategoryUrlValue(PluginCategory pluginCategory) { return(pluginCategory.ToString().Replace("__", "-").Replace('_', ' ')); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <param name="field">the fields to retrieve</param> /// <param name="sortField">the PluginInfoField to sort the results</param> /// <param name="limit">the maximum amount or results</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl(PluginCategory pluginCategory, PluginInfoField[] field, PluginInfoField sortField, int limit) { return(ConstructUrl(pluginCategory, field, sortField, false, limit)); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <param name="field">the fields to retrieve</param> /// <param name="limit">the maximum amount or results</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl(PluginCategory pluginCategory, PluginInfoField[] field, int limit) { return(ConstructUrl(pluginCategory, field) + GetLimitUrlValue(limit)); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <param name="field">the fields to retrieve</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl(PluginCategory pluginCategory, PluginInfoField[] field) { return(ConstructUrl(pluginCategory) + GetFieldArrayUrlValue(field)); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl(PluginCategory pluginCategory) { return(ConstructBaseUrl() + "/categories/" + GetCategoryUrlValue(pluginCategory)); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl(PluginCategory pluginCategory) { return ConstructBaseUrl() + "/categories/" + GetCategoryUrlValue(pluginCategory); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <param name="field">the fields to retrieve</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl(PluginCategory pluginCategory, PluginInfoField[] field) { return ConstructUrl(pluginCategory) + GetFieldArrayUrlValue(field); }
public static Dictionary <String, BukgetPlugin> GetPluginsByCategory(PluginCategory category, int amount) { string url = BukgetUrlBuilder.ConstructUrl(category, BukgetUrlBuilder.FieldsSimple, amount); return(RetrieveParseStore(url)); }
/// <summary> /// Construct the url to make an API call get a list of plugins in the requested category /// </summary> /// <param name="pluginCategory">The category to list</param> /// <param name="field">the fields to retrieve</param> /// <param name="sortField">the PluginInfoField to sort the results</param> /// <param name="limit">the maximum amount or results</param> /// <returns>The URL to make the api call to, as a string</returns> public static string ConstructUrl(PluginCategory pluginCategory, PluginInfoField[] field, PluginInfoField sortField, int limit) { return ConstructUrl(pluginCategory, field, sortField, false, limit); }
public static Dictionary<String, BukgetPlugin> GetPluginsByCategory(PluginCategory category, int amount = DEFAULT_COUNT) { string url = BukgetUrlBuilder.ConstructUrl(category, BukgetUrlBuilder.FieldsSimple, amount); return RetrieveParseStore(url); }
private static string GetCategoryUrlValue(PluginCategory pluginCategory) { return pluginCategory.ToString().Replace("__", "-").Replace('_', ' '); }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="interpreter">The interpreter which has loaded the current plugin instance.</param> protected AbstractInterpreterPlugin(Interpreter interpreter, PluginCategory category) { Interpreter = interpreter; PluginCategory = category; }