Esempio n. 1
0
        public long  MenuAddPage(long SiteID, long MenuID, long MenuSN, string Title, bool appendIdToName = false)
        {
            SQLData.Database db = new SQLData.Database(WebInfo.Conn);

            long   NewPageNO = GetItem.NewSN();
            string sql       =
                "INSERT Pages(No,Lang,Ver,SiteID,MenuID,SN,Title,ShowStatus,PublishStatus,Creator,CreateTime) VALUES(@No,@Lang,@Ver,@SiteID,@MenuID,@SN,@Title,@ShowStatus,@PublishStatus,@Creator,Getdate());\n";

            SQLData.ParameterCollection para = new SQLData.ParameterCollection();
            para.Add("@No", NewPageNO);
            para.Add("@Lang", "zh-tw");
            para.Add("@Ver", 1);
            para.Add("@MenuID", MenuID);
            para.Add("@SiteID", SiteID);
            para.Add("@SN", MenuSN);
            para.Add("@PublishStatus", 1);
            para.Add("@ShowStatus", 1);
            db.ExecuteNonQuery(sql, para);


            if (appendIdToName)
            {
                sql = " Update Pages Set SN = SN + '_'+ NO Where No = @NO ;\n";
            }
            SQLData.ParameterCollection para2 = new SQLData.ParameterCollection();
            para2.Add("@No", NewPageNO);
            db.ExecuteNonQuery(sql, para2);


            return(NewPageNO);
        }
Esempio n. 2
0
        public ActionResult Edit(PlainTextModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.IsValid = false;
                return(View(model));
            }

            DateTime now = DateTime.Now;

            if (model.ID == 0)
            {
                model.ID         = GetItem.NewSN();
                model.Creator    = MemberDAO.SysCurrent.Id;
                model.CreateTime = now;
            }

            model.Modifier   = MemberDAO.SysCurrent.Id;
            model.ModifyTime = now;

            int result = PlainTextDAO.Instance.Update(model);

            if (result == 0)
            {
                ViewBag.EditResult = "儲存發生錯誤";
            }
            else
            {
                ViewBag.EditResult = "儲存成功";
            }

            return(View(model));
        }
Esempio n. 3
0
        public static void SaveInfo(MenusModels data)
        {
            SQLData.Database db = new SQLData.Database(WebInfo.Conn);

            SQLData.TableObject TableObj = db.GetTableObject("Menus");
            //TableObj.GetDataFromObject(data);

            TableObj.Add("Title", data.Title);
            TableObj.Add("ShowStatus", data.ShowStatus);

            SQLData.ParameterCollection para = new SQLData.ParameterCollection();
            if (data.ID == 0)
            {
                TableObj.Add("ID", GetItem.NewSN());
                TableObj.Add("SN", data.SN);
                TableObj.Add("SiteID", data.SiteID);
                TableObj.Add("AreaID", data.AreaID);
                TableObj.Add("ParentID", data.ParentID);
                TableObj.Add("DataType", data.DataType);
                TableObj.Add("Sort", data.Sort);
                TableObj.Add("Creator", MemberDAO.SysCurrent.Id);
                TableObj.Add("CreateTime", DateTime.Now.ToString(WebInfo.DateTimeFmt));
                TableObj.Insert();
            }
            else
            {
                TableObj.Add("Modifier", MemberDAO.SysCurrent.Id);
                TableObj.Add("ModifyTime", DateTime.Now.ToString(WebInfo.DateTimeFmt));
                para.Add("@ID", data.ID);
                TableObj.Update(para);
            }
        }
Esempio n. 4
0
        public ActionResult ImgEdit(string[] imgs)
        {
            if (imgs == null || imgs.Length == 0)
            {
                ViewBag.Exit = true;
                return(View());
            }


            List <ClickImgModel> model = new List <ClickImgModel>();
            int index = 0;

            foreach (var img in imgs)
            {
                ClickImgModel data = JsonConvert.DeserializeObject <ClickImgModel>(img);
                if (data.ID == 0)
                {
                    data.ID = GetItem.NewSN();
                }

                model.Add(data);
                index++;
            }

            ViewBag.Data = JsonConvert.SerializeObject(model);
            ViewBag.Exit = true;

            return(View());
        }
