Ejemplo n.º 1
0
        public static async Task <Dosyalar> Kaydet(IFormFile file, IGenericService genericService)
        {
            var resim    = $"{DateTime.Now:yyyyMMddHHmmss.}{Path.GetFileName(file.FileName).Split(".").Last()}";
            var filePath = Path.Combine(Dir, resim).Replace("admin.", "");

            using (var fileStream = new FileStream(filePath, FileMode.Create))
            {
                await file.CopyToAsync(fileStream);
            }


//            string data;
//            using (var memoryStream = new MemoryStream())
//            {
//                file.CopyTo(memoryStream);
//                data = Convert.ToBase64String(memoryStream.ToArray());
//            }

            var dosya = new Dosyalar
            {
                Adi    = resim,
                Boyutu = file.Length,
                Tipi   = file.ContentType,
                Yolu   = filePath
            };
            await genericService.Save(dosya);

            return(dosya);
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "DosyaID,KurulID," +
                                          "DosyaAdi,DosyaYeniAdi,YukleyenPersNo,Aciklama,Tur")] Dosyalar dosya)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dosya).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "Dosyalar",
                                 routeValues: new { id = dosya.KurulID }));
     }
     return(View());
 }
        public bool DosyaDelete(int DosyaID)
        {
            using (okanorhancomBlogDB db = new okanorhancomBlogDB())
            {
                Dosyalar Delete = db.Dosyalar.Find(DosyaID);
                db.Dosyalar.Remove(Delete);
                db.SaveChanges();
            }
            var result = true;

            return(result);
        }
        public bool DosyaCreate(string SavePath)
        {
            using (okanorhancomBlogDB db = new okanorhancomBlogDB())
            {
                Dosyalar Kayit = new Dosyalar();
                Kayit.DosyaPath = SavePath;
                db.Dosyalar.Add(Kayit);
                db.SaveChanges();
            }
            var result = true;

            return(result);
        }
Ejemplo n.º 5
0
        public bool DeleteConfirmedAjax(int?id)
        {
            if (id == null)
            {
                return(false);
            }
            Dosyalar dosya = db.Dosyalar.Find(id);

            if (dosya == null)
            {
                return(false);
            }
            db.Dosyalar.Remove(dosya);
            db.SaveChanges();
            return(true);
        }
Ejemplo n.º 6
0
 public ActionResult Create(HttpPostedFileBase file, [Bind(Include = "DosyaID," +
                                                                     "KurulID,DosyaAdi,DosyaYeniAdi,YukleyenPersNo,Aciklama,Tur")] Dosyalar dosya)
 {
     if (ModelState.IsValid)
     {
         if (file != null && file.ContentLength > 0)
         {
             var fileName = Path.GetFileName(file.FileName);
             var path     = Path.Combine(Server.MapPath("~/Upload"), fileName);
             file.SaveAs(path);
             dosya.DosyaYeniAdi = "/Upload/" + fileName;
             db.Dosyalar.Add(dosya);
             db.SaveChanges();
         }
         return(RedirectToAction("Index", "Dosyalar",
                                 routeValues: new { id = dosya.KurulID }));
     }
     return(View());
 }
Ejemplo n.º 7
0
        public JsonResult FileUpload2(FormCollection collection, HttpPostedFileBase[] dosyalar)
        {
            int personelID = Convert.ToInt32(collection["personelID"]);

            if (dosyalar != null)
            {
                if (Directory.Exists(Server.MapPath("~/files")) == false)
                {
                    Directory.CreateDirectory(Server.MapPath("~/files"));
                }
                for (int i = 0; i < dosyalar.Length; i++)
                {
                    dosyalar[i].SaveAs(Server.MapPath("~/files/" + dosyalar[i].FileName));
                    Dosyalar dos = new Dosyalar();
                    dos.DosyaYolu  = "/files/" + dosyalar[i].FileName;
                    dos.PersonalId = personelID;
                    db.Dosyalar.Add(dos);
                }
                db.SaveChanges();
                return(Json(new { hasError = false, message = "dosya yüklendi" }));
            }
            return(Json(new { hasError = true, message = "dosya yüklenemedi" }));
        }
