Esempio n. 1
0
        public void AddRecurringTransaction(IRecurringTransaction transaction)
        {
            /* TODO:
             * When should we enumerate elements? When do we add them to the calendar?
             *
             * It's not enough to add them when we add the transaction in. It's a kludge, and it shows that we can at least get it to work, but it isn't great.
             *
             * TODO: #2
             * How does a recurring transaction handle a Transfer? It might have to be:
             *  1. Identify a transfer as a composite object made of 2 accounts and 1 Amount. The value is inverted between the accounts
             *  2. Transactions will need to be rethought completely...
             */
            RecurringTransactionsList.Add(transaction);

            if (DayCollection.Any())
            {
                transaction.EnumerateElementsUntilDate(DayCollection.Last().Date);
            }

            foreach (var el in transaction.Elements)
            {
                var day = GetDayForDate(el.Date);
                day.AddTransaction(el);
            }
        }
Esempio n. 2
0
    static void Main(string[] args)
    {
        DayCollection week = new DayCollection();

        System.Console.WriteLine(week["일"]);
        System.Console.WriteLine(week["Made-up Day"]);
    }
Esempio n. 3
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <DayInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <DayInfo> list = new List <DayInfo>();

            Query q = Day.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            DayCollection collection = new  DayCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Day day  in collection)
            {
                DayInfo dayInfo = new DayInfo();
                LoadFromDAL(dayInfo, day);
                list.Add(dayInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Esempio n. 4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <DayInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(DayInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <DayInfo>);
            }
            else
            {
                List <DayInfo> list       = new List <DayInfo>();
                DayCollection  collection = new  DayCollection();
                Query          qry        = new Query(Day.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (Day day in collection)
                {
                    DayInfo dayInfo = new DayInfo();
                    LoadFromDAL(dayInfo, day);
                    list.Add(dayInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(DayInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
Esempio n. 5
0
        private IEnumerable<Streak> GetStreaksFromOrderedDayGroupingList(DayCollection days)
        {
            var list = days.OrderBy(collection => collection.First().ChatDate).ToList();

            var currentStreak = new List<ChatCollection>();
            currentStreak.Add(list[0]);

            for (int i = 1; i < list.Count; i++)
            {
                var prevDay = currentStreak[currentStreak.Count - 1].First().ChatDate;
                var nextDay = prevDay.AddDays(1);

                var checkDay = list[i].First().ChatDate;

                if (nextDay.DayOfYear == checkDay.DayOfYear &&
                    nextDay.Year == checkDay.Year)
                    currentStreak.Add(list[i]);
                else
                {
                    yield return GetStreakFromChatCollectionList(currentStreak);

                    currentStreak.Clear();
                    currentStreak.Add(list[i]);
                }
            }

            if (currentStreak.Count > 0)
                yield return GetStreakFromChatCollectionList(currentStreak);
        }
Esempio n. 6
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <DayInfo> pList, DayCollection pCollection)
 {
     foreach (Day day in pCollection)
     {
         DayInfo dayInfo = new DayInfo();
         LoadFromDAL(dayInfo, day);
         pList.Add(dayInfo);
     }
 }
Esempio n. 7
0
        static void Main(string[] args)
        {
            var week = new DayCollection();

            Console.WriteLine(week["Fri"]);
            try {
                Console.WriteLine(week["Made-up day"]);
            } catch (ArgumentOutOfRangeException e) {
                Console.WriteLine($"Not supported input:{e.Message}");
            }
        }
    static void Main(string[] args)
    {
        DayCollection week = new DayCollection();
        System.Console.WriteLine(week["Fri"]);

        // Raises ArgumentOutOfRangeException
        System.Console.WriteLine(week["Made-up Day"]);

        // Keep the console window open in debug mode.
        System.Console.WriteLine("Press any key to exit.");
        System.Console.ReadKey();
    }
Esempio n. 9
0
    static void Main(string[] args)
    {
        DayCollection week = new DayCollection();

        System.Console.WriteLine(week["Fri"]);

        // Raises ArgumentOutOfRangeException
        System.Console.WriteLine(week["Made-up Day"]);

        // Keep the console window open in debug mode.
        System.Console.WriteLine("Press any key to exit.");
        System.Console.ReadKey();
    }
Esempio n. 10
0
    static void Main()
    {
        var week = new DayCollection();

        System.Console.WriteLine(week["Fri"]);

        try
        {
            System.Console.WriteLine(week["Made-up day"]);
        }
        catch (System.ArgumentOutOfRangeException e)
        {
            System.Console.WriteLine($"Not supported input: {e.Message}");
        }
    }
Esempio n. 11
0
        public void GetItemsTest()
        {
            var dc = new DayCollection<int>();

            var dt1 = new DateTime(2000, 1, 1);
            var dt2 = new DateTime(2005, 2, 1);
            var dt3 = new DateTime(2010, 3, 1);

            dc.Add(dt2, 200);
            dc.Add(dt3, 300);
            dc.Add(dt1, 100);

            //Verify order
            int i = dc[0][0];
            Assert.AreEqual(100, i);
            Assert.AreEqual(200, dc[1][0]);
            Assert.AreEqual(300, dc[2][0]);
        }
Esempio n. 12
0
        public void GetItemsTest()
        {
            var dc = new DayCollection <int>();

            var dt1 = new DateTime(2000, 1, 1);
            var dt2 = new DateTime(2005, 2, 1);
            var dt3 = new DateTime(2010, 3, 1);

            dc.Add(dt2, 200);
            dc.Add(dt3, 300);
            dc.Add(dt1, 100);

            //Verify order
            int i = dc[0][0];

            Assert.AreEqual(100, i);
            Assert.AreEqual(200, dc[1][0]);
            Assert.AreEqual(300, dc[2][0]);
        }
Esempio n. 13
0
        private void InsertDay(int index, ref FinancialDay day)
        {
            if (index > 0)
            {
                var previous = DayCollection[index - 1];

                previous.NextDay = day;
                day.PreviousDay  = previous;
            }

            if (index < DayCollection.Count)
            {
                var next = DayCollection[index];

                next.PreviousDay = day;
                day.NextDay      = next;
            }

            DayCollection.Insert(index, day);
            OnDayCollectionChanged();
        }
Esempio n. 14
0
        public static ResponseItem <List <DayCollection> > Get()
        {
            var res = new ResponseItem <List <DayCollection> >();

            res.data = new List <DayCollection>();

            var id_clients            = ClientsPayments.GetClientsWithOutPayments();
            var clients_payment_today = GetClientsTochargeToday(id_clients.data.Keys.ToList());

            foreach (var item in clients_payment_today.data)
            {
                var payment_days = 1;
                if (item.payment_type == 2)
                {
                    payment_days = 7;
                }
                else if (item.payment_type == 3)
                {
                    payment_days = 14;
                }
                else if (item.payment_type == 4)
                {
                    payment_days = 30;
                }

                var day_collection = new DayCollection();
                day_collection.id_client          = item.id_client;
                day_collection.name_client        = item.name;
                day_collection.phone_client       = item.phone;
                day_collection.payments           = id_clients.data.Where(x => x.Key == item.id_client).FirstOrDefault().Value.ToString();
                day_collection.payments_scheduled = Math.Round((decimal)item.time_limit / (decimal)payment_days).ToString();
                var interest_rate = item.loan * (item.interest_rate / 100);
                day_collection.payments_value = (item.loan / (item.time_limit / payment_days)).ToString();

                res.data.Add(day_collection);
            }

            res.data.RemoveAll(x => x.payments == x.payments_scheduled);
            return(res);
        }
Esempio n. 15
0
        private IEnumerable<Streak> GetStreaksFromContactGrouping(IEnumerable<Chat> contactGrouping)
        {
            var byDay = new DayCollection(contactGrouping);

            return GetStreaksFromOrderedDayGroupingList(byDay);
        }
Esempio n. 16
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<DayInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< DayInfo> list = new List< DayInfo>();

            Query q = Day .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            DayCollection  collection=new  DayCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Day  day  in collection)
            {
                DayInfo dayInfo = new DayInfo();
                LoadFromDAL(dayInfo,   day);
                list.Add(dayInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Esempio n. 17
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< DayInfo> pList, DayCollection pCollection)
 {
     foreach (Day day in pCollection)
     {
         DayInfo dayInfo = new DayInfo();
         LoadFromDAL(dayInfo, day );
         pList.Add(dayInfo);
     }
 }
Esempio n. 18
0
		/// <summary>
		/// Resets the timeline to Now, loads PPItems in range and loads Stations
		/// <para>This method is using _initialTimer so its body will be run with a 10ms delay</para>
		/// </summary>
		public void ResetTimeLine()
		{
			//exit if loaded once
			if (_initialTimer != null) return;

			_initialTimer = new System.Threading.Timer(new System.Threading.TimerCallback
				(t => Dispatcher.Invoke(() =>
				{
					_suppressUpdateRange = true;
					//initialize DateTimes
					var currentDate = Arash.PersianDate.Today.ToDateTime();
					var startDate = currentDate.GetNorooz();

					//initialize Timeline components
					Days = new DayCollection();
					Months = new MonthCollection(startDate);
					Months.SelectedMonthChanged += month => SelectedMonth = month;
					Hours = new HourCollection();

					//initialize PPItems
					PPItems = new PPItemCollection(this);
					PPItems.Manager.DayColorsUpdated += (startingDate, colors) =>
					{
						//refetch it, if selected month is changed after fetch
						if (SelectedMonth.Data != startingDate)
						{
							PPItems.Manager.InitMonth(SelectedMonth.Data);
							return;
						}
						//colorize days
						for (int i = 0; i < colors.Length; i++)
						{
							Days[i].Color = colors[i];
						}
					};
					PPItems.Manager.WorkTimeAdded += item =>
					{
						var vms = Soheil.Core.ViewModels.OrganizationCalendar.WorkTimeRangeVm.CreateAuto(item);
						foreach (var vm in vms)
						{
							ShiftsAndBreaks.Add(vm);
						}
					};
					PPItems.Manager.WorkTimesRemoved += () =>
					{
						ShiftsAndBreaks.Clear();
					};
					PPItems.BlockAdded += vm =>
					{
						initializeCommands(vm);
					};
					PPItems.BlockRemoved += id =>
					{
						if (SelectedBlock != null && SelectedBlock.Id == id)
							SelectedBlock = null;
					};
					PPItems.NptAdded += vm =>
					{
						initializeCommands(vm);
					};
					PPItems.NptRemoved += id =>
					{
						if (SelectedNPT != null && SelectedNPT.Id == id)
							SelectedNPT = null;
					};


					//Initialize stations
					var stationModels = new DataServices.StationDataService().FixAndGetActives();
					NumberOfStations = stationModels.Count();
					foreach (var stationModel in stationModels)
					{
						PPItems.Add(new StationVm { Text = stationModel.Name });
					}

					//Set advanced timeline components
					SelectedMonth = Months[(int)currentDate.GetPersianMonth() - 1];
					HoursPassed = currentDate.Subtract(SelectedMonth.Data).TotalHours;
					if (currentDate.Year % 4 == 3)
					{
						HoursInYear = 8784;
						DaysInYear = 366;
					}
					else
					{
						HoursInYear = 8760;
						DaysInYear = 365;
					}

					//Loads PPItems
					_suppressUpdateRange = false;
					GoToNowCommand.Execute(null);
				})), null, _initialTimerInterval, System.Threading.Timeout.Infinite);
		}
Esempio n. 19
0
        public void updateHandler(Object sender, NotifyCollectionChangedEventArgs eArgs)
        {
            DayCollection collection = (DayCollection)GetValue(DaysProperty);

            contentGrid.Children.Clear();

            contentGrid.RowDefinitions.Clear();

            RowDefinition row = new RowDefinition();

            row.Height = GridLength.Auto;
            contentGrid.RowDefinitions.Add(row);

            contentGrid.Children.Add(monthLabel);

            row        = new RowDefinition();
            row.Height = GridLength.Auto;
            contentGrid.RowDefinitions.Add(row);

            for (int i = 0; i < DayLabels.Count(); ++i)
            {
                dayLabels[i].Content = DayLabels[i];
                contentGrid.Children.Add(dayLabels[i]);
            }

            if (collection.Count == 0)
            {
                return;
            }

            for (int i = 0; i < numRows; ++i)
            {
                row        = new RowDefinition();
                row.Height = new GridLength(1, GridUnitType.Star);
                contentGrid.RowDefinitions.Add(row);
            }


            for (int i = 0; i < collection.Count; ++i)
            {
                Day d = collection.ElementAt(i);

                Button dayLabel = new Button();
                dayLabel.Tag     = d.Id;
                dayLabel.Content = d.Label;
                dayLabel.Click  += OnEventClick;
                if (d.IsToday)
                {
                    dayLabel.BorderThickness = new Thickness(6);
                    dayLabel.BorderBrush     = new SolidColorBrush(Colors.Red);
                }
                if (!d.IsThisMonth)
                {
                    dayLabel.Foreground = new SolidColorBrush(Colors.DarkGray);
                }
                if (d.HasEvents)
                {
                    dayLabel.Style = (Style)Resources["HighlightedMonthDayLabel"];
                }
                else
                {
                    dayLabel.Style = (Style)Resources["MonthDayLabel"];
                }
                Grid.SetRow(dayLabel, d.Row + 2);
                Grid.SetColumn(dayLabel, d.Col);

                contentGrid.Children.Add(dayLabel);
            }
        }
Esempio n. 20
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<DayInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(DayInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< DayInfo>;
     }
     else
     {
         List< DayInfo>  list =new List< DayInfo>();
         DayCollection  collection=new  DayCollection();
         Query qry = new Query(Day.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Day day in collection)
         {
             DayInfo dayInfo= new DayInfo();
             LoadFromDAL(dayInfo,day);
             list.Add(dayInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(DayInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }