예제 #1
0
        public String DataReader2XmlString(IDataReader reader, string tablename)
        {
            StringBuilder strBuilder = new StringBuilder();

            try
            {
                string tableName = Metin.GecerliMi(tablename) ? tablename : table;
                strBuilder.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                strBuilder.AppendFormat("<{0}>\n", tableName + "s");
                while (reader.Read())
                {
                    strBuilder.AppendFormat("<{0}>\n", tableName);
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        strBuilder.AppendFormat("<{0}>{1}</{2}>\n",
                                                reader.GetName(i), reader.GetString(i), reader.GetName(i));
                    }
                    strBuilder.AppendFormat("</{0}>\n", tableName);
                }
                strBuilder.AppendFormat("</{0}>\n", tableName + "s");
            }
            catch (Exception)
            {
                strBuilder = new StringBuilder();
                strBuilder.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            }
            return(strBuilder.ToString());
        }
예제 #2
0
        protected override void Seed(MyDiary.Models.ApplicationDbContext context)
        {
            if (!context.Users.Any(x => x.UserName == "*****@*****.**"))
            {
                ApplicationUser user = new ApplicationUser
                {
                    UserName = "******",
                    Email    = "*****@*****.**"
                };

                var userStore   = new UserStore <ApplicationUser>(context);
                var userManager = new UserManager <ApplicationUser>(userStore);
                userManager.Create(user, "Ankara1.");

                Metin metin = new Metin
                {
                    Baslik            = "Ýlk Metin",
                    Icerik            = "Bir masal gibi geçti tüm yaþananlar.",
                    OluþturulmaTarihi = DateTime.Now,
                    YazarId           = user.Id
                };

                context.Metinler.Add(metin);
                context.SaveChanges();
            }
        }
        public void OzetKelimelerAyarla(List <dbTez> list)
        {
            string islenecekKelimeler = "";
            Metin  metin;
            Dictionary <string, int> sozluk;

            string kelimeler = ciktiManager.GetAll().Where(c => c.Bolum.Id == list[0].Bolum.Id).FirstOrDefault().CiktiKelimeler;

            string[] sonKelimeler = kelimeler.Split('|');
            foreach (var item in list)
            {
                metin  = new Metin(item.TezOzet);
                sozluk = metin.SozlukGetir();

                Console.WriteLine("sozluk +" + sozluk.Count);

                foreach (var sozlukitem in sozluk)
                {
                    for (int i = 0; i < sonKelimeler.Length; i++)
                    {
                        if (sonKelimeler[i] == sozlukitem.Key)
                        {
                            islenecekKelimeler += sonKelimeler[i] + "|";
                        }
                    }
                }

                //Console.WriteLine(islenecekKelimeler);
                item.OzetKelime = islenecekKelimeler;
                tezManager.Update(item);
                islenecekKelimeler = "";
                //Console.ReadLine();
            }
        }
        public void CiktiKelimelerAyarla(List <dbTez> tez)
        {
            string gmetin = "";

            for (int i = 0; i < tez.Count; i++)
            {
                gmetin += tez[i].TezOzet;
            }

            Metin metin = new Metin(gmetin);
            Dictionary <string, int> sozluk = metin.SozlukGetir();
            string sonMetin = "";

            foreach (var item in sozluk)
            {
                if (item.Value < 50)
                {
                    sonMetin += item.Key + "|";
                }
            }
            List <dbCikti> s = ciktiManager.GetAll().Where(c => c.Bolum.Id == tez[0].Bolum.Id).ToList();

            Console.WriteLine("Sozluk Uzunlugu " + sozluk.Count);
            if (s.Count == 0)
            {
                ciktiManager.Add(new dbCikti()
                {
                    CiktiKelimeler = sonMetin, Bolum = tez[0].Bolum
                });
            }
            else
            {
                //BURAYA CIKTIMANAGER UPDATE METODU GELECEK.
            }
        }
