コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                SOCIETE societe = entity.SOCIETE.FirstOrDefault(S => S.CODE_S.Equals((decimal)comboboxSociete.SelectedValue));
                MACHINE Machine = entity.MACHINE.FirstOrDefault(machine => machine.ID_M == machineID);


                Machine.TYPE_M     = cb2.Text;
                Machine.CODE_S     = societe.CODE_S;
                Machine.LIB        = tb1.Text;
                Machine.IP         = tb2.Text;
                Machine.PORT       = Convert.ToDecimal(tb3.Text);
                Machine.PWD        = tb4.Text;
                Machine.ID_LECTEUR = 1;
                // Machine.SOCIETE = societe;



                entity.SaveChanges();


                MessageFormtOK MessageFormtOK = new MessageFormtOK("Modification avec success...");
                var            result         = MessageFormtOK.ShowDialog();

                Close();
            }
            catch (Exception ex)
            {
                MessageFormError MessageForm = new MessageFormError(ex.Message.ToString());
                var result = MessageForm.ShowDialog();
            }
        }
コード例 #2
0
        public ActionResult MachinesInsertOrEdit(int machineID)
        {
            using (DBEPREntities db = new DBEPREntities())
            {
                MachinesViewModel mvm = new MachinesViewModel();
                //for Modals:

                List <MANUFACTURER> manList = db.MANUFACTURERS.Where(s => s.IsDeleted == false).ToList();
                ViewBag.ManufacturerList = new SelectList(manList, "ID", "Name");
                List <MACHINETYPE> tList = db.MACHINETYPES.Where(s => s.IsDeleted == false).ToList();
                ViewBag.typeList = new SelectList(tList, "ID", "Name");
                List <UZAUTOSUPPLIER> uList = db.UZAUTOSUPPLIERS.Where(s => s.IsDeleted == false).ToList();
                ViewBag.UzAutoSupplierList = new SelectList(uList, "ID", "Name");

                if (machineID > 0)
                {
                    MACHINE machine = db.MACHINES.SingleOrDefault(m => m.IsDeleted == false && m.ID == machineID);
                    if (machine != null)
                    {
                        mvm.ID               = machine.ID;
                        mvm.Name             = machine.Name;
                        mvm.Description      = machine.Description;
                        mvm.PartNumber       = machine.PartNumber;
                        mvm.Lifespan         = machine.Lifespan;
                        mvm.InstalledDate    = machine.InstalledDate;
                        mvm.Status           = machine.IsActive;
                        mvm.ManufacturerID   = machine.ManufacturerID;
                        mvm.UzAutoSupplierID = machine.UzAutoSupplierID;
                        mvm.TypeID           = machine.TypeID;
                    }
                }
                return(PartialView("MachinesInsertOrEdit", mvm));
            }
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                SOCIETE societe = entity.SOCIETE.FirstOrDefault(S => S.CODE_S.Equals((decimal)comboboxSociete.SelectedValue));
                MACHINE machine = new MACHINE
                {
                    //  ID_M = Convert.ToDecimal(cb1.Text),
                    TYPE_M     = cb2.Text,
                    CODE_S     = societe.CODE_S,
                    LIB        = tb1.Text,
                    IP         = tb2.Text,
                    PORT       = Convert.ToDecimal(tb3.Text),
                    PWD        = tb4.Text,
                    ID_LECTEUR = 1,
                    SOCIETE    = societe
                };


                entity.MACHINE.Add(machine);
                entity.SaveChanges();

                MessageBox.Show("ajout avec success...");
                MessageFormtOK MessageFormtOK = new MessageFormtOK("ajout avec success...");
                var            result         = MessageFormtOK.ShowDialog();

                Close();
            }
            catch (Exception ex)
            {
                MessageFormError MessageForm = new MessageFormError(ex.Message.ToString());
                var result = MessageForm.ShowDialog();
            }
        }
コード例 #4
0
 public Vertex(int c, BRANCH branch, MACHINE type, int num)
 {
     Core   = c;
     Type   = type;
     Num    = num;
     Branch = branch;
 }
