Пример #1
0
        public ActionResult ManageServer()
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();

            DSRCManagementSystem.Models.ManageServer        ObjAC    = new DSRCManagementSystem.Models.ManageServer();
            List <DSRCManagementSystem.Models.ManageServer> AsgnList = new List <DSRCManagementSystem.Models.ManageServer>();

            AsgnList = (from a in db.ManageServers
                        where a.ISDelete == false && a.Raid == true
                        join l in db.locations on a.LocationId equals l.locationid
                        join o in db.Master_ServerOs on a.OperatingSystem equals o.ServerOsName
                        // join c in db.Cpus on a.Processor equals c.CpuName
                        select new DSRCManagementSystem.Models.ManageServer()
            {
                RackNo = a.RackNo,
                MachineName = a.MachineName,
                Location = l.LocationName,
                ServerMake = a.ServerMake,
                Model = a.Model,
                Processor = a.Processor,
                Memory = a.Memory,
                HardDisks = a.HardDisks,
                Raid = a.Raid,
                Configurationdetails = a.Configurationdetails,
                OperatingSystem = o.ServerOsName,
                ServerEdition = a.ServerEdition,
                NameofProjectsHosted = a.NameofProjectsHosted,
                ID = a.ManageServers_Id
            }).ToList();

            return(View(AsgnList.ToList()));
        }
Пример #2
0
        public ActionResult EditServer(DSRCManagementSystem.Models.ManageServer modelObj, List <int> ProjectList, List <int> AssignedTo)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            var userId = (int)Session["UserId"];

            ViewBag.Raid = new SelectList(new[] { new { Text = "No", Value = 0 }, new { Text = "Yes", Value = 1 } }, "Value", "Text", 0);
            var LocationList = db.locations.ToList();

            ViewBag.LocationIDList = new SelectList(LocationList, "locationid", "LocationName");
            var OsList = db.Master_ServerOs.ToList();

            ViewBag.OsIdList  = new SelectList(OsList, "ServerOsId", "ServerOsName");
            ViewBag.Reporting = new SelectList(GetReportingPersons(userId), "UserId", "Name");

            //project();

            //if (!ModelState.IsValid)
            //{

            string temp = "";

            //for (int i = 0; i < j; i++)
            // {
            //   temp += ProjectList[i] + ";";
            // }

            if (ProjectList != null)
            {
                foreach (int i in ProjectList)
                {
                    temp += i + ";";
                }
            }
            string temp1 = "";

            if (AssignedTo != null)
            {
                foreach (var i in AssignedTo)
                {
                    temp1 += i + ";";
                }
            }
            using (DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1())

            {
                var obj_server = objdb.ManageServers.Where(o => o.ManageServers_Id == modelObj.ID).Select(o => o).FirstOrDefault();
                obj_server.LocationId           = modelObj.LocationId;
                obj_server.RackNo               = modelObj.RackNo;
                obj_server.AssetId              = modelObj.AssetId;
                obj_server.MachineName          = modelObj.MachineName;
                obj_server.ServerMake           = modelObj.ServerMake;
                obj_server.Model                = modelObj.Model;
                obj_server.Processor            = modelObj.Processor;
                obj_server.Memory               = modelObj.Memory;
                obj_server.HardDisks            = modelObj.HardDisks;
                obj_server.Raid                 = Convert.ToInt32(modelObj.Raid) == 0 ? true : false;
                obj_server.Configurationdetails = modelObj.Configurationdetails;
                obj_server.OperatingSystem      = modelObj.ServerOsName;
                obj_server.ServerEdition        = modelObj.ServerEdition;
                obj_server.NameofProjectsHosted = temp;
                obj_server.Assignedto           = temp1;
                obj_server.OtherProjects        = modelObj.OtherProjects;
                objdb.SaveChanges();
                List <int> selectedProjects = new List <int>();
                if (obj_server.NameofProjectsHosted != null)
                {
                    string[] tokens = obj_server.NameofProjectsHosted.Split(new string[] { ";" }, StringSplitOptions.None);
                    foreach (var i in tokens)
                    {
                        int val;
                        int.TryParse(i, out val);
                        selectedProjects.Add(val);
                    }
                }
                ViewBag.ProjectIDList = new MultiSelectList(ProjectList, "ProjectID", "ProjectName", selectedProjects);
            }


            return(Json("Success", JsonRequestBehavior.AllowGet));
            //}
            //else
            //{
            //    return View();
            //}
        }
