コード例 #1
0
ファイル: ControlController.cs プロジェクト: Gnail-nehc/Black
 public ActionResult Create(Control instance)
 {
     ActionResult ar = VerifyIfProjectSelected("PRJNAME");
     if (null != ar) return ar;
     ViewBag.Title = "Create Control";
     ClearSessions();
     string requestKey = Request.Form.Keys[Request.Form.Keys.Count - 1] as string;
     if (requestKey.Contains(".")) requestKey = requestKey.Substring(0, requestKey.IndexOf("."));
     if (requestKey == "save")
     {
         if (ModelState.IsValid)
         {
             string log = "";
             this.ControlService.CurrentProjectId = (int)Session["PID"];
             bool isSuccess = this.ControlService.AddControl(instance.ControlProperty.Type,instance.ControlProperty.Property,instance.PropertyValue,instance.Name, out log);
             if (isSuccess)
             {
                 Session["HasQueried_c"] = null;
                 return RedirectToAction("Index");
             }
             ViewBag.Log = log;
         }
         return View("Create", new Control());
     }
     Session["Log_c"] = null;
     Session["HasQueried_c"] = null;
     return RedirectToAction("Index");
 }
コード例 #2
0
ファイル: ControlService.cs プロジェクト: Gnail-nehc/Black
 public bool AddControl(string controlType, string controlProperty, string propertyValue, string controlName, out string log)
 {
     Guard.ArgumentNotNullOrEmpty(controlType, "controlType");
     Guard.ArgumentNotNullOrEmpty(controlProperty, "controlProperty");
     if (null == propertyValue) propertyValue = "";
     Guard.ArgumentNotNullOrEmpty(controlName, "controlName");
     int pid = (this.CurrentProjectId > 0) ? this.CurrentProjectId : 1;
     bool isUnique = this.ControlRepository.IsControlNameUniqueInSameTypeAndProperty(pid, controlType, controlProperty, controlName);
     if (isUnique)
     {
         log = "done.";
         int propId = this.ControlPropertyRepository.QueryPropertyId(controlType,controlProperty);
         Control instance = new Control();
         instance.ProjectId = pid;
         instance.PropertyId = propId;
         instance.PropertyValue = propertyValue;
         instance.Name = controlName;
         return this.ControlRepository.AddControl(instance,out log);
     }
     else
     {
         log = "Fail to Add.The control name should be unique for " + controlType + " in Project " + pid.ToString();
     }
     return isUnique ;
 }
コード例 #3
0
ファイル: ControlController.cs プロジェクト: Gnail-nehc/Black
 private ActionResult Save(Control updatedItem,int pageIndex)
 {
     int cid = updatedItem.Id;
     if (null != updatedItem.Name || null != updatedItem.ControlProperty.Property)
     {
         this.ControlService.CurrentProjectId = (int)Session["PID"];
         string log = "";
         bool isSuccess = this.ControlService.UpdateControl(cid,updatedItem.ControlProperty.Type,
             updatedItem.ControlProperty.Property,updatedItem.PropertyValue,updatedItem.Name, out log);
         if (isSuccess)
         {
             Session["Log_c"] = null;
             Session["UpdatedId_c"] = null;
             Session["PropertyListWhenEdit"] = null;
             return RedirectToAction("Index", new { pageIndex = pageIndex });
         }
         Session["Log_c"] = log;
         return Edit(cid, updatedItem.ControlProperty.Property, pageIndex);
     }
     Session["Log_c"] = "Control Type, Property, Name Required!";
     return Edit(cid, updatedItem.ControlProperty.Property, pageIndex);
 }
コード例 #4
0
ファイル: ControlService.cs プロジェクト: Gnail-nehc/Black
 public bool UpdateControl(int id, string controlType, string controlProperty, string newPropertyValue, string newName, out string log)
 {
     Guard.ArgumentNotNullOrEmpty(controlType, "controlType");
     Guard.ArgumentNotNullOrEmpty(controlProperty, "controlProperty");
     if (null == newPropertyValue) newPropertyValue = "";
     Guard.ArgumentNotNullOrEmpty(newName, "controlName");
     int pid = (this.CurrentProjectId > 0) ? this.CurrentProjectId : 1;
     string property = this.GetControlPropertyById(id);
     string controlName = this.ControlRepository.GetControlById(id).Name;
     bool isUnique = true;
     bool ifChanged = (property.Equals(controlProperty) && controlName.Equals(newName)) ? false : true;
     if (ifChanged)
     {
         isUnique = this.ControlRepository.IsControlNameUniqueInSameTypeAndProperty(pid, controlType, controlProperty, newName);
     }
     if (isUnique)
     {
         int propId = this.ControlPropertyRepository.QueryPropertyId(controlType, controlProperty);
         Control instance = new Control() { Id = id, ProjectId = pid, PropertyId = propId, PropertyValue = newPropertyValue, Name = newName };
         this.ControlRepository.UpdateControl(instance,out log);
     }
     else
     {
         log = "Fail to Update.The control name should be unique for " + controlType + " in Project " + pid.ToString();
     }
     return isUnique;
 }