Exemple #1
0
 public PageExpression GetPage(AchieveRequest request)
 {
     var result = new PageExpression();
     try
     {
         PageLogger.RecordInfoLog(String.Format("GetPage {0}.{1}", request.Id, request.UserName));
         var user = UserInfoMaintenance.Instance[request.UserName];
         if (user != null && user.Token == request.UserToken)
         {
             result.Result = ResponseResult.Success;
             var example = PageExampleMaintenance.Instance.AddPageExample(request, user.GetAdminIdx());
             if (example != null)
             {
                 example.Refresh();
                 result = example.Expression;
             }
         }
         else
         {
             result.Result = ResponseResult.UnAuthenticate;
         }
     }
     catch (Exception ex)
     {
         result.Result = ResponseResult.Fault;
         PageLogger.RecordErrorLog("GetPage", ex);
     }
     return result;
 }
        private static List<PageParameter> EvaluateParameters(AchieveRequest request, PageScheme scheme)
        {
            List<PageParameter> result = new List<PageParameter>();
            foreach (var item in scheme.Parameters)
	        {
		        result.Add(item.Clone() as PageParameter);
	        }
            return result;
        }
 public static PageContext TransformToPageContext(AchieveRequest request, PageScheme scheme)
 {
     var result = new PageContext();
     result.Id = request.Id;
     result.Parameters = request.Parameters;
     result.UserToken = request.UserToken;
     EvaluatePage(request, scheme, result);
     return result;
 }
 public PageExample AddPageExample(AchieveRequest request, Int32 adminIdx)
 {
     var context = PageContextMaintenance.Instance.GetPageContext(request, adminIdx);
     var example = new PageExample();
     example.Expression = context.Expression.Clone() as PageExpression;
     example.Expression.InstanceId = request.InstanceId;
     example.Evaluataion = context.Evaluataion.Clone() as PageEvaluataion;
     example.InstanceId = request.InstanceId;
     example.Response = new PageResponse();
     example.Response.InstanceId = request.InstanceId;
     m_PageExamples.TryAdd(example.InstanceId, example);
     PageResolveParameterce.Instance.Resolve(example);
     return example;
 }
 public PageContext GetPageContext(AchieveRequest request, Int32 adminIdx)
 {
     PageContext context = null;
     if (!m_PageContexts.TryGetValue(request.Key, out context))
     {
         var scheme = PageSchemeMaintenance.Instance.GetScheme(request.Id, adminIdx);
         if (scheme != null)
         {
             PageLogger.RecordInfoLog(String.Format("GetPageContext {0},{1},{2},{3}", request.Id, adminIdx, scheme.Id, scheme.IsDefault));
             context = PageContextTransform.TransformToPageContext(request, scheme);
             AddPageContext(context);
         }
     }
     return context;
 }
 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;
 }
Exemple #7
0
 public void TestPageParameterTransform()
 {
     var scheme = PageSchemeTransform.TransformToPageScheme(content);
     var request = new AchieveRequest();
     request.Id = scheme.Id;
     request.InstanceId = Guid.NewGuid().ToString();
     request.Parameters = "InputSite1=12&InputEquipment1=34";
     var context = PageContextTransform.TransformToPageContext(request, scheme);
     bool result = true;
     try
     {
         PageParameterTransform.TransformToPropertyEvaluataion(context.Evaluataion);
     }
     catch
     {
         result = false;
     }
     Assert.IsTrue(result);
 }
Exemple #8
0
 public void TestPageContextTransform()
 {
     var scheme = PageSchemeTransform.TransformToPageScheme(content);
     var request = new AchieveRequest();
     request.Id = scheme.Id;
     request.InstanceId = Guid.NewGuid().ToString();
     request.Parameters = "InputSite1=12&InputEquipment1=34";
     var context = PageContextTransform.TransformToPageContext(request, scheme);
     Assert.IsNotNull(context);
     Assert.IsNotNull(context.Evaluataion);
     Assert.IsNotNull(context.Expression);
     Assert.AreNotEqual(context.Expression.Children[0], scheme.Children[0]);
 }