/// <summary> /// Создать шаблон запроса /// </summary> private void CreateReqTemplate() { try { if (ReqParams.CmdLine == "") { throw new ScadaException(Localization.UseRussian ? "Командная строка пуста." : "The command line is empty."); } else { reqTemplate = new ParamString(ReqParams.CmdLine); ValidateReqTemplate(); sessState = SessStates.Waiting; } } catch (Exception ex) { sessState = SessStates.FatalError; reqTemplate = null; WriteToLog((Localization.UseRussian ? "Не удалось получить HTTP-запрос из командной строки КП: " : "Unable to get HTTP request from the device command line: ") + ex.Message); } writeSessState = true; }
public override void Execute(Context context) { Validate(context); //setup the array of Parameters tokens = ParamString.Split(Delimiter.ToCharArray(), numParams); //now format the string resultString = String.Format(BaseString, tokens); context.LogInfo(string.Format("String Formatter created : {0}", resultString)); context.Add(contextKeyWithResult, resultString, true); }
public void ORA_ReservedNameString_Test() { using (var db = OpenDbConnection()) { DropAndCreateTables(db); var row = new ParamString { Id = 2, String = 11 }; db.Insert(row); row.String = 234234; db.Update(row); } }
/// <summary> /// Performs actions when starting a communication line. /// </summary> public override void OnCommLineStart() { isReady = false; flagLoggingRequired = false; // load device configuration deviceConfig = new DeviceConfig(); string fileName = DeviceConfig.GetFileName(AppDirs.ConfigDir, Number); string errMsg; if (File.Exists(fileName)) { if (!deviceConfig.Load(fileName, out errMsg)) { WriteToLog(errMsg); } } else { // get URI from command line for backward compatibility deviceConfig.Uri = ReqParams.CmdLine; } // initialize variables if the configuration is valid if (ValidateConfig(deviceConfig, out errMsg)) { if (deviceConfig.ParamEnabled) { paramUri = new ParamString(deviceConfig.Uri, deviceConfig.ParamBegin, deviceConfig.ParamEnd); paramContent = new ParamString(deviceConfig.Content, deviceConfig.ParamBegin, deviceConfig.ParamEnd); } else { paramUri = null; paramContent = null; } addressBook = AbUtils.GetAddressBook(AppDirs.ConfigDir, CommonProps, WriteToLog); SetCurData(TagIndex.NotifCounter, 0, 1); // reset notification counter isReady = true; flagLoggingRequired = true; } else { WriteToLog(errMsg); } }
private bool flagLoggingRequired; // logging of the ready flag is required /// <summary> /// Initializes a new instance of the class. /// </summary> public KpHttpNotifLogic(int number) : base(number) { CanSendCmd = true; ConnRequired = false; stopwatch = new Stopwatch(); deviceConfig = null; addressBook = null; paramUri = null; paramContent = null; httpClient = null; isReady = false; flagLoggingRequired = false; InitDeviceTags(); }
private char[] respBuf; // буфер ответа на запрос /// <summary> /// Конструктор /// </summary> public KpHttpNotifLogic(int number) : base(number) { CanSendCmd = true; ConnRequired = false; addressBook = null; sessState = SessStates.Waiting; writeSessState = true; reqTemplate = null; respBuf = new char[RespBufLen]; InitKPTags(new List <KPTag>() { new KPTag(1, Localization.UseRussian ? "Отправлено уведомлений" : "Sent notifications") }); }
/// <summary> /// Converts the pattern for a single parameter description into an /// initialized description object. /// </summary> /// <param name="pOptions">Parsing options to use.</param> /// <param name="pHelpProvider"></param> /// <param name="pPattern">A string containing the syntax of a single argument.</param> /// <returns>A description object</returns> /// <exception cref="SyntaxErrorException"></exception> public static Description Parse(CliOptions pOptions, iHelpProvider pHelpProvider, string pPattern) { if (string.IsNullOrWhiteSpace(pPattern)) { throw new SyntaxErrorException(Errors.DescriptionFactoryNoPattern); } string pattern = pPattern.Trim(); eSCOPE scope = pattern.StartsWith("[") && pattern.EndsWith("]") ? eSCOPE.OPTIONAL : eSCOPE.REQUIRED; pattern = scope == eSCOPE.OPTIONAL ? pattern.Substring(1, pattern.Length - 2) : pattern; eROLE role = pattern.StartsWith(pOptions.Prefix) ? eROLE.NAMED : eROLE.PASSED; pattern = role == eROLE.NAMED ? pattern.Substring(pOptions.Prefix.Length) : pattern; eMULTIPLICITY multi = pattern.EndsWith("#") ? eMULTIPLICITY.MULTIPLE : eMULTIPLICITY.ONCE; pattern = multi == eMULTIPLICITY.MULTIPLE ? pattern.Substring(0, pattern.Length - 1) : pattern; int equal = pattern.IndexOf(pOptions.EqualChar, StringComparison.Ordinal); string type = equal == -1 ? null : pattern.Substring(equal + 1).ToLower(); string name = equal == -1 ? pattern : pattern.Substring(0, equal); iParamType paramType = type == null ? null : ParamTypeFactory.Create(type); if (paramType == null && role == eROLE.PASSED) { paramType = new ParamString(); } if (string.IsNullOrWhiteSpace(name)) { throw new SyntaxErrorException(Errors.DescriptionName); } string help = pHelpProvider.Get(name); return(new Description(name, help, role, paramType, scope, multi)); }
public void ORA_ReservedNameString_Test() { using (var db = OpenDbConnection()) { DropAndCreateTables(db); var row = new ParamString { Id = 2, String = 11 }; db.Insert(row); row.String = 234234; db.Update(row); } }