Example #1
0
        public ActionResult RelocateComputer(string b, string r, string u, string n)
        {
            string result = "Success";

            try
            {
                if (String.IsNullOrEmpty(b))
                    throw new Exception("Building ID is required");

                if (String.IsNullOrEmpty(r))
                    throw new Exception("Room ID is required");

                if (String.IsNullOrEmpty(u))
                    throw new Exception("Unit Number is required");

                if (String.IsNullOrEmpty(n))
                    throw new Exception("Computer Name is required");

                ApplicationBase app = LcpsDbContext.DefaultApp;
                string un = string.Format("{0}\\{1}", app.LDAPDomain, app.LDAPUserName);

                RemoteComputer c = new RemoteComputer(n, un, app.LDAPPassword);

                c.Refresh();

                ComputerInfo info = c.ToComputerInfo();
                info.BuildingId = new Guid(b);
                info.RoomId = new Guid(r);
                info.UnitNumber = u.PadLeft(3, '0');

                c.DBAcrchive(info, User.Identity.Name);

                info.UpdateLDAP();
            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector(ex);
                result = ec.ToUL();
            }

            return Content(result);
        }