public Form_PolicyProperties(RequestedOperation op) { InitializeComponent(); m_RequestedOperation = op; ultraTabControl1.DrawFilter = new HideFocusRectangleDrawFilter(); }
public static bool Process(Policy importingPolicy, bool allowEdit, RequestedOperation op) { Form_PolicyProperties frm = new Form_PolicyProperties(op); frm.InitializeDialog(importingPolicy, allowEdit); // return true if updated, otherwise false return(DialogResult.Cancel != frm.ShowDialog()); }
public static bool Process(int policyId, int assessmentId, bool allowEdit, RequestedOperation op, int metricId) { Form_PolicyProperties frm = new Form_PolicyProperties(op); frm.InitializeDialog(policyId, assessmentId, allowEdit, metricId); // return true if updated, otherwise false return(DialogResult.Cancel != frm.ShowDialog()); }
public override int GetHashCode() { unchecked { var hashCode = (FinishedAt != null ? FinishedAt.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Message != null ? Message.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RequestedOperation != null ? RequestedOperation.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Phase != null ? Phase.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RetryCount != null ? RetryCount.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (StartedAt != null ? StartedAt.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SyncResult != null ? SyncResult.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Setup for the VersionRule object. Since we consider this object to be an immutable type, we restrict the /// constructor to this methof and require these setup values to be passed. /// </summary> /// <param name="newActionType">See property "ActionType".</param> /// <param name="newIsPublic">See property "IsPublic".</param> /// <param name="newIsRetired">See property "IsRetired".</param> /// <param name="newNameRequiredAction">See property "NameRequiredAction".</param> /// <param name="newMajorRequiredAction">See property "MajorRequiredAction".</param> /// <param name="newMinorRequiredAction">See property "MinorRequiredAction".</param> /// <param name="newBuildRequiredAction">See property "BuildRequiredAction".</param> /// <param name="newRevisionRequiredAction">See property "RevisionRequiredAction".</param> public Rule(RequestedOperation newActionType, bool newIsPublic, bool newIsRetired, RequiredChange newNameRequiredAction, RequiredChange newMajorRequiredAction, RequiredChange newMinorRequiredAction, RequiredChange newBuildRequiredAction, RequiredChange newRevisionRequiredAction) { ActionType = newActionType; IsPublic = newIsPublic; IsRetired = newIsRetired; NameRequiredChange = newNameRequiredAction; MajorRequiredChange = newMajorRequiredAction; MinorRequiredChange = newMinorRequiredAction; BuildRequiredChange = newBuildRequiredAction; RevisionRequiredChange = newRevisionRequiredAction; }
/// <summary> /// Checks the rules for versioning. If the rules are incorrect, it returns false and a string detailing what the error /// was, and a human readable string to display to the user. /// </summary> /// <param name="workflowToCheck">the StoreActivity record we care about versioning</param> /// <param name="requestedOperation">The state of the object being saved. I.e., is this a new record, an update, etc. /// Save, AddNew, Compile (and for future use), Delete. "Null" means "figure it out from what's in the database"</param> /// <param name="workflowRecordState">Public, Private, Retired. </param> /// <param name="userName">the user making the request</param> /// <returns> /// a tuple with a bool indicating pass/fail and a description of what needs to change (if any) /// Message is a message describing the problem, and Rule is the rule that was applied/tested against. /// </returns> public static Tuple<bool, string, Rule> CheckVersioningRules(StoreActivitiesDC workflowToCheck, RequestedOperation? requestedOperation, string userName) { var isRulePassed = true; bool isPublic; bool isRetired; var errorString = String.Empty; var previousVersions = Activities.StoreActivitiesGetByName(workflowToCheck.Name, userName); Rule rule = null; if (!IsValidMarketplaceVersion(workflowToCheck.Version)) throw new VersionException(string.Format(InvalidVersionNumberMessage, workflowToCheck.Version), null); previousVersions = previousVersions.Where(item => Version.Parse(item.Version) >= Version.Parse(workflowToCheck.Version)).ToList(); if (null == requestedOperation) requestedOperation = previousVersions.Any() ? RequestedOperation.Update : RequestedOperation.AddNew; if (!string.IsNullOrEmpty(workflowToCheck.StatusCodeName)) workflowToCheck.WorkflowRecordState = (WorkflowRecordState)Enum.Parse(typeof(WorkflowRecordState), workflowToCheck.StatusCodeName); if (null == workflowToCheck.WorkflowRecordState) workflowToCheck.WorkflowRecordState = WorkflowRecordState.Private; isPublic = workflowToCheck.WorkflowRecordState == WorkflowRecordState.Public; isRetired = workflowToCheck.WorkflowRecordState == WorkflowRecordState.Retired; if ((previousVersions.Count == 0) && !isPublic) return new Tuple<bool, string, Rule>(true, String.Empty, null); // find the rule that matches the current condition var ruleQuery = (from candidateRule in versioningRules where (candidateRule.ActionType == requestedOperation) && (candidateRule.IsPublic == isPublic) && (candidateRule.IsRetired == isRetired) select candidateRule) .ToList(); if (ruleQuery.Any()) { rule = ruleQuery.First(); if (rule.NameRequiredChange != RequiredChange.NoActionRequired) { // VersionRequiredActionEnum.MustChange is the only valid action here - check to make sure this name does not exist in the database isRulePassed = (previousVersions.Count == 0); if (!isRulePassed) errorString += string.Format(NameMustBeChangedMessage); } var major = GetVersionSection(workflowToCheck.Version, Section.Major); if ((from workflow in previousVersions where GetVersionSection(workflow.Version, Section.Major) > major select workflow).Any()) { isRulePassed = false; errorString += string.Format(MustBeIncrementedMessage, Section.Major.ToString()); } // when checking minor, build, revision, we only care about number ranges within the major build. // for instance, there can be a build 5 in major version 2, even though the max build number might be 10 in another major version previousVersions = (from workflow in previousVersions where GetVersionSection(workflow.Version, Section.Major) == major select workflow) .ToList(); isRulePassed &= CheckVersionSection(rule, Section.Major, previousVersions, workflowToCheck, ref errorString); isRulePassed &= CheckVersionSection(rule, Section.Minor, previousVersions, workflowToCheck, ref errorString); isRulePassed &= CheckVersionSection(rule, Section.Build, previousVersions, workflowToCheck, ref errorString); isRulePassed &= CheckVersionSection(rule, Section.Revision, previousVersions, workflowToCheck, ref errorString); } else { // TODO: Provide the correct associated error code when the error handling refactoring is performed. throw new BusinessException(-1, string.Format(NoRuleDefinedMessage, requestedOperation, workflowToCheck.WorkflowRecordState)); } return new Tuple<bool, string, Rule>(isRulePassed, errorString.Trim(), rule); }