Esempio n. 1
0
        public static void InsertPointCloudToDB(DrawingStack dwg, DateTime time, IList <Point3dCollection> pointsList, IList <Point2dCollection> boundaryList)
        {
            var UPPER = pointsList.Count;

            using (DatabaseCommands commands = new DatabaseCommands())
            {
                try
                {
                    for (int i = 0; i < UPPER; i++)
                    {
                        if (((pointsList[i].Count == 0) || boundaryList[i].Count == 0))
                        {
                            throw new ArgumentNullException(string.Format("PointsList: {0}", pointsList[i].Count));
                        }
                        //Store as Points
                        SqlBytes p = GeometryManager.SerializeSqlGeographyMultiPoint(pointsList[i]);
                        SqlBytes b = GeometryManager.SerializeSqlGeographyMultiPoint(boundaryList[i]);
                        commands.InsertNewPolylineGeometry(dwg, time, GeometryManager.ToBytes(b),
                                                           GeometryManager.ToBytes(p));
                    }
                }

                catch
                (Exception ex)
                {
                    DatabaseLogs.FormatLogs(ex.Message);
                }
            }
        }
        public void PullPointCloudFiles(DateTime time)
        {
            using (var context = GetDataBasePath.GetSql4Connection())
            {
                var points =
                    from p in context.PointCloud
                    where (p.DateStamp == Convert.ToDateTime(DateSelected))
                    select p;


                string command;
                var    i = 1;
                foreach (var val in points)
                {
                    var stack = new DrawingStack();
                    command = string.Format(
                        "{0},{1},{2},{3},{4}", Order(val.DrawingName), val.DrawingName, val.SourcePath,
                        val.DestinationPath,
                        val.DateStamp);
                    stack.Function = command;
                    context.DrawingStack.InsertOnSubmit(stack);
                    // PointClouds.Add(stack);
                }

                context.SubmitChanges();
            }
        }
Esempio n. 3
0
        private void MergeStacks(IList <Files> pointClouds, IList <Files> polylines)
        {
            string order, pointFile, destination, timestamp, command;

            using (var context = GetDataBasePath.GetSql4Connection())
            {
                string t = "";

                for (int i = 1; i < 19; i++)
                {
                    if (i < 10)
                    {
                        t = "0" + i.ToString();
                    }
                    else
                    {
                        t = i.ToString();
                    }
                    var point = from po in pointClouds
                                where ((po.Order).Equals(t))
                                select po;


                    var pline = from pl in polylines
                                where ((pl.Order).Equals(t))
                                select pl;


                    foreach (var po in point)
                    {
                        DrawingStack stack = new DrawingStack();

                        order     = po.Order;
                        pointFile = System.IO.Path.Combine(po.SourceFile, po.FileName);
                        if (String.IsNullOrEmpty(po.DestFile))
                        {
                            destination = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(po.SourceFile),
                                                                 "HOLE" + po.Order);
                        }
                        else
                        {
                            destination = System.IO.Path.Combine(po.DestFile, "HOLE" + po.Order);
                        }
                        timestamp = po.time.ToString();

                        var polyfile = from p in pline
                                       where order.Equals(p.Order)
                                       select System.IO.Path.Combine(p.SourceFile, p.FileName);

                        command = String.Format(
                            "{0},{1},{2},{3},{4}", order, pointFile, polyfile.FirstOrDefault(), destination, timestamp);


                        //stack.Commands = command;
                        //context.CommandStack.InsertOnSubmit(stack);
                    }
                    context.SubmitChanges();
                }
            }
        }
Esempio n. 4
0
        private void Initialize()
        {
            DrawingStack.Shuffle();

            for (var index = 0; index < CardsPerPlayer; index++)
            {
                for (var playerIndex = 0; playerIndex < Players.Count; playerIndex++)
                {
                    var actualPlayerIndex = (playerIndex + CurrentDealerIndex + 1) % Players.Count;

                    var card = DrawingStack.WithdrawTopCard();
                    Players[actualPlayerIndex].AppendCard(card);

                    if (index == CardsPerPlayer - 1 && actualPlayerIndex == CurrentDealerIndex)
                    {
                        RequiredFirstCard = card;
                    }
                }
            }

            if (ActiveStack.Cards.Count != 0)
            {
                throw new InvalidOperationException(
                          $@"[Internal error] After initialization the active stack must be empty but it has {
                        ActiveStack.Cards.Count} cards.");
            }
        }
Esempio n. 5
0
        private static string SetOutPutFolder(DrawingStack dwg, DatabaseCommands commands)
        {
            if (commands == null)
            {
                commands = new DatabaseCommands();
            }

            var date   = DateConverts.ConDateTimeToStringForFileSafeDatabase(dwg.DateStamp.Value);
            var output = Path.Combine(commands.GetGlobalDestinationPath(),
                                      String.Format("DISJOINT-HOLES-{0}", date));

            Utils.FileUtilities.CreateDirectory(output);
            return(output);
        }
Esempio n. 6
0
        private PlayingCard DrawCard()
        {
            if (DrawingStack.IsEmpty)
            {
                throw new InvalidOperationException(@"[Internal error] The drawing stack is empty.");
            }

            var result = DrawingStack.WithdrawTopCard();

            if (DrawingStack.IsEmpty)
            {
                var refillCards = ActiveStack.WithdrawAllCardsExceptTopCardWithSameRank();
                DrawingStack.Refill(refillCards);
                DrawingStack.Shuffle();

                PointsRatio++;
            }

            return(result);
        }
Esempio n. 7
0
        public void PullPointCloudFiles(DateTime time)
        {
            try
            {
                if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
                {
                    return;
                }

                using (PGAContext context = GetDataBasePath.GetSql4Connection())
                {
                    var points =
                        from p in context.PointCloud
                        where (p.DateStamp == Convert.ToDateTime(DateSelected))
                        select p;


                    string command;
                    // var i = 1;
                    foreach (var val in points)
                    {
                        var stack = new DrawingStack();
                        command = string.Format(
                            "{0},{1},{2},{3},{4}", Order(val.DrawingName), val.DrawingName, val.SourcePath,
                            val.DestinationPath,
                            val.DateStamp);
                        stack.Function = command;
                        context.DrawingStack.InsertOnSubmit(stack);
                        // PointClouds.Add(stack);
                    }

                    context.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                PGA.MessengerManager.MessengerManager.LogException(ex);
            }
        }