private Int32 ResolveProperty(PageExample example, PageEvaluataion page, ControlEvaluataion control) { var dynamicTotlal = 0; foreach (var property in control.Propertys) { if (!String.IsNullOrEmpty(property.OrignalScript)) { try { var scripts = ScriptUtility.GetMatchedScriptFromProperty(property.OrignalScript); foreach (Match script in scripts) { property.OrignalScript = property.OrignalScript.Replace( script.Value, PropertyValueTransform.TransformToScript(page, script.Value)); } ComplieScript(property); dynamicTotlal++; } catch (Exception ex) { PageLogger.RecordErrorLog("ResolvePageProperty", ex); } } } return dynamicTotlal; }
public static void TransformToPropertyEvaluataion(PageEvaluataion page) { AdditionalParameter(page); if (String.IsNullOrEmpty(page.InputParameters)) return; TransformInputParameter(page); ReplaceValueByInputParameter(page); }
public static String TransformToScript(PageEvaluataion page, String script) { var result = ScriptUtility.TrimParameter(script); var parameter = page.PageParameters.FirstOrDefault(p => p.Name == result); if (parameter != null) { var scriptPattern = ParameterTypeMapScritptUtility.MapToScript(parameter.Type); scriptPattern = String.Format(scriptPattern, parameter.Value); result = result.Replace(result, scriptPattern); } return result; }
private static void AdditionalParameter(PageEvaluataion page) { CreateParameter(page, "InputUserName1", DataTypeEnum.User.ToString(), page.InputUserName); CreateParameter(page, "InputHost1", DataTypeEnum.Host.ToString(), String.Empty); CreateParameter(page, "InputGroup1", DataTypeEnum.Group.ToString(), String.Empty); CreateParameter(page, "InputSite1", DataTypeEnum.Site.ToString(), String.Empty); CreateParameter(page, "InputEquipment1", DataTypeEnum.Equipment.ToString(), String.Empty); CreateParameter(page, "InputSignal1", DataTypeEnum.Signal.ToString(), String.Empty); CreateParameter(page, "InputCommand1", DataTypeEnum.Command.ToString(), String.Empty); CreateParameter(page, "InputCommandDO1", DataTypeEnum.CommandDO.ToString(), String.Empty); CreateParameter(page, "InputAffair1", DataTypeEnum.Affair.ToString(), String.Empty); CreateParameter(page, "InputNode1", DataTypeEnum.Node.ToString(), String.Empty); }
private static void EvaluatePage(AchieveRequest request, PageScheme scheme, PageContext context) { var expression = new PageExpression(); var evaluate = new PageEvaluataion(); expression.Id = request.Id; expression.InstanceId = request.InstanceId; expression.Meta = scheme.Meta.Clone() as PageMeta; evaluate.InputParameters = request.Parameters; evaluate.InputUserName = request.UserName; evaluate.InputUserToken = request.UserToken; evaluate.PageParameters = EvaluateParameters(request, scheme); EvaluatePageControl(scheme, expression, evaluate); context.Expression = expression; context.Evaluataion = evaluate; }
public object Clone() { var result = new PageEvaluataion(); result.InputUserName = InputUserName; result.InputUserToken = InputUserToken; result.InputParameters = InputParameters; foreach (var item in PageParameters) { result.PageParameters.Add(item.Clone() as PageParameter); } foreach (var item in PageControls) { result.PageControls.Add(item.Clone() as ControlEvaluataion); } return result; }
public static String TransformToScript(PageEvaluataion page, String instanceId, String invokerId, String eventName, String script) { var result = String.Empty; var scripts = script.Split(new String[] { CommonSeparator.SCRIPT }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < scripts.Length; i++) { var eventlist = scripts[i].Split(new String[] { CommonSeparator.EVNETTYPE }, StringSplitOptions.RemoveEmptyEntries); if (eventlist.Length > 1) { EventTypeEnum eventType = EventTypeEnum.Change; if (Enum.TryParse<EventTypeEnum>(eventlist[0], out eventType)) { result += ParseChange(eventType, eventlist[1], instanceId, invokerId, eventName); } } } return result; }
private static void RecursionEvaluatePageControl(PageControl control, PageControl expression, PageEvaluataion evaluate) { var expressionControl = control.Clone() as PageControl; expressionControl.Children.Clear(); var evaluationControl = new ControlEvaluataion(); evaluationControl.ControlId = control.Id; EvaluatePageControlProperty(control, expressionControl, evaluationControl); EvaluatePageControlEvent(control, expressionControl, evaluationControl); expression.Children.Add(expressionControl); if (evaluationControl.Propertys.Count > 0 || evaluationControl.Events.Count > 0) { evaluate.PageControls.Add(evaluationControl); } foreach (var child in control.Children) { RecursionEvaluatePageControl(child, expressionControl, evaluate); } }
private static void TransformInputParameter(PageEvaluataion page) { var parameters = ParameterTypeMapScritptUtility.ParseParameter(page.InputParameters); foreach (var parameter in parameters) { var contextParameter = page.PageParameters .FirstOrDefault(p => p.Name == parameter.Key); if (contextParameter != null) { contextParameter.Value = parameter.Value; } else { var pType = GetInputParameterType(parameter.Key); if (!String.IsNullOrEmpty(pType)) { CreateParameter(page, parameter.Key, pType, parameter.Value); } } } }
private static void ReplaceValueByInputParameter(PageEvaluataion page) { foreach (var parameter in page.PageParameters) { if (parameter.Value.Contains(INPUT)) { var parameterValues = parameter.Value.Split(COMMA); foreach (var parameterValue in parameterValues) { if (parameterValue.StartsWith(INPUT)) { var contextParameter = page.PageParameters .FirstOrDefault(p => p.Name == parameterValue); if (contextParameter != null) { parameter.Value = parameter.Value .Replace(contextParameter.Name, contextParameter.Value); } } } } } }
private Int32 ResolveEvent(PageExample example, PageEvaluataion page, ControlEvaluataion control) { var dynamicTotlal = 0; foreach (var events in control.Events) { if (!String.IsNullOrEmpty(events.OrignalScript)) { try { events.OrignalScript = EventValueTransform.TransformToScript(page, example.InstanceId, control.ControlId, events.Name, events.OrignalScript); ComplieScript(events); dynamicTotlal++; } catch (Exception ex) { PageLogger.RecordErrorLog("ResolvePageProperty", ex); } } } return dynamicTotlal; }
private static void CreateParameter(PageEvaluataion page, String pName, String pType, String pValue) { var tempParameter = page.PageParameters.FirstOrDefault(p => p.Name == pName); if (tempParameter == null) { tempParameter = new PageParameter(); tempParameter.Name = pName; tempParameter.Type = pType; tempParameter.Value = pValue; page.PageParameters.Add(tempParameter); } else { tempParameter.Value = pValue; } }