Beispiel #1
0
    /// <summary>
    /// 获取推送用户的别名
    /// </summary>
    /// <param name="order"></param>
    /// <param name="userType">0:推送给经销商 1:推送给企业</param>
    /// <returns></returns>
    public string[] GetUserAlias(Hi.Model.DIS_Order order, string userType)
    {
        List <Hi.Model.SYS_CompUser> userList = new List <Hi.Model.SYS_CompUser>();

        switch (userType.Trim())
        {
        case "0":
            userList = new Hi.BLL.SYS_CompUser().GetList("",
                                                         " compID='" + order.CompID + "' and IsAudit = 2 and disID='" + order.DisID + "' and dr=0 and IsEnabled=1 and (Utype=1 or Utype =5)", "");
            break;

        case "1":
            userList = new Hi.BLL.SYS_CompUser().GetList("",
                                                         " compID='" + order.CompID + "' and IsAudit = 2 and dr=0 and IsEnabled=1 and Utype between 3 and 4", "");
            break;

        case "2":
            userList = new Hi.BLL.SYS_CompUser().GetList("", " dr=0 and IsAudit = 2 and IsEnabled=1 and Utype in (1,3,4,5)", "");
            break;

        default:
            return(null);
        }

        if (userList == null || userList.Count == 0)
        {
            return(null);
        }

        string[] arr = new String[userList.Count];
        for (int i = 0; i < userList.Count; i++)
        {
            arr[i] = AESHelper.Encrypt_MD5(userList[i].ID.ToString());
        }
        return(arr);
    }
Beispiel #2
0
    public ResultLogin Login(string JSon, string version)
    {
        try
        {
            #region JSon取值

            string LoginName = string.Empty;
            string PassWord  = string.Empty;
            List <Hi.Model.SYS_Users> userList = null;
            Hi.BLL.SYS_Users          bll_user = new Hi.BLL.SYS_Users();
            int phone = 0;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["LoginName"].ToString() != "" && JInfo["PassWord"].ToString() != "")
            {
                LoginName = JInfo["LoginName"].ToString();

                PassWord = JInfo["PassWord"].ToString();
            }
            else
            {
                return(new ResultLogin()
                {
                    Result = "F", Description = "参数为空异常"
                });
            }

            #endregion
            //if (int.TryParse(LoginName, out phone))//如果登录账号输入的是整数,先判断是否手机号登录,没对应的手机号,再判断账号登录
            //{
            //    userList = bll_user.GetList("",
            //        "Phone = " + LoginName + " and AuditState =2 and dr=0 and isnull(IsEnabled,0) =1", "");
            //}
            if (version.ToLower() != "android" && version.ToLower() != "ios" && float.Parse(version) >= 8)
            {
                PassWord = AESHelper.Encrypt_MD5(PassWord);
            }
            double phone_double = 0;
            if (double.TryParse(LoginName, out phone_double))//如果登录账号输入的是整数,先判断是否手机号登录,没对应的手机号,再判断账号登录
            {
                userList = bll_user.GetList("",
                                            "Phone = '" + LoginName + "' and AuditState =2 and dr=0 and isnull(IsEnabled,0) =1", "");
            }
            if (userList == null || userList.Count <= 0)
            {
                userList = new Hi.BLL.SYS_Users().GetList("",
                                                          " UserName='******' and AuditState =2 and dr=0 and isnull(IsEnabled,0) =1", "");
                if (userList == null || userList.Count == 0)
                {
                    return new ResultLogin()
                           {
                               Result = "F", Description = "账号密码错误"
                           }
                }
                ;
            }
            //if (userList == null || userList.Count == 0)
            //    return new ResultLogin() { Result = "F", Description = "账号密码错误" };


            List <User> UserList = new List <User>();
            foreach (var user in userList)
            {
                if (user.UserPwd != PassWord)
                {
                    return new ResultLogin()
                           {
                               Result = "F", Description = "账号密码错误"
                           }
                }
                ;

                List <Hi.Model.SYS_CompUser> compUserList = new Hi.BLL.SYS_CompUser().GetList("",
                                                                                              "UserID='" + user.ID + "' and IsAudit=2 and IsNull(dr,0)=0  and isnull(IsEnabled,0) = 1", "");
                if (compUserList != null && compUserList.Count > 0)
                {
                    foreach (var compUser in compUserList)
                    {
                        User resultUser = new User();

                        resultUser.UserID = compUser.UserID;
                        resultUser.CompID = compUser.CompID;

                        resultUser.TrueName  = user.TrueName;
                        resultUser.Sex       = user.Sex;
                        resultUser.Phone     = user.Phone;
                        resultUser.IsEnabled = user.IsEnabled; //列表无判断,前台要使用此状态

                        Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(compUser.CompID);
                        if (comp != null)
                        {
                            resultUser.Erptype = comp.Erptype;

                            resultUser.CompName = comp.CompName;
                        }
                        else
                        {
                            // return new ResultLogin() { Result = "F", Description = "核心企业异常" };
                        }

                        resultUser.UType      = compUser.UType;
                        resultUser.CType      = compUser.CType; // 1:核心企业  2:经销商
                        resultUser.CompUserID = compUser.ID;
                        if (compUser.CType == 2)
                        {
                            resultUser.DisID = compUser.DisID;
                            Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(compUser.DisID);
                            if (dis == null)
                            {
                                return new ResultLogin()
                                       {
                                           Result = "F", Description = "经销商异常"
                                       }
                            }
                            ;
                            if (dis.IsEnabled == 0 || dis.dr == 1)
                            {
                                continue;
                            }

                            resultUser.DisName = dis.DisName;
                        }

                        UserList.Add(resultUser);
                    }
                }
                else
                {
                    return(new ResultLogin()
                    {
                        Result = "F", Description = "未找到登录信息"
                    });
                }
            }
            return(new ResultLogin()
            {
                Result = "T",
                Description = "登录成功",
                UserList = UserList
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "Login:"******"F", Description = "参数异常"
            });
        }
    }
