Пример #1
0
 void StartServer()
 {
     SynapseContext.LoadRoutePath(new List <string> {
         @"C:\Users\AdeolaOjo\Documents\visual studio 2013\Projects\nerve\nervefileconsumer\bin\Debug\nervefileconsumer.dll"
     });
     SynapseContext.StartEngine();
     Console.ReadLine();
 }
Пример #2
0
        public override Exchange Process(Exchange exchange, UriDescriptor endPointDescriptor)
        {
            var path  = endPointDescriptor.ComponentPath;
            var route = SynapseContext.GetRouteBy(path);

            if (route != null)
            {
                route.CurrentRouteStep.ProcessChannel(exchange);
            }

            return(exchange);
        }
Пример #3
0
        /// <summary>
        /// Digest Route Information
        /// </summary>
        private void Exec(XElement routeElement)
        {
            if (routeElement == null)
            {
                return;
            }

            try
            {
                var description = XmlDataUtil.Attribute <string>(routeElement, TagConstant.Description);
                var routeObj    = new Route {
                    Description = description, PackageDescriptor = _packageDescriptor
                };
                RouteStep nextRouteStepProcessorToLink = null;

                //read all steps in route
                foreach (var xmlStep in routeElement.Elements())
                {
                    if (routeObj.CurrentRouteStep == null)
                    {
                        routeObj.CurrentRouteStep    = new RouteStep(xmlStep, routeObj);
                        nextRouteStepProcessorToLink = routeObj.CurrentRouteStep;
                    }
                    else
                    {
                        var nextStep = new RouteStep(xmlStep, routeObj);
                        if (nextRouteStepProcessorToLink == null)
                        {
                            continue;
                        }

                        nextRouteStepProcessorToLink.NextRouteStep = nextStep;
                        nextRouteStepProcessorToLink = nextRouteStepProcessorToLink.NextRouteStep;
                    }
                }

                //add route for execution
                SynapseContext.SetRoute(routeObj);
            }
            catch (Exception exception)
            {
                var msg = exception.Message;
            }
        }
Пример #4
0
        /// <summary>
        /// ProcessChannel
        /// </summary>
        /// <param name="splitElement"></param>
        /// <param name="exchange"></param>
        public static void Execute(XElement splitElement, Exchange exchange)
        {
            try
            {
                if (splitElement == null)
                {
                    return;
                }

                var spliterXml = splitElement.Elements().FirstOrDefault();
                if (spliterXml == null)
                {
                    return;
                }

                ISplitterStrategy strategy = null;
                var strategyAttr           = splitElement.Attribute("strategy");

                if (strategyAttr != null)
                {
                    strategy = SynapseContext.LoadBean(strategyAttr.Value.ToString(CultureInfo.InvariantCulture)) as ISplitterStrategy;
                }

                var result = new List <String>();
                if (strategy != null)
                {
                    result = strategy.Split(exchange);
                }
                else
                {
                    var splitterName = spliterXml.Name.ToString();
                    switch (splitterName)
                    {
                    case "xpath":
                        result = SplitByXPath(spliterXml.Value, exchange);
                        break;

                    case "simple":
                        result = SplitSimple(spliterXml.Value, exchange);
                        break;
                    }
                }

                if (result == null)
                {
                    return;
                }

                var nextSteps = strategy == null?splitElement.Elements().Skip(1) : splitElement.Elements();

                //process each
                foreach (var nextStep in nextSteps)
                {
                    try
                    {
                        //hold original message
                        var originalMessage = exchange.InMessage.Body;
                        foreach (var item in result)
                        {
                            var exchangeMsg = item;

                            var splitterExchange = exchange.CloneExchange(new Message
                            {
                                Body             = exchangeMsg,
                                HeaderCollection = exchange.InMessage.HeaderCollection
                            },
                                                                          new Message(),
                                                                          exchange.Route);

                            RouteStep.ExecuteRouteStep(nextStep, exchange.Route, splitterExchange);
                        }
                        //restore original message
                        exchange.InMessage.Body = originalMessage;
                    }
                    catch (Exception exception)
                    {
                    }
                }
            }
            catch (Exception exception)
            {
            }
        }
Пример #5
0
 public StudentRepository(SynapseContext context)
 {
     _context = context;
 }
Пример #6
0
 public AdminRepository(SynapseContext context)
 {
     _context = context;
 }
Пример #7
0
 public StudentController(SynapseContext dbContext)
 {
     _adminRepository   = new AdminRepository(dbContext);
     _studentRepository = new StudentRepository(dbContext);
     _teacherRepository = new TeacherRepository(dbContext);
 }
Пример #8
0
 public TeacherRepository(SynapseContext context)
 {
     _context = context;
 }
Пример #9
0
 public TeacherController(SynapseContext dbContext)
 {
     _teacherRepository = new TeacherRepository(dbContext);
     _adminRepository   = new AdminRepository(dbContext);
 }
Пример #10
0
 public GradesHub(SynapseContext context)
 {
     _teacherRepository = new TeacherRepository(context);
 }