Beispiel #1
0
        public Topic(ITopicNode parent, ITopicFile file) : base(Path.GetFileNameWithoutExtension(file.FilePath))
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            Project = parent.Project;

            File = file;

            IsIndex = Name.EqualsIgnoreCase(Index);
            if (IsIndex)
            {
                Key         = parent.Url;
                OrderString = file.RelativeFile.IsEmpty() ? string.Empty : file.RelativeFile.ParentUrl();
            }
            else
            {
                Key = parent.Url.AppendUrl(Name);
            }

            OrderString = OrderString.Replace(".spark", "");

            TopicBuilder.BuildOut(this);
        }
Beispiel #2
0
        public static void Initialize(OrderingContext context)
        {
            context.Database.EnsureCreated();

            if (context.Order.Any())
            {
                return;
            }

            var orders = new Order[]
            {
                //new Order{Date= new DateTime(1991, 12, 31, 22, 56, 59), Sum = 3000, UserId = 1, User=context.User.FirstOrDefault()},
                // new Order{Date= new DateTime(2000, 12, 31, 22, 56, 59),Sum = 10000, UserId = 2, User=context.User.FirstOrDefault()},
                // new Order{Url="http://orders.msdn.com/visualstudio"}
            };

            foreach (Order b in orders)
            {
                context.Order.Add(b);
            }
            context.SaveChanges();

            var products = new Product[]
            {
                new Product {
                    Name = "Спортивная куртка на молнии", Costs = 3000
                },
                new Product {
                    Name = "Спортивный зимний костюм", Costs = 5000
                }
            };

            foreach (Product p in products)
            {
                context.Product.Add(p);
            }
            var users = new User[]
            {
                // new User { Username="******",Email = "*****@*****.**" },
                // new User { Username="******",Email = "*****@*****.**"  }
            };

            foreach (User p in users)
            {
                context.User.Add(p);
            }
            context.SaveChanges();

            var os = new OrderString[]
            {
                new OrderString {
                    OrderId = 1, ProductId = 1, Cost = 3000, Count = 1
                },
                new OrderString {
                    OrderId = 2, ProductId = 2, Cost = 10000, Count = 2
                }
            };

            foreach (OrderString p in os)
            {
                context.OrderString.Add(p);
            }
            context.SaveChanges();
        }
Beispiel #3
0
        private void TestWithWordsAndAnswer(string words, string answer)
        {
            OrderString orderString = new OrderString();

            Assert.AreEqual(orderString.Order(words), answer);
        }
Beispiel #4
0
    public void UpdateData()
    {
        if (User.Length > 0)
        {
            IEnumerable <Aircraft> rgac = new UserAircraft(User).GetAircraftForUser();
            AircraftForUser.Clear();
            foreach (Aircraft ac in rgac)
            {
                AircraftForUser[ac.AircraftID] = ac;
            }

            IEnumerable <LogbookEntryDisplay> rgle = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntryDisplay.QueryCommand(Restriction), User, "Date", SortDirection.Descending, false, false);
            gvFlightLogs.DataSource = rgle;

            // See whether or not to show catclassoverride column
            bool fShowAltCatClass = false;
            foreach (LogbookEntryDisplay le in rgle)
            {
                fShowAltCatClass |= le.IsOverridden;
            }

            if (!fShowAltCatClass)
            {
                foreach (DataControlField dcf in gvFlightLogs.Columns)
                {
                    if (dcf.HeaderText.CompareCurrentCultureIgnoreCase("Alternate Cat/Class") == 0)
                    {
                        gvFlightLogs.Columns.Remove(dcf);
                        break;
                    }
                }
            }

            // Generate the set of properties used by the user
            int cColumns = gvFlightLogs.Columns.Count;
            PropertyColumnMap.Clear();
            HashSet <CustomPropertyType> hscpt = new HashSet <CustomPropertyType>();
            foreach (LogbookEntryBase le in rgle)
            {
                foreach (CustomFlightProperty cfp in le.CustomProperties)
                {
                    if (!hscpt.Contains(cfp.PropertyType))
                    {
                        hscpt.Add(cfp.PropertyType);
                    }
                }
            }

            // Now sort that alphabetically and add them
            List <CustomPropertyType> lst = new List <CustomPropertyType>(hscpt);
            lst.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
            foreach (CustomPropertyType cpt in lst)
            {
                PropertyColumnMap[cpt.PropTypeID] = cColumns++;
                BoundField bf = new BoundField()
                {
                    HeaderText       = cpt.Title,
                    HtmlEncode       = false,
                    DataField        = string.Empty,
                    DataFormatString = string.Empty
                };
                gvFlightLogs.Columns.Add(bf);
            }

            if (OrderString != null && OrderString.Length > 0)
            {
                char[]    delimit  = { ',' };
                string[]  rgszCols = OrderString.Split(delimit);
                ArrayList alCols   = new ArrayList();

                // identify the requested front columns
                foreach (string szcol in rgszCols)
                {
                    if (int.TryParse(szcol, NumberStyles.Integer, CultureInfo.InvariantCulture, out int col))
                    {
                        if (col < gvFlightLogs.Columns.Count)
                        {
                            alCols.Add(col);
                        }
                    }
                }

                int[] rgCols = (int[])alCols.ToArray(typeof(int));

                // pull those columns to the left; this creates a duplicate column and shifts everything right by one...
                int iCol = 0;
                for (iCol = 0; iCol < rgCols.Length; iCol++)
                {
                    gvFlightLogs.Columns.Insert(iCol, gvFlightLogs.Columns[rgCols[iCol] + iCol]);
                }

                // And then remove the duplicates, from right to left
                Array.Sort(rgCols);
                for (int i = rgCols.Length - 1; i >= 0; i--)
                {
                    gvFlightLogs.Columns.RemoveAt(rgCols[i] + iCol);
                }
            }

            gvFlightLogs.DataBind();
        }
    }