private void ExecuteImport(object o) { if (!this.CurrentFilePath.Length.Equals(0) && MessageBox.Show("변경한 내용은 저장되지 않습니다. 그래도 진행하시겠습니까?", "경고", MessageBoxButton.YesNo, MessageBoxImage.Warning).Equals(MessageBoxResult.No)) { return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "dat Files (*.dat)|*.dat|All Files (*.*)|*.*"; if (openFileDialog.ShowDialog().Equals(true)) { this.CurrentFilePath = openFileDialog.FileName; var data = XmlManager.Deserialize(this.CurrentFilePath, typeof(List <AttendanceRecord>)); if (data == null) { MessageBox.Show("출결정보 파일이 아닙니다.", "에러", MessageBoxButton.OK, MessageBoxImage.Error); return; } this.attendanceRecords = ((List <AttendanceRecord>)data).ConvertAll(x => (ICalendarData)x); MyCalendar calendar = o as MyCalendar; calendar.BuildCalendarOutCaller(this.attendanceRecords); ConfigManager.WriteProfileString(EConfigSection.Attendance.ToString(), EConfigKey.FilePath.ToString(), this.CurrentFilePath); } }
public void TestMyCalendar() { var calendar = new MyCalendar(); //calendar.Book(10, 20); // returns true //calendar.Book(15, 25); // returns false //calendar.Book(20, 30); // returns true }
//#endregion public void Initial() { MyCalendar m_c = new MyCalendar(); DateEntity tmp = new DateEntity(); tmp._date = this._date; m_c.SetDateEntity(ref tmp); this._BeginMonth = tmp._BeginMonth; this._BeginZodiac = tmp._BeginZodiac; this.nonglimonth = tmp.nonglimonth; this.nongliday = tmp.nongliday; this.nonglihour = tmp.nonglihour; this.nongliyearflag = tmp.nongliyearflag; this.NongliMonthDays = tmp.NongliMonthDays; if (nongliyearflag) { BaZi.BaZiBiz m_bz = PPLive.BaZi.BaZiBiz.GetInstance(); this.nongliTG = m_bz.YearTG(_date.Year - 1); this.nongliDZ = m_bz.YearDZ(_date.Year - 1); } else { BaZi.BaZiBiz m_bz = PPLive.BaZi.BaZiBiz.GetInstance(); this.nongliTG = m_bz.YearTG(_date.Year); this.nongliDZ = m_bz.YearDZ(_date.Year); } }
public int Solution(int Y, string A, string B, string W) { // write your code in C# 6.0 with .NET 4.5 (Mono) string[] Months = { "January", "February", "March", "April", "May", "June", "July", "August","September","October", "November", "December" }; string[] Days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; MyCalendar dt = new MyCalendar(Months.ToList().IndexOf(W), Y); int startMonthIndex = Months.ToList().IndexOf(A); int endMonthIndex = Months.ToList().IndexOf(B); while ((dt.getMonthIndex() != startMonthIndex) || (!string.Equals(Days[dt.getDayOfMonthIndex()], "Monday", StringComparison.OrdinalIgnoreCase))) { dt.advance(); } int daysSpent = 0; while (dt.getMonthIndex() <= endMonthIndex) { daysSpent++; dt.advance(); } return(daysSpent / 7); }
public static void SaveToken(string token) { _Token = token; var database = new NoteDatabase(); database.InsertOrUpdateToken(new Tconnect.Data.Token("Yammer", token)); database.InsertOrUpdateToken(new Tconnect.Data.Token("Calendar", "1")); MyCalendar.ImportCalendar(); MyCalendar.ImportContacts(); MyCalendar cal = new MyCalendar(); Debug.WriteLine("ruight herjelkfjsd tohooooooooooooo"); String[] s = cal.getUserDeets(token); database.InsertOrUpdateToken(new Tconnect.Data.Token("fname", s[0])); database.InsertOrUpdateToken(new Tconnect.Data.Token("lname", s[1])); database.InsertOrUpdateToken(new Tconnect.Data.Token("email", s[2])); database.InsertOrUpdateToken(new Tconnect.Data.Token("phone", s[3])); database.InsertOrUpdateToken(new Tconnect.Data.Token("org", s[4])); database.InsertOrUpdateToken(new Tconnect.Data.Token("uid", s[5])); database.InsertOrUpdateToken(new Tconnect.Data.Token("profilepicture", s[6])); // { fname, lname, email, phone, org, uid, profilepicture }; Debug.WriteLine("oi we got here m8"); //Person p = new Person (s [0], s [1], s [2], s [3], s [4], s [5], s [6]); //p.NoteId = 0; //database.InsertOrUpdatePerson (p); //Debug.WriteLine ("afftaahh:: " + database.GetPerson(0).Name); }
public static void Main() { MyCalendar solution = new MyCalendar(); Test.Check(solution.Book, 10, 20, true); Test.Check(solution.Book, 15, 25, false); Test.Check(solution.Book, 20, 30, true); }
public void Test1() { var calendar = new MyCalendar(); Assert.IsTrue(calendar.Book(10, 20)); Assert.IsFalse(calendar.Book(15, 25)); Assert.IsTrue(calendar.Book(20, 30)); }
public ActionResult RemoveEventById(int id) { var currentUserId = this.User.Identity.GetUserId(); MyCalendar calender = this.db.MyCalendars.FirstOrDefault(x => x.UserId == currentUserId && x.EventId == id); this.db.MyCalendars.Remove(calender); this.db.SaveChanges(); return(this.RedirectToAction("My", "Events", "Events/My")); }
public void MyCalenderOneTest() { var cal = new MyCalendar(); Assert.AreEqual(cal.Book(37, 50), true); Assert.AreEqual(cal.Book(33, 50), false); Assert.AreEqual(cal.Book(4, 17), true); Assert.AreEqual(cal.Book(35, 48), false); Assert.AreEqual(cal.Book(8, 25), false); }
public void Test3() { var calendar = new MyCalendar(); Assert.IsTrue(calendar.Book(37, 50)); Assert.IsFalse(calendar.Book(33, 50)); Assert.IsTrue(calendar.Book(4, 17)); Assert.IsFalse(calendar.Book(35, 48)); Assert.IsFalse(calendar.Book(8, 25)); }
static void Main(string[] args) { MyCalendar m = new MyCalendar(); m.Book(10, 20); // returns true m.Book(50, 60); // returns true m.Book(10, 40); // returns true m.Book(5, 15); // returns false m.Book(5, 10); // returns true m.Book(25, 55); // returns true }
public void Test2() { var calendar = new MyCalendar(); Assert.IsTrue(calendar.Book(47, 50)); Assert.IsTrue(calendar.Book(33, 41)); Assert.IsFalse(calendar.Book(39, 45)); Assert.IsFalse(calendar.Book(33, 42)); Assert.IsTrue(calendar.Book(25, 32)); Assert.IsFalse(calendar.Book(26, 35)); Assert.IsTrue(calendar.Book(19, 25)); Assert.IsTrue(calendar.Book(3, 8)); Assert.IsTrue(calendar.Book(8, 13)); Assert.IsFalse(calendar.Book(18, 27)); }
private void ExecuteAllClear(object o) { if (MessageBox.Show("모든 내용을 지우시겠습니까?", "경고", MessageBoxButton.YesNo, MessageBoxImage.Warning).Equals(MessageBoxResult.Yes)) { this.attendanceRecords.Clear(); MyCalendar calendar = o as MyCalendar; calendar.BuildCalendarOutCaller(this.attendanceRecords); this.ExecuteClearCondition(null); this.ExecuteClearResultCondition(null); this.CurrentFilePath = string.Empty; ConfigManager.WriteProfileString(EConfigSection.Attendance.ToString(), EConfigKey.FilePath.ToString(), this.CurrentFilePath); } }
private async void MarkDates() { //get todo list var todoList = await App.Database.GetTodoListAsync(); foreach (var item in todoList) { MyCalendar.SpecialDates.Add(new SpecialDate(item.Date) { BackgroundColor = Color.Purple, TextColor = Color.White, Selectable = true }); } MyScheduleLabel.Text = "My Schedule (" + todoList.Count + ")"; MyCalendar.RaiseSpecialDatesChanged(); }
private void ExecuteInit(object o) { if (this.CurrentFilePath.Length.Equals(0)) { MessageBox.Show("작업중인 파일이 없습니다.", "실패", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (MessageBox.Show("변경한 내용은 저장되지 않습니다. 그래도 진행하시겠습니까?", "경고", MessageBoxButton.YesNo, MessageBoxImage.Warning).Equals(MessageBoxResult.Yes)) { this.attendanceRecords = ((List <AttendanceRecord>)XmlManager.Deserialize(this.CurrentFilePath, typeof(List <AttendanceRecord>))) .ConvertAll(x => (ICalendarData)x); MyCalendar calendar = o as MyCalendar; calendar.BuildCalendarOutCaller(this.attendanceRecords); } }
public void Test5() { //[[0,6],[27,36],[6,11],[20,25],[32,37],[14,20],[7,16],[13,22],[39,47],[37,46],[42,50],[9,17],[49,50],[31,37],[43,49],[2,10],[3,12],[8,14],[14,21],[42,47],[43,49],[36,43]] //[true,false,false,false,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false] var calendar = new MyCalendar(); Assert.IsTrue(calendar.Book(23, 32)); Assert.IsTrue(calendar.Book(42, 50)); Assert.IsTrue(calendar.Book(6, 14)); Assert.IsFalse(calendar.Book(0, 7)); Assert.IsFalse(calendar.Book(21, 30)); Assert.IsFalse(calendar.Book(26, 31)); Assert.IsFalse(calendar.Book(46, 50)); Assert.IsFalse(calendar.Book(46, 50)); Assert.IsFalse(calendar.Book(28, 36)); Assert.IsTrue(calendar.Book(0, 6)); }
public void Test4() { var calendar = new MyCalendar(); Assert.IsTrue(calendar.Book(69, 70)); Assert.IsTrue(calendar.Book(3, 4)); Assert.IsTrue(calendar.Book(39, 40)); Assert.IsTrue(calendar.Book(35, 36)); Assert.IsFalse(calendar.Book(3, 4)); Assert.IsTrue(calendar.Book(55, 56)); Assert.IsTrue(calendar.Book(61, 62)); Assert.IsTrue(calendar.Book(97, 98)); Assert.IsTrue(calendar.Book(79, 80)); Assert.IsTrue(calendar.Book(76, 77)); Assert.IsTrue(calendar.Book(46, 47)); Assert.IsTrue(calendar.Book(78, 79)); }
public AttendanceMainVM(MyCalendar myCalendar) { CalendarDayClickedCommand = new RelayCommand(OnCalendarDayClicked); CalendarDayModifyCommand = new RelayCommand(OnCalendarDayModify); CalendarDayDeleteCommand = new RelayCommand(OnCalendarDayDelete); SaveCommand = new RelayCommand(ExecuteSave); ImportCommand = new RelayCommand(ExecuteImport); ExportCommand = new RelayCommand(ExecuteExport); InitCommand = new RelayCommand(ExecuteInit); AllClearCommand = new RelayCommand(ExecuteAllClear); ClearConditionCommand = new RelayCommand(ExecuteClearCondition); AddConditionCommand = new RelayCommand(ExecuteAddCondition); ClearResultConditionCommand = new RelayCommand(ExecuteClearResultCondition); string tmpStudentsPath = string.Empty; tmpStudentsPath = ConfigManager.ReadProfileString(EConfigSection.Students.ToString(), EConfigKey.FilePath.ToString(), tmpStudentsPath); if (tmpStudentsPath != null && !tmpStudentsPath.Equals(string.Empty)) { this.Students.Add(new Student(string.Empty)); foreach (var item in XmlManager.Deserialize(tmpStudentsPath, this.Students.GetType()) as List <Student> ) { this.Students.Add(item); } } else { MessageBox.Show("학생 정보가 없습니다. 설정을 먼저 해주세요."); this.IsVisibility = Visibility.Collapsed; this.Dispose(); var a = ViewManager.GetValue(typeof(AttendanceMainV), false); IsGoodInit = false; return; } this.CurrentFilePath = ConfigManager.ReadProfileString(EConfigSection.Attendance.ToString(), EConfigKey.FilePath.ToString(), this.CurrentFilePath); if (!this.CurrentFilePath.Equals(string.Empty)) { this.attendanceRecords = ((List <AttendanceRecord>)XmlManager.Deserialize(this.CurrentFilePath, typeof(List <AttendanceRecord>))). ConvertAll(x => (ICalendarData)x); myCalendar.BuildCalendarOutCaller(this.attendanceRecords); } IsGoodInit = true; }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public TempMenuViewModel(IMyNavigationService navigationService) { this.navigationService = navigationService; LogoutCommand = new Command(() => { database.LoseToken("Yammer"); navigationService.NavigateTo(ViewModelLocator.FeedPageKey); }); ContactsCommand = new Command(() => { database.truncadePerson(); MyCalendar.ImportContacts(); }); CalendarCommand = new Command(() => { database.truncade(); MyCalendar.ImportCalendar(); }); PurgeCommand = new Command(() => { database.truncade(); database.truncadePerson(); }); }
private void dochecks() { //Login if (!IsLoggedIn) { var database = new NoteDatabase(); if (database.HasToken("Yammer")) { var t = database.GetToken("Yammer"); if (t != null) { _Token = t.Value; } Debug.WriteLine(_Token); } } if (IsLoggedIn) { MyCalendar.ImportCalendar(); } }
public void UpdateCalendar() { if (CalendarPeriod.StartDate == null || CalendarPeriod.EndDate == null) return; DateTime startDate = CalendarPeriod.StartDate.Value; DateTime endDate = CalendarPeriod.EndDate.Value; if (endDate < startDate) MessageBox.Show("An End date must be greater or equal to a Start date.", "Organizer", MessageBoxButton.OK, MessageBoxImage.Information); EventType eventType = cbEventTypes.SelectedItem as EventType; MyCalendar calendar; if (eventType == null) calendar = new MyCalendar(startDate, endDate.Date.AddDays(1)); else calendar = new MyCalendar(startDate, endDate.Date.AddDays(1), eventType.TypeId); calendarPanel.Children.Clear(); DateTime previousDate = DateTime.Now; int counter = 0; Style eventTitleStyle = Application.Current.Resources["eventTitle"] as Style; Style eventDetailsStyle = Application.Current.Resources["eventDetails"] as Style; Style dateStyle = Application.Current.Resources["postDate"] as Style; Style timeStyle = Application.Current.Resources["postTime"] as Style; foreach (CalendarEvent calEvent in calendar) { DockPanel itemPanel = new DockPanel(); itemPanel.Tag = calEvent.EventId.ToString(); itemPanel.MouseEnter += ItemStackPanel_MouseEnter; itemPanel.MouseLeave += ItemStackPanel_MouseLeave; itemPanel.MouseLeftButtonDown += ItemPanel_MouseLeftButtonDown; itemPanel.ContextMenu = CalendarContextMenu(); TextBlock eventDate = new TextBlock(); eventDate.Style = dateStyle; if (previousDate != calEvent.EventStart.Date) { eventDate.Text = calEvent.EventStart.ToString("dd MMMM yyyy, "); eventDate.Text += calEvent.EventStart.ToString("ddd").ToLower(); previousDate = calEvent.EventStart.Date; calendarPanel.Children.Add(eventDate); } TextBlock eventTime = new TextBlock(); eventTime.Style = timeStyle; eventTime.Text = calEvent.EventStart.ToString("HH:mm"); itemPanel.Children.Add(eventTime); StackPanel eventDetails = new StackPanel(); TextBlock eventTitle = new TextBlock(); eventTitle.Text = calEvent.EventTitle; eventTitle.Style = eventTitleStyle; eventDetails.Children.Add(eventTitle); TextBlock eventEnd = new TextBlock(); eventEnd.Text = "Ending: " + calEvent.EventEnd.ToString("HH:mm ddd dd MMMM yyyy"); eventEnd.Style = eventDetailsStyle; eventDetails.Children.Add(eventEnd); TextBlock eventVenue = new TextBlock(); if (!string.IsNullOrWhiteSpace(calEvent.EventVenue)) { eventVenue.Text = "Location: "; } eventVenue.Text += calEvent.EventVenue; eventVenue.Style = eventDetailsStyle; eventVenue.Visibility = Visibility.Collapsed; eventDetails.Children.Add(eventVenue); TextBlock eventDescription = new TextBlock(); eventDescription.Text = calEvent.EventDescription; eventDescription.Style = eventDetailsStyle; eventDescription.Visibility = Visibility.Collapsed; eventDetails.Children.Add(eventDescription); itemPanel.Children.Add(eventDetails); calendarPanel.Children.Add(itemPanel); counter++; } }