Exemple #1
0
        public static void Init()
        {
            ConcurrentDictionary <uint, ushort[]> dimensions = new ConcurrentDictionary <uint, ushort[]>();

            string[] dimensionData = System.IO.File.ReadAllLines("C:/db/mapdimensions.dat");
            foreach (string md in dimensionData)
            {
                string[] mdd    = md.Split(' ');
                ushort   Width  = ushort.Parse(mdd[1]);
                ushort   Height = ushort.Parse(mdd[2]);
                ushort[] dim    = new ushort[2] {
                    Width, Height
                };
                dimensions.TryAdd(uint.Parse(mdd[0]), dim);
            }
            Database.Database     DB = new Database.Database("C:/db/maps.s3db");
            System.Data.DataTable DT = DB.GetDataTable("SELECT `UniqueID`, `Type` FROM `maptypes`");
            for (int i = 0; i < DT.Rows.Count; i++)
            {
                System.Data.DataRow dr = DT.Rows[i];
                Mapping.Map         M  = new Map();
                M.UniqueID = Convert.ToUInt32(dr.ItemArray[0]);
                M.Type     = Convert.ToUInt32(dr.ItemArray[1]);
                if (!M.LoadDMap())
                {
                    ushort[] dims;
                    if (dimensions.TryGetValue(M.Type, out dims))
                    {
                        M.Width  = dims[0];
                        M.Height = dims[1];
                    }
                    else
                    {
                        M.Width  = 1300;
                        M.Height = 1300;
                    }
                    M.Coords = new byte[M.Height, M.Width];
                    for (short ix = 0; ix < M.Height; ix++)
                    {
                        for (short iy = 0; iy < M.Width; iy++)
                        {
                            M.Coords[ix, iy] = (byte)Enums.MapPointType.Empty;
                        }
                    }
                }
                Kernel.Maps.TryAdd(M.UniqueID, M);
            }
            DB.Dispose();
            dimensions.Clear();
        }
Exemple #2
0
        private void loadCategories(bool silent)
        {
            editCategoryId.Items.Clear();

            Database.Database db = Provider.GetDb(Index);
            if (db == null)
            {
                if (!silent)
                {
                    MessageBox.Show((Index + 1) + ". kutu için veritabanı ayarları geçersiz.", "Çınar CMS Desktop Editor");
                }
                return;
            }

            foreach (DataRow dr in db.GetDataTable("select Id, Title from Content where ClassName='Category' order by Title").Rows)
            {
                editCategoryId.Items.Add(new Item(dr));
            }
        }
Exemple #3
0
        private void loadAuthors(bool silent)
        {
            editAuthor.Items.Clear();

            Database.Database db = Provider.GetDb(Index);
            if (db == null)
            {
                if (!silent)
                {
                    MessageBox.Show((Index + 1) + ". kutu için veritabanı ayarları geçersiz.", "Çınar CMS Desktop Editor");
                }
                return;
            }

            foreach (DataRow dr in db.GetDataTable("select Id, Name as Title from Author").Rows)
            {
                editAuthor.Items.Add(new Item(dr));
            }
        }
Exemple #4
0
        public static void Run()
        {
            string arabicStart = @"<font size=""5"" face=""Arabic Typesetting"">";
            string turkishStart = @"<font face=""Verdana"" size=""2"">";

            Database.Database db = new Database.Database(DatabaseProvider.MySQL, "localhost", "quran", "root", "bk", 30);

            DataTable dt = db.GetDataTable("select sura, aya from quran_text order by 1,2");
            foreach (DataRow dr in dt.Rows)
            {
                string url = string.Format("http://www.kuranmeali.com/mobil/m-kelime.asp?sure={0}&ayet={1}", dr["sura"], dr["aya"]);
                Encoding enc = Encoding.UTF8;
                string res = url.DownloadPage(ref enc);

                int index = 0, end = -1, orderNo = 0;

                while (true)
                {
                    index = res.IndexOf(arabicStart, index);
                    if (index == -1) break;
                    end = res.IndexOf("</font>", index);

                    var arabic = HttpUtility.HtmlDecode(res.Substring(index + arabicStart.Length, end - index - arabicStart.Length).Replace(" : ",""));

                    index = res.IndexOf(turkishStart, end);
                    end = res.IndexOf("</font>", index);

                    var turkish = HttpUtility.HtmlDecode(res.Substring(index + turkishStart.Length, end - index - turkishStart.Length).Replace("\\","'"));

                    turkish = turkish.Replace("ý", "ı").Replace("ð", "ğ").Replace("þ", "ş").Replace("Ý", "I").Replace("Ð", "Ğ").Replace("Þ", "Ş");

                    db.ExecuteNonQuery("insert into quran_kelime_meal(sura, aya, orderno, arabic, turkish) values({0}, {1}, {2}, {3}, {4})", dr["sura"], dr["aya"], orderNo, arabic, turkish);
                    orderNo++;
                }

                Console.WriteLine("{0}, {1}", dr["sura"], dr["aya"]);
            }
        }
