/// <summary> /// 修改用户组 /// </summary> /// <param name="org"></param> /// <returns>执行结果</returns> public Result Update(sys_org org) { Result res = new Result(); OrganizationDAL orgDAL = new OrganizationDAL(); try { if (orgDAL.Update(org) == 0) { res.Code = RES.ERROR; res.Message = "修改失败!"; return(res); } else { res.Code = RES.OK; res.Message = "修改成功!"; return(res); } } catch { res.Code = RES.ERROR; res.Message = "修改失败!"; return(res); } }
/// <summary> /// 删除组织机构 /// </summary> /// <param name="id"></param> /// <returns>执行结果</returns> public Result Del(int id) { Result res = new Result(); OrganizationDAL orgDAL = new OrganizationDAL(); try { List <sys_org> org = orgDAL.SelectByparentid(id); foreach (var item in org) { Del(item.id); } if (orgDAL.Del(id) == 1) { res.Code = RES.OK; res.Message = "删除成功!"; return(res); } else { res.Code = RES.ERROR; res.Message = "删除失败!"; return(res); } } catch { res.Code = RES.ERROR; res.Message = "删除失败!"; return(res); } }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="userid"></param> /// <param name="agentid"></param> /// <returns></returns> public static Users GetUserByUserID(string userid, string agentid) { if (string.IsNullOrEmpty(userid) || string.IsNullOrEmpty(agentid)) { return(null); } var list = GetUsers(agentid); if (list.Where(u => u.UserID == userid).Count() > 0) { return(list.Where(u => u.UserID == userid).FirstOrDefault()); } else { DataTable dt = new OrganizationDAL().GetUserByUserID(userid); Users model = new Users(); if (dt.Rows.Count > 0) { model.FillData(dt.Rows[0]); model.Department = GetDepartmentByID(model.DepartID, agentid); model.Role = GetRoleByIDCache(model.RoleID, agentid); Users[agentid].Add(model); } return(model); } }
/// <summary> /// 根据明道用户ID和网络ID获取云销用户信息(登录) /// </summary> /// <param name="mduserid"></param> /// <param name="mdprojectid"></param> /// <returns></returns> public static Users GetUserByMDUserID(string mduserid, string mdprojectid, string operateip) { DataSet ds = new OrganizationDAL().GetUserByMDUserID(mduserid); Users model = null; if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0) { model = new Users(); model.FillData(ds.Tables["User"].Rows[0]); model.Department = GetDepartmentByID(model.DepartID, model.AgentID); model.Role = GetRoleByIDCache(model.RoleID, model.AgentID); model.Menus = CommonBusiness.ClientMenus; //处理缓存 if (!Users.ContainsKey(model.AgentID)) { GetUsers(model.AgentID); } if (Users[model.AgentID].Where(u => u.MDUserID == mduserid).Count() == 0) { Users[model.AgentID].Add(model); } } if (!string.IsNullOrEmpty(operateip)) { //记录登录日志 LogBusiness.AddLoginLog(mduserid, model != null, CloudSalesEnum.EnumSystemType.Client, operateip); } return(model); }
public IHttpActionResult GetOrganizationSortByPoint() { try { List <OrganizationBasicInfo> allRankedOrganizaation; using (var db = new OrganizationDAL()) { allRankedOrganizaation = db.GetOrganizationOrderByDecendingPoint(); } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Message = "", Type = "", Data = allRankedOrganizaation })); } catch (Exception) { return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.ERROR, Message = "", Type = "" })); } }
public static Users GetUserByUserName(string loginname, string pwd, out int result, string operateip) { pwd = WinWarTool.Encrypt.GetEncryptPwd(pwd, loginname); DataSet ds = new OrganizationDAL().GetUserByUserName(loginname, pwd, out result); Users model = null; if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0) { model = new Users(); model.FillData(ds.Tables["User"].Rows[0]); model.LogGUID = Guid.NewGuid().ToString(); model.Role = GetRoleByID(model.RoleID); //权限 if (model.Role != null && model.Role.IsDefault == 1) { model.Menus = CommonBusiness.ClientMenus; } else { model.Menus = new List <Menu>(); foreach (DataRow dr in ds.Tables["Permission"].Rows) { Menu menu = new Menu(); menu.FillData(dr); model.Menus.Add(menu); } } } return(model); }
public IHttpActionResult GetRankOfOrganization(int orgId) { try { RankingDTO rankOfOrganization; using (var db = new OrganizationDAL()) { Organization org = db.GetOrganizationById(orgId); WsRanking ranking = new WsRanking(); rankOfOrganization = ranking.RankingWithPoint(org.Point); } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Message = "", Type = "", Data = rankOfOrganization })); } catch (Exception) { return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.ERROR, Message = "", Type = "" })); } }
public IHttpActionResult GetOrganizationUsingId(int orgId) { OrganizationBasicInfo currentOrganization = new OrganizationBasicInfo(); try { using (var db = new OrganizationDAL()) { currentOrganization = db.GetFullOrganizationBasicInformation(orgId); } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Message = "", Type = "", Data = currentOrganization })); } catch (Exception) { return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.ERROR, Message = "", Type = "" })); } }
public IHttpActionResult GetTopThreeOrganization() { var basicOrgList = new List <OrganizationBasicInfo>(); using (var db = new OrganizationDAL()) { List <Organization> topOrg = db.GetTopThreeOrganizations(3); foreach (Organization org in topOrg) { basicOrgList.Add(new OrganizationBasicInfo { OrganizationId = org.OrganizationId, OrganizationName = org.OrganizationName, Introduction = org.Introduction, LogoUrl = org.LogoUrl, Phone = org.Phone, Email = org.Email, Address = org.Address, IsActive = org.IsActive, Point = org.Point }); } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Data = basicOrgList })); } }
public IEnumerable <organization> GetOrganization(string Identifier, string addressCity, string partof, string type, string active, string addressState) { try { if (string.IsNullOrEmpty(Identifier) && string.IsNullOrEmpty(addressCity) && string.IsNullOrEmpty(partof) && string.IsNullOrEmpty(type)) { OrganizationDAL OrgDAL = new OrganizationDAL(); return(OrgDAL.GetAll()); } else { organization FilterObj = organizationConverter.ConvertParams(Identifier, active, type, addressCity, addressState, partof); OrganizationDAL OrgDAL = new OrganizationDAL(); return(OrgDAL.Filter(FilterObj)); } } catch (Exception e) { throw e; } }
public IHttpActionResult GetStatisticAboutOrganization() { try { StatisticManageBasicInforDTO statistic = new StatisticManageBasicInforDTO(); using (var db = new OrganizationDAL()) { statistic = db.GetStatisticAboutOrgaization(); } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Message = "", Type = "", Data = statistic })); } catch (Exception) { return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.ERROR, Message = "", Type = "" })); } }
public IHttpActionResult GetNewesCreatedOrganization() { try { List <OrganizationBasicInfo> orgList = new List <OrganizationBasicInfo>(); using (var db = new OrganizationDAL()) { orgList = db.GetNewestCreatedOrgzation(); } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Message = "", Type = "", Data = orgList })); } catch (Exception) { return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.ERROR, Message = "", Type = "" })); } }
public IHttpActionResult CancelCreateOrganizationRequest(int organizationId) { try { bool isSuccess; OrganizationBasicInfo organizationBasic; // Delete create request using (var db = new OrganizationDAL()) { //get inforamation of organziation Creator organizationBasic = db.GetFullOrganizationBasicInformation(organizationId); isSuccess = db.DeleteOrganization(organizationId); } //Send mail to Creator to anounce that admin reject create organization request if (isSuccess) { //khai bao bien var fromAddress = new MailAddress(WsConstant.OrganizationRegistration.AdminEmail, WsConstant.OrganizationRegistration.WsAdmin); var toAddress = new MailAddress(organizationBasic.Creator.Email, organizationBasic.Creator.UserName); string fromPassword = WsConstant.OrganizationRegistration.AdminEmailPass; string subject = WsConstant.OrganizationRegistration.EmailSubjectRejectRegistration; string body = WsConstant.OrganizationRegistration.EmailContentFirst + "Yêu cầu tạo tổ chức : '" + organizationBasic.OrganizationName + "' " + WsConstant.OrganizationRegistration.EmailContentRejectRegistration; //xu li gui mail var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Timeout = 30000, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); } } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Data = isSuccess })); } catch (Exception) { return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.ERROR })); } }
public IHttpActionResult AcceptingOrganization(int organizationId) { try { OrganizationBasicInfo organizationBasic; using (var db = new OrganizationDAL()) { var org = db.GetOrganizationById(organizationId); org.IsVerify = true; org.IsActive = true; db.UpdateOrganization(org); organizationBasic = db.GetFullOrganizationBasicInformation(org.OrganizationId); } //send email to register user //khai bao bien var fromAddress = new MailAddress(WsConstant.OrganizationRegistration.AdminEmail, WsConstant.OrganizationRegistration.WsAdmin); var toAddress = new MailAddress(organizationBasic.Creator.Email, organizationBasic.Creator.UserName); string fromPassword = WsConstant.OrganizationRegistration.AdminEmailPass; string subject = WsConstant.OrganizationRegistration.EmailSubjectAcceptRegistration; string body = WsConstant.OrganizationRegistration.EmailContentFirst + "Yêu cầu tạo tổ chức : '" + organizationBasic.OrganizationName + "' " + WsConstant.OrganizationRegistration.EmailContentAcceptRegistration; //xu li gui mail var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Timeout = 30000, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Data = true })); } catch (Exception) { return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.ERROR })); } }
public IHttpActionResult GetEventsSortByPoint() { List <Event> EventFollowPoint = null; var basicEventList = new List <EventBasicInfo>(); try { using (var db = new EventDAL()) { EventFollowPoint = db.GetEventSortByPoint(); foreach (Event events in EventFollowPoint) { var eventMainImage = db.GetMainImageEventById(events.EventID); //get name of organizationt which is owner of this event. string organizationName; string eventType; using (var dbOrg = new OrganizationDAL()) { var orgOwner = dbOrg.GetOrganizationById(events.CreatorID); organizationName = orgOwner.OrganizationName; } //get type of this event. using (var dbWscontext = new Ws_DataContext()) { var eventTypes = dbWscontext.EventTypes.Find(events.EventType); eventType = eventTypes.EventTypeName; } basicEventList.Add(new EventBasicInfo { EventID = events.EventID, CreatorID = events.CreatorID, CreatorName = organizationName, EventName = events.EventName, MainImageUrl = eventMainImage.ImageUrl, Content = events.Description, ShortDescription = events.ShortDescription, Status = true, EventType = eventType, CreatedDate = events.Created_Date.ToString("H:mm:ss dd/MM/yy") }); } } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Data = basicEventList })); } catch (Exception) { //ViewBag.ErrorMessage = ex; return(Redirect("/#/Error")); } }
public static Users GetUserByAliMemberID(string aliMemberID, string operateip) { DataSet ds = new OrganizationDAL().GetUserByAliMemberID(aliMemberID); Users model = null; if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0) { model = new Users(); model.FillData(ds.Tables["User"].Rows[0]); model.LogGUID = Guid.NewGuid().ToString(); model.Role = GetRoleByID(model.RoleID); //处理缓存 if (!Users.ContainsKey(model.AgentID)) { GetUsers(model.AgentID); } if (Users[model.AgentID].Where(u => u.UserID == model.UserID).Count() == 0) { Users[model.AgentID].Add(model); } else { var user = Users[model.AgentID].Where(u => u.UserID == model.UserID).FirstOrDefault(); user.LogGUID = model.LogGUID; } //权限 if (model.Role != null && model.Role.IsDefault == 1) { model.Menus = CommonBusiness.ClientMenus; } else { model.Menus = new List <Menu>(); foreach (DataRow dr in ds.Tables["Permission"].Rows) { Menu menu = new Menu(); menu.FillData(dr); model.Menus.Add(menu); } } } if (string.IsNullOrEmpty(operateip)) { operateip = ""; } return(model); }
/// <summary> /// 获取部门列表 /// </summary> /// <param name="clientid">客户端ID</param> /// <returns></returns> public static List <Department> GetDepartments(string clientid) { DataTable dt = new OrganizationDAL().GetDepartments(clientid); List <Department> list = new List <Department>(); foreach (DataRow dr in dt.Rows) { Department model = new Department(); model.FillData(dr); list.Add(model); } return(list); }
public static bool ConfirmLoginPwd(string loginname, string pwd) { pwd = WinWarTool.Encrypt.GetEncryptPwd(pwd, loginname); int result; DataSet ds = new OrganizationDAL().GetUserByUserName(loginname, pwd, out result); if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0) { return(true); } return(false); }
public static DataSet GetRole(string Role, string RoleID) { DataSet ds = new DataSet(); try { ds = OrganizationDAL.GetRole(Role, RoleID); } catch (Exception ex) { Log(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } return(ds); }
public static DataSet GetAdminUserDetails(UserBO objUserBO, int ChildUserID) { DataSet ds = new DataSet(); try { ds = OrganizationDAL.GetAdminUserDetails(objUserBO, ChildUserID); } catch (Exception ex) { Log(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } return(ds); }
public static DataSet GetCountry(int UserID) { DataSet ds = new DataSet(); try { ds = OrganizationDAL.GetCountry(UserID); } catch (Exception ex) { Log(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } return(ds); }
/// <summary> /// 编辑部门 /// </summary> /// <param name="departid">部门ID</param> /// <param name="name">名称</param> /// <param name="description">描述</param> /// <param name="operateid">操作人</param> /// <param name="operateip">操作IP</param> /// <returns></returns> public bool UpdateDepartment(string departid, string name, string description, string operateid, string operateip, string agentid) { var dal = new OrganizationDAL(); bool bl = dal.UpdateDepartment(departid, name, description, agentid); if (bl) { //处理缓存 var model = GetDepartments(agentid).Where(d => d.DepartID == departid).FirstOrDefault(); model.Name = name; model.Description = description; } return(bl); }
public bool UpdateDepartment(string departid, string name, string description, string operateid, string operateip, string clientid) { var dal = new OrganizationDAL(); bool bl = dal.UpdateDepartment(departid, name, description); if (bl) { //处理缓存 var model = GetDepartmentByID(departid, clientid); model.Name = name; model.Description = description; } return(bl); }
public static List <Role> GetRoles() { DataTable dt = new OrganizationDAL().GetRoles(); List <Role> list = new List <Role>(); foreach (DataRow dr in dt.Rows) { Role model = new Role(); model.FillData(dr); list.Add(model); } return(list); }
/// <summary> /// Check Event state to Create /// </summary> /// <param name="userId"></param> /// <returns></returns> public JsonResult CheckCreateEvent(int userId) { using (var db = new OrganizationDAL()) { var orgaGet = db.GetOrganizationById(userId); if (!orgaGet.IsVerify || !orgaGet.IsActive) { return(Json(false, JsonRequestBehavior.AllowGet)); } else { return(Json(true, JsonRequestBehavior.AllowGet)); } } }
/// <summary> /// 获取部门列表 /// </summary> /// <param name="agentid">代理商ID</param> /// <returns></returns> public static List <Department> GetDepartments(string agentid) { if (!Departments.ContainsKey(agentid)) { DataTable dt = new OrganizationDAL().GetDepartments(agentid); List <Department> list = new List <Department>(); foreach (DataRow dr in dt.Rows) { Department model = new Department(); model.FillData(dr); list.Add(model); } Departments.Add(agentid, list); return(list); } return(Departments[agentid].Where(m => m.Status == 1).ToList()); }
/// <summary> /// 获取角色列表 /// </summary> /// <param name="agentid">代理商ID</param> /// <returns></returns> public static List <Role> GetRoles(string agentid) { if (!Roles.ContainsKey(agentid)) { DataTable dt = new OrganizationDAL().GetRoles(agentid); List <Role> list = new List <Role>(); foreach (DataRow dr in dt.Rows) { Role model = new Role(); model.FillData(dr); list.Add(model); } Roles.Add(agentid, list); return(list); } return(Roles[agentid].Where(m => m.Status == 1).ToList()); }
public IHttpActionResult GetStatisticManageBasicInfor() { try { StatisticManageBasicInforDTO statistic = new StatisticManageBasicInforDTO(); using (var db = new UserDAL()) { statistic.NumberActiveUser = db.CountUserActiveOrNot(true); statistic.NumberNotActiveUser = db.CountUserActiveOrNot(false); statistic.NumberVerifyUser = db.CountUserVerifyOrNot(true); statistic.NumberNotVerifyUser = db.CountUserVerifyOrNot(false); statistic.NumberNewCreateUser = db.CountNewUser(); statistic.NumberTotalUser = db.CountTotalUser(); //Get number of event statistic.NumberTotalEvent = db.CountTotalEvent(); //Get number of post statistic.NumberTotalThread = db.CountTotalThread(); } using (var db = new OrganizationDAL()) { //Get number of organization statistic.NumberTotalOrganization = db.CountTotalOrganization(); } return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.SUCCESS, Message = "", Type = "", Data = statistic })); } catch (Exception) { return(Ok(new HTTPMessageDTO { Status = WsConstant.HttpMessageType.ERROR, Message = "", Type = "" })); } }
/// <summary> /// 根据用户名密码获取会员信息(登录) /// </summary> /// <param name="loginname">用户名</param> /// <param name="pwd">密码</param> /// <returns></returns> public static Users GetUserByUserName(string loginname, string pwd, string operateip) { pwd = CloudSalesTool.Encrypt.GetEncryptPwd(pwd, loginname); DataSet ds = new OrganizationDAL().GetUserByUserName(loginname, pwd); Users model = null; if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0) { model = new Users(); model.FillData(ds.Tables["User"].Rows[0]); if (CommonCache.ClientMenus.ContainsKey(model.ClientID)) { model.Menus = CommonCache.ClientMenus[model.ClientID]; } else if (ds.Tables.Contains("Modules")) { List <Menu> list = new List <Menu>(); var modules = CommonCache.Modules; foreach (DataRow dr in ds.Tables["Modules"].Rows) { Modules module = new Modules(); module.FillData(dr); if (modules.ContainsKey(module.ModulesID)) { foreach (var item in modules[module.ModulesID]) { if (list.Where(m => m.MenuCode == item.MenuCode).Count() == 0) { list.Add(item); } } } } list = list.OrderBy(m => m.Sort).ToList(); CommonCache.ClientMenus.Add(model.ClientID, list); model.Menus = list; } } //记录登录日志 LogBusiness.AddLoginLog(loginname, model != null, CloudSalesEnum.EnumSystemType.Client, operateip); return(model); }
public static Users GetUserByUserID(string userid) { if (string.IsNullOrEmpty(userid)) { return(null); } userid = userid.ToLower(); DataTable dt = new OrganizationDAL().GetUserByUserID(userid); Users model = new Users(); if (dt.Rows.Count > 0) { model.FillData(dt.Rows[0]); model.Role = GetRoleByID(model.RoleID); } return(model); }