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)
|
public static object RAUNAME(string request)
|
||||||
{
|
{
|
||||||
if (MemoryCache.Default.Contains(request))
|
if (MemoryCache.Default.Contains(request))
|
||||||
return MemoryCache.Default[request].ToString();
|
{
|
||||||
|
IProduct product = MemoryCache.Default[request] as IProduct;
|
||||||
|
return product.Name;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object result = ExcelAsyncUtil.Run("Rauname", new[] { request },
|
object result = ExcelAsyncUtil.Run("Rauname", new[] { request },
|
||||||
delegate
|
delegate
|
||||||
{
|
{
|
||||||
Task<IProduct> product = Task.Run(() => SkuAssist.GetProduct(request));
|
Task<IProduct> p = Task.Run(() => SkuAssist.GetProduct(request));
|
||||||
return product.Result;
|
return p.Result;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Equals(result, ExcelError.ExcelErrorNA))
|
if (result == null)
|
||||||
{
|
|
||||||
return "Загрузка...";
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (result == null)
|
|
||||||
{
|
|
||||||
return "Не найдено";
|
return "Не найдено";
|
||||||
}
|
|
||||||
|
|
||||||
else
|
if (result.Equals(ExcelError.ExcelErrorNA))
|
||||||
{
|
return "Загрузка...";
|
||||||
MemoryCache.Default.Add(request, result, System.DateTime.Now.AddMinutes(10));
|
|
||||||
return result.ToString();
|
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
|
||||||
|
{
|
||||||
|
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