Add RauSku Function. Some refactoring.
This commit is contained in:
parent
2f7c5688dd
commit
c748be35c4
@ -10,32 +10,60 @@ namespace Rehau.Sku.Assist
|
||||
public static object RAUNAME(string request)
|
||||
{
|
||||
if (MemoryCache.Default.Contains(request))
|
||||
return MemoryCache.Default[request].ToString();
|
||||
{
|
||||
IProduct product = MemoryCache.Default[request] as IProduct;
|
||||
return product.Name;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
object result = ExcelAsyncUtil.Run("Rauname", new[] { request },
|
||||
delegate
|
||||
{
|
||||
Task<IProduct> product = Task.Run(() => SkuAssist.GetProduct(request));
|
||||
return product.Result;
|
||||
Task<IProduct> p = Task.Run(() => SkuAssist.GetProduct(request));
|
||||
return p.Result;
|
||||
});
|
||||
|
||||
if (Equals(result, ExcelError.ExcelErrorNA))
|
||||
{
|
||||
return "Загрузка...";
|
||||
}
|
||||
|
||||
else if (result == null)
|
||||
{
|
||||
if (result == null)
|
||||
return "Не найдено";
|
||||
|
||||
if (result.Equals(ExcelError.ExcelErrorNA))
|
||||
return "Загрузка...";
|
||||
|
||||
IProduct product = result as IProduct;
|
||||
MemoryCache.Default.Add(request, product, System.DateTime.Now.AddMinutes(10));
|
||||
//MemoryCache.Default.Add(product.Name, product, System.DateTime.Now.AddMinutes(10));
|
||||
return product.Name;
|
||||
}
|
||||
}
|
||||
|
||||
[ExcelFunction]
|
||||
public static object RAUSKU(string request)
|
||||
{
|
||||
if (MemoryCache.Default.Contains(request))
|
||||
{
|
||||
IProduct result = MemoryCache.Default[request] as IProduct;
|
||||
return result.Sku;
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryCache.Default.Add(request, result, System.DateTime.Now.AddMinutes(10));
|
||||
return result.ToString();
|
||||
}
|
||||
object result = ExcelAsyncUtil.Run("RauSku", new[] { request },
|
||||
delegate
|
||||
{
|
||||
Task<IProduct> p = Task.Run(() => SkuAssist.GetProduct(request));
|
||||
return p.Result;
|
||||
});
|
||||
|
||||
if (result == null)
|
||||
return "Не найдено";
|
||||
|
||||
if (result.Equals(ExcelError.ExcelErrorNA))
|
||||
return "Загрузка...";
|
||||
|
||||
IProduct product = result as IProduct;
|
||||
MemoryCache.Default.Add(request, product, System.DateTime.Now.AddMinutes(10));
|
||||
//MemoryCache.Default.Add(product.Sku, product, System.DateTime.Now.AddMinutes(10));
|
||||
return product.Sku;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user