Esempio n. 1
0
        static void Main(string[] args)
        {
            var  rnd = new Random();
            long carId, empId;

            carId = empId = rnd.Next();

            IdentifierFor <Employee> employeeIdentifier = (empId);

            employeeIdentifier = (Guid.NewGuid());

            var carIdentifier = new IdentifierFor <Car>(carId);

            var carwash = new Carwash();

            carwash.Hire(employeeIdentifier);

            carwash.Assign(empId, carId);
            carwash.Assign(carId, empId);

            Console.WriteLine(employeeIdentifier);
            Console.WriteLine((long)employeeIdentifier);

            Console.WriteLine(carIdentifier);
            Console.WriteLine((long)carIdentifier);

            Console.WriteLine(employeeIdentifier.Equals(employeeIdentifier));

            Console.WriteLine(employeeIdentifier.Equals(carIdentifier));

            Console.WriteLine(employeeIdentifier == employeeIdentifier);

            // Console.ReadLine();
        }
Esempio n. 2
0
        public List <Carwash> GetCarwashCategories()
        {
            List <Carwash> olist = new List <Carwash>();
            Carwash        cw;

            try
            {
                string sSQL = "SELECT UnitId, [Category] FROM [CSCAdmin].[dbo].[Carwash]  "
                              + "order by  UnitId";
                var dt = GetRecords(sSQL, DataSource.CSCAdmin);
                if (dt == null || dt.Rows.Count == 0)
                {
                    return(olist);
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    cw          = new Carwash();
                    cw.UnitId   = int.Parse(dt.Rows[i][0].ToString());
                    cw.Category = dt.Rows[i][1].ToString();
                    olist.Add(cw);
                }
            }
            catch (Exception ex)
            {
                _performancelog.Error("AckrooService.GetCarwashCategories(): " + ex.Message);
            }
            return(olist);
        }
        public static byte[] GetStatistics(byte[] key, byte[] iv, int carwashId)
        {
            AesEncryption aes        = new AesEncryption();
            Statistics    statistics = new Statistics();
            Carwash       carwash    = CarwashRepository.GetCarwash(carwashId);

            statistics.TotalWashes = carwash.Washes.Count;

            foreach (Wash wash in carwash.Washes)
            {
                if (wash is BasicWash)
                {
                    statistics.BasicWashes++;
                }
                if (wash is SilverWash)
                {
                    statistics.SilverWashes++;
                }
                if (wash is GoldWash)
                {
                    statistics.GoldWashes++;
                }
            }

            string json = JsonHelper.SerializeJson <Statistics>(statistics);

            return(aes.Encrypt(json, key, iv));
        }
        private void btn_DeleteCarwash_Click(object sender, EventArgs e)
        {
            Carwash carwash = (Carwash)combo_Carwashes.SelectedItem;

            if (CarwashRepository.DeleteCarwash(carwash.Name))
            {
                UpdateComboCarwashes();
            }
        }
        private async void btn_GoToCarwash_Click(object sender, EventArgs e)
        {
            string  carwashName = combo_Carwashes.Text;
            Carwash carwash     = await CarwashRepository.GetCarwashByNameAsync(carwashName);

            CarwashForm form = new CarwashForm(carwash.Id);

            form.Show();
            this.Hide();
        }
Esempio n. 6
0
        public static Carwash NewCarwash(string name)
        {
            if (Carwashes.Any(c => c.Name == name))
            {
                return(null);
            }

            int id = 0;

            if (Carwashes.Count > 0)
            {
                id = Carwashes.Max(c => c.Id) + 1;
            }

            Carwash carwash = new Carwash()
            {
                Id   = id,
                Name = name
            };

            Carwashes.Add(carwash);
            return(carwash);
        }
Esempio n. 7
0
        private void DisplayWashes()
        {
            flowpanel_Washes.FlowDirection = FlowDirection.TopDown;

            // Gets current washes where car is not collected
            Carwash     carwash = CarwashRepository.GetCarwash(_carwashId);
            List <Wash> washes  = carwash.Washes
                                  .Where(w => w.Car.IsCollected == false)
                                  .ToList();

            // Handles the layout
            foreach (Wash wash in washes)
            {
                FlowLayoutPanel panelUpper = new FlowLayoutPanel();
                panelUpper.AutoSize = true;
                panelUpper.Height   = 15;

                Label carName = new Label();
                carName.Text     = $"{wash.GetType().Name}: {wash.Car.Name} {wash.Car.CarPlate}";
                carName.AutoSize = true;

                Label carStatus = new Label();
                carStatus.Text = Enum.GetName(typeof(CarStatus), wash.Car.CarStatus);

                // Adds the labels to panelUpper
                panelUpper.Controls.Add(carName);
                panelUpper.Controls.Add(carStatus);

                FlowLayoutPanel panelLower = new FlowLayoutPanel();
                panelLower.AutoSize = true;
                panelLower.Height   = 25;
                panelLower.Margin   = new Padding(0, 0, 0, 20);

                ProgressBar progressBar = new ProgressBar();
                progressBar.Minimum = 0;
                progressBar.Maximum = 100;
                progressBar.Width   = 150;
                progressBar.Value   = wash.Progress;

                Button button = new Button();
                button.Text   = "Cancel";
                button.Click += Cancel_Clicked;
                button.Name   = wash.Id.ToString();

                Button collect = new Button();
                collect.Text    = "Collect";
                collect.Click  += btn_Collect;
                collect.Name    = wash.Id.ToString();
                collect.Enabled = (wash.Progress == 100) ? true : false;

                // Adds the progressbar and button to the panelLower
                panelLower.Controls.Add(button);
                panelLower.Controls.Add(progressBar);
                panelLower.Controls.Add(collect);

                // Adds the panels to the flowpanel
                flowpanel_Washes.Controls.Add(panelUpper);
                flowpanel_Washes.Controls.Add(panelLower);

                wash.OnProgressChange += (int progress) =>
                {
                    uiCtx.Send(_ => progressBar.Value = progress, null);
                };

                wash.Car.OnCarStatusChanged += (CarStatus carstatus) =>
                {
                    uiCtx.Send(_ => carStatus.Text = Enum.GetName(typeof(CarStatus), carstatus), null);

                    if (carstatus == CarStatus.Finished)
                    {
                        uiCtx.Send(_ => collect.Enabled = true, null);
                    }
                    else if (carstatus == CarStatus.Collected)
                    {
                        uiCtx.Send(_ => panelUpper.Controls.Clear(), null);
                        uiCtx.Send(_ => panelLower.Controls.Clear(), null);
                    }
                };
            }
        }
Esempio n. 8
0
        public static void AddWash(int carwashId, Wash wash)
        {
            Carwash carwash = GetCarwash(carwashId);

            carwash.Washes.Add(wash);
        }