private RoleOpPvg GetRoleOpPvg(string roleName, int opId, int itemVal, int selfVal, int crewVal, int othersVal, bool addVal) { int pvgOfItem = GetCompositeValueOfPvg(itemVal, false); int pvgOfSubitemSelf = GetCompositeValueOfPvg(selfVal, addVal); int pvgOfSubitemCrew = GetCompositeValueOfPvg(crewVal, false); int pvgOfSubitemOthers = GetCompositeValueOfPvg(othersVal, false); RoleOpPvg roleOpPvg = new RoleOpPvg() { RoleName = roleName, OpId = opId, PvgOfItem = pvgOfItem, PvgOfSubitemSelf = pvgOfSubitemSelf, PvgOfSubitemCrew = pvgOfSubitemCrew, PvgOfSubitemOthers = pvgOfSubitemOthers }; return(roleOpPvg); }
public override ClientResult ProcessRequest() { ClientResult cr = null; roleName = GetParamValue("roleName"); string strOpId = GetParamValue("opId"); int opId = 0; string strItemVal = GetParamValue("itemVal"); int itemVal = 0; string strSelfVal = GetParamValue("selfVal"); int selfVal = 0; string strCrewVal = GetParamValue("crewVal"); int crewVal = 0; string strOthersVal = GetParamValue("othersVal"); int othersVal = 0; string strAddVal = GetParamValue("addVal"); bool addVal = false; string strRoleId = GetParamValue("roleId"); roleId = 0; if (!int.TryParse(strOpId, out opId)) { throw new Exception("opId is invalid"); } if (!int.TryParse(strItemVal, out itemVal)) { throw new Exception("itemVal is invalid"); } if (!int.TryParse(strSelfVal, out selfVal)) { throw new Exception("selfVal is invalid"); } if (!int.TryParse(strCrewVal, out crewVal)) { throw new Exception("crewVal is invalid"); } if (!int.TryParse(strOthersVal, out othersVal)) { throw new Exception("othersVal is invalid"); } if (!bool.TryParse(strAddVal, out addVal)) { throw new Exception("addVal is invalid"); } if (!int.TryParse(strRoleId, out roleId)) { throw new Exception("roleId is invalid"); } // authenticate empAuth = new EmployeeAuthorityLogic(c); empAuth.SetCustomEmployeeAuthorizationResult(this); empAuth.InitialAuthorizationResultOfSubPages(); if (!empAuth.CanEditThisPage()) { cr = new ClientResult() { b = false, err = "invalid authentication" }; return(cr); } // check limitation if (itemVal == 0 && selfVal > 0) { selfVal = 0; } if (selfVal < 2 && addVal == true) { addVal = false; } if (crewVal > selfVal) { crewVal = selfVal; } if (othersVal > crewVal) { othersVal = crewVal; } RoleOpPvg newPvg = GetRoleOpPvg(roleName, opId, itemVal, selfVal, crewVal, othersVal, addVal); // save into list in the session RoleOpPvg oldPvg = c.seRoleOpPvgs.Find(pvg => string.Compare(pvg.RoleName, roleName, true) == 0 && pvg.OpId == opId); if (oldPvg != null) { oldPvg.PvgOfItem = newPvg.PvgOfItem; oldPvg.PvgOfSubitemSelf = newPvg.PvgOfSubitemSelf; oldPvg.PvgOfSubitemCrew = newPvg.PvgOfSubitemCrew; oldPvg.PvgOfSubitemOthers = newPvg.PvgOfSubitemOthers; } else { c.seRoleOpPvgs.Add(newPvg); } cr = new ClientResult() { b = true, o = newPvg }; return(cr); }