Example #1
0
        internal static void Load()
        {
            if (!Directory.Exists(ErrorPath))
            {
                Directory.CreateDirectory(ErrorPath);
            }
            SalePromotions  = new List <IPromotion>();
            TotalPromotions = new List <IPromotion>();
            try
            {
                TotalPromotion.Load();
            }
            catch (Exception ex)
            {
                Settings.Log(String.Format("Promo.dat dosyasi yuklenemedi!\r{0}", ex.Message));
            }
#if !WindowsCE
            try
            {
                ProductPromotion.Load();
            }
            catch (Exception ex)
            {
                Settings.Log(String.Format("Prourun.dat dosyasi yuklenemedi!\r{0}", ex.Message));
            }
            try
            {
                CategoryPromotion.Load();
            }
            catch (Exception ex)
            {
                Settings.Log(String.Format("Proreyon.dat dosyasi yuklenemedi!\r{0}", ex.Message));
            }
            try
            {
                SpecialPromotion.Load();
            }
            catch (Exception ex)
            {
                Settings.Log(String.Format("Ozelpromo.dat dosyasi yuklenemedi!\r{0}", ex.Message));
            }
#endif
            try
            {
                FileWatcher.Start();
            }
            catch (Exception ex)
            {
                Settings.Log(String.Format("Promosyon dosyasý bulunamadý.\r{0}", ex.Message));
            }
        }
Example #2
0
        static void LoadChangedFile(string filePath)
        {
            string       fileName            = filePath.Substring(filePath.LastIndexOfAny(new char[] { '\\', '/' }) + 1);
            int          fileContentHashCode = String.Empty.GetHashCode();
            StreamReader sr = null;
            string       context;

            using (sr = new StreamReader(filePath, Settings.DefaultEncoding))
            {
                context = sr.ReadToEnd();
            }
            fileContentHashCode = context.GetHashCode();
            if (contentHashCodes.ContainsKey(fileName))
            {
                if (contentHashCodes[fileName] == fileContentHashCode)
                {
                    return;
                }
                contentHashCodes.Remove(fileName);
            }
            Settings.Log("File is changed : " + fileName);
            try
            {
                switch (fileName)
                {
                case Settings.PRODUCT_PROMOTION_FILE_NAME:
                case Settings.CATEGORY_PROMOTION_FILE_NAME:
                    Settings.SalePromotions = new List <IPromotion>();
                    CategoryPromotion.Load();
                    ProductPromotion.Load();
                    break;

                case Settings.TOTAL_PROMOTION_FILE_NAME:
                case Settings.SPECIAL_PROMOTION_FILE_NAME:
                    Settings.TotalPromotions = new List <IPromotion>();
                    TotalPromotion.Load();
                    SpecialPromotion.Load();
                    break;
                }
                contentHashCodes.Add(fileName, fileContentHashCode);
            }
            catch (Exception ex)
            {
                Settings.Log(ex.Message);
            }
        }