107 lines
3.3 KiB
C#
107 lines
3.3 KiB
C#
using Ninject;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.IBLL.Res;
|
||
using WX.CRM.WebHelper.UtilityModel;
|
||
|
||
namespace WX.CRM.WebHelper.DoItems
|
||
{
|
||
/// <summary>
|
||
/// 高级分配资源提醒
|
||
/// </summary>
|
||
public sealed class MySeniorResMessage : IPopupMessage
|
||
{
|
||
private IRES_MYALLOCATERES _allocateRes;
|
||
#region 单例
|
||
private static volatile MySeniorResMessage instance = null;
|
||
private MySeniorResMessage()
|
||
{
|
||
_allocateRes = Infrastructure.NinjectControllerFactory.ninjectKernel.Get<IRES_MYALLOCATERES>();
|
||
}
|
||
// Lock对象,线程安全所用
|
||
private static object locked = new Object();
|
||
public static MySeniorResMessage Instance
|
||
{
|
||
get
|
||
{
|
||
if (instance == null)
|
||
{
|
||
lock (locked)
|
||
{
|
||
if (instance == null)
|
||
instance = new MySeniorResMessage();
|
||
}
|
||
}
|
||
return instance;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 私有数据
|
||
//private Boolean NeedRefresh = true;
|
||
//private DateTime LastLoadTime = DateTime.Now;
|
||
private Dictionary<decimal, UserResourceCount> UserRes = new Dictionary<decimal, UserResourceCount>();
|
||
private void LoadResource(decimal UserId)
|
||
{
|
||
|
||
UserRes.Clear();
|
||
var lists = _allocateRes.GetSeniorNotice();
|
||
|
||
var queryList = from a in lists group a by a.InnerUserId into g select new { g.Key, time = g.Max(p => p.Ctime) };
|
||
|
||
var tipUser = new List<decimal>();
|
||
foreach (var item in queryList)
|
||
{
|
||
tipUser.Add(item.Key);
|
||
}
|
||
|
||
lists = lists.Where(p => tipUser.Contains(p.InnerUserId)).ToList();
|
||
|
||
foreach (var list in lists)
|
||
{
|
||
UserResourceCount resinfo = null;
|
||
if (!UserRes.ContainsKey(list.InnerUserId))
|
||
{
|
||
resinfo = new UserResourceCount
|
||
{
|
||
SalesId = list.InnerUserId
|
||
};
|
||
UserRes.Add(list.InnerUserId, resinfo);
|
||
}
|
||
else
|
||
{
|
||
resinfo = UserRes[list.InnerUserId];
|
||
}
|
||
resinfo.Add(list.ResId.ToString());
|
||
}
|
||
}
|
||
#endregion
|
||
public string GetUrl()
|
||
{
|
||
return @"../Res/Allocate/SeniorDistribution?isExe=0";// 高级分配资源提醒
|
||
}
|
||
public void SetView(decimal UserId, string pkid)
|
||
{
|
||
if (!UserRes.ContainsKey(UserId))
|
||
return;
|
||
var ResInfo = UserRes[UserId];
|
||
if (ResInfo == null)
|
||
return;
|
||
ResInfo.Remove(pkid);
|
||
}
|
||
|
||
public string GetMessage(decimal UserId)
|
||
{
|
||
LoadResource(UserId);
|
||
if (!UserRes.ContainsKey(UserId))
|
||
return string.Empty;
|
||
var ResInfo = UserRes[UserId];
|
||
if (ResInfo == null || ResInfo.Count == 0)
|
||
return string.Empty;
|
||
return string.Format("{0}", ResInfo.Count);
|
||
}
|
||
}
|
||
}
|