예제 #1
0
        public static async Task <bool> GoToNextSite(AdvertiseType type, short mode)
        {
            try
            {
                //mode 0 => حرکت رو به جلو
                //mode 1 => از سر گیری سایت ها بعد از ریستارت مورم
                SettingBusiness _cls;
                var             res = await SettingBusiness.GetAllAsync();

                _cls = res.Count == 0 ? new SettingBusiness() : res[0];
                var path = Path.Combine(Application.StartupPath, "SiteRate.txt");
                var lst  = File.ReadAllLines(path).ToList();
                if (!lst.Any())
                {
                    return(false);
                }
                var index = "";
                if (mode == 0)
                {
                    for (var i = 0; i < lst.Count; i++)
                    {
                        if (lst[i] != type.ToString())
                        {
                            continue;
                        }
                        if (i + 1 == lst.Count)
                        {
                            index = null;
                            break;
                        }

                        index = lst[i + 1];
                        break;
                    }
                }
                else
                {
                    CloseAllChromeWindows();
                    index = lst[0];
                }

                switch (index)
                {
                case "Divar":
                    if (_cls.DivarSetting.CountAdvInIp != 0)
                    {
                        var divar = await DivarAdv.GetInstance();

                        await divar.StartRegisterAdv();

                        return(true);
                    }
                    break;

                case "Sheypoor":
                    if (_cls.SheypoorSetting.CountAdvInIp != 0)
                    {
                        var sheypoor = await SheypoorAdv.GetInstance();

                        await sheypoor.StartRegisterAdv();

                        return(true);
                    }
                    break;

                case "NiazKade":
                    if (_cls.NiazSetting.CountAdvInIp != 0)
                    {
                        var niaz = await NiazAdv.GetInstance();

                        await niaz.StartRegisterAdv();

                        return(true);
                    }
                    break;

                case "NiazmandyHa":
                    break;
                }

                return(false);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorLogInstance.StartLog(ex);
                return(false);
            }
        }
예제 #2
0
        public static async Task <NiazAdv> GetInstance()
        {
            await GetDataFromSetting();

            return(_me ?? (_me = new NiazAdv()));
        }