// GET: ImportData public ActionResult ImportData(string result) { _logger.Debug("ImportData"); List <SelectListItem> ddTestTypes = null; ImportDataViewModel data = new ImportDataViewModel(); try { data.results = ""; ddTestTypes = new List <SelectListItem>(); var client = GetHttpClient(); // var task = client.GetAsync(Api + "api/ImportData?WorkStudyId=none").ContinueWith((res) => var task = client.GetAsync(Api + "api/ImportData?Active=2").ContinueWith((res) => { if (res.Result.IsSuccessStatusCode) { data = JsonConvert.DeserializeObject <ImportDataViewModel>(res.Result.Content.ReadAsStringAsync().Result); if (data != null) { ddTestTypes = data.ddTestType; } } }); task.Wait(); ViewBag.ddTestTypes = ddTestTypes; ViewBag.ddTestTypesDefault = ddTestTypes; ViewBag.result = " "; ViewBag.error = " "; if (result != null) { if (result.Contains("data saved")) { ViewBag.result = result; } else { ViewBag.error = result; } } } catch (Exception ex) { ViewBag.error = ex.ToString(); _logger.Error(ex); } return(View(data)); }
public ImportDataView() { InitializeComponent(); var projects=HelperMethods.Instance.ProjectsWithWells(); if (!projects.Any()) { _shouldClose = true; Loaded += ImportDataView_Loaded; } _dataContext = new ImportDataViewModel(Token); DataContext = _dataContext; SetDialogFilters(); AddKeyBindings<BaseEntity>(); }
public ActionResult Index(ImportDataViewModel model) { if (ModelState.IsValid) { System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); System.Diagnostics.Debug.WriteLine("Starting Data Import"); watch.Start(); UnitOfWork work = new UnitOfWork(); _userMap = new Dictionary<int, ImportedUser>(); _achievementMap = new Dictionary<int, ImportedEarnable>(); _questMap = new Dictionary<int, ImportedEarnable>(); _userStoryMap = new Dictionary<int, ImportedEarnable>(); _userContentMap = new Dictionary<int, ImportedEarnable>(); // Do the importing System.Diagnostics.Debug.WriteLine("* Importing Users"); ImportUsers(model.UserTable, model.Delimiter, work); System.Diagnostics.Debug.WriteLine("* Finished Importing Users - " + watch.Elapsed); System.Diagnostics.Debug.WriteLine("* Importing Profiles"); ImportProfiles(model.ProfileTable, model.Delimiter, work); System.Diagnostics.Debug.WriteLine("* Finished Importing Profiles - " + watch.Elapsed); System.Diagnostics.Debug.WriteLine("* Importing Friends"); ImportFriends(model.FriendTable, model.Delimiter, work); System.Diagnostics.Debug.WriteLine("* Finished Importing Friends - " + watch.Elapsed); System.Diagnostics.Debug.WriteLine("* Importing Achievement Templates"); ImportAchievements( model.AchievementTemplateTable, model.AchievementPointTemplateTable, model.AchievementRequirementsTable, model.Delimiter, work); System.Diagnostics.Debug.WriteLine("* Finished Importing Achievement Templates - " + watch.Elapsed); System.Diagnostics.Debug.WriteLine("* Importing Achievement User Stuff"); ImportAchievementUserStuff( model.AchievementUserStoryTable, model.AchievementUserContentTable, model.Delimiter, work); System.Diagnostics.Debug.WriteLine("* Finished Importing Achievement User Stuff - " + watch.Elapsed); System.Diagnostics.Debug.WriteLine("* Importing Achievement Instances"); ImportAchievementInstances( model.AchievementInstanceTable, model.AchievementPointInstanceTable, model.Delimiter, work); System.Diagnostics.Debug.WriteLine("* Finished Importing Achievement Instances - " + watch.Elapsed); System.Diagnostics.Debug.WriteLine("* Importing Quest Templates"); ImportQuestTemplates( model.QuestTemplateTable, model.QuestAchievementStepTable, model.Delimiter, work); System.Diagnostics.Debug.WriteLine("* Finished Importing Quest Templates - " + watch.Elapsed); System.Diagnostics.Debug.WriteLine("* Importing Quest Instances"); ImportQuestInstances(model.QuestInstanceTable, model.Delimiter, work); System.Diagnostics.Debug.WriteLine("* Finished Importing Quest Instances - " + watch.Elapsed); watch.Stop(); System.Diagnostics.Debug.WriteLine("IMPORT TIME: " + watch.Elapsed); // Should be good return RedirectToAction("Index"); } return View(model); }
private DataSearch <ImportDataViewModel> GetResults(DataGridoption option) { _logger.Debug("GetResults"); string message1 = "Records cannot be Entered Manully:"; string message = message1.Trim(); AdoHelper ado = new AdoHelper(); //SqlDataReader reader = null; List <ImportDataViewModel> lstResults = new List <ImportDataViewModel>(); List <SqlParameter> lstSqlParameter = new List <SqlParameter>(); lstSqlParameter.Add(new SqlParameter("@CurrentPage", option.pageIndex)); lstSqlParameter.Add(new SqlParameter("@NoOfRecords", option.pageSize)); try { #region Manual Entry SqlParameter param0 = new SqlParameter("@SelectedTests", option.searchBy); using (SqlDataReader reader = ado.ExecDataReaderProc("RNDCheckTestType_READ", "RND", new object[] { param0 })) { if (reader.HasRows) { ImportDataViewModel ID = null; while (reader.Read()) { ID = new ImportDataViewModel(); ID.TestingNo = Convert.ToInt32(reader["TestingNo"]); ID.TestType = Convert.ToString(reader["TestType"]); ID.Active = Convert.ToChar(reader["Active"]); if (ID.Active != '3') { if (message.Trim() == message1.Trim()) { message += ID.TestType; } else { message += ", " + ID.TestType; } } else { lstResults.Add(ID); } } } if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open) { ado._conn.Close(); ado._conn.Dispose(); } } #endregion } catch (Exception ex) { _logger.Error(ex.Message); } DataSearch <ImportDataViewModel> ds = new DataSearch <ImportDataViewModel> { items = lstResults, // total = (lstResults != null && lstResults.Count > 0) ? lstResults[0].total : 0, total = (lstResults != null && lstResults.Count > 0) ? lstResults.Count : 0, Message = message }; return(ds); }
public ImportDataView(ImportDataViewModel model) { InitializeComponent(); this.DataContext = model; _viewModel = model; }