예제 #5
0
        public void CiktiKelimelerAyarla()
        {
            List <dbTez> tez = tezManager.GetAll().ToList();

            string gmetin = "";

            for (int i = 0; i < tez.Count; i++)
            {
                gmetin += tez[i].TezOzet;
            }

            Metin metin = new Metin(gmetin);
            Dictionary <string, int> sozluk = metin.SozlukGetir();
            string sonMetin = "";

            foreach (var item in sozluk)
            {
                if (item.Value < 50)
                {
                    sonMetin += item.Key + "|";
                }
            }

            Console.WriteLine("Sozluk Uzunlugu " + sozluk.Count);
            ciktiManager.Add(new dbCikti()
            {
                Id = 0, CiktiKelimeler = sonMetin
            });
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader">DataReader nesnesi</param>
        /// <param name="tablename">Xml de gösterilecek tablo ismi</param>
        /// <returns>Xml dosyası döndürür.</returns>
        public XmlDocument DataReader2Xml(IDataReader reader, string tablename)
        {
            XmlDocument doc = null;

            try
            {
                doc = new XmlDocument();
                XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
                doc.AppendChild(docNode);
                string  tableName = Metin.GecerliMi(tablename) ? tablename : table;
                XmlNode rootNode  = doc.CreateElement(tableName + "s");
                doc.AppendChild(rootNode);

                while (reader.Read())
                {
                    XmlNode rowNode = doc.CreateElement(tableName);
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        XmlNode colNode = doc.CreateElement(reader.GetName(i));
                        colNode.InnerText = reader.GetString(i);
                        rowNode.AppendChild(colNode);
                    }

                    rootNode.AppendChild(rowNode);
                }
            }
            catch (Exception)
            {
                doc = null;
            }
            return(doc);
        }
