Exemple #1
0
        private void UpdateContent(object sender, PropertyChangedEventArgs e)
        {
            var value = sender as CtFile;

            if (value == null)
            {
                return;
            }
            if (e.PropertyName == nameof(value.UserName) && !string.IsNullOrEmpty(CtFileSettings.UserName))
            {
                CtFileSettings.NameFile =
                    $"{value.Date.ToString("yMMdd").Substring(1)}ct_.{value.UserName.ToLower()}";
            }
            Content = CtFileSettings.FormatString(Content, CtFileSettings.GetValues <CtFile>());
        }
Exemple #2
0
 private void UpdateWorkingDay(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (CtFileSettings.CtWorking.Any())
     {
         var pattern = Template.ListPatterns[nameof(CtFileSettings.CtWorking).ToLower()];
         var line    = pattern.Line;
         var list    = CtFileSettings.FormatString(new List <string>(Template.Content).ToArray(), CtFileSettings.GetValues <CtFile>()).ToList();
         foreach (var working in CtFileSettings.CtWorking)
         {
             var str = "";
             for (var i = 0; i < pattern.Index; i++)
             {
                 str += " ";
             }
             str += CtFileSettings.FormatString(pattern.Pattern, working.GetValues <LineCtWorkingDay>()).TrimEnd();
             working.PropertyChanged += (o, args) =>
             {
                 var val = o as LineCtWorkingDay;
                 if (!string.IsNullOrEmpty(val?.EndTime) && !string.IsNullOrEmpty(val.StartTime))
                 {
                     UpdateWorkingDay(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                 }
             };
             list.Insert(line, str);
             Content = list.ToArray();
             line++;
         }
     }
 }
Exemple #3
0
        private void GenerateCt(object o)
        {
            VisibilityContent = Visibility.Visible;
            var list    = CtFileSettings.FormatString(new List <string>(Template.Content).ToArray(), CtFileSettings.GetValues <CtFile>()).ToList();
            var pat     = Template.ListPatterns[nameof(CtFileSettings.CtWorking).ToLower()];
            var pattern = Template.ListPatterns[nameof(CtFileSettings.CtWorking).ToLower()];
            int line    = pattern.Line;

            for (var i = 1; i <= DateTime.DaysInMonth(2017, 10); i++)
            {
                var date = new DateTime(2017, 10, i);
                var dic  = new Dictionary <string, object> {
                    { nameof(date), date }
                };
                dic = dic.Concat(GenerateCtWorking.GetValues <LineCtWorkingDay>().Where(k => !
                                                                                        string.Equals(k.Key, "date", StringComparison.InvariantCultureIgnoreCase)
                                                                                        )).ToDictionary(t => t.Key, t => t.Value);
                if (date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday)
                {
                    //dates.Add(date.ToString("dd'.'MM") + " xxx");
                    list.Insert(line, date.ToString("dd'.'MM") + " xxx");
                    CtFileSettings.CtWorking.Add(new LineCtWorkingDay()
                    {
                        StartTime = "xxx", Day = date
                    });
                }
                else
                {
                    //dates.Add(date.DayOfWeek == DayOfWeek.Monday ? "" :
                    //    CtFileSettings.FormatString(pat.Pattern, dic).TrimEnd());
                    list.Insert(line, date.DayOfWeek == DayOfWeek.Monday ? "" :
                                CtFileSettings.FormatString(pat.Pattern, dic).TrimEnd());
                    CtFileSettings.CtWorking.Add(new LineCtWorkingDay()
                    {
                        Day         = date,
                        StartTime   = dic[nameof(GenerateCtWorking.StartTime).ToLower()].ToString(),
                        EndTime     = dic[nameof(GenerateCtWorking.EndTime).ToLower()].ToString(),
                        StartDinner = dic[nameof(GenerateCtWorking.StartDinner).ToLower()].ToString(),
                        EndDinner   = dic[nameof(GenerateCtWorking.EndDinner).ToLower()].ToString()
                    });
                }
                Content = list.ToArray();
                line++;
            }
        }