示例#1
0
 private static void ApplySajda(int suraNo, Aya aya)
 {
     if (suraNo == 7 && aya.AyaNo == 206)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 13 && aya.AyaNo == 15)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 16 && aya.AyaNo == 50)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 17 && aya.AyaNo == 109)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 19 && aya.AyaNo == 58)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 22 && aya.AyaNo == 18)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 22 && aya.AyaNo == 77)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 25 && aya.AyaNo == 60)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 27 && aya.AyaNo == 26)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 32 && aya.AyaNo == 15)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = true;
     }
     else if (suraNo == 38 && aya.AyaNo == 24)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 41 && aya.AyaNo == 38)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = true;
     }
     else if (suraNo == 53 && aya.AyaNo == 62)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = true;
     }
     else if (suraNo == 84 && aya.AyaNo == 21)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = false;
     }
     else if (suraNo == 96 && aya.AyaNo == 19)
     {
         aya.HasSajda     = true;
         aya.IsSajdaVajeb = true;
     }
 }
示例#2
0
        private static void Finalize()
        {
            string path = string.Format("../../Out/{0}-midstage.txt", QuranConfig.Current.FileName);

            string[] lines = File.ReadAllText(path).Split(new string[] { "\r\n" }, StringSplitOptions.None);

            Model.Quran quran = new Model.Quran();
            quran.TextType    = (int)QuranTextType.Uthmani;
            quran.Version     = QuranConfig.Current.Version;
            quran.Created     = DateTime.Today.ToShortDateString();
            quran.Description = "";

            List <Sura> suras = new List <Sura>();
            List <Aya>  ayas  = new List <Aya>();

            int suraNo = 1;
            int ayaNo  = 1;

            foreach (string line in lines)
            {
                if (line.Trim().Length == 0 || Int32.Parse(line.Substring(0, 3)) != suraNo)
                {
                    Sura sura = new Sura();
                    sura.Ayas        = (Aya[])ayas.ToArray();
                    sura.Index       = QuranConfig.Current.Meta.Suras[suraNo - 1].SuraNo;
                    sura.TotalAyas   = QuranConfig.Current.Meta.Suras[suraNo - 1].TotalAyas;
                    sura.Order       = QuranConfig.Current.Meta.Suras[suraNo - 1].Order;
                    sura.NameArabic  = QuranConfig.Current.Meta.Suras[suraNo - 1].NameArabic;
                    sura.NameEnglish = QuranConfig.Current.Meta.Suras[suraNo - 1].NameEnglish;
                    sura.IsMeccan    = QuranConfig.Current.Meta.Suras[suraNo - 1].IsMeccan;
                    suras.Add(sura);

                    // Reset
                    ayas = new List <Aya>();
                    ++suraNo;

                    if (suraNo == 1 || suraNo == 9)
                    {
                        ayaNo = 1;
                    }
                    else
                    {
                        ayaNo = 0;
                    }
                }


                if (line.Trim().Length > 0)
                {
                    Aya aya = new Aya();
                    aya.AyaNo = ayaNo;
                    if (ayaNo == 0)
                    {
                        aya.Slices = new Slice[1] {
                            new Slice()
                            {
                                SliceID = suraNo * 1000000, AyaNo = ayaNo, Text = line.Remove(0, 8) + " "
                            }
                        }
                    }
                    ;
                    else
                    {
                        aya.Slices = new Slice[1] {
                            new Slice()
                            {
                                SliceID = suraNo * 1000000 + ayaNo * 1000 + 1, AyaNo = ayaNo, Text = line.Remove(0, 8) + " "
                            }
                        }
                    };

                    ApplySajda(suraNo, aya);

                    aya.Page   = GetValue(QuranConfig.Current.Meta.Pages, suraNo, aya.AyaNo);
                    aya.Juz    = GetValue(QuranConfig.Current.Meta.Juzs, suraNo, aya.AyaNo);
                    aya.Hizb   = GetValue(QuranConfig.Current.Meta.Hizbs, suraNo, aya.AyaNo);
                    aya.Manzil = GetValue(QuranConfig.Current.Meta.Manzils, suraNo, aya.AyaNo);
                    aya.Ruku   = GetValue(QuranConfig.Current.Meta.Rukus, suraNo, aya.AyaNo);

                    ayas.Add(aya);

                    ++ayaNo;
                }
            }

            quran.Suras = suras.ToArray();

            if (quran.Suras.Length != 114)
            {
                throw new ApplicationException("There is no 114 Suras!");
            }

            using (var file = File.Create(string.Format("../../Out/{0}.dat", QuranConfig.Current.FileName)))
            {
                using (CryptoStream cs = new CryptoStream(file, Crypto.AES.CreateEncryptor(), CryptoStreamMode.Write))
                {
                    Serializer.Serialize <Model.Quran>(cs, quran);
                }
            }
        }