예제 #7
0
        public DataSet GetDataSetWithConnection(IDbConnection Conn,
                                                CommandType cmdType, string QueryOrProcedure, params Param[] parameters)
        {
            DataSet dS = new DataSet();

            if (Conn.State != ConnectionState.Open)
            {
                Conn.Open();
            }

            using (IDbTransaction dbTrans = Conn.BeginTransaction())
            {
                try
                {
                    using (IDbCommand dbCmd = Conn.CreateCommand())
                    {
                        dbCmd.Transaction = dbTrans;
                        dbCmd.CommandText = QueryOrProcedure;
                        dbCmd.CommandType = cmdType;
                        foreach (Param p in parameters)
                        {
                            if (!Metin.GecerliMi(p.Name))
                            {
                                throw new Exception("Parameter name could not be empty or null.");
                            }

                            IDataParameter dbParameter =
                                GetParameter(Conn);

                            dbParameter.ParameterName = p.Name;
                            dbParameter.Value         = p.Value;
                            dbCmd.Parameters.Add(dbParameter);
                        }



                        IDataAdapter dbAdapter = GetDataAdapter(Conn);
                        dbAdapter.Fill(dS);

                        dbTrans.Commit();

                        dbCmd.Parameters.Clear();
                    } // end dbcmd
                }     // end try
                catch (Exception exc)
                {
                    dbTrans.Rollback();
                    throw exc;
                }
                finally
                {
                    Conn.Close();
                    GC.Collect();
                }
            } // end dbTrans


            return(dS);
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionstring">Connection String</param>
        /// <param name="procedurename">Query</param>
        /// <param name="parameters">Paramaters array as Param type</param>
        /// <see cref="tr.mustaliscl.data.Param"/>
        /// <returns>Returns a DataSet with given parameters</returns>
        public DataSet GiveDataSetWithGivenProcedureAndParameters(
            ConnectionTypes conType,
            string ConnStr, string procedurename, params Param[] parameters)
        {
            DataSet dS = new DataSet();

            using (IDbConnection dbConn = GetConnection(conType))
            {
                dbConn.ConnectionString = ConnStr;
                using (IDbTransaction dbTrans = dbConn.BeginTransaction())
                {
                    try
                    {
                        using (IDbCommand dbCmd = dbConn.CreateCommand())
                        {
                            dbCmd.Transaction = dbTrans;
                            dbCmd.CommandText = procedurename;
                            dbCmd.CommandType = CommandType.StoredProcedure;
                            foreach (Param p in parameters)
                            {
                                if (!Metin.GecerliMi(p.Name))
                                {
                                    throw new Exception("Parameter name could not be empty or null.");
                                }

                                IDataParameter dbParameter =
                                    GetParameter(conType);

                                dbParameter.ParameterName = p.Name;
                                dbParameter.Value         = p.Value;
                                dbCmd.Parameters.Add(dbParameter);
                            }

                            dbConn.Open();

                            IDataAdapter dbAdapter = GetDataAdapter(conType, dbCmd);
                            dbAdapter.Fill(dS);

                            dbTrans.Commit();

                            dbCmd.Parameters.Clear();
                        } // end dbcmd
                    }     // end try
                    catch (Exception exc)
                    {
                        dbTrans.Rollback();
                        throw exc;
                    }
                    finally
                    {
                        dbConn.Close();
                        GC.Collect();
                    }
                } // end dbTrans
            }     // end dbConn

            return(dS);
        }
예제 #9
0
        public Int32 ExecuteQueryWithGivenParameters(ConnectionTypes conType,
                                                     string ConnStr, string query, params Param[] parameters)
        {
            Int32 willBeReturn;

            using (IDbConnection dbConn = GetConnection(conType))
            {
                dbConn.ConnectionString = ConnStr;
                using (IDbTransaction dbTrans = dbConn.BeginTransaction())
                {
                    try
                    {
                        using (IDbCommand dbCmd = dbConn.CreateCommand())
                        {
                            dbCmd.Transaction = dbTrans;
                            dbCmd.CommandText = query;
                            dbCmd.CommandType = CommandType.Text;
                            foreach (Param p in parameters)
                            {
                                if (!Metin.GecerliMi(p.Name))
                                {
                                    throw new Exception("Parameter name could not be empty or null.");
                                }

                                IDataParameter dbParameter = GetParameter(conType);
                                dbParameter.ParameterName = p.Name;
                                dbParameter.Value         = p.Value;
                                dbCmd.Parameters.Add(dbParameter);
                            }

                            dbConn.Open();

                            willBeReturn = dbCmd.ExecuteNonQuery();

                            dbTrans.Commit();

                            dbCmd.Parameters.Clear();
                            dbConn.Close();
                        } // end dbcmd
                    }     // end try
                    catch (Exception exc)
                    {
                        dbTrans.Rollback();
                        throw exc;
                    }
                    finally
                    {
                        dbConn.Close();
                        GC.Collect();
                    }
                } // end dbTrans
            }     // end dbConn

            return(willBeReturn);
        }
예제 #10
0
        private void eToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog Klasor = new FolderBrowserDialog();

            Klasor.ShowDialog();
            DirectoryInfo Dosyalar = new DirectoryInfo(Klasor.SelectedPath);

            foreach (FileInfo item in Dosyalar.GetFiles())
            {
                string eni = "", boyu = "", Adi = "";
                int    Sayac = 0, Sayac1 = 0, Sayac2 = 0, Kolon = 1;
                foreach (var Metin in item.Name.ToCharArray())
                {
                    if (Sayac == 0)
                    {
                        if (Metin.ToString() != "x" && Metin.ToString() != "X")
                        {
                            eni = eni + Metin.ToString();
                        }
                        else
                        {
                            Sayac = 1;
                        }
                    }
                    else
                    {
                        if (Metin.ToString() != " " && Sayac1 == 0)
                        {
                            boyu = boyu + Metin.ToString();
                        }
                        else
                        {
                            Sayac1 = 1;
                            if (Metin.ToString() != "." && Sayac2 == 0)
                            {
                                Adi = Adi + Metin.ToString();
                            }
                            else
                            {
                                Sayac2 = 1;
                            }
                        }
                    }
                }
                double en = Convert.ToDouble(eni), boy = Convert.ToDouble(boyu);
                double Metrekaresi = Math.Round(((en * boy) / 100) / 100, 2);//çok önemli metrekare hesabı
                Tablosu.Rows.Add(eni + "X" + boyu, Adi, Metrekaresi.ToString());
                Kolon++;
                Sayac  = 0;
                Sayac1 = 0;
                Sayac2 = 0;
            }
            gridControl1.DataSource = Tablosu;
        }
