/// <summary> /// Constructeur /// </summary> public ChatHistoryService() { chatHistoryDAO = new ChatHistoryDAO(); groupDAO = new GroupDAO(); personDAO = new PersonDAO(); followingDAO = new FollowingDAO(); }
private StringBuilder getGroupSum() { StringBuilder strbd = new StringBuilder(); GroupDAO groupDAO = new GroupDAO(); List <Group> lstGrp = new List <Group>(); lstGrp = groupDAO.getGroupSummary(); string str_num_failed = ""; for (int i = 0; i < lstGrp.Count; i++) { if (lstGrp[i].Failed != 0) { str_num_failed = "<span class='badge badge-danger'>" + lstGrp[i].Failed + "</span>"; } else { str_num_failed = lstGrp[i].Failed.ToString(); } strbd.Append("<tr>"); strbd.Append("<td><strong>").Append(lstGrp[i].Group_name).Append("</strong></td>"); strbd.Append("<td>").Append(lstGrp[i].Completed).Append("</td>"); strbd.Append("<td>").Append(lstGrp[i].Running).Append("</td>"); strbd.Append("<td>").Append(str_num_failed).Append("</td>"); strbd.Append("<td>").Append(lstGrp[i].Notstart).Append("</td>"); strbd.Append("<td>").Append(lstGrp[i].Except).Append("</td>"); strbd.Append("<td>").Append(lstGrp[i].Total).Append("</td>"); strbd.Append("</tr>"); } return(strbd); }
public static int SetItems(List <GroupPermissionModels> permissions, long groupId, long siteId) { using (var conn = new SqlConnection(WebInfo.Conn)) { GroupModels group = GroupDAO.GetItem(groupId, siteId); string sql = @" DELETE FROM GroupPermission WHERE GroupID = @GroupID AND PermissionType = @PermissionType "; Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("GroupID", groupId); param.Add("PermissionType", group.GroupType); conn.Execute(sql, param); } if (permissions == null) { return(0); } int retValue = 0; foreach (GroupPermissionModels permission in permissions) { retValue += SetItem(permission); } return(retValue); }
//Create a new method to create a group public void CreateGroup(GroupDAO GroupToCreate) { try { //Create a new connection to the database using (SqlConnection connection = new SqlConnection(connectionstring)) { //This creates a new database object using (SqlCommand command = new SqlCommand("sp_CreateGroup", connection)) { //This states what command type the object is command.CommandType = CommandType.StoredProcedure; //This adds the parameters nessicary for the stored procedure command.Parameters.AddWithValue("@GroupName", GroupToCreate.GroupName); command.Parameters.AddWithValue("@GroupLeader", GroupToCreate.GroupLeaderID); command.Parameters.AddWithValue("@Description", GroupToCreate.Description); //This opens a new connection to the database connection.Open(); //This will excecute the above stored procedure command.ExecuteNonQuery(); //This will close the database connection connection.Close(); //This will dispose the database connection connection.Dispose(); } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } }
//Create a new method to delete a group public void DeleteGroup(GroupDAO GroupToDelete) { try { //This creates a new connection to the Sql Database using (SqlConnection connection = new SqlConnection(connectionstring)) { //This creates a new command object for the database using (SqlCommand command = new SqlCommand("sp_DeleteGroup", connection)) { //This specifies what type the command object is command.CommandType = CommandType.StoredProcedure; //This states the parameters for the stored procedure command.Parameters.AddWithValue("@GroupID", GroupToDelete.GroupID); //This opens the connection to the database connection.Open(); //This executes the above stored procedure command.ExecuteNonQuery(); //This closes the opened connection connection.Close(); //This disposes the sql connection connection.Dispose(); } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } }
//Create a new method to Update a group public void UpdateGroup(GroupDAO GroupToUpdate) { try { //This creates a new connection to the Sql database using (SqlConnection connection = new SqlConnection(connectionstring)) { //This creates a new command object for the database using (SqlCommand command = new SqlCommand("sp_UpdateGroup", connection)) { //This specifies the command type the obbject is command.CommandType = CommandType.StoredProcedure; //This fills the value needed for the stored procedures command.Parameters.AddWithValue("@GroupID", GroupToUpdate.GroupID); command.Parameters.AddWithValue("@GroupName", GroupToUpdate.GroupName); command.Parameters.AddWithValue("@GroupLeader", GroupToUpdate.GroupLeaderID); command.Parameters.AddWithValue("@Description", GroupToUpdate.Description); //This opens the connection to the database connection.Open(); //This executes the stored procedure command.ExecuteNonQuery(); //This closes the sql connection connection.Close(); //This disposes the Sql Connection connection.Dispose(); } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } }
//Create a method to view all groups public List <GroupDAO> GetAllGroups() { List <GroupDAO> grouplist = new List <GroupDAO>(); try { using (SqlConnection connection = new SqlConnection(connectionstring)) { using (SqlCommand command = new SqlCommand("sp_ViewGroups", connection)) { command.CommandType = CommandType.StoredProcedure; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { GroupDAO groupToList = new GroupDAO(); groupToList.GroupID = reader.GetInt32(0); groupToList.GroupName = reader.GetString(1); groupToList.GroupLeader = reader.GetString(2); groupToList.GroupLeaderID = reader.GetInt32(3); groupToList.Description = reader.GetString(4); grouplist.Add(groupToList); } } } } } catch (Exception errorCaught) { ErrorLogger errorToLog = new ErrorLogger(); errorToLog.errorlogger(errorCaught); } return(grouplist); }
/// <summary> /// Constructeur /// </summary> public TaskService() : base() { taskDAO = new TaskDAO(); groupDAO = new GroupDAO(); personDAO = new PersonDAO(); followingDAO = new FollowingDAO(); }
public ActionResult PermissionSetting(long ID) { IEnumerable <WorkV3.Models.SitesModels> sites = WorkV3.Models.DataAccess.SitesDAO.GetDatas(); List <ViewModels.GroupPermissionViewModel> siteMenuList = new List <ViewModels.GroupPermissionViewModel>(); foreach (WorkV3.Models.SitesModels site in sites) { siteMenuList.Add(new ViewModels.GroupPermissionViewModel { SiteID = site.Id, menus = BackendMenuDAO.GetRoots(site.Id) }); } long siteId = PageCache.SiteID; //IEnumerable<BackendMenuModel> rootMenu = BackendMenuDAO.GetRoots(); //string jsonResult = JsonConvert.SerializeObject(siteMenuList); GroupModels group = GroupDAO.GetItem(ID, siteId); ViewBag.BodyClass = "body-admin-main"; ViewBag.Group = group; ViewBag.RootMenu = siteMenuList; ViewBag.SiteID = siteId; //ViewBag.RootMenuJson = jsonResult; ViewBag.WebUrl = System.Configuration.ConfigurationManager.AppSettings["WebUrl"].TrimEnd('/'); return(View()); }
public JsonResult PermissionGroupSetting(long ID, long SiteID) { string[] arrPermissionGroup = (Request["PermissionGroup"].ToString() ?? "").Split(','); GroupDAO.PermissionGroupSetting(ID, SiteID, arrPermissionGroup); return(Json("OK", JsonRequestBehavior.AllowGet)); }
public static bool HaverPermission(long groupId, long siteId, int menuType, long menuId) { using (var conn = new SqlConnection(WebInfo.Conn)) { GroupModels group = GroupDAO.GetItem(groupId, siteId); string sql = @" SELECT 1 FROM GroupPermission WHERE [GroupID] = @GroupID AND [SiteID] = @SiteID AND [MenuType] = @MenuType AND [MenuID] = @MenuID "; Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("@GroupID", groupId); param.Add("@SiteID", siteId); param.Add("@MenuType", menuType); param.Add("@MenuID", menuId); IEnumerable <GroupPermissionModels> permission = conn.Query <GroupPermissionModels>(sql, param); if (group.GroupType == 1) // 黑名單模式,找到的話 return false { return(permission.Count() == 0 ? true : false); } else // 白名單模式,找到的話 return true { return(permission.Count() == 0 ? false : true); } } }
public UserController(UserDAO userDAO, UserRepository userRepository, GroupDAO groupDAO, AuthUser authUser) : base(authUser) { _userDAO = userDAO; _userRepository = userRepository; _groupDAO = groupDAO; }
public static string getGroupSumAjax() { GroupDAO groupDAO = new GroupDAO(); string str_json = new JavaScriptSerializer().Serialize(groupDAO.getGroupSummary()); return(str_json); }
// GET: Backend/Permission public ActionResult PermissionGroup() { IEnumerable <GroupModels> items = GroupDAO.GetItems(); ViewBag.WebUrl = System.Configuration.ConfigurationManager.AppSettings["WebUrl"].TrimEnd('/'); return(View(items)); }
public MentorController(MentorDAO mentorDAO, ClassEnrolmentDAO classEnrolmentDAO, GroupDAO groupDAO, StudentDAO studentDAO, ICurrentSession session) { _mentorDAO = mentorDAO; _classEnrolmentDAO = classEnrolmentDAO; _groupDAO = groupDAO; _studentDAO = studentDAO; _session = session; _credentialID = _session.LoggedUser.CredentialID; }
public ArtifactManagement() { _studentDAO = new StudentDAO(); _artifact = new ArtifactDAO(); _ownedArtifactGroup = new OwnedArtifactGroupDAO(); _ownedArtifactStudent = new OwnedArtifactStudentDAO(); _groupDAO = new GroupDAO(); _groupTransactionDAO = new GroupTransactionDAO(); _studentAcceptanceDAO = new StudentAcceptanceDAO(); }
/// <summary> /// adds a new group to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <exception cref="ArgumentNullException">If the given string is null.</exception> /// <exception cref="CouldNotFindException">If the user for the given username could not be found.</exception> /// <exception cref="EntryAlreadyExistsException">If the group already exists in the database.</exception> /// <exception cref="SQLException">An unknown SQL happened.</exception> public void addGroup_Click(Object sender, EventArgs e) { SqlController controller = new SqlController(); UserDAO owner = Session["userDAO"] as UserDAO; GroupDAO group = new GroupDAO(owner); group.Name = Request["groupNameBox"]; group.GroupTag = Request["groupTagBox"]; group.Description = Request["groupDescriptionBox"]; if (string.IsNullOrWhiteSpace(group.Name) || group.Name.Length >= GroupDAO.NameMaxLength) { ShowError(string.Format("Invalid group name. Please enter a name under {0} characters.", GroupDAO.NameMaxLength)); groupNameBox.Focus(); } else if (string.IsNullOrWhiteSpace(group.GroupTag) || group.GroupTag.Length > GroupDAO.GroupTagMaxLength || group.GroupTag.Length < 4) { ShowError(string.Format("Invalid group tag. Please enter a tag between {0} and {1} characters.", 4, GroupDAO.GroupTagMaxLength)); groupTagBox.Focus(); } else if (string.IsNullOrWhiteSpace(group.Description) || group.Description.Length >= GroupDAO.DescriptionMaxLength) { ShowError(string.Format("Invalid group description. Please enter a name under {0} characters.", GroupDAO.DescriptionMaxLength)); groupDescriptionBox.Focus(); } else { try { if (controller.CreateGroup(group)) { // Redirect to the manage page Response.Redirect(string.Format("ManageGroup.aspx?grouptag={0}", HttpUtility.UrlEncode(group.GroupTag))); } else { ShowError("Your group was not created successfully. Please try again!"); } } catch (ArgumentNullException) { ShowError("An unknown error has happened. Please try again later."); } catch (EntryAlreadyExistsException) { ShowError("This group already exists!"); } catch (SqlException error) { ShowError("An unknown error has happened. Please try again later."); Logger.LogMessage("AddGroup.aspx: " + error.Message, LoggerLevel.SEVERE); } } }
public StudentController(StudentDAO studentDAO, QuestDAO questDAO, OwnedQuestStudentDAO ownedQuestStudentDAO, ClassroomDAO classroomDAO, GroupDAO groupDAO) { _studentDAO = studentDAO; _questDAO = questDAO; _ownedQuestStudentDAO = ownedQuestStudentDAO; _classroomDAO = classroomDAO; _groupDAO = groupDAO; }
public ActionResult GroupSetting(long?ID = null) { GroupModels model = new GroupModels(); ViewBag.BodyClass = "body-admin-main"; if (ID.HasValue) { model = GroupDAO.GetItem((long)ID, PageCache.SiteID); } ViewBag.WebUrl = System.Configuration.ConfigurationManager.AppSettings["WebUpdUrl"].Replace("WebUPD", "").TrimEnd('/'); return(View(model)); }
public ActionResult EditMemberInfo(MemberModels model) { model.IsChangedPassword = true; ManagerDAO.SetPersonalItem(model); ViewBag.Exit = true; ViewBag.RefreshLoginInfo = true; ViewBag.UploadUrl = uploadUrl; var group = GroupDAO.GetItems(); ViewBag.group = group; return(View(model)); }
// GET: Backend/Manager public ActionResult Manager(int?index, MemberSearch search, long siteId = 0) { IEnumerable <GroupModels> groups = GroupDAO.GetItems(); foreach (GroupModels group in groups) { group.SetPermissionsForAllSites(1); } Pagination pagination = new Pagination { PageIndex = index ?? 1, PageSize = WebInfo.PageSize }; if (Request.HttpMethod == "GET") { if (index == null) { Utility.ClearSearchValue(); Session[$"ExportSearch"] = null; } else { MemberSearch prevSearch = Utility.GetSearchValue <MemberSearch>(); if (prevSearch != null) { search = prevSearch; } } } else if (Request.HttpMethod == "POST") { Utility.SetSearchValue(search); Session[$"ExportSearch"] = search; } int totalRecord; List <MemberModels> items = ManagerDAO.GetItems(pagination.PageSize, pagination.PageIndex, out totalRecord, search); pagination.TotalRecord = totalRecord; ViewBag.Pagination = pagination; ViewBag.SiteID = siteId; ViewBag.Groups = groups; ViewBag.Search = search; return(View(items)); }
/// <summary> /// Adds new user role. /// </summary> protected void frmRole_ItemInserting(object sender, FormViewInsertEventArgs e) { if (Page.IsValid) { GroupDAO gd = new GroupDAO(); string nazwa = ((TextBox)frmRole.FindControl("txtNazwa")).Text; string skrot = ((TextBox)frmRole.FindControl("txtSkrot")).Text; gd.CreateGroup(nazwa, skrot, false, 0); gvGroupsList.DataBind(); frmRole.ChangeMode(FormViewMode.ReadOnly); frmRole.Visible = false; } }
public ActionResult PermissionGroup_User(long ID) { List <MemberModels> GetMemberByGroup = GroupDAO.GetMemberByGroup(ID); string GroupName = ""; GroupModels GM = GroupDAO.GetItem(ID); if (GM != null) { GroupName = GM.Name; } ViewBag.GroupName = GroupName; ViewBag.BodyClass = "body-admin-main"; return(View(GetMemberByGroup)); }
private void UpdateValueStudentWallet(int groupID, int artifactID) { var studentGroup = new GroupDAO().FindOneRecordBy(groupID); studentGroup.GroupStudents = new StudentDAO().FetchAllStudentInGroup(groupID); var artifactToBuy = new ArtifactDAO().FindOneRecordBy(artifactID); int amountStudents = studentGroup.GroupStudents.Count; foreach (Student student in studentGroup.GroupStudents) { int currentWalletValue = student.Wallet - (artifactToBuy.Cost / amountStudents); student.Wallet = currentWalletValue; new StudentDAO().UpdateRecord(student); } }
/// <summary> /// Modifies selected user role. /// </summary> protected void frmRole_ItemUpdating(object sender, FormViewUpdateEventArgs e) { if (Page.IsValid) { GroupDAO gd = new GroupDAO(); int groupId = int.Parse(gvGroupsList.SelectedDataKey.Value.ToString()); string nazwa = ((TextBox)frmRole.FindControl("txtNazwa")).Text; string skrot = ((TextBox)frmRole.FindControl("txtSkrot")).Text; gd.UpdateGroup(groupId, 0, nazwa, skrot, false); gvGroupsList.DataBind(); frmRole.ChangeMode(FormViewMode.ReadOnly); frmRole.Visible = false; } }
/// <summary> /// Adds new users group. /// </summary> protected void frmGroup_ItemInserting(object sender, FormViewInsertEventArgs e) { if (Page.IsValid) { GroupDAO gd = new GroupDAO(); string nazwa = ((TextBox)frmGroup.FindControl("txtNazwa")).Text; string skrot = ((TextBox)frmGroup.FindControl("txtSkrot")).Text; int idRodzica = int.Parse(((DropDownList)frmGroup.FindControl("ddlParentGroup")).SelectedItem.Value); gd.CreateGroup(nazwa, skrot, true, idRodzica); gvGroupsList.DataBind(); frmGroup.ChangeMode(FormViewMode.ReadOnly); frmGroup.Visible = false; } }
protected void lnkAddGroup_Click(object sender, EventArgs e) { GroupDAO gd = new GroupDAO(); DataSet dsGroups = gd.GetGroupsListDataSet(); dsGroups.DataSetName = "Groups"; dsGroups.Tables[0].TableName = "Group"; DataRelation dRel = new DataRelation("parentGroups", dsGroups.Tables["Group"].Columns["id"], dsGroups.Tables["Group"].Columns["idRodzica"], true); dRel.Nested = true; dsGroups.Relations.Add(dRel); dsxmlGroups.Data = dsGroups.GetXml(); tvGroups.DataBind(); pnlGroups.Visible = true; pnlJRWA.Visible = false; }
private void LoadDepartments() { try { GroupDAO gd = new GroupDAO(); DataSet dsGroups = gd.GetGroupsListDataSet(); dsGroups.DataSetName = "Groups"; dsGroups.Tables[0].TableName = "Group"; DataRelation dRel = new DataRelation("parentGroups", dsGroups.Tables["Group"].Columns["id"], dsGroups.Tables["Group"].Columns["idRodzica"], true); dRel.Nested = true; dsGroups.Relations.Add(dRel); dsxmlGroups.Data = dsGroups.GetXml(); tvGroups.DataBind(); } catch (Exception e) { lblMessage.Text = e.Message; } }
public ActionResult Edit(MemberModels model, IEnumerable <MemberToCompanyModel> companyItems, long siteId = 0) { ////密碼 //string hidpassword = Request["hidpassword"]; //string hashKey = uRandom.GetRandomCode(10); //if (!string.IsNullOrEmpty(hidpassword)) //{ // model.HashKey = hashKey; // model.HashPwd = HashWord.EncryptSHA256(hidpassword, hashKey); //} ViewBag.Exit = true; HttpPostedFileBase imgFile = model.imgFile; if (imgFile != null && imgFile.ContentLength > 0) { string Path = string.Format("{0}/{1}", GetItem.UpdPath(), "Manager"); if (!System.IO.Directory.Exists(Path)) { System.IO.Directory.CreateDirectory(Path); } string saveName = WorkV3.Golbal.UpdFileInfo.SaveFiles(imgFile, Path); model.Img = saveName; } ManagerDAO.SetItem(model); //ManagerDAO.SetMemberToCompany(model.Id, companyItems); 20190912 Joe 問題單,目前尚無MemberToCompany這張表,故先註解 var group = GroupDAO.GetItems(); ViewBag.group = group; ViewBag.UploadUrl = Golbal.UpdFileInfo.GetVPathBySiteID(siteId).TrimEnd('/') + "/"; ViewBag.SiteID = siteId; return(View(model)); }
public ActionResult EditMemberInfo(long?ID) { ViewBag.UploadUrl = uploadUrl; MemberModels m = new MemberModels(); if (ID.HasValue) { m = ManagerDAO.GetItem((long)ID); ViewBag.IsNew = false; } else { ViewBag.IsNew = true; } var group = GroupDAO.GetItems(); ViewBag.group = group; ViewBag.ID = ID ?? 0; return(View(m)); }
public ActionResult Create(Group entity) { bool kiemtra = new GroupDAO().KiemTraGroupTonTai(entity); if (kiemtra == true) { SetAlert("Đã tồn tại nhóm trong hệ thống !", "success"); } else { long id = new GroupDAO().Insert(entity); if (id > 0) { SetAlert("Tạo mới thành công", "success"); return(RedirectToAction("Create", "Group"));//Action: Index, Controller: User neu OK } else { ModelState.AddModelError("", "Thêm nhóm không thành công !"); } } return(View("Create")); }
private void GetGroupData() { try { IDBController controller = new SqlController(); _currentGroup = controller.RetrieveGroup(Request["grouptag"]); } catch (ArgumentNullException) { // Shouldn't happen } catch (CouldNotFindException) { Response.Redirect(string.Format(@"Index.aspx?error={0}", HttpUtility.UrlEncode(@"An unknown error occurred. Please try again soon."))); return; } catch (SqlException ex) { Logger.LogMessage("ManageGroup.aspx.cs: " + ex.Message, LoggerLevel.SEVERE); Response.Redirect(string.Format("ManagePlugins.aspx?error={0}", HttpUtility.UrlEncode("An unknown error occurred. Please try again soon."))); return; } }