Exemplo n.º 1
0
 public string Send(NotifierData msg, string userId)
 {
     DAL.EmpModels.EmpContext emp = new DAL.EmpModels.EmpContext();
     try
     {
         var u = emp.Users.FirstOrDefault(x => x.Id == userId);
         if (u.Email == null)
         {
             return(null);
         }
         if (u == null)
         {
             return(null);
         }
         if (msg.Msg.Body == null)
         {
             msg.Msg.Body = msg.Msg.Subject;
         }
         EmailHelper e = new EmailHelper(u.Email, msg.Msg.Subject, msg.Msg.Body);
         e.Send();
         return(userId);
         //}
     }
     catch (Exception ex)
     {
         MyConsole.log(ex, "邮件发送异常");
         //throw (ex);
     }
     return(null);
 }
Exemplo n.º 2
0
        public List <string> Send(NotifierData msg, List <string> userIds)
        {
            List <string> successes = new List <string>();

            DAL.EmpModels.EmpContext emp = new DAL.EmpModels.EmpContext();
            var users = emp.Users.Where(x => userIds.Contains(x.Id)).ToList();

            if (users.Count() == 0)
            {
                return(successes);
            }

            foreach (var u in users)
            {
                try
                {
                    EmailHelper e = new EmailHelper(u.Email, msg.Msg.Subject, msg.Msg.Body);
                    e.Send();
                    successes.Add(u.Id);
                }
                catch (Exception ex)
                {
                    MyConsole.log(ex, "邮件发送异常");
                }
            }
            return(successes);
        }
Exemplo n.º 3
0
        public List <string> Send(NotifierData msg, List <string> userIds)
        {
            DAL.EmpModels.EmpContext emp       = new DAL.EmpModels.EmpContext();
            List <string>            successes = new List <string>();

            ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", appkey, secret);
            var        users  = emp.Users.Where(x => userIds.Contains(x.Id)).ToList();

            if (users.Count() == 0)
            {
                return(successes);
            }

            foreach (var u in users)
            {
                try
                {
                    AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                    req.SmsType         = "normal";
                    req.SmsFreeSignName = msg.SignName;
                    req.SmsParam        = "{\"source\":\"\",\"reason\":\"" + msg.Msg.Subject + "\",\"alert\":\"\"}";
                    req.RecNum          = "" + u.PhoneNumber;
                    req.SmsTemplateCode = msg.TemplateCode;
                    AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                    successes.Add(u.Id);
                }
                catch (Exception ex)
                {
                    MyConsole.log(ex, "短信发送异常");
                }
            }
            return(successes);
        }
Exemplo n.º 4
0
        public string  Send(NotifierData msg, string userId)
        {
            DAL.EmpModels.EmpContext emp = new DAL.EmpModels.EmpContext();
            ITopClient client            = new DefaultTopClient("http://gw.api.taobao.com/router/rest", appkey, secret);

            try
            {
                var u = emp.Users.FirstOrDefault(x => x.Id == userId);
                if (u == null)
                {
                    return(null);
                }
                AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
                req.SmsType         = "normal";
                req.SmsFreeSignName = msg.SignName;
                req.SmsParam        = "{\"source\":\"\",\"reason\":\"" + msg.Msg.Subject + "\",\"alert\":\"\"}";
                req.RecNum          = "" + u.PhoneNumber;
                req.SmsTemplateCode = msg.TemplateCode;
                AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                return(rsp.Body);
            }
            catch (Exception ex)
            {
                MyConsole.log(ex, "短信发送异常");
            }
            return(null);
        }
