Exemplo n.º 1
0
 public IdentityClient()
 {
     Application    = new ApplicationSection();
     Authentication = new AuthenticationSection();
     Account        = new AccountSection();
     Email          = new EmailSection();
 }
Exemplo n.º 2
0
 public void LoadGradesSection()
 {
     if (_gradesSection == null)
     {
         _gradesSection = AccountSection.GetGradesSection(this);
     }
 }
Exemplo n.º 3
0
 public SampleService()
 {
     Config = ConfigurationManager.OpenMappedExeConfiguration(FileMap, ConfigurationUserLevel.None);
     if (!Config.HasFile)
     {
         throw new ArgumentException("系统未找到" + FileMap.ExeConfigFilename + "文件");
     }
     AccountSection = (AccountSection)Config.GetSection("accountConfig");
     if (AccountSection == null)
     {
         throw new ArgumentException(FileMap.ExeConfigFilename + "文件中未配置accountConfig节点");
     }
 }
        public void SwitchUserLogin(IWebDriver driver)
        {
            AccountSection objAccountSection = new AccountSection(driver);

            objAccountSection.Account().Click();
            objAccountSection.Signout().Click();
            Login login = new Login(driver);

            login.Password().SendKeys("abc@1234");
            //login.Username().SendKeys("*****@*****.**");
            login.Username().SendKeys("*****@*****.**");
            login.LoginButton().Click();
        }
