Exemplo n.º 1
0
        private static void DistinctActorPrinter(System.Collections.Generic.List <MovieActor> actors)
        {
            // Demo for the first part of Alex's article.
            //var distinct = actors.Distinct(new ActorComparer());

            // This KeySelector leaves only the first of Baldwin brothers in the output.
            var distinct = actors.Distinct(new ActorComparerGeneralized()
            {
                KeySelector = actor => actor.LastName
            });

            Console.WriteLine(String.Format("\n{0} distinct actors.", distinct.Count()));

            foreach (var actor in distinct)
            {
                Console.WriteLine(actor);
            }

            // This KeySelector leave both Alec and William in the output.
            distinct = actors.Distinct(new ActorComparerGeneralized()
            {
                KeySelector = actor => new { actor.FirstName, actor.LastName }
            });
            Console.WriteLine(String.Format("\n{0} distinct actors.", distinct.Count()));

            foreach (var actor in distinct)
            {
                Console.WriteLine(actor);
            }
        }
Exemplo n.º 2
0
        private static void NaiveDistinctActorPrinter(System.Collections.Generic.List <MovieActor> actors)
        {
            // Prints "7 distinct actors" in the second output line.
            var distinct = actors.Distinct();

            Console.WriteLine(
                String.Format("\n{0} distinct actors.", distinct.Count()));

            foreach (var actor in distinct)
            {
                Console.WriteLine(actor);
            }
        }
Exemplo n.º 3
0
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.ImportedBuyer> FindSupplierBuyers()
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("CommercialAgreement", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "FindSupplierBuyers")) {
         string supUsername = "";
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement> supplierAgreements = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement>((a) => a.Supplier.UserName == zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentApplicationUser().UserName);
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.ImportedBuyer>       foundBuyers        = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.ImportedBuyer>();
         foreach (var supAgreement in supplierAgreements ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement>())
         {
             zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "CommercialAgreement", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "buyer: " + (supAgreement?.ImportedBuyer?.Code ?? "") + "c.a. " + (supAgreement?.Id?.ToString() ?? ""));
             foundBuyers?.Add(supAgreement?.ImportedBuyer);
         }
         return(foundBuyers?.Distinct().ToList());
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取易捷北京商家信息
        /// </summary>
        /// <param name="appIds">商家Id列表</param>
        /// <returns>商家信息</returns>
        public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.SellerInfoDTO> GetYJSellerInfoesExt(System.Collections.Generic.List <System.Guid> appIds)
        {
            if (appIds.Count == 0)
            {
                return(new System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.SellerInfoDTO>());
            }
            var ids         = appIds.Distinct();
            var mallApplies = MallApply.ObjectSet().Where(m => m.EsAppId == YJB.Deploy.CustomDTO.YJBConsts.YJAppId && ids.Contains(m.AppId)).ToList()
                              .Select(m => new Jinher.AMP.BTP.Deploy.CustomDTO.SellerInfoDTO {
                AppId = m.AppId, AppName = m.AppName, EsAppId = m.EsAppId, EsAppName = m.EsAppName, Type = m.GetTypeString()
            }).ToList();

            return(mallApplies);
        }
 public static System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Order> FindAgreement()
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("Order", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "FindAgreement")) {
         string userName = "";
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement> agreements  = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement>((a) => a.Investor.UserName == zAppDev.DotNet.Framework.Identity.IdentityHelper.GetCurrentApplicationUser().UserName);
         System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Order>     foundOrders = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Order>();
         foreach (var agr in agreements ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Agreement>())
         {
             userName = (agr?.Supplier?.UserName ?? ""); foreach (var order in new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <DSS5_SupplyChainFinancialsOptimisation.BO.Order>((o) => o.Transaction.Supplier.UserName == userName) ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Order>())
             {
                 foundOrders?.Add(order);
             }
         }
         return(foundOrders?.Distinct().ToList());
     }
 }
