feat: expand cockpit integrations and support workflows
Add Phoenix remote desktop, action connector, documentation engine, and gamification support. Refactor support-case processing and search/action UI, and update installer assets and dependencies.
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
using F4SD.DocuEngine.DocuEngineParser.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace F4SD.DocuEngine.DocuEngineParser.ContentBlock
|
||||
{
|
||||
internal partial class ContentBlock
|
||||
{
|
||||
private void ParseSwitchCommand(ref int index)
|
||||
{
|
||||
string tempString = "";
|
||||
bool foundTrueCase = false;
|
||||
bool foundAllCases = false;
|
||||
int tempIndex = 0;
|
||||
(string VariableType, string VariableName) switchVariable = ParseSwitchBlock(ref index);
|
||||
while (!foundAllCases)
|
||||
{
|
||||
tempIndex = index;
|
||||
SkipWhiteSpace(ref index);
|
||||
if (DocuTemplate.Substring(index, 4).Equals("case"))
|
||||
{
|
||||
index += 4;
|
||||
tempString += ParseCaseBlock(ref index, switchVariable, out var isCaseTrue);
|
||||
if (isCaseTrue && !foundTrueCase)
|
||||
{
|
||||
foundTrueCase = true;
|
||||
parsingContext.Append(tempString);
|
||||
}
|
||||
tempString = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
foundAllCases = true;
|
||||
index = tempIndex;
|
||||
}
|
||||
}
|
||||
tempIndex = index;
|
||||
SkipWhiteSpace(ref index);
|
||||
if (DocuTemplate.Substring(index, 7).Equals("default"))
|
||||
{
|
||||
index += 7;
|
||||
tempString += ParseDefaultBlock(ref index);
|
||||
if (!foundTrueCase)
|
||||
{
|
||||
foundTrueCase = true;
|
||||
parsingContext.Append(tempString);
|
||||
tempString = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
index = tempIndex;
|
||||
}
|
||||
}
|
||||
|
||||
private (string VariableType, string VariableName) ParseSwitchBlock(ref int index)
|
||||
{
|
||||
string variableName = "";
|
||||
string variableType = "";
|
||||
SkipWhiteSpace(ref index);
|
||||
variableType = ParseVariableType(ref index);
|
||||
SkipWhiteSpace(ref index);
|
||||
if (!(DocuTemplate.ElementAtOrDefault(index).Equals(';')))
|
||||
{
|
||||
throw new SyntaxErrorException(";", DocuTemplate.ElementAtOrDefault(index).ToString());
|
||||
}
|
||||
index++;
|
||||
SkipWhiteSpace(ref index);
|
||||
variableName = ParseVariableName(ref index);
|
||||
SkipWhiteSpace(ref index);
|
||||
if (!(DocuTemplate.ElementAtOrDefault(index).Equals(')')))
|
||||
{
|
||||
throw new SyntaxErrorException(")", DocuTemplate.ElementAtOrDefault(index).ToString());
|
||||
}
|
||||
index++;
|
||||
SkipWhiteSpace(ref index);
|
||||
if (!DocuTemplate.Substring(index, 2).Equals("{{"))
|
||||
{
|
||||
throw new SyntaxErrorException("{{", DocuTemplate.Substring(index, 2));
|
||||
}
|
||||
index += 2;
|
||||
return (variableType, variableName);
|
||||
}
|
||||
|
||||
private string ParseCaseBlock(ref int index, (string VariableType, string VariableName) switchVariable, out bool isCaseTrue)
|
||||
{
|
||||
string returnString = "";
|
||||
isCaseTrue = false;
|
||||
string value = "";
|
||||
SkipWhiteSpace(ref index);
|
||||
if (!(DocuTemplate.ElementAtOrDefault(index).Equals('(')))
|
||||
{
|
||||
throw new SyntaxErrorException("(", DocuTemplate.ElementAtOrDefault(index).ToString());
|
||||
}
|
||||
index++;
|
||||
SkipWhiteSpace(ref index);
|
||||
value = ParseValue(ref index);
|
||||
isCaseTrue = CheckCondition(switchVariable.VariableType, switchVariable.VariableName, '=', value);
|
||||
SkipWhiteSpace(ref index);
|
||||
if (!DocuTemplate.Substring(index, 2).Equals("{{"))
|
||||
{
|
||||
throw new SyntaxErrorException("{{", DocuTemplate.Substring(index, 2));
|
||||
}
|
||||
index += 2;
|
||||
ContentBlock contentBlock = new ContentBlock(DocuTemplate, Container);
|
||||
returnString += contentBlock.ParseContentBlock(ref index);
|
||||
return returnString;
|
||||
}
|
||||
|
||||
private string ParseDefaultBlock(ref int index)
|
||||
{
|
||||
string returnString = "";
|
||||
SkipWhiteSpace(ref index);
|
||||
if (!DocuTemplate.Substring(index, 2).Equals("{{"))
|
||||
{
|
||||
throw new SyntaxErrorException("{{", DocuTemplate.Substring(index, 2));
|
||||
}
|
||||
index += 2;
|
||||
ContentBlock contentBlock = new ContentBlock(DocuTemplate, Container);
|
||||
returnString += contentBlock.ParseContentBlock(ref index);
|
||||
return returnString;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user