예제 #1
0
 public void InsertServer(Server source)
 {
     _entities.AddToServers(source);
 }
 /// <summary>
 /// Create a new Server object.
 /// </summary>
 /// <param name="serverID">Initial value of the ServerID property.</param>
 /// <param name="serverName">Initial value of the ServerName property.</param>
 /// <param name="serverTypeID">Initial value of the ServerTypeID property.</param>
 public static Server CreateServer(global::System.Int32 serverID, global::System.String serverName, global::System.Int32 serverTypeID)
 {
     Server server = new Server();
     server.ServerID = serverID;
     server.ServerName = serverName;
     server.ServerTypeID = serverTypeID;
     return server;
 }
예제 #3
0
        public ActionResult ApplicationGraph()
        {
            #region ServerTypes

            var webServer = new ServerType {TypeName = "Web",ServerTypeID = 1};
            var dbServer = new ServerType { TypeName = "DB", ServerTypeID = 2 };

            #endregion

            #region Servers

            var Web2 = new Server
                           {
                               ServerID = 1,
                               ServerName = "WEB2",
                               ServerType = webServer
                           };
            var web9 = new Server
                               {
                                   ServerID = 2,
                                   ServerName = "WEB9",
                                   ServerType = webServer
                               };
            var db15 = new Server
                               {
                                   ServerID = 3,
                                   ServerName = "DB15",
                                   ServerType = dbServer
                               };
            var atlsetweb1 = new Server
            {
                ServerID = 4,
                ServerName = "atl-setweb1",
                ServerType = webServer
            };

            var atlsetweb2 = new Server
            {
                ServerID = 5,
                ServerName = "atl-setweb2",
                ServerType = webServer
            };

            var atlsetweb3 = new Server
            {
                ServerID = 6,
                ServerName = "atl-setweb3",
                ServerType = webServer
            };

            var atlsetweb4 = new Server
            {
                ServerID = 7,
                ServerName = "atl-setweb4",
                ServerType = webServer
            };

            var db8 = new Server
            {
                ServerID = 8,
                ServerName = "db8",
                ServerType = dbServer
            };

            var creditAppDB = new Server
            {
                ServerID = 9,
                ServerName = "CreditAppDB",
                ServerType = dbServer
            };

            #endregion

            #region ApplicationTypes

            var DotNetWebForms = new ApplicationType
                                     {
                                         TypeName = ".NET WebForms",
                                         ApplicationTypeID = 1
                                     };

            var DotNetMVC = new ApplicationType
            {
                TypeName = ".NET MVC",
                ApplicationTypeID = 2
            };

            var ClassicASP = new ApplicationType
                                 {
                                     TypeName = "Classic ASP",
                                     ApplicationTypeID = 3
                                 };

            var Webservice = new ApplicationType
            {
                TypeName = "Web Service",
                ApplicationTypeID = 4
            };

            #endregion

            #region Applications

            var oldBAT = new Application
                             {
                                 ApplicationID = 1,
                                 Name = "Old BAT",
                                 ApplicationType = DotNetWebForms
                             };

            var oldBATConfigurator = new Application
            {
                ApplicationID = 2,
                Name = "OldBAT Configurator",
                ApplicationType = ClassicASP
            };

            var newBAT = new Application
                             {
                                 ApplicationID = 3,
                                 Name = "NewBAT",
                                 ApplicationType = DotNetMVC
                             };

            var ice = new Application
            {
                ApplicationID = 4,
                Name = "ICE",
                ApplicationType = DotNetWebForms
            };

            var ipa = new Application
            {
                ApplicationID = 5,
                Name = "IPA",
                ApplicationType = DotNetWebForms
            };

            var SETLeads = new Application
            {
                ApplicationID = 6,
                Name = "SET Leads",
                ApplicationType = Webservice
            };

            #endregion

            #region Application Dependencies

            var applicationDeps = new List<ApplicationDependencies>();

            applicationDeps.Add(new ApplicationDependencies
            {
                Application = newBAT,
                Servers = new List<Server> { db15, atlsetweb1, atlsetweb2, atlsetweb3, atlsetweb4 }
            });

            applicationDeps.Add(new ApplicationDependencies
            {
                Application = oldBAT,
                Servers = new List<Server> { db15, web9, Web2 }
            });

            applicationDeps.Add(new ApplicationDependencies
            {
                Application = oldBATConfigurator,
                Servers = new List<Server> { db15, web9, Web2, db8 }
            });

            applicationDeps.Add(new ApplicationDependencies
            {
                Application = ice,
                Servers = new List<Server> { db15, web9, Web2 }
            });

            applicationDeps.Add(new ApplicationDependencies
            {
                Application = ipa,
                Servers = new List<Server> { db15, web9, Web2 }
            });

            applicationDeps.Add(new ApplicationDependencies
            {
                Application = SETLeads,
                Servers = new List<Server> { db15, atlsetweb2, creditAppDB }
            });

            #endregion

            var nodes = new List<Node>();

            nodes = AddApplicationsToNodeList(new List<Application>
                                                  {
                                                      oldBAT,
                                                      newBAT,
                                                      oldBATConfigurator,
                                                      ice,
                                                      ipa,
                                                      SETLeads
                                                  },nodes );

            nodes = AddServersToNodeList(new List<Server>
                                             {
                                                 web9,
                                                 Web2,
                                                 db15,
                                                 atlsetweb1,
                                                 atlsetweb2,
                                                 atlsetweb3,
                                                 atlsetweb4,
                                                 db8,
                                                 creditAppDB
                                             }, nodes);

            var links = new List<Link>();

            var count = 0;
            foreach (var dep in applicationDeps)
            {
                links.AddRange(dep.Servers.Select(serv => new Link
                    {
                        Source = nodes.Where(a => a.Name == dep.Application.Name).Select(a => a.Index).FirstOrDefault(),
                        Target = nodes.Where(a => a.Name == serv.ServerName).Select(a => a.Index).FirstOrDefault(),
                        Value = 1,
                        Weight = 1
                    }));
            }

            var jsonObj = new {nodes = nodes, links = links};
            var serializer = new JavaScriptSerializer();
            var model = new ApplicationGraphModel {json = serializer.Serialize(jsonObj).ToLower()};

            return View(model);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Servers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToServers(Server server)
 {
     base.AddObject("Servers", server);
 }