Ejemplo n.º 8
0
        public ActionResult DosyaGonder(int id, HttpPostedFileBase file)
        {
            Dosyalar          d  = new Dosyalar();
            DosyaGonderimleri dg = new DosyaGonderimleri();


            d.DosyaAciklamasi    = Request["dosyaAciklama"].ToString();
            d.DosyaYuklemeTarihi = DateTime.Now;
            d.DosyaDuyuruID      = Convert.ToInt32(Request["DosyaDuyuruId"]);
            var path = Path.Combine(Server.MapPath("/Dosyalar/DuyuruDosyalari/"), file.FileName);

            file.SaveAs(path);
            d.DosyaYolu     = "/Dosyalar/DuyuruDosyalari/" + file.FileName;
            d.DosyaSahibiID = Convert.ToInt32(Session["KullaniciId"]);
            icerik.Dosyalar.Add(d);
            icerik.SaveChanges();
            dg.DosyayiAlanID     = id;
            dg.DosyayıGonderenID = Convert.ToInt32(Session["KullaniciId"]);
            dg.GonderilenDosyaID = d.DosyaID;
            icerik.DosyaGonderimleri.Add(dg);
            icerik.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 9
0
        public Data()
        {
            XmlVeriEkle = new RelayCommand <object>(parameter =>
            {
                XmlDocument document = MainViewModel.xmlDataProvider.Document;
                XmlNode rootNode     = document.CreateElement("Veri");

                XmlAttribute Id            = document.CreateAttribute("Id");
                Id.Value                   = new Random().Next(1, int.MaxValue).ToString();
                XmlAttribute Saat          = document.CreateAttribute("Saat");
                Saat.Value                 = EtkinlikSüresi.ToString();
                XmlAttribute SaatBaslangic = document.CreateAttribute("SaatBaslangic");
                SaatBaslangic.Value        = SaatBaşlangıç;
                XmlAttribute Tekrar        = document.CreateAttribute("AyTekrar");
                Tekrar.Value               = AyTekrar.ToString().ToLower();

                rootNode.Attributes.Append(Id);
                rootNode.Attributes.Append(Saat);
                rootNode.Attributes.Append(SaatBaslangic);
                rootNode.Attributes.Append(Tekrar);

                XmlAttribute Renk = document.CreateAttribute("Renk");
                VeriRenk          = typeof(Brushes).GetProperties(BindingFlags.Public | BindingFlags.Static).Select(pi => (Brush)pi.GetValue(null, null)).Where(z => z != Brushes.Black && z != Brushes.White && z != Brushes.Transparent).OrderBy(_ => Guid.NewGuid()).Take(1).First();
                Renk.Value        = VeriRenk.ToString();
                rootNode.Attributes.Append(Renk);

                if (ÖnemliMi)
                {
                    XmlAttribute Onemli = document.CreateAttribute("Onemli");
                    Onemli.Value        = ÖnemliMi.ToString().ToLower();
                    rootNode.Attributes.Append(Onemli);
                }

                XmlAttribute TekrarGun = document.CreateAttribute("TekrarGun");
                TekrarGun.Value        = AyTekrarGun.ToString();
                rootNode.Attributes.Append(TekrarGun);

                if (KilitliMi)
                {
                    XmlAttribute Kilitli = document.CreateAttribute("Kilitli");
                    Kilitli.Value        = KilitliMi.ToString().ToLower();
                    rootNode.Attributes.Append(Kilitli);
                }

                XmlAttribute Okundu = document.CreateAttribute("Okundu");
                Okundu.Value        = "false";
                rootNode.Attributes.Append(Okundu);

                if (OcrMetin != null)
                {
                    XmlAttribute Ocr = document.CreateAttribute("Ocr");
                    Ocr.Value        = OcrMetin;
                    rootNode.Attributes.Append(Ocr);
                }

                XmlNode Gun   = document.CreateElement("Gun");
                Gun.InnerText = TamTarih.ToString("o");
                rootNode.AppendChild(Gun);

                XmlNode Aciklama   = document.CreateElement("Aciklama");
                Aciklama.InnerText = GünNotAçıklama;
                rootNode.AppendChild(Aciklama);

                if (ResimData != null && DosyaUzantı != null)
                {
                    XmlNode Resim = document.CreateElement("Resim");
                    rootNode.AppendChild(Resim);
                    XmlAttribute ResimExt = document.CreateAttribute("Ext");
                    ResimExt.Value        = DosyaUzantı;
                    Resim.Attributes.Append(ResimExt);
                    Resim.InnerText = Convert.ToBase64String(ResimData);
                }

                if (PdfData != null && DosyaUzantı != null)
                {
                    XmlNode Pdf = document.CreateElement("Pdf");
                    rootNode.AppendChild(Pdf);
                    XmlAttribute PdfExt = document.CreateAttribute("Ext");
                    PdfExt.Value        = DosyaUzantı;
                    Pdf.Attributes.Append(PdfExt);
                    Pdf.InnerText = Convert.ToBase64String(PdfData);
                }

                if (Dosyalar != null)
                {
                    XmlNode xmlnodeDosyalar = document.CreateElement("Dosyalar");
                    rootNode.AppendChild(xmlnodeDosyalar);
                    WriteFileListtoXml(document, xmlnodeDosyalar);
                }
                document.DocumentElement.AppendChild(rootNode);
                document.Save(MainViewModel.xmldatapath);
                VeriSayısı++;
                MainViewModel.xmlDataProvider.Refresh();
                CollectionViewSource.GetDefaultView((Application.Current.MainWindow.DataContext as MainViewModel)?.AyGünler).Refresh();
            }, parameter => !string.IsNullOrWhiteSpace(GünNotAçıklama) && DateTime.TryParseExact(SaatBaşlangıç, "H:m", new CultureInfo("tr-TR"), DateTimeStyles.None, out _));

            ResimYükle = new RelayCommand <object>(parameter =>
            {
                OpenFileDialog openFileDialog = new() { Multiselect = false, Filter = "Resim Dosyaları (*.jpg;*.jpeg;*.tif;*.tiff;*.png;*.webp)|*.jpg;*.jpeg;*.tif;*.tiff;*.png;*.webp" };
                if (openFileDialog.ShowDialog() == true)
                {
                    ResimYolu   = openFileDialog.FileName;
                    DosyaUzantı = ".webp";
                    ResimData   = Path.GetExtension(ResimYolu.ToLower()) == ".webp" ? File.ReadAllBytes(ResimYolu) : ResimYolu.WebpEncode(WebpQuality);
                }
            }, parameter => Environment.OSVersion.Version.Major > 5);

            PdfYükle = new RelayCommand <object>(parameter =>
            {
                OpenFileDialog openFileDialog = new() { Multiselect = false, Filter = "Pdf Dosyaları (*.pdf)|*.pdf" };
                if (openFileDialog.ShowDialog() == true)
                {
                    PdfData     = File.ReadAllBytes(openFileDialog.FileName);
                    DosyaUzantı = ".pdf";
                }
            }, parameter => Environment.OSVersion.Version.Major > 5);

            ResimSakla = new RelayCommand <object>(parameter =>
            {
                if (parameter is XmlElement xmlElement)
                {
                    SaveFileDialog saveFileDialog = new()
                    {
                        Title    = "SAKLA",
                        Filter   = "Resim Dosyaları (*.webp)|*.webp",
                        FileName = xmlElement["Aciklama"]?.InnerText + xmlElement.GetAttribute("Ext")
                    };

                    if (saveFileDialog.ShowDialog() == true && xmlElement["Resim"]?.InnerText != null)
                    {
                        byte[] bytes = Convert.FromBase64String(xmlElement["Resim"].InnerText);
                        using FileStream imageFile = new(saveFileDialog.FileName, FileMode.Create);
                        imageFile.Write(bytes, 0, bytes.Length);
                        imageFile.Flush();
                        bytes = null;
                    }
                }
            }, parameter => true);

            PencereKapat = new RelayCommand <object>(parameter => (parameter as Window)?.Close(), parameter => true);

            OcrUygula = new RelayCommand <object>(parameter =>
            {
                Task OcrTask = Task.Factory.StartNew(() =>
                {
                    OcrSürüyor = true;
                    OcrMetin   = (parameter as byte[]).WebpDecode().ToTiffJpegByteArray(ExtensionMethods.Format.Jpg).OcrYap();
                    OcrSürüyor = false;
                }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
            }, parameter => parameter is byte[] && !OcrSürüyor && Environment.OSVersion.Version.Major > 5 && Ocr.tesseractexsist);

            EkDosyaAç = new RelayCommand <object>(parameter =>
            {
                if (parameter is string yol)
                {
                    Process.Start(yol);
                }
            }, parameter => parameter is string yol && File.Exists(yol));

            DosyaGör = new RelayCommand <object>(parameter =>
            {
                if (parameter is XmlElement xmlElement)
                {
                    using Viewer viewer = new(xmlElement)
                          {
                              Owner = Application.Current.MainWindow
                          };
                    viewer.ShowDialog();
                }
            }, parameter => true);

            ArşivDosyasıEkle = new RelayCommand <object>(parameter =>
            {
                if (parameter is string arşivdosyayolu)
                {
                    if (File.Exists(arşivdosyayolu))
                    {
                        Dosyalar?.Add(arşivdosyayolu);
                    }
                    else
                    {
                        MessageBox.Show("Arşiv Dosyası Bulunamadı.", "TAKVİM", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }, parameter => true);

            XmlVeriSil = new RelayCommand <object>(parameter =>
            {
                if (parameter is XmlAttribute Id && MessageBox.Show("Seçili kaydı silmek istiyor musun?", "TAKVİM", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                {
                    foreach (XmlNode item in MainViewModel.xmlDataProvider.Document?.SelectNodes("/Veriler/Veri"))
                    {
                        if (item.Attributes["Id"].InnerText == Id.Value)
                        {
                            item.ParentNode.RemoveChild(item);
                        }
                    }
                    VeriSayısı--;
                    MainViewModel.xmlDataProvider.Document.Save(MainViewModel.xmldatapath);
                    MainViewModel.xmlDataProvider.Refresh();
                    CollectionViewSource.GetDefaultView((Application.Current.MainWindow.DataContext as MainViewModel)?.AyGünler).Refresh();
                }
            }, parameter => true);

            CsvDosyasınaYaz = new RelayCommand <object>(parameter =>
            {
                XmlDocument doc  = MainViewModel.xmlDataProvider.Document;
                string dosyaismi = Path.GetTempPath() + Guid.NewGuid() + ".csv";
                string seperator = new CultureInfo(CultureInfo.CurrentCulture.Name).TextInfo.ListSeparator;
                foreach (XmlNode item in doc.SelectNodes("//Veriler/Veri"))
                {
                    File.AppendAllText(dosyaismi, $"{item["Gun"]?.InnerText}{seperator}{item.Attributes["SaatBaslangic"]?.InnerText}{seperator}{item["Aciklama"]?.InnerText}\n", Encoding.UTF8);
                }
                Process.Start(dosyaismi);
            }, parameter => true);

            XmlVeriGüncelle = new RelayCommand <object>(parameter =>
            {
                if (parameter is XmlAttribute xmlattributeId)
                {
                    UpdateAttribute(xmlattributeId, "SaatBaslangic", SaatBaşlangıç);
                    UpdateAttribute(xmlattributeId, "Saat", EtkinlikSüresi.ToString());
                    UpdateAttribute(xmlattributeId, "AyTekrar", AyTekrar.ToString().ToLower());
                    UpdateAttribute(xmlattributeId, "Renk", VeriRenk.ToString());
                    UpdateAttribute(xmlattributeId, "TekrarGun", AyTekrarGun.ToString());
                }
            }, parameter => EtkinlikSüresi is <= 24 and >= 0 && VeriRenk is not null && DateTime.TryParseExact(SaatBaşlangıç, "H:m", new CultureInfo("tr-TR"), DateTimeStyles.None, out _));

            XmlRenkGüncelle = new RelayCommand <object>(parameter =>
            {
                if (parameter is XmlElement xmlElement)
                {
                    UpdateAttribute(int.Parse(xmlElement.GetAttribute("Id")), "Renk", xmlElement.GetAttribute("Renk"));
                }
            }, parameter => true);

            Resimİptal = new RelayCommand <object>(parameter => ResimData = null, parameter => ResimData?.Length > 0);

            Pdfİptal = new RelayCommand <object>(parameter => PdfData = null, parameter => PdfData?.Length > 0);

            PrintXmlData = new RelayCommand <object>(parameter =>
            {
                if (parameter is IEnumerable <XmlNode> list)
                {
                    FlowDocument fd = new();
                    foreach (XmlNode item in list)
                    {
                        fd.Blocks.Add(new Paragraph(new Run(item.Attributes.GetNamedItem("SaatBaslangic").InnerText + " " + item["Aciklama"].InnerText)));
                    }
                    PrintDialog pd = new();
                    pd.PrintDocument(((IDocumentPaginatorSource)fd).DocumentPaginator, "Yazdır");
                }
            }, parameter => true);

            Okunduİşaretle = new RelayCommand <object>(parameter =>
            {
                if (parameter is int id)
                {
                    UpdateAttribute(id, "Okundu", "true");
                }
            }, parameter => true);

            IcalEkle = new RelayCommand <object>(parameter =>
            {
                OpenFileDialog openFileDialog = new() { Multiselect = false, Filter = "Ical File (*.ics)|*.ics" };
                if (openFileDialog.ShowDialog() == true)
                {
                    try
                    {
                        VCalendar vcalendar = new(File.ReadAllText(openFileDialog.FileName));
                        foreach (VEvent data in vcalendar.vEvents)
                        {
                            foreach (KeyValuePair <string, ContentLine> item in data.ContentLines)
                            {
                                if (item.Key == "SUMMARY")
                                {
                                    GünNotAçıklama = item.Value.Value;
                                }

                                if (item.Key == "RRULE" && item.Value.Value.Contains("MONTHLY"))
                                {
                                    AyTekrar            = true;
                                    string aytekrardata = item.Value.Value.Split(';')?[1];
                                    if (aytekrardata?.Contains("BYMONTHDAY") == true)
                                    {
                                        AyTekrarGun = Convert.ToDouble(aytekrardata?.Split('=')?[1]);
                                    }
                                }

                                if (item.Key == "DTSTART")
                                {
                                    if (item.Value.Value.Length > 8)
                                    {
                                        SaatBaşlangıç = item.Value.Value.Substring(9, 2) + ":" + item.Value.Value.Substring(11, 2);
                                    }
                                    TamTarih = DateTime.ParseExact(item.Value.Value.Substring(0, 8), "yyyyMMdd", CultureInfo.CurrentCulture);
                                }
                            }
                            XmlVeriEkle.Execute(null);
                        }
                        TamTarih = DateTime.Today;
                        MessageBox.Show("Takvim Verileri Eklendi.", "TAKVİM", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "TAKVİM", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }, parameter => true);

            VeriEkleEkranı = new RelayCommand <object>(parameter =>
            {
                Window verigirişwindow = new()
                {
                    Title                 = TamTarih.ToString("dd MMMM yyyy dddd"),
                    Content               = new DataEnterWindow(),
                    DataContext           = parameter as Data,
                    Width                 = 504,
                    AllowsTransparency    = true,
                    WindowStyle           = WindowStyle.None,
                    Height                = 454,
                    Background            = Brushes.Transparent,
                    Owner                 = Application.Current.MainWindow,
                    ShowInTaskbar         = false,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };
                Dosyalar = new ObservableCollection <string>();
                verigirişwindow.MouseLeftButtonDown += (s, e) => verigirişwindow.DragMove();
                verigirişwindow.ShowDialog();
            }, parameter => true);
            PropertyChanged += Data_PropertyChanged;
        }

        public ICommand ArşivDosyasıEkle {
            get;
        }

        public ICommand CsvDosyasınaYaz {
            get;
        }