/// <summary> /// Returns an name of an InfoEvent. /// </summary> /// <param name="Header"></param> /// <returns></returns> public static string GetName(short Header) { using (DictionaryAdapter<string, short> DA = new DictionaryAdapter<string, short>(InfoEvents)) { return DA.TryPopKey(Header); } }
/// <summary> /// Returns the code of an badge, by the id. /// </summary> /// <param name="BadgeId"></param> /// <returns></returns> public string GetBadgeCode(int BadgeId) { using (DictionaryAdapter<int, BadgeInformation> DA = new DictionaryAdapter<int, BadgeInformation>(BadgeInformations)) { return DA.TryPopValue(BadgeId).BadgeCode; } }
/// <summary> /// Returns an header from an InfoEvent. /// </summary> /// <param name="Event"></param> /// <returns></returns> public short GetHeader(Event Event) { using (DictionaryAdapter<string, short> DA = new DictionaryAdapter<string, short>(InfoEvents)) { return DA.TryPopValue(Event.GetType().Name); } }
public void Remove_RemovesFromDictionary() { // Arrange var nameKey = "Name"; var dictionary = new Dictionary <string, object>(StringComparer.Ordinal) { [nameKey] = "James" }; var dictionaryAdapter = new DictionaryAdapter <string, object>(); var options = new JsonSerializerOptions(); // Act var removeStatus = dictionaryAdapter.TryRemove(dictionary, typeof(Dictionary <string, object>), nameKey, options, out var message); //Assert Assert.True(removeStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Empty(dictionary); }
public void Remove_RemovesFromDictionary_WithUriKey() { // Arrange var uriKey = new Uri("http://www.test.com/name"); var dictionary = new Dictionary <Uri, object> { [uriKey] = "James" }; var dictionaryAdapter = new DictionaryAdapter <Uri, object>(); var options = new JsonSerializerOptions(); // Act var removeStatus = dictionaryAdapter.TryRemove(dictionary, typeof(Dictionary <Uri, object>), uriKey.ToString(), options, out var message); //Assert Assert.True(removeStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Empty(dictionary); }
public void Add_IntKeyWhichAlreadyExists_ReplacesExistingValue() { // Arrange var intKey = 1; var dictionary = new Dictionary <int, object>(); dictionary[intKey] = "Mike"; var dictionaryAdapter = new DictionaryAdapter <int, object>(); var resolver = new DefaultContractResolver(); // Act var addStatus = dictionaryAdapter.TryAdd(dictionary, intKey.ToString(), resolver, "James", out var message); // Assert Assert.True(addStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal("James", dictionary[intKey]); }
public void ReplacingExistingItem() { // Arrange var nameKey = "Name"; var dictionary = new Dictionary <string, object>(StringComparer.Ordinal); dictionary.Add(nameKey, "Mike"); var dictionaryAdapter = new DictionaryAdapter <string, object>(); var resolver = new DefaultContractResolver(); // Act var replaceStatus = dictionaryAdapter.TryReplace(dictionary, nameKey, resolver, "James", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal("James", dictionary[nameKey]); }
public void Add_KeyWhichAlreadyExists_ReplacesExistingValue() { // Arrange var key = "Status"; var dictionary = new Dictionary <string, int>(StringComparer.Ordinal); dictionary[key] = 404; var dictionaryAdapter = new DictionaryAdapter <string, int>(); var resolver = new DefaultContractResolver(); // Act var addStatus = dictionaryAdapter.TryAdd(dictionary, key, resolver, 200, out var message); // Assert Assert.True(addStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal(200, dictionary[key]); }
public void ReplacingExistingItem_WithGuidKey() { // Arrange var guidKey = new Guid(); var dictionary = new Dictionary <Guid, object>(); dictionary.Add(guidKey, "Mike"); var dictionaryAdapter = new DictionaryAdapter <Guid, object>(); var resolver = new DefaultContractResolver(); // Act var replaceStatus = dictionaryAdapter.TryReplace(dictionary, guidKey.ToString(), resolver, "James", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal("James", dictionary[guidKey]); }
public void ListRooms() { comboBoxRooms.Items.Clear(); var roomsList = DbQuery.GetAllRooms(); if (roomsList != null) { foreach (var room in roomsList) { var dictionaryAdapter = new DictionaryAdapter(room); var comboItem = new ComboboxItem { Text = "Room " + dictionaryAdapter.GetValue("id"), Value = int.Parse(dictionaryAdapter.GetValue("id")) }; comboBoxRooms.Items.Add(comboItem); } } }
public void ClearsSource() { var dictionary = new Dictionary <int, string>() { { 1, "one" }, { 2, "two" }, { 3, "three" } }; var forwarderDictionary = new DictionaryAdapter <int, string>( dictionary.TryGetValue, () => dictionary.Keys, (key, value) => dictionary[key] = value, dictionary.Remove); forwarderDictionary.Clear(); Assert.Empty(dictionary); }
public void Test_ThrowsJsonPatchException_IfTestFails() { // Arrange var key = "Name"; var dictionary = new Dictionary <string, object> { [key] = "James" }; var dictionaryAdapter = new DictionaryAdapter <string, object>(); var expectedErrorMessage = "The current value 'James' at path 'Name' is not equal to the test value 'John'."; var options = new JsonSerializerOptions(); // Act var testStatus = dictionaryAdapter.TryTest(dictionary, typeof(Dictionary <string, object>), key, options, "John", out var errorMessage); //Assert Assert.False(testStatus); Assert.Equal(expectedErrorMessage, errorMessage); }
public IList <Schedule> GetSchedules() { // Time now var date = new DateTime(); var day = date.Day; var month = date.Month; var year = date.Year; // Schedules var schedules = DbQuery.GetAllSchedules(); var schedulesList = new List <Schedule>(); foreach (var schedule in schedules) { var scheduleAdapter = new DictionaryAdapter(schedule); var startDateValue = scheduleAdapter.GetValue("firstDay"); var lastDateValue = scheduleAdapter.GetValue("lastDay"); var startDayMonthYear = startDateValue.Split('-'); var endDayMonthYear = lastDateValue.Split('-'); if (month.ToString().Equals(startDayMonthYear[1]) && year.ToString().Equals(endDayMonthYear[1])) { if (day.ToString().Equals(startDayMonthYear[0]) || day.ToString().Equals(endDayMonthYear[0])) { var selectedSchedule = new Schedule(schedule); schedulesList.Add(selectedSchedule); } else if (day > int.Parse(startDayMonthYear[0]) && day < int.Parse(endDayMonthYear[0])) { var selectedSchedule = new Schedule(schedule); schedulesList.Add(selectedSchedule); } } } if (schedulesList.Count == 0) { return(null); } return(schedulesList); }
public void Add_KeyWhichAlreadyExists_ReplacesExistingValue() { // Arrange var key = "Status"; var dictionary = new Dictionary <string, int>(StringComparer.Ordinal) { [key] = 404 }; var dictionaryAdapter = new DictionaryAdapter <string, int>(); var options = new JsonSerializerOptions(); // Act var addStatus = dictionaryAdapter.TryAdd(dictionary, typeof(Dictionary <string, int>), key, options, 200, out var message); // Assert Assert.True(addStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal(200, dictionary[key]); }
public void ReplacingExistingItem_WithGuidKey() { // Arrange var guidKey = new Guid(); var dictionary = new Dictionary <Guid, object> { { guidKey, "Mike" } }; var dictionaryAdapter = new DictionaryAdapter <Guid, object>(); var options = new JsonSerializerOptions(); // Act var replaceStatus = dictionaryAdapter.TryReplace(dictionary, typeof(Dictionary <Guid, object>), guidKey.ToString(), options, "James", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal("James", dictionary[guidKey]); }
public void ReplacingWithInvalidValue_ThrowsInvalidValueForPropertyException() { // Arrange var guidKey = new Guid(); var dictionary = new Dictionary <Guid, int>(); dictionary.Add(guidKey, 5); var dictionaryAdapter = new DictionaryAdapter <Guid, int>(); var resolver = new DefaultContractResolver(); // Act var replaceStatus = dictionaryAdapter.TryReplace(dictionary, guidKey.ToString(), resolver, "test", out var message); // Assert Assert.False(replaceStatus); Assert.Equal( string.Format("The value '{0}' is invalid for target location.", "test"), message); Assert.Equal(5, dictionary[guidKey]); }
public void Add_IntKeyWhichAlreadyExists_ReplacesExistingValue() { // Arrange var intKey = 1; var dictionary = new Dictionary <int, object> { [intKey] = "Mike" }; var dictionaryAdapter = new DictionaryAdapter <int, object>(); var options = new JsonSerializerOptions(); // Act var addStatus = dictionaryAdapter.TryAdd(dictionary, typeof(Dictionary <int, object>), intKey.ToString(), options, "James", out var message); // Assert Assert.True(addStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal("James", dictionary[intKey]); }
public void ReplacingExistingItem() { // Arrange var nameKey = "Name"; var dictionary = new Dictionary <string, object>(StringComparer.Ordinal) { { nameKey, "Mike" } }; var dictionaryAdapter = new DictionaryAdapter <string, object>(); var options = new JsonSerializerOptions(); // Act var replaceStatus = dictionaryAdapter.TryReplace(dictionary, typeof(Dictionary <string, object>), nameKey, options, "James", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal("James", dictionary[nameKey]); }
public void ReplacingWithInvalidValue_ThrowsInvalidValueForPropertyException() { // Arrange var guidKey = new Guid(); var dictionary = new Dictionary <Guid, int> { { guidKey, 5 } }; var dictionaryAdapter = new DictionaryAdapter <Guid, int>(); var options = new JsonSerializerOptions(); // Act var replaceStatus = dictionaryAdapter.TryReplace(dictionary, typeof(Dictionary <Guid, int>), guidKey.ToString(), options, "test", out var message); // Assert Assert.False(replaceStatus); Assert.Equal("The value 'test' is invalid for target location.", message); Assert.Equal(5, dictionary[guidKey]); }
public void Replace_UsesCustomConverter() { // Arrange var nameKey = "Name"; var dictionary = new Dictionary <string, Rectangle>(StringComparer.Ordinal); dictionary.Add(nameKey, new Rectangle() { RectangleProperty = "Mike" }); var dictionaryAdapter = new DictionaryAdapter <string, Rectangle>(); var resolver = new RectangleContractResolver(); // Act var replaceStatus = dictionaryAdapter.TryReplace(dictionary, nameKey, resolver, "James", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Single(dictionary); Assert.Equal("James", dictionary[nameKey].RectangleProperty); }
public void Test_DoesNotThrowException_IfTestIsSuccessful() { // Arrange var key = "Name"; var dictionary = new Dictionary <string, List <object> >(); var value = new List <object> { "James", 2, new Customer("James", 25) }; dictionary[key] = value; var dictionaryAdapter = new DictionaryAdapter <string, List <object> >(); var options = new JsonSerializerOptions(); // Act var testStatus = dictionaryAdapter.TryTest(dictionary, typeof(Dictionary <string, List <object> >), key, options, value, out var message); //Assert Assert.True(testStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); }
public void Test_DoesNotThrowException_IfTestIsSuccessful() { // Arrange var key = "Name"; var dictionary = new Dictionary <string, List <object> >(); var value = new List <object>() { "James", 2, new Customer("James", 25) }; dictionary[key] = value; var dictionaryAdapter = new DictionaryAdapter <string, List <object> >(); var resolver = new DefaultContractResolver(); // Act var testStatus = dictionaryAdapter.TryTest(dictionary, key, resolver, value, out var message); //Assert Assert.True(testStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); }
/// <summary> /// Returns an category with the id. /// </summary> /// <param name="CategoryId"></param> /// <returns></returns> public AchievementCategory GetCategory(int CategoryId) { using (DictionaryAdapter<int, AchievementCategory> DA = new DictionaryAdapter<int, AchievementCategory>(Categorys)) { return DA.TryPopValue(CategoryId); } }
public void UpdateExhibitions() { var exhibitionsResult = DbQuery.GetAllEventsOrderedByLast(); if (exhibitionsResult?.Count >= 2) { for (var i = 0; i < 2; i++) { var adapter = new DictionaryAdapter(exhibitionsResult[i]); var temporaryResult = DbQuery.GetTemporariesInEvents(adapter.GetValue("id")); if (temporaryResult.Count == 0) { var permanentResult = DbQuery.GetPermanentsInEvents(adapter.GetValue("id")); if (permanentResult.Count > 0) { adapter = new DictionaryAdapter(permanentResult[0]); if (i == 0) { TitleFirstExhibition.Text = adapter.GetValue("title"); NameExhibitionOne.Text = adapter.GetValue("name"); DescriptionExhibitionOne.Text = adapter.GetValue("description"); FromExhibitionOne.Text = @"---"; ToExhibitionOne.Text = @"---"; ScheduleExhibitionOne.Text = @"9:00 - 19:00"; ArtistExhibitionOne.Text = @"Museum Property"; } else { TitleSecondExhibition.Text = adapter.GetValue("title"); NameExhibitionTwo.Text = adapter.GetValue("name"); DescriptionExhibitionTwo.Text = adapter.GetValue("description"); ToExhibitionTwo.Text = @"---"; FromExhibitionTwo.Text = @"---"; ScheduleExhibitionTwo.Text = @"9:00 - 19:00"; ArtistExhibitionTwo.Text = @"Museum Property"; } } } else { foreach (var property in temporaryResult) { var temporaryAdapter = new DictionaryAdapter(property); var schedulesResult = DbQuery.GetSchedulesById(temporaryAdapter.GetValue("schedule_id")); var schedulesAdapter = new DictionaryAdapter(schedulesResult[0]); var processesResult = DbQuery.GetProcessesById(temporaryAdapter.GetValue("processes_id")); var processesAdapter = new DictionaryAdapter(processesResult[0]); var exhibitorResult = DbQuery.GetExhibitorsById(processesAdapter.GetValue("exhibitors_id")); var exhibitorAdapter = new DictionaryAdapter(exhibitorResult[0]); var personResult = DbQuery.GetPeopleById(exhibitorAdapter.GetValue("persons_id")); var personAdapter = new DictionaryAdapter(personResult[0]); if (i == 0) { TitleFirstExhibition.Text = adapter.GetValue("title"); NameExhibitionOne.Text = adapter.GetValue("name"); DescriptionExhibitionOne.Text = adapter.GetValue("description"); FromExhibitionOne.Text = schedulesAdapter.GetValue("startDay") + @"/" + schedulesAdapter.GetValue("startMonth") + @"/" + schedulesAdapter.GetValue("startYear"); ToExhibitionOne.Text = schedulesAdapter.GetValue("endDay") + @"/" + schedulesAdapter.GetValue("endMonth") + @"/" + schedulesAdapter.GetValue("endYear"); ScheduleExhibitionOne.Text = schedulesAdapter.GetValue("startTime") + @"-" + schedulesAdapter.GetValue("endTime"); ArtistExhibitionOne.Text = personAdapter.GetValue("name"); } else { TitleSecondExhibition.Text = adapter.GetValue("title"); NameExhibitionTwo.Text = adapter.GetValue("name"); DescriptionExhibitionTwo.Text = adapter.GetValue("description"); FromExhibitionTwo.Text = schedulesAdapter.GetValue("startDay") + @"/" + schedulesAdapter.GetValue("startMonth") + @"/" + schedulesAdapter.GetValue("startYear"); ToExhibitionTwo.Text = schedulesAdapter.GetValue("endDay") + @"/" + schedulesAdapter.GetValue("endMonth") + @"/" + schedulesAdapter.GetValue("endYear"); ScheduleExhibitionTwo.Text = schedulesAdapter.GetValue("startTime") + @"-" + schedulesAdapter.GetValue("endTime"); ArtistExhibitionTwo.Text = personAdapter.GetValue("name"); } } } } ExhibitionOne.Visible = true; ExhibitionTwo.Visible = true; } else { ExhibitionOne.Visible = false; ExhibitionTwo.Visible = false; } }
public DictionaryItemTouchHelper(WordsLogic wordsLogic, DictionaryAdapter adapter, DictionaryActivity activity) { this.wordsLogic = wordsLogic; this.adapter = adapter; this.activity = activity; }
/// <summary> /// Calculates how much you need for a specified level. /// </summary> /// <param name="Level"></param> /// <returns></returns> public int GetRequired(int Level) { using (DictionaryAdapter<int, int> DA = new DictionaryAdapter<int, int>(Limits)) { return DA.TryPopValue(Level); } }
public static Dictionary <TKey, TValue> LoadDictionary <TKey, TValue>(string fileName) { List <KVPair <TKey, TValue> > lst = (List <KVPair <TKey, TValue> >)DoLoad(fileName, typeof(List <KVPair <TKey, TValue> >)); return(DictionaryAdapter.ToDictionary(lst)); }
public static void SaveDictionary <TKey, TValue>(string fileName, Dictionary <TKey, TValue> dictionary) { Save(fileName, DictionaryAdapter.ToList(dictionary)); }
private void SpecSchedule_Click(object sender, EventArgs e) { Exhibitions.Controls.Clear(); var value = (ComboboxItem)RoomsCombo.SelectedItem; long idRoom; try { idRoom = value.Value; } catch (NullReferenceException) { return; } var date = dateTimePicker.Value; var day = date.Day; var month = date.Month; var year = date.Year; var eventsId = DbQuery.GetEventsByRoom(idRoom.ToString()); var hasPermanent = false; if (eventsId.Count > 0) { var idSchedules = new List <int>(); foreach (var events in eventsId) { var adapter = new DictionaryAdapter(events); var temporariesList = DbQuery.GetTemporariesInEvents(adapter.GetValue("events_id")); var permanentsList = DbQuery.GetPermanentsInEvents(adapter.GetValue("events_id")); if (permanentsList?.Count > 0) { hasPermanent = true; } else if (temporariesList.Count > 0) { var eventsAdapter = new DictionaryAdapter(temporariesList[0]); idSchedules.Add(int.Parse(eventsAdapter.GetValue("schedule_id"))); } } var heigtht = Exhibitions.Size.Height; var width = Exhibitions.Size.Width; if (idSchedules.Count > 0) { var allSchedules = DbQuery.GetSchedulesByIds(idSchedules, day, month, year); var scheduleList = new List <Schedule>(); foreach (var schedule in allSchedules) { var addSchedule = new Schedule(schedule); scheduleList.Add(addSchedule); } var totalDivisions = 20; var spacesList = new List <int>(); var pickList = new List <string>(); var textsLabel = new List <string>(); var baseTime = "9:00"; foreach (var schedule in scheduleList) { var startTime = schedule.StartTime; var startTimeComponentes = startTime.Split(':'); var endTime = schedule.EndTime; var endTimeComponentes = endTime.Split(':'); if (!baseTime.Equals(startTime)) { var baseSplit = baseTime.Split(':'); var baseInicial = int.Parse(baseSplit[0]) * 2; baseInicial = startTimeComponentes[1].Equals("30") ? baseInicial + 1 : baseInicial; var startTimeNext = int.Parse(startTimeComponentes[0]) * 2; startTimeNext = startTimeComponentes[1].Equals("30") ? startTimeNext + 1 : startTimeNext; var spaceWithout = startTimeNext - baseInicial; // totalDivisions += spaceWithout; textsLabel.Add("Free Schedule"); spacesList.Add(spaceWithout); pickList.Add("Without"); } var horaInicial = int.Parse(startTimeComponentes[0]) * 2; horaInicial = startTimeComponentes[1].Equals("30") ? horaInicial + 1 : horaInicial; var horaFinal = int.Parse(endTimeComponentes[0]) * 2; horaFinal = endTimeComponentes[1].Equals("30") ? horaFinal + 1 : horaFinal; var space = horaFinal - horaInicial; // totalDivisions += space; spacesList.Add(space); pickList.Add("Schedule"); baseTime = endTime; var processEventResult = DbQuery.GetProcessByScheduleId(schedule.Id.ToString()); var adapter = new DictionaryAdapter(processEventResult[0]); textsLabel.Add(adapter.GetValue("title") + "-" + adapter.GetValue("name")); } if (!baseTime.Equals("19:00")) { var final = 38; var componentTime = baseTime.Split(':'); var lastDivision = componentTime[1].Equals("30") ? int.Parse(componentTime[0]) * 2 + 1 : int.Parse(componentTime[0]) * 2; lastDivision = final - lastDivision + 1; spacesList.Add(lastDivision); pickList.Add("Without"); textsLabel.Add("Free Schedule"); } var listOfPanels = new List <Panel>(); var distanceTop = 0; var pie = (float)heigtht / totalDivisions; for (var i = 0; i < spacesList.Count; i++) { var panel = new Panel { Dock = DockStyle.Top, Location = new Point(0, (int)(i * (distanceTop * pie))), Name = "Time" + i, BackColor = pickList[i].Equals("Without") ? Color.White : Color.Yellow, Size = new Size(width, (int)(spacesList[i] * pie)), AutoSize = false, TabIndex = i, BorderStyle = BorderStyle.FixedSingle }; var label = new Label { Dock = DockStyle.Fill, Font = new Font("Microsoft Sans Serif", 12F, FontStyle.Bold, GraphicsUnit.Point, 0), Location = new Point(0, (int)(i * (distanceTop * pie))), Name = "Event-" + i, Size = new Size(width, (int)(spacesList[i] * pie)), TabIndex = 1, Text = textsLabel[i], TextAlign = ContentAlignment.MiddleCenter }; distanceTop += spacesList[i]; panel.Controls.Add(label); listOfPanels.Add(panel); } listOfPanels.Reverse(); foreach (var panel in listOfPanels) { Exhibitions.Controls.Add(panel); } } else { if (hasPermanent) { var panel = new Panel { Dock = DockStyle.Top, Location = new Point(0, 0), Name = "Time", BackColor = Color.Yellow, Size = new Size(width, heigtht), AutoSize = false, TabIndex = 0, BorderStyle = BorderStyle.FixedSingle }; var label = new Label { Dock = DockStyle.Fill, Font = new Font("Microsoft Sans Serif", 12F, FontStyle.Bold, GraphicsUnit.Point, 0), Location = new Point(0, 0), Name = "Event-", Size = new Size(width, heigtht), TabIndex = 1, Text = "Permanent Event", TextAlign = ContentAlignment.MiddleCenter }; panel.Controls.Add(label); Exhibitions.Controls.Add(panel); } } } }
/// <summary> /// Tries to get the value of the rank /// </summary> /// <param name="Key"></param> /// <returns></returns> public CharacterRank GetRank(int Key) { using (DictionaryAdapter<int, CharacterRank> DA = new DictionaryAdapter<int, CharacterRank>(CharacterRanks)) { return DA.TryPopValue(Key); } }
private void AddMessage(int c) { if (Enumerator.Current == null) // caso inicial quando ainda n foi efetuado o primeiro movenext { Enumerator.MoveNext(); } var msg = Enumerator.Current; var nrMsg = Person.Messages.Count; if (nrMsg > 0) { Debug.WriteLine("nr_msg: " + nrMsg); if (msg != null) { var list = DbQuery.GetMessageLastUpdate(msg.Id.ToString()); string lastUpdate = null; foreach (var msgdict in list) { var da = new DictionaryAdapter(msgdict); lastUpdate = da.GetValue("lastUpdate"); } if (lastUpdate != null) { var msgtext = AddMessageField(80 * c); //Cria o campo do label no windows forms msgtext.AutoSize = false; msgtext.BorderStyle = BorderStyle.FixedSingle; msgtext.BackColor = Color.BurlyWood; msgtext.Text = @"Title: " + msg.Title + Environment.NewLine + @"From: " + msg.Sender.Name + @" - Received at: " + lastUpdate; msgtext.TextAlign = ContentAlignment.MiddleCenter; msgtext.Width = 625; msgtext.Height = 80; msgtext.Click += delegate { msgtext_Click(msg); }; msgtext.MouseHover += delegate { msgtext.BackColor = Color.AntiqueWhite; Cursor.Current = Cursors.Hand; }; msgtext.MouseEnter += delegate { msgtext.BackColor = Color.AntiqueWhite; Cursor.Current = Cursors.Hand; }; msgtext.MouseLeave += delegate { msgtext.BackColor = Color.BurlyWood; Cursor.Current = Cursors.Default; }; if (Enumerator.Current != null) { Debug.WriteLine(Enumerator.Current.Id); } } } } else { var msgtext = AddMessageField(20 * 1); //Cria o campo no windows forms msgtext.AutoSize = false; msgtext.Font = new Font("Microsoft Sans Serif", 18F); msgtext.BackColor = Color.BurlyWood; msgtext.Text = @"No messages"; msgtext.TextAlign = ContentAlignment.MiddleCenter; msgtext.Width = 625; msgtext.Height = 80; } }
private bool CheckRoomAvailbility(List <int> roomsId) { var date = FromPicker.Value; var dayStart = date.Day; var monthStart = date.Month; var yearStart = date.Year; date = UntilPicker.Value; var dayEnd = date.Day; var monthEnd = date.Month; var yearEnd = date.Year; var desiredStartDayMonthYear = new[] { dayStart.ToString(), monthStart.ToString(), yearStart.ToString() }; var desiredEndDayMonthYear = new[] { dayEnd.ToString(), monthEnd.ToString(), yearEnd.ToString() }; var desiredStartTime = startBox.Text.Split(':'); var desiredEndTime = endBox.Text.Split(':'); foreach (var room in roomsId) { var roomsEventsResult = DbQuery.GetEventsByRoom(room.ToString()); if (roomsEventsResult != null) { foreach (var events in roomsEventsResult) { var eventAdapter = new DictionaryAdapter(events); var temporaries = DbQuery.GetTemporariesInEvents(eventAdapter.GetValue("events_id")); var temporariesAdapter = new DictionaryAdapter(temporaries[0]); var scheduleEventResult = DbQuery.GetScheduleByIdOrderByLastUpdateDesc(temporariesAdapter.GetValue("schedule_id")); if (scheduleEventResult != null) { foreach (var schedule in scheduleEventResult) { var scheduleAdapter = new DictionaryAdapter(schedule); var startDayValue = scheduleAdapter.GetValue("startDay"); var startMonthValue = scheduleAdapter.GetValue("startMonth"); var startYearValue = scheduleAdapter.GetValue("startMonth"); var lastDayValue = scheduleAdapter.GetValue("endDay"); var lastMonthValue = scheduleAdapter.GetValue("endMonth"); var lastYearValue = scheduleAdapter.GetValue("endYear"); var startTime = scheduleAdapter.GetValue("startTime"); var endTime = scheduleAdapter.GetValue("endTime"); var startHourMin = startTime.Split(':'); var endHourMin = endTime.Split(':'); if (int.Parse(desiredEndDayMonthYear[2]) == int.Parse(startYearValue) || int.Parse(desiredEndDayMonthYear[2]) == int.Parse(lastYearValue) || int.Parse(desiredStartDayMonthYear[2]) == int.Parse(startYearValue) || int.Parse(desiredStartDayMonthYear[2]) == int.Parse(lastYearValue)) { if (startMonthValue.Equals(desiredStartDayMonthYear[1]) && lastMonthValue.Equals(desiredEndDayMonthYear[1])) { if (int.Parse(startDayValue) > int.Parse(desiredStartDayMonthYear[0])) { if (int.Parse(startDayValue) < int.Parse(desiredEndDayMonthYear[0])) { } else if (int.Parse(startDayValue) > int.Parse(desiredEndDayMonthYear[0])) { return(false); } else if (int.Parse(startDayValue) == int.Parse(desiredEndDayMonthYear[0])) { if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin, endHourMin)) { return(false); } } } else if (int.Parse(startDayValue) < int.Parse(desiredStartDayMonthYear[0])) { if (int.Parse(startDayValue) < int.Parse(desiredEndDayMonthYear[0])) { } else if (int.Parse(lastDayValue) > int.Parse(desiredStartDayMonthYear[0])) { return(false); } else if (int.Parse(lastDayValue) == int.Parse(desiredStartDayMonthYear[0])) { if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin, endHourMin)) { return(false); } } } else if (int.Parse(lastDayValue) == int.Parse(desiredStartDayMonthYear[0])) { if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin, endHourMin)) { return(false); } } else { return(false); } } else if (lastMonthValue.Equals(desiredStartDayMonthYear[1])) { if (int.Parse(lastDayValue) < int.Parse(desiredStartDayMonthYear[0])) { } else if (int.Parse(lastDayValue) > int.Parse(desiredStartDayMonthYear[0])) { return(false); } else if (int.Parse(lastDayValue) == int.Parse(desiredStartDayMonthYear[0])) { if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin, endHourMin)) { return(false); } } } else if (startMonthValue.Equals(desiredEndDayMonthYear[1])) { if (int.Parse(desiredEndDayMonthYear[1]) < int.Parse(startMonthValue)) { } else if (int.Parse(desiredEndDayMonthYear[1]) > int.Parse(startMonthValue)) { return(false); } else if (int.Parse(lastDayValue) == int.Parse(desiredStartDayMonthYear[1])) { if (!CheckTimeConflict(desiredStartTime, desiredEndTime, startHourMin, endHourMin)) { return(false); } } } } } } } } } return(true); }
private void Submit_Click(object sender, EventArgs e) { if (CheckFields()) { var rooms = new List <Room>(); var roomsResult = DbQuery.GetAllRoomsByIds(_roomsIdList); if (roomsResult.Count > 0) { if (CheckRoomAvailbility(_roomsIdList)) { if (ParentForm != null) { var appForms = (MadeiraMuseum)ParentForm; var dashboardControl = appForms.DashboardControl; var exhibitorResult = DbQuery.GetExhibitorByPersonId(dashboardControl.Person.Id.ToString()); var exhibitor = (Exhibitor)FactoryCreator.Instance .CreateFactory(FactoryCreator.PersonFactory) .ImportData(PersonFactory.Exhibitor, exhibitorResult[0]); foreach (var room in roomsResult) { var newRoom = new Room(room); rooms.Add(newRoom); } var date = FromPicker.Value; var dayStart = date.Day; var monthStart = date.Month; var yearStart = date.Year; date = UntilPicker.Value; var dayEnd = date.Day; var monthEnd = date.Month; var yearEnd = date.Year; var schedule = new Schedule(dayStart.ToString(), monthStart.ToString(), yearStart.ToString(), dayEnd.ToString(), monthEnd.ToString(), yearEnd.ToString(), startBox.Text, endBox.Text); schedule.Save(); var employeesResult = DbQuery.GetAllEmployees(); var number = 0; var chosenId = 0; for (var i = 0; i < employeesResult.Count; i++) { var adapterEmployee = new DictionaryAdapter(employeesResult[i]); var processesResult = DbQuery.GetProcessesByEmployeeIdandActive(adapterEmployee.GetValue("id")); if (i == 0) { number = processesResult.Count; chosenId = int.Parse(adapterEmployee.GetValue("id")); } else { if (number > processesResult.Count) { number = processesResult.Count; chosenId = int.Parse(adapterEmployee.GetValue("id")); } } } var employeeResult = DbQuery.GetAllEmployeesByRoleId(chosenId.ToString()); var employee = (Employee)FactoryCreator.Instance .CreateFactory(FactoryCreator.PersonFactory) .ImportData(PersonFactory.Employee, employeeResult[0]); var process = new Process(exhibitor, employee, schedule, rooms, textBoxName.Text, textBoxDescription.Text, textBoxTitle.Text, "img"); process.Save(); } _roomsIdList.Clear(); if (ParentForm != null) { var appForms = (MadeiraMuseum)ParentForm; var processesExhibitorControl = appForms.ProcessesExhibitorControl; processesExhibitorControl.GetProcesses(); processesExhibitorControl.ResetProcesses(); processesExhibitorControl.ListProcesses(processesExhibitorControl.ActualPage); processesExhibitorControl.BringToFront(); } } else { var myTimer = new Timer { Interval = 1000 }; InvalidValue.Text = @"These schedule is not available in this rooms!"; InvalidValue.Visible = true; myTimer.Tick += HideFail; myTimer.Start(); } } else { var myTimer = new Timer { Interval = 1000 }; InvalidValue.Text = @"You add atleast one room!"; InvalidValue.Visible = true; myTimer.Tick += HideFail; myTimer.Start(); } } }
/// <summary> /// Gets an Id of the unit from character id. /// </summary> /// <param name="CharacterId"></param> /// <returns></returns> public bool GetUnit(int CharacterId, out RoomUnit RoomUnit) { using (DictionaryAdapter<int, RoomUnit> DA = new DictionaryAdapter<int, RoomUnit>(Units)) { RoomUnit = DA.TryPopValue(GetUnitId(CharacterId)); } return RoomUnit != null; }
public RoomModel GetModel(int Id) { using (DictionaryAdapter<int, RoomModel> DA = new DictionaryAdapter<int, RoomModel>(Models)) { return DA.TryPopValue(Id); } }
public int GetHeader(IIncomingPacketEvent _Event) { using (DictionaryAdapter<string, int> DA = new DictionaryAdapter<string, int>(IncomingEventsInfo)) { return DA.TryPopValue(_Event.GetType().Name); } }
public void GetUsers() { senderLabel.Text = Person.Name; var r = new Regex("(Employee -)"); var rName = new Regex("(" + Person.Name + ")"); var l = DbQuery.GetAllPeople(); foreach (var d in l) { var valueExists = false; var da = new DictionaryAdapter(d); var counter = 0; var cmbEnumerator = receivercomboBox1.Items.GetEnumerator(); while (counter < receivercomboBox1.Items.Count && receivercomboBox1.Items.Count > 0) { cmbEnumerator.MoveNext(); var cmbItem = (ComboboxItem)cmbEnumerator.Current; if (cmbItem != null && cmbItem.Value == int.Parse(da.GetValue("id"))) { valueExists = true; } Debug.WriteLine("Items count:" + receivercomboBox1.Items.Count + " counter: " + counter); counter++; } if (!valueExists) { var item = new ComboboxItem { Value = int.Parse(da.GetValue("id")) }; var queryex = DbQuery.GetExhibitorByPersonId(da.GetValue("id")); if (queryex.Count > 0) { item.Text = "Exhibitor - " + da.GetValue("name"); } else { item.Text = "Employee - " + da.GetValue("name"); } var m = r.Match(item.Text); var mName = rName.Match(item.Text); Debug.WriteLine(mName.Success); if (Role == "Exhibitor" && m.Success) { if (mName.Success) { // caso seja o seu nome, não mostra o seu nome nos destinatarios } else { Debug.WriteLine("Value added: " + receivercomboBox1.Items.Count); receivercomboBox1.Items.Add(item); } } else if (Role == "Employee") { if (mName.Success) { // caso seja o seu nome, não mostra o seu nome nos destinatarios } else { Debug.WriteLine("Value added"); receivercomboBox1.Items.Add(item); } } } //MessageBox.Show((receivercomboBox1.SelectedItem as ComboboxItem).Value.ToString()); } receivercomboBox1.SelectedIndex = 0; }
/// <summary> /// Returns the progress of an achievement /// </summary> /// <param name="AchievementId"></param> /// <returns></returns> public int GetAchievementProgress(int AchievementId) { using (DictionaryAdapter<int, int> DA = new DictionaryAdapter<int, int>(Achievements)) { return DA.TryPopValue(AchievementId); } }
public virtual Person GetOtherPerson(DictionaryAdapter dictionaryAdapter) { return(null); }