/// <summary> /// <inheritdoc/> /// </summary> public async Task <Profession> GetProfessionAsync(string professionId) { ProfessionEntity profession = await _db.Professions.SingleOrDefaultAsync(profession => profession.Id == professionId); if (profession == default) { return(null); } MainProfile mainProfile = await GetMainProfileAsync(profession.MainProfile); SecondaryProfile secondaryProfile = await GetSecondaryProfileAsync(profession.SecondaryProfile); List <string> advancesTo = await _db.Advances.Where(advance => advance.ProfessionId == professionId).Select(advance => advance.AdvanceTo).ToListAsync(); List <string> advancesFrom = await _db.Advances.Where(advance => advance.AdvanceTo == professionId).Select(advance => advance.AdvanceTo).ToListAsync(); List <string> professionTalents = await _db.ProfessionTalents.Where(professionTalent => professionTalent.ProfessionId == professionId).Select(professionTalent => professionTalent.TalentId).ToListAsync(); List <string> talents = await _db.Talents.Where(talent => professionTalents.Contains(talent.Id)).Select(talent => talent.Text).ToListAsync(); List <string> professionTrappings = await _db.ProfessionTrappings.Where(professionTrapping => professionTrapping.ProfessionId == professionId).Select(professionTrapping => professionTrapping.TrappingId).ToListAsync(); List <string> trappings = await _db.Trappings.Where(trapping => professionTrappings.Contains(trapping.Id)).Select(trapping => trapping.Text).ToListAsync(); List <Skill> skills = GetSkills(professionId).Select(s => GetChildSkills(s)).ToList(); return(new Profession(professionId, profession.Label, profession.Description, profession.Role, profession.Notes, profession.Source, profession.IsAdvanced, mainProfile, secondaryProfile, advancesFrom, advancesTo, skills, talents, trappings, profession.NumberOfAdvances)); }
public ActionResult ContactUs(string Email, string Name, string Phone, string Message) { MainProfile mp = db.MainProfiles.FirstOrDefault(); try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(Email); mail.Subject = "Music Store"; mail.Body = "Name: " + Name + System.Environment.NewLine + "Contact Number is " + Phone + System.Environment.NewLine + Message; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "9033344995jalu"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); ViewBag.msg = "Mail has been sent"; } catch { ViewBag.error = "Mail has not been sent"; } return(View(mp)); }
public ActionResult Profile(int id = 0) { if (Session["Admin_Id"] == null) { return(RedirectToAction("Index")); } try { MainProfile mp = db.MainProfiles.FirstOrDefault(); mp.Name = Request["name"]; mp.Email = Request["email"]; mp.ContactNumber = Request["contactnumber"]; mp.Address = Request["address"]; mp.CoverProfilePhoto = Request["CoverProfilePhoto"]; mp.FacebookLink = Request["FacebookLink"]; mp.YouTubeLink = Request["YouTubeLink"]; mp.TwiterLink = Request["TwiterLink"]; mp.Google_Link = Request["Google_Link"]; mp.About_1 = Request["About_1"]; db.Entry(mp).State = System.Data.Entity.EntityState.Modified; int i = db.SaveChanges(); if (i > 0) { return(RedirectToAction("Profile")); } else { ViewBag.error = "Failed to Update"; } } catch { } return(View("Profile")); }
public void SetUpResources() { var myProfile = new MainProfile(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile)); var mapper = new Mapper(configuration); _moqMapper = mapper; _moqEmployeeFactory = new Mock <IEmployeeFactory>(); _moqEmployeeRepository = new Mock <IEmployeeRepository>(); }
public ActionResult Home() { MainProfile mp = db.MainProfiles.FirstOrDefault(); Session["Twitter"] = mp.TwiterLink; Session["Facebook"] = mp.FacebookLink; Session["Youtube"] = mp.YouTubeLink; Session["google+"] = mp.Google_Link; return(View()); }
public ActionResult Profile() { if (Session["Admin_Id"] == null) { return(RedirectToAction("Index")); } MainProfile mp = db.MainProfiles.FirstOrDefault(); return(View(mp)); }
public static ExcelDocument LoadMainProfileDB(MainProfile mainProfile) { List <ExcelResult> answerListContent = new List <ExcelResult>(); List <ExcelProfile> profilesListContent = new List <ExcelProfile>(); using (profileContext db = new profileContext()) { mainProfile = db.MainProfile.SingleOrDefault(p => p == mainProfile); db.Entry(mainProfile).Collection(t => t.Profile).Load(); db.Entry(mainProfile).Collection(t => t.Questioned).Load(); foreach (var profileItem in mainProfile.Profile) { db.Entry(profileItem).Collection(t => t.Question).Load(); db.Entry(profileItem).Collection(t => t.Result).Load(); db.Entry(profileItem).Reference(t => t.Type).Load(); List <ExcelQuestion> questions = new List <ExcelQuestion>(); foreach (var questionItem in profileItem.Question) { if (questionItem.LeftLimit == null && questionItem.RightLimit == null) { questions.Add(new ExcelQuestion { Id = questionItem.SerialNumber, Content = questionItem.Content, LeftLimit = "", RightLimit = "" }); } else { questions.Add(new ExcelQuestion { Id = questionItem.SerialNumber, Content = questionItem.Content, LeftLimit = questionItem.LeftLimit, RightLimit = questionItem.RightLimit }); } } ExcelProfile excelProfile = new ExcelProfile { Id = profileItem.SerialNumber, Answers = profileItem.Answer, Name = profileItem.Name, Type = profileItem.Type.Type, Questions = questions }; profilesListContent.Add(excelProfile); foreach (var resultItem in profileItem.Result) { string questionedId = mainProfile.Questioned.SingleOrDefault(q => q.Id == resultItem.QuestionedId).Number; ExcelResult excelResult = new ExcelResult { Id = questionedId, ProfileNum = resultItem.Profile.SerialNumber, QuestionNum = resultItem.Question.SerialNumber, Answer = resultItem.Answer }; answerListContent.Add(excelResult); } } return(new ExcelDocument { DocumentName = mainProfile.Name, AnswerListContent = answerListContent, ProfilesListContent = profilesListContent }); } }
private static void Run() { m_Now = DateTime.Now; m_TotalProfile = new MainProfile(m_Now); m_CurrentProfile = new MainProfile(m_Now); while (!m_Closing) { m_Now = DateTime.Now; /* wait until event happens */ m_Signal.WaitOne(); ClockProfile(MainProfile.TimerId.Idle); /* process mobiles */ Mobile.ProcessDeltaQueue(); ClockProfile(MainProfile.TimerId.MobileDelta); /* process items */ Item.ProcessDeltaQueue(); ClockProfile(MainProfile.TimerId.ItemDelta); /* process timers */ Timer.Slice(); ClockProfile(MainProfile.TimerId.Timers); /* network */ m_MessagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); ClockProfile(MainProfile.TimerId.Network); if (Slice != null) { Slice(); } /* done with this iteration */ m_TotalProfile.Next(); m_CurrentProfile.Next(); } }
private void saveDBBtn_Click(object sender, EventArgs e)//+ { try { using (profileContext db = new profileContext()) { using (Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction tr = db.Database.BeginTransaction()) { try { try { DataManipulationService.SaveProfileToDB(db, tr, Document); tr.Commit(); } catch (Exception ex) { tr.Rollback(); MessageBox.Show(ex.Message); return; } DataManipulationService.SaveResultToDB(db, tr, Document); } catch (Exception ex) { MainProfile mainProfile = db.MainProfile.SingleOrDefault(p => p.Name == Document.DocumentName); if (mainProfile != null) { db.MainProfile.Remove(mainProfile); db.SaveChanges(); } MessageBox.Show(ex.Message); return; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void loadDataDBBtn_Click(object sender, EventArgs e)//+ { try { MainProfile mainProfile = null; using (ChooseMainProfileForm cmp = new ChooseMainProfileForm()) { cmp.Type = "load"; cmp.ShowDialog(); if (cmp.Status) { mainProfile = cmp.SelectedMainProfiles[0]; Document = SortDocument(DataManipulationService.LoadMainProfileDB(mainProfile)); if (Document != null) { ShowOnTabControl(Document); InitAutoComplete(questionTB, Document); saveBtn.Enabled = true; closeProfileBtn.Enabled = true; visDataBtn.Enabled = true; questionBtn.Enabled = true; MessageBox.Show("Данные успешно загружены."); } } else { return; } } } catch (Exception ex) { MessageBox.Show(ex.Message + " Исправте ошибки и попытайтесь снова!"); return; } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; ParseArguments(args); SetupConsoleLogging(); m_Thread = Thread.CurrentThread; Process = Process.GetCurrentProcess(); Assembly = Assembly.GetEntryAssembly(); if (m_Thread != null) { m_Thread.Name = "Core Thread"; } if (BaseDirectory.Length > 0) { Directory.SetCurrentDirectory(BaseDirectory); } var version = Assembly.GetName().Version; CoreVersion = version; var platform = (int)Environment.OSVersion.Platform; if (platform == 4 || platform == 128) { Unix = true; } GCSettings.LatencyMode = GCLatencyMode.LowLatency; log.Info("X-RunUO Server - Version {0}.{1}.{2}, Build {3}", version.Major, version.Minor, version.Build, version.Revision); log.Info("Running on OS {0}", Environment.OSVersion); log.Info("Running on {0} {1}", Unix ? "Mono" : ".NET Framework", Environment.Version); if (MultiProcessor || Is64Bit) { log.Info("Optimizing for {0} {2}processor{1}", ProcessorCount, ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : ""); } log.Info("Using GC {0} {1} mode", GCSettings.IsServerGC ? "Server" : "Workstation", GCSettings.LatencyMode); Config = new RootConfig(BaseDirectory, "x-runuo.xml"); Server.Config.Load(); #region Dependency management LibraryConfig = new LibraryConfig(BaseDirectory, "libraries.xml"); if (ForceUpdateDeps) { Directory.Delete(Path.Combine(BaseDirectory, "deps"), recursive: true); } #endregion if (!ScriptCompiler.Compile(Debug)) { log.Fatal("Compilation failed. Press any key to exit."); Console.ReadLine(); return; } ScriptCompiler.VerifyLibraries(); // This instance is shared among timer scheduler and timer executor, // and accessed from both core & timer threads. var timerQueue = new Queue <Timer>(); // Timer scheduler must be set up before world load, since world load // could schedule timers on entity deserialization. var timerScheduler = TimerScheduler.Instance = new TimerScheduler(timerQueue); m_TimerThread = new TimerThread(timerScheduler); var timerExecutor = new TimerExecutor(timerQueue); try { ScriptCompiler.Configure(); TileData.Configure(); } catch (TargetInvocationException e) { log.Fatal("Configure exception: {0}", e.InnerException); return; } SaveConfig(); Region.Load(); World.Load(); try { ScriptCompiler.Initialize(); } catch (TargetInvocationException e) { log.Fatal("Initialize exception: {0}", e.InnerException); return; } m_TimerThread.Start(); NetServer netServer = new NetServer(new Listener(Listener.Port)); netServer.Initialize(); GameServer.Instance = new GameServer(netServer); GameServer.Instance.Initialize(); EventSink.InvokeServerStarted(); PacketDispatcher.Initialize(); Now = DateTime.UtcNow; m_TotalProfile = new MainProfile(Now); m_CurrentProfile = new MainProfile(Now); try { while (!Closing) { Now = DateTime.UtcNow; Thread.Sleep(1); ClockProfile(MainProfile.TimerId.Idle); Mobile.ProcessDeltaQueue(); ClockProfile(MainProfile.TimerId.MobileDelta); Item.ProcessDeltaQueue(); ClockProfile(MainProfile.TimerId.ItemDelta); timerExecutor.Slice(); ClockProfile(MainProfile.TimerId.Timers); netServer.Slice(); ClockProfile(MainProfile.TimerId.Network); // Done with this iteration. m_TotalProfile.Next(); m_CurrentProfile.Next(); } } catch (Exception e) { HandleCrashed(e); } m_TimerThread.Stop(); }
public static void ResetCurrentProfile() { m_CurrentProfile = new MainProfile(Now); }
public static void SaveResultToDB(profileContext db, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction tr, Excel.ExcelDocument document) { MainProfile mainProfile = db.MainProfile.SingleOrDefault(m => m.Name == document.DocumentName); if (mainProfile == null) { throw new Exception("Ошибка при сохранении!"); } List <Profile> profiles = db.Profile.Where(p => p.MainProfile == mainProfile).ToList(); foreach (var profileItem in profiles) { db.Entry(profileItem).Collection(t => t.Question).Load(); } Dictionary <string, Questioned> questionedMap = new Dictionary <string, Questioned>(); DataTable questionedDT = new DataTable(); questionedDT.Columns.Add(new DataColumn("id")); questionedDT.Columns.Add(new DataColumn("number")); questionedDT.Columns.Add(new DataColumn("main_profile_id")); foreach (var resultItem in document.AnswerListContent) { if (!questionedMap.ContainsKey(resultItem.Id)) { questionedMap.Add(resultItem.Id, new Questioned { Number = resultItem.Id, MainProfile = mainProfile }); DataRow row = questionedDT.NewRow(); row["id"] = null; row["number"] = resultItem.Id; row["main_profile_id"] = mainProfile.Id; questionedDT.Rows.Add(row); } } BulkWriteToDB(questionedDT, "questioned"); Application.DoEvents(); questionedMap = db.Questioned.Where(q => q.MainProfile == mainProfile).ToDictionary(q => q.Number, q => q); DataTable resultDT = new DataTable(); resultDT.Columns.Add(new DataColumn("id")); resultDT.Columns.Add(new DataColumn("profile_id")); resultDT.Columns.Add(new DataColumn("question_id")); resultDT.Columns.Add(new DataColumn("answer")); resultDT.Columns.Add(new DataColumn("questioned_id")); foreach (var resultItem in document.AnswerListContent) { Profile profile = profiles.SingleOrDefault(p => p.SerialNumber == resultItem.ProfileNum); Question question = profile.Question.SingleOrDefault(q => q.SerialNumber == resultItem.QuestionNum); Questioned questioned = questionedMap[resultItem.Id]; DataRow row = resultDT.NewRow(); row["id"] = null; row["profile_id"] = profile.Id; row["question_id"] = question.Id; row["answer"] = resultItem.Answer; row["questioned_id"] = questioned.Id; resultDT.Rows.Add(row); if (resultDT.Rows.Count > 30000) { BulkWriteToDB(resultDT, "result"); resultDT.Rows.Clear(); Application.DoEvents(); } } if (resultDT.Rows.Count != 0) { BulkWriteToDB(resultDT, "result"); } }
public static void SaveProfileToDB(profileContext db, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction tr, Excel.ExcelDocument document) { Dictionary <string, QType> questionTypeMap = new Dictionary <string, QType>(); questionTypeMap = db.QType.Select(q => q).ToDictionary(q => q.Type, q => q); MainProfile mainProfile = db.MainProfile.SingleOrDefault(m => m.Name == document.DocumentName); if (mainProfile == null) { mainProfile = new MainProfile { Name = document.DocumentName }; } else { throw new Exception("Файл с таким именем уже был сохранен!"); } foreach (var profileItem in document.ProfilesListContent) { QType qType = null; if (questionTypeMap.ContainsKey(profileItem.Type)) { qType = questionTypeMap[profileItem.Type]; } else { qType = new QType { Type = profileItem.Type }; questionTypeMap.Add(qType.Type, qType); } Profile profile = mainProfile.Profile.SingleOrDefault(p => p.Name == profileItem.Name); if (profile == null) { profile = new Profile { SerialNumber = profileItem.Id, Name = profileItem.Name, Type = qType, Answer = profileItem.Answers, MainProfile = mainProfile }; mainProfile.Profile.Add(profile); } else { throw new Exception("В файле не может содержаться несколько анкет с одинаковым именем!"); } foreach (var questionItem in profileItem.Questions) { Question question = null; if (qType.Type == "range") { question = new Question { SerialNumber = questionItem.Id, Content = questionItem.Content, LeftLimit = questionItem.LeftLimit, RightLimit = questionItem.RightLimit }; } else { question = new Question { SerialNumber = questionItem.Id, Content = questionItem.Content, LeftLimit = null, RightLimit = null }; } profile.Question.Add(question); } } db.MainProfile.Add(mainProfile); db.SaveChanges(); Application.DoEvents(); }
public static void Run() { EventSink.Instance = new EventSink(); if (!ScriptCompiler.Compile(Environment.Debug)) { Console.WriteLine("Fatal: Compilation failed. Press any key to exit."); Console.ReadLine(); return; } ScriptCompiler.VerifyLibraries(); // This instance is shared among timer scheduler and timer executor, // and accessed from both core & timer threads. Queue <Timer> timerQueue = new Queue <Timer>(); // Timer scheduler must be set up before world load, since world load // could schedule timers on entity deserialization. var timerScheduler = TimerScheduler.Instance = new TimerScheduler(timerQueue); m_TimerThread = new TimerThread(timerScheduler); TimerExecutor timerExecutor = new TimerExecutor(timerQueue); PacketHandlers.Instance = new PacketHandlers(); try { ScriptCompiler.Configure(); TileData.Configure(); } catch (TargetInvocationException e) { Console.WriteLine("Fatal: Configure exception: {0}", e.InnerException); return; } Environment.SaveConfig(); Region.Load(); World.Instance.Load(); try { ScriptCompiler.Initialize(); } catch (TargetInvocationException e) { Logger.Error("Initialize exception: {0}", e.InnerException); return; } m_TimerThread.Start(); NetServer netServer = new NetServer(new Listener(Listener.Port)); netServer.Initialize(); GameServer.Instance = new GameServer(netServer, PacketHandlers.Instance); GameServer.Instance.Initialize(); EventSink.Instance.InvokeServerStarted(); PacketDispatcher.Initialize(); m_Now = DateTime.UtcNow; m_TotalProfile = new MainProfile(m_Now); m_CurrentProfile = new MainProfile(m_Now); try { while (!m_Closing) { m_Now = DateTime.UtcNow; Thread.Sleep(1); ClockProfile(MainProfile.TimerId.Idle); Mobile.ProcessDeltaQueue(); ClockProfile(MainProfile.TimerId.MobileDelta); Item.ProcessDeltaQueue(); ClockProfile(MainProfile.TimerId.ItemDelta); timerExecutor.Slice(); ClockProfile(MainProfile.TimerId.Timers); netServer.Slice(); ClockProfile(MainProfile.TimerId.Network); // Done with this iteration. m_TotalProfile.Next(); m_CurrentProfile.Next(); } } catch (Exception e) { HandleCrashed(e); } m_TimerThread.Stop(); }
public ActionResult ContactUs() { MainProfile mp = db.MainProfiles.FirstOrDefault(); return(View(mp)); }