Beispiel #1
0
        public ActionResult AppUpdateAdd(FormCollection Form)
        {
            hx_AppUpdatePackage model = new hx_AppUpdatePackage();

            if (Form.Count < 1)
            {
                ViewBag.UpdateLevelList = GetUpdateLevel();
                ViewBag.PlatformList    = GetPlatformList();
                return(View(model));
            }

            model.Code        = Guid.NewGuid().ToString().Replace("-", "");
            model.Channel     = Form["channel"] ?? string.Empty;
            model.CreateTime  = DateTime.Now;
            model.DependCode  = Form["DependCode"] ?? string.Empty;
            model.Description = Form["Description"] ?? string.Empty;
            var canUse = Form["canUse"] ?? "否";

            if (canUse == "是")
            {
                model.IsEnable = 1;
            }
            else
            {
                model.IsEnable = 0;
            }
            model.DownloadCount = 0;
            model.Platform      = Form["Platform"] ?? string.Empty;
            string updateLevel = Form["UpdateLevel"];

            model.UpdateLevel = Convert.ToInt32(updateLevel);
            model.ValideCode  = string.Empty;
            model.Version     = Form["version"];
            model.VirtualPath = "";
            if (model.Platform == "IOS")
            {
                model.Channel     = "CLT";
                model.Ways        = "Apple Store";
                model.ValideCode  = "XxxxXxxxXxxxXxxxXxxxXxxxXxxxXxxx";
                model.VirtualPath = "";
            }
            else
            {
                model.Ways = "Http";
                var    uploadFile    = HttpContext.Request.Files[0];
                string directoryPath = Utils.GetPhysicalPath("Static/AppUpdate");
                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }
                string fileName = directoryPath + "/" + model.Code;
                uploadFile.SaveAs(fileName);
                string md5 = EncryptHelper.GetMD5HashFromFile(fileName);
                model.ValideCode  = md5;
                model.VirtualPath = "Static/AppUpdate/" + model.Code;
            }
            ef.hx_AppUpdatePackage.Add(model);
            ef.SaveChanges();
            return(Redirect("AppUpdateList"));
        }
Beispiel #2
0
 public int Add(hx_AppUpdatePackage model)
 {
     if (string.IsNullOrWhiteSpace(model.Code))
     {
         model.Code = Guid.NewGuid().ToString().Replace("-", "");
     }
     ef.hx_AppUpdatePackage.Add(model);
     return(ef.SaveChanges());
 }
Beispiel #3
0
        public List <hx_AppUpdatePackage> GetList(hx_AppUpdatePackage model)
        {
            long?id = null;

            if (model.id > 0)
            {
                id = model.id;
            }
            int?updateLevel = null;

            if (model.UpdateLevel > 0)
            {
                updateLevel = model.UpdateLevel;
            }

            return(GetList(id, model.Code, model.Platform, model.Version, updateLevel, model.Description, model.DependCode, model.Channel, model.ValideCode, model.VirtualPath, model.Ways, model.IsEnable, null, null, null));
        }
Beispiel #4
0
        public bool Update(long id, hx_AppUpdatePackage model)
        {
            var query = from data in ef.hx_AppUpdatePackage
                        where data.id == id
                        select data;
            var tmp = query.ToList().FirstOrDefault();

            if (tmp != null)
            {
                tmp.Channel       = model.Channel;
                tmp.DependCode    = model.DependCode;
                tmp.Description   = model.Description;
                tmp.DownloadCount = model.DownloadCount;
                tmp.IsEnable      = model.IsEnable;
                tmp.UpdateLevel   = model.UpdateLevel;
                tmp.ValideCode    = model.ValideCode;
                tmp.Version       = model.Version;
                tmp.VirtualPath   = model.VirtualPath;
                tmp.Ways          = model.Ways;
                ef.SaveChanges();
                return(true);
            }
            return(false);
        }
Beispiel #5
0
 public List <hx_AppUpdatePackage> GetList(hx_AppUpdatePackage where)
 {
     return(dal.GetList(where));
 }
Beispiel #6
0
 public bool Update(int id, hx_AppUpdatePackage model)
 {
     return(dal.Update(id, model));
 }
Beispiel #7
0
 public int Add(hx_AppUpdatePackage model)
 {
     return(dal.Add(model));
 }