Example #1
0
        public bool IsFirstRunComplete()
        {
            bool result  = false;
            var  content = _globalOptionService.GetOptionContent(SettingConstant.FirstRunCompleteKey);

            if (!content.IsEmpty())
            {
                result = bool.Parse(content);
            }

            return(result);
        }
Example #2
0
        public void SaveSponsor(SponsorZip sponsorZip)
        {
            Queue <Guid> keys = new Queue <Guid>();

            keys.Enqueue(new Guid("61c98633-6a56-4e6c-b778-67ca9c2fd788"));
            keys.Enqueue(new Guid("5dcf147e-ca79-46e6-b0bc-56f72712bbcc"));
            keys.Enqueue(new Guid("3a4c4e4c-a8e7-42a5-b443-bf7ce06b4dc9"));
            keys.Enqueue(new Guid("8a4fc4db-32ad-43e0-9c4f-a53a723556e1"));
            keys.Enqueue(new Guid("8868a907-81fd-4fbe-b6ba-bd41aec38113"));
            keys.Enqueue(new Guid("98ef9d9e-010b-4c42-a9b4-0af1400fadf2"));
            keys.Enqueue(new Guid("59cddf7c-8f63-46d2-8c39-2b76b0e929ef"));
            keys.Enqueue(new Guid("f33afe4b-dea7-41c4-86da-307f108eae90"));
            keys.Enqueue(new Guid("ff7f8731-427f-4d3f-b9cb-c7e1eee07576"));

            List <Sponsor> result = new List <Sponsor>();

            if (sponsorZip == null || sponsorZip.ZipFile.IsEmpty())
            {
            }
            else
            {
            }

            string fileName = ApplicationSettingsConstant.SponsorFileName;
            string path     = Path.Combine(_crossFileService.GetDefaultDirectory(),
                                           ApplicationSettingsConstant.DocumentsDirectory,
                                           fileName);

            if (!_crossFileService.IsFileExists(path))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(SettingConstant.milkDigitalID);
                sb.AppendLine(SettingConstant.SilverDigitalID);
                sb.AppendLine(SettingConstant.EarsWebSite);
                _crossFileService.Save(sb.ToString(), path);
            }

            string content = _crossFileService.Load(path);

            string[] sponsorEntries = Regex.Split(content, Environment.NewLine);
            foreach (string sponsorEntry in sponsorEntries)
            {
                string[] sponsorAttributes = sponsorEntry.Split(',');
                if (sponsorAttributes.Length == 3)
                {
                    Sponsor sponsor = new Sponsor();
                    if (sponsorAttributes[1].Contains("Club"))
                    {
                        sponsor.SponsorKey = Guid.Empty;
                    }
                    else
                    {
                        sponsor.SponsorKey = keys.Dequeue();
                    }

                    sponsor.SponsorIcon = sponsorAttributes[0].ConvertToBase64String();
                    sponsor.SponsorName = sponsorAttributes[1].Trim();
                    sponsor.SponsorUrl  = sponsorAttributes[2].Trim();

                    result.Add(sponsor);
                }
            }

            // Store Sponsor List to database if needed


            // Store the new sponsor id and list for re-use.....Andy
            string sponsorList = JsonConvert.SerializeObject(result);

            _globalOptionService.SetOption(SettingConstant.SponsorListKey, sponsorList);
            string sponsorId = sponsorZip == null?
                               _globalOptionService.GetOptionContent(SettingConstant.SponsorIdKey)
                                   : sponsorZip.ZipId.ToString();

            _globalOptionService.SetOption(SettingConstant.SponsorIdKey, sponsorId);
        }
Example #3
0
        public void CheckSponsor()
        {
            string registrationId = _globalOptionService.GetOptionContent(SettingConstant.RegistrationKey);
            string promoCode      = _globalOptionService.GetOptionContent(SettingConstant.PromoCodeKey);

            //we have sponsor info from the database
            string sponsorId = _globalOptionService.GetOptionContent(SettingConstant.SponsorIdKey);

            // now compare sponsorid with the web sponsor id
            string newSponsorId = GetSponsorId(registrationId, promoCode);

            // If they ( web and databse) match then download new sponsorinfo
            // There is a good change both of them are null.
            // a new user who couldn't connect to the web
            if (sponsorId == null && newSponsorId == null)
            {
                _sponsorService.SaveSponsor(sponsorZip: null);
                return;
            }

            // existing sponsor user who couldn't connect to the web
            if (sponsorId != null && newSponsorId == null)
            {
                // stay with current one and exit
                return;
            }

            if (sponsorId != newSponsorId)
            {
                _sponsorService.SaveSponsor(GetSponsorData());

                // Update New SponsorId
                _globalOptionService.SetOption(SettingConstant.SponsorIdKey, newSponsorId);
            }
        }