Inheritance: INotifyPropertyChanged
Esempio n. 1
0
        public WorkYear(int year, WorkDayParserSettings parserSettings, int hitListLookBackInWeeks, float hoursPerDay, PNSearchViewModel pnSearch, PositionSearchViewModel positionSearch)
        {
            this.hitListLookBackInWeeks = hitListLookBackInWeeks;
            this.pnSearch = pnSearch;
            this.positionSearch = positionSearch;
            this.Year = year;
            this.Months = new ObservableCollection<WorkMonth>();
            this.Weeks = new ObservableCollection<WorkWeek>();

            var germanSpecialDays = SpecialDaysUtils.GetGermanSpecialDays(year);

            var cal = new GregorianCalendar();
            for (int month = 1; month <= cal.GetMonthsInYear(year); month++)
            {
                WorkMonth wm = new WorkMonth(year, month, germanSpecialDays, parserSettings, hoursPerDay);
                this.Months.Add(wm);
                foreach (var workWeek in wm.Weeks)
                {
                    this.Weeks.Add(workWeek);
                    workWeek.PropertyChanged += this.workWeek_PropertyChanged;
                }
            }
            this.ProjectHitlist = new QuickFillObservableCollection<HitlistInfo>();
            this.PositionHitlist = new QuickFillObservableCollection<HitlistInfo>();
            this.UpdateProjectHitlistAsync();
            this.UpdatePositionHitlistAsync();
        }
Esempio n. 2
0
 private void Export(WorkMonth month, string filename)
 {
     List<string> data = new List<string>();
       this.AddHeader(data);
       var gotData = this.AddData(month, data);
       if (gotData) {
     File.WriteAllLines(filename, data, Encoding.GetEncoding("ISO-8859-1"));
       }
 }
Esempio n. 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="month"></param>
 /// <param name="data"></param>
 /// <returns>if there was any data</returns>
 private bool AddData(WorkMonth month, List<string> data)
 {
     bool gotData = false;
       foreach (var day in month.Days) {
     foreach (var item in day.Items) {
       var description = string.IsNullOrEmpty(item.Description) ? "-" : item.Description;
       data.Add(string.Format(CultureInfo.InvariantCulture, " {0:00}     {1}    {2}    {3:00.00}   {4}    {5}      {6}", day.Day, item.Start.ToMonlistString(), item.End.ToMonlistString(), item.HoursDuration, item.Project, item.Position, description));
       gotData = true;
     }
       }
       return gotData;
 }
Esempio n. 4
0
        public void HoursDuration_OnAMonth_ShouldSumCorrect()
        {
            WorkMonth wm = new WorkMonth(2011, 1, null, new WorkDayParserSettings(), 1);
            WorkDay wd = wm.Days.First();
            wd.AddWorkItem(new WorkItem(new TimeItem(10), new TimeItem(11)));
            Assert.AreEqual(1, wd.HoursDuration);
            wd.AddWorkItem(new WorkItem(new TimeItem(11), new TimeItem(12)));
            Assert.AreEqual(2, wd.HoursDuration);
            wd.AddWorkItem(new WorkItem(new TimeItem(12), new TimeItem(12, 15)));
            Assert.AreEqual(2.25, wd.HoursDuration);
            wd.AddWorkItem(new WorkItem(new TimeItem(12, 15), new TimeItem(13)));
            Assert.AreEqual(3, wd.HoursDuration);

            Assert.AreEqual(3, wm.HoursDuration);
        }
Esempio n. 5
0
        public void ShortCutStatistic_OnAMonth_ShouldSumCorrect()
        {
            var abbr = new List<ShortCut>();
            abbr.Add(new ShortCut("ctb", "11111-111"));
            WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { ShortCuts = abbr, InsertDayBreak = false };
            WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
            WorkDayParser.Instance = wdp;
            WorkMonth wm = new WorkMonth(2011, 1, null, workDayParserSettings, 1);
            WorkDay wd = wm.Days.First();
            wd.OriginalString = "8,8;ctb";

            wm.CalcShortCutStatistic();
            var scs = wm.ShortCutStatistic.FirstOrDefault(s => s.Key == "ctb");
            Assert.NotNull(scs);
            Assert.AreEqual(8, scs.UsedInMonth);
        }