Beispiel #3
0
    /// <summary>
    /// 获取推送用户,返回推送类
    /// </summary>
    /// <param name="userType">0 (当前用户类型是企业,即推送至经销商) 1 (当前用户类型是经销商,即推送至企业) 2 全部 </param>
    /// <param name="sendType">类型同微信推送</param>
    /// <returns></returns>
    public PushPayload GetMsgUserModel(string orderID, string type)
    {
        Hi.Model.BD_CompNews order = new Hi.BLL.BD_CompNews().GetModel(int.Parse(orderID));
        if (order == null)
        {
            return(null);
        }

        //推送设置
        PushPayload payload = new PushPayload();

        payload.platform = Platform.android_ios();//推送平台

        //推送用户,0:推送给经销商 1:推送给企业
        //payload.audience = Audience.all();
        List <Hi.Model.SYS_CompUser> userList = new Hi.BLL.SYS_CompUser().GetList("",
                                                                                  " compID='" + order.CompID + "' and IsAudit = 2 and disID!=0 and dr=0 and IsEnabled=1 and (Utype=1 or Utype =5)", "");

        if (userList == null || userList.Count == 0)
        {
            return(null);
        }
        string[] arr = new String[userList.Count];
        for (int i = 0; i < userList.Count; i++)
        {
            //arr[i] = AESHelper.Encrypt_android(userList[i].ID.ToString());
            //arr[i] = AESHelper.Encrypt_android_old(userList[i].ID.ToString());
            arr[i] = AESHelper.Encrypt_MD5(userList[i].ID.ToString());//MD5加密
        }
        payload.audience = Audience.s_alias(arr);
        //payload.audience = Audience.s_alias(AESHelper.Encrypt_android("1304"));

        //推送通知
        string str = "{\"Type\":\"" + (type == "" || type == "-1" ? "-1" : order.NewsType.ToString()) +
                     "\",\"Title\":\"" + order.NewsTitle +
                     "\",\"ID\":\"" + order.ID.ToString() + "\",\"Date\":\"" + DateTime.Now.ToString("yyyy-MM-dd") + "\"}";

        // SendType 0:推送给经销商 1:推送给企业
        string sendStr = "{\"SendType\":\"0\",\"CompID\":\"" + order.CompID + "\"}";

        //AndroidNotification android = new AndroidNotification();
        //android.setAlert(GetAlertContent(order, sendType));//推送内容
        //payload.notification = new Notification().setAndroid(android);//推送内容
        payload.notification = new Notification().setAlert("您有一条新的信息公告!")
                               .setAndroid(new AndroidNotification()//设置Android的notification
                                           .AddExtra("Type", "2")
                                           .AddExtra("CheckUser", AESHelper.Encrypt_android(sendStr))
                                           .AddExtra("Json", AESHelper.Encrypt_android(str)))
                               .setIos(new IosNotification()              //设置IOS的notification
                                       .setAlert("您有一条新的信息公告")
                                       .autoBadge()
                                       .AddExtra("Type", "2")
                                       .AddExtra("CheckUser", AESHelper.Encrypt_android(sendStr))
                                       .AddExtra("Json", AESHelper.Encrypt_android(str)));

        //推送消息
        payload.message = Message.content("您有一条新的短消息!")
                          .AddExtras("Type", "2")
                          .AddExtras("CheckUser", AESHelper.Encrypt_android(sendStr))
                          .AddExtras("Json", AESHelper.Encrypt_android(str));
        Options op = new Options();

        op.apns_production = false;
        payload.options    = op;

        return(payload);
    }
Beispiel #4
0
 public string Maker_MD5(string JSon)
 {
     return(AESHelper.Encrypt_MD5(JSon));
 }