Exemplo n.º 1
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         StringBuilder output = null;
         if (interpreterType == InterpreterTypeCode.Output)
         {
             output = templateContext.OutputCodeBuilder;
         }
         else
         {
             output = templateContext.ContentCodeBuilder;
         }
         string propertyValue = GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
         if (!String.IsNullOrEmpty(propertyValue))
         {
             output.Append(propertyValue);
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 2
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         if (GrammarHelper.IsReservedWord(VariableName) == true)
         {
             throw new System.Exception(String.Format(DisplayValues.Message_TemplateVariableConflict, VariableName));
         }
         if (templateContext.Variables.HasKey(VariableName) == true)
         {
             throw new System.Exception(String.Format(DisplayValues.Message_TemplateVariableAlreadyDeclared, VariableName));
         }
         if (Parameter != null)
         {
             templateContext.Variables[VariableName] = Parameter.GetObjectValue(solutionContext, templateContext, modelContext, interpreterType);
         }
         else
         {
             templateContext.Variables[VariableName] = String.Empty;
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 3
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         string parameterValue = String.Empty;
         if (Text != null)
         {
             parameterValue = Text.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
         }
         string message = ShowDebugMessage(solutionContext, templateContext, modelContext, parameterValue, false);
         if (FilePath != null)
         {
             string path = FilePath.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
             FileHelper.AppendToFile(path, message);
         }
         MessageBox.Show(message, DisplayValues.Debug_Caption);
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 4
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         string parameterValue = Parameter.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
         if (TemplateProperty == LanguageTerms.TextProperty)
         {
             // reset content text
             templateContext.ContentCodeBuilder.Clear();
             templateContext.ContentCodeBuilder.Append(parameterValue);
         }
         else if (TemplateProperty == LanguageTerms.PathProperty)
         {
             // reset output text
             templateContext.OutputCodeBuilder.Clear();
             templateContext.OutputCodeBuilder.Append(parameterValue);
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         string path = FilePath.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
         if (!String.IsNullOrEmpty(path))
         {
             if (solutionContext.IsSampleMode == true)
             {
                 // don't perform delete of output files, just indicate it would be deleted
                 templateContext.MessageBuilder.Append("\r\nX ");
                 templateContext.MessageBuilder.Append(path);
             }
             else if (solutionContext.LoggedErrors.Count == 0)
             {
                 if (File.Exists(path) == true)
                 {
                     File.Delete(path);
                 }
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>Create the instance with the designer view and other data.</summary>
 ///
 /// <param name="templateName">The template name.</param>
 /// <param name="templateType">The template type.</param>
 /// <param name="ast">The abstract syntax tree reults.</param>
 /// <param name="sampleCode">Sample code from interpreter.</param>
 ///--------------------------------------------------------------------------------
 public CodeTemplateResultsViewModel(string templateName, InterpreterTypeCode templateType, TemplateNode ast, string sampleCode)
 {
     Name         = templateName;
     TemplateType = templateType;
     ResultsAST   = ast;
     SampleCode   = sampleCode;
     WorkspaceID  = Guid.NewGuid();
 }
Exemplo n.º 7
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         int itemIndex = 0;
         templateContext.ItemIndex = itemIndex;
         string directoryPath = DirectoryPath.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
         foreach (string filePath in GetFilePaths(directoryPath, Extensions))
         {
             templateContext.IsBreaking      = false;
             templateContext.IsContinuing    = false;
             solutionContext.CurrentFilePath = filePath.Replace("\\\\", "\\");
             solutionContext.CurrentFileText = FileHelper.GetText(filePath);
             foreach (IStatementNode node in Statements)
             {
                 if (node.HandleDebug(interpreterType, solutionContext, templateContext, modelContext) == false)
                 {
                     return;
                 }
                 if (templateContext.IsContinuing == true)
                 {
                     break;
                 }
                 if (templateContext.IsBreaking == true || templateContext.IsReturning == true)
                 {
                     templateContext.IsBreaking = false;
                     break;
                 }
                 if (node is BreakStatementNode)
                 {
                     templateContext.IsBreaking = true;
                     break;
                 }
                 if (node is ContinueStatementNode)
                 {
                     break;
                 }
                 if (node is ReturnStatementNode)
                 {
                     templateContext.IsReturning = true;
                     break;
                 }
                 node.InterpretNode(interpreterType, solutionContext, templateContext, modelContext);
             }
             itemIndex++;
             templateContext.ItemIndex = itemIndex;
         }
         templateContext.ItemIndex = 0;
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 8
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         templateContext.IsBreaking = false;
         while (Expression.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType) == true)
         {
             templateContext.IsContinuing = false;
             foreach (IStatementNode node in Statements)
             {
                 if (node.HandleDebug(interpreterType, solutionContext, templateContext, modelContext) == false)
                 {
                     return;
                 }
                 if (templateContext.IsContinuing == true)
                 {
                     break;
                 }
                 if (templateContext.IsBreaking == true || templateContext.IsReturning == true)
                 {
                     templateContext.IsBreaking = false;
                     break;
                 }
                 if (node is BreakStatementNode)
                 {
                     templateContext.IsBreaking = true;
                     break;
                 }
                 if (node is ContinueStatementNode)
                 {
                     break;
                 }
                 if (node is ReturnStatementNode)
                 {
                     templateContext.IsReturning = true;
                     break;
                 }
                 node.InterpretNode(interpreterType, solutionContext, templateContext, modelContext);
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 9
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         solutionContext.PutStringLoggedValue(Parameter1.GetStringValue(solutionContext, templateContext, modelContext, interpreterType), Parameter2.GetStringValue(solutionContext, templateContext, modelContext, interpreterType), Parameter3.GetStringValue(solutionContext, templateContext, modelContext, interpreterType));
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         TemplateProperty.InterpretContentAndOutput(solutionContext, templateContext, modelContext, modelContext);
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         templateContext.OutputCodeBuilder.Clear();
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         IDomainEnterpriseObject withModelContext = GetModelContext(solutionContext, templateContext, modelContext, interpreterType);
         templateContext.PushModelContext(withModelContext);
         templateContext.IsBreaking = false;
         if (withModelContext != null)
         {
             foreach (IStatementNode node in Statements)
             {
                 if (node.HandleDebug(interpreterType, solutionContext, templateContext, withModelContext) == false)
                 {
                     return;
                 }
                 if (templateContext.IsBreaking == true || templateContext.IsReturning == true)
                 {
                     templateContext.IsBreaking = false;
                     break;
                 }
                 if (node is BreakStatementNode)
                 {
                     templateContext.IsBreaking = true;
                     break;
                 }
                 if (node is ContinueStatementNode)
                 {
                     templateContext.IsContinuing = true;
                 }
                 if (node is ReturnStatementNode)
                 {
                     templateContext.IsReturning = true;
                     break;
                 }
                 node.InterpretNode(interpreterType, solutionContext, templateContext, withModelContext);
             }
         }
         templateContext.PopModelContext();
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 13
0
        ///--------------------------------------------------------------------------------
        /// <summary>Handle breakpoint.</summary>
        ///
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="lineNumber">The associated line number.</param>
        ///--------------------------------------------------------------------------------
        public void HandleBreakpoint(InterpreterTypeCode interpreterType, IDomainEnterpriseObject modelContext, int lineNumber)
        {
            SolutionDebugEventArgs args = new SolutionDebugEventArgs();

            args.InterpreterType = interpreterType;
            args.Solution        = Solution;
            args.TemplateContext = SpecTemplate;
            args.ModelContext    = modelContext;
            args.LineNumber      = lineNumber;
            if (interpreterType == InterpreterTypeCode.Content)
            {
                OnContentBreakpointReached(this, args);
            }
            else if (interpreterType == InterpreterTypeCode.Output)
            {
                OnOutputBreakpointReached(this, args);
            }
        }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         if (templateContext.Variables.HasKey(VariableName) == false)
         {
             throw new System.Exception(String.Format("The variable {0} has not been declared, cannot be assigned to.", VariableName));
         }
         templateContext.Variables[VariableName] = Parameter.GetObjectValue(solutionContext, templateContext, modelContext, interpreterType);
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 15
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         bool isCaseClauseExecuted = false;
         foreach (CaseClauseNode node in CaseClauses)
         {
             if (node.EvaluateConditions(solutionContext, ModelProperty.GetPropertyStringValue(solutionContext, templateContext, modelContext, modelContext, interpreterType)) == true)
             {
                 isCaseClauseExecuted = true;
                 foreach (IStatementNode statement in node.Statements)
                 {
                     if (statement is BreakStatementNode)
                     {
                         break;
                     }
                     statement.InterpretNode(interpreterType, solutionContext, templateContext, modelContext);
                 }
                 break;
             }
         }
         if (isCaseClauseExecuted == false)
         {
             foreach (IStatementNode statement in DefaultClause.Statements)
             {
                 if (statement is BreakStatementNode)
                 {
                     break;
                 }
                 statement.InterpretNode(interpreterType, solutionContext, templateContext, modelContext);
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 16
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     // only perform progress operations if not in sample mode
     if (solutionContext.IsSampleMode == false)
     {
         if (templateContext is SpecTemplate)
         {
             if (Parameter != null)
             {
                 // set build model work
                 int work = 0;
                 if (int.TryParse(Parameter.GetStringValue(solutionContext, templateContext, modelContext, interpreterType), out work) == true)
                 {
                     solutionContext.SetModelProgressWork(work);
                 }
             }
             else
             {
                 // increment build model progress
                 solutionContext.IncrementModelProgress();
             }
         }
         else if (templateContext is CodeTemplate)
         {
             if (Parameter != null)
             {
                 // set build code work
                 int work = 0;
                 if (int.TryParse(Parameter.GetStringValue(solutionContext, templateContext, modelContext, interpreterType), out work) == true)
                 {
                     solutionContext.SetCodeProgressWork(work);
                 }
             }
             else
             {
                 // increment build code progress
                 solutionContext.IncrementCodeProgress();
             }
         }
     }
 }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         StringBuilder output = null;
         if (interpreterType == InterpreterTypeCode.Output)
         {
             output = templateContext.OutputCodeBuilder;
         }
         else
         {
             output = templateContext.ContentCodeBuilder;
         }
         output.Clear();
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the collection context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="collectionType">The type of collection to get.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public IEnterpriseEnumerable GetCollection(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, ModelContextNode collectionType, InterpreterTypeCode interpreterType)
        {
            IDomainEnterpriseObject collectionContext = modelContext;

            if (ModelContext != null)
            {
                bool isValidContext;
                collectionContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
            }
            else if (CurrentItem != null)
            {
                collectionContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            else if (SpecCurrentItem != null)
            {
                collectionContext = SpecCurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            if (MethodName == LanguageTerms.FindAllMethod && ModelProperty != null)
            {
                IEnterpriseEnumerable collection = collectionType.GetCollection(solutionContext, templateContext, collectionContext);
                if (collection != null)
                {
                    return(collection.FindItems(ModelProperty.ModelPropertyName, Parameter.GetObjectValue(solutionContext, templateContext, modelContext, interpreterType)));
                }
            }
            else if (MethodName == LanguageTerms.GetEntityAndBasesCollection)
            {
                // TODO: condense ability to get extended collections
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    EnterpriseDataObjectList <Entity> entities = new EnterpriseDataObjectList <Entity>();
                    Entity currentEntity = collectionContext as Entity;
                    while (currentEntity != null)
                    {
                        entities.Add(currentEntity);
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(entities);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Property loopItem in currentEntity.PropertyList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (PropertyReference loopItem in currentEntity.PropertyReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (EntityReference loopItem in currentEntity.EntityReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Collection loopItem in currentEntity.CollectionList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Relationship loopItem in currentEntity.RelationshipList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Index loopItem in currentEntity.IndexList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Method loopItem in currentEntity.MethodList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.GetBaseAndEntitiesCollection)
            {
                // TODO: condense ability to get extended collections
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    EnterpriseDataObjectList <Entity> items = new EnterpriseDataObjectList <Entity>();
                    Entity currentEntity = collectionContext as Entity;
                    while (currentEntity != null)
                    {
                        items.Insert(0, currentEntity);
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Property loopItem in currentEntity.PropertyList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (PropertyReference loopItem in currentEntity.PropertyReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (EntityReference loopItem in currentEntity.EntityReferenceList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Collection loopItem in currentEntity.CollectionList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Relationship loopItem in currentEntity.RelationshipList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Index loopItem in currentEntity.IndexList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    while (currentEntity != null)
                    {
                        foreach (Method loopItem in currentEntity.MethodList)
                        {
                            items.Add(loopItem);
                        }
                        currentEntity = currentEntity.BaseEntity;
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.ExtendingEntitiesCollection)
            {
                if (collectionType.ModelContextName == "Entity" && collectionContext is Entity)
                {
                    return((collectionContext as Entity).ExtendingEntites);
                }
                else if (collectionType.ModelContextName == "Property")
                {
                    EnterpriseDataObjectList <Property> items = new EnterpriseDataObjectList <Property>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Property loopItem in loopEntity.PropertyList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "PropertyReference")
                {
                    EnterpriseDataObjectList <PropertyReference> items = new EnterpriseDataObjectList <PropertyReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (PropertyReference loopItem in loopEntity.PropertyReferenceList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "EntityReference")
                {
                    EnterpriseDataObjectList <EntityReference> items = new EnterpriseDataObjectList <EntityReference>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (EntityReference loopItem in loopEntity.EntityReferenceList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Collection")
                {
                    EnterpriseDataObjectList <Collection> items = new EnterpriseDataObjectList <Collection>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Collection loopItem in loopEntity.CollectionList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Relationship")
                {
                    EnterpriseDataObjectList <Relationship> items = new EnterpriseDataObjectList <Relationship>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Relationship loopItem in loopEntity.RelationshipList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Index")
                {
                    EnterpriseDataObjectList <Index> items = new EnterpriseDataObjectList <Index>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Index loopItem in loopEntity.IndexList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
                else if (collectionType.ModelContextName == "Method")
                {
                    EnterpriseDataObjectList <Method> items = new EnterpriseDataObjectList <Method>();
                    bool   isValidContext;
                    Entity currentEntity = Entity.GetModelContext(solutionContext, collectionContext, out isValidContext) as Entity;
                    if (currentEntity != null)
                    {
                        foreach (Entity loopEntity in currentEntity.ExtendingEntites)
                        {
                            foreach (Method loopItem in loopEntity.MethodList)
                            {
                                items.Add(loopItem);
                            }
                        }
                    }
                    return(items);
                }
            }
            else if (MethodName == LanguageTerms.PathRelationships)
            {
                if (collectionType.ModelContextName == "Relationship" && collectionContext is Entity)
                {
                    return((collectionContext as Entity).PathRelationships);
                }
            }
            return(null);
        }
Exemplo n.º 19
0
        ///--------------------------------------------------------------------------------
        /// <summary>Evaluate expression associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public bool EvaluateExpression(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, InterpreterTypeCode interpreterType)
        {
            string value = GetExpressionValue(solutionContext, templateContext, modelContext, interpreterType);

            if (String.IsNullOrEmpty(value) || value == "false")
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 20
0
        ///--------------------------------------------------------------------------------
        /// <summary>Evaluate expression associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public string GetExpressionValue(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, InterpreterTypeCode interpreterType)
        {
            string expression1Value = String.Empty;

            if (Expression1 != null)
            {
                expression1Value = Expression1.GetExpressionValue(solutionContext, templateContext, modelContext, interpreterType);
            }
            string expression2Value = String.Empty;

            if (Expression2 != null)
            {
                expression2Value = Expression2.GetExpressionValue(solutionContext, templateContext, modelContext, interpreterType);
            }
            if (String.IsNullOrEmpty(expression1Value))
            {
                expression1Value = "null";
            }
            if (String.IsNullOrEmpty(expression2Value))
            {
                expression2Value = "null";
            }
            long   expression1Long;
            long   expression2Long;
            double expression1Double;
            double expression2Double;

            if (Literal != null)
            {
                return(Literal.RawValue);
            }
            if (ModelProperty != null)
            {
                return(ModelProperty.GetPropertyStringValue(solutionContext, templateContext, modelContext, modelContext, interpreterType));
            }
            if (ModelContext != null)
            {
                bool isValidContext;
                IDomainEnterpriseObject nodeContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
                if (nodeContext == null)
                {
                    return("null");
                }
                else
                {
                    if (nodeContext.ID == Guid.Empty || nodeContext.ID == null)
                    {
                        return("null");
                    }
                    return(nodeContext.ID.ToString());
                }
            }
            else if (CurrentItem != null)
            {
                IDomainEnterpriseObject nodeContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
                if (nodeContext == null)
                {
                    return("null");
                }
                else
                {
                    return(nodeContext.ID.ToString());
                }
            }
            else if (SpecCurrentItem != null)
            {
                IDomainEnterpriseObject nodeContext = SpecCurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
                if (nodeContext == null)
                {
                    return("null");
                }
                else
                {
                    return(nodeContext.ID.ToString());
                }
            }
            else if (Expression1 != null && Expression2 != null)
            {
                if (BinaryOperator != null)
                {
                    switch (BinaryOperator.Operator)
                    {
                    case "||":
                        if (Expression1.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType) || Expression2.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType))
                        {
                            return("true");
                        }
                        return("false");

                    case "&&":
                        if (Expression1.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType) && Expression2.EvaluateExpression(solutionContext, templateContext, modelContext, interpreterType))
                        {
                            return("true");
                        }
                        return("false");

                    case "==":
                        if (expression1Value == expression2Value)
                        {
                            return("true");
                        }
                        return("false");

                    case "!=":
                        if (expression1Value != expression2Value)
                        {
                            return("true");
                        }
                        return("false");

                    case "<":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            if (expression1Long < expression2Long)
                            {
                                return("true");
                            }
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            if (expression1Double < expression2Double)
                            {
                                return("true");
                            }
                        }
                        else
                        {
                            if (expression1Value.Length < expression2Value.Length)
                            {
                                return("true");
                            }
                        }
                        return("false");

                    case ">":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            if (expression1Long > expression2Long)
                            {
                                return("true");
                            }
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            if (expression1Double > expression2Double)
                            {
                                return("true");
                            }
                        }
                        else
                        {
                            if (expression1Value.Length > expression2Value.Length)
                            {
                                return("true");
                            }
                        }
                        return("false");

                    case "<=":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            if (expression1Long <= expression2Long)
                            {
                                return("true");
                            }
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            if (expression1Double <= expression2Double)
                            {
                                return("true");
                            }
                        }
                        else
                        {
                            if (expression1Value.Length <= expression2Value.Length)
                            {
                                return("true");
                            }
                        }
                        return("false");

                    case ">=":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            if (expression1Long >= expression2Long)
                            {
                                return("true");
                            }
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            if (expression1Double >= expression2Double)
                            {
                                return("true");
                            }
                        }
                        else
                        {
                            if (expression1Value.Length >= expression2Value.Length)
                            {
                                return("true");
                            }
                        }
                        return("false");

                    default:
                        return("false");
                    }
                }
                else if (MathOperator != null)
                {
                    switch (MathOperator.Operator)
                    {
                    case "+":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            return((expression1Long + expression2Long).ToString());
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            return((expression1Double + expression2Double).ToString());
                        }
                        else
                        {
                            return(expression1Value + expression2Value);
                        }

                    case "-":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            return((expression1Long - expression2Long).ToString());
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            return((expression1Double - expression2Double).ToString());
                        }
                        else
                        {
                            return(expression1Value.Replace(expression2Value, ""));
                        }

                    case "*":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true)
                        {
                            return((expression1Long * expression2Long).ToString());
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true)
                        {
                            return((expression1Double * expression2Double).ToString());
                        }
                        break;

                    case "/":
                        if (long.TryParse(expression1Value, out expression1Long) == true && long.TryParse(expression2Value, out expression2Long) == true && expression2Long != 0)
                        {
                            return((expression1Long / expression2Long).ToString());
                        }
                        else if (double.TryParse(expression1Value, out expression1Double) == true && double.TryParse(expression2Value, out expression2Double) == true && expression2Double != 0.00)
                        {
                            return((expression1Double / expression2Double).ToString());
                        }
                        break;

                    default:
                        break;
                    }
                    return("null");
                }
            }
            else if (Expression1 != null)
            {
                return(Expression1.GetExpressionValue(solutionContext, templateContext, modelContext, interpreterType));
            }
            return("null");
        }
Exemplo n.º 21
0
 ///--------------------------------------------------------------------------------
 /// <summary>Handle debugging workflow.</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public bool HandleDebug(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     if (DebugHelper.DebugAction == DebugAction.Stop)
     {
         // cause subsequent statements to not execute
         return(false);
     }
     if (solutionContext.IsSampleMode == true)              // only allow debugging from designer side using sample mode
     {
         if (interpreterType == InterpreterTypeCode.Content)
         {
             if (templateContext.ContentBreakpoints.Contains(LineNumber) == true && DebugHelper.DebugAction != DebugAction.Breaking)
             {
                 // handle breakpoint
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     DebugHelper.DebugAction = DebugAction.Breaking;
                 }
                 // fire breaking event
                 solutionContext.HandleBreakpoint(interpreterType, templateContext, modelContext, LineNumber);
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     while (DebugHelper.DebugAction == DebugAction.Breaking)
                     {
                         Monitor.Wait(DebugHelper.DEBUG_OBJECT);
                     }
                 }
                 if (DebugHelper.DebugAction == DebugAction.Stop)
                 {
                     // cause subsequent statements to not execute
                     return(false);
                 }
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     DebugHelper.DebugAction = DebugAction.Continue;
                 }
             }
         }
         else if (interpreterType == InterpreterTypeCode.Output)
         {
             if (templateContext.OutputBreakpoints.Contains(LineNumber) == true && DebugHelper.DebugAction != DebugAction.Breaking)
             {
                 // handle breakpoint
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     DebugHelper.DebugAction = DebugAction.Breaking;
                 }
                 // fire breaking event
                 solutionContext.HandleBreakpoint(interpreterType, templateContext, modelContext, LineNumber);
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     while (DebugHelper.DebugAction == DebugAction.Breaking)
                     {
                         Monitor.Wait(DebugHelper.DEBUG_OBJECT);
                     }
                 }
                 if (DebugHelper.DebugAction == DebugAction.Stop)
                 {
                     // cause subsequent statements to not execute
                     return(false);
                 }
                 lock (DebugHelper.DEBUG_OBJECT)
                 {
                     DebugHelper.DebugAction = DebugAction.Continue;
                 }
             }
         }
     }
     return(true);
 }
Exemplo n.º 22
0
 ///--------------------------------------------------------------------------------
 /// <summary>Log an exception associated with this node.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 /// <param name="messageBody">The main body message to show.</param>
 /// <param name="interpreterType">The interpreter type, such as content or output.</param>
 ///--------------------------------------------------------------------------------
 public string LogException(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, string messageBody, InterpreterTypeCode interpreterType = InterpreterTypeCode.None)
 {
     return(templateContext.LogException(solutionContext, modelContext, messageBody, LineNumber, interpreterType));
 }
Exemplo n.º 23
0
 ///--------------------------------------------------------------------------------
 /// <summary>Log an exception associated with this node.</summary>
 ///
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 /// <param name="ex">The exception to show.</param>
 /// <param name="interpreterType">The interpreter type, such as content or output.</param>
 ///--------------------------------------------------------------------------------
 public string LogException(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, System.Exception ex, InterpreterTypeCode interpreterType = InterpreterTypeCode.None)
 {
     return(LogException(solutionContext, templateContext, modelContext, ex.Message + "\r\n" + ex.StackTrace, interpreterType));
 }
Exemplo n.º 24
0
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
 }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         if (CurrentItem != null)
         {
             if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentAuditProperty))
             {
                 if (solutionContext.CurrentAuditProperty != null)
                 {
                     AuditProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- AuditProperty: ").Append(solutionContext.CurrentAuditProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentCollection))
             {
                 if (solutionContext.CurrentCollection != null)
                 {
                     Collection.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Collection: ").Append(solutionContext.CurrentCollection.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEntity))
             {
                 if (solutionContext.CurrentEntity != null)
                 {
                     Entity.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Entity: ").Append(solutionContext.CurrentEntity.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEntityReference))
             {
                 if (solutionContext.CurrentEntityReference != null)
                 {
                     EntityReference.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- EntityReference: ").Append(solutionContext.CurrentEntityReference.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentEnumeration))
             {
                 if (solutionContext.CurrentEnumeration != null)
                 {
                     Enumeration.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Enumeration: ").Append(solutionContext.CurrentEnumeration.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentFeature))
             {
                 if (solutionContext.CurrentFeature != null)
                 {
                     Feature.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Feature: ").Append(solutionContext.CurrentFeature.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentIndex))
             {
                 if (solutionContext.CurrentIndex != null)
                 {
                     Index.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Index: ").Append(solutionContext.CurrentIndex.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentIndexProperty))
             {
                 if (solutionContext.CurrentIndexProperty != null)
                 {
                     IndexProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- IndexProperty: ").Append(solutionContext.CurrentIndexProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentMethod))
             {
                 if (solutionContext.CurrentMethod != null)
                 {
                     Method.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Method: ").Append(solutionContext.CurrentMethod.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentMethodRelationship))
             {
                 if (solutionContext.CurrentMethodRelationship != null)
                 {
                     MethodRelationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- MethodRelationship: ").Append(solutionContext.CurrentMethodRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModel))
             {
                 if (solutionContext.CurrentModel != null)
                 {
                     Model.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Model: ").Append(solutionContext.CurrentModel.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModelObject))
             {
                 if (solutionContext.CurrentModelObject != null)
                 {
                     ModelObject.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ModelObject: ").Append(solutionContext.CurrentModelObject.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentModelProperty))
             {
                 if (solutionContext.CurrentModelProperty != null)
                 {
                     ModelProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ModelProperty: ").Append(solutionContext.CurrentModelProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentObjectInstance))
             {
                 if (solutionContext.CurrentObjectInstance != null)
                 {
                     ObjectInstance.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ObjectInstance: ").Append(solutionContext.CurrentObjectInstance.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentParameter))
             {
                 if (solutionContext.CurrentParameter != null)
                 {
                     Parameter.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Parameter: ").Append(solutionContext.CurrentParameter.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentProject))
             {
                 if (solutionContext.CurrentProject != null)
                 {
                     Project.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Project: ").Append(solutionContext.CurrentProject.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentProperty))
             {
                 if (solutionContext.CurrentProperty != null)
                 {
                     Property.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Property: ").Append(solutionContext.CurrentProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyInstance))
             {
                 if (solutionContext.CurrentPropertyInstance != null)
                 {
                     PropertyInstance.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyInstance: ").Append(solutionContext.CurrentPropertyInstance.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyReference))
             {
                 if (solutionContext.CurrentPropertyReference != null)
                 {
                     PropertyReference.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyReference: ").Append(solutionContext.CurrentPropertyReference.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentPropertyRelationship))
             {
                 if (solutionContext.CurrentPropertyRelationship != null)
                 {
                     PropertyRelationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- PropertyRelationship: ").Append(solutionContext.CurrentPropertyRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentRelationship))
             {
                 if (solutionContext.CurrentRelationship != null)
                 {
                     Relationship.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Relationship: ").Append(solutionContext.CurrentRelationship.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentRelationshipProperty))
             {
                 if (solutionContext.CurrentRelationshipProperty != null)
                 {
                     RelationshipProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- RelationshipProperty: ").Append(solutionContext.CurrentRelationshipProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStage))
             {
                 if (solutionContext.CurrentStage != null)
                 {
                     Stage.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Stage: ").Append(solutionContext.CurrentStage.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStageTransition))
             {
                 if (solutionContext.CurrentStageTransition != null)
                 {
                     StageTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StageTransition: ").Append(solutionContext.CurrentStageTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentState))
             {
                 if (solutionContext.CurrentState != null)
                 {
                     State.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- State: ").Append(solutionContext.CurrentState.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStateModel))
             {
                 if (solutionContext.CurrentStateModel != null)
                 {
                     StateModel.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StateModel: ").Append(solutionContext.CurrentStateModel.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStateTransition))
             {
                 if (solutionContext.CurrentStateTransition != null)
                 {
                     StateTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StateTransition: ").Append(solutionContext.CurrentStateTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStep))
             {
                 if (solutionContext.CurrentStep != null)
                 {
                     Step.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Step: ").Append(solutionContext.CurrentStep.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentStepTransition))
             {
                 if (solutionContext.CurrentStepTransition != null)
                 {
                     StepTransition.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- StepTransition: ").Append(solutionContext.CurrentStepTransition.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentValue))
             {
                 if (solutionContext.CurrentValue != null)
                 {
                     Value.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Value: ").Append(solutionContext.CurrentValue.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentView))
             {
                 if (solutionContext.CurrentView != null)
                 {
                     View.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- View: ").Append(solutionContext.CurrentView.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentViewProperty))
             {
                 if (solutionContext.CurrentViewProperty != null)
                 {
                     ViewProperty.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- ViewProperty: ").Append(solutionContext.CurrentViewProperty.InnerXmlData);
                     }
                 }
             }
             else if (CurrentItem.CurrentItemName == Enum.GetName(typeof(CurrentItemTypeCode), CurrentItemTypeCode.CurrentWorkflow))
             {
                 if (solutionContext.CurrentWorkflow != null)
                 {
                     Workflow.DeleteCurrentItemFromSolution(solutionContext);
                     if (solutionContext.IsSampleMode == true)
                     {
                         templateContext.MessageBuilder.Append("\r\n- Workflow: ").Append(solutionContext.CurrentWorkflow.InnerXmlData);
                     }
                 }
             }
             #region protected
             #endregion protected
             else
             {
                 LogException(solutionContext, templateContext, modelContext, String.Format(DisplayValues.Exception_CouldNotDeleteItem, CurrentItem.CurrentItemName), interpreterType);
             }
         }
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
Exemplo n.º 26
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the model context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        /// <param name="helperModelContext">The associated helper model context node.</param>
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        ///--------------------------------------------------------------------------------
        public IDomainEnterpriseObject GetModelContext(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, ModelContextNode helperModelContext, InterpreterTypeCode interpreterType)
        {
            IDomainEnterpriseObject parentContext = modelContext;

            if (ModelContext != null)
            {
                bool isValidContext;
                parentContext = ModelContext.GetModelContext(solutionContext, templateContext, modelContext, out isValidContext);
            }
            else if (CurrentItem != null)
            {
                parentContext = CurrentItem.GetModelContext(solutionContext, templateContext, modelContext);
            }
            if (MethodName == LanguageTerms.FindMethod)
            {
                IEnterpriseEnumerable collection = helperModelContext.GetCollection(solutionContext, templateContext, parentContext);
                if (collection != null)
                {
                    if (ModelProperty != null)
                    {
                        object paramValue            = Parameter.GetObjectValue(solutionContext, templateContext, modelContext, interpreterType);
                        IDomainEnterpriseObject item = collection.FindItem(ModelProperty.ModelPropertyName, paramValue) as IDomainEnterpriseObject;
                        if (item != null)
                        {
                            return(item);
                        }
                        if (modelContext is ObjectInstance)
                        {
                            // get item by specified model property
                            foreach (ObjectInstance instance in collection)
                            {
                                foreach (PropertyInstance property in instance.PropertyInstanceList)
                                {
                                    if (property.ModelPropertyName == ModelProperty.ModelPropertyName && property.PropertyValue == paramValue.ToString())
                                    {
                                        return(instance);
                                    }
                                }
                            }
                        }
                        return(null);
                    }
                    else
                    {
                        string parameterValue = Parameter.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
                        Guid   parameterID    = Guid.Empty;
                        if (Guid.TryParse(parameterValue, out parameterID))
                        {
                            return(collection.FindItemByID(parameterID) as IDomainEnterpriseObject);
                        }
                        else
                        {
                            LogException(solutionContext, templateContext, modelContext, DisplayValues.Message_InterpreterBadFindParameter, interpreterType);
                        }
                    }
                }
                return(null);
            }
            return(modelContext);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>Interpret this node to produce code, output, or model data..</summary>
        ///
        /// <param name="interpreterType">The type of interpretation to perform.</param>
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
        {
            try
            {
                string text;
                if (CustomText != null)
                {
                    text = CustomText.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
                }
                else
                {
                    text = templateContext.ContentCodeBuilder.ToString();
                }
                string path = FilePath.GetStringValue(solutionContext, templateContext, modelContext, interpreterType);
                if (!String.IsNullOrEmpty(text) && !String.IsNullOrEmpty(path))
                {
                    if (solutionContext.IsSampleMode == true)
                    {
                        // don't perform replacement of output files, just indicate it would be output
                        templateContext.MessageBuilder.Append("\r\n> ");
                        templateContext.MessageBuilder.Append(path);
                    }
                    else if (solutionContext.LoggedErrors.Count == 0)
                    {
                        if (File.Exists(path) == true)
                        {
                            if (solutionContext.UseProtectedAreas == true && String.IsNullOrEmpty(solutionContext.ProtectedAreaStart) == false && String.IsNullOrEmpty(solutionContext.ProtectedAreaEnd) == false)
                            {
                                // preserve protected areas in output file
                                string originalText = FileHelper.GetText(path);
                                if (originalText.Contains(solutionContext.ProtectedAreaStart) && originalText.Contains(solutionContext.ProtectedAreaEnd))
                                {
                                    int           currentTextIndex         = 0;
                                    int           currentOriginalTextIndex = 0;
                                    bool          hasProtectedText         = false;
                                    StringBuilder updatedText = new StringBuilder();
                                    while (currentTextIndex < (text.Length - 1))
                                    {
                                        if (text.IndexOf(solutionContext.ProtectedAreaStart, currentTextIndex) >= 0 && text.IndexOf(solutionContext.ProtectedAreaEnd, text.IndexOf(solutionContext.ProtectedAreaStart, currentTextIndex)) >= 0)
                                        {
                                            // append text to next protected block
                                            updatedText.Append(text.Substring(currentTextIndex, text.IndexOf(solutionContext.ProtectedAreaStart, currentTextIndex) - currentTextIndex));
                                            currentTextIndex = text.IndexOf(solutionContext.ProtectedAreaStart, currentTextIndex);

                                            if (originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex) >= 0 && originalText.IndexOf(solutionContext.ProtectedAreaEnd, originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex)) >= 0)
                                            {
                                                hasProtectedText         = true;
                                                currentOriginalTextIndex = originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex);
                                                if (String.IsNullOrWhiteSpace(originalText.Substring(currentOriginalTextIndex + solutionContext.ProtectedAreaStart.Length, originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) - currentOriginalTextIndex - solutionContext.ProtectedAreaStart.Length)))
                                                {
                                                    hasProtectedText = false;
                                                }
                                                if (hasProtectedText == true)
                                                {
                                                    // append protected block in original text
                                                    updatedText.Append(originalText.Substring(currentOriginalTextIndex, originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) - currentOriginalTextIndex + solutionContext.ProtectedAreaEnd.Length));
                                                }
                                                else
                                                {
                                                    // append protected block in generated text
                                                    updatedText.Append(text.Substring(currentTextIndex, text.IndexOf(solutionContext.ProtectedAreaEnd, currentTextIndex) - currentTextIndex + solutionContext.ProtectedAreaEnd.Length));
                                                }
                                                currentOriginalTextIndex = originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) + solutionContext.ProtectedAreaEnd.Length;

                                                // skip protected block in text
                                                currentTextIndex = text.IndexOf(solutionContext.ProtectedAreaEnd, currentTextIndex) + solutionContext.ProtectedAreaEnd.Length;
                                            }
                                            else
                                            {
                                                // append remainder of text to updated text
                                                updatedText.Append(text.Substring(currentTextIndex));
                                                currentTextIndex = text.Length - 1;
                                            }
                                        }
                                        else
                                        {
                                            // append remainder of text to updated text
                                            updatedText.Append(text.Substring(currentTextIndex));
                                            currentTextIndex = text.Length - 1;

                                            // append remainder of protected blocks in original text (if any, user will have to move/replace these blocks)
                                            while (originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex) >= 0 && originalText.IndexOf(solutionContext.ProtectedAreaEnd, originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex)) >= 0)
                                            {
                                                hasProtectedText         = true;
                                                currentOriginalTextIndex = originalText.IndexOf(solutionContext.ProtectedAreaStart, currentOriginalTextIndex);
                                                if (String.IsNullOrWhiteSpace(originalText.Substring(currentOriginalTextIndex + solutionContext.ProtectedAreaStart.Length, originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) - currentOriginalTextIndex - solutionContext.ProtectedAreaStart.Length)))
                                                {
                                                    hasProtectedText = false;
                                                }
                                                if (hasProtectedText == true)
                                                {
                                                    updatedText.Append(originalText.Substring(currentOriginalTextIndex, originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) - currentOriginalTextIndex + solutionContext.ProtectedAreaEnd.Length));
                                                }
                                                currentOriginalTextIndex = originalText.IndexOf(solutionContext.ProtectedAreaEnd, currentOriginalTextIndex) + solutionContext.ProtectedAreaEnd.Length;
                                            }
                                        }
                                    }
                                    FileHelper.ReplaceFile(path, updatedText.ToString());
                                }
                                else
                                {
                                    // replace file if protected tags not found
                                    FileHelper.ReplaceFile(path, text);
                                }
                            }
                            else
                            {
                                // replace file wholesale
                                FileHelper.ReplaceFile(path, text);
                            }
                        }
                        else
                        {
                            string directory = Directory.GetParent(path).FullName;
                            if (!Directory.Exists(directory))
                            {
                                Directory.CreateDirectory(directory);
                            }
                            FileHelper.CreateFile(path, text);
                        }
                    }
                }
            }
            catch (ApplicationAbortException)
            {
                throw;
            }
            catch (System.Exception ex)
            {
                LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
            }
        }
Exemplo n.º 28
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method updates visibility based on current debug state.</summary>
        ///
        /// <param name="solution">The corresponding solution.</param>
        ///--------------------------------------------------------------------------------
        public void SetDebugVisibility(DebugAction debugAction, InterpreterTypeCode debugType, Guid templateID)
        {
            switch (debugAction)
            {
            case DebugAction.Breaking:
            case DebugAction.Continue:
                IsDebuggerRunning = true;
                break;

            default:
                IsDebuggerRunning = false;
                break;
            }
            switch (debugType)
            {
            case InterpreterTypeCode.Content:
                if (TemplateID != templateID)
                {
                    // make everything invisible
                    ContentDebugGoVisibility   = "Collapsed";
                    ContentDebugStopVisibility = "Collapsed";
                    ContentWatchesVisibility   = "Collapsed";
                    OutputDebugGoVisibility    = "Collapsed";
                    OutputDebugStopVisibility  = "Collapsed";
                    OutputWatchesVisibility    = "Collapsed";
                    IsContentWatchReadOnly     = true;
                    IsOutputWatchReadOnly      = true;
                }
                else
                {
                    OutputDebugGoVisibility   = "Collapsed";
                    OutputDebugStopVisibility = "Collapsed";
                    OutputWatchesVisibility   = "Collapsed";
                    IsOutputWatchReadOnly     = true;
                    switch (debugAction)
                    {
                    case DebugAction.Breaking:
                        ContentDebugGoVisibility   = "Visible";
                        ContentDebugStopVisibility = "Visible";
                        ContentWatchesVisibility   = "Visible";
                        IsContentWatchReadOnly     = false;
                        break;

                    case DebugAction.Continue:
                        ContentDebugGoVisibility   = "Collapsed";
                        ContentDebugStopVisibility = "Visible";
                        ContentWatchesVisibility   = "Visible";
                        IsContentWatchReadOnly     = true;
                        break;

                    default:
                        OutputDebugGoVisibility    = "Visible";
                        ContentDebugGoVisibility   = "Visible";
                        ContentDebugStopVisibility = "Collapsed";
                        ContentWatchesVisibility   = "Collapsed";
                        IsContentWatchReadOnly     = true;
                        break;
                    }
                }
                break;

            case InterpreterTypeCode.Output:
                if (TemplateID != templateID)
                {
                    // make everything invisible
                    ContentDebugGoVisibility   = "Collapsed";
                    ContentDebugStopVisibility = "Collapsed";
                    ContentWatchesVisibility   = "Collapsed";
                    OutputDebugGoVisibility    = "Collapsed";
                    OutputDebugStopVisibility  = "Collapsed";
                    OutputWatchesVisibility    = "Collapsed";
                    IsContentWatchReadOnly     = true;
                    IsOutputWatchReadOnly      = true;
                }
                else
                {
                    ContentDebugGoVisibility   = "Collapsed";
                    ContentDebugStopVisibility = "Collapsed";
                    ContentWatchesVisibility   = "Collapsed";
                    IsContentWatchReadOnly     = true;
                    switch (debugAction)
                    {
                    case DebugAction.Breaking:
                        OutputDebugGoVisibility   = "Visible";
                        OutputDebugStopVisibility = "Visible";
                        OutputWatchesVisibility   = "Visible";
                        IsOutputWatchReadOnly     = false;
                        break;

                    case DebugAction.Continue:
                        OutputDebugGoVisibility   = "Collapsed";
                        OutputDebugStopVisibility = "Visible";
                        OutputWatchesVisibility   = "Visible";
                        IsOutputWatchReadOnly     = true;
                        break;

                    default:
                        ContentDebugGoVisibility  = "Visible";
                        OutputDebugGoVisibility   = "Visible";
                        OutputDebugStopVisibility = "Collapsed";
                        OutputWatchesVisibility   = "Collapsed";
                        IsOutputWatchReadOnly     = true;
                        break;
                    }
                }
                break;

            default:
                // assume debugging is done, set to initial state
                ContentDebugGoVisibility   = "Visible";
                ContentDebugStopVisibility = "Collapsed";
                ContentWatchesVisibility   = "Collapsed";
                OutputDebugGoVisibility    = "Visible";
                OutputDebugStopVisibility  = "Collapsed";
                OutputWatchesVisibility    = "Collapsed";
                break;
            }
        }
 ///--------------------------------------------------------------------------------
 /// <summary>Interpret this node to produce code, output, or model data..</summary>
 ///
 /// <param name="interpreterType">The type of interpretation to perform.</param>
 /// <param name="solutionContext">The associated solution.</param>
 /// <param name="templateContext">The associated template.</param>
 /// <param name="modelContext">The associated model context.</param>
 ///--------------------------------------------------------------------------------
 public void InterpretNode(InterpreterTypeCode interpreterType, Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext)
 {
     try
     {
         int itemIndex = 0;
         templateContext.ItemIndex = itemIndex;
         if (ForeachClause.ForeachHelperName == LanguageTerms.RecordItem)
         {
             bool   isValidContext;
             Entity entityContext = Entity.GetModelContext(solutionContext, modelContext, out isValidContext) as Entity;
             if (entityContext != null)
             {
                 templateContext.PushModelContext(entityContext);
                 SqlDbManager manager      = new SqlDbManager(new DatabaseOptions(solutionContext.SourceDbServerName, solutionContext.SourceDbName));
                 string       sqlStatement = "SELECT * FROM " + entityContext.DBTableName;
                 templateContext.DbReader = manager.ExecuteRawSqlReader(sqlStatement);
                 while (templateContext.DbReader.Read())
                 {
                     if (ForeachClause.LimitClause == null || ForeachClause.LimitClause.Limit >= itemIndex + 1)
                     {
                         templateContext.IsBreaking   = false;
                         templateContext.IsContinuing = false;
                         foreach (IStatementNode node in Statements)
                         {
                             if (node.HandleDebug(interpreterType, solutionContext, templateContext, entityContext) == false)
                             {
                                 return;
                             }
                             if (templateContext.IsContinuing == true)
                             {
                                 break;
                             }
                             if (templateContext.IsBreaking == true || templateContext.IsReturning == true)
                             {
                                 templateContext.IsBreaking = false;
                                 break;
                             }
                             if (node is BreakStatementNode)
                             {
                                 templateContext.IsBreaking = true;
                                 break;
                             }
                             if (node is ContinueStatementNode)
                             {
                                 break;
                             }
                             if (node is ReturnStatementNode)
                             {
                                 templateContext.IsReturning = true;
                                 break;
                             }
                             node.InterpretNode(interpreterType, solutionContext, templateContext, modelContext);
                         }
                         itemIndex++;
                         templateContext.ItemIndex = itemIndex;
                     }
                 }
                 manager.Close();
                 manager = null;
                 templateContext.DbReader = null;
                 templateContext.PopModelContext();
             }
         }
         else
         {
             IEnterpriseEnumerable collection = GetCollection(solutionContext, templateContext, modelContext, interpreterType);
             if (collection != null)
             {
                 foreach (IDomainEnterpriseObject itemContext in collection)
                 {
                     templateContext.PushModelContext(itemContext);
                     if (templateContext.IsBreaking == true || templateContext.IsReturning == true)
                     {
                         templateContext.IsBreaking = false;
                         break;
                     }
                     if (ForeachClause.WhereClause == null || ForeachClause.WhereClause.Expression.EvaluateExpression(solutionContext, templateContext, itemContext, interpreterType) == true)
                     {
                         if (ForeachClause.LimitClause == null || ForeachClause.LimitClause.Limit >= itemIndex + 1)
                         {
                             templateContext.IsBreaking   = false;
                             templateContext.IsContinuing = false;
                             foreach (IStatementNode node in Statements)
                             {
                                 if (node.HandleDebug(interpreterType, solutionContext, templateContext, itemContext) == false)
                                 {
                                     return;
                                 }
                                 if (templateContext.IsContinuing == true)
                                 {
                                     break;
                                 }
                                 if (templateContext.IsBreaking == true || templateContext.IsReturning == true)
                                 {
                                     templateContext.IsBreaking = false;
                                     break;
                                 }
                                 if (node is BreakStatementNode)
                                 {
                                     templateContext.IsBreaking = true;
                                     break;
                                 }
                                 if (node is ContinueStatementNode)
                                 {
                                     break;
                                 }
                                 if (node is ReturnStatementNode)
                                 {
                                     templateContext.IsReturning = true;
                                     break;
                                 }
                                 node.InterpretNode(interpreterType, solutionContext, templateContext, itemContext);
                             }
                         }
                         itemIndex++;
                         templateContext.ItemIndex = itemIndex;
                     }
                     templateContext.PopModelContext();
                 }
             }
             templateContext.IsBreaking = false;
         }
         templateContext.ItemIndex = 0;
     }
     catch (ApplicationAbortException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         LogException(solutionContext, templateContext, modelContext, ex, interpreterType);
     }
 }
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the collection context associated with this node.</summary>
        ///
        /// <param name="solutionContext">The associated solution.</param>
        /// <param name="templateContext">The associated template.</param>
        /// <param name="modelContext">The associated model context.</param>
        ///--------------------------------------------------------------------------------
        public IEnterpriseEnumerable GetCollection(Solution solutionContext, ITemplate templateContext, IDomainEnterpriseObject modelContext, InterpreterTypeCode interpreterType)
        {
            IEnterpriseEnumerable collection = null;

            if (ForeachClause.ModelContext != null)
            {
                if (ForeachClause.InClause != null)
                {
                    collection = ForeachClause.InClause.InClauselItem.GetCollection(solutionContext, templateContext, modelContext, ForeachClause.ModelContext, interpreterType);
                }
                else
                {
                    collection = ForeachClause.ModelContext.GetCollection(solutionContext, templateContext, modelContext);
                }
                if (ForeachClause.SortClause != null)
                {
                    if (ForeachClause.SortClause.SortDirectionClause != null && ForeachClause.SortClause.SortDirectionClause.AscendingSort == false)
                    {
                        collection.Sort(ForeachClause.SortClause.ModelProperty.ModelPropertyName, SortDirection.Descending);
                    }
                    else
                    {
                        collection.Sort(ForeachClause.SortClause.ModelProperty.ModelPropertyName, SortDirection.Ascending);
                    }
                }
            }
            return(collection);
        }