Exemplo n.º 1
0
        public static Clients GetClientDetail(string clientID)
        {
            DataTable dt = ClientDAL.BaseProvider.GetClientDetail(clientID);
            Clients model = new Clients();
            if (dt.Rows.Count==1)
            {
                DataRow row=dt.Rows[0];
                model.FillData(row);
                model.City = CommonBusiness.Citys.Where(c => c.CityCode == model.CityCode).FirstOrDefault();
                model.IndustryEntity =Manage.IndustryBusiness.GetIndustrys().Where(i => i.IndustryID.ToLower() == model.Industry.ToLower()).FirstOrDefault();
                model.Modules = ModulesBusiness.GetModulesByClientID(clientID);
            }

            return model;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取客户端列表
        /// </summary>
        /// <param name="keyWords"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public static List<Clients> GetClients(string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount)
        {
            DataTable dt = CommonBusiness.GetPagerData("Clients", "*", "Status<>9", "AutoID", pageSize, pageIndex, out totalCount, out pageCount);
            List<Clients> list = new List<Clients>();
            Clients model;
            foreach (DataRow item in dt.Rows)
            {
                model = new Clients();
                model.FillData(item);
                model.City = CommonCache.Citys.Where(c => c.CityCode == model.CityCode).FirstOrDefault();
                model.IndustryEntity = IndustryBusiness.GetIndustryByClientID(AppSettings.Settings[AppSettingsWEB.Manage, "ClientID"]).Where(i => i.IndustryID.ToLower() == model.Industry.ToLower()).FirstOrDefault();
                list.Add(model);
            }

            return list;
        }
Exemplo n.º 3
0
 /// <summary>
 /// 添加客户端
 /// </summary>
 /// <param name="model">Clients 对象</param>
 /// <param name="loginName">账号</param>
 /// <param name="loginPwd">密码</param>
 /// <param name="userid">操作人</param>
 /// <param name="result">0:失败 1:成功 2:账号已存在 3:模块未选择</param>
 /// <returns></returns>
 public static string InsertClient(Clients model, string loginName, string loginPwd, string userid, out int result)
 {
     string modules = "";
     foreach (var item in model.Modules)
     {
         modules += item.ModulesID + ",";
     }
     if (modules == "")
     {
         result = 3;
         return "";
     }
     loginPwd = CloudSalesTool.Encrypt.GetEncryptPwd(loginPwd, loginName);
     modules = modules.Substring(0, modules.Length - 1);
     string clientid = ClientDAL.BaseProvider.InsertClient(model.CompanyName, model.ContactName, model.MobilePhone, model.Industry, model.CityCode,
                                                      model.Address, model.Description, loginName, loginPwd, modules, userid, out result);
     return clientid;
 }
Exemplo n.º 4
0
        //明道登录回掉
        public ActionResult MDCallBack(string code)
        {
            string operateip = string.IsNullOrEmpty(Request.Headers.Get("X-Real-IP")) ? Request.UserHostAddress : Request.Headers["X-Real-IP"];
            var user = OauthBusiness.GetMDUser(code);
            if (user.error_code <= 0)
            {
                var model = OrganizationBusiness.GetUserByMDUserID(user.user.id, user.user.project.id, operateip);
                //已注册云销账户
                if (model != null)
                {
                    //未注销
                    if (model.Status.Value != 9)
                    {
                        model.MDToken = user.user.token;
                        if (string.IsNullOrEmpty(model.Avatar)) model.Avatar = user.user.avatar;

                        Session["ClientManager"] = model;
                        return Redirect("/Home/Index");
                    }
                }
                else
                {
                    int error = 0;
                    bool isAdmin = MD.SDK.Entity.App.AppBusiness.IsAppAdmin(user.user.token, user.user.id, out error);
                    if (isAdmin)
                    {
                        bool bl = AgentsBusiness.IsExistsMDProject(user.user.project.id);
                        //明道网络未注册
                        if (!bl)
                        {
                            int result = 0;
                            Clients clientModel = new Clients();
                            clientModel.CompanyName = user.user.project.name;
                            clientModel.ContactName = user.user.name;
                            clientModel.MobilePhone = user.user.mobile_phone;
                            var clientid = ClientBusiness.InsertClient(clientModel, "", "", "", out result, user.user.email, user.user.id, user.user.project.id);
                            if (!string.IsNullOrEmpty(clientid))
                            {
                                var current = OrganizationBusiness.GetUserByMDUserID(user.user.id, user.user.project.id, operateip);

                                current.MDToken = user.user.token;
                                if (string.IsNullOrEmpty(current.Avatar)) current.Avatar = user.user.avatar;
                                Session["ClientManager"] = current;

                                return Redirect("/Home/Index");
                            }

                        }
                        else
                        {
                            int result = 0;
                            var current = OrganizationBusiness.CreateUser("", "", user.user.name, user.user.mobile_phone, user.user.email, "", "", "", "", "", "", "", "", user.user.id, user.user.project.id, 1, "", out result);
                            if (current != null)
                            {
                                current.MDToken = user.user.token;
                                if (string.IsNullOrEmpty(current.Avatar)) current.Avatar = user.user.avatar;

                                Session["ClientManager"] = current;

                                return Redirect("/Home/Index");
                            }
                        }
                    }
                    else
                    {
                        return Redirect("/Home/InfoPage");
                    }
                }
            }
            return Redirect("/Home/Login");
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取客户端列表
        /// </summary>
        /// <param name="keyWords"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public static List<Clients> GetClients(string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount)
        {
            string whereSql = "Status<>9";
            if (!string.IsNullOrEmpty(keyWords))
                whereSql += " and ( CompanyName like '%" + keyWords + "%'  or  MobilePhone like '%" + keyWords + "%')";
            DataTable dt = CommonBusiness.GetPagerData("Clients", "*", whereSql, "AutoID", pageSize, pageIndex, out totalCount, out pageCount);
            List<Clients> list = new List<Clients>();
            Clients model;
            foreach (DataRow item in dt.Rows)
            {
                model = new Clients();
                model.FillData(item);
                model.City = CommonBusiness.Citys.Where(c => c.CityCode == model.CityCode).FirstOrDefault();
                model.IndustryEntity =Manage.IndustryBusiness.GetIndustrys().Where(i => i.IndustryID.ToLower() == model.Industry.ToLower()).FirstOrDefault();
                list.Add(model);
            }

            return list;
        }
Exemplo n.º 6
0
 public static bool UpdateClient(Clients model, string userid, out int result)
 {
     result = 1;
     return ClientDAL.BaseProvider.UpdateClient(model.ClientID, model.CompanyName
         , model.ContactName, model.MobilePhone, model.Industry
         , model.CityCode, model.Address, model.Description
         , userid);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 添加客户端
 /// </summary>
 /// <param name="model">Clients 对象</param>
 /// <param name="loginName">账号</param>
 /// <param name="loginPwd">密码</param>
 /// <param name="userid">操作人</param>
 /// <param name="result">0:失败 1:成功 2:账号已存在 3:模块未选择</param>
 /// <returns></returns>
 public static string InsertClient(Clients model, string loginName, string loginPwd, string userid, out int result, string email = "", string mduserid = "", string mdprojectid = "")
 {
     loginPwd = CloudSalesTool.Encrypt.GetEncryptPwd(loginPwd);
     string clientid = ClientDAL.BaseProvider.InsertClient(model.CompanyName, model.ContactName, model.MobilePhone, model.Industry, model.CityCode,
                                                      model.Address, model.Description, loginName, loginPwd, email, mduserid, mdprojectid, userid, out result);
     return clientid;
 }