예제 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectionstring">Connection String</param>
        /// <param name="procedurename">Query</param>
        /// <param name="parameters">Paramaters array as Param type</param>
        /// <see cref="tr.mustaliscl.data.Param"/>
        /// <returns>Returns a DataSet with given parameters</returns>
        public DataSet GetDataSetWithGivenQuery(string ConnStr, string query, params Param[] parameters)
        {
            DataSet dS = new DataSet();

            using (SqlConnection conn = new SqlConnection(ConnStr))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        using (SqlCommand cmd = conn.CreateCommand())
                        {
                            cmd.CommandText = query;
                            cmd.CommandType = CommandType.Text;
                            cmd.Transaction = trans;

                            if (parameters != null)
                            {
                                foreach (Param p in parameters)
                                {
                                    if (Metin.GecerliMi(p.Name))
                                    {
                                        cmd.Parameters.AddWithValue(p.Name, p.Value);
                                    }
                                    else
                                    {
                                        throw new Exception();
                                    }
                                }
                            }
                            //conn.Open();
                            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                            adapter.Fill(dS);
                            trans.Commit();
                            cmd.Parameters.Clear();
                        } // end sql cmd
                    }
                    catch (Exception exc)
                    {
                        trans.Rollback();
                        throw exc;
                    }
                    finally
                    {
                        conn.Close();
                        SqlConnection.ClearPool(conn);
                        GC.Collect();
                    }
                }// end trans
            }
            return(dS);
        }// end GetDataSetWithGivenQuery method
예제 #12
0
        }// end GetDataSetWithGivenQuery method

        #endregion



        #region [Get DataSet With Given Procedure And Parameters]
        /// <summary>
        ///
        /// </summary>
        /// <param name="ConnStr">Connection String</param>
        /// <param name="procedurename">Procedure Name will be used</param>
        /// <param name="parameters">Paramaters array as Param type</param>
        /// <see cref="tr.mustaliscl.data.Param"/>
        /// <returns>Returns a DataSet with given parameters</returns>
        public DataSet GetDataSetWithGivenProcedureAndParameters(string ConnStr, string procedurename, params Param[] parameters)
        {
            DataSet dS = new DataSet();


            using (SqlConnection conn = new SqlConnection(ConnStr))
            {
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        using (SqlCommand cmd = conn.CreateCommand())
                        {
                            cmd.CommandText = procedurename;
                            cmd.CommandType = CommandType.StoredProcedure;

                            foreach (Param p in parameters)
                            {
                                if (Metin.GecerliMi(p.Name))
                                {
                                    cmd.Parameters.AddWithValue(p.Name, p.Value);
                                }
                                else
                                {
                                    throw new Exception();
                                }
                            }

                            conn.Open();
                            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                            adapter.Fill(dS);
                            trans.Commit();
                            adapter.Dispose();
                            cmd.Parameters.Clear();
                        } // end sql cmd
                    }
                    catch (Exception exc)
                    {
                        trans.Rollback();
                        throw exc;
                    }
                    finally
                    {
                        conn.Close();
                        GC.Collect();
                    }
                }// end trans
                SqlConnection.ClearPool(conn);
            }
            return(dS);
        } // end GiveDataSetWithGivenProcedureAndParameters method
