/// <summary> /// Check the settings file and restrict the operation if needed. /// </summary> /// <param name="eventArgs"></param> private void RestrictOperation(WebServiceCommandEventArgs eventArgs, string eventName) { RestrictSettings settings = RestrictSettings.Load(); if (settings.RestrictedOperations.Contains(eventName)) { eventArgs.AddRestriction(new ExtensionRestriction("Unknown", "Test restriction")); } }
/// <summary> /// Check the settings file and restrict the operation if needed. /// </summary> /// <param name="eventArgs"></param> private void RestrictOperation(WebServiceCommandEventArgs eventArgs, string eventName) { RestrictSettings settings = RestrictSettings.Load(); if (settings.RestrictedOperations.Contains(eventName)) { eventArgs.AddRestriction(new ExtensionRestriction("Parallel Approval - Change State", "The listed states are required to finally release: " + mParallelStates[0] + ", " + mParallelStates[1] + ", " + mParallelStates[2])); } }
// checks for a four eyes violation for a given file history private void CheckFile(File[] files, long toStateId, long currentUserId, LfCycState reviewState, LfCycState releaseState, WebServiceCommandEventArgs eventArgs) { // if we are not moving to released, don't event bother with the check if (toStateId != releaseState.Id) { return; } File maxFile = files.First(n => n.MaxCkInVerNum == n.VerNum); if (maxFile.FileRev == null) { return; } // gather all the files in the revision and arrange them by version IEnumerable <File> filesInRev = from n in files where n.FileRev.RevId == maxFile.FileRev.RevId orderby n.VerNum select n; File[] filesArray = filesInRev.ToArray(); long reviewUserId = -1; for (int i = 1; i < filesArray.Length; i++) { File f1 = filesArray[i - 1]; File f2 = filesArray[i]; // compare two concecutive file versions to determine // where a state changed happened if (f1.FileLfCyc != null && f2.FileLfCyc != null && f1.FileLfCyc.LfCycStateName != f2.FileLfCyc.LfCycStateName && f2.VerNum - f1.VerNum == 1) { // f2 is a version where the state changed if (f2.FileLfCyc.LfCycStateName == reviewState.DispName) { reviewUserId = f2.CreateUserId; } } } if (reviewUserId > 0 && currentUserId == reviewUserId) { // the same person reviewed the file in an earlier version eventArgs.AddRestriction( new ExtensionRestriction(maxFile.Name, "File cannot be reviewed and released by the same person")); } }
private void RestrictRelease(WebServiceCommandEventArgs eventArgs, string eventName, string mFileName, string[] mStates) { string mStateNames = ""; for (int i = 0; i < mStates.Count(); i++) { mStateNames = mStateNames + ", " + mStates[i]; } eventArgs.AddRestriction(new ExtensionRestriction(mFileName, "The listed predecessing states are expected to release: " + mStateNames)); }