Exemplo n.º 6
0
        public void TestMethodTranslate()
        {
            System.Collections.Generic.List <GlobalStructureInfo> AllStructures = new System.Collections.Generic.List <GlobalStructureInfo>();

            var UnusedObjects = CleanUp.GetUnusedObjects(
                Path.Combine(@"C:\steamcmd\empyrion\Saves\Games\Server\Shared"),
                AllStructures).ToArray();

            var PossibleCleanUpObjects = UnusedObjects.Where(O => (DateTime.Now - O.LastAccess).TotalDays > 14).ToArray();

            var usedTypes = AllStructures.Distinct(new StructureTypeEqualityComparer());
            var Result    =
                usedTypes.Aggregate("", (L, T) => L + T.type + ": " + AllStructures.Count(S => S.type == T.type)) + "\n" +
                $"Unused:{UnusedObjects.Length} ({UnusedObjects.Aggregate(0L, (S, O) => S + O.GetSize()) / (1024 * 1024):N2}MB) possible CleanUp:{PossibleCleanUpObjects.Length} ({PossibleCleanUpObjects.Aggregate(0L, (S, O) => S + O.GetSize()) / (1024 * 1024):N2}MB)"
            ;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Sets up the parameters of the ZoomSlider
        /// </summary>
        public void SetupZoom()
        {
            System.Collections.Generic.List <double> resolutions = new System.Collections.Generic.List <double>();
            foreach (Layer layer in Map.Layers)
            {
                if (layer is TiledMapServiceLayer)
                {
                    TiledMapServiceLayer tlayer = layer as TiledMapServiceLayer;
                    if (tlayer.TileInfo == null || tlayer.TileInfo.Lods == null)
                    {
                        continue;
                    }
                    var res = from t in tlayer.TileInfo.Lods
                              select t.Resolution;
                    resolutions.AddRange(res);
                }
            }
            resolutions.Sort();
            layerResolutions = resolutions.Distinct().Reverse().ToArray();
            int count = layerResolutions.Length;

            if (ZoomSlider != null)
            {
                if (count > 0)
                {
                    ZoomSlider.Minimum    = 0;
                    ZoomSlider.Maximum    = count - 1;
                    Map.MaximumResolution = layerResolutions[0];
                    Map.MinimumResolution = layerResolutions[count - 1];
                    double level = getValueFromMap(Map.Extent);
                    if (level >= 0)
                    {
                        ZoomSlider.Value = level;
                    }
                    ZoomSlider.Visibility = Visibility.Visible;
                    _resolutionsDefined   = true;
                }
                else
                {
                    ZoomSlider.Visibility = Visibility.Collapsed;
                }
            }
        }
Exemplo n.º 8
0
        public static void AddUniqueConnection(string name, string ip)
        {
            var key = name + ip;

            lock (_connections)
            {
                if (!_connections.Contains(key))
                {
                    _connections.Add(key);
                }
            }

            try
            {
                var savePath = System.IO.Path.Combine(Globals.DataPath, "connections.log");
                System.IO.File.WriteAllLines(savePath, _connections.Distinct().ToArray());
            }
            catch { }
        }
Exemplo n.º 9
0
        public void AddToHistory(string wrld)
        {
            history.Insert(0, wrld);
            history = history.Distinct().ToList();

            while (history.Count > 12)
            {
                history.RemoveAt(11);
            }

            string serialized = "";

            for (int i = 0; i < history.Count(); i++)
            {
                serialized += history[i] + "\n";
            }
            serialized = serialized.Substring(0, serialized.Length - 1);

            File.WriteAllText(path, serialized);

            Redraw();
        }
Exemplo n.º 10
0
 public override void Unique()
 {
     collection = collection.Distinct().ToList();
 }
Exemplo n.º 11
0
        private System.Collections.Generic.List <string> AddressFiltr(System.Collections.Generic.List <string> addresses)
        {
            //============================================(-1-)===============================================================

            addresses = addresses
                        .Where(x => !x.Contains("mailto:") && !x.Contains("file:") && !x.Contains("skype:") && !x.Contains("javascript:"))    //we deleted references to "mailto:" and "file:" and "skype:" and "javascript:"
                        .Select(x => x = deleteGetParam(x))                                                                                   //delete get params
                        .ToList <string>();

            //================================================================================================================
            //============================================(-2-)===============================================================
            //we selected references that starts with "//" and we added protocol http or https
            System.Collections.Generic.List <string> temp1 = addresses.Where(x => x.StartsWith("//"))
                                                             .Select(x => targetSiteObj.Protocol + x)
                                                             .ToList <string>();

            if (temp1.Count > 0)
            {
                addresses = addresses.Where(x => !x.StartsWith("//")).ToList <string>();
            }
            //================================================================================================================
            //============================================(-3-)===============================================================

            //we added to domain name selected root references
            System.Collections.Generic.List <string> temp = addresses
                                                            .Where(x => x.StartsWith("/"))
                                                            .Select(x => targetSiteObj.WholeName + x)
                                                            .ToList <string>();


            //================================================================================================================
            //============================================(-4-)===============================================================
            //we selected references with domain names or similar
            System.Collections.Generic.List <string> temp2 = addresses
                                                             .Where(x => isNecessarySite(x, targetSiteObj.JustNameSite))
                                                             .ToList <string>();

            //================================================================================================================
            //============================================(-5-)===============================================================

            //we united the lists
            temp.AddRange(temp1);
            temp.AddRange(temp2);
            //================================================================================================================
            //============================================(-6-)===============================================================

            //we deleted unnecessary links to files
            temp = temp.Where(x => !isFile(x)).ToList <string>();
            //================================================================================================================
            //============================================(-7-)===============================================================

            //change special characters html to unicod characters
            temp = temp.Select(x => x = checkTheCharacters(x)).ToList <string>();

            //we deleted local links
            temp = temp.Select(x => x = deleteLocalLink2(x)).ToList <string>();

            //we removed duplicate strings
            temp = temp.Distinct().ToList <string>();

            //delete visited addresses
            temp = temp.Except(listVisitedLinks).ToList <string>();

            temp = temp.Where(x => x.Contains(targetSiteObj.WholeName)).ToList <string>();

            return(temp);
        }
Exemplo n.º 12
0
        public ActionResult SolvingTask(int id, string Answer)
        {
            SolveTaskModel Model = new SolveTaskModel();
            ApplicationDbContext DB = new ApplicationDbContext();

            Model.Nicknames = new System.Collections.Generic.Dictionary<string,string>();
            Model.Task = DB.Tasks.First(c => c.UserTaskID == id);
            Model.Answers = DB.Answers.Where(c => c.TaskID == id).AsEnumerable();
            Model.Tags = DB.Tags.Where(c => c.TaskID == id).AsEnumerable();
            Model.UserName = DB.Users.First(c => c.Id == Model.Task.UserID).UserName;
            Model.Comments = DB.Comments.Where(c => c.TaskID == id).AsEnumerable();

            System.Collections.Generic.List<string> IDs = new System.Collections.Generic.List<string>();
            foreach(var i in DB.Comments.Where(c => c.TaskID == id))
                IDs.Add(i.UserID);
            IDs = IDs.Distinct().ToList();

            foreach (var i in IDs)
            {
                Model.Nicknames.Add(i, DB.Users.First(c=>c.Id==i).NickName);
            }
            
            string CurrentUserID = DB.Users.First(c => c.UserName == User.Identity.Name).Id;
            Model.Rating = 0;
            if (DB.Ratings.Any(c => c.UserID == CurrentUserID && c.TaskID == id)==true)
                Model.Rating = DB.Ratings.First(c => c.UserID == CurrentUserID && c.TaskID == id).RatingValue;
            
            Model.Solved = -1;
            if (DB.Tasks.Any(c => c.UserID == CurrentUserID && c.UserTaskID == id) == true)
                Model.Solved = -2;
            else
            {
                if (DB.Solves.Any(c => c.UserID == CurrentUserID && c.TaskID == id) == true)
                {
                    Model.Solved = -3;
                }
                else
                {
                    if (Answer != "" && Answer != null)
                    {
                        if (DB.Answers.Where(c => (c.TaskID == id) && (c.AnswerText == Answer)).ToList().Count != 0)
                        {
                            Model.Solved = 1;
                            Solves NewSolve = new Solves();
                            NewSolve.TaskID = id;
                            NewSolve.UserID = CurrentUserID;
                            DB.Solves.Add(NewSolve);
                            DB.Tasks.First(c => c.UserTaskID == id).SolveCount++;
                            DB.Entry(NewSolve).State = System.Data.Entity.EntityState.Added;
                            DB.SaveChanges();
                        }
                        else
                            Model.Solved = 0;
                    }
                }

            }
            return View(Model);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 插入改动商品信息
        /// </summary>
        /// <param name="commodityAndCategoryDTO">商品扩展实体</param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveCommodityChangeExt(System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> commodity)
        {
            try
            {
                if (commodity == null)
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "参数不能为空"
                    });
                }
                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                var            ComIds         = commodity.Select(s => s.CommodityId).ToList();
                var            ComList        = CommodityChange.ObjectSet().Where(p => ComIds.Contains(p.CommodityId)).GroupBy(p => p.CommodityId).Select(p => p.OrderByDescending(s => s.ModifiedOn).FirstOrDefault()).ToList();

                var LoginUserID = this.ContextDTO.LoginUserID;
                foreach (var item in commodity.Distinct())
                {
                    var             CommodityList = ComList.FirstOrDefault(p => p.CommodityId == item.CommodityId);
                    System.TimeSpan t3            = TimeSpan.Parse("0");
                    if (CommodityList != null)
                    {
                        var ModifyTime = CommodityList.ModifiedOn;
                        t3 = item.ModifiedOn - ModifyTime;
                    }
                    if (t3.TotalSeconds >= 5 || CommodityList == null)//时间间隔超过五秒  避免数据重复
                    {
                        CommodityChange ChangedCommodity = CommodityChange.CreateCommodityChange();
                        ChangedCommodity.Id                 = Guid.NewGuid();
                        ChangedCommodity.CommodityId        = item.CommodityId;
                        ChangedCommodity.Name               = item.Name;
                        ChangedCommodity.Code               = item.Code;
                        ChangedCommodity.No_Number          = item.No_Number;
                        ChangedCommodity.SubId              = item.SubId;
                        ChangedCommodity.Price              = item.Price;
                        ChangedCommodity.Stock              = item.Stock;
                        ChangedCommodity.PicturesPath       = item.PicturesPath;
                        ChangedCommodity.State              = item.State;
                        ChangedCommodity.IsDel              = item.IsDel;
                        ChangedCommodity.Description        = "";
                        ChangedCommodity.AppId              = item.AppId;
                        ChangedCommodity.No_Code            = item.No_Code;
                        ChangedCommodity.TotalCollection    = item.TotalCollection;
                        ChangedCommodity.TotalReview        = item.TotalReview;
                        ChangedCommodity.Salesvolume        = item.Salesvolume;
                        ChangedCommodity.ModifiedOn         = DateTime.Now;
                        ChangedCommodity.GroundTime         = item.GroundTime;
                        ChangedCommodity.ComAttribute       = item.ComAttribute;
                        ChangedCommodity.CategoryName       = item.CategoryName;
                        ChangedCommodity.SortValue          = item.SortValue;
                        ChangedCommodity.FreightTemplateId  = item.FreightTemplateId;
                        ChangedCommodity.MarketPrice        = item.MarketPrice;
                        ChangedCommodity.IsEnableSelfTake   = item.IsEnableSelfTake;
                        ChangedCommodity.Weight             = item.Weight;
                        ChangedCommodity.PricingMethod      = item.PricingMethod;
                        ChangedCommodity.SaleAreas          = item.SaleAreas;
                        ChangedCommodity.SharePercent       = item.SharePercent;
                        ChangedCommodity.CommodityType      = item.CommodityType;
                        ChangedCommodity.HtmlVideoPath      = item.HtmlVideoPath;
                        ChangedCommodity.MobileVideoPath    = item.MobileVideoPath;
                        ChangedCommodity.VideoPic           = item.VideoPic;
                        ChangedCommodity.VideoName          = item.VideoName;
                        ChangedCommodity.ScorePercent       = item.ScorePercent;
                        ChangedCommodity.Duty               = item.Duty;
                        ChangedCommodity.SpreadPercent      = item.SpreadPercent;
                        ChangedCommodity.ScoreScale         = item.ScoreScale;
                        ChangedCommodity.TaxRate            = item.TaxRate;
                        ChangedCommodity.TaxClassCode       = item.TaxClassCode;
                        ChangedCommodity.Unit               = item.Unit;
                        ChangedCommodity.InputRax           = item.InputRax;
                        ChangedCommodity.Barcode            = item.Barcode;
                        ChangedCommodity.JDCode             = item.JDCode;
                        ChangedCommodity.CostPrice          = item.CostPrice;
                        ChangedCommodity.IsAssurance        = item.IsAssurance;
                        ChangedCommodity.IsReturns          = item.IsReturns;
                        ChangedCommodity.ServiceSettingId   = item.ServiceSettingId;
                        ChangedCommodity.Type               = item.Type;
                        ChangedCommodity.YJCouponActivityId = item.YJCouponActivityId;
                        ChangedCommodity.YJCouponType       = item.YJCouponType;
                        ChangedCommodity.SubOn              = item.SubOn;
                        ChangedCommodity.ModifiedId         = LoginUserID;
                        ChangedCommodity.AuditState         = 0;
                        ChangedCommodity.SubTime            = DateTime.Now;
                        contextSession.SaveObject(ChangedCommodity);
                    }
                }
                int count = contextSession.SaveChanges();
                LogHelper.Info("数据同步到商品变动明细报表保存条数: " + count + ",DateTime: " + DateTime.Now);
                return(new ResultDTO {
                    ResultCode = 1, Message = "保存成功", isSuccess = true
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("保存商品变动数据异常"), ex);
                return(new ResultDTO {
                    ResultCode = 0, Message = "保存失败", isSuccess = false
                });
            }
        }