当前位置: 首页>>代码示例>>C#>>正文


C# List.ConvertAll方法代码示例

本文整理汇总了C#中Common.List.ConvertAll方法的典型用法代码示例。如果您正苦于以下问题:C# List.ConvertAll方法的具体用法?C# List.ConvertAll怎么用?C# List.ConvertAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Common.List的用法示例。


在下文中一共展示了List.ConvertAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCountOfLogItemForDates

		public Dictionary<DateTime, int> GetCountOfLogItemForDates(Log.Items logItemType, List<DateTime> dates)
		{
			return Caching.Instances.Main.GetWithLocalCaching(
				String.Format("GetCountOfLogItemForDates(logItemType={0}, dates={1})", logItemType, string.Join(",", dates.ConvertAll(d => d.ToShortDateString()).ToArray())),
				() =>
				{
					var query = new Query();
					query.Columns = new ColumnSet(Log.Columns.Count, Log.Columns.Date);
					query.QueryCondition = new And(
												new Q(Log.Columns.Item, logItemType),
												   new Or(
													   dates.ConvertAll(date => new Q(Log.Columns.Date, date.Date)).ToArray()
												   )
											   );
					var ls = new LogSet(query);
					var results = new Dictionary<DateTime, int>();
					foreach (Log l in ls)
					{
						results.Add(l.Date, l.Count);
					}
					foreach (DateTime d in dates)
					{
						if (!results.ContainsKey(d.Date))
						{
							results.Add(d.Date, 0);
						}
					}
					return results;
				},
				5.Minutes(),
				1.Days()
			);
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:33,代码来源:DataDrivenTrafficShape.cs

示例2: Init

		public void Init(Usr u)
		{
			AllMusicTypes = null;
			SelectedMusicTypes = null;
			GenericMusicTypes = null;
			SelectedPlaces = null;
			MusicQ = null;
			PlaceQ = null;
			#region Populate MusicQ and MusicTypes
			if (u.FavouriteMusicTypeK == 0 && u.MusicTypesFavouriteCount == 0)
			{
				MusicQ = new Q(true);
			}
			else
			{
				List<int> musicTypesK = new List<int>();

				#region Add MusicTypes
				if (u.MusicTypesFavouriteCount > 0)
				{
					foreach (MusicType mt in u.MusicTypesFavourite)
					{
						if (!musicTypesK.Contains(mt.K))
						{
							musicTypesK.Add(mt.K);
							AllMusicTypes.Add(mt.Order, mt);
							SelectedMusicTypes.Add(mt.Order, mt);
							AddMusicTypeChildren(mt, ref musicTypesK);
							#region Add the parent
							if (u.UpdateSendGenericMusic && mt.ParentK > 1 && !musicTypesK.Contains(mt.ParentK))
							{
								musicTypesK.Add(mt.ParentK);
								AllMusicTypes.Add(mt.Parent.Order, mt.Parent);
								GenericMusicTypes.Add(mt.Parent.Order, mt.Parent);
							}
							#endregion
						}
					}
				}
				else
				{
					if (u.FavouriteMusicTypeK != 0)
					{
						musicTypesK.Add(u.FavouriteMusicTypeK);
						AllMusicTypes.Add(u.FavouriteMusicType.Order, u.FavouriteMusicType);
						SelectedMusicTypes.Add(u.FavouriteMusicType.Order, u.FavouriteMusicType);
						AddMusicTypeChildren(u.FavouriteMusicType, ref musicTypesK);
					}
				}
				if (u.UpdateSendGenericMusic && !musicTypesK.Contains(1))
				{
					musicTypesK.Add(1);
					MusicType mtAllMusic = new MusicType(1);
					AllMusicTypes.Add(mtAllMusic.Order, mtAllMusic);
					GenericMusicTypes.Add(mtAllMusic.Order, mtAllMusic);
				}
				#endregion
				musicTypesK.Sort();
				MusicQ = new Or(musicTypesK.ConvertAll<Q>(mtk => new Q(EventMusicType.Columns.MusicTypeK, mtk)).ToArray());
			}
			#endregion
			#region Populate PlaceQ and SelectedPlaces
			List<int> placesK = new List<int>();
			if (u.HomePlaceK > 0)
			{
				placesK.Add(u.HomePlaceK);
				SelectedPlaces.Add(u.Home.Name, u.Home);
			}

			foreach (Place p in u.PlacesVisit(null, 0))
			{
				if (!placesK.Contains(p.K))
				{
					placesK.Add(p.K);
					SelectedPlaces.Add(p.Name, p);
				}
			}

			if (placesK.Count > 0)
			{
				placesK.Sort();
				PlaceQ = new Or(placesK.ConvertAll<Q>(pk => new Q(Venue.Columns.PlaceK, pk)).ToArray());
			}
			else
			{
				PlaceQ = new Q(false);
			}
			#endregion
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:89,代码来源:Usr.cs

示例3: Refund


//.........这里部分代码省略.........
							RefundTicket(actionUsr, ticket, refundIncludeBookingFee, areFundsAlreadyReleased);

                            if (ticket.Cancelled)
                            {
                                if (!ticketRunKs.Contains(ticket.TicketRunK))
                                    ticketRunKs.Add(ticket.TicketRunK);

                                successfulRefundTransferCount++;
                                successfulRefundQuantity += ticket.Quantity;

                                if (chargePromoterTicketPrice)
                                    sumTicketPrice += ticket.Price;
                            }
                        }
                        catch (Exception ex)
                        {
                            failedRefundExceptions.Add(ex);
                            failedTicketKs += ticket.K.ToString() + ", ";
                        }
                    }

                    if (successfulRefundTransferCount > 0 && (chargePromoterTicketPrice || chargeToPromoter > 0))
                    {
                        // create invoice with tickets.count * chargeToPromoter invoice item for refund.
                        DateTime now = DateTime.Now;

                        InvoiceDataHolder refundChargeInvoiceDH = new InvoiceDataHolder();
                        refundChargeInvoiceDH.ActionUsrK = Usr.Current.K;
                        refundChargeInvoiceDH.CreatedDateTime = now;
                        refundChargeInvoiceDH.DueDateTime = now.AddDays(tickets[0].TicketRun.Promoter.InvoiceDueDaysEffective > Vars.InvoiceDueDaysDefault ? tickets[0].TicketRun.Promoter.InvoiceDueDaysEffective : Vars.InvoiceDueDaysDefault);
                        refundChargeInvoiceDH.DuplicateGuid = Guid.NewGuid();
                        refundChargeInvoiceDH.PromoterK = tickets[0].TicketRun.PromoterK;
                        refundChargeInvoiceDH.TaxDateTime = now;
                        refundChargeInvoiceDH.Type = Invoice.Types.Invoice;
                        if (tickets[0].TicketRun.Promoter.PrimaryUsrK != 0)
                            refundChargeInvoiceDH.UsrK = tickets[0].TicketRun.Promoter.PrimaryUsrK;
                        else
                            refundChargeInvoiceDH.UsrK = Usr.Current.K;
                        refundChargeInvoiceDH.VatCode = Invoice.VATCodes.T1;

                        if (chargePromoterTicketPrice)
                        {
                            InvoiceItemDataHolder iidhPrice = new InvoiceItemDataHolder();
                            iidhPrice.RevenueStartDate = now;
                            iidhPrice.RevenueEndDate = now;
                            iidhPrice.Description = "Ticket price refund charge for " + successfulRefundQuantity.ToString() + " ticket" + (successfulRefundQuantity > 1 ? "s" : "");
                            iidhPrice.ShortDescription = "Ticket price refund charge";
                            iidhPrice.Type = InvoiceItem.Types.Misc;
                            iidhPrice.VatCode = InvoiceItem.VATCodes.T9;
                            iidhPrice.SetTotal(Math.Round(sumTicketPrice, 2));

                            refundChargeInvoiceDH.InvoiceItemDataHolderList.Add(iidhPrice);
                        }

                        InvoiceItemDataHolder iidh = new InvoiceItemDataHolder();
                        iidh.RevenueStartDate = now;
                        iidh.RevenueEndDate = now;
                        iidh.Description = "Ticket refund charge for " + successfulRefundTransferCount.ToString() + " ticket" + (successfulRefundTransferCount > 1 ? "s" : "") + " transfers";
                        iidh.ShortDescription = "Ticket refund charge";
                        iidh.Type = InvoiceItem.Types.Misc;
                        iidh.VatCode = InvoiceItem.VATCodes.T1;
                        iidh.SetTotal(Math.Round(successfulRefundTransferCount * chargeToPromoter, 2));

                        refundChargeInvoiceDH.InvoiceItemDataHolderList.Add(iidh);

                        Invoice refundChargeInovice = refundChargeInvoiceDH.UpdateInsertDelete();

                        foreach (int ticketRunK in ticketRunKs)
                        {
                            new TicketRun(ticketRunK).CalculateSoldTicketsAndUpdate();
                        }

                        refundChargeInovice.UpdateAndAutoApplySuccessfulTransfersWithAvailableMoney();

                        Utilities.EmailInvoice(refundChargeInovice, true);

						if (areFundsAlreadyReleased)
							ticketPromoterEvent.CalculateTotalFundsAndVat();
                    }

                    failedTicketKs = failedTicketKs.Trim();

                    if (failedTicketKs.Length > 0)
                    {
                        string exceptionMessages = "";
                        foreach (Exception ex in failedRefundExceptions)
                            exceptionMessages += ex.Message + "\n\n";

                        failedTicketKs = failedTicketKs.Substring(0, failedTicketKs.Length - 1);

                        throw new Exception("Failed to refund the following tickets #" + failedTicketKs + ". Exception messages: " + exceptionMessages);
                    }
                }
            }
            catch (Exception ex)
            {
				Utilities.AdminEmailAlert("Exception in Ticket.Refund(List<Ticket> tickets)", "Exception in Ticket.Refund(List<Ticket> tickets)", ex, tickets.ConvertAll(ticket => (IBobAsHTML)ticket));
                throw ex;
            }
        }
