/// <summary> /// display variable in variables list /// </summary> public void ShowVariableList() { var count = 1; foreach (var variable in VariablesStorageQueries.GetVariables()) { CMD.ShowApplicationMessageToUser($"{count++} ) {variable.Item1}\t{variable.Item2}"); } }
/// <summary> /// Looping in the list of effects whose value is enumerable /// </summary> /// <param name="name">Name of variable</param> public void ShowVariableProperties(string name) { var value = VariablesStorageQueries.GetVariableValue(name); var count = 0; foreach (var item in value as IEnumerable <object> ) { CMD.ShowApplicationMessageToUser($"{count++} )\t{item}"); } }
/// <summary> /// copy records to variable /// </summary> /// <param name="name">name of variable</param> public void CopyRecords(string name) { try { var data = RecordQueries.GetNewInstanceOfRecords().Select(item => new { Name = item.Key, Value = item.Value }); VariablesStorageQueries.AddNewVariable(name, data); } catch (Exception e) { CMD.ShowApplicationMessageToUser($"message : {e.Message}\nroute : {this.ToString()}", showType: ShowType.DANGER); } }
/// <summary> /// paste records in records list /// </summary> /// <param name="name">name of variable</param> public void PasteRecords(string name) { try { var records = VariablesStorageQueries.GetVariableValue(name) as IEnumerable <object>; foreach (dynamic item in records) { RecordQueries.AddNewRecord(item.Name, item.Value); } } catch (Exception e) { CMD.ShowApplicationMessageToUser($"message : {e.Message}\nroute : {this.ToString()}", showType: ShowType.DANGER); } }
/// <summary> /// Remove variable from variabes list /// </summary> /// <param name="variables">Variable names</param> public void RemoveVariable(string variables) { try { var array = Utilities.GetArray(variables, Utilities.Mode_1); for (int i = 0; i < array.Length; i++) { VariablesStorageQueries.RemoveVariable(array[i]); CMD.ShowApplicationMessageToUser($"var {array[i]} removed", showType: ShowType.SUCCESS); } } catch (Exception e) { CMD.ShowApplicationMessageToUser($"message : {e.Message}\nroute : {this.ToString()}", showType: ShowType.DANGER); } }
/// <summary> /// paste config to request specified /// </summary> /// <param name="varName">The variable in which the configuration is stored</param> /// <param name="key">request key</param> protected void PasteConfig(string varName, string key = null) { try { var request = ProgramStorageQueries.GetRequest(key); var config = VariablesStorageQueries.GetVariableValue(varName) as IEnumerable <object>; foreach (dynamic item in config) { var name = item.Name as string; var value = item.Value; var prop = request.GetType().GetProperty(name); prop.SetValue(request, item.Value); } } catch (Exception e) { CMD.ShowApplicationMessageToUser($"message : {e.Message}\nroute : {this.ToString()}", showType: ShowType.DANGER); } }
/// <summary> /// copy all headers of request in variables list /// </summary> /// <param name="variableName">The name of the variable that holds the config</param> /// <param name="targets">defined header</param> /// <param name="key">request key</param> protected void CopyRequestConfig(string variableName, string targets = null, string key = null) { try { var request = ProgramStorageQueries.GetCurrentRequest(); if (targets == null) { var properties = CopyConfig(request); VariablesStorageQueries.AddNewVariable(variableName, properties); } else { var properties = CopyConfig(request, targets); VariablesStorageQueries.AddNewVariable(variableName, properties); } } catch (Exception e) { CMD.ShowApplicationMessageToUser($"message : {e.Message}\nroute : {this.ToString()}", showType: ShowType.DANGER); } }
/// <summary> /// Clear variables list /// </summary> public void RemoveAllVariables() { VariablesStorageQueries.RemoveAllVariables(); }
//additional command : //public void PluseMultiVariables(string command) //{ // VariableAnalysis.ExecuteVariableCommand(command: command); //} //protected void CutVariableAndSave(string name, string newName, string startStr, string endStr, string startNum, string endNum) //{ // VariableStorageQueries.AddNewVariable(newName, Utilities.GetSubstring(VariableStorageQueries.GetVariableValue(name), startStr, endStr, startNum, endNum)); //} //protected void ReplaceDataInVariable(string newValue, string oldValue, string name) //{ // var variable = variablestoragequeries.getvariable(name); // var value = variable.value.replace(oldvalue, variableanalysis.executevariablecommand(newvalue) ?? newvalue); // variablestoragequeries.updatevariable(name, value); //} /// <summary> /// Adds new varible in variables list /// </summary> /// <param name="name">Name of variable</param> /// <param name="value">Value of variable</param> public void AddNewVariable(string name, string value) { VariablesStorageQueries.AddNewVariable(name, value); }