public List <Organization> ChildOrganization(long Id) { List <Organization> OrgLists = new List <Organization>(); Organization Orgs = (from item in context.Organization where item.Id == Id select item).FirstOrDefault(); IQueryable <Organization> Org = from item in context.Organization where item.ParentId == Orgs.UserId select item; foreach (Organization list in Org.ToList()) { UserMemberInfo userInfo = context.UserMemberInfo.FirstOrDefault((UserMemberInfo m) => m.Id == list.UserId); PurchaseRolesInfo roleInfo = context.PurchaseRolesInfo.FirstOrDefault((PurchaseRolesInfo m) => m.Id == list.RoleId); if (roleInfo != null) { PurchaseRolesInfo UserInfos = context.PurchaseRolesInfo.FirstOrDefault((PurchaseRolesInfo m) => m.Id == list.ParentRoleId); if (userInfo != null) { list.UserName = userInfo.UserName; list.RealName = userInfo.RealName; } if (UserInfos != null) { list.RoleName = roleInfo.RoleName; list.ParentRoleName = UserInfos.RoleName; } OrgLists.Add(list); } } return(OrgLists); }
public ActionResult Edit(long Id) { PurchaseRolesInfo roleInfo = ServiceHelper.Create <IPermissionGroupService>().GetPurchaseRole(Id); ViewBag.Id = Id; ViewBag.RoleName = roleInfo.RoleName; ViewBag.Limited = ServiceHelper.Create <IOrganizationService>().GetLimitedAmountByRoleId(Id); ViewBag.CoinDics = ServiceHelper.Create <IChemCloud_DictionariesService>().GetListByType(1); return(View()); }
public JsonResult AddPermissionGroup(string RoleName) { PurchaseRolesInfo roleInfo = ServiceHelper.Create <IPermissionGroupService>().AddPermissionGroup(base.CurrentUser.Id, RoleName); if (roleInfo != null) { return(Json(new { success = true, roleId = roleInfo.Id })); } else { return(Json(new { success = false })); } }
public JsonResult IsExitsAdmin(long Id) { PurchaseRolesInfo roleInfo = ServiceHelper.Create <IPermissionGroupService>().GetPurchaseRole(Id); if (roleInfo.RoleName == "管理员" || roleInfo.RoleName == "Admin") { return(Json(new { success = true, msg = "删除成功" })); } else { return(Json(new { success = false, msg = "删除失败" })); } }
public PurchaseRolesInfo AddPermissionGroup(long parentId, string rolename) { PurchaseRolesInfo roleInfos; using (TransactionScope transactionScope = new TransactionScope()) { PurchaseRolesInfo roleInfo = new PurchaseRolesInfo() { MasterId = parentId, RoleName = rolename }; roleInfos = roleInfo; roleInfos = context.PurchaseRolesInfo.Add(roleInfos); context.SaveChanges(); transactionScope.Complete(); } return(roleInfos); }
public Organization GetOrganizationByUserId(long UserId) { Organization Org = (from item in context.Organization where item.UserId == UserId select item).FirstOrDefault(); if (Org != null) { UserMemberInfo userInfo = context.UserMemberInfo.FirstOrDefault((UserMemberInfo m) => m.Id == Org.UserId); UserMemberInfo UserInfos = context.UserMemberInfo.FirstOrDefault((UserMemberInfo m) => m.Id == Org.ParentId); PurchaseRolesInfo roleInfo = context.PurchaseRolesInfo.FirstOrDefault((PurchaseRolesInfo m) => m.Id == Org.RoleId); PurchaseRolesInfo roleInfos = context.PurchaseRolesInfo.FirstOrDefault((PurchaseRolesInfo m) => m.Id == Org.ParentRoleId); Org.UserName = (userInfo == null ? "" : userInfo.UserName); Org.RealName = (userInfo == null ? "" : userInfo.RealName); Org.ParentName = (UserInfos == null ? "" : UserInfos.UserName); Org.ParentRoleName = (roleInfos == null ? "" : roleInfos.RoleName); Org.RoleName = roleInfo.RoleName; } return(Org); }
public JsonResult RegisterUser(string username, string password, string email, string registertype, long introducer = 0L) { bool result = false; string RoleName = ""; long id = 0; UserMemberInfo userMemberInfo = ServiceHelper.Create <IMemberService>().Register(username, password, email, registertype, introducer); if (userMemberInfo != null) { base.Session.Remove("regist_CheckCode"); result = true; id = userMemberInfo.Id; ServiceHelper.Create <ISiteMessagesService>().SendMemberRegisterMessage(userMemberInfo.Id); } if (id != 0) { if (int.Parse(System.Configuration.ConfigurationManager.AppSettings["Language"].ToString()) == 1) { RoleName = "管理员"; } if (int.Parse(System.Configuration.ConfigurationManager.AppSettings["Language"].ToString()) == 2) { RoleName = "Admin"; } } PurchaseRolesInfo rolesInfo = ServiceHelper.Create <IPermissionGroupService>().AddPermissionGroup(id, RoleName); if (rolesInfo.Id != 0) {//用户添加成功 添加组织结构 Organization oinfo = new Organization() { UserId = id, RoleId = rolesInfo.Id, RoleName = rolesInfo.RoleName, ParentRoleId = 0, ParentId = 0 }; ServiceHelper.Create <IOrganizationService>().AddOrganization(oinfo); } return(Json(new { success = result, memberId = id })); }
public bool UpdatePermissionGroup(long Id, string RoleName) { PurchaseRolesInfo roleInfo = GetPurchaseRole(Id); if (roleInfo.RoleName != RoleName) { roleInfo.RoleName = RoleName; int i = context.SaveChanges(); if (i > 0) { return(true); } else { return(false); } } else { return(true); } }
public bool Delete(long Id, long[] Ids) { int i = 0; using (TransactionScope transactionScope = new TransactionScope()) { PurchaseRolesInfo roleInfo = GetPurchaseRole(Id); context.PurchaseRolesInfo.Remove(roleInfo); IQueryable <LimitedAmount> limiteds = context.LimitedAmount.FindBy((LimitedAmount item) => Ids.Contains(item.RoleId)); context.LimitedAmount.RemoveRange(limiteds); i = context.SaveChanges(); transactionScope.Complete(); } if (i > 0) { return(true); } else { return(false); } }
//private ManagerInfo SellerLoginIn(string username, string password, bool keep = false) //{ // ManagerInfo managerInfo = ServiceHelper.Create<IManagerService>().Login(username, password, false); // if (managerInfo == null) // { // return null; // } // string str = UserCookieEncryptHelper.Encrypt(managerInfo.Id, "SellerAdmin"); // if (!keep) // { // WebHelper.SetCookie("ChemCloud-SellerManager", str); // } // else // { // DateTime now = DateTime.Now; // WebHelper.SetCookie("ChemCloud-SellerManager", str, now.AddDays(7)); // } // return managerInfo; //} /// <summary> /// 卖家和平台管理元登录 /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <param name="keep"></param> /// <returns></returns> private int SellerLoginIn(string username, string password, bool keep) { UserMemberInfo userMemberInfo = ServiceHelper.Create <IMemberService>().Login(username, password); if (userMemberInfo == null) { throw new LoginException("用户名和密码不匹配", LoginException.ErrorTypes.PasswordError); } if (userMemberInfo.UserType == 2) { if (userMemberInfo.Disabled == false) { throw new LoginException("请到邮箱验证用户", LoginException.ErrorTypes.UsernameError); } BizAfterLogin.Run(userMemberInfo.Id); string str = UserCookieEncryptHelper.Encrypt(userMemberInfo.Id, "SellerAdmin"); string str1 = UserCookieEncryptHelper.Encrypt(userMemberInfo.Id, "Web"); if (!keep) { WebHelper.SetCookie("ChemCloud-SellerManager", str); WebHelper.SetCookie("ChemCloud-User", str1); } else { DateTime now = DateTime.Now; WebHelper.SetCookie("ChemCloud-SellerManager", str, now.AddDays(7)); WebHelper.SetCookie("ChemCloud-User", str1, now.AddDays(7)); } return(2); } else if (userMemberInfo.UserType == 3) { if (userMemberInfo.Disabled == false) { throw new LoginException("用户未激活", LoginException.ErrorTypes.UsernameError); } BizAfterLogin.Run(userMemberInfo.Id); string str = UserCookieEncryptHelper.Encrypt(userMemberInfo.Id, "Web"); if (!keep) { WebHelper.SetCookie("ChemCloud-User", str); } else { DateTime now = DateTime.Now; WebHelper.SetCookie("ChemCloud-User", str, now.AddDays(7)); } if (userMemberInfo.ParentSellerId == 0) { string name = ""; PurchaseRolesInfo roleInfo = ServiceHelper.Create <IPermissionGroupService>().GetPurchaseRoleByUserId(userMemberInfo.Id); if (roleInfo == null) { long Languagetype = int.Parse(System.Configuration.ConfigurationManager.AppSettings["Language"].ToString()); if (Languagetype == 1) { name = "管理员"; } if (Languagetype == 2) { name = "Admin"; } PurchaseRolesInfo roleInfos = ServiceHelper.Create <IPermissionGroupService>().AddPermissionGroup(userMemberInfo.Id, name); if (roleInfos.Id != 0) {//用户添加成功 添加组织结构 Organization oinfo = new Organization() { UserId = userMemberInfo.Id, RoleId = roleInfos.Id, RoleName = roleInfos.RoleName, ParentRoleId = 0, ParentId = 0 }; ServiceHelper.Create <IOrganizationService>().AddOrganization(oinfo); } } } return(3); } else { return(-1); } }
/// <summary> /// 根据ID获取权限组 /// </summary> /// <param name="Id"></param> /// <returns></returns> public PurchaseRolesInfo GetPurchaseRole(long Id) { PurchaseRolesInfo roleInfo = context.PurchaseRolesInfo.FirstOrDefault((PurchaseRolesInfo m) => m.Id == Id); return(roleInfo); }
public PurchaseRolesInfo GetPurchaseRoleByUserId(long MasterId) { PurchaseRolesInfo roleInfo = context.PurchaseRolesInfo.FirstOrDefault((PurchaseRolesInfo m) => m.MasterId == MasterId); return(roleInfo); }
public PurchaseRolesInfo GetPurchaseRoleByMasterId(long MasterId, string RoleName) { PurchaseRolesInfo roleInfo = context.PurchaseRolesInfo.FirstOrDefault((PurchaseRolesInfo m) => m.MasterId == MasterId && m.RoleName == RoleName); return(roleInfo); }
public JsonResult CheckMyMoney(string price, string onum) { Organization oinfo = ServiceHelper.Create <IOrganizationService>().GetOrganizationByUserId(base.CurrentUser.Id); PurchaseRolesInfo roleInfo = ServiceHelper.Create <IPermissionGroupService>().GetPurchaseRole(oinfo.RoleId); if (roleInfo != null) { if ((roleInfo.RoleName == "管理员") || (roleInfo.RoleName == "Admin")) { return(Json("ok")); } else { if (oinfo != null) { OrderInfo o = ServiceHelper.Create <IOrderService>().GetOrder(long.Parse(onum)); LimitedAmount la = ServiceHelper.Create <IOrganizationService>().GetlimitedByRoleId(oinfo.RoleId, int.Parse(o.CoinType.ToString())); if (la != null) { decimal usermoney = la.Money; decimal ordermoney = decimal.Parse(price); if (usermoney >= ordermoney) { return(Json("ok")); } else { //申请判断 ApplyAmountInfo aai = ServiceHelper.Create <IApplyAmountService>().GetApplyByUserId(base.CurrentUser.Id, long.Parse(onum)); if (aai != null) { int status = aai.ApplyStatus; if (status == 0) { return(Json("您已提交限额申请,请耐心等待")); } else if (status == 1) { return(Json("ok")); } else { return(Json("您提交限额申请没有通过,请进行重新提交")); } } else { return(Json("你的限额受限"));//你的限额受限,是否提交申请? } } } else { return(Json("获取您的限额信息失败")); } } else { return(Json("您现在还没有组织架构哦")); } } } else { return(Json("您现在还没有权限组哦")); } }