public string Validate(AlvisProject alvisProject)
        {
            if (!alvisProject.Page.Agents.Any(x => x.Active))

                return "No active agnet";

            return "";
        }
        public string Validate(AlvisProject alvisProject)
        {
            var passiveAgents = alvisProject.Page.Agents.Where(x=>!x.Active);
            var passiveAgentsWithNoPorts = passiveAgents.Where (x => !x.Ports.Any ());
            if (passiveAgentsWithNoPorts.Any()) {
                var agent = passiveAgentsWithNoPorts.First();
                return string.Format("Passive agent {0} has no port", agent.Name);
            }

            return "";
        }
예제 #3
0
        public override string Serialize(AlvisProject ap)
        {
            using(StringWriter writer= new StringWriter())

            {

                xmlSerializer.Serialize(writer, ap);

                return writer.ToString();

            }
        }
예제 #4
0
        public string Validate(AlvisProject alvisProject)
        {
            if (string.IsNullOrWhiteSpace(alvisProject.Code))

            {

                return "No code in alvis specification";

            }

            if (!alvisProject.Code.ToUpper().Contains("AGENT"))

            {

                return "No agent definition in code";

            }

            if (AlvisCodeValidators != null)

            {

                foreach (var alvisCodeValidator in AlvisCodeValidators)

                {

                    string errorMsg = alvisCodeValidator.Validate(alvisProject.Code);

                    if (!string.IsNullOrWhiteSpace(errorMsg))

                    {

                        return errorMsg;

                    }

                }

            }

            return "";
        }
예제 #5
0
 public override string Serialize(AlvisProject ap)
 {
     return JsonConvert.SerializeObject(ap);
 }
예제 #6
0
        public string Validate(AlvisProject alvisProject)
        {
            var connections = alvisProject.Page.Connections;

            if (!connections.Any()) return "no connections";

            if (connections.Count != connections.Select(x => new { x.Source, x.Target }).Distinct().Count())

            {

                return "Duplated connections";

            }

            var ports = alvisProject.Page.Agents.SelectMany(x => x.Ports, (agent, port) => new {agent.Name, port});

            if (!ports.Any()) return "No ports";

            if (ports.Count() != ports.Select(x => x.port.Id).Distinct().Count())

            {

                return "Duplicated ports";

            }

            if (connections.Count() * 2 != ports.Count())

            {

                return "Number of port should be 2 times number of connections";

            }

            foreach (var connection in connections)

            {

                var sourcePort = ports.Where(x => x.port.Id == connection.Source);

                var targetPort = ports.Where(x => x.port.Id == connection.Target);

                if (!sourcePort.Any()) return "No source for connection: " + connection;

                if (!targetPort.Any()) return "No target for connection: " + connection;

                if (sourcePort.Count() > 1) return "Find more then one source for connection: " + connection;

                if (targetPort.Count() > 1) return "Find more then one target for connection: " + connection;

                if (sourcePort.First().Name == targetPort.First().Name)

                {

                    return "Connection " + connection.ToString() + " is refering to one agent";

                }

                if (targetPort.First().port.Name != sourcePort.First().port.Name)

                {

                    return "Source port and target port has got diffrent names for connection " + connections;

                }

            }

            return "";
        }