예제 #1
0
        public ActionResult MenuEdit_File(MenusModels MData, HttpPostedFileBase updFiles)
        {
            ViewBag.HasChildren = false;

            var childList = MenusDAO.GetChildren(MData.ID);

            if (childList != null && childList.Count() > 0)
            {
                ViewBag.HasChildren = true;
            }

            MenusDAO.Save_Single(MData);
            //單檔
            if (updFiles != null)
            {
                if (updFiles.ContentLength > 0)
                {
                    string uPath    = UpdFileInfo.GetUPathBySiteID(MData.SiteID, "Menus");
                    string fileName = UpdFileInfo.SaveFiles(updFiles, uPath);

                    ResourceFilesModels newFile = new ResourceFilesModels();

                    newFile.Id           = 1;
                    newFile.SiteID       = MData.SiteID;
                    newFile.SourceNo     = MData.ID;
                    newFile.SourceType   = (byte)SourceType.Menu;
                    newFile.Ver          = 1;
                    newFile.AreaID       = 1;
                    newFile.FileInfo     = fileName;
                    newFile.FileType     = ResourceFileType.inFile;
                    newFile.ClickType    = (byte)ClickType.OpenNewWin;
                    newFile.FileSize     = newFile.GetSize(uPath);
                    newFile.FileMimeType = newFile.GetMimeType();
                    ResourceFilesDAO.Save_Menu(newFile);
                }
                else
                {
                    ResourceFilesDAO.DelAll(MData.SiteID, MData.ID, (byte)SourceType.Menu, 1, 1);
                }
            }



            //多檔
            //List<ResourceFilesModels> newFileList = new List<ResourceFilesModels>();
            //int Count = 0;
            //foreach (var ff in updFiles)
            //{
            //    if (ff != null)
            //    {
            //        if (ff.ContentLength > 0)
            //        {
            //            Count += 1;
            //            var fileName = Path.GetFileName(ff.FileName);
            //            var path = Path.Combine(GetItem.UpdPath(GetItem.SiteID() + "\\Menus"), fileName);
            //            ff.SaveAs(path);

            //        }
            //    }
            //}

            SysLog.SaveLog(SysActions.Edit, SysMgrNo.Menu, MData.Title, MData.SiteID, MData.ID);
            TempData["refreshData"] = SysActions.Edit;
            Response.Redirect(Request.RawUrl);

            return(View());
        }