Example #1
0
        public ActionResult Add(HttpPostedFileBase filedll)
        {
            if (filedll == null)
            {
                ModelState.AddModelError("Error", "请选择上传文件");
                return(View());
            }
            Stream dll = filedll.InputStream;

            byte[] dllbyte = new byte[dll.Length];
            dll.Read(dllbyte, 0, Convert.ToInt32(dll.Length));
            try
            {
                tb_cluster_collect_version_dal dal = new tb_cluster_collect_version_dal();
                using (DbConn PubConn = DbConfig.CreateConn(Config.PlatformManageConnectString))
                {
                    PubConn.Open();
                    tb_cluster_collect_version_model model = new tb_cluster_collect_version_model()
                    {
                        versionnum        = dal.GetMaxVersion(PubConn),
                        versioncreatetime = DateTime.Now,
                        zipfile           = dllbyte,
                        zipfilename       = filedll.FileName
                    };
                    dal.Add(PubConn, model);
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex.Message);
                return(View());
            }
        }