Exemplo n.º 5
0
 public BaseItemWP Find(Guid identifier)
 {
     return(AccountSection.Find(identifier));
 }
        private static async System.Threading.Tasks.Task UpgradeAccount(string dir)
        {
            try
            {
                var accountSection = AccountSection.Get(Guid.Parse(dir)).Value;

                // Null means that data deserialization failed for some reason
                if (accountSection == null)
                {
                    return;
                }

                AccountDataItem accountUWP = new AccountDataItem(accountSection.LocalId)
                {
                    AccountId               = accountSection.AccountId,
                    AutoLogin               = accountSection.AutoLogin,
                    CurrentChangeNumber     = accountSection.CurrentChangeNumber,
                    CurrentSemesterId       = accountSection.School.ActiveSemesterIdentifier,
                    DeviceId                = accountSection.DeviceId,
                    LocalToken              = accountSection.Password,
                    PremiumAccountExpiresOn = accountSection.PremiumAccountExpiresOn,
                    RememberPassword        = accountSection.RememberPassword,
                    RememberUsername        = accountSection.RememberUsername,
                    Username                = accountSection.Username,
                    WeekOneStartsOn         = accountSection.WeekOneStartsOn,
                    Version             = accountSection.Version,
                    ImageUploadOption   = ConvertImageUploadOption(accountSection.ImageUploadOption),
                    IsPushDisabled      = !accountSection.IsPushEnabled,
                    NeedsToSyncSettings = accountSection.NeedsToSyncSettings,
                    RemindersDayBefore  = accountSection.RemindersDayBefore,
                    RemindersDayOf      = accountSection.RemindersDayOf
                };

                accountUWP.MainTileSettings.ShowEvents         = accountSection.ShowExamsOnTiles;
                accountUWP.MainTileSettings.ShowTasks          = accountSection.ShowHomeworkOnTiles;
                accountUWP.MainTileSettings.SkipItemsOlderThan = accountSection.IgnoreItemsOlderThan;

                // Save account (need to do this so there's a folder for everything else)
                await AccountsManager.Save(accountUWP);

                try
                {
                    AccountDataStore dataStoreUWP = await AccountDataStore.Get(accountUWP.LocalAccountId);

                    // Transfer the changes
                    await AccountDataStore.ChangedItems.ImportChangesAsync(accountUWP.LocalAccountId, accountSection.PartialChanges.Changes.Keys.ToArray(), accountSection.PartialChanges.Deletes.Keys.ToArray());

                    try
                    {
                        // Transfer images to upload
                        string[] imagesToUpload = accountSection.StoredImagesToUpload.ToArray();
                        await dataStoreUWP.AddImagesToUploadAsync(imagesToUpload);


                        // Transfer stored imagesDataContract
                        IFolder newImagesFolder = await PowerPlannerAppDataLibrary.DataLayer.FileHelper.GetOrCreateImagesFolder(accountUWP.LocalAccountId);


                        foreach (string imageName in accountSection.StoredImagesToUpload)
                        {
                            string path = Files.IMAGE_FILE_NAME(imageName, accountUWP.LocalAccountId);

                            // Try transfering the image
                            try
                            {
                                using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                                {
                                    using (IsolatedStorageFileStream existingStream = store.OpenFile(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, FileShare.Read))
                                    {
                                        var newFile = await newImagesFolder.CreateFileAsync(imageName, StorageEverywhere.CreationCollisionOption.ReplaceExisting);

                                        using (Stream newStream = await newFile.OpenAsync(StorageEverywhere.FileAccess.ReadAndWrite))
                                        {
                                            existingStream.CopyTo(newStream);
                                        }
                                    }
                                }
                            }

                            catch (Exception ex)
                            {
                                TelemetryExtension.Current?.TrackException(ex);
                            }
                        }
                    }

                    catch { }


                    // Get all the existing items in universal sync language
                    BaseItem[] syncItems = accountSection.GetAllItemsInSendingFormat().ToArray();

                    // Convert them to the UWP data format
                    BaseDataItem[] uwpItems = PowerPlannerAppDataLibrary.SyncLayer.Sync.GetSyncItemsAsDataItems(syncItems);

                    // And then input those into the new database
                    await dataStoreUWP.ImportItemsAsync(uwpItems);
                }

                catch (Exception ex)
                {
                    try
                    {
                        TelemetryExtension.Current?.TrackException(ex);
                    }

                    catch { }

                    await AccountsManager.Delete(accountUWP.LocalAccountId);
                }
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
                Debug.WriteLine("Failed upgrading Silverlight account");
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            String method = System.Configuration.ConfigurationManager.AppSettings["method"];

            string[] emails = (System.Configuration.ConfigurationManager.AppSettings["email"] as string).Split(',');
            String   URL    = System.Configuration.ConfigurationManager.AppSettings["method_url"];
            String   startdate;
            int      days = -2;

            if (args.Length == 0 || int.TryParse(args[0], out days))
            {
                DateTime date = DateTime.Now.AddDays(days);
                startdate = date.ToString("yyyy-MM-dd");
            }
            else
            {
                startdate = args[0];
            }


            Dictionary <String, String> parameters = new Dictionary <String, String>()
            {
                { "OPERATIONTYPE", method },
                { "DATE", startdate },
                { "COMPRESSION", "ZIP" },
                { "VERSION", "2.0" },
                { "TIMEZONE", "Europe/Paris" },
                { "COLUMNS", "ORDERID;EXECCODE;NATURE;AMOUNT;CURRENCY;BILLINGFEES INCL. VAT;DATE;CHARGEBACKDATE;OPERATIONTYPE;TRANSFER REFERENCE;IDENTIFIER;EXTRADATA" }
            };
            AccountSection           section = ConfigurationManager.GetSection("accountSection") as AccountSection;
            AccountElementCollection coll    = section.Accounts;

            foreach (String email in emails)
            {
                foreach (AccountElement account in coll)
                {
                    parameters["MAILTO"]     = email;
                    parameters["IDENTIFIER"] = account.Name;
                    String clearMessage = account.Password;
                    foreach (String key in parameters.Keys.OrderBy(k => k))
                    {
                        clearMessage += string.Format("{0}={1}{2}", key, parameters[key], account.Password);
                    }

                    //Init the ASCII Encoder
                    var encoder = new UTF8Encoding();

                    //Transform the clear query string to a byte array
                    byte[] messageBytes = encoder.GetBytes(clearMessage);


                    var sha256 = new SHA256Managed();

                    //Hash the message
                    byte[] hashValue = sha256.ComputeHash(messageBytes);

                    //Transform the hash bytes array to a string
                    string hash = "";
                    foreach (byte x in hashValue)
                    {
                        hash += String.Format("{0:x2}", x);
                    }


                    parameters["HASH"] = hash;
                    var postData = "method=" + method;
                    foreach (String key in parameters.Keys.OrderBy(k => k))
                    {
                        postData += String.Format("&params[{0}]={1}", key, System.Web.HttpUtility.UrlEncode(parameters[key]));
                    }


                    var request = (HttpWebRequest)WebRequest.Create(URL);

                    var data = Encoding.ASCII.GetBytes(postData);

                    request.Method        = "POST";
                    request.ContentType   = "application/x-www-form-urlencoded";
                    request.ContentLength = data.Length;

                    using (var stream = request.GetRequestStream())
                    {
                        stream.Write(data, 0, data.Length);
                    }

                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    Stream          stream2  = response.GetResponseStream();
                    StreamReader    reader   = new StreamReader(stream2, Encoding.UTF8);
                    Console.WriteLine(account.Name + " / " + email + " => " + reader.ReadToEnd());
                    parameters.Remove("HASH");
                }
            }

            Console.ReadLine();
        }
Exemplo n.º 8
0
        public async Task <IActionResult> DoQuiz(int sectionId, [FromQuery] int currentQuiz = 0)
        {
            if (await _repo.GetOneWithKey <Section>(sectionId) == null)
            {
                return(NotFound(new
                {
                    Error = "Không tìm thấy bài học"
                }));
            }
            var sectionFromDb = await _repo.GetOneWithManyToMany <Section>(sec => sec.Id == sectionId);

            var section = await sectionFromDb.Include(s => s.Quizzes).Include(s => s.Accounts).FirstOrDefaultAsync();

            if (User.FindFirst(ClaimTypes.NameIdentifier) != null)
            {
                int userId         = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
                var accountSection = await _repo.GetOneWithConditionTracking <AccountSection>(s => s.AccountId == userId && s.SectionId == sectionId);

                if (accountSection == null)
                {
                    var accountSec = new AccountSection()
                    {
                        AccountId = userId,
                        SectionId = sectionId,
                        Start_At  = DateTime.Now
                    };
                    _repo.Create(accountSec);
                }
                var quizDone = section.Accounts.Where(s => s.AccountId == userId).FirstOrDefault();
                var newQuiz  = section.Quizzes.Skip(quizDone == null ? 0 : quizDone.QuizDoneCount).Take(1).FirstOrDefault();
                if (newQuiz == null)
                {
                    var randomQuiz     = section.Quizzes.GetOneRandomFromList();
                    var oldQuizHistory = new History()
                    {
                        AccountId = userId,
                        QuizId    = randomQuiz.Id,
                        StartDate = DateTime.Now,
                        IsDone    = false
                    };
                    _repo.Create(oldQuizHistory);
                    await _repo.SaveAll();

                    var quizQuery = await _repo.GetOneWithManyToMany <Quiz>(quiz => quiz.Id == randomQuiz.Id);

                    var quizQuestions = await quizQuery.Include(e => e.Questions).ThenInclude(q => q.Question).FirstOrDefaultAsync();

                    var questions = _mapper.Map <QuizDTO>(quizQuestions);

                    // var examFromDb = await _repo.GetOneWithManyToMany<Section>(quiz => quiz.Id == quizId);
                    // var exam = await examFromDb.Include(e => e.Questions).ThenInclude(q => q.Question).FirstOrDefaultAsync();
                    // var returnQuestions = _mapper.Map<QuizDTO>(exam);
                    return(Ok(questions));
                }
                var userQuizQuery = await _repo.GetOneWithManyToMany <Quiz>(quiz => quiz.Id == newQuiz.Id);

                var userQuiz = await userQuizQuery.Include(e => e.Questions).ThenInclude(q => q.Question).FirstOrDefaultAsync();

                var returnQuiz = _mapper.Map <QuizDTO>(userQuiz);
                if (returnQuiz.Questions.Count() > 0)
                {
                    var history = new History()
                    {
                        AccountId = userId,
                        QuizId    = userQuiz.Id,
                        StartDate = DateTime.Now,
                        IsDone    = false
                    };
                    _repo.Create(history);
                    await _repo.SaveAll();
                }
                return(Ok(returnQuiz));
            }
            var anonymousQuiz = section.Quizzes.Skip(currentQuiz).Take(1).FirstOrDefault();

            if (anonymousQuiz == null)
            {
                return(NotFound());
            }
            var examFromDb = await _repo.GetOneWithManyToMany <Quiz>(quiz => quiz.Id == anonymousQuiz.Id);

            var exam = await examFromDb.Include(e => e.Questions).ThenInclude(q => q.Question).FirstOrDefaultAsync();

            var returnQuestions = _mapper.Map <QuizDTO>(exam);

            // var examFromDb = await _repo.GetOneWithManyToMany<Section>(quiz => quiz.Id == quizId);
            // var exam = await examFromDb.Include(e => e.Questions).ThenInclude(q => q.Question).FirstOrDefaultAsync();
            // var returnQuestions = _mapper.Map<QuizDTO>(exam);
            return(Ok(returnQuestions));
        }
Exemplo n.º 9
0
 public BaseItemWP(AccountSection accountSection)
 {
     AccountSection = accountSection;
 }