Esempio n. 5
0
        public void MenuAdd(MenusModels MData)
        {
            long NewID = GetItem.NewSN();

            MData.ID = NewID;
            MenusDAO.Insert_Single(MData);

            List <CardsTypeModels> CardsType = CardsTypeDAO.GetData();
            CardsTypeModels        CT        = CardsType.FindLast(dr => dr.Code == MData.DataType);

            if (CT.isNeedSN == true)
            {
                //新增
                // PubFunc.AddPage(MData.SiteID, MData.ID, MData.SN, MData.DataType, CT.EditURLAction, false, MData.Title, 1, true);
                PubFunc.AddPage(MData.SiteID, MData.ID, MData.SN, MData.DataType, null, false, MData.Title, 1, true);
            }
            SysLog.SaveLog(SysActions.Add, SysMgrNo.Menu, MData.Title, MData.SiteID, MData.ID, null);
            if (CT != null)
            {
                Response.Redirect(Url.Action(CT.URLAction, "Menus", new { id = NewID, SiteID = MData.SiteID }));
            }
            else
            {
                TempData["refreshData"] = 1;
                Response.Redirect(Request.RawUrl);
            }
        }
Esempio n. 6
0
        public ActionResult VideoEdit(ClickVideoModel model, string customVideo)
        {
            if (model.Type == "custom")
            {
                model.Link = customVideo;
            }

            if (model.ID == 0)
            {
                model.ID = GetItem.NewSN();
            }

            ViewBag.Data = JsonConvert.SerializeObject(model);
            ViewBag.Exit = true;

            return(View());
        }
Esempio n. 7
0
        public static void SaveInfo(SysLogModels data)
        {
            SQLData.Database db = new SQLData.Database(WebInfo.Conn);

            SQLData.TableObject TableObj = db.GetTableObject("Syslog");
            TableObj.Add("ID", GetItem.NewSN());

            if (MemberDAO.SysCurrent != null)
            {
                TableObj.Add("MemberID", MemberDAO.SysCurrent.Id);
            }

            if (data.MgrNo != null)
            {
                TableObj.Add("MgrNo", data.MgrNo);
            }

            TableObj.Add("Actions", data.Actions);

            if (data.SiteID != null)
            {
                TableObj.Add("SiteID", data.SiteID);
            }

            if (data.MenuID != null)
            {
                TableObj.Add("MenuID", data.MenuID);
            }

            if (data.SourceID != null)
            {
                TableObj.Add("SourceID", data.SourceID);
            }

            TableObj.Add("ReMark", data.ReMark);
            TableObj.Add("AddTime", DateTime.Now.ToString(WebInfo.DateTimeFmt));

            string IP = GetItem.IPAddr();

            TableObj.Add("IP", IP);
            TableObj.Add("IPNum", GetItem.GetIPNum(IP));

            TableObj.Insert();
        }
Esempio n. 8
0
        public ActionResult VoiceEdit(string[] voices)
        {
            if (voices == null || voices.Length == 0)
            {
                ViewBag.Exit = true;
                return(View());
            }

            ClickVoiceModel model = JsonConvert.DeserializeObject <ClickVoiceModel>(voices[0]);

            if (model.ID == 0)
            {
                model.ID       = GetItem.NewSN();
                model.MimeType = uMimeType.GetMimeType(model.Path);
            }

            ViewBag.Data = JsonConvert.SerializeObject(model);
            ViewBag.Exit = true;

            return(View());
        }
Esempio n. 9
0
        public static void InsertLineNewsData(long SiteID, string SelectDate, long Sid, long SelectMenuID, IEnumerable <long> SelectIDs)
        {
            long userID = MemberDAO.SysCurrent.Id;

            #region 主table
            string Sql = "";
            if (isExistSelectDate(SiteID, SelectDate))
            {
                Sql = "update CustomLINENews Set Modifier = " + userID + ", ModifyTime= Getdate() where SiteID={0} and ID={1}";
            }
            else
            {
                Sql = "INSERT INTO [dbo].[CustomLINENews]([ID],[SiteID],[SelectDate],[Creator],[CreateTime])VALUES({1},{0},'" + SelectDate + "', " + userID + " ,GetDate())";
                Sid = GetItem.NewSN();
            }
            using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn))
            {
                conn.Execute(string.Format(Sql, SiteID, Sid));
            }
            #endregion

            #region 子資料
            System.Text.StringBuilder sql = new System.Text.StringBuilder();
            string fmt = " IF Not EXISTS (SELECT 1 FROM [CustomLINENewsData] WHERE [SourceID]={0} and SiteID={1} and SelectMenuID={2} and SelectID={3})\n " +
                         " INSERT INTO [dbo].[CustomLINENewsData]([ID],[SourceID],[SiteID],[SelectMenuID],[SelectID],[Creator],[CreateTime])VALUES({4},{0},{1} ,{2} ,{3} ," + userID + " ,GetDate()) \n ";
            int i = 0;
            if (SelectIDs.Count() > 0)
            {
                foreach (long SelectID in SelectIDs)
                {
                    sql.AppendFormat(fmt, Sid, SiteID, SelectMenuID, SelectID, GetItem.NewSN(), ++i);
                }

                using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn))
                {
                    conn.Execute(sql.ToString());
                }
            }
            #endregion
        }
