public ActionResult Edit(DevModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = bll.DevModels.Edit(model);
                    if (result)
                    {
                        return(Json(new { success = result }));
                    }
                    else
                    {
                        return(Json(new { success = result, errors = bll.DevModels.ErrorMessage }));
                    }
                    //return RedirectToAction("Index");
                }

                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
        private void HandleDevice(TDevice data)
        {
            Device = new DevModel()
            {
                addrRes     = new AddResource(),
                dvBrandid   = "",
                dvIsid      = Uuid.Create16Token(),
                managerIsid = cfg.AppSettings["managerIsid"],
                nodeIsid    = NodeIsid,
                dvTypeCode  = "37",
                dvName      = data.Name,
            };

            DbData = new SqlTDevice()
            {
                beginRunTime = SuperBTagBase.Transfer(data.BeginRunTime),
                devTypeId    = (int)data.DeviceType,
                objDesc      = data.Des,
                objId        = data.ID,
                parentId     = data.ParentID,
                objName      = data.Name,
                objTypeId    = (int)data.Type,
                productor    = data.Productor,
                version      = data.Version,
            };
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("devModelId,devModelName,brandId,equipmentTypeId")] DevModel devModel)
        {
            if (id != devModel.devModelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(devModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DevModelExists(devModel.devModelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["brandId"]         = new SelectList(_context.Brand, "brandId", "brandName", devModel.brandId);
            ViewData["equipmentTypeId"] = new SelectList(_context.EquipmentType, "equipmentTypeId", "equipmentTypeName", devModel.equipmentTypeId);
            return(View(devModel));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Genre,OpenDate,ClosedDate,DevStatus")] DevModel devModel)
        {
            if (id != devModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(devModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DevModelExists(devModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(devModel));
        }
        // GET: TypeModel/Edit/5
        public ActionResult Edit(int id)
        {
            DevModel model = bll.DevModels.Find(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
        // GET: TypeModel/Details/5
        public ActionResult Details(int id)
        {
            DevModel model = bll.DevModels.Find(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(model));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("ID,Name,Genre,OpenDate,ClosedDate,DevStatus")] DevModel devModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(devModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(devModel));
        }
Esempio n. 8
0
        public async Task <IActionResult> Create([Bind("devModelId,devModelName,brandId,equipmentTypeId")] DevModel devModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(devModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["brandId"]         = new SelectList(_context.Brand, "brandId", "brandName", devModel.brandId);
            ViewData["equipmentTypeId"] = new SelectList(_context.EquipmentType, "equipmentTypeId", "equipmentTypeName", devModel.equipmentTypeId);
            return(View(devModel));
        }
Esempio n. 9
0
 public ActionResult Index(DevModel model)
 {
     try
     {
         new DevModel().SetDevInfo(model);
     }
     catch (Exception ex)
     {
         ViewBag.Msg = "Error:" + ex.Message;
         return(View(new DevModel().GetDevInfo()));
     }
     ViewBag.Msg = "修改成功!";
     return(View(new DevModel().GetDevInfo()));
 }
 public ActionResult Create(DevModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bll.DevModels.Add(model);
             return(RedirectToAction("Index"));
         }
         return(View(model));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 11
0
        public IEnumerable <DevModel> GetDevs()
        {
            List <DevModel> devs      = new List <DevModel>();
            var             bips      = GetBIPs().ToList();
            var             container = Storage.CreateBlobContainer();

            Parallel.ForEach(container
                             .ListBlobs("BlockSize/AcceptedDevs", true, BlobListingDetails.All)
                             .OfType <CloudBlockBlob>()
                             .Where(o => o.Name.EndsWith(".asc") || o.Name.EndsWith(".pgp")), blob =>
            {
                var localBlob = blob;
                if (localBlob.Name.EndsWith(".pgp"))
                {
                    var ascBlob = container.GetBlockBlobReference(localBlob.Name.Replace(".pgp", ".asc"));
                    foreach (var meta in localBlob.Metadata)
                    {
                        ascBlob.Metadata.Add(meta);
                    }
                    var content = CryptoHelper.ToAsc(new WebClient().DownloadData(localBlob.Uri));
                    ascBlob.UploadFromByteArray(content, 0, content.Length);
                    ascBlob.SetMetadata();
                    localBlob.DeleteIfExists();
                    localBlob = ascBlob;
                }

                var dev          = new DevModel();
                dev.Id           = localBlob.Name.Split('/').Last().Split('.').First();
                dev.FriendlyName = localBlob.Metadata.ContainsKey("Name") ? localBlob.Metadata["Name"].Replace("%20", " ") : dev.Id;
                dev.Group        = localBlob.Metadata.ContainsKey("Group") ? localBlob.Metadata["Group"].Replace("%20", " ") : "";
                dev.Group        = dev.Group == "CoreDevs" ? "Core Developers" : dev.Group;
                dev.Group        = dev.Group == "Devs" ? "Developers" : dev.Group;

                var vm = GetDevViewModel(dev.Id);
                for (int i = 0; i < bips.Count; i++)
                {
                    var opinion = vm.Opinions.Where(o => o.Name.Equals(bips[i].Name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    dev.Approvals.Add(opinion == null ? null : new Approval?(opinion.Approve));
                }
                lock (devs)
                {
                    devs.Add(dev);
                }
            });
            return(devs);
        }
Esempio n. 12
0
        public async Task <IActionResult> Create([Bind("deviceId,contractNo,devModelId,createTime,inWareHouse,devCount,toLocation")] MultiDev multidev)
        {
            //DeviceFlowHistory history = new DeviceFlowHistory { toLocation = multidev.toLocation, flowDateTime = multidev.createTime, deviceStatus = ToyForSI.Models.Enum.DeviceStatus.Warehouse };
            //multidev.historys = new List<DeviceFlowHistory>() { history }.AsEnumerable();
            if (ModelState.IsValid)
            {
                //List<Device> devices=new List<Device>();
                for (int idx = 0; idx != multidev.devCount; idx++)
                {
                    DevModel          devModel = _context.DevModel.FirstOrDefault(d => d.devModelId == multidev.devModelId);
                    DeviceFlowHistory history  = new DeviceFlowHistory {
                        toLocation = multidev.toLocation, flowDateTime = multidev.createTime, deviceStatus = ToyForSI.Models.Enum.DeviceStatus.Warehouse
                    };
                    List <DeviceFlowHistory> h = new List <DeviceFlowHistory>
                    {
                        history
                    };
                    Device device =
                        new Device {
                        contractNo  = multidev.contractNo,
                        devModelId  = multidev.devModelId,
                        createTime  = multidev.createTime,
                        inWareHouse = multidev.inWareHouse,
                        historys    = h.AsEnumerable()
                    };
                    _context.Add(device);
                }
                await _context.SaveChangesAsync();

                //foreach (Device d in devices)
                //{
                //    DeviceFlowHistory history = new DeviceFlowHistory { toLocation = multidev.toLocation, deviceId = d.deviceId, transferDateTime = DateTime.Now };
                //    _context.Add(history);
                //}
                //await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["devModelId"] = new SelectList(_context.DevModel, "devModelId", "devModelName", multidev.devModelId);
            return(View(multidev));
        }
Esempio n. 13
0
        /// <summary>
        /// 新增数据库中没有增加的设备模型
        /// </summary>
        /// <param name="resultAction"></param>
        public void AddDevModelTypeByExcel(Action <int, int> resultAction = null)
        {
            int             modelCount   = 0;
            int             typeCount    = 0;
            var             list         = DbInfoHelper.GetDevModels();
            var             devModelList = DevModels.ToList();
            List <DevModel> newModels    = new List <DevModel>();

            foreach (var item in list)
            {
                if (string.IsNullOrEmpty(item.Name))
                {
                    continue;
                }
                if (devModelList == null)
                {
                    newModels.Add(item);
                }
                else
                {
                    DevModel model = devModelList.Find(i => i.Name == item.Name);
                    if (model == null)
                    {
                        newModels.Add(item);
                    }
                }
            }
            if (newModels.Count != 0)
            {
                modelCount = newModels.Count;
                DevModels.AddRange(newModels);
            }

            var            list2       = DbInfoHelper.GetDevTypes();
            var            devTypeList = DevTypes.ToList();
            List <DevType> newTypes    = new List <DevType>();

            foreach (var item in list2)
            {
                if (string.IsNullOrEmpty(item.TypeName))
                {
                    continue;
                }
                if (devTypeList == null)
                {
                    newTypes.Add(item);
                }
                else
                {
                    DevType model = devTypeList.Find(i => i.TypeName == item.TypeName);
                    if (model == null)
                    {
                        newTypes.Add(item);
                    }
                }
            }
            if (newTypes.Count != 0)
            {
                typeCount = newTypes.Count;
                DevTypes.AddRange(newTypes);
            }
            ClearModelTypeNullData(devModelList, DevModels, devTypeList, DevTypes);
            if (resultAction != null)
            {
                resultAction(modelCount, typeCount);
            }
        }
Esempio n. 14
0
        public DevModel GetDevClassByDevModel(string devModelName)
        {
            DevModel devModel = db.DevModels.FirstOrDefault(dev => dev.Name == devModelName);

            return(devModel);
        }