Exemplo n.º 1
0
        protected void btnKaydet_Click(object sender, EventArgs e)
        {
            string url = Helper.GetUrl(txtBaslik.Text);

            if (GalleryId == 0)
            {
                string folder = ConfigurationManager.AppSettings["GalleryImagePath"] + @"\" + Helper.GetDirectory();
                //string GId = GalleryOprt.InsertGallery(Convert.ToInt32(ddListKategori.SelectedValue.ToString()), txtBaslik.Text, Convert.ToInt32(ddListTur.SelectedValue.ToString()), Convert.ToInt32(ddListAktifmi.SelectedValue.ToString()), url);
                //if (!string.IsNullOrEmpty(GId))
                //{
                //    if (FuGaleriGorseli.HasFile)
                //    {
                //        #region Galeri için seçilen görselin orjinali ve varyasyonları kaydediliyor.
                //        if (!Directory.Exists(folder))
                //            Directory.CreateDirectory(folder);
                //        byte[] imageByteArray = FuGaleriGorseli.FileBytes;
                //        MemoryStream stream = new MemoryStream();
                //        stream.Write(imageByteArray, 0, imageByteArray.Length);
                //        Bitmap imageBitMap = new Bitmap(stream);
                //        System.Drawing.Image yeniImg = System.Drawing.Image.FromStream(stream);
                //        int height = (yeniImg.Height * 640) / yeniImg.Width;
                //        UploadImage uploadGaleriResmi = new UploadImage();
                //        uploadGaleriResmi.SaveImageAllSize(imageBitMap, folder, GId, txtBaslik.Text);
                //        #endregion

                //        if (FuGaleriitems.HasFile)
                //        {
                //            string ItemsSql = "";
                //            #region Oluşturulan galeri fotogaleri ise galeri görselleri ekleniyor.
                //            string[] itemSummary = txtItemSummary.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                //            int itemSummaryCount = itemSummary.Length;
                //            for (int i = 0; i < FuGaleriitems.PostedFiles.Count; i++)
                //            {
                //                Bitmap imageBitMapitems = new Bitmap(FuGaleriitems.PostedFiles[i].InputStream);
                //                System.Drawing.Image yeniImgitem = System.Drawing.Image.FromStream(FuGaleriitems.PostedFiles[i].InputStream);
                //                int heightitem = (yeniImgitem.Height * 640) / yeniImgitem.Width;
                //                string imageName = url + "_" + GId + "_" + (i + 1) + Path.GetExtension(FuGaleriitems.PostedFiles[i].FileName);
                //                UploadImage uploaditems = new UploadImage();
                //                uploaditems.SaveImageSingle(imageBitMapitems, folder, imageName, 640, heightitem);

                //                if (i < itemSummaryCount)
                //                {
                //                    ItemsSql += "INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GId + ", '" + itemSummary[i].ToString() + "', 1, '" + folder + imageName + "', " + (i + 1) + "); ";
                //                }
                //                else
                //                {
                //                    ItemsSql += "INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GId + ", '', 1, '" + folder + imageName + "', " + (i + 1) + "); ";
                //                }
                //            }
                //            O_Gallery.InsertGalleryItems(ItemsSql);
                //            #endregion
                //        }
                //        else if (FuVideo.HasFile)
                //        {
                //            #region Oluşturulan galeri video ise galeri videosu ekleniyor.
                //            string VideoFolder = ConfigurationManager.AppSettings["GalleryVideoPath"] + @"\" + Helper.GetDirectory();
                //            if (!Directory.Exists(VideoFolder))
                //                Directory.CreateDirectory(VideoFolder);
                //            string file = VideoFolder + url + "_" + GId + Path.GetExtension(FuVideo.PostedFile.FileName);
                //            FuVideo.SaveAs(file);
                //            O_Gallery.InsertGalleryItems("INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GId + ", '" + txtVideoSummary.Text + "', 0, '" + file + "', 1)");
                //            #endregion
                //        }
                //    }
                //}
            }
            else
            {
                //GalleryOprt.UpdateGallery(Convert.ToInt32(ddListKategori.SelectedValue.ToString()), txtBaslik.Text, Convert.ToInt32(ddListTur.SelectedValue.ToString()), Convert.ToInt32(ddListAktifmi.SelectedValue.ToString()), url, GalleryId.ToString());
                //G = GalleryOprt.GalleryDetail(GalleryId);
                string folder = "";//G.FilePath;
                string GId    = GalleryId.ToString();
                if (!string.IsNullOrEmpty(GId))
                {
                    if (FuGaleriGorseli.HasFile)
                    {
                        #region Galeri için seçilen görselin orjinali ve varyasyonları kaydediliyor.
                        if (!Directory.Exists(folder))
                        {
                            Directory.CreateDirectory(folder);
                        }
                        byte[]       imageByteArray = FuGaleriGorseli.FileBytes;
                        MemoryStream stream         = new MemoryStream();
                        stream.Write(imageByteArray, 0, imageByteArray.Length);
                        Bitmap imageBitMap            = new Bitmap(stream);
                        System.Drawing.Image yeniImg  = System.Drawing.Image.FromStream(stream);
                        int         height            = (yeniImg.Height * 640) / yeniImg.Width;
                        UploadImage uploadGaleriResmi = new UploadImage();
                        uploadGaleriResmi.SaveImageAllSize(imageBitMap, folder, GId, txtBaslik.Text);
                        #endregion

                        if (FuGaleriitems.HasFile)
                        {
                            string ItemsSql = "";
                            #region Oluşturulan galeri fotogaleri ise galeri görselleri ekleniyor.
                            string[] itemSummary      = txtItemSummary.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                            int      itemSummaryCount = itemSummary.Length;
                            for (int i = 0; i < FuGaleriitems.PostedFiles.Count; i++)
                            {
                                Bitmap imageBitMapitems          = new Bitmap(FuGaleriitems.PostedFiles[i].InputStream);
                                System.Drawing.Image yeniImgitem = System.Drawing.Image.FromStream(FuGaleriitems.PostedFiles[i].InputStream);
                                int         heightitem           = (yeniImgitem.Height * 640) / yeniImgitem.Width;
                                string      imageName            = url + "_" + GalleryId + "_" + (i + 1) + Path.GetExtension(FuGaleriitems.PostedFiles[i].FileName);
                                UploadImage uploaditems          = new UploadImage();
                                uploaditems.SaveImageSingle(imageBitMapitems, folder, imageName, 640, heightitem);

                                if (i < itemSummaryCount)
                                {
                                    ItemsSql += "INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GalleryId + ", '" + itemSummary[i].ToString() + "', 1, '" + folder + imageName + "', " + (i + 1) + "); ";
                                }
                                else
                                {
                                    ItemsSql += "INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GalleryId + ", '', 1, '" + folder + imageName + "', " + (i + 1) + "); ";
                                }
                            }
                            //O_Gallery.InsertGalleryItems(ItemsSql);
                            #endregion
                        }
                        else if (FuVideo.HasFile)
                        {
                            #region Oluşturulan galeri video ise galeri videosu ekleniyor.
                            string VideoFolder = ConfigurationManager.AppSettings["GalleryVideoPath"] + @"\" + Helper.GetDirectory();
                            if (!Directory.Exists(VideoFolder))
                            {
                                Directory.CreateDirectory(VideoFolder);
                            }
                            string file = VideoFolder + url + "_" + GalleryId + Path.GetExtension(FuVideo.PostedFile.FileName);
                            FuVideo.SaveAs(file);
                            //O_Gallery.InsertGalleryItems("INSERT INTO GalleryItem (GalleryId, Summary, Type, FilePath, ItemOrder) VALUES (" + GalleryId + ", '" + txtVideoSummary.Text + "', 0, '" + file + "', 1)");
                            #endregion
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void btnKaydet_Click(object sender, EventArgs e)
        {
            int    _newsid      = 0;
            string _baslik      = txtMansetBaslik.Text;
            string _baslikUrl   = Helper.GetUrl(txtMansetBaslik.Text);
            string _ozet        = txtOzet.Text;
            string _haberMetni  = ckEditor.Value;
            string _etiket      = txtEtiketler.Text;
            int    _anaKategori = Convert.ToInt32(ddListKategori.SelectedValue);
            int    _newsType    = Convert.ToInt32(ddListTip.SelectedValue);
            int    _durum       = Convert.ToInt32(ddListAktifmi.SelectedValue);
            int    _yorum       = Convert.ToInt32(cbYorum.Checked);
            string _image       = "";

            //yeni haber ekleniyor
            if (NewsId == 0)
            {
                //_newsid = NewsOprt.Insert(_baslik, _baslikUrl, _ozet, _haberMetni, _durum, _yorum, _etiket, _anaKategori,_newsType);

                if (_newsid > 0)
                {
                    if (fuHaberGorseli.HasFile)
                    {
                        #region Haber için seçilen görselin orjinali ve varyasyonları kaydediliyor.

                        string folder = ConfigurationManager.AppSettings["NewsImagePath"] + Helper.GetDirectory();
                        if (!Directory.Exists(folder))
                        {
                            Directory.CreateDirectory(folder);
                        }

                        byte[]       imageByteArray = fuHaberGorseli.FileBytes;
                        MemoryStream stream         = new MemoryStream();
                        stream.Write(imageByteArray, 0, imageByteArray.Length);
                        Bitmap      imageBitMap        = new Bitmap(stream);
                        UploadImage uploadHaberGorseli = new UploadImage();
                        uploadHaberGorseli.SaveImageAllSize(imageBitMap, folder, _newsid.ToString(),
                                                            txtMansetBaslik.Text);
                        _image = folder + Helper.GetUrl(txtMansetBaslik.Text) + "_" + _newsid + ".jpg";

                        #endregion

                        //NewsOprt.Update(_image, _newsid);
                    }
                }
            }
            else //haber düzenleniyor
            {
                _newsid = NewsId;
                //NewsOprt.Update(_baslik, _newsid, _ozet, _haberMetni, _durum, _yorum, _etiket, _anaKategori);
                //M_News N = NewsOprt.NewsDetail(_newsid);
                if (fuHaberGorseli.HasFile)
                {
                    #region Haber için seçilen görselin orjinali ve varyasyonları kaydediliyor.

                    //string folder = ConfigurationManager.AppSettings["NewsImagePath"] + @"\" +N.PublishDate.ToString("yyyy/MM/dd").Replace(".", "/") + "/";
                    //if (!Directory.Exists(folder))
                    //    Directory.CreateDirectory(folder);

                    //byte[] imageByteArray = fuHaberGorseli.FileBytes;
                    //MemoryStream stream = new MemoryStream();
                    //stream.Write(imageByteArray, 0, imageByteArray.Length);
                    //Bitmap imageBitMap = new Bitmap(stream);
                    //UploadImage uploadHaberGorseli = new UploadImage();
                    //uploadHaberGorseli.SaveImageAllSize(imageBitMap, folder, _newsid.ToString(), txtMansetBaslik.Text);
                    //_image = folder + Helper.GetUrl(txtMansetBaslik.Text) + "_" + _newsid + ".jpg";

                    #endregion

                    //NewsOprt.Update(_image, _newsid);
                }
            }

            if (Session["VideoId"] != null)
            {
                //VideoOprt.Insert(_newsid, Convert.ToInt32(Session["VideoId"]), "haber");
                //NewsOprt.Update(Convert.ToInt32(Session["VideoId"]), _newsid);
            }
            //CrossOprt.InsertDigerKategoriler(ref cblDigerKategoriler, _newsid);
        }