コード例 #5
0
        public ActionResult MachinesSave(MachinesViewModel model)
        {
            using (DBEPREntities db = new DBEPREntities())
            {
                if (model.ID > 0)
                {
                    MACHINE machine = db.MACHINES.SingleOrDefault(m => m.IsDeleted == false && m.ID == model.ID);
                    if (machine != null)
                    {
                        machine.Name          = model.Name;
                        machine.Description   = model.Description;
                        machine.Lifespan      = model.Lifespan;
                        machine.InstalledDate = model.InstalledDate;
                        machine.PartNumber    = model.PartNumber;
                        if (model.Status)
                        {
                            machine.IsActive = true;
                        }
                        else
                        {
                            machine.IsActive = false;
                        }
                        machine.ManufacturerID   = model.ManufacturerID;
                        machine.UzAutoSupplierID = model.UzAutoSupplierID;
                        machine.TypeID           = model.TypeID;

                        db.SaveChanges();
                    }
                }
                else
                {
                    MACHINE machine = new MACHINE();

                    machine.Name          = model.Name;
                    machine.Description   = model.Description;
                    machine.Lifespan      = model.Lifespan;
                    machine.InstalledDate = model.InstalledDate;
                    machine.PartNumber    = model.PartNumber;
                    if (model.Status)
                    {
                        machine.IsActive = true;
                    }
                    else
                    {
                        machine.IsActive = false;
                    }
                    machine.ManufacturerID   = model.ManufacturerID;
                    machine.UzAutoSupplierID = model.UzAutoSupplierID;
                    machine.TypeID           = model.TypeID;
                    machine.IsDeleted        = false;

                    db.MACHINES.Add(machine);
                    db.SaveChanges();
                }
                return(RedirectToAction("Machines"));
            }
        }
コード例 #6
0
        //вычисление знаменателя в формуле вероятности (для выбора пути муравьем)
        public static double ZnamenatelP(List <Vertex> list, int i, BRANCH branch, MACHINE type, Duga[,] curves, Muravey muravey)
        {
            double sum = 0;

            for (int j = 0; j < list.Count; j++)
            {
                if (curves[i, j] != null && list[j].Type == type && list[j].Branch == branch && !muravey.Tabu.Contains(j))
                {
                    sum += Math.Pow(curves[i, j].T, ALPHA) * Math.Pow(curves[i, j].N, BETA);
                }
            }
            return(sum);
        }
コード例 #7
0
        //вычисление знаменателя в формуле вероятности (для выбора стартового вирт. элемента муравьем)
        public static double ZnamenatelStart(List <Vertex> list, BRANCH branch, Duga[,] curves)
        {
            MACHINE type = MACHINE.VIRTUAL;
            double  sum  = 0;

            for (int j = 0; j < list.Count; j++)
            {
                if (curves[0, j] != null && list[j].Type == type && list[j].Branch == branch)
                {
                    sum += Math.Pow(curves[0, j].T, ALPHA) * Math.Pow(curves[0, j].N, BETA);
                }
            }
            return(sum);
        }
