Esempio n. 1
0
        // Méthode de récupération de l'ID d'un technicien
        private static int SelectIDTechnical(C_Technical tech = null, string usn = null)
        {
            Technical tech1 = null;

            try
            {
                if (tech != null)
                {
                    tech1 = db.Technicals.Single(t => t.User.Usn == tech.Username);
                }
                else if (usn != null)
                {
                    tech1 = db.Technicals.Single(t => t.User.Usn == usn);
                }
                else
                {
                    new Exception("Pas de variables passées");
                }
                return(tech1.ID);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        // Save Employee Technical Details
        public string SaveEmployeeTechnicalDetails(Technical technicalObj)
        {
            try
            {
                string returnVaue;
                sqlConnection          = OpenConnection();
                sqlCommand             = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "uspSaveEmployeeTechnicalDetails";

                sqlCommand.Parameters.Add("@EmployeeID", SqlDbType.VarChar).Value           = technicalObj.EmployeeID;
                sqlCommand.Parameters.Add("@ProgrammingLanguages", SqlDbType.VarChar).Value = technicalObj.ProgrammingLanguages;
                sqlCommand.Parameters.Add("@DatabasesKnown", SqlDbType.VarChar).Value       = technicalObj.DatabasesKnown;
                sqlCommand.Parameters.Add("@ORMTechnologies", SqlDbType.VarChar).Value      = technicalObj.ORMTechnologies;
                sqlCommand.Parameters.Add("@UITechnologies", SqlDbType.VarChar).Value       = technicalObj.UITechnologies;

                returnVaue = sqlCommand.ExecuteNonQuery().ToString();

                sqlCommand.Dispose();
                return(returnVaue);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            finally
            {
                CloseConnection(sqlConnection);
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("TechnicalID,AeroRating,EngineSupplier,ChassisRating,TeamBudget")] Technical technical)
        {
            if (id != technical.TechnicalID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(technical);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TechnicalExists(technical.TechnicalID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(technical));
        }
 private void EmployeeDetails_Load(object sender, EventArgs e)
 {
     EmployeeObj    = new Employee();
     CompanyObj     = new Company();
     ProjectObj     = new Project();
     TechnicalObj   = new Technical();
     EducationalObj = new Educational();
 }
Esempio n. 5
0
 /// <summary>
 /// Functions searches previous scans and adds current scan there or if it can't tries to add it for today
 /// </summary>
 /// <param name="response"></param>
 /// <param name="techEntry"></param>
 /// <param name="sc"></param>
 /// <param name="dostawaEntry"></param>
 /// <returns></returns>
 public bool CheckBackOrAdd(ScannedResponse response, Technical techEntry, ScannedCode sc, Dostawa dostawaEntry)
 {
     if (!SearchBack(techEntry, sc, dostawaEntry))
     {
         return(AddOrCreateNewSet(response, techEntry, sc, dostawaEntry));
     }
     return(true);
 }
Esempio n. 6
0
    private void RandomObstaclePosition()
    {
        Technical.Shuffle(startPositions);

        for (int i = 0; i < obstacleTransforms.Length; i++)
        {
            obstacleTransforms[i].position = startPositions[i];
        }
    }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("TechnicalID,AeroRating,EngineSupplier,ChassisRating,TeamBudget")] Technical technical)
        {
            if (ModelState.IsValid)
            {
                _context.Add(technical);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(technical));
        }
Esempio n. 8
0
 public void SetTechnicalFlag(Technical flag, bool isSet)
 {
     if (isSet)
     {
         TechnicalFlags |= flag;
     }
     else
     {
         TechnicalFlags &= ~flag;
     }
 }
Esempio n. 9
0
 private void Awake()
 {
     if (!Instance)
     {
         Instance = this;
     }
     else
     {
         DestroyImmediate(this.gameObject);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Tries to add current scan as a whole
        /// </summary>
        /// <param name="response"></param>
        /// <param name="techEntry"></param>
        /// <param name="sc"></param>
        /// <param name="dostawaEntry"></param>
        /// <returns></returns>
        public bool AddOrCreateNewSet(ScannedResponse response, Technical techEntry, ScannedCode sc, Dostawa dostawaEntry)
        {
            VTMagazyn VT = ExistsInVT(sc);

            if (VT == null && !sc.addedBefore)
            {
                // If no instance of this scan exists
                AddToVT(techEntry, sc, dostawaEntry);
            }
            else if (VT == null && sc.addedBefore)
            {
                if (sc.isForcedInsert)
                {
                    // If instance of this code have been added to previous scans
                    AddToVT(techEntry, sc, dostawaEntry);
                }
                else
                {
                    response.Header = HeaderTypes.error;
                    response.Flag   = FlagType.codeExistsBack;
                    return(false);
                }
            }
            else
            {
                if (sc.isForcedInsert)
                {
                    var deliveriesForToday = _db.Dostawa.AsNoTracking().Include(c => c.Technical)
                                             .Where(c => c.Technical.Wiazka == sc.Wiazka && c.Data.Date == sc.dataDostawyOld.Date).ToList();
                    var VTList = new List <VTMagazyn>();
                    VTList.Add(VT);
                    // ?
                    // If instance of this scan have been added for todays delivery
                    if (VT.SztukiZeskanowane < GetPossibleDeclaredValue(sc, VTList, deliveriesForToday))
                    {
                        return(AddQuantityIncorrect(deliveriesForToday, response, techEntry, sc, dostawaEntry));
                    }
                    else
                    {
                        AddToVT(techEntry, sc, dostawaEntry, true);
                    }
                }
                else
                {
                    response.Header = HeaderTypes.error;
                    response.Flag   = FlagType.codeExists;
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 11
0
    private void Start()
    {
        colorType = (ColorType)Random.Range(0, Technical.EnumCount <ColorType>());
        var main = particleSystem.main;

        switch (colorType)
        {
        case ColorType.Green:
            main.startColor = Color.green;
            break;

        case ColorType.Red:
            main.startColor = Color.red;
            break;

        case ColorType.Yellow:
            main.startColor = Color.yellow;
            break;
        }
    }
Esempio n. 12
0
        public async Task <IActionResult> Create(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await CreateUserAsync(model);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "Este Email ya está en uso.");
                    return(View(model));
                }

                var technical = new Technical
                {
                    Visits = new List <Visit>(),
                    User   = user,
                };

                _dataContext.Technicals.Add(technical);
                await _dataContext.SaveChangesAsync();

                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "MyApp - Email confirmation", $"<h1>MyApp - Email Confirmation</h1>" +
                                     $"Para autorizar el Usuario, " +
                                     $"por favor haga clic en este link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");



                return(RedirectToAction(nameof(Index)));
            }

            return(View(model));
        }
        // Get Technical Details Table Values
        public Technical GetTechnicalData(string employeeID)
        {
            try
            {
                sqlConnection = OpenConnection();
                Technical employeeTechnical = new Technical();
                sqlCommand             = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "uspGetEmployeeTechnicalDetails";

                sqlCommand.Parameters.Add("EmployeeID", SqlDbType.Int).Value = Convert.ToInt32(employeeID);

                SqlDataReader technicalDetailsReader = sqlCommand.ExecuteReader();

                while (technicalDetailsReader.Read())
                {
                    employeeTechnical.EmployeeID           = technicalDetailsReader.GetInt32(technicalDetailsReader.GetOrdinal("EmployeeID"));
                    employeeTechnical.ProgrammingLanguages = technicalDetailsReader.GetString(technicalDetailsReader.GetOrdinal("ProgrammingLanguages"));
                    employeeTechnical.DatabasesKnown       = technicalDetailsReader.GetString(technicalDetailsReader.GetOrdinal("DatabasesKnown"));
                    employeeTechnical.ORMTechnologies      = technicalDetailsReader.GetString(technicalDetailsReader.GetOrdinal("ORMTechnologies"));
                    employeeTechnical.UITechnologies       = technicalDetailsReader.GetString(technicalDetailsReader.GetOrdinal("UITechnologies"));
                }
                technicalDetailsReader.Close();
                return(employeeTechnical);
            }
            catch (Exception)
            {
                // Logging goes here
                throw;
            }
            finally
            {
                CloseConnection(sqlConnection);
            }
        }
Esempio n. 14
0
        public async Task <IActionResult> Register(AddUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                var role = "Technical";
                if (model.RoleId == 1)
                {
                    role = "Company";
                }

                var user = await _userHelper.AddUser(model, role);

                if (user == null)
                {
                    ModelState.AddModelError(string.Empty, "Este Email ya está en uso.");
                    return(View(model));
                }

                if (model.RoleId == 1)
                {
                    var company = new Company
                    {
                        //Contracts = new List<Contract>(),
                        User = user
                    };

                    _dataContext.Companies.Add(company);
                }
                else
                {
                    var technical = new Technical
                    {
                        //VisitDetails = new List<VisitDetail>(),
                        Visits = new List <Visit>(),
                        User   = user
                    };

                    _dataContext.Technicals.Add(technical);
                }
                await _dataContext.SaveChangesAsync();

                //var loginViewModel = new LoginViewModel
                //{
                //    Password = model.Password,
                //    RememberMe = false,
                //    Username = model.Username
                //};

                //var result2 = await _userHelper.LoginAsync(loginViewModel);

                //if (result2.Succeeded)
                //{
                //    return RedirectToAction("Index", "Home");
                //}
                var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                var tokenLink = Url.Action("ConfirmEmail", "Account", new
                {
                    userid = user.Id,
                    token  = myToken
                }, protocol: HttpContext.Request.Scheme);

                _mailHelper.SendMail(model.Username, "MyApp - Email confirmation", $"<h1>MyApp - Email Confirmation</h1>" +
                                     $"Para permitir el Usuario, " +
                                     $"por favor haga clic en este link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>");
                ViewBag.Message = "Las instrucciones para habilitar su usuario han sido enviadas por mail.";
                return(View(model));
            }
            model.Roles = _combosHelper.GetComboRoles();
            return(View(model));
        }
Esempio n. 15
0
        /// <summary>
        /// Browse old scans in hope to find somewhere to add current scan to
        /// </summary>
        /// <param name="technical"></param>
        /// <param name="scanned"></param>
        /// <param name="dostawa"></param>
        /// <returns></returns>
        public bool SearchBack(Technical technical, ScannedCode scanned, Dostawa dostawa)
        {
            if (!scanned.isLookingBack || _scanCache.LookedBack == true)
            {
                return(false);
            }

            // Find all scans between dates
            var pastScans = _db.VTMagazyn.Include(c => c.Dostawy).Where(c =>
                                                                        c.Wiazka == scanned.Wiazka &&
                                                                        c.DataDostawy.Date < scanned.dataDostawy.Date &&
                                                                        c.autocompleteEnabled == true &&
                                                                        c.DataDostawy.Date >= scanned.dataDostawy.Date.AddDays(-7))
                            .OrderBy(c => c.DataDostawy).ToList().GroupBy(c => c.DataDostawy).Select(g => g.ToList()).ToList();

            var pastDeliveries = _db.Dostawa.AsNoTracking().Include(c => c.Technical)
                                 .Where(c => c.Technical.Wiazka == scanned.Wiazka &&
                                        c.Data.Date <scanned.dataDostawy.Date &&
                                                     c.Data.Date> scanned.dataDostawy.Date.AddDays(-7)).ToList();

            foreach (var scanPerDate in pastScans)
            {
                // Look if there are any duplicate scans (multiple sets)
                var duplicateScans    = scanPerDate.Where(c => c.KodCiety == scanned.kodCiety).OrderBy(c => c.NumerKompletu).ToList();
                int mostFrequentCount = 0;

                if (duplicateScans.Count > 0)
                {
                    foreach (var scan in duplicateScans)
                    {
                        mostFrequentCount = GetPossibleDeclaredValue(new ScannedCode {
                            Wiazka = scan.Wiazka, dataDostawyOld = scan.DataDostawy
                        }, scanPerDate, pastDeliveries, scan.NumerKompletu);

                        // If this scan have already been added set flags and notify user
                        if (scan.DataDopisu != null &&
                            ((DateTime)scan.DataDopisu).Date == scanned.dataDostawy.Date &&
                            !scanned.isForcedInsert)
                        {
                            scanned.addedBefore = true;
                            return(false);
                        }

                        // Check if we can add current scan to previous one
                        if (scan.SztukiZeskanowane + scanned.sztukiSkanowane == mostFrequentCount &&
                            scan.SztukiZeskanowane != mostFrequentCount)
                        {
                            scan.SztukiZeskanowane += scanned.sztukiSkanowane;
                            scan.DataDopisu         = scanned.dataDostawy;
                            scan.DopisanaIlosc      = scanned.sztukiSkanowane;
                            scan.DostawaDopis       = scanned.DokDostawy;
                            scanned.dataDostawyOld  = scan.DataDostawy;
                            if (dostawa != null)
                            {
                                UpdateVT(dostawa, scan);
                            }
                            _db.Update(scan);
                            _db.SaveChanges();

                            return(true);
                        }
                    }

                    // Check if any set is missing current scan
                    int[] setIDs = scanPerDate.Where(c => c.Komplet == false).Select(c => c.NumerKompletu).Distinct().ToArray();
                    foreach (int setID in setIDs)
                    {
                        mostFrequentCount = GetPossibleDeclaredValue(new ScannedCode {
                            Wiazka = scanned.Wiazka, dataDostawyOld = scanPerDate[0].DataDostawy
                        }, scanPerDate, pastDeliveries, setID);
                        // Only add on the previous date if "declared" value is the same as scanned
                        if (scanned.sztukiSkanowane == mostFrequentCount && duplicateScans.Where(c => c.NumerKompletu == setID).Select(c => c.KodCiety).FirstOrDefault() != scanned.kodCiety)
                        {
                            scanned.DataDopisu     = scanned.dataDostawy;
                            scanned.DopisanaIlosc  = scanned.sztukiSkanowane;
                            scanned.dataDostawyOld = scanPerDate[0].DataDostawy;
                            scanned.DostawaDopis   = scanned.DokDostawy;
                            AddToVT(technical, scanned, dostawa, true);
                            return(true);
                        }
                    }
                }
                else
                {
                    mostFrequentCount = GetPossibleDeclaredValue(new ScannedCode {
                        Wiazka = scanned.Wiazka, dataDostawyOld = scanPerDate[0].DataDostawy
                    }, scanPerDate, pastDeliveries, 0);
                    // Only add on the previous date if "declared" value is the same as scanned
                    if (scanned.sztukiSkanowane == mostFrequentCount)
                    {
                        scanned.DataDopisu     = scanned.dataDostawy;
                        scanned.DopisanaIlosc  = scanned.sztukiSkanowane;
                        scanned.dataDostawyOld = scanPerDate[0].DataDostawy;
                        scanned.DostawaDopis   = scanned.DokDostawy;
                        AddToVT(technical, scanned, dostawa);
                        return(true);
                    }
                }
            }

            _scanCache.LookedBack = true;
            _db.Update(_scanCache);
            _db.SaveChanges();
            return(false);
        }
 public void click()
 {
     Technical.Focus();
     Technical.Click();
     Technical.Click();
 }
Esempio n. 17
0
        /// <summary>
        /// Adds scan to the database
        /// </summary>
        /// <param name="technical"></param>
        /// <param name="scanned"></param>
        /// <param name="dostawa"></param>
        /// <param name="newCmplt">Does it need to create new set</param>
        public void AddToVT(Technical technical, ScannedCode scanned, Dostawa dostawa, bool newCmplt = false)
        {
            if (dostawa != null && dostawa.Uwagi != "")
            {
                scanned.complete = true;
            }

            // Set proper set ID depending which set ID is missing
            if (!newCmplt)
            {
                scanned.NumerKompletu = 0;
            }
            else
            {
                int nextKpl    = 0;
                var SetNumbers = GetCompleteID(scanned);
                foreach (var kplNumber in SetNumbers)
                {
                    if (nextKpl != kplNumber)
                    {
                        break;
                    }
                    nextKpl++;
                }

                scanned.NumerKompletu = nextKpl;
            }



            VtToDostawa vtToDostawa = new VtToDostawa();

            vtToDostawa.Dostawa = dostawa;

            VTMagazyn vt = new VTMagazyn
            {
                NumerKompletu       = scanned.NumerKompletu,
                SztukiZeskanowane   = scanned.sztukiSkanowane,
                SztukiDeklarowane   = 0,
                Wiazka              = technical.Wiazka,
                KodCiety            = technical.PrzewodCiety,
                Pracownik           = scanned.User,
                DokDostawy          = scanned.DokDostawy,
                DataUtworzenia      = scanned.dataUtworzenia,
                DataDostawy         = scanned.dataDostawyOld == DateTime.MinValue ? scanned.dataDostawy : scanned.dataDostawyOld,
                Komplet             = scanned.complete,
                Deklarowany         = scanned.Declared,
                DataDopisu          = scanned.DataDopisu,
                DostawaDopis        = scanned.DostawaDopis,
                DopisanaIlosc       = scanned.DopisanaIlosc,
                Uwagi               = scanned.Uwagi,
                autocompleteEnabled = true,
                wymuszonaIlosc      = false,
                Technical           = technical
            };

            vtToDostawa.VTMagazyn = vt;

            // Create a relation between Dostawa and VTMagazyn scan
            vt.Dostawy = new List <VtToDostawa>();
            if (dostawa != null)
            {
                vt.Dostawy.Add(vtToDostawa);
            }

            _db.VTMagazyn.Add(vt);
        }
Esempio n. 18
0
 public bool GetTechnicalFlag(Technical flag)
 {
     return((TechnicalFlags &= flag) == flag);
 }
Esempio n. 19
0
 public void Push()
 {
     Technical.Click();
 }
Esempio n. 20
0
        private void AssignOrderToTechnical(IApplicationBuilder builder)
        {
            //_provider = builder.ApplicationServices;
            var provider     = builder.ApplicationServices;
            var scopeFactory = provider.GetRequiredService <IServiceScopeFactory>();

            using (var scope = scopeFactory.CreateScope())
            {
                using (var _uow = scope.ServiceProvider.GetRequiredService <IUnitOfWork>())
                {
                    var Orders = new HashSet <Order>();
                    //Orders still in Ordered action state
                    var OrdersNotAccepted = _uow.OrderRepository.GetAll().Include(ent => ent.OrderService).Where(ent => ent.OrderService != null && ent.OrderTrackActionId == (int)EN_OrderActions.ordered);
                    //Orders no accepted with assigned time less than halh hour
                    var datetime = DateTime.Now;
                    //Orders not accepted but to wait

                    var OrderToWait = _uow.OrderTechnicalAssignmentRepository.GetAll().Where(ent => (datetime - ent.CreationDate).TotalMinutes < 30 && ent.status == (int)EN_OrderTechnicalAssignmentStatus.waitToAnswer).Select(ent => ent.OrderId);
                    Orders = OrdersNotAccepted.Where(ent => !OrderToWait.Contains(ent.Id)).ToHashSet();
                    var technical = new Technical();
                    foreach (var Order in Orders)
                    {
                        technical = _uow.TechnicalsRepository.GetAll().Where(ent => ent.ServiceId == Order.OrderService.ServiceId).OrderBy(ent => ent.LastAssignTime).FirstOrDefault();
                        if (technical != null)
                        {
                            OrderTechnicalAssignment ors = new OrderTechnicalAssignment();
                            ors.OrderId              = Order.Id;
                            ors.status               = (int)EN_OrderTechnicalAssignmentStatus.waitToAnswer;
                            ors.TechnicalUserId      = technical.UsersId;
                            technical.LastAssignTime = DateTime.Now;
                            //change technica last assign
                            _uow.TechnicalsRepository.Update(technical);
                            //change last technical assigned status
                            var last_assigned = _uow.OrderTechnicalAssignmentRepository.Get(ent => ent.OrderId == Order.Id && ent.status == (int)EN_OrderTechnicalAssignmentStatus.waitToAnswer);
                            if (last_assigned != null && last_assigned.status != (int)EN_OrderTechnicalAssignmentStatus.rejected)
                            {
                                last_assigned.status = (int)EN_OrderTechnicalAssignmentStatus.timedout;
                                _uow.OrderTechnicalAssignmentRepository.Update(last_assigned);
                                //Add notification to technical for not available order
                                Notification notification = new Notification();
                                notification.Text       = "Order With Code: " + Order.Code + " Not Available yet";
                                notification.ToUSer     = last_assigned.TechnicalUserId ?? 0;
                                notification.TypeOfUser = (int)EN_TypeUser.Technical;
                                _uow.NotificationRepository.Add(notification);
                            }
                            _uow.OrderTechnicalAssignmentRepository.Add(ors);
                            //Add notification to techncal to accept order
                            Notification notification2Accept = new Notification();
                            notification2Accept.Text       = "A new Order Wait Your Accept With Code: " + Order.Code;
                            notification2Accept.ToUSer     = technical.UsersId ?? 0;
                            notification2Accept.URl        = AppSession.AppURL + "api/ApiOrder/AcceptOrder/" + Order.Id;
                            notification2Accept.TypeOfUser = (int)EN_TypeUser.Technical;
                            _uow.NotificationRepository.Add(notification2Accept);
                        }
                        else
                        {
                            //Add alert notification to admin with no technical available for service
                            Notification adminNotification = new Notification();
                            adminNotification.IsAlert    = true;
                            adminNotification.Text       = "No Technical Available for New Order woth Code: " + Order.Code;
                            adminNotification.URl        = "/ServicesReport/Index";
                            adminNotification.TypeOfUser = (int)EN_TypeUser.Admin;
                            var isfind = _uow.NotificationRepository.GetMany(ent => ent.URl == adminNotification.URl).Any();
                            if (!isfind)
                            {
                                _uow.NotificationRepository.Add(adminNotification);
                            }
                        }
                        _uow.Save();
                    }
                }
            }
        }
Esempio n. 21
0
        public async Task Start()
        {
            bool flag = true;

            while (flag)
            {
                Console.WriteLine("1. Watch all Technical.");
                Console.WriteLine("2. Create new Technical.");
                Console.WriteLine("3. Edit Technical.");
                Console.WriteLine("4. Delete Technical.");
                Console.WriteLine("5. Find Technical by cost");
                Console.WriteLine("6. Sort by weight.");
                Console.WriteLine("7. Exit");
                string line = Console.ReadLine();
                switch (line)
                {
                case "1":
                {
                    using TcpClient client           = new TcpClient(_ip, _port);
                    await using NetworkStream stream = client.GetStream();
                    DataContainer <Technical> sendData = new DataContainer <Technical> {
                        Operation = Operation.Watch
                    };
                    _formatter.Serialize(stream, sendData);
                    if (_formatter.Deserialize(stream) is List <Technical> recieveData)
                    {
                        foreach (var item in recieveData)
                        {
                            Console.WriteLine("Name: " + item.Name + "; State of Product: " + item.StateName +
                                              "; Cost: " + item.Cost + "by.; Weight: " + item.Weight +
                                              "kg.; Volume: " + item.Volume + "m^3.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Collection is empty");
                    }
                    break;
                }

                case "2":
                {
                    int convert;
                    Console.Write("Enter name of Technical: ");
                    string name = Console.ReadLine();
                    Console.Write("Enter state name, where technical is created: ");
                    string stateName = Console.ReadLine();
                    Console.Write("Enter cost of Technical (default is 0): ");
                    line = Console.ReadLine();
                    int cost;
                    if (line == null || Int32.TryParse(line, out convert))
                    {
                        cost = line == null ? 0 : Int32.Parse(line);
                    }
                    else
                    {
                        break;
                    }
                    Console.Write("Enter weight of Technical (default is 0): ");
                    line = Console.ReadLine();
                    int weight;
                    if (line == null || Int32.TryParse(line, out convert))
                    {
                        weight = line == null ? 0 : Int32.Parse(line);
                    }
                    else
                    {
                        break;
                    }
                    Console.Write("Enter volume of Technical (default is 0): ");
                    line = Console.ReadLine();
                    int volume;
                    if (line == null || Int32.TryParse(line, out convert))
                    {
                        volume = line == null ? 0 : Int32.Parse(line);
                    }
                    else
                    {
                        break;
                    }
                    Technical newTechnical = new Technical()
                    {
                        Cost      = cost,
                        Name      = name,
                        StateName = stateName,
                        Volume    = volume,
                        Weight    = weight
                    };
                    using TcpClient client           = new TcpClient(_ip, _port);
                    await using NetworkStream stream = client.GetStream();
                    DataContainer <Technical> sendData = new DataContainer <Technical>()
                    {
                        Data      = newTechnical,
                        Operation = Operation.Create
                    };
                    _formatter.Serialize(stream, sendData);
                    string recieveData = _formatter.Deserialize(stream) as string;
                    if (recieveData == null)
                    {
                        Console.WriteLine("Creating failed.");
                    }
                    else if (recieveData.Equals("OK"))
                    {
                        Console.WriteLine("Creating successful.");
                    }
                    else if (recieveData.Equals("Exist"))
                    {
                        Console.WriteLine("Technical already exist with tipped name.");
                    }
                    else
                    {
                        Console.WriteLine("Creating failed.");
                    }

                    break;
                }

                case "3":
                {
                    int convert;
                    Console.Write("Enter name of Technical: ");
                    string name = Console.ReadLine();
                    Console.Write("Enter state name, where technical is created: ");
                    string stateName = Console.ReadLine();
                    Console.Write("Enter cost of Technical (default is 0): ");
                    line = Console.ReadLine();
                    int cost;
                    if (line == null || Int32.TryParse(line, out convert))
                    {
                        cost = line == null ? 0 : Int32.Parse(line);
                    }
                    else
                    {
                        break;
                    }
                    Console.Write("Enter weight of Technical (default is 0): ");
                    line = Console.ReadLine();
                    int weight;
                    if (line == null || Int32.TryParse(line, out convert))
                    {
                        weight = line == null ? 0 : Int32.Parse(line);
                    }
                    else
                    {
                        break;
                    }
                    Console.Write("Enter volume of Technical (default is 0): ");
                    line = Console.ReadLine();
                    int volume;
                    if (line == null || Int32.TryParse(line, out convert))
                    {
                        volume = line == null ? 0 : Int32.Parse(line);
                    }
                    else
                    {
                        break;
                    }
                    Technical newTechnical = new Technical()
                    {
                        Cost      = cost,
                        Name      = name,
                        StateName = stateName,
                        Volume    = volume,
                        Weight    = weight
                    };
                    using TcpClient client           = new TcpClient(_ip, _port);
                    await using NetworkStream stream = client.GetStream();
                    DataContainer <Technical> sendData = new DataContainer <Technical>
                    {
                        Operation = Operation.Edit,
                        Data      = newTechnical
                    };
                    _formatter.Serialize(stream, sendData);
                    string recieveData = _formatter.Deserialize(stream) as string;
                    if (recieveData == null)
                    {
                        Console.WriteLine("Editting failed");
                    }
                    else
                    {
                        Console.WriteLine(recieveData.Equals("OK") ? "Editting successful." : "Editting failed.");
                    }
                    break;
                }

                case "4":
                {
                    Console.Write("Enter name of Technical: ");
                    string    name         = Console.ReadLine();
                    Technical newTechnical = new Technical()
                    {
                        Name = name
                    };
                    using TcpClient clientWatch           = new TcpClient(_ip, _port);
                    await using NetworkStream streamWatch = clientWatch.GetStream();
                    DataContainer <Technical> sendData = new DataContainer <Technical> {
                        Operation = Operation.Watch
                    };
                    _formatter.Serialize(streamWatch, sendData);
                    List <Technical> recieveDataList = _formatter.Deserialize(streamWatch) as List <Technical>;
                    if (recieveDataList.First(x => x.Name.Equals(newTechnical.Name)) != null)
                    {
                        using TcpClient clientDelete           = new TcpClient(_ip, _port);
                        await using NetworkStream streamDelete = clientDelete.GetStream();
                        newTechnical = recieveDataList.First(x => x.Name.Equals(newTechnical.Name));
                        sendData     = new DataContainer <Technical>()
                        {
                            Data      = newTechnical,
                            Operation = Operation.Delete
                        };
                        _formatter.Serialize(streamDelete, sendData);
                        string recieveData = _formatter.Deserialize(streamDelete) as string;
                        Console.WriteLine(recieveData.Equals("OK") ? "Deleting successful." : "Deleting failed.");
                    }
                    else
                    {
                        Console.WriteLine("Technical with this name is not existed.");
                    }

                    break;
                }

                case "5":
                {
                    Console.Write("Enter cost of Technical: ");
                    int cost = Int32.Parse((Console.ReadLine()));
                    using TcpClient client           = new TcpClient(_ip, _port);
                    await using NetworkStream stream = client.GetStream();
                    DataContainer <Technical> sendData = new DataContainer <Technical> {
                        Operation = Operation.Watch
                    };
                    _formatter.Serialize(stream, sendData);
                    List <Technical> recieveData = _formatter.Deserialize(stream) as List <Technical>;
                    if (recieveData.First(x => x.Cost == cost) != null)
                    {
                        foreach (Technical item in recieveData.FindAll(x => x.Cost == cost))
                        {
                            Console.WriteLine("Name: " + item.Name + "; State of Product: " + item.StateName +
                                              "; Cost: " + item.Cost + "by.; Weight: " + item.Weight +
                                              "kg.; Volume: " + item.Volume + "m^3.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Technical with this cost is not existed.");
                    }

                    break;
                }

                case "6":
                {
                    using TcpClient client           = new TcpClient(_ip, _port);
                    await using NetworkStream stream = client.GetStream();
                    DataContainer <Technical> sendData = new DataContainer <Technical> {
                        Operation = Operation.Watch
                    };
                    _formatter.Serialize(stream, sendData);
                    List <Technical> recieveData = _formatter.Deserialize(stream) as List <Technical>;
                    recieveData.Sort((x, y) =>
                        {
                            if (x.Weight > y.Weight)
                            {
                                return(1);
                            }

                            if (y.Weight > x.Weight)
                            {
                                return(-1);
                            }
                            return(0);
                        });
                    foreach (Technical item in recieveData)
                    {
                        Console.WriteLine("Name: " + item.Name + "; State of Product: " + item.StateName +
                                          "; Cost: " + item.Cost + "by.; Weight: " + item.Weight +
                                          "kg.; Volume: " + item.Volume + "m^3.");
                    }

                    break;
                }

                case "7":
                {
                    flag = false;
                    break;
                }

                default:
                {
                    Console.WriteLine("Wrong input.");
                    break;
                }
                }
                Console.WriteLine("Enter any key to continue...");
                Console.ReadKey();
            }
        }