Exemplo n.º 1
0
    void Update()
    {
        Vector3 mPos = Input.mousePosition;

        mPos = new Vector3(mPos.x, mPos.y, transform.position.y);
        Vector3 pos = Camera.main.ScreenToWorldPoint(mPos);

        if (currentBuilding != null && !isPlaced)
        {
            currentBuilding.position = new Vector3(pos.x, 0, pos.z);

            if (Input.GetMouseButtonDown(0))
            {
                if (IsAvailable())
                {
                    isPlaced  = true;
                    clickable = gameObject.GetComponent <Manager>();
                    clickable.SetClickable(true);
                }
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit = new RaycastHit();
                Ray        ray = new Ray(new Vector3(pos.x, 8, pos.z), Vector3.down);
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, bMask))
                {
                    if (availableX != null)
                    {
                        availableX.SetSelected(false);
                    }
                    hit.collider.gameObject.GetComponent <Available>().SetSelected(true);
                    availableX = hit.collider.gameObject.GetComponent <Available>();
                }
                else
                {
                    if (availableX != null)
                    {
                        availableX.SetSelected(false);
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
 public Driver(int driverId, string firstname, string lastname, DateTime birthday, string phone, int gender, string email, string photoUrl, string password, bool registerState, Available availability, string carBrand, TypeOfCar carType, string immatriculation)
 {
     DriverId        = driverId;
     Firstname       = firstname;
     Lastname        = lastname;
     Birthday        = birthday;
     Phone           = phone;
     Gender          = gender;
     Email           = email;
     PhotoUrl        = photoUrl;
     Password        = password;
     RegisterState   = registerState;
     Availability    = availability;
     CarBrand        = carBrand;
     CarType         = carType;
     Immatriculation = immatriculation;
 }
Exemplo n.º 3
0
        public void PairDelayedSecondaryWithInitialValue()
        {
            using (var pipeline = Pipeline.Create())
            {
                Generators.Range(pipeline, 0, 2, TimeSpan.FromSeconds(1)); // hold pipeline open
                var primary   = Generators.Range(pipeline, 0, 5, TimeSpan.FromTicks(1));
                var secondary = Generators.Range(pipeline, 0, 5, TimeSpan.FromTicks(1)).Delay(TimeSpan.FromMilliseconds(100));
                var paired    = primary.Pair(secondary, 42).ToObservable().ToListObservable();
                var fused     = primary.Fuse(secondary, Available.LastOrDefault(42)).ToObservable().ToListObservable();
                pipeline.Run();

                var pairedResults = paired.AsEnumerable().ToArray();
                Assert.IsTrue(Enumerable.SequenceEqual(new[] { 0, 1, 2, 3, 4 }.Zip(new[] { 42, 42, 42, 42, 42 }, ValueTuple.Create), pairedResults));

                var fusedResults = fused.AsEnumerable().ToArray();
                Assert.IsTrue(Enumerable.SequenceEqual(new[] { 0, 1, 2, 3, 4 }.Zip(new[] { 42, 42, 42, 42, 42 }, ValueTuple.Create), pairedResults));
            }
        }
Exemplo n.º 4
0
        public void PairDelayedPrimaryWithOutputCreator()
        {
            using (var pipeline = Pipeline.Create())
            {
                Generators.Range(pipeline, 0, 2, TimeSpan.FromSeconds(1)); // hold pipeline open
                var primary   = Generators.Range(pipeline, 0, 5, TimeSpan.FromTicks(1)).Delay(TimeSpan.FromMilliseconds(100));
                var secondary = Generators.Range(pipeline, 0, 5, TimeSpan.FromTicks(1));
                var paired    = primary.Pair(secondary, (p, s) => p * 10 + s).ToObservable().ToListObservable();
                var fused     = primary.Fuse(secondary, Available.Last <int>(), (p, s) => p * 10 + s).ToObservable().ToListObservable();
                pipeline.Run();

                var pairedResults = paired.AsEnumerable().ToArray();
                Assert.IsTrue(Enumerable.SequenceEqual(new[] { 04, 14, 24, 34, 44 }, pairedResults));

                var fusedResults = fused.AsEnumerable().ToArray();
                Assert.IsTrue(Enumerable.SequenceEqual(new[] { 04, 14, 24, 34, 44 }, fusedResults));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns the available grid point nearest to the supplied Vector3 point.
        /// </summary>
        /// <param name="point">The Vector3 point to compare.</param>
        /// <returns>
        /// A Vector3 point.
        /// </returns>
        public Vector3 AvailableNearTo(Vector3 point)
        {
            var x = Available.First().X;
            var y = Available.First().Y;

            foreach (Vector3 aPoint in Available)
            {
                var xDelta = Math.Abs(point.X - aPoint.X);
                var yDelta = Math.Abs(point.Y - aPoint.Y);
                if (xDelta <= Math.Abs(x - aPoint.X) ||
                    yDelta <= Math.Abs(y - aPoint.Y))
                {
                    x = aPoint.X;
                    y = aPoint.Y;
                }
            }
            return(new Vector3(x, y));
        }
Exemplo n.º 6
0
        public void PushEntry(WalletEntry entry, BlockType?blockType)
        {
            if (blockType == null && entry.Block != null)
            {
                throw new ArgumentException("An entry coming from a block should have a blocktype");
            }

            Unconfirmed.PushEntry(entry);
            if (entry.Type == WalletEntryType.Outcome)
            {
                Available.PushEntry(entry);
            }
            if (entry.Block != null && blockType == BlockType.Main)
            {
                Available.PushEntry(entry);
                Confirmed.PushEntry(entry);
            }
        }
Exemplo n.º 7
0
        public void PairDelayedSecondryWithInitialValueAndOutputCreator()
        {
            using (var pipeline = Pipeline.Create())
            {
                Generators.Range(pipeline, 0, 2, TimeSpan.FromSeconds(1)); // hold pipeline open
                var primary   = Generators.Range(pipeline, 0, 5, TimeSpan.FromTicks(1));
                var secondary = primary.Delay(TimeSpan.FromMilliseconds(100));
                var paired    = primary.Pair(secondary, (p, s) => p * 10 + s, 7).ToObservable().ToListObservable();
                var fused     = primary.Fuse(secondary, Available.LastOrDefault(7), (p, s) => p * 10 + s).ToObservable().ToListObservable();
                pipeline.Run();

                var pairedResults = paired.AsEnumerable().ToArray();
                Assert.IsTrue(Enumerable.SequenceEqual(new[] { 07, 17, 27, 37, 47 }, pairedResults));

                var fusedResults = fused.AsEnumerable().ToArray();
                Assert.IsTrue(Enumerable.SequenceEqual(new[] { 07, 17, 27, 37, 47 }, fusedResults));
            }
        }
Exemplo n.º 8
0
        public void PairDelayedSecondary()
        {
            using (var pipeline = Pipeline.Create())
            {
                Generators.Range(pipeline, 0, 2, TimeSpan.FromSeconds(1)); // hold pipeline open
                var primary   = Generators.Range(pipeline, 0, 5, TimeSpan.FromTicks(1));
                var secondary = Generators.Range(pipeline, 0, 5, TimeSpan.FromTicks(1)).Delay(TimeSpan.FromMilliseconds(100));
                var paired    = primary.Pair(secondary).ToObservable().ToListObservable();
                var fused     = primary.Fuse(secondary, Available.Last <int>()).ToObservable().ToListObservable();
                pipeline.Run();

                var pairedResults = paired.AsEnumerable().ToArray();
                Assert.IsTrue(Enumerable.SequenceEqual(new ValueTuple <int, int>[] { }, pairedResults));

                var fusedResults = fused.AsEnumerable().ToArray();
                Assert.IsTrue(Enumerable.SequenceEqual(new ValueTuple <int, int>[] { }, fusedResults));
            }
        }
Exemplo n.º 9
0
        string Answer(MessageEventArgs e, Available available)
        {
            using var db = new ApplicationContext();
            var user = db.Users.Where(u => u.UserId == e.Message.Chat.Id)
                       .Include(p => p.Products)
                       .FirstOrDefault();
            var result = String.Empty;

            if (user != null && user.Products.Count != 0)
            {
                var sortedEinumerable = available switch
                {
                    Available.all => from person in user.Products
                    orderby person.NameProduct
                    select person,

                    Available.available => from person in user.Products
                    where person.ProductIsNow == true
                    orderby person.NameProduct
                    select person,

                    Available.not_available => from person in user.Products
                    where person.ProductIsNow == false
                    orderby person.NameProduct
                    select person,

                    _ => throw new NotImplementedException()
                };

                result += $"Товаров {available} {sortedEinumerable.Count()} шт: \n\n";

                foreach (var product in sortedEinumerable)
                {
                    result += $"{product.NameProduct} - {product.PricePreviousBYN}р.\n"
                              + $"Подробней - /I{product.Artikul} \n\n";
                }
            }
            else
            {
                result = "Сначала добавьте товары";
            }

            return(result);
        }
Exemplo n.º 10
0
        async Task getAvailableHours(DateTime date)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://ec2-18-191-1-231.us-east-2.compute.amazonaws.com:5000/api/user/Available");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = "{\"day\":\"" + date.Date + "\"}";

                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                if (result.Contains("fail_invalid_day"))
                {
                    DisplayInvalidDay();
                    return;
                }
                JObject jObject = JObject.Parse(result);
                JToken  jToken  = jObject.GetValue("available");
                Available.Clear();
                var currentTime = DateTime.Now;
                foreach (var value in jToken.Values <int>())
                {
                    if (value + 1 == currentTime.Hour && currentTime.Minute <= 30)
                    {
                        Available.Add(value + ":00");
                    }
                    else if (value > currentTime.Hour && value != currentTime.Hour + 1)
                    {
                        Available.Add(value + ":00");
                    }
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes the camera.
        /// </summary>
        /// <returns>The camera.</returns>
        public void InitializeCamera()
        {
            try
            {
                NSError error;
                NSError err;

                _device.LockForConfiguration(out err);
                _device.FocusMode = AVCaptureFocusMode.ContinuousAutoFocus;
                _device.UnlockForConfiguration();

                _input = new AVCaptureDeviceInput(_device, out error);
                _captureSession.AddInput(_input);

                _output = new AVCaptureStillImageOutput();

                var dict = new NSMutableDictionary();
                dict[AVVideo.CodecKey] = new NSNumber((int)AVVideoCodec.JPEG);
                _captureSession.AddOutput(_output);

                InvokeOnMainThread(delegate
                {
                    // capture connection used for rotating camera
                    _captureConnection = _previewLayer.Connection;
                    SetStartOrientation();
                    // set orientation before loading camera
                    _captureSession.StartRunning();
                });
            }
            catch (Exception error)
            {
                _log.WriteLineTime(_tag + "\n" +
                                   "InitializeCamera() Camera failed to initialise \n " +
                                   "ErrorMessage: \n" +
                                   error.Message + "\n" +
                                   "Stacktrace: \n " +
                                   error.StackTrace);
            }

            Available?.Invoke(this, _cameraAvailable);

            _log.WriteLineTime(_tag + "\n" + "RetrieveCameraDevice() Camera initalised \n ");
        }
Exemplo n.º 12
0
        /// <summary>
        /// Returns the minimum available grid point.
        /// </summary>
        /// <returns>
        /// A Vector3 point.
        /// </returns>

        public Vector3 AvailableMin()
        {
            if (Available.Count == 0)
            {
                return(new Vector3(double.NaN, double.NaN, double.NaN));
            }
            var minX = Available.First().X;
            var minY = Available.First().Y;

            foreach (Vector3 point in Available)
            {
                if (point.X + point.Y < minX + minY)
                {
                    minX = point.X;
                    minY = point.Y;
                }
            }
            return(new Vector3(minX, minY));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Returns the maximum available grid point.
        /// </summary>
        /// <returns>
        /// A Vector3 point.
        /// </returns>
        public Vector3 AvailableMax()
        {
            if (Available.Count == 0)
            {
                return(new Vector3(double.NaN, double.NaN, double.NaN));
            }
            var maxX = Available.First().X;
            var maxY = Available.First().Y;

            foreach (Vector3 point in Available)
            {
                if (point.X + point.Y > maxX + maxY)
                {
                    maxX = point.X;
                    maxY = point.Y;
                }
            }
            return(new Vector3(maxX, maxY));
        }
Exemplo n.º 14
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                if (Available != default(long))
                {
                    hash = hash * 23 + Available.GetHashCode();
                }
                if (Total != default(long))
                {
                    hash = hash * 23 + Total.GetHashCode();
                }
                if (Currency != default(string))
                {
                    hash = hash * 23 + Currency.GetHashCode();
                }

                return(hash);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Allocates the points in the grid falling within or on the supplied Polygon.
        /// </summary>
        /// <param name="polygon">The Polygon bounding the points to be allocated.</param>
        /// <returns>
        /// None.
        /// </returns>
        public void Allocate(Polygon polygon)
        {
            var rmvPoints = new List <int>();
            var index     = 0;

            foreach (Vector3 point in Available)
            {
                if (polygon.Covers(point))
                {
                    rmvPoints.Add(index);
                    Allocated.Add(point);
                }
                index++;
            }
            rmvPoints.Reverse();
            foreach (int rmv in rmvPoints)
            {
                Available.RemoveAt(rmv);
            }
        }
Exemplo n.º 16
0
        public bool Avail(TaxiPosition taxiPosition)
        {
            try
            {
                Available av = new Available();

                av.ID         = taxiPosition.ID;
                av.td         = taxiPosition.td;
                av.No         = taxiPosition.No;
                av.DriverName = taxiPosition.DriverName;
                av.Week       = taxiPosition.Week;
                av.RoutePrice = av.SelectPrice();
                db.Availables.Add(av);
                //  db.TaxiPosition.Remove(taxiPosition);
                db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            { return(false); }
        }
Exemplo n.º 17
0
        public void testAvailableComponent()
        {
            var vcal = Environment.NewLine
                       + "BEGIN:VCALENDAR" + Environment.NewLine
                       + "BEGIN:AVAILABLE" + Environment.NewLine
                       + "END:AVAILABLE" + Environment.NewLine
                       + "END:VCALENDAR" + Environment.NewLine;
            var       document = Sabre.VObject.Reader.read(ContextExtensions.CurrentContext, vcal);
            var       children = ((VCalendar)document.Object).children().Array;
            Available AvaObj   = null;

            foreach (var o in children.Values)
            {
                if (o.Object.GetType() == typeof(Available))
                {
                    AvaObj = (Available)o.Object;
                    break;
                }
            }

            Assert.IsInstanceOf(typeof(Available), AvaObj);
        }
Exemplo n.º 18
0
        public void PizzaTest()
        {
            var whitePizzas = new Available(new WhitePizza(), 3);
            var meatPizzas  = new Available(new MeatPizza(), 5);

            whitePizzas.OrderPizza("Luna");
            whitePizzas.OrderPizza("Mimi");
            whitePizzas.OrderPizza("Foma");
            whitePizzas.OrderPizza("Barley");

            meatPizzas.OrderPizza("Barley");
            meatPizzas.OrderPizza("Tonya");
            meatPizzas.OrderPizza("Anthony");
            meatPizzas.OrderPizza("Lindsay");
            meatPizzas.OrderPizza("Cameron");
            meatPizzas.OrderPizza("Linden");

            var whitePizzaOrders = whitePizzas.Display();
            var meatPizzaOrders  = meatPizzas.Display();

            var expectedWhitePizzaOrders = new[] {
                "Luna ordered white pizza",
                "Mimi ordered white pizza",
                "Foma ordered white pizza",
                "Barley was unable to order white pizza"
            };

            var expectedMeatPizzaOrders = new[] {
                "Barley ordered meat pizza",
                "Tonya ordered meat pizza",
                "Anthony ordered meat pizza",
                "Lindsay ordered meat pizza",
                "Cameron ordered meat pizza",
                "Linden was unable to order meat pizza"
            };

            whitePizzaOrders.Should().ContainAll(expectedWhitePizzaOrders);
            meatPizzaOrders.Should().ContainAll(expectedMeatPizzaOrders);
        }
Exemplo n.º 19
0
        private static void Main()
        {
            var salad = new Salad {
                Greens   = "Lettuce",
                Cheese   = "Parmesan",
                Dressing = "Caesar"
            };

            salad.Display();
            var pasta = new Pasta {
                PastaType = "Daily Pasta",
                Sauce     = "Alfredo"
            };

            pasta.Display();

            var saladAvailable =
                new Available {
                RestaurantDish = salad, NumberOfDishesAvailable = 3
            };
            var pastaAvailable =
                new Available {
                RestaurantDish = pasta, NumberOfDishesAvailable = 4
            };

            saladAvailable.OrderItem("Mike");
            saladAvailable.OrderItem("John");
            saladAvailable.OrderItem("Chris");

            pastaAvailable.OrderItem("Mariana");
            pastaAvailable.OrderItem("Jake");
            pastaAvailable.OrderItem("Constantin");
            pastaAvailable.OrderItem("Gabriela");
            pastaAvailable.OrderItem("Gunther");

            saladAvailable.DisplayDishAndWhoOrderedIt();
            pastaAvailable.DisplayDishAndWhoOrderedIt();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Allocates points in the grid falling within the supplied Polygons.
        /// </summary>
        /// <param name="polygon">The Polygon bounding the points to be allocated.</param>
        /// <returns>
        /// None.
        /// </returns>
        public void Allocate(IList <Polygon> polygons)
        {
            var rmvPoints = new List <int>();
            var index     = 0;
            var allocate  = new List <Vector3>();

            foreach (Vector3 point in Available)
            {
                foreach (Polygon polygon in polygons)
                {
                    if (polygon.Covers(point))
                    {
                        allocate.Add(point);
                    }
                    index++;
                }
            }
            foreach (Vector3 point in allocate)
            {
                Available.Remove(point);
                Allocated.Add(point);
            }
        }
Exemplo n.º 21
0
        public bool Reserve(Available avail)
        {
            Reserved reserve = new Reserved();


            var po = db.reserved.Where(n => n.TaxiDriver.TaxiNo == avail.TaxiDriver.TaxiNo).Select(n => n.Count).FirstOrDefault();

            if (po > 0)
            {
                po = db.reserved.Where(n => n.TaxiDriver.TaxiNo == avail.TaxiDriver.TaxiNo).Select(n => n.Count).Max();
            }
            else
            {
                po = 0;
            }
            var max = db.reserved.Where(n => n.TaxiDriver.TaxiNo == avail.TaxiDriver.TaxiNo).Select(n => n.Count).Max();

            try
            {
                reserve.ID         = avail.ID;
                reserve.td         = avail.td;
                reserve.No         = avail.No;
                reserve.DriverName = avail.DriverName;
                reserve.Week       = avail.Week;
                reserve.Count      = max + 1;

                db.reserved.Add(reserve);
                //data.available.Remove(avail);
                db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 22
0
 private void ProcessInputEndUpdate()
 {
     Uploadable.EndUpdate();
     Uploaded.EndUpdate();
     Available.EndUpdate();
 }
Exemplo n.º 23
0
 public override int GetHashCode()
 {
     return(Id.GetHashCode() ^ Available.GetHashCode() ^ Reason.GetHashCode());
 }
Exemplo n.º 24
0
 public override string ToString()
 {
     return(String.Format("{0} {1} age {2} sex {3} from {4} is available {5}.", FirstName, LastName, Age.ToString(), SexualIdentity, StateCode, Available.ToString()));
 }
Exemplo n.º 25
0
 public AvailableElement(string selector, IWebElement element, Available after)
 {
     _element = element;
     Selector = selector;
     _after = after;
 }
Exemplo n.º 26
0
        public void TupleCollapsingReversedPairWithoutInitialValue()
        {
            using (var pipeline = Pipeline.Create())
            {
                var range   = Generators.Range(pipeline, 0, 10, TimeSpan.FromMilliseconds(100));
                var sourceA = range.Select(x => $"A{x}");
                var sourceB = range.Select(x => $"B{x}");
                var sourceC = range.Select(x => $"C{x}");
                var sourceD = range.Select(x => $"D{x}");
                var sourceE = range.Select(x => $"E{x}");
                var sourceF = range.Select(x => $"F{x}");
                var sourceG = range.Select(x => $"G{x}");

                var pairedTuplesFG      = sourceF.Pair(sourceG);
                var pairedTuplesEFG     = sourceE.Pair(pairedTuplesFG);
                var pairedTuplesDEFG    = sourceD.Pair(pairedTuplesEFG);
                var pairedTuplesCDEFG   = sourceC.Pair(pairedTuplesDEFG);
                var pairedTuplesBCDEFG  = sourceB.Pair(pairedTuplesCDEFG);
                var pairedTuplesABCDEFG = sourceA.Pair(pairedTuplesBCDEFG);
                var pairedTuples        = pairedTuplesABCDEFG.ToObservable().ToListObservable();

                var fusedTuplesFG      = sourceF.Fuse(sourceG, Available.Last <string>());
                var fusedTuplesEFG     = sourceE.Fuse(fusedTuplesFG, Available.Last <(string, string)>());
                var fusedTuplesDEFG    = sourceD.Fuse(fusedTuplesEFG, Available.Last <(string, string, string)>());
                var fusedTuplesCDEFG   = sourceC.Fuse(fusedTuplesDEFG, Available.Last <(string, string, string, string)>());
                var fusedTuplesBCDEFG  = sourceB.Fuse(fusedTuplesCDEFG, Available.Last <(string, string, string, string, string)>());
                var fusedTuplesABCDEFG = sourceA.Fuse(fusedTuplesBCDEFG, Available.Last <(string, string, string, string, string, string)>());
                var fusedTuples        = fusedTuplesABCDEFG.ToObservable().ToListObservable();

                pipeline.Run();

                // cannot validate length as above because without initial value, it is non-deterministic
                var pairedResults = pairedTuples.AsEnumerable().ToArray();

                // can't really validate content ordering as with Join because Pair is inherently non-deterministic
                foreach (var r in pairedResults)
                {
                    Assert.IsTrue(r.Item1.StartsWith("A"));
                    Assert.IsTrue(r.Item2.StartsWith("B"));
                    Assert.IsTrue(r.Item3.StartsWith("C"));
                    Assert.IsTrue(r.Item4.StartsWith("D"));
                    Assert.IsTrue(r.Item5.StartsWith("E"));
                    Assert.IsTrue(r.Item6.StartsWith("F"));
                    Assert.IsTrue(r.Item7.StartsWith("G"));
                }

                // cannot validate length as above because without initial value, it is non-deterministic
                var fusedResults = fusedTuples.AsEnumerable().ToArray();

                // can't really validate content ordering as with Join because Pair is inherently non-deterministic
                foreach (var r in fusedResults)
                {
                    Assert.IsTrue(r.Item1.StartsWith("A"));
                    Assert.IsTrue(r.Item2.StartsWith("B"));
                    Assert.IsTrue(r.Item3.StartsWith("C"));
                    Assert.IsTrue(r.Item4.StartsWith("D"));
                    Assert.IsTrue(r.Item5.StartsWith("E"));
                    Assert.IsTrue(r.Item6.StartsWith("F"));
                    Assert.IsTrue(r.Item7.StartsWith("G"));
                }
            }
        }
Exemplo n.º 27
0
        public void TupleCollapsingPairWithInitialValue()
        {
            using (var pipeline = Pipeline.Create())
            {
                var range   = Generators.Range(pipeline, 0, 10, TimeSpan.FromMilliseconds(100));
                var sourceA = range.Select(x => $"A{x}");
                var sourceB = range.Select(x => $"B{x}");
                var sourceC = range.Select(x => $"C{x}");
                var sourceD = range.Select(x => $"D{x}");
                var sourceE = range.Select(x => $"E{x}");
                var sourceF = range.Select(x => $"F{x}");
                var sourceG = range.Select(x => $"G{x}");

                var pairedTuples = // expecting tuple flattening
                                   sourceA
                                   .Pair(sourceB, "B?")
                                   .Pair(sourceC, "C?")
                                   .Pair(sourceD, "D?")
                                   .Pair(sourceE, "E?")
                                   .Pair(sourceF, "F?")
                                   .Pair(sourceG, "G?")
                                   .ToObservable().ToListObservable();

                var fusedTuples = // expecting tuple flattening
                                  sourceA
                                  .Fuse(sourceB, Available.LastOrDefault("B?"))
                                  .Fuse(sourceC, Available.LastOrDefault("C?"))
                                  .Fuse(sourceD, Available.LastOrDefault("D?"))
                                  .Fuse(sourceE, Available.LastOrDefault("E?"))
                                  .Fuse(sourceF, Available.LastOrDefault("F?"))
                                  .Fuse(sourceG, Available.LastOrDefault("G?"))
                                  .ToObservable().ToListObservable();
                pipeline.Run();

                var pairedResults = pairedTuples.AsEnumerable().ToArray();

                Assert.AreEqual(10, pairedResults.Length);

                // can't really validate content ordering as with Join because Pair is inherently non-deterministic
                foreach (var r in pairedResults)
                {
                    Assert.IsTrue(r.Item1.StartsWith("A"));
                    Assert.IsTrue(r.Item2.StartsWith("B"));
                    Assert.IsTrue(r.Item3.StartsWith("C"));
                    Assert.IsTrue(r.Item4.StartsWith("D"));
                    Assert.IsTrue(r.Item5.StartsWith("E"));
                    Assert.IsTrue(r.Item6.StartsWith("F"));
                    Assert.IsTrue(r.Item7.StartsWith("G"));
                }

                var fusedResults = fusedTuples.AsEnumerable().ToArray();

                Assert.AreEqual(10, fusedResults.Length);

                // can't really validate content ordering as with Join because Fuse is inherently non-deterministic
                foreach (var r in fusedResults)
                {
                    Assert.IsTrue(r.Item1.StartsWith("A"));
                    Assert.IsTrue(r.Item2.StartsWith("B"));
                    Assert.IsTrue(r.Item3.StartsWith("C"));
                    Assert.IsTrue(r.Item4.StartsWith("D"));
                    Assert.IsTrue(r.Item5.StartsWith("E"));
                    Assert.IsTrue(r.Item6.StartsWith("F"));
                    Assert.IsTrue(r.Item7.StartsWith("G"));
                }
            }
        }
Exemplo n.º 28
0
 /// <summary>
 /// Notifies the available.
 /// </summary>
 /// <param name="isAvailable">If set to <c>true</c> is available.</param>
 public void NotifyAvailable(bool isAvailable)
 {
     Available?.Invoke(this, isAvailable);
 }
Exemplo n.º 29
0
 public void SetWebElement(string selector, IWebElement element, Available after = Available.Immediately)
 {
     _availableElements.Add(new AvailableElement(selector, element, after));
 }
Exemplo n.º 30
0
        private static void SetInvAvailability(int EventId, Available avlType)
        {
            // create our NHibernate session factory
            var sessionFactory = FluentNHibernate.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                // retreive all stores and display them
                using (session.BeginTransaction())
                {
                    events evt = session.Load<events>(EventId);

                    IList<order> ordList = evt.orderList.ToList();

                    if (ordList.Count == 0)
                    {
                        session.Close();
                        return;
                    }

                    var MaxDate = evt.checkIn; // ordList.Max(x => x.checkin);

                    var MinDate = evt.checkOut; // ordList.Min(x => x.checkout);

                    if (avlType == Available.Red)
                    {
                        MaxDate = evt.eventDate; MinDate = evt.eventDate;
                    }

                    DateTime dMax = Convert.ToDateTime(MaxDate);

                    DateTime dMin = Convert.ToDateTime(MinDate);

                    IList<order> ord = session.CreateCriteria(typeof(order)).List<order>();

                    IList<inventory> inv = session.CreateCriteria(typeof(inventory)).List<inventory>();

                    IList<bom> bom = session.CreateCriteria(typeof(bom)).List<bom>();

                    IList<loadlist> tmp = session.CreateCriteria(typeof(loadlist)).List<loadlist>();

                    TimeSpan DaysDiff = dMin - dMax;

                    int Days = 1;

                    if (DaysDiff.Days > 0) { Days = DaysDiff.Days; }

                    DateTime[] myDate = new DateTime[Days];

                    myDate[0] = dMin;

                    for (int i = 1; i < DaysDiff.Days; i++)
                    {
                        myDate[i] = dMin.AddDays(i);
                    }

                    IList<compOrdInv> CompQty = (from o in ord
                                                 join b in bom on o.item equals b.item
                                                 join i in inv on b.component equals i.item
                                                 from d in myDate
                                                 where  d >= o.orderEvent.checkOut
                                                        && d <= o.orderEvent.checkIn
                                                        && avlType==Available.Yellow
                                                 || d.ToShortDateString() == o.orderEvent.eventDate.ToShortDateString()
                                                        && avlType == Available.Red
                                                 select new compOrdInv
                                                 {
                                                     myDate = d
                                                     ,
                                                     item = b.component
                                                     ,
                                                     InvQty = i.qty
                                                     ,
                                                     ordQty = o.orderQty
                                                     ,
                                                     extQty = b.qty * o.orderQty
                                                 })
                                        .ToList();

                    IList<compOrdInv> Short = (from s in CompQty
                                               group s by new { s.myDate, s.item, s.InvQty }
                                                   into g
                                                   where g.Key.InvQty - g.Sum(x => x.extQty) < 0
                                                   select new compOrdInv
                                                   {
                                                       myDate = g.Key.myDate
                                                       ,
                                                       item = g.Key.item
                                                       ,
                                                       InvQty = g.Key.InvQty
                                                       ,
                                                       extQty = g.Sum(x => x.extQty)
                                                       ,
                                                       avl = g.Key.InvQty - g.Sum(x => x.extQty)
                                                   }).ToList();

                    IList<order> ordAffected = (from o in ord
                                                 join b in bom on o.item equals b.item
                                                 join s in Short on b.component equals s.item
                                                 join ol in ordList on o.id equals ol.id
                                                 where s.myDate >= o.checkout
                                                 && s.myDate <= o.checkin
                                                 select o
                            ).ToList();

                    if (avlType == Available.Yellow)
                    {
                        foreach (order o in ordList)
                        {

                            o.available = (int)Available.Green;
                            o.orderEvent.available = (int)Available.Green;
                            session.SaveOrUpdate(o.orderEvent);
                        }
                    }

                    foreach (order o in ordAffected)
                    {
                        o.available = (int)avlType;
                        o.orderEvent.available = (int)avlType;
                        session.SaveOrUpdate(o);
                        session.SaveOrUpdate(o.orderEvent);
                    }

                    session.Transaction.Commit();

                    session.Close();

                }
            }
        }
Exemplo n.º 31
0
 public void Then_available_amount_should_be_set()
 {
     SUT.Snapshot.Available.ShouldBeGreaterThan(Available.FromDecimal(0m));
 }
Exemplo n.º 32
0
 public void Then_available_amount_should_equal_zero()
 {
     SUT.Snapshot.Available.ShouldEqual(Available.FromDecimal(0m));
 }
Exemplo n.º 33
0
 public void Then_available_amount_should_be_correct()
 {
     SUT.Snapshot.Available.ShouldEqual(Available.FromDecimal(20m));
 }