private void EditUserGroup() { UserGroup curUserGroup; strName = NameComboBox.Text; curUserGroup = mainDataSet.GetGroupItem(strName); if (curUserGroup == null) { InputWarning.PlacementTarget = NewNameBox; WarningInfo.Text = "Selected User is not exists in DB."; InputWarning.IsOpen = true; return; } RefreshUsers(curUserGroup); curUserGroup.Description = strDescription; return; }
private void RefreshUserGroup(IfUser curUser) { bool bolIsExist; List <string> insertGroups; List <UserGroup> deleteGroups; //比较两表生成一个Insert表,一个Delete表 deleteGroups = new List <UserGroup>(); foreach (UserGroup curGroup in curUser.UserGroups) { bolIsExist = false; foreach (string sItem in UserGroups) { if (curGroup.Name == sItem) { bolIsExist = true; } } if (bolIsExist == false) { deleteGroups.Add(curGroup); } } insertGroups = new List <string>(); foreach (string sItem in UserGroups) { bolIsExist = false; foreach (UserGroup curGroup in curUser.UserGroups) { if (curGroup.Name == sItem) { bolIsExist = true; } } if (bolIsExist == false) { insertGroups.Add(sItem); } } if (deleteGroups.Count != 0) { foreach (UserGroup curGroup in deleteGroups) { curUser.UserGroups.Remove(curGroup); curGroup.Users.Remove(curUser); } } if (insertGroups.Count != 0) { UserGroup newGroup; foreach (string curItem in insertGroups) { newGroup = mainDataSet.GetGroupItem(curItem); if (newGroup == null) { continue; } curUser.UserGroups.Add(newGroup); newGroup.Users.Add(curUser); } } }
private bool InputVarification() { const string strExtractPattern = @"[\u4E00-\u9FA5A-Za-z0-9_]+"; //匹配目标"Step:+Handler:"组合 MatchCollection matches; Regex regObj; //用户名 if (IsCreateCheckBox.IsChecked == true) { strName = NewNameBox.Text; if (strName == "") { InputWarning.PlacementTarget = NewNameBox; WarningInfo.Text = "Please enter a non-empty value."; InputWarning.IsOpen = true; return false; } regObj = new Regex(strExtractPattern);//正则表达式初始化,载入匹配模式 matches = regObj.Matches(strName);//正则表达式对分词结果进行匹配 if (matches.Count == 0) { InputWarning.PlacementTarget = NewNameBox; WarningInfo.Text = "Name field only include Chinese, English, Underline characters."; InputWarning.IsOpen = true; return false; } } else { //绑定步骤检查 int index = 0; newProceSteps = new List<ProcedureStep>(); ProcedureStep newPStep, previousStep = null; foreach(StepStore newStep in newSteps) { newPStep = new ProcedureStep(newStep.Name, index, newStep.IsFeedback, newStep.Description); newPStep.HandleRole = mainDataSet.GetGroupItem(newStep.HandleGroup); newPStep.HandleRole.BindingStep.Add(newPStep); if (previousStep != null) { previousStep.NextStep = newPStep; newPStep.PreviousStep = previousStep; } newProceSteps.Add(newPStep); previousStep = newPStep; index++; } } //任务类型 strType = TypeComboBox.Text; if(strType != null) { regObj = new Regex(strExtractPattern);//正则表达式初始化,载入匹配模式 matches = regObj.Matches(strType);//正则表达式对分词结果进行匹配 if (matches.Count == 0) { InputWarning.PlacementTarget = TypeComboBox; WarningInfo.Text = "Type field only include Chinese, English, Underline characters."; InputWarning.IsOpen = true; return false; } } //描述 strDescription = DescriptionBox.Text; if (strDescription == "") { InputWarning.PlacementTarget = DescriptionBox; WarningInfo.Text = "Please enter a non-empty value."; InputWarning.IsOpen = true; return false; } return true; }