Exemple #5
0
 public static void Init()
 {
     ConcurrentDictionary<uint, ushort[]> dimensions = new ConcurrentDictionary<uint, ushort[]>();
     string[] dimensionData = System.IO.File.ReadAllLines("C:/db/mapdimensions.dat");
     foreach (string md in dimensionData)
     {
         string[] mdd = md.Split(' ');
         ushort Width = ushort.Parse(mdd[1]);
         ushort Height = ushort.Parse(mdd[2]);
         ushort[] dim = new ushort[2] { Width, Height };
         dimensions.TryAdd(uint.Parse(mdd[0]), dim);
     }
     Database.Database DB = new Database.Database("C:/db/maps.s3db");
     System.Data.DataTable DT = DB.GetDataTable("SELECT `UniqueID`, `Type` FROM `maptypes`");
     for (int i = 0; i < DT.Rows.Count; i++)
     {
         System.Data.DataRow dr = DT.Rows[i];
         Mapping.Map M = new Map();
         M.UniqueID = Convert.ToUInt32(dr.ItemArray[0]);
         M.Type = Convert.ToUInt32(dr.ItemArray[1]);
         if (!M.LoadDMap())
         {
             ushort[] dims;
             if (dimensions.TryGetValue(M.Type, out dims))
             {
                 M.Width = dims[0];
                 M.Height = dims[1];
             }
             else
             {
                 M.Width = 1300;
                 M.Height = 1300;
             }
             M.Coords = new byte[M.Height, M.Width];
             for (short ix = 0; ix < M.Height; ix++)
                 for (short iy = 0; iy < M.Width; iy++)
                     M.Coords[ix, iy] = (byte)Enums.MapPointType.Empty;
         }
         Kernel.Maps.TryAdd(M.UniqueID, M);
     }
     DB.Dispose();
     dimensions.Clear();
 }
Exemple #6
0
        public FormSettings(int index)
        {
            InitializeComponent();

            var s = Settings.Load();

            if (s.Providers.ContainsKey(index))
            {
                try
                {
                    editConnectionString.Text = s.ConnectionStrings[index];
                    editProvider.Text         = s.Providers[index].ToString();
                    editSiteAddress.Text      = s.SiteAddress[index];
                    editEmail.Text            = s.Emails[index];
                    editPassword.Text         = s.Passwords[index];

                    try
                    {
                        Database.Database db = Provider.GetDb(index);
                        var dt = db.GetDataTable("select Id, Title from Content where ClassName='Category' order by Title");
                        loadCategories(editCategoryId0, dt);
                        loadCategories(editCategoryId1, dt);
                        loadCategories(editCategoryId2, dt);
                        loadCategories(editCategoryId3, dt);
                        loadCategories(editCategoryId4, dt);
                        loadCategories(editCategoryId5, dt);
                        loadCategories(editCategoryId6, dt);
                        loadCategories(editCategoryId7, dt);
                        loadCategories(editCategoryId8, dt);
                        loadCategories(editCategoryId9, dt);
                    }
                    catch { }

                    if (s.Feed == null || string.IsNullOrWhiteSpace(s.Feed[index]))
                    {
                        s.Feed[index] = "|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n";
                    }

                    var feeds = s.Feed[index].Replace("\r", "").Split('\n');
                    try
                    {
                        editRSS0.Text = feeds[0].Split('|')[0];
                        editCategoryId0.SelectedIndex = editCategoryId0.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[0].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS1.Text = feeds[1].Split('|')[0];
                        editCategoryId1.SelectedIndex = editCategoryId1.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[1].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS2.Text = feeds[2].Split('|')[0];
                        editCategoryId2.SelectedIndex = editCategoryId2.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[2].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS3.Text = feeds[3].Split('|')[0];
                        editCategoryId3.SelectedIndex = editCategoryId3.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[3].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS4.Text = feeds[4].Split('|')[0];
                        editCategoryId4.SelectedIndex = editCategoryId4.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[4].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS5.Text = feeds[5].Split('|')[0];
                        editCategoryId5.SelectedIndex = editCategoryId5.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[5].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS6.Text = feeds[6].Split('|')[0];
                        editCategoryId6.SelectedIndex = editCategoryId6.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[6].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS7.Text = feeds[7].Split('|')[0];
                        editCategoryId7.SelectedIndex = editCategoryId7.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[7].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS8.Text = feeds[8].Split('|')[0];
                        editCategoryId8.SelectedIndex = editCategoryId8.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[8].Split('|')[1]));
                    }
                    catch { }
                    try
                    {
                        editRSS9.Text = feeds[9].Split('|')[0];
                        editCategoryId9.SelectedIndex = editCategoryId9.Items.Cast <Item>().IndexOf(i => i.Id == Convert.ToInt32(feeds[9].Split('|')[1]));
                    }
                    catch { }
                }
                catch { }
            }
        }