Exemplo n.º 5
0
        public static void Init()
        {
            DAL.EmpModels.EmpContext db = new DAL.EmpModels.EmpContext();

            if (db.Roles.Count(o => o.Name == "缴费账户") == 0)
            {
                Role role = new Role();
                role.Name = "缴费账户";
                Guid guid = Guid.NewGuid();
                role.Id = guid.ToString();
                db.Roles.Add(role);
            }
            //if (db.Roles.Count(o => o.Name == "维修员") == 0)
            //{
            //    Role role = new Role();
            //    role.Name = "维修员";
            //    Guid guid = Guid.NewGuid();
            //    role.Id = guid.ToString();
            //    db.Roles.Add(role);
            //}
            //if (db.Roles.Count(o => o.Name == "维修管理员") == 0)
            //{
            //    Role role = new Role();
            //    role.Name = "维修管理员";
            //    Guid guid = Guid.NewGuid();
            //    role.Id = guid.ToString();
            //    db.Roles.Add(role);
            //}
            if (db.Roles.Count(o => o.Name == "能耗用户") == 0)
            {
                Role role = new Role();
                role.Name = "能耗用户";
                Guid guid = Guid.NewGuid();
                role.Id = guid.ToString();
                db.Roles.Add(role);
            }
            if (db.Roles.Count(o => o.Name == "收费员") == 0)
            {
                Role role = new Role();
                role.Name = "收费员";
                Guid guid = Guid.NewGuid();
                role.Id = "2";
                db.Roles.Add(role);
            }
            db.SaveChanges();
            var roles = db.Roles.ToList();

            PayMentRoleId = roles.FirstOrDefault(o => o.Name == "缴费账户").Id;
            PayMentRole   = roles.FirstOrDefault(o => o.Name == "缴费账户");
            //RepairerRoleId = roles.FirstOrDefault(o => o.Name == "维修员").Id;
            //RepairManagerRoleId = roles.FirstOrDefault(o => o.Name == "维修管理员").Id;
            AdminRoleId         = roles.FirstOrDefault(o => o.Name == "超级管理员").Id;
            PowerUserRoleId     = roles.FirstOrDefault(o => o.Name == "能耗用户").Id;
            TollCollectorRoleId = roles.FirstOrDefault(o => o.Name == "收费员").Id;
        }
Exemplo n.º 6
0
        public static Dictionary <int, Dictionary> Reset()
        {
            DAL.EmpModels.EmpContext db = new DAL.EmpModels.EmpContext();
            dictionaryCache = new Dictionary <int, Dictionary>();
            var dics = db.Dictionaries.Where(o => o.Enable == true).ToList();

            foreach (Dictionary m in dics)
            {
                dictionaryCache.Add(m.Id, m);
            }

            return(dictionaryCache);
        }
Exemplo n.º 7
0
        public string Send(NotifierData msg, string userId)
        {
            DAL.EmpModels.EmpContext emp = new DAL.EmpModels.EmpContext();
            JPushClient client           = new JPushClient(app_key, master_secret);
            PushPayload pushPayload      = new PushPayload();

            pushPayload.platform     = Platform.android();
            pushPayload.audience     = Audience.s_tag(userId);
            pushPayload.notification = Notification.android(msg.Msg.Body, msg.Msg.Subject);
            try
            {
                var result = client.SendPush(pushPayload);
                return(userId);
            }
            catch {
                return(null);
            }
            return(null);
        }
Exemplo n.º 8
0
        public List <string> Send(NotifierData msg, List <string> userIds)
        {
            DAL.EmpModels.EmpContext emp       = new DAL.EmpModels.EmpContext();
            List <string>            successes = new List <string>();
            JPushClient client = new JPushClient(app_key, master_secret);

            foreach (var userId in userIds)
            {
                PushPayload pushPayload = new PushPayload();
                pushPayload.platform     = Platform.android();
                pushPayload.audience     = Audience.s_tag(userId);
                pushPayload.notification = Notification.android(msg.Msg.Body, msg.Msg.Subject);
                try
                {
                    var result = client.SendPush(pushPayload);
                    successes.Add(userId);
                }
                catch
                {
                }
            }
            return(successes);
        }
Exemplo n.º 9
0
 public static Dictionary <int, Dictionary> Get()
 {
     DAL.EmpModels.EmpContext db = new DAL.EmpModels.EmpContext();
     if (dictionaryCache.Count() == 0)
     {
         var dics = db.Dictionaries.ToList();
         foreach (Dictionary m in dics)
         {
             dictionaryCache.Add(m.Id, m);
         }
     }
     //水电控设备
     if (ParameterUsedPower != null && !ParametersPower.Contains(ParameterUsedPower.Id))
     {
         ParametersPower.Add(ParameterUsedPower.Id);
     }
     if (ParametersAllBaseEnergy != null && ParametersAllBaseEnergy.Count() == 0)
     {
         ParametersAllBaseEnergy.AddRange(ParametersPower);
         ParametersAllBaseEnergy.AddRange(ParametersWater);
     }
     return(dictionaryCache);
 }