开发者ID:davelondon,项目名称:dontstayin,代码行数:101,代码来源:Ticket.cs

示例4: CurrentUrlGeneric

		private string CurrentUrlGeneric(List<string> NewTags, string Application, params object[] Params)
		{
			Hashtable par = new Hashtable();
			for (int i = 0; i < Params.Length - 1; i = i + 2)
			{
				if (Params[i] != null)
				{
					par[Params[i].ToString()] = Params[i + 1];
				}
			}
			ArrayList alParams = new ArrayList();

			foreach (string key in this.Keys)
			{
				if (par.ContainsKey(key))
				{
					if (par[key] != null)
					{
						alParams.Add(key);
						alParams.Add(par[key].ToString());
					}
				}
				else
				{
					alParams.Add(key);
					alParams.Add(this[key].ValuePlain.ToString());
				}
			}

			foreach (string key in par.Keys)
			{
				if (!this.ContainsKey(key) && par[key] != null)
				{
					alParams.Add(key);
					alParams.Add(par[key].ToString());
				}
			}

			string currentFilter = "";

			string[] finalParams = (string[])alParams.ToArray(typeof(string));

			if (HasCustomPage)
			{
				return PageUrl(this.PageType, this.PageName, finalParams);
			}
			else
			{
				if (!HasTagFilter && NewTags == null && alParams.Count > 0 && Application.Length == 0)
					Application = "home";

				if (CurrentFilter != null)
				{
					currentFilter = CurrentFilter;
					if (currentFilter.Length > 0)
						currentFilter = currentFilter.Substring(1);
				}

				if (NewTags != null)
				{
					Application = "tags/" + ((NewTags.Count == 0 && alParams.Count > 0) ? "all" : String.Join("-", NewTags.ConvertAll(k => Cambro.Web.Helpers.UrlTextSerialize(k)).ToList().ToArray()));
				}
				else if (alParams.Count > 0 && HasTagFilter && TagFilter.Count == 0)
					Application = "tags/all";



				return MakeUrl(currentFilter, Application, finalParams);
			}
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:70,代码来源:UrlInfo.cs


注:本文中的Common.List.ConvertAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。