public IGenericResponseResult DeleteCondition(WhereClauseRegisterCondition condition, [FromUri] string currentKey) { var updatedConditions = _conditionService.RemoveCondition(condition, currentKey); return(new GenericResponseResult <ICollection <Condition> > { ResultObject = updatedConditions }); }
public IGenericResponseResult CreateCondition(WhereClauseRegisterCondition condition) { var realCondition = condition.RealCondition; if (realCondition == null) { throw new InvalidOperationException("error creating condition"); } var storedCondition = _dao.Save(realCondition); return(new GenericResponseResult <Condition> { ResultObject = storedCondition, SuccessMessage = "Condition successfully created" }); }
public void Register(string applicationName, String query, WhereClauseRegisterCondition condition = null, bool validate = true) { if (validate) { Validate(applicationName); } var configKey = String.Format(WcConfig, ConfigTypes.WhereClauses.GetRootLevel(), applicationName); if (!_appStarted) { _toRegister.Add(Tuple.Create(configKey, query, condition)); } else { DoRegister(configKey, query, condition); } }
public IList <Condition> RemoveCondition(WhereClauseRegisterCondition condition, string currentCategoryKey) { var values = _dao.FindByQuery <PropertyValue>(PropertyValue.ByCondition, condition); var canDeleteCondition = !condition.Global || values.Count <= 1; foreach (var propertyValue in values) { if (propertyValue.Definition.FullKey.StartsWith(currentCategoryKey) || !condition.Global) { _dao.Delete(propertyValue); } } if (canDeleteCondition) { _dao.Delete(condition.RealCondition); } return(_dao.FindAll <Condition>(typeof(Condition))); }
private void CreateReportWhereClauses() { //Adding Hardware Repair Report default where clause var HardwareReportCondition = new WhereClauseRegisterCondition { Alias = "hardwarerepair", UserProfile = ProfileType.Itc.GetName(), AppContext = new ApplicationLookupContext { Schema = "hardwarerepair" } }; _wcFacade.Register("incident", "@reportWhereClauseProvider.HardwareRepairReportWhereClauseWithR17", HardwareReportCondition); HardwareReportCondition = new WhereClauseRegisterCondition { Alias = "hardwarerepair", AppContext = new ApplicationLookupContext { Schema = "hardwarerepair" }, Module = "xitc" }; _wcFacade.Register("incident", "@reportWhereClauseProvider.HardwareRepairReportWhereClauseWithR17", HardwareReportCondition); HardwareReportCondition = new WhereClauseRegisterCondition { Alias = "hardwarerepair", AppContext = new ApplicationLookupContext { Schema = "hardwarerepair" }, Module = Conditions.AnyCondition }; _wcFacade.Register("incident", "@reportWhereClauseProvider.HardwareRepairReportWhereClause", HardwareReportCondition); //Adding Tape BackUp Report default where clause var TapeBackReportCondition = new WhereClauseRegisterCondition { Alias = "tapebackupreport", UserProfile = ProfileType.Itc.GetName(), AppContext = new ApplicationLookupContext { Schema = "tapebackupreport" } }; _wcFacade.Register("incident", "@reportWhereClauseProvider.TapeBackupReportWhereClauseWithR17", TapeBackReportCondition); TapeBackReportCondition = new WhereClauseRegisterCondition { Alias = "tapebackupreport", AppContext = new ApplicationLookupContext { Schema = "tapebackupreport" }, Module = "xitc" }; _wcFacade.Register("incident", "@reportWhereClauseProvider.TapeBackupReportWhereClauseWithR17", TapeBackReportCondition); TapeBackReportCondition = new WhereClauseRegisterCondition { Alias = "tapebackupreport", AppContext = new ApplicationLookupContext { Schema = "tapebackupreport" }, Module = Conditions.AnyCondition }; _wcFacade.Register("incident", "@reportWhereClauseProvider.TapeBackupReportWhereClause", TapeBackReportCondition); //Adding Group Report default where clause var GroupReportCondition = new WhereClauseRegisterCondition { Alias = "groupreport", AppContext = new ApplicationLookupContext { Schema = "groupreport" }, Module = Conditions.AnyCondition }; _wcFacade.Register("persongroupview", qc.DefaultGroupReportQuery, GroupReportCondition); //Adding Escalation Incident Report default where clause var EscalationIncidentReport = new WhereClauseRegisterCondition { Alias = "escalationincident", AppContext = new ApplicationLookupContext { Schema = "escalationincident" } }; _wcFacade.Register("incident", qc.DefaultEscalationIncidentQuery, EscalationIncidentReport); //Adding ITC Report default where clause var ITCReportCondition = new WhereClauseRegisterCondition { Alias = "itcreport", AppContext = new ApplicationLookupContext { Schema = "itcreport" }, Module = Conditions.AnyCondition }; _wcFacade.Register("persongroupview", qc.DefaultITCReportQuery, ITCReportCondition); var ITCReportComplementCondition = new WhereClauseRegisterCondition { Alias = "itcreportregionandarea", AppContext = new ApplicationLookupContext { Schema = "itcreportregionandarea" }, Module = Conditions.AnyCondition }; _wcFacade.Register("persongroupview", qc.DefaultITCReportRegionAndAreaQuery, ITCReportComplementCondition); // var RI101Condition = new WhereClauseRegisterCondition { // Alias = "RI101", // AppContext = new ApplicationLookupContext { Schema = "RI101Export" }, // Module = Conditions.AnyCondition // }; // // _wcFacade.Register("asset", "ASSET.STATUS = '120 ACTIVE'", RI101Condition); }
private void DoRegister(string configKey, string query, WhereClauseRegisterCondition condition) { if (condition != null && condition.Environment != null && condition.Environment != ApplicationConfiguration.Profile) { //we don´t need to register this property here. return; } if (condition == null) { //if no condition is passed, we just need to update the base definition data var definition = new PropertyDefinition { FullKey = configKey, Key = CategoryUtil.GetPropertyKey(configKey), StringValue = query, DataType = typeof(string).Name, Renderer = "whereclause", Alias = "", Contextualized = true }; _dao.Save(definition); return; } var savedDefinition = _dao.FindSingleByQuery <PropertyDefinition>(PropertyDefinition.ByKey, configKey); Condition storedCondition = null; if (condition.Alias != null) { //this means that we actually have a condition rather then just a simple utility class WhereClauseRegisterCondition storedCondition = _dao.FindSingleByQuery <WhereClauseCondition>(Condition.ByAlias, condition.Alias); if (storedCondition != null) { condition.Id = storedCondition.Id; } storedCondition = _dao.Save(condition.RealCondition); } var profile = new UserProfile(); if (condition.UserProfile != null) { profile = UserProfileManager.FindByName(condition.UserProfile); if (condition.UserProfile != null && profile == null) { Log.Warn(String.Format("unable to register definition as profile {0} does not exist", condition.UserProfile)); return; } } var storedValue = _dao.FindSingleByQuery <PropertyValue>( PropertyValue.ByDefinitionConditionModuleProfile, savedDefinition.FullKey, storedCondition, condition.Module, profile.Id); if (storedValue == null) { var newValue = new PropertyValue { Condition = storedCondition, Definition = savedDefinition, SystemStringValue = query, Module = condition.Module, UserProfile = profile.Id }; _dao.Save(newValue); } else { storedValue.SystemStringValue = query; _dao.Save(storedValue); } }