예제 #13
0
        private void excellKaydetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog Dosya = new OpenFileDialog();

            Dosya.ShowDialog();
            string eni = "", boyu = "", Adi = "";
            int    Sayac = 0, Sayac1 = 0, Sayac2 = 0, Kolon = 0;

            foreach (var Metin in Dosya.SafeFileName)
            {
                if (Sayac == 0)
                {
                    if (Metin.ToString() != "x" && Metin.ToString() != "X")
                    {
                        eni = eni + Metin.ToString();
                    }
                    else
                    {
                        Sayac = 1;
                    }
                }
                else
                {
                    if (Metin.ToString() != " " && Sayac1 == 0)
                    {
                        boyu = boyu + Metin.ToString();
                    }
                    else
                    {
                        Sayac1 = 1;
                        if (Metin.ToString() != "." && Sayac2 == 0)
                        {
                            Adi = Adi + Metin.ToString();
                        }
                        else
                        {
                            Sayac2 = 1;
                        }
                    }
                }
            }
            double en = Convert.ToDouble(eni), boy = Convert.ToDouble(boyu);
            double Metrekaresi = Math.Round(((en * boy) / 100) / 100, 2);//çok önemli metrekare hesabı

            Tablosu.Rows.Add(eni + "X" + boyu, Adi, Metrekaresi.ToString());
            Kolon++;
            Sayac  = 0;
            Sayac1 = 0;
            Sayac2 = 0;
            gridControl1.DataSource = Tablosu;
        }
예제 #14
0
        public IHttpActionResult MetinEkle(PostMetinDTO model)
        {
            Metin metin = new Metin
            {
                YazarId           = User.Identity.GetUserId(),
                OluşturulmaTarihi = DateTime.Now,
                Baslik            = model.Baslik,
                Icerik            = model.Icerik,
            };

            db.Metinler.Add(metin);
            db.SaveChanges();
            return(Ok(metin));
        }
예제 #15
0
        public IHttpActionResult MetinSil(int id)
        {
            Metin metin = db.Metinler.Find(id);

            if (metin.YazarId != UserId)
            {
                return(Unauthorized());
            }

            db.Metinler.Remove(metin);
            metin.DüzenlenmeTarihi = DateTime.Now;
            db.SaveChanges();
            return(Ok(metin));
        }
예제 #16
0
        public IHttpActionResult MetinGuncelle(UpdateMetinDTO model)
        {
            if (ModelState.IsValid)
            {
                Metin metin = db.Metinler.Find(model.Id);
                if (metin.YazarId != UserId)
                {
                    return(Unauthorized());
                }
                metin.Baslik           = model.Baslik;
                metin.Icerik           = model.Icerik;
                metin.DüzenlenmeTarihi = DateTime.Now;

                db.SaveChanges();

                return(Ok(metin));
            }
            return(BadRequest());
        }
        public void BaslikKelimelerAyarla(List <dbTez> list)
        {
            string islenecekKelimeler = "";
            Metin  metin;
            string sonkelime = "";

            foreach (var item in list)
            {
                islenecekKelimeler = item.TezAdi;
                islenecekKelimeler = islenecekKelimeler.ToLower();
                islenecekKelimeler = islenecekKelimeler.Replace("ve", "");
                islenecekKelimeler = islenecekKelimeler.Replace("ile", "");
                metin = new Metin(islenecekKelimeler);
                foreach (var sozluk in metin.MetinKelimeler())
                {
                    sonkelime += sozluk + "|";
                }
                item.BaslikKelime = sonkelime;
                tezManager.Update(item);
                sonkelime = "";
            }
        }