Esempio n. 6
0
        public void HoursDuration_OnAWeek_ShouldSumCorrect()
        {
            WorkMonth wm = new WorkMonth(2011, 1, null, new List<ShortCut>(), 1);
              WorkDay wd = wm.Days.First();
              wd.AddWorkItem(new WorkItem(new TimeItem(10),new TimeItem(11)));
              Assert.AreEqual(1,wd.HoursDuration);
              wd.AddWorkItem(new WorkItem(new TimeItem(11),new TimeItem(12)));
              Assert.AreEqual(2,wd.HoursDuration);
              wd.AddWorkItem(new WorkItem(new TimeItem(12),new TimeItem(12,15)));
              Assert.AreEqual(2.25,wd.HoursDuration);
              wd.AddWorkItem(new WorkItem(new TimeItem(12,15),new TimeItem(13)));
              Assert.AreEqual(3,wd.HoursDuration);

              WorkWeek ww = wm.Weeks.First();
              Assert.AreEqual(3,ww.HoursDuration);
        }
Esempio n. 7
0
 private void Export(WorkMonth month, string filename)
 {
     var pack = new JSONPackage();
     pack.UserId = 123;
     var items = new List<JSONWorkItem>();
     foreach (var day in month.Days)
     {
         foreach (var item in day.Items)
         {
             items.Add(new JSONWorkItem(item));
         }
     }
     pack.Items = items;
     var serializeObject = JsonConvert.SerializeObject(pack, Formatting.Indented);
     File.WriteAllText(filename, serializeObject);
 }
Esempio n. 8
0
 public string Export(WorkMonth wmonth)
 {
     var month = new MonapiMonth();
     month.Nummer = this.monlistUserNUmber;
     month.Jahr = wmonth.Year;
     month.Monat = wmonth.Month;
     var items = new List<MonapiWorkItem>();
     foreach (var day in wmonth.Days)
     {
         foreach (var item in day.Items)
         {
             items.Add(new MonapiWorkItem(item));
         }
     }
     month.Stunden = items;
     var serializedObject = JsonConvert.SerializeObject(month, Formatting.Indented);
     return serializedObject;
 }
Esempio n. 9
0
        private async Task ExportAsync(WorkMonth month, string filename)
        {
            var data = new List <string>();

            this.AddHeader(data);
            var gotData = this.AddData(month, data);

            if (gotData)
            {
                using (var stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 4096, true))
                    using (var sw = new StreamWriter(stream, Encoding.GetEncoding("ISO-8859-1")))
                    {
                        foreach (var line in data)
                        {
                            await sw.WriteLineAsync(line).ConfigureAwait(false);
                        }
                    }
            }
        }
Esempio n. 10
0
        public string Export(WorkMonth wmonth)
        {
            var month = new MonapiMonth();

            month.Nummer = this.monlistUserNUmber;
            month.Jahr   = wmonth.Year;
            month.Monat  = wmonth.Month;
            var items = new List <MonapiWorkItem>();

            foreach (var day in wmonth.Days)
            {
                foreach (var item in day.Items)
                {
                    items.Add(new MonapiWorkItem(item));
                }
            }
            month.Stunden = items;
            var serializedObject = JsonConvert.SerializeObject(month, Formatting.Indented);

            return(serializedObject);
        }
Esempio n. 11
0
        public WorkYear(int year, IEnumerable<ShortCut> shortCuts, int hitListLookBackInWeeks, float hoursPerDay, PNSearchViewModel pnSearch, PositionSearchViewModel positionSearch)
        {
            this.hitListLookBackInWeeks = hitListLookBackInWeeks;
              this.pnSearch = pnSearch;
              this.positionSearch = positionSearch;
              this.Year = year;
              this.Months = new ObservableCollection<WorkMonth>();
              this.Weeks = new ObservableCollection<WorkWeek>();

              var germanSpecialDays = SpecialDaysUtils.GetGermanSpecialDays(year);

              var cal = new GregorianCalendar();
              for (int month = 1; month <= cal.GetMonthsInYear(year); month++) {
            WorkMonth wm = new WorkMonth(year, month, germanSpecialDays, shortCuts, hoursPerDay);
            this.Months.Add(wm);
            foreach (var workWeek in wm.Weeks) {
              this.Weeks.Add(workWeek);
              workWeek.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.workWeek_PropertyChanged);
            }
              }
        }
Esempio n. 12
0
 public WorkWeek(WorkMonth month, int weekOfYear)
 {
     this.Month = month;
       this.weekOfYear = weekOfYear;
       this.days = new ObservableCollection<WorkDay>();
 }
Esempio n. 13
0
 public string FilenameForMonth(WorkMonth month)
 {
     var filename = string.Format("monlist_{0}_{1}.txt", month.Year, month.Month.ToString("00"));
       return Path.Combine(this.dataDirectory, filename);
 }
Esempio n. 14
0
 public WorkWeek(WorkMonth month, int weekOfYear)
 {
     this.Month      = month;
     this.weekOfYear = weekOfYear;
     this.days       = new ObservableCollection <WorkDay>();
 }