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


C# List.GroupBy方法代码示例

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


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

示例1: GenerateReceptionRegister

        public static void GenerateReceptionRegister(List<sp_Get_RegistruRegeptie_Result> lines, string fileName, DateTime reportDate)
        {
            using (var output = File.Open(fileName, FileMode.Create))
            {
                using (var document = DocX.Create(output))
                {
                    Paragraph title = document.InsertParagraph();
                    title.AppendLine("REGISTRU DE RECEPŢIE A PROBELOR DE LAPTE").FontSize(15).Bold().Alignment = Alignment.center;
					title = document.InsertParagraph();
                    title.AppendLine("Data:" + reportDate.ToString("dd.MM.yyyy") + "          ").FontSize(15).Bold().Alignment = Alignment.right;
                    var t = document.AddTable(lines.Count + 2, 5);
                    //Set header
                    t.Rows[0].Cells[0].Paragraphs.First().Append("Seria PV/Data").Bold().Alignment = Alignment.center;
                    t.Rows[0].Cells[1].Paragraphs.First().Append("Nume/Cod Prelevator").Bold().Alignment = Alignment.center;
                    t.Rows[0].Cells[2].Paragraphs.First().Append("Nume proba").Bold().Alignment = Alignment.center;
                    t.Rows[0].Cells[3].Paragraphs.First().Append("Cod identificare probă").Bold().Alignment = Alignment.center;
                    t.Rows[0].Cells[4].Paragraphs.First().Append("Tipul de analiză").Bold().Alignment = Alignment.center;
                    t.Rows[1].Cells[0].Paragraphs.First().Append("Cerere analiză").Bold().Alignment = Alignment.center;
                    t.Rows[1].Cells[4].Paragraphs.First().Append("a),b),c),d),e)*").Bold().Alignment = Alignment.center;

                    int start = 2;
                    int end = 2;
                    //Add content to this Table.
                    foreach (var commandNrGroup in lines.GroupBy(x => x.NrComanda).ToList())
                    {
                        start = end;
                        end = start + commandNrGroup.Count();
                        t.Rows[start].Cells[0].VerticalAlignment = VerticalAlignment.Center;
                        t.Rows[start].Cells[0].Paragraphs.First().Append(commandNrGroup.Key).Alignment = Alignment.center;
                        if (commandNrGroup.Count() > 1)
                            t.MergeCellsInColumn(0, start, end - 1);
                        foreach (var codGroup in commandNrGroup.GroupBy(x => x.NumeCodPrelevator))
                        {
                            t.Rows[start].Cells[1].VerticalAlignment = VerticalAlignment.Center;
                            t.Rows[start].Cells[1].Paragraphs.First().Append(codGroup.Key).Alignment = Alignment.center;
                            if (codGroup.Count() > 1)
                                t.MergeCellsInColumn(1, start, start + codGroup.Count() - 1);
                            foreach (var probeGroup in codGroup.GroupBy(x => x.NumeProba))
                            {
                                t.Rows[start].Cells[2].VerticalAlignment = VerticalAlignment.Center;
                                t.Rows[start].Cells[2].Paragraphs.First().Append(probeGroup.Key).Alignment = Alignment.center;
                                if (probeGroup.Count() > 1)
                                    t.MergeCellsInColumn(2, start, start + probeGroup.Count() - 1);

                                foreach (var elem in probeGroup)
                                {
                                    t.Rows[start].Cells[3].Paragraphs.First().Append(elem.CodProba).Alignment = Alignment.center;
                                    t.Rows[start].Cells[4].Paragraphs.First().Append(elem.TipAnaliza).Alignment = Alignment.center;

                                    start++;
                                }
                            }
                        }
                    }
                    // Insert the Table into the document.
                    t.Alignment = Alignment.center;
                    t.Design = TableDesign.TableGrid;
                    document.InsertTable(t);
                    

                    document.InsertParagraph().AppendLine(@"
    a) determinarea numărului total de germeni,
    b) determinarea numărului de celule somatice,
    c) determinare proprietăţi fizico-chimice,
    d) determinarea inhibitorilor,
    e) determinarea punctului de congelare.
    În urma verificării calitative şi cantitative efectuate la produsul de încercat/analizat, s-au constatat următoarele:
    Este acceptat un număr de ________ probe.
    Un număr de _______ probe nu corespund din punct de vedere cantitativ / calitativ.
    După încercare produsul este eliminat ca deşeu.").FontSize(12).Alignment = Alignment.left;

                    document.InsertParagraph().Append("Semnătura de primire\n").Alignment = Alignment.right;

					document.InsertParagraph().Append("Cod: FG – L – 12 – 02   Ediţia: 1/11.05.2015    Revizia: 1/11.05.2015").FontSize(8).Alignment = Alignment.left;
                    document.Save();
                }
            }
        }
开发者ID:veronica1981,项目名称:veronica,代码行数:78,代码来源:WordHelper.cs

示例2: PrintOrder


//.........这里部分代码省略.........
            Queue<string> RepassCost = new Queue<string>();

            //questo array mi serve per il merge
            Queue<string> filesDelivery = new Queue<string>();

            order.MergeField(docMain);
            order.OrderProduct.MergeField(docMain);
            order.OrderProduct.Product.MergeField(docMain);

            var product = productRepository.GetSingle(order.OrderProduct.Product.CodProduct);
            product.ProductParts.FirstOrDefault().MergeField(docMain);
            try
            {
                product.ProductParts.FirstOrDefault().productpartprintings.FirstOrDefault().MergeField(docMain);
            }
            catch (Exception)
            {
            }

            //    product.ProductParts.FirstOrDefault().ProductPartPrintableArticles.FirstOrDefault().MergeField(docMain);

            var costs = order.OrderProduct.Costs.OrderBy(x => x.IndexOf);
            Console.WriteLine(costs);



            //group costdetails by taskexecutor
            List<CostDetail> costDetails = new List<CostDetail>();
            foreach (var item in costs)
            {
                costDetails.AddRange(item.CostDetails);
            }

            var TaskExecutorGroups = costDetails.GroupBy(p => p.CodTaskExecutorSelected,
                p => p,
                (key, g) => new CostDetailGrouped
                {
                    CodTaskExecutorSelected = key,
                    CostDetails = g.ToList()
                });

            Console.WriteLine(TaskExecutorGroups);
            //end grouping




            foreach (var cost in costs)
            {
                // Create the document in memory:
                //var docCost = DocX.Load(fileNameCost);
                //                cost.MergeField(docCost);

                //try
                //{
                var cd = cost.CostDetails.FirstOrDefault();
                if (cd != null)
                {
                    cd = costDetailRepository.GetSingle(cd.CodCostDetail);
                    cd.InitCostDetail(taskExecutorRepository.GetAll(), articleRepository.GetAll());

                    if (cost.CostDetails.FirstOrDefault().TypeOfCostDetail.ToString() == "PrintedRollArticleCostDetail" ||
                        cost.CostDetails.FirstOrDefault().TypeOfCostDetail.ToString() == "PrintingZRollCostDetail" ||
                        cost.CostDetails.FirstOrDefault().TypeOfCostDetail.ToString() == "PrintedSheetArticleCostDetail" ||
                        cost.CostDetails.FirstOrDefault().TypeOfCostDetail.ToString() == "PrintingSheetCostDetail" ||
                        cost.CostDetails.FirstOrDefault().TypeOfCostDetail.ToString() == "ControlTableCostDetail")
开发者ID:algola,项目名称:backup,代码行数:67,代码来源:DocumentController2.cs


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