예제 #18
0
        public Dictionary <dbTez, float> KarsilastirmaBaslat(string girdiMetin)
        {
            float         benzerlikOrani        = 0;
            int           AgirlikDegeri         = 0;
            Metin         metin                 = new Metin(girdiMetin);
            List <string> gelenKelimeler        = metin.MetinKelimeler();
            float         ToplamKelimeKaysayisi = gelenKelimeler.Count * ToplamAgirlik;

            girdiMetin = girdiMetin.ToLower();
            string[] KeywordKarsilastirma = girdiMetin.Split(' ');

            List <string>             VeritabaniKelimeler;
            Dictionary <dbTez, float> Sonuclar = new Dictionary <dbTez, float>();
            List <dbTez> liste               = tezManager.GetAll().ToList();
            int          BaslikIndexTutucu   = -5;
            int          BaslikPuanKatlayici = 1;

            foreach (var item in liste)
            {
                VeritabaniKelimeler = item.BaslikKelime.Split('|').ToList();
                for (int i = 0; i < gelenKelimeler.Count; i++)
                {
                    for (int j = 0; j < VeritabaniKelimeler.Count; j++)
                    {
                        if (gelenKelimeler[i] == VeritabaniKelimeler[j])
                        {
                            if (BaslikIndexTutucu >= 0 && (BaslikIndexTutucu + 1) == j)
                            {
                                AgirlikDegeri += BaslikPuanKatlayici;
                                BaslikPuanKatlayici++;
                                //		System.Diagnostics.Debug.WriteLine("Baslik Katlayici Artiyor " + BaslikPuanKatlayici);
                            }
                            else
                            {
                                BaslikPuanKatlayici = 1;
                            }
                            //	System.Diagnostics.Debug.WriteLine(i+" BASLIK ESLESMELERI INDEX"+j );
                            AgirlikDegeri += BaslikAgirlik;
                            //	System.Diagnostics.Debug.WriteLine(ToplamAgirlik + " BASLIK ESLESTI " + AgirlikDegeri);
                            BaslikIndexTutucu = j;
                            break;
                        }
                    }
                }

                VeritabaniKelimeler = item.OzetKelime.Split('|').ToList();
                for (int i = 0; i < gelenKelimeler.Count; i++)
                {
                    for (int j = 0; j < VeritabaniKelimeler.Count; j++)
                    {
                        if (gelenKelimeler[i] == VeritabaniKelimeler[j])
                        {
                            AgirlikDegeri += OzetAgirlik;
                            //	System.Diagnostics.Debug.WriteLine( ToplamAgirlik+" OZET ESLESTI "+AgirlikDegeri);
                            break;
                        }
                    }
                }

                VeritabaniKelimeler = item.KeywordsKelime.Split('|').ToList();
                for (int i = 0; i < KeywordKarsilastirma.Length; i++)
                {
                    for (int j = 0; j < VeritabaniKelimeler.Count; j++)
                    {
                        if (KeywordKarsilastirma[i] == VeritabaniKelimeler[j])
                        {
                            AgirlikDegeri += KeywordAgirlik;

                            //System.Diagnostics.Debug.WriteLine(ToplamAgirlik + " KEYWORD ESLESTI " + AgirlikDegeri);

                            break;
                        }
                    }
                }
                benzerlikOrani = AgirlikDegeri / ToplamKelimeKaysayisi * 100;
                System.Diagnostics.Debug.WriteLine("BENZERLIK ORANI  " + benzerlikOrani);
                if (benzerlikOrani > 100)
                {
                    System.Diagnostics.Debug.WriteLine("BENZERLIK ORANI 100leniyor " + benzerlikOrani);
                    benzerlikOrani = 100;
                }

                if (benzerlikOrani != 0)
                {
                    Sonuclar.Add(item, benzerlikOrani);
                }
                AgirlikDegeri = 0;
            }
            Sonuclar = Sonuclar.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

            for (int i = 0; i < Sonuclar.Count; i++)
            {
                //	Console.WriteLine(Sonuclar.Keys.ToList()[i] + " | " + Sonuclar.Values.ToList()[i]);
                //System.Diagnostics.Debug.WriteLine(Sonuclar.Keys.ToList()[i] + " | " + Sonuclar.Values.ToList()[i]+" | "+ToplamKelimeKaysayisi);
            }

            return(Sonuclar);
        }