TG.WXCRM.V4/WebHelper/DoItems/QiWeForbidMessage.cs

98 lines
3.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Ninject;
using System;
using System.Collections.Generic;
using System.Linq;
using WX.CRM.BLL.Ww;
using WX.CRM.Common;
using WX.CRM.IBLL.Ww;
using WX.CRM.Model.crmModel;
using WX.CRM.WebHelper.UtilityModel;
namespace WX.CRM.WebHelper.DoItems
{
/// <summary>
/// 企微暂停提醒
/// </summary>
public sealed class QiWeForbidMessage : IPopupMessage
{
private IWw_huser _WxuserService;
#region
private static volatile QiWeForbidMessage instance = null;
private QiWeForbidMessage()
{
_WxuserService = Infrastructure.NinjectControllerFactory.ninjectKernel.Get<IWw_huser>();
}
// Lock对象线程安全所用
private static object locked = new Object();
public static QiWeForbidMessage Instance
{
get
{
if (instance == null)
{
lock (locked)
{
if (instance == null)
instance = new QiWeForbidMessage();
}
}
return instance;
}
}
#endregion
#region
//private Boolean NeedRefresh = true;
//private DateTime LastLoadTime = DateTime.Now;
private Dictionary<decimal, int> UserRes = new Dictionary<decimal, int>();
/// <summary>
/// 获取数据锁
/// </summary>
private void LoadResource(decimal UserId)
{
UserRes.Clear();
var lists = _WxuserService.GetWxStatusNotice(4);
UserFilter.AddRange(lists.Select(n => n.UserId).ToList());
var groupList = lists.GroupBy(n => n.InnerUserId).Select(n => new { n.Key, count = n.Count() });
foreach(var user in groupList)
{
if (!UserRes.ContainsKey(user.Key))
{
UserRes.Add(user.Key, user.count);
}
else
{
UserRes[user.Key] = user.count;
}
}
}
#endregion
public string GetUrl()
{
if (UserFilter.Count > 0)
{
UserFilter = UserFilter.Distinct().ToList();
var filter = string.Join(";", UserFilter);
return @"../Ww/MyWork/index?isExe=0&&assignStatus=4&&filteruserId=" + filter;// 高级分配资源提醒
}
return @"../Ww/MyWork/index?isExe=0&&assignStatus=4";// 高级分配资源提醒
}
private List<string> UserFilter = new List<string>();
public void SetView(decimal UserId, string pkid)
{
if (!UserRes.ContainsKey(UserId))
return;
}
public string GetMessage(decimal UserId)
{
LoadResource(UserId);
if (!UserRes.ContainsKey(UserId))
return string.Empty;
var ResInfo = UserRes[UserId];
return string.Format("{0}", ResInfo);
}
}
}