using System.Collections.Generic; using System.Linq; using WX.CRM.BLL.Util; using WX.CRM.Common; using WX.CRM.Model.Entity; namespace WX.CRM.BLL.Res { public class RESMOBILE_BL { string clientid = Utility.GetSettingByKey("CRMClientKey"); WX.CRM.IBLL.Util.ISecurityHelper sHelper = new SecurityHelper(); public string GetNumberByResId(string resId) { using (var db = new SqlDbContext()) { RES_RESOURCEMOBILE entry = db.RES_RESOURCEMOBILE.FirstOrDefault(m => m.RESID == resId); if (entry == null) return ""; else return sHelper.decyptData(clientid, entry.MOBILE); } } public IDictionary GetNumberByResId(string[] resId) { using (var db = new SqlDbContext()) { var entrys = db.RES_RESOURCEMOBILE.Where(m => resId.Contains(m.RESID)); IDictionary rsts = new Dictionary(); if (entrys != null && entrys.Count() > 0) { foreach (var entry in entrys) { if (!rsts.ContainsKey(entry.RESID)) { rsts[entry.RESID] = sHelper.decyptData(clientid, entry.MOBILE); } } } return rsts; } } public MobileInfo GetNumberAndNameByResId(string resId) { using (var db = new SqlDbContext()) { var query = db.RES_RESOURCEMOBILE.AsQueryable(); var returnData = from a in query join b in db.RES_CUSTOMERDETAIL on a.RESID equals b.RESID into jiontemp from b in jiontemp.DefaultIfEmpty() where a.RESID == resId select new MobileInfo { Mobile = a.MOBILE, Name = b.CNAME }; var mobileInfo = returnData.FirstOrDefault(); if (mobileInfo != null) { mobileInfo.Mobile = sHelper.decyptData(clientid, mobileInfo.Mobile); return mobileInfo; } return null; } } } }