コード例 #8
0
        public JsonResult MachinesDelete(int machineID)
        {
            bool result = false;

            using (DBEPREntities db = new DBEPREntities())
            {
                MACHINE machine = db.MACHINES.SingleOrDefault(m => m.IsDeleted == false && m.ID == machineID);
                if (machine != null)
                {
                    machine.IsDeleted = true;
                    db.SaveChanges();
                    result = true;
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public modifierMachine(decimal machineID)
        {
            this.machineID = machineID;
            MACHINE Machine = entity.MACHINE.FirstOrDefault(machine => machine.ID_M == machineID);



            // ID_LECTEUR = 1;
            //SOCIETE = societe;
            InitializeComponent();
            cb1.Text         = Machine.ID_M.ToString();
            cb2.SelectedItem = Machine.TYPE_M;

            tb1.Text = Machine.LIB;
            tb2.Text = Machine.IP;
            tb3.Text = Machine.PORT.ToString();
            tb4.Text = Machine.PWD;
            comboboxSociete.DataSource    = entity.SOCIETE.ToList();
            comboboxSociete.DisplayMember = "NOM_S";
            comboboxSociete.ValueMember   = "CODE_S";
            comboboxSociete.SelectedValue = Machine.CODE_S;
        }
コード例 #10
0
 static protected void SetOwnerStateMachine(BASE_STATE_TYPE state, MACHINE machine)
 {
     state.SetOwnerStateMachine(machine);
 }
コード例 #11
0
ファイル: Port.cs プロジェクト: ayoubabess/AccessControle
        public static void matching()
        {
            initialiser();

            while (!StopBits)
            {
                while (!outPut.Contains("Found ID "))
                {
                    //Console.Write(".");
                }
                outPut = "";
                while (idEmprient == "" || idEmprient == "\n")
                {
                    idEmprient = port.ReadExisting();
                }

                // while(!outPut.Contains("operation terminé"))
                Console.Write(idEmprient);
                decimal id;

                if (Decimal.TryParse(idEmprient, out id))
                {
                    Console.WriteLine(id);
                    idEmprient = "";


                    DbEntities entity     = new DbEntities();
                    MACHINE    machine    = entity.MACHINE.Where(m => m.ID_M == 21).FirstOrDefault();
                    PERSONNEL  p          = entity.PERSONNEL.FirstOrDefault(per => per.IDEMPRIENT == id);
                    DateTime   Datenow    = DateTime.Now;
                    DateTime   Datedebut  = (DateTime)p.SHIFT.DATEDDEBUT;
                    DateTime   Datedefin  = (DateTime)p.SHIFT.DATEDFIN;
                    DateTime   Heuredebut = (DateTime)p.SHIFT.HEUREDEBUT;
                    DateTime   Heuredefin = (DateTime)p.SHIFT.HEUREFIN;
                    //DateTime heuredebutpause = (DateTime)p.SHIFT.FirstOrDefault().HEUREDEBUT;
                    //DateTime heuredefinpause = (DateTime)p.SHIFT.FirstOrDefault().HEUREFIN;
                    if (Datedebut.CompareTo(Datenow) <= 0 && Datedefin.CompareTo(Datenow) >= 0 && Heuredebut.TimeOfDay.CompareTo(Datenow.TimeOfDay) <= 0 && Heuredefin.TimeOfDay.CompareTo(Datenow.TimeOfDay) >= 0)
                    {
                        var count = entity.POINTAGE.Where(point => point.MAT.Equals(p.MAT)).Count();
                        if (count % 2 == 0)
                        {
                            sens = "Entrée";
                        }
                        else
                        {
                            sens = "Sortie";
                        }
                        port.Write("1");
                        POINTAGE Pointage = new POINTAGE
                        {
                            MAT       = p.MAT,
                            DATE_P    = Datenow,
                            ID_M      = machine.ID_M,
                            SENS      = sens,
                            PERSONNEL = p,
                            MACHINE   = machine
                        };
                        entity.POINTAGE.Add(Pointage);
                        entity.SaveChanges();


                        Console.Write("okkkkk" + Datedebut + " <=" + Datenow + " >= " + Datedefin);
                    }
                    else
                    {
                        port.Write("2"); Console.Write("not okkkkk" + Datedebut + " >" + Datenow + " >= " + Datedefin);
                    }
                }
                else
                {
                    port.Write("2");  Console.WriteLine("Unable to parse '{0}'.", idEmprient);
                }

                //StopBits = true;
            }
        }
コード例 #12
0
        public static int roulettePath(List <Vertex> list, int CurrentMashine, BRANCH branch, MACHINE machine, Muravey muravey, Duga[,] curves)
        {
            //Dictionary для хранения вероятностей перехода  вирт--->физ
            Dictionary <int, double> P = new Dictionary <int, double>();
            int    indVertex           = 0;
            double p;

            //находнеие вероятностей перехода
            for (int j = 0; j < list.Count; j++)
            {
                //существут дуга && соотв. тип (вирт./физ.) && соответствут ветка (вычислит./storage)
                if (curves[CurrentMashine, j] != null && (list[j].Type == machine && list[j].Branch == branch))
                {
                    if ((machine == MACHINE.VIRTUAL && !muravey.Tabu.Contains(j)) || machine == MACHINE.REAL)
                    {
                        //верроятность перехода
                        p = Math.Pow(curves[CurrentMashine, j].T, ALPHA) * Math.Pow(curves[CurrentMashine, j].N, BETA) / ZnamenatelP(list, CurrentMashine, branch, machine, curves, muravey);
                    }
                    else
                    {
                        p = 0;
                    }
                    P.Add(j, p);
                }
            }

            return(indVertex = rouletteChouse(P));
        }
コード例 #13
0
        public static void matching()
        {
            try
            {
                initialiser();

                while (!StopBits)
                {
                    while (!outPut.Contains("Found ID "))
                    {
                        //Console.Write(".");
                    }
                    outPut = "";
                    while (idEmprient == "" || idEmprient == "\n")
                    {
                        idEmprient = port.ReadExisting();
                    }

                    // while(!outPut.Contains("operation terminé"))
                    Console.Write(idEmprient);
                    decimal id;

                    if (Decimal.TryParse(idEmprient, out id))
                    {
                        Console.WriteLine(id);
                        idEmprient = "";


                        DbEntities entity     = new DbEntities();
                        MACHINE    machine    = entity.MACHINE.Where(m => m.ID_M == 21).FirstOrDefault();
                        PERSONNEL  p          = entity.PERSONNEL.FirstOrDefault(per => per.IDEMPRIENT == id);
                        DateTime   Datenow    = DateTime.Now;
                        DateTime   Datedebut  = (DateTime)p.SHIFT.DATEDDEBUT;
                        DateTime   Datedefin  = (DateTime)p.SHIFT.DATEDFIN;
                        DateTime   Heuredebut = (DateTime)p.SHIFT.HEUREDEBUT;
                        DateTime   Heuredefin = (DateTime)p.SHIFT.HEUREFIN;
                        //DateTime heuredebutpause = (DateTime)p.SHIFT.FirstOrDefault().HEUREDEBUT;
                        //DateTime heuredefinpause = (DateTime)p.SHIFT.FirstOrDefault().HEUREFIN;
                        if (Datedebut.CompareTo(Datenow) <= 0 && Datedefin.CompareTo(Datenow) >= 0 && Heuredebut.TimeOfDay.CompareTo(Datenow.TimeOfDay) <= 0 && Heuredefin.TimeOfDay.CompareTo(Datenow.TimeOfDay) >= 0)
                        {
                            var count = entity.POINTAGE.Where(point => point.MAT.Equals(p.MAT)).Count();
                            if (count % 2 == 0)
                            {
                                sens = "Entrée";
                            }
                            else
                            {
                                sens = "Sortie";
                            }
                            port.Write("1");
                            POINTAGE Pointage = new POINTAGE
                            {
                                MAT       = p.MAT,
                                DATE_P    = Datenow,
                                ID_M      = machine.ID_M,
                                SENS      = sens,
                                PERSONNEL = p,
                                MACHINE   = machine
                            };
                            entity.POINTAGE.Add(Pointage);
                            entity.SaveChanges();

                            if (sens == "Entrée")
                            {
                                NotificationPointageForm MessageFormt = new NotificationPointageForm("Entrée enregitré pour : " + p.NOM + " " + p.PRENOM + " le " + Datenow.ToShortDateString() + " à " + Datenow.ToShortTimeString());
                                MessageFormt.ShowDialog();
                            }
                            else
                            {
                                NotificationPointageForm MessageFormt = new NotificationPointageForm("Sortie enregisté pour : " + p.NOM + " " + p.PRENOM + "le " + Datenow.ToShortDateString() + " à " + Datenow.ToShortTimeString());
                                MessageFormt.ShowDialog();
                            }
                        }
                        else
                        {
                            port.Write("2");
                            MessageFormError MessageForm = new MessageFormError("Access refusé pour : " + p.NOM + " " + p.PRENOM + "le " + Datenow.ToShortDateString() + " à " + Datenow.ToShortTimeString());

                            MessageForm.ShowDialog();
                        }
                    }
                    else
                    {
                        port.Write("2"); Console.WriteLine("Unable to parse '{0}'.", idEmprient);
                    }

                    //StopBits = true;
                }
            }
            catch (Exception ex)
            {
                MessageFormError MessageForm = new MessageFormError(ex.Message.ToString());
                var result = MessageForm.ShowDialog();
            }
        }