コード例 #1
0
 public JsonResult AddLocation(LocationIndexViewModel data)
 {
     var result = new JsonResultModel();
     var rack = new Rack();
     var existing = RackBLO.Current.GetByName(new Rack { RackName = data.RackName });
     if (existing == null)
     {
         rack.RackName = data.RackName;
         rack.MaximumPower = data.MaximumPower;
         RackBLO.Current.AddRackAndLocation(rack);
         result.Success = true;
     }
     else
     {
         result.Success = false;
     }
     
     return Json(result);
 }
コード例 #2
0
 public JsonResult AddIPRange(IPIndexViewModel iivm)
 {
     var ips = new List<IPAddressPool>();
     var result = new JsonResultModel();
     var existing = IPAddressPoolBLO.Current.GetByKeys(new IPAddressPool { IPAddress = iivm.Address });
     if (existing == null)
     {
         if (iivm.Option == "After")
         {
             ips = IPAddressPoolBLO.Current.GenerateIPAfterFirst(iivm.Address, iivm.Netmask);
         }
         if (iivm.Option == "Before")
         {
             ips = IPAddressPoolBLO.Current.GenerateIPBeforeLast(iivm.Address, iivm.Netmask);
         }
         var k = ips.Count - 1;
         ips[k].StatusCode = Constants.StatusCode.IP_RESERVE;
         for (int i = 0; i < ips.Count; i++)
         {
             ips[i].Staff = GetCurrentUserName();
         }
         for (var i = 0; i < ips.Count - 1; i++)
         {
             if (ips[i].IPAddress == ips[i].NetworkIP || ips[i].IPAddress == ips[i].Gateway)
             {
                 ips[i].StatusCode = Constants.StatusCode.IP_RESERVE;
             }
             else
             {
                 ips[i].StatusCode = Constants.StatusCode.IP_AVAILABLE;
             }
         }
         IPAddressPoolBLO.Current.AddIP(ips);
         result.Success = true;
     }
     else
     {
         result.Success = false;
     }
     return Json(result);
 }
コード例 #3
0
 public JsonResult AddServerTemp(RequestAddServerViewModel data)
 {
     var result = new JsonResultModel();
     result.Action = data.Server.btnAction;
     if (data.Server.btnAction == Constants.FormAction.EDIT_ACTION)
     {
         var temp = TempRequestBLO.Current.GetByKeys(new TempRequest { TempCode = data.Server.TempCode });
         temp.Data = JsonConvert.SerializeObject(data.Server);
         TempRequestBLO.Current.Update(temp);
         result.Success = true;
         result.Codes.Add(temp.TempCode);
     }
     else
     {
         var temp = new TempRequest();
         data.Server.Customer = GetCurrentUserName();
         temp.RequestCode = Session[Constants.Session.REQUEST_CODE].ToString();
         temp.Data = JsonConvert.SerializeObject(data.Server);
         temp.TempCode = TempRequestBLO.Current.GenerateCode();
         TempRequestBLO.Current.Add(temp);
         result.Success = true;
         result.Codes.Add(temp.TempCode);
     }
     return Json(result);
 }
コード例 #4
0
        public JsonResult DeactivateIP(IPIndexViewModel iivm)
        {
            var result = new JsonResultModel();
            for (var i = 0; i < iivm.NetIPAvai.Count; i++)
            {
                var item = iivm.NetIPAvai[i];
                if (item.Selected == true)
                {
                    var listip = IPAddressPoolBLO.Current.GetAllIP();
                    for (var j = 0; j < listip.Count; j++)
                    {
                        if (listip[j].NetworkIP == item.Value)
                        {
                            listip[j].StatusCode = Constants.StatusCode.IP_DEACTIVATE;
                            IPAddressPoolDAO.Current.Update(listip[j]);
                        }
                    }

                }
            }
            result.Success = true;
            return Json(result);
        }