Пример #3
0
        public ActionResult AddNew(DSRCManagementSystem.Models.ManageServer modelObj, List <int> ProjectList, List <int> AssignedTo, int Raid)
        {
            DSRCManagementSystem.Models.ManageServer obj_Assign = new DSRCManagementSystem.Models.ManageServer();
            DSRCManagementSystemEntities1            db         = new DSRCManagementSystemEntities1();
            var OsList       = db.Master_ServerOs.ToList();
            var LocationList = db.locations.ToList();
            //  var cpulist = db.Cpus.ToList();
            // var ProjectList = db.Projects.ToList();
            // int j = ProjectList.Count();
            string temp = "";

            //for (int i = 0; i < j; i++)
            // {
            //   temp += ProjectList[i] + ";";
            // }

            foreach (int i in ProjectList)
            {
                temp += i;
            }

            string temp1 = "";

            foreach (var i in AssignedTo)
            {
                temp1 += i;
            }

            ViewBag.Raid         = new SelectList(new[] { new { Text = "No", Value = 0 }, new { Text = "Yes", Value = 1 } }, "Value", "Text", 0);
            ViewBag.LocationList = new SelectList(new[] { new location()
                                                          {
                                                              locationid = 0, LocationName = "---Select---"
                                                          } }.Union(LocationList), "locationid", "LocationName", 0);
            ViewBag.OsList = new SelectList(new[] { new Master_ServerOs()
                                                    {
                                                        ServerOsId = 0, ServerOsName = "---Select---"
                                                    } }.Union(OsList), "ServerOsId", "ServerOsName", 0);
            // ViewBag.cpulist = new SelectList(new[] { new Cpu() { CpuIdNew = 0, CpuName = "---Select---" } }.Union(cpulist), "CpuIdNew", "CpuName", 0);
            DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();
            var already  = objdb.ManageServers.Where(o => o.MachineName == modelObj.MachineName).Select(o => o).FirstOrDefault();
            var already1 = objdb.ManageServers.Where(o => o.OtherProjects == modelObj.OtherProjects).Select(o => o).FirstOrDefault();

            if (already != null)
            {
                return(Json(new { Result = "AlreadyExist", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet));
            }
            else if (already1 != null)
            {
                return(Json(new { Result = "Already", URL = @Url.Action("AlertPopUp", "Popup") }, JsonRequestBehavior.AllowGet));
            }


            else
            {
                var Asgnobj = db.ManageServers.CreateObject();
                Asgnobj.LocationId           = modelObj.LocationId;
                Asgnobj.MachineName          = modelObj.MachineName.Trim();
                Asgnobj.ServerMake           = modelObj.ServerMake.Trim();
                Asgnobj.Model                = modelObj.Model;
                Asgnobj.Processor            = modelObj.Processor.Trim();
                Asgnobj.Memory               = modelObj.Memory;
                Asgnobj.HardDisks            = modelObj.HardDisks;
                Asgnobj.Raid                 = Raid == 0 ? false : true;
                Asgnobj.Configurationdetails = modelObj.Configurationdetails.Trim();
                Asgnobj.OperatingSystem      = modelObj.ServerOsName;
                Asgnobj.ServerEdition        = modelObj.ServerEdition.Trim();
                //Asgnobj.NameofProjectsHosted = modelObj.NameofProjectsHosted;
                Asgnobj.NameofProjectsHosted = temp;
                Asgnobj.Assignedto           = temp1;
                //Asgnobj.AssignedtoUserId = Convert.ToInt32(temp1.Trim(new Char[] { ' ', '*', '.', ';' }));
                Asgnobj.ISDelete      = false;
                Asgnobj.AssetId       = modelObj.AssetId.Trim();
                Asgnobj.RackNo        = modelObj.RackNo;
                Asgnobj.OtherProjects = modelObj.OtherProjects;
                db.ManageServers.AddObject(Asgnobj);
                db.SaveChanges();

                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
        }