Esempio n. 10
0
        public ActionResult FileEdit(long SiteID, long MenuID, string[] files)
        {
            if (files == null || files.Length == 0)
            {
                ViewBag.Exit = true;
                return(View());
            }

            ClickFileModel model = JsonConvert.DeserializeObject <ClickFileModel>(files[0]);

            if (model.ID == 0)
            {
                if (Request.Files.Count == 0)
                {
                    ViewBag.Exit = true;
                    return(View());
                }

                HttpPostedFileBase file = Request.Files[0];

                if (file == null || file.ContentLength == 0)
                {
                    ViewBag.Exit = true;
                    return(View());
                }

                string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(file, SiteID, MenuID);

                model.ID           = GetItem.NewSN();
                model.FileInfo     = fileName;
                model.FileSize     = file.ContentLength;
                model.FileMimeType = uMimeType.GetMimeType(fileName);
            }

            ViewBag.Data = JsonConvert.SerializeObject(model);
            ViewBag.Exit = true;

            return(View());
        }
Esempio n. 11
0
        /// <summary>
        /// 自訂目錄存檔
        /// </summary>
        /// <param name="updFiles"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static string SaveFiles(HttpPostedFileBase updFiles, string path, string Base64 = "", string Base64_Resize = "")
        {
            if (updFiles.ContentLength == 0)
            {
                return(null);
            }

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string oFileName = Path.GetFileName(updFiles.FileName);

            string fileName;

            if (File.Exists(path + "\\" + oFileName))
            {
                fileName = Path.GetFileNameWithoutExtension(path + "\\" + oFileName);
                lock (lockObj)
                {
                    string suffix = Regex.Match(updFiles.FileName, @"\.\w+$").Value;
                    fileName += "_" + GetItem.NewSN() + suffix;
                }
            }
            else
            {
                fileName = oFileName;
            }
            string saveFileFullPath = path + "\\" + fileName;

            if (!string.IsNullOrEmpty(Base64) &&
                FileExtensionsType.Base64_Pic.Contains(Path.GetExtension(fileName).Trim('.').ToLower()))
            {
                string baseString64 = Base64.Split(',')[1];
                var    bytes        = Convert.FromBase64String(baseString64);
                using (var imageFile = new FileStream(saveFileFullPath, FileMode.Create))
                {
                    imageFile.Write(bytes, 0, bytes.Length);
                    imageFile.Flush();
                    imageFile.Dispose();
                }
            }
            else
            {
                //圖片轉向 先註解
                //try
                //{
                //    Image img = Image.FromStream(updFiles.InputStream);

                //    foreach (var prop in img.PropertyItems)
                //    {
                //        if (prop.Id == 0x0112) //value of EXIF
                //        {
                //            int orientationValue = img.GetPropertyItem(prop.Id).Value[0];
                //            RotateFlipType rotateFlipType = GetOrientationToFlipType(orientationValue);
                //            img.RotateFlip(rotateFlipType);
                //            break;
                //        }
                //    }
                //    img.Save(saveFileFullPath);
                //}
                //catch
                //{
                updFiles.SaveAs(saveFileFullPath);
                //}
            }
            string saveResizeFileFullPath = path + "\\R_" + fileName;

            if (!string.IsNullOrEmpty(Base64_Resize) &&
                FileExtensionsType.Base64_Pic.Contains(Path.GetExtension(fileName).Trim('.').ToLower()))
            {
                string baseString64 = Base64_Resize.Split(',')[1];
                var    bytes        = Convert.FromBase64String(baseString64);
                using (var imageFile = new FileStream(saveResizeFileFullPath, FileMode.Create))
                {
                    imageFile.Write(bytes, 0, bytes.Length);
                    imageFile.Flush();
                    imageFile.Dispose();
                }
            }
            else
            {
                try
                {
                    Image img = Image.FromStream(updFiles.InputStream);

                    foreach (var prop in img.PropertyItems)
                    {
                        if (prop.Id == 0x0112) //value of EXIF
                        {
                            int            orientationValue = img.GetPropertyItem(prop.Id).Value[0];
                            RotateFlipType rotateFlipType   = GetOrientationToFlipType(orientationValue);
                            img.RotateFlip(rotateFlipType);
                            break;
                        }
                    }
                    img.Save(saveFileFullPath);
                }
                catch
                {
                    updFiles.SaveAs(saveResizeFileFullPath);
                }
            }
            //updFiles.SaveAs(path + "\\" + fileName);
            return(fileName);
        }
Esempio n. 12
0
        public ActionResult Edit(long SiteID, long MenuID, ParallaxModel model, HttpPostedFileBase ImgFile, string ImgFileBase64, string ImgFileBase64_Resize)
        {
            ViewBag.SiteID      = SiteID;
            ViewBag.MenuID      = MenuID;
            ViewBag.UploadVPath = UpdFileInfo.GetVPathByMenuID(SiteID, MenuID);

            if (!ModelState.IsValid)
            {
                ViewBag.IsValid = false;
                return(View(model));
            }

            #region 圖片

            if (!string.IsNullOrWhiteSpace(model.Img))
            {
                ImageModel imgModel = JsonConvert.DeserializeObject <ImageModel>(model.Img);
                if (imgModel.ID == 0)
                {
                    if (ImgFile == null || ImgFile.ContentLength == 0)
                    {
                        model.Img = string.Empty;
                    }
                    else
                    {
                        string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(ImgFile, SiteID, MenuID, ImgFileBase64, ImgFileBase64_Resize);
                        imgModel.ID  = GetItem.NewSN();
                        imgModel.Img = fileName;
                        model.Img    = JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            #endregion

            #region 儲存資料

            if (model.Description == null)
            {
                model.Description = "";
            }

            DateTime now = DateTime.Now;
            if (model.ID == 0)
            {
                model.ID         = GetItem.NewSN();
                model.Creator    = MemberDAO.SysCurrent.Id;
                model.CreateTime = now;
            }

            model.Modifier   = MemberDAO.SysCurrent.Id;
            model.ModifyTime = now;

            int result = ParallaxDAO.Instance.Update(model);
            if (result == 0)
            {
                ViewBag.EditResult = "儲存發生錯誤";
            }
            else
            {
                ViewBag.EditResult = "儲存成功";
            }

            return(View(model));

            #endregion
        }
Esempio n. 13
0
        public ActionResult Edit(long SiteID, long MenuID, MainVisionModel model,
                                 HttpPostedFileBase ImgFile, HttpPostedFileBase ImgMFile, HttpPostedFileBase fVideoImg, HttpPostedFileBase fVideoImgM, HttpPostedFileBase fIcon, HttpPostedFileBase fHoverIcon,
                                 string ImgFileBase64, string ImgMFileBase64, string fVideoImgBase64, string fVideoImgMBase64, string fIconBase64, string fHoverIconBase64,
                                 string ImgFileBase64_Resize, string ImgMFileBase64_Resize, string fVideoImgBase64_Resize, string fVideoImgMBase64_Resize, string fIconBase64_Resize, string fHoverIconBase64_Resize)
        {
            ViewBag.SiteID      = SiteID;
            ViewBag.MenuID      = MenuID;
            ViewBag.UploadVPath = UpdFileInfo.GetVPathByMenuID(SiteID, MenuID);

            if (!ModelState.IsValid)
            {
                ViewBag.IsValid = false;
                return(View(model));
            }

            #region 電腦版圖片

            if (!string.IsNullOrWhiteSpace(model.Img))
            {
                ImageModel imgModel = JsonConvert.DeserializeObject <ImageModel>(model.Img);
                if (imgModel.ID == 0)
                {
                    if (ImgFile == null || ImgFile.ContentLength == 0)
                    {
                        model.Img = string.Empty;
                    }
                    else
                    {
                        string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(ImgFile, SiteID, MenuID, ImgFileBase64, ImgFileBase64_Resize);
                        imgModel.ID  = GetItem.NewSN();
                        imgModel.Img = fileName;
                        model.Img    = JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            #endregion

            #region 手機版圖片

            if (!string.IsNullOrWhiteSpace(model.ImgM))
            {
                ImageModel imgModel = JsonConvert.DeserializeObject <ImageModel>(model.ImgM);
                if (imgModel.ID == 0)
                {
                    if (ImgMFile == null || ImgMFile.ContentLength == 0)
                    {
                        model.ImgM = string.Empty;
                    }
                    else
                    {
                        string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(ImgMFile, SiteID, MenuID, ImgMFileBase64, ImgMFileBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = fileName;
                        model.ImgM   = JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            #endregion

            #region 影片截圖

            if (model.VideoImgIsCustom)
            {
                if (!string.IsNullOrWhiteSpace(model.VideoImg))
                {
                    if (model.VideoImg[0] == '{')
                    {
                        ImageModel imgModel = JsonConvert.DeserializeObject <ImageModel>(model.VideoImg);
                        if (imgModel.ID == 0)
                        {
                            if (fVideoImg == null || fVideoImg.ContentLength == 0)
                            {
                                model.VideoImg = string.Empty;
                            }
                            else
                            {
                                string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(fVideoImg, SiteID, MenuID, fVideoImgBase64, fVideoImgBase64_Resize);
                                imgModel.ID    = 1;
                                imgModel.Img   = fileName;
                                model.VideoImg = JsonConvert.SerializeObject(imgModel);
                            }
                        }
                    }
                    else
                    {
                        model.VideoImg = string.Empty;
                    }
                }

                if (!string.IsNullOrWhiteSpace(model.VideoImgM))
                {
                    if (model.VideoImgM[0] == '{')
                    {
                        ImageModel imgModel = JsonConvert.DeserializeObject <ImageModel>(model.VideoImgM);
                        if (imgModel.ID == 0)
                        {
                            if (fVideoImgM == null || fVideoImgM.ContentLength == 0)
                            {
                                model.VideoImgM = string.Empty;
                            }
                            else
                            {
                                string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(fVideoImgM, SiteID, MenuID, fVideoImgMBase64, fVideoImgMBase64_Resize);
                                imgModel.ID     = 1;
                                imgModel.Img    = fileName;
                                model.VideoImgM = JsonConvert.SerializeObject(imgModel);
                            }
                        }
                    }
                    else
                    {
                        model.VideoImgM = string.Empty;
                    }
                }
            }

            #endregion

            #region Icon

            if (!string.IsNullOrWhiteSpace(model.Icon))
            {
                ImageModel imgModel = JsonConvert.DeserializeObject <ImageModel>(model.Icon);
                if (imgModel.ID == 0)
                {
                    if (fIcon == null || fIcon.ContentLength == 0)
                    {
                        model.Icon = string.Empty;
                    }
                    else
                    {
                        string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(fIcon, SiteID, MenuID, fIconBase64, fIconBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = fileName;
                        model.Icon   = JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            #endregion

            #region HoverIcon

            if (!string.IsNullOrWhiteSpace(model.HoverIcon))
            {
                ImageModel imgModel = JsonConvert.DeserializeObject <ImageModel>(model.HoverIcon);
                if (imgModel.ID == 0)
                {
                    if (fHoverIcon == null || fHoverIcon.ContentLength == 0)
                    {
                        model.HoverIcon = string.Empty;
                    }
                    else
                    {
                        string fileName = Golbal.UpdFileInfo.SaveFilesByMenuID(fHoverIcon, SiteID, MenuID, fHoverIconBase64, fHoverIconBase64_Resize);
                        imgModel.ID     = 1;
                        imgModel.Img    = fileName;
                        model.HoverIcon = JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            #endregion
            if (!ModelState.IsValid)
            {
                ViewBag.IsValid = false;
                return(View(model));
            }

            #region 儲存資料

            DateTime now = DateTime.Now;
            if (model.ID == 0)
            {
                model.ID         = GetItem.NewSN();
                model.Creator    = MemberDAO.SysCurrent.Id;
                model.CreateTime = now;
            }

            model.Modifier   = MemberDAO.SysCurrent.Id;
            model.ModifyTime = now;

            int result = MainVisionDAO.Instance.Update(model);
            if (result == 0)
            {
                ViewBag.EditResult = "儲存發生錯誤";
            }
            else
            {
                ViewBag.EditResult = "儲存成功";
            }

            return(View(model));

            #endregion
        }