public void Result() { bool message; message = Check(); string MessageData = Code.login + message.ToString(); Program.tcpSendData(Listener, MessageData); if (message) { SQLEvent sqlEvent = new SQLEvent($" Пользователь {Username} авторизовался"); sqlEvent.Start(); } }
private List <Zombie> GetZombies() { List <Zombie> returnList = new List <Zombie>(); XmlNodeList Zombies = this.ConfigXML.SelectNodes("//Zombies/Zombie[@Multiplier>0]"); foreach (XmlNode zombie in Zombies) { Zombie z = new Zombie(); z.Name = GetAttributeValue(zombie, "Name"); z.Frequency = Convert.ToInt32(GetAttributeValue(zombie, "Frequency")); z.Multiplier = Convert.ToInt32(GetAttributeValue(zombie, "Multiplier")); XmlElement taskVariableList = zombie["TaskVariables"]; if (taskVariableList != null) { foreach (XmlNode variableNode in taskVariableList.ChildNodes) { switch (GetAttributeValue(variableNode, "Type").ToLower()) { case "static": StaticTaskVariable staticVar = new StaticTaskVariable(); staticVar.Name = GetNodeInnerText(variableNode, "Name"); staticVar.Value = GetNodeInnerText(variableNode, "Value"); staticVar.Reset = Convert.ToBoolean(GetAttributeValue(variableNode, "Reset")); z.TaskVariables.Add(staticVar.Name, staticVar); break; case "sql": SQLTaskVariable sqlVar = new SQLTaskVariable(); sqlVar.Name = GetNodeInnerText(variableNode, "Name"); sqlVar.Reset = Convert.ToBoolean(GetAttributeValue(variableNode, "Reset")); sqlVar.ConnectionString = GetAttributeValue(variableNode, "ConnectionString"); sqlVar.ConnectionString = (sqlVar.ConnectionString.ToLower() == "{parent}") ? SourceConnectionString : sqlVar.ConnectionString; sqlVar.Statement = GetAttributeValue(variableNode, "Statement"); z.TaskVariables.Add(sqlVar.Name, sqlVar); break; } } } XmlElement taskNodeList = zombie["Tasks"]; if (taskNodeList != null) { foreach (XmlNode taskNode in taskNodeList.ChildNodes) { switch (taskNode.Attributes["Type"].Value.ToLower()) { case "sql": SQLTask task = new SQLTask(this); task.Name = taskNode.Attributes["Name"].Value; task.Sequence = Convert.ToInt32(taskNode.Attributes["Sequence"].Value); XmlNodeList sqlStatements = taskNode["SQLStatements"].ChildNodes; foreach (XmlNode statement in sqlStatements) { SQLStatement newStatement = new SQLStatement(); newStatement.Statement = statement["Text"].InnerText; if (statement.Attributes["OutputType"] != null) { newStatement.OutputType = (SqlStatementOutputType)Enum.Parse(typeof(SqlStatementOutputType), statement.Attributes["OutputType"].Value); } else { newStatement.OutputType = SqlStatementOutputType.None; } newStatement.ConnectionString = statement.Attributes["ConnectionString"].Value == "{PARENT}" ? SourceConnectionString : statement.Attributes["ConnectionString"].Value; XmlElement traceSQLOutput = statement["OutputList"]; if (traceSQLOutput != null) { newStatement.OutputList = GetOutputValues(traceSQLOutput.ChildNodes); } task.QueryList.Add(newStatement); } XmlElement traceSQLReplacements = taskNode["Replacements"]; if (traceSQLReplacements != null) { task.Replacements = GetReplacementValues(traceSQLReplacements.ChildNodes); } z.Tasks.Add(task); break; case "sqltrace": SQLTraceTask trace = new SQLTraceTask(this); trace.Name = taskNode.Attributes["Name"].Value; trace.TraceSource = taskNode.Attributes["FilePath"].Value; trace.ConnectionString = taskNode.Attributes["ConnectionString"].Value; XmlNodeList traceTaskReplacements = taskNode["Replacements"].ChildNodes; if (traceTaskReplacements != null) { trace.Replacements = GetReplacementValues(traceTaskReplacements); } XmlNodeList traceEventList = taskNode["EventsToMonitor"].ChildNodes; foreach (XmlNode sqlEvent in traceEventList) { SQLEvent newEvent = new SQLEvent(); newEvent.EventName = sqlEvent.Attributes["Text"].Value; trace.EventList.Add(newEvent); } z.Tasks.Add(trace); break; case "webservice": WebServiceTask restTask = new WebServiceTask(); restTask.Endpoint = GetNodeInnerText(taskNode, "URL"); restTask.ContentType = GetChildNodeAttribute(taskNode, "URL", "ContentType"); restTask.ContentLength = Convert.ToInt32(GetChildNodeAttribute(taskNode, "URL", "ContentLength")); restTask.Method = GetChildNodeAttribute(taskNode, "URL", "Verb"); if (taskNode["Authentication"] != null) { switch (taskNode["Authentication"].Attributes["Type"].Value.ToLower()) { case "basic": restTask.UserName = GetChildNodeAttribute(taskNode["Authentication"], "Credentials", "UserName"); restTask.Password = GetChildNodeAttribute(taskNode["Authentication"], "Credentials", "Password"); break; case "none": break; } } if (taskNode["Cookies"] != null) { foreach (XmlNode taskCookie in taskNode["Cookies"].ChildNodes) { HttpCookie cookie = new HttpCookie(); cookie.Domain = GetAttributeValue(taskCookie, "Domain"); cookie.Name = GetAttributeValue(taskCookie, "Name"); cookie.Value = GetNodeInnerText(taskCookie, "Value"); restTask.Cookies.Add(cookie); } } z.Tasks.Add(restTask); break; } } } z.Tasks.Sort((task1, task2) => task1.Sequence.CompareTo(task2.Sequence)); returnList.Add(z); } return(returnList); }