public async Task <IActionResult> Edit(int id, [Bind("VocationId,BeginDateTime,DaysCount,TourId,OperatorId,CustomerId")] Vocation vocation) { if (id != vocation.OperatorId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vocation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VocationExists(vocation.OperatorId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "UserId", "LastName", vocation.CustomerId); ViewData["OperatorId"] = new SelectList(_context.Operators, "OperatorId", "LastName", vocation.OperatorId); ViewData["TourId"] = new SelectList(_context.Tours, "TourId", "Country", vocation.TourId); return(View(vocation)); }
//Изменить запись отпускных public bool ModifyVocation(Vocation vocation, out string error) { error = string.Empty; if (conn == null) { error = "conn == null"; return(false); } if (vocation == null) { error = "vocation == null"; return(false); } SqlCommand command = new SqlCommand(spVocationUpdate, conn); command.CommandType = System.Data.CommandType.StoredProcedure; command.Connection = conn; command.Parameters.AddWithValue("@inVocation_Id", vocation.Vocation_Id); command.Parameters.AddWithValue("@inVocation_PersCard_Id", vocation.Vocation_PersCard_Id == 0 ? Convert.DBNull : vocation.Vocation_PersCard_Id); command.Parameters.AddWithValue("@inVocation_RefDep_Id", vocation.Vocation_RefDep_Id == 0 ? Convert.DBNull : vocation.Vocation_RefDep_Id); command.Parameters.AddWithValue("@inVocation_Date", vocation.Vocation_Date == DateTime.MinValue ? Convert.DBNull : vocation.Vocation_Date); command.Parameters.AddWithValue("@inVocation_Days", vocation.Vocation_Days); command.Parameters.AddWithValue("@inVocation_Sm", vocation.Vocation_Sm); command.Parameters.AddWithValue("@inVocation_PayDate", vocation.Vocation_PayDate == DateTime.MinValue ? Convert.DBNull : vocation.Vocation_PayDate); try { command.ExecuteNonQuery(); } catch (Exception ex) { error = ex.Message; return(false); } return(true); }
public async Task <IActionResult> Create( [Bind("VocationId,BeginDateTime,DaysCount,TourId,OperatorId,CustomerId")] Vocation vocation) { if (ModelState.IsValid) { var o = await _context.Operators.FindAsync(vocation.OperatorId); var c = await _context.Customers.FindAsync(vocation.CustomerId); var t = await _context.Tours.FindAsync(vocation.TourId); vocation.Customer = c; vocation.Operator = o; vocation.Tour = t; _context.Add(vocation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "UserId", "LastName", vocation.CustomerId); ViewData["OperatorId"] = new SelectList(_context.Operators, "OperatorId", "LastName", vocation.OperatorId); ViewData["TourId"] = new SelectList(_context.Tours, "TourId", "Country", vocation.TourId); return(View(vocation)); }
public void SetVocation(string vocation) { if (vocation.Contains("knight")) { this.vocation = Vocation.Knight; } else if (vocation.Contains("druid")) { this.vocation = Vocation.Druid; } else if (vocation.Contains("paladin")) { this.vocation = Vocation.Paladin; } else if (vocation.Contains("sorcerer")) { this.vocation = Vocation.Sorcerer; } else { this.vocation = Vocation.None; } if (vocation.Contains("elder") || vocation.Contains("royal") || vocation.Contains("elite") || vocation.Contains("master")) { this.promoted = true; } }
//Обновление строки private void UpdateRecord() { if (dgvVocation.CurrentRow == null) { return; } v_Vocation vvocation = dgvVocation.CurrentRow.DataBoundItem as v_Vocation; if (vvocation == null) { MessageBox.Show("Не знайдений рядок відпускних для оновлення", "Помилка"); return; } fmVocationEdit fmEdit = new fmVocationEdit(EnumFormMode.Edit, "Зміна відпускного"); fmEdit.SetData(vvocation); if (fmEdit.ShowDialog() == DialogResult.OK) { Vocation vocation = fmEdit.GetData(); string error; if (!_repoVocation.ModifyVocation(vocation, out error)) { MessageBox.Show("Помилка оновлення відпускного.\nТехнічна інформація: " + error, "Помилка"); return; } RefreshTableVocation(_depId, _datBeg, _datEnd); } }
void Generator_OnVocationCreated(Element sender, Element rec, Vocation vocation) { if (sender == processor2) { vocations.Add(vocation); //Debug.WriteLine(vocation.LiveTime); } }
public void SetHelper(Vocation vocation, string name, string level, string attack, int number) { SetHelperImage(vocation); SetHelperName(name); SetHelperLevel(level); SetHelperAttack(attack); SetHelperHeartNumber(number); }
public void SetHelper(Vocation vocation, string name, string level, string attack, int number) { SetHelperImage(vocation); SetHelperName(name); SetHelperLevel(level); SetHelperAttack(attack); SetHelperHeartNumber(number); }
//Получить отпускные по параметрам public List <Vocation> GetVocationsByParams(int vocation_id, int refDep_id, DateTime vocation_dateBeg, DateTime vocation_dateEnd, out string error) { error = string.Empty; List <Vocation> vocations = new List <Vocation>(); if (conn == null) { error = "conn == null"; return(vocations); } if (vocation_id == 0 && refDep_id == 0 && vocation_dateBeg == DateTime.MinValue && vocation_dateEnd == DateTime.MinValue) { error = "Не задані вхідні параметри"; return(vocations); } if (vocation_dateBeg == DateTime.MinValue || vocation_dateEnd == DateTime.MinValue) { error = "Не заданий період"; return(vocations); } SqlCommand command = new SqlCommand(spVocationSelect, conn); command.CommandType = System.Data.CommandType.StoredProcedure; command.Connection = conn; command.Parameters.AddWithValue("@inVocation_Id", vocation_id); command.Parameters.AddWithValue("@inVocation_RefDep_Id", refDep_id); command.Parameters.AddWithValue("@inVocation_DateBeg", (vocation_dateBeg == DateTime.MinValue) ? Convert.DBNull : vocation_dateBeg); command.Parameters.AddWithValue("@inVocation_DateEnd", (vocation_dateEnd == DateTime.MinValue) ? Convert.DBNull : vocation_dateEnd); SqlDataReader reader = null; try { reader = command.ExecuteReader(); while (reader.Read()) { Vocation vocation = new Vocation(); FillDataRec(reader, vocation); vocations.Add(vocation); } } catch (Exception ex) { error = ex.Message; } finally { if (reader != null) { reader.Close(); } } return(vocations); }
public void SetData(Vocation vocation) { _id = vocation.Vocation_Id; cmbCalendar.SelectedIndex = SalaryHelper.GetIndexByDate( DateTime.Today.Year - SetupProgram.YearSalary, vocation.Vocation_Date, false); cmbCard.ReadCombobox(vocation.Vocation_PersCard_Id); cmbDep.ReadCombobox(vocation.Vocation_RefDep_Id); cmbPayDate.SelectedIndex = SalaryHelper.GetIndexByDate( DateTime.Today.Year - SetupProgram.VocationPayYear, vocation.Vocation_PayDate, false); tbDays.Text = vocation.Vocation_Days.ToString(); tbSm.Text = vocation.Vocation_Sm.ToString("0.00"); }
//Добавить отпускные public int AddVocation(Vocation vocation, out string error) { error = string.Empty; if (vocation == null) { error = "Vocation == null"; return(0); } if (conn == null) { error = "conn == null"; return(0); } SqlCommand command = new SqlCommand(spVocationInsert, conn); command.CommandType = System.Data.CommandType.StoredProcedure; command.Connection = conn; command.Parameters.AddWithValue("@inVocation_PersCard_Id", vocation.Vocation_PersCard_Id == 0 ? Convert.DBNull : vocation.Vocation_PersCard_Id); command.Parameters.AddWithValue("@inVocation_RefDep_Id", vocation.Vocation_RefDep_Id == 0 ? Convert.DBNull : vocation.Vocation_RefDep_Id); command.Parameters.AddWithValue("@inVocation_Date", vocation.Vocation_Date == DateTime.MinValue ? Convert.DBNull : vocation.Vocation_Date); command.Parameters.AddWithValue("@inVocation_Days", vocation.Vocation_Days); command.Parameters.AddWithValue("@inVocation_Sm", vocation.Vocation_Sm); command.Parameters.AddWithValue("@inVocation_PayDate", vocation.Vocation_PayDate == DateTime.MinValue ? Convert.DBNull : vocation.Vocation_PayDate); // определяем выходной параметр SqlParameter outId = new SqlParameter { ParameterName = "outId", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int }; command.Parameters.Add(outId); try { command.ExecuteNonQuery(); } catch (Exception ex) { error = ex.Message; return(0); } int id = 0; int.TryParse(command.Parameters["outId"].Value.ToString(), out id); return(id); }
void Element_OnVocationCreated(Element sender, Element reciever, Vocation vocation) { if (sender == this.sender) { if (this.vocation != null) { Debug.WriteLine("ssssppp"); } this.vocation = vocation; if (isBusy) { Debug.WriteLine("ssssssss"); } isBusy = true; } }
//Получить список отпускных public List <Vocation> GetAllVocations(out string error) { error = string.Empty; List <Vocation> vocations = new List <Vocation>(); if (conn == null) { error = "conn == null"; return(vocations); } SqlCommand command = new SqlCommand(spVocationSelect, conn); command.CommandType = System.Data.CommandType.StoredProcedure; SqlDataReader reader = null; try { reader = command.ExecuteReader(); while (reader.Read()) { Vocation vocation = new Vocation(); FillDataRec(reader, vocation); vocations.Add(vocation); } } catch (Exception exc) { error = exc.Message; } finally { if (reader != null) { reader.Close(); } } return(vocations); }
/// <summary> /// Loads the specified file name. /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns>The collection of vocations.</returns> private IEnumerable <IVocation> Load(string fileName) { XDocument document = XDocument.Load(fileName); foreach (XElement element in document.Element("vocations").Elements("vocation")) { IVocation vocation = new Vocation(); if (element.Attribute("id") is XAttribute idAttribute) { vocation.Id = byte.Parse(idAttribute.Value); } if (element.Attribute("name") is XAttribute nameAttribute) { vocation.Name = nameAttribute.Value; } yield return(vocation); } }
private void FillDataRec(SqlDataReader reader, Vocation vocation) { int resInt = 0; DateTime resDate = DateTime.MinValue; decimal resDec = 0; if (int.TryParse(reader["Vocation_Id"].ToString(), out resInt)) { vocation.Vocation_Id = resInt; } if (int.TryParse(reader["Vocation_PersCard_Id"].ToString(), out resInt)) { vocation.Vocation_PersCard_Id = resInt; } if (int.TryParse(reader["Vocation_RefDep_Id"].ToString(), out resInt)) { vocation.Vocation_RefDep_Id = resInt; } if (DateTime.TryParse(reader["Vocation_Date"].ToString(), out resDate)) { vocation.Vocation_Date = resDate; } if (int.TryParse(reader["Vocation_Days"].ToString(), out resInt)) { vocation.Vocation_Days = resInt; } if (decimal.TryParse(reader["Vocation_Sm"].ToString(), out resDec)) { vocation.Vocation_Sm = resDec; } if (DateTime.TryParse(reader["Vocation_PayDate"].ToString(), out resDate)) { vocation.Vocation_PayDate = resDate; } if (decimal.TryParse(reader["Vocation_ResSm"].ToString(), out resDec)) { vocation.Vocation_ResSm = resDec; } }
//Вставка строки private void InsertRecord() { fmVocationEdit fmEdit = new fmVocationEdit(EnumFormMode.Insert, "Створення відпускних"); Vocation setVocation = new Vocation(); int month = SalaryHelper.GetMonthByIndex(cmbCalendar.SelectedIndex, true); if (month == 0) { setVocation.Vocation_Date = DateTime.MinValue.AddYears(DateTime.Today.Year - 1).AddMonths(DateTime.Today.Month - 1); } else { int year = SalaryHelper.GetYearByIndex(DateTime.Today.Year - SetupProgram.YearSalary, cmbCalendar.SelectedIndex, true); setVocation.Vocation_Date = DateTime.MinValue.AddYears(year - 1).AddMonths(month - 1); } if (MenuItemDeps.CheckState == CheckState.Checked && dgvDep.CurrentRow != null) { v_Dep dep = dgvDep.CurrentRow.DataBoundItem as v_Dep; if (dep != null) { setVocation.Vocation_RefDep_Id = dep.Id; } } fmEdit.SetData(setVocation); if (fmEdit.ShowDialog() == DialogResult.OK) { string error; Vocation getVocation = fmEdit.GetData(); int id = _repoVocation.AddVocation(getVocation, out error); if (id == 0) { MessageBox.Show("Помилка додавання рядка.\nТехнічна інформація: " + error, "Помилка"); return; } RefreshTableVocation(_depId, _datBeg, _datEnd); dgvVocation.SetPositionRow <v_Vocation>("Vocation_Id", id.ToString()); } }
private void PopulateVocations() { Vocation knight = new Vocation( DataReader.ReadSprite(203), "Elite", "Knight", 10, 15, 5, 5 ); Vocation paladin = new Vocation( DataReader.ReadSprite(506), "Royal", "Paladin", 7.5, 10, 7.5, 10 ); Vocation sorcerer = new Vocation( DataReader.ReadSprite(1337), "Master", "Sorcerer", 5, 5, 10, 15 ); Vocation druid = new Vocation( DataReader.ReadSprite(1286), "Elder", "Druid", 5, 5, 10, 15 ); _vocations.Add(knight); _vocations.Add(paladin); _vocations.Add(sorcerer); _vocations.Add(druid); }
void Element_OnVocationCreated(Element sender, Element rec, Vocation vocation) { if (sender == this.sender) { if (this.vocation != null) { Debug.WriteLine("ssssppp"); } this.vocation = vocation; if (((Processor)this.reciever).IsBusy) { if (currentCapacity >= capacity) { isBusy = true; } if (!isBusy) { currentCapacity++; } } else { OnVocationCreated?.Invoke(this, this.reciever, vocation); this.vocation = null; if (counter != null) { counter.Increment(); } } } }
public Vocation GetData() { Vocation vocation = new Vocation(); vocation.Vocation_Id = _id; vocation.Vocation_PersCard_Id = _cmbCardParams.PersCard_Id; vocation.Vocation_RefDep_Id = _cmbDepParams.RefDep_Id; vocation.Vocation_Date = SalaryHelper.GetDateByIndex(cmbCalendar.SelectedIndex, DateTime.Today.Year - SetupProgram.YearSalary, false); vocation.Vocation_PayDate = SalaryHelper.GetDateByIndex(cmbPayDate.SelectedIndex, DateTime.Today.Year - SetupProgram.VocationPayYear, false); int resInt = 0; decimal resDec = 0; //Дни if (int.TryParse(tbDays.Text, out resInt)) { vocation.Vocation_Days = resInt; } //Сумма if (decimal.TryParse(tbSm.Text, out resDec)) { vocation.Vocation_Sm = resDec; } return(vocation); }
public async Task <Highscore> GetHighscore(string world, HighscoreType type, Vocation vocation) { return(await _highscoreService.Get(world, type, vocation)); }
public static string GetVocationName(this Vocation vocation) { return(Regex.Replace(vocation.ToString(), "([A-Z])", " $1", RegexOptions.Compiled).Trim()); }
public void SetHelperImage(Vocation vocation) { LoggerHelper.Debug("Vocation: " + vocation); helperImage.spriteName = IconData.dataMap.Get((int)IconOffset.Avatar + (int)vocation).path; }
public void SetHelperImage(Vocation vocation) { LoggerHelper.Debug("Vocation: " + vocation); helperImage.spriteName = IconData.dataMap.Get((int)IconOffset.Avatar + (int)vocation).path; }
public void SetVocation(string vocation) { if (vocation.Contains("knight")) this.vocation = Vocation.Knight; else if (vocation.Contains("druid")) this.vocation = Vocation.Druid; else if (vocation.Contains("paladin")) this.vocation = Vocation.Paladin; else if (vocation.Contains("sorcerer")) this.vocation = Vocation.Sorcerer; else this.vocation = Vocation.None; if (vocation.Contains("elder") || vocation.Contains("royal") || vocation.Contains("elite") || vocation.Contains("master")) this.promoted = true; }
private string GetVocationByName(Vocation vocation) { switch (vocation) { case Vocation.DRUID: return "druid"; case Vocation.KNIGHT: return "knight"; case Vocation.NONE: return "no vocation"; case Vocation.PALADIN: return "paladin"; case Vocation.SORCERER: return "sorcerer"; default: throw new Exception("Invalid call to GetVocationByName()"); } }
public Worker(string log, string pass, Vocation prof) { Login = log; Password = pass; Profession = prof; }
public static string GetQueryString(this Vocation vocation) => vocation.ToString().Replace("_", "+");
public async Task <Highscore> Get(string world, HighscoreType type, Vocation vocation) { var response = await GetResponse($"{ _baseUri }{ world }//{ type.ToString() }//{ vocation.GetQueryString() }.json"); return(JsonConvert.DeserializeObject <HighscoreResponse>(response).Highscores); }
public int GetRewardByVocation(Vocation vocation) { return(reward[(int)vocation]); }
internal static void Main() { NativeMethods.SetConsoleCtrlHandler(ConsoleCtrlOperationHandler, true); Game.Initialize(); Tools.Initialize(); OutputMessagePool.Initialize(); NetworkMessagePool.Initialize(); Console.Title = Constants.ServerName; Console.Clear(); Console.WriteLine("Welcome to {0} - Version {1}", Constants.ServerName, Constants.ServerVersion); Console.WriteLine("Developed by {0}", Constants.ServerDevelopers); Console.WriteLine(); // Start Threads DispatcherManager.Start(); // Loading config.lua if (!ConfigManager.Load("config.lua")) { ExitApplication(); } if (!Enum.TryParse(ConfigManager.Instance[ConfigStr.MinConsoleLogLevel], true, out Logger.MinConsoleLogLevel)) { Console.WriteLine("LOGGER LOG LEVEL COULD NOT BE PARSED! PLEASE FIX!"); ExitApplication(); } // Setting up process priority switch (ConfigManager.Instance[ConfigStr.DefaultPriority]) { case "realtime": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; break; case "high": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; break; case "higher": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal; break; } // Setting up RSA cyrpto if (!Rsa.SetKey(RsaP, RsaQ)) { ExitApplication(); } // Initializing Database connection if (!Database.Initialize()) { ExitApplication(); } //DATABASE MANAGER UPDATE DATABASE //DATABASE TASKS START // Loading vocations if (!Vocation.LoadVocations()) { ExitApplication(); } // Loading items if (!ItemManager.Load()) { ExitApplication(); } // Loading Chat Channels if (!Chat.Load()) { ExitApplication(); } // Loading scripts if (!ScriptManager.LoadCsScripts() || !ScriptManager.LoadLuaScripts()) { ExitApplication(); } // Loading Command Line Operations if (!ScriptManager.LoadCommandLineOperations()) { ExitApplication(); } // LOAD CREATURES HERE // Loading outfits if (!OutfitManager.Load()) { ExitApplication(); } // Loading map if (!Map.Load()) { ExitApplication(); } // Setting game world type switch (ConfigManager.Instance[ConfigStr.WorldType]) { case "pvp": Game.WorldType = GameWorldTypes.Pvp; break; case "no-pvp": Game.WorldType = GameWorldTypes.NoPvp; break; case "pvp-enforced": Game.WorldType = GameWorldTypes.PvpEnforced; break; default: Logger.Log(LogLevels.Error, "Invalid game world type: " + ConfigManager.Instance[ConfigStr.WorldType]); ExitApplication(); break; } Logger.Log(LogLevels.Operation, "Setting Game World Type: " + Game.WorldType); // Initialize Game State Game.GameState = GameStates.Init; //TODO: HOUSE RENTS //TODO: MARKET CHECK OFFERS //TODO: MARKET STATISTICS if (ConfigManager.Instance[ConfigBool.UseExternalLoginServer]) { //Create secret communication channel with login server if login server is external if (!SecretServerConnection.Initialize()) { ExitApplication(); } // Create signal waiting system to get authentication response from external login server } else { _loginServer = new LoginServer.LoginServer(); _loginServer.Start(); } GameServer.Start(); Game.GameState = GameStates.Normal; Game.StartJobs(); //TODO: FIRE SERVER RUNNING EVENT while (true) { string input = Console.ReadLine(); if (input == null) { continue; } string[] firstPass = input.Split('"'); List <string> secondPass = firstPass[0].Trim().Split(' ').ToList(); if (firstPass.Length > 1) { for (int i = 1; i < firstPass.Length; i++) { if (i % 2 == 1) { secondPass.Add(firstPass[i]); } else { secondPass.AddRange(firstPass[i].Trim().Split(' ')); } } } string[] command = secondPass.ToArray(); if (ScriptManager.CommandLineOperations.ContainsKey(command[0])) { try { ScriptManager.CommandLineOperations[command[0]].Invoke(command); } catch (Exception) { Logger.Log(LogLevels.Warning, "Command '" + command[0] + "' could not be executed in this environment!"); } } else { Logger.Log(LogLevels.Warning, "Command is unknown!"); } } // ReSharper disable FunctionNeverReturns }
public void SetData(Vocation vocation) { }
static public string GetPortraitByVocation(Vocation voc) { return((PORTRAIT + (byte)voc).ToString()); }
public void SetVocation(int value) { // if you wanna set it to value v = new Vocation(value); }
public static string GetProperString(this Vocation vocation) => vocation.ToString().Replace("_", " ");