public bool IncCounter(string ShortName = "", string counter = "DL", string Customer = "known") { if (string.IsNullOrEmpty(Customer)) { Customer = "known"; } return(RZRestAPIv2.IncCounter(ShortName, counter, Customer)); }
private JArray getCatalog(string url, string Customer = "") { try { return(RZRestAPIv2.GetCatalog(Customer, wwwpath)); } catch { } return(new JArray()); }
//Upload SW and wait for approval public bool UploadSoftwareWaiting(JArray Software) { try { string ProductName = Base.clean(Software[0]["ProductName"].ToString()).Trim(); string ProductVersion = Base.clean(Software[0]["ProductVersion"].ToString()).Trim(); string Manufacturer = Base.clean(Software[0]["Manufacturer"].ToString()).Trim(); string sIconId = DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.DayOfYear.ToString("D" + 3) + Convert.ToInt32(DateTime.Now.TimeOfDay.TotalMinutes).ToString(); int iIconID = int.Parse(sIconId); foreach (JObject jObj in Software) { try { if (jObj["SWId"] == null) { jObj.Add("SWId", iIconID); } else { jObj["SWId"] = iIconID; } //only used for V <= 1.6.2.x if (jObj["IconId"] == null) { jObj.Add("IconId", iIconID); } else { jObj["IconId"] = iIconID; } } catch { } } return(RZRestAPIv2.UploadSoftware(Software)); } catch { } return(false); }
public JArray GetSoftwares(string shortname) { JArray jResult = new JArray(); //Try to get value from Memory if (_cache.TryGetValue("sn-" + shortname.ToLower(), out jResult)) { return(jResult); } jResult = RZRestAPIv2.GetSoftwares(shortname); if (jResult.Count > 0) { var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(SlidingExpiration)); //cache hash for x Seconds _cache.Set("sn-" + shortname.ToLower(), jResult, cacheEntryOptions); return(jResult); } return(new JArray()); }
public JArray GetSoftwares(string name = "", string ver = "", string man = "_unknown") { JArray jResult = new JArray(); try { if (string.IsNullOrEmpty(man)) { man = "_unknown"; } //Try to get value from Memory if (_cache.TryGetValue("mnv-" + Base.clean(man).ToLower() + Base.clean(name).ToLower() + Base.clean(ver).ToLower(), out jResult)) { return(jResult); } jResult = RZRestAPIv2.GetSoftwares(name, ver, man); if (jResult.Count > 0) { UpdateURLs(ref jResult); //Update URL's before caching to cache the change... var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(SlidingExpiration)); //cache hash for x Seconds _cache.Set("mnv-" + Base.clean(man).ToLower() + Base.clean(name).ToLower() + Base.clean(ver).ToLower(), jResult, cacheEntryOptions); return(jResult); } } catch (Exception ex) { Console.WriteLine("ERROR: GetSoftwares - " + ex.Message); } return(new JArray()); }
public bool IncCounter(string ShortName = "", string counter = "DL", string Customer = "known") { return(RZRestAPIv2.IncCounter(ShortName, counter)); }
public async Task <Stream> GetIcon(Int32 iconid = 0, string iconhash = "") { string sico = iconhash; if (iconid > 0) { sico = iconid.ToString(); } //Stream bResult; byte[] bCache; //Try to get value from Memory if (_cache.TryGetValue("ico-" + sico, out bCache)) { var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(95)); //cache icon for other 90 Minutes _cache.Set("ico-" + sico, bCache, cacheEntryOptions); return(new MemoryStream(bCache)); } //Try to load Icon from Disk if (File.Exists(Path.Combine(Settings["icons"], sico + ".jpg"))) { bCache = File.ReadAllBytes(Path.Combine(Settings["icons"], sico + ".jpg")); var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(95)); //cache icon for other 90 Minutes _cache.Set("ico-" + sico, bCache, cacheEntryOptions); return(new MemoryStream(bCache)); } try { using (MemoryStream ms = new MemoryStream()) { Stream x = await RZRestAPIv2.GetIcon(iconid, iconhash); await x.CopyToAsync(ms); bCache = ms.ToArray(); } if (bCache.Length > 0) { var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(95)); //cache icon for 90 Minutes _cache.Set("ico-" + sico, bCache, cacheEntryOptions); try { File.WriteAllBytes(Path.Combine(Settings["icons"], sico + ".jpg"), bCache); } catch { } } return(new MemoryStream(bCache)); } catch { } return(null); }
public async Task <Stream> GetIcon(Int32 iconid = 0, string iconhash = "", string customerid = "", int size = 0) { string sico = iconhash; if (iconid > 0) { sico = iconid.ToString(); } //Stream bResult; byte[] bCache; //Try to get value from Memory if (_cache.TryGetValue("ico-" + size.ToString() + sico, out bCache)) { var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(95)); //cache icon for other 90 Minutes _cache.Set("ico-" + size.ToString() + sico, bCache, cacheEntryOptions); return(new MemoryStream(bCache)); } //Try to load Icon from Disk if (File.Exists(Path.Combine(Settings["icons"], sico + "_" + size.ToString() + ".jpg"))) { bCache = File.ReadAllBytes(Path.Combine(Settings["icons"], sico + "_" + size.ToString() + ".jpg")); var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(95)); //cache icon for other 90 Minutes _cache.Set("ico-" + size.ToString() + sico, bCache, cacheEntryOptions); return(new MemoryStream(bCache)); } try { using (MemoryStream ms = new MemoryStream()) { Stream x = await RZRestAPIv2.GetIcon(iconid, iconhash, size); await x.CopyToAsync(ms); bCache = ms.ToArray(); if (size > 0) { using (Image image = Image.Load(bCache)) { image.Mutate(i => i.Resize(new ResizeOptions { Size = new Size(size, size) })); using (var imgs = new MemoryStream()) { var imageEncoder = image.GetConfiguration().ImageFormatsManager.FindEncoder(PngFormat.Instance); image.Save(imgs, imageEncoder); bCache = imgs.ToArray(); } } } } if (bCache.Length > 0) { var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(95)); //cache icon for 90 Minutes _cache.Set("ico-" + size.ToString() + sico, bCache, cacheEntryOptions); try { File.WriteAllBytes(Path.Combine(Settings["icons"], sico + "_" + size.ToString() + ".jpg"), bCache); } catch { } } return(new MemoryStream(bCache)); } catch { } return(null); }