Ejemplo n.º 1
0
        private void copiaDaAttualeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Dati> l = new List <Dati>();

            if (dgw.SelectedRows == null)
            {
                return;
            }
            foreach (DataGridViewRow item in dgw.SelectedRows)
            {
                try
                {
                    Dati iDatiObj = new Dati();

                    iDatiObj.Tipo           = item.Cells["Tipo"].Value.ToString()[0];
                    iDatiObj.DisplayName    = (string)item.Cells["DisplayName"].Value ?? " ";
                    iDatiObj.GUID           = (string)item.Cells["Name"].Value ?? " ";
                    iDatiObj.DisplayVersion = (string)item.Cells["DisplayVersion"].Value ?? " ";
                    l.Add(iDatiObj);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }

            copy(l, true);
        }
Ejemplo n.º 2
0
        //---------------- Metodi Privati ---------------------------------------
        private static void Aggiungi(string Item, object name, object vers, char tipo, List <Dati> ListaDati)
        {
            Dati          riga = new Dati();
            StringBuilder s1   = new StringBuilder();

            if (name != null)
            {
                s1.Append(name);
            }
            else
            {
                s1.Append("");
            }
            riga.DisplayName = s1.ToString(); s1 = new StringBuilder();
            if (vers != null)
            {
                s1.Append(vers);
            }
            else
            {
                s1.Append("");
            }
            riga.DisplayVersion = s1.ToString();;
            riga.GUID           = Item;
            riga.Tipo           = tipo;
            ListaDati.Add(riga);
        }
Ejemplo n.º 3
0
        private void startBtn_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid1.Items.Count == 0)
            {
                MessageBox.Show("Please, Load the Data File in the Main Window first!");
            }
            else
            {
                var _itemSourceList = new CollectionViewSource()
                {
                    Source = dati
                };
                ICollectionView Itemlist = _itemSourceList.View;
                // Filter


                for (int i = 0; i < scriptData.Count; i++)          //Move to Scripting Manager
                {
                    scriptRow.Dati d = scriptData[i];
                    var            yourCostumFilter = new Predicate <object>(item => ((Dati)item).name.Contains(d.name));

                    Itemlist.Filter = yourCostumFilter;
                    Dati o = (Dati)Itemlist.CurrentItem;            //change variable name

                    if (d.operation == "Write")
                    {
                        if (o.type.ToString() != "DI" || o.type.ToString() != "AI")
                        {
                            MessageBox.Show("Not Writable Variable:" + d.name);
                        }
                        else
                        {
                            string nomeScript = scriptData[i].name;
                            for (int j = 0; j < dati.Count; j++)
                            {
                                if (dati[j].name == nomeScript)
                                {
                                    dati[j].value = scriptData[i].value;
                                }
                            }
                            results.Add("PASSED");
                        }
                    }                   //Add Reading
                    else if (d.operation == "Read")
                    {
                        if (o.type.ToString() != "DO" || o.type.ToString() != "AO")
                        {
                            MessageBox.Show("Not Readable Variable:" + d.name);
                        }
                        else
                        {
                            results.Add("-");
                        }
                    }
                }
                dataGrid1.Items.Refresh();
                resGrid.ItemsSource = results;
                startBtn.IsEnabled  = false;
            }
        }
Ejemplo n.º 4
0
        public void Post([FromBody] Dati dati)
        {
            FPContext db = new FPContext();

            db.Datis.Add(dati);
            db.SaveChanges();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 保存大题,生成实例对象
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void save_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtFrontTitle.Text.Length == 0 && FileUpload1.HasFile)
                {
                    lblMessage.Text = "文字和图片至少选择一个";
                }
                else
                {
                    if (File.Exists(path))
                    {
                        File.Move(path, Imgfile);
                        btmimg.ImageUrl = "none";
                        File.Delete(path);
                    }
                    Dati dati = new Dati();
                    dati.Title    = txtFrontTitle.Text;
                    dati.ImgFile  = Imgfile + filename;
                    dati.CourseID = int.Parse(ddlCourse.SelectedValue);
                    dati.Zhang    = 2;
                    dati.jie      = 2;
                    dati.Nandu    = nadu.SelectedIndex;
                    if (Request["ID"] != null)
                    {
                        dati.ID = int.Parse(Request["ID"].ToString());              //取出试题主键
                        if (dati.UpdateByProc(int.Parse(Request["ID"].ToString()))) //调用修改试题方法修改试题
                        {
                            lblMessage.Text = "成功修改该填空题!";
                        }
                        else
                        {
                            lblMessage.Text = "修改该填空题失败!";
                        }
                    }
                    if (dati.InsertByProc())
                    {
                        lblMessage.Text = "成功添加该大题";
                    }
                    else
                    {
                        lblMessage.Text = "添加大题失败!";
                    }
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
            finally
            {
                path     = string.Empty;
                filename = string.Empty;

                this.Dispose();
            }
        }
Ejemplo n.º 6
0
        private static void AggiungiWMQU(string Name, string Query, string Result, char tipo, List <Dati> ListaDati)
        {
            Dati riga = new Dati();

            riga.Tipo           = tipo;
            riga.DisplayName    = Query;
            riga.DisplayVersion = Result;
            riga.GUID           = Name;
            ListaDati.Add(riga);
        }
Ejemplo n.º 7
0
        private static void AggiungiPwr(string Prop, uint Sec, char tipo, List <Dati> ListaDati)
        {
            Dati riga = new Dati();

            riga.Tipo           = tipo;
            riga.DisplayName    = Convert.ToString(Sec);
            riga.DisplayVersion = "secondi";
            riga.GUID           = Prop;
            ListaDati.Add(riga);
        }
Ejemplo n.º 8
0
        private static void AggiungiReg(string BaseKey, string Keyb, string NSubVal, char tipo, List <Dati> ListaDati)
        {
            Dati riga = new Dati();

            riga.Tipo           = tipo;
            riga.DisplayName    = Keyb;
            riga.DisplayVersion = NSubVal;
            riga.GUID           = BaseKey;
            ListaDati.Add(riga);
        }
Ejemplo n.º 9
0
        private static void AggiungiFileEx(string Path, string Esiste, string EDir, char tipo, List <Dati> ListaDati)
        {
            Dati riga = new Dati();

            riga.Tipo           = tipo;
            riga.DisplayName    = Path;
            riga.DisplayVersion = Esiste;
            riga.GUID           = EDir;
            ListaDati.Add(riga);
        }
Ejemplo n.º 10
0
        private static void AggiungiCert(string StoreName, string PropValore, string PropQuale, char tipo, List <Dati> ListaDati)
        {
            Dati riga = new Dati();

            riga.Tipo           = tipo;
            riga.DisplayName    = PropValore;
            riga.DisplayVersion = PropQuale;
            riga.GUID           = StoreName;
            ListaDati.Add(riga);
        }
Ejemplo n.º 11
0
        private static void AggiungiServ(string DisplayName, string Name, string Status, char tipo, List <Dati> ListaDati)
        {
            Dati riga = new Dati();

            riga.Tipo           = tipo;
            riga.DisplayName    = DisplayName;
            riga.DisplayVersion = Status;
            riga.GUID           = Name;

            ListaDati.Add(riga);
        }
Ejemplo n.º 12
0
        public void leggi(string percorso)
        {
            FileStream   stream = new FileStream(percorso, FileMode.Open, FileAccess.Read);
            StreamReader reader = new StreamReader(stream);
            string       linea;

            while (!reader.EndOfStream)
            {
                linea = reader.ReadLine();
                string[] dati = linea.Split(';');
                Dati     c    = new Dati(dati[0], dati[1], dati[2], dati[3], dati[4]);
                add(c);
            }
        }
Ejemplo n.º 13
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            string val  = newValtxt.Text;
            double v    = Convert.ToDouble(val);
            int    riga = dataGrid1.SelectedIndex;
            Dati   p    = dati[riga];

            p.value    = v;
            dati[riga] = p;
            dataGrid1.Items.Refresh();
            okbtn.IsEnabled = false;
            newValtxt.Clear();
            newValtxt.IsEnabled = false;
            cancBtn.IsEnabled   = false;
        }
Ejemplo n.º 14
0
        //初始化数据
        protected void InitData()
        {
            int  DatiID = int.Parse(Request["ID"].ToString());
            Dati dati   = new Dati();

            if (dati.LoadData(DatiID))
            {
                ddlCourse.SelectedValue = dati.CourseID.ToString();
                txtFrontTitle.Text      = dati.Title;
                btmimg.ImageUrl         = dati.ImgFile;
            }
            else
            {
                lblMessage.Text = "加载数据出错!";
            }
        }
Ejemplo n.º 15
0
        private static void GetDatiFromReg(RegistryKey key, List <Dati> ListaDati, StringBuilder s2)
        {
            string[] j = key.GetSubKeyNames();
            //Console.WriteLine(key.GetValue("ProductID").ToString());

            Dati riga = new Dati();

            foreach (string item in j)
            {
                RegistryKey h = key.OpenSubKey(item);
                if (h == null)
                {
                    continue;
                }
                // string[] F = h.GetValueNames();
                var n = h.GetValue("DisplayName");
                var v = h.GetValue("DisplayVersion");
                if (n != null)
                {
                    if (!UpgradeOffice(item, (string)n))
                    {
                        riga = new Dati();
                        if (n != null)
                        {
                            riga.DisplayName = Utf16ToUtf8((string)n).Normalize();
                        }
                        else
                        {
                            s2.Append("\t");
                        }
                        if (v != null)
                        {
                            riga.DisplayVersion = ((string)v).Normalize();
                        }
                        else
                        {
                            s2.Append("\t");
                        }
                        riga.GUID = item.Normalize();
                        riga.Tipo = 'P';
                        ListaDati.Add(riga);
                    }
                    h.Close();
                }
            }
        }
Ejemplo n.º 16
0
        public ValuesController( IHostingEnvironment env)
        {
            // Setta le variabili di ambiente (per poter accedere al file system)
            ambiente = env;
            Dati     = XDocument.Load($"{ambiente.ContentRootPath}/{pathToDataFile}");

            // Carica il file XML
            Persone = (
                from p in Dati.Element("root").Element("Persone").Elements("Persona")
                select new Persona {
                Nome = p.Attribute("Nome").Value
            }
                ).ToList <Persona>();

            // si connette al db
            db = new BloggingContext();
        }
Ejemplo n.º 17
0
        public static List <Dati> ReadCSVRegioni()
        {
            string       source  = "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-regioni/dpc-covid19-ita-regioni.csv";
            StringReader rawFile = new StringReader(new WebClient().DownloadString(source));

            using (var reader = rawFile) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                {
                    List <Dati> records = new List <Dati>();
                    csv.Read();
                    csv.ReadHeader();
                    while (csv.Read())
                    {
                        Dati regionep = new Dati();
                        regionep.totaleTamponi  = 0;
                        regionep.totaleDeceduti = 0;
                        if (records.Count > 21)
                        {
                            regionep.totaleTamponi  = records[records.Count - 21].totaleTamponi;
                            regionep.totaleDeceduti = records[records.Count - 21].totaleDeceduti;
                            regionep.totaleGuariti  = records[records.Count - 21].totaleGuariti;
                        }

                        var record = new Dati
                        {
                            data           = csv.GetField <DateTime>("data"),
                            regione        = csv.GetField("denominazione_regione").ToString(),
                            nuoviPositivi  = csv.GetField <int>("nuovi_positivi"),
                            totaleCasi     = csv.GetField <int>("totale_casi"),
                            totaleDeceduti = csv.GetField <int>("deceduti"),
                            totaleTamponi  = csv.GetField <int>("tamponi"),
                            totaleGuariti  = csv.GetField <int>("dimessi_guariti"),
                            totalePositivi = csv.GetField <int>("totale_positivi"),
                            nuoviGuariti   = csv.GetField <int>("dimessi_guariti") - regionep.totaleGuariti,
                            nuoviDeceduti  = csv.GetField <int>("deceduti") - regionep.totaleDeceduti,
                            nuoviTamponi   = csv.GetField <int>("tamponi") - regionep.totaleTamponi
                        };

                        records.Add(record);
                    }

                    return(records);
                }
        }
Ejemplo n.º 18
0
        public static void GetCestino(List <Dati> ListaDati)
        {
            Dati riga = new Dati();

            riga.Tipo = 'X';

            riga.DisplayVersion = "-";
            riga.GUID           = "Cestino";
            int itemsCount = Altro.GetCestino();

            if ((itemsCount) > 0)
            {
                riga.DisplayName = "Cestino con " + Convert.ToString(itemsCount) + " oggetti";
            }
            else
            {
                riga.DisplayName = "Cestino vuoto";
            };
            ListaDati.Add(riga);
        }
Ejemplo n.º 19
0
        static private void ordinaECodifica()          //Metodo per ordinare ogni volta la lista e codificare i simboli secondo l'algoritmo di Huffman
        {
            if (Lista.Count > 1)
            {
                for (int i = 0; i < Lista.Count - 1; i++)           //Ordinamento della lista
                {
                    for (int j = i + 1; j < Lista.Count; j++)
                    {
                        if (Lista[i].ripetizione < Lista[j].ripetizione)
                        {
                            Dati swap = Lista[i];
                            Lista[i] = Lista[j];
                            Lista[j] = swap;
                        }
                    }
                }
                string temp = Lista[Lista.Count - 1].carattere, temp2 = Lista[Lista.Count - 2].carattere;
                CodificaSimboli(temp, temp2);
                Dati temp1;
                temp1.carattere        = Lista[Lista.Count - 2].carattere + Lista[Lista.Count - 1].carattere;
                temp1.ripetizione      = Lista[Lista.Count - 1].ripetizione + Lista[Lista.Count - 2].ripetizione;
                Lista[Lista.Count - 2] = temp1;
                Lista.RemoveAt(Lista.Count - 1);

                ordinaECodifica();
            }
            else
            {
                for (int i = 0; i < codifiche.Length; i++)          //Aggiungo 1 in modo che gli 0 non vengano "persi nella fase di decodifica"
                {
                    codifiche[i].c += "1";
                }
                for (int i = 0; i < codifiche.Length; i++)          //Riverso tutte le codifiche dei simboli
                {
                    codifiche[i].c = riversaStringa(codifiche[i].c);
                }
                return;
            }
        }
Ejemplo n.º 20
0
        private void Huffman()
        {
            if (Lista.Count > 1)
            {
                for (int i = 0; i < Lista.Count - 1; i++)
                {
                    for (int j = i + 1; j < Lista.Count; j++)
                    {
                        if (Lista[i].ripetizione < Lista[j].ripetizione)
                        {
                            Dati swap = Lista[i];
                            Lista[i] = Lista[j];
                            Lista[j] = swap;
                        }
                    }
                }
                string temp = Lista[Lista.Count - 1].carattere, temp2 = Lista[Lista.Count - 2].carattere;
                CodificaCaratteri(temp, temp2);
                Dati temp1;
                temp1.carattere        = Lista[Lista.Count - 2].carattere + Lista[Lista.Count - 1].carattere;
                temp1.ripetizione      = Lista[Lista.Count - 1].ripetizione + Lista[Lista.Count - 2].ripetizione;
                Lista[Lista.Count - 2] = temp1;
                Lista.RemoveAt(Lista.Count - 1);

                Huffman();
            }
            else
            {
                statoOperazioni("", false);
                MessageBox.Show("Codifica eseguita!");
                for (int i = 0; i < codifiche.Length; i++)
                {
                    codifiche[i].codifica = riversaStringa(codifiche[i].codifica);
                    lstCodiciHuffman.Items.Add(codifiche[i].simbolo + "  =   " + codifiche[i].codifica);
                }
                return;
            }
        }
Ejemplo n.º 21
0
        private void copiaDeltaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Dati> l = new List <Dati>();
            int         r, rmax, rmin;

            rmin = dgvDelta.Rows.Count - 1;
            rmax = 0;
            foreach (DataGridViewCell item in dgvDelta.SelectedCells)
            {
                r = item.RowIndex;
                if (rmin > r)
                {
                    rmin = r;
                }
                if (rmax < r)
                {
                    rmax = r;
                }
            }
            for (int i = rmin; i <= rmax; i++)
            {
                DataGridViewRow item = dgvDelta.Rows[i];

                Dati iDatiObj = new Dati();


                iDatiObj.Tipo           = item.Cells[1].Value.ToString()[0];
                iDatiObj.DisplayName    = (string)item.Cells[2].Value ?? " ";
                iDatiObj.GUID           = item.Cells[3].Value.ToString();
                iDatiObj.DisplayVersion = item.Cells[4].Value.ToString();
                if (iDatiObj.Tipo != 0)
                {
                    l.Add(iDatiObj);
                }
            }
            copy(l, false);
        }
Ejemplo n.º 22
0
        private void combo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ObservableCollection <Dati> datiD = new ObservableCollection <Dati>();
            ObservableCollection <Dati> datiA = new ObservableCollection <Dati>();

            //Digital selection
            if (combo.SelectedIndex == 0)
            {
                dati.Clear();
                for (int i = 0; i < datiBackUp.Count; i++)
                {
                    dati.Add(datiBackUp[i]);
                }

                for (int i = 0; i < dati.Count; i++)
                {
                    Dati d = dati[i];
                    if (d.type == "DO" || d.type == "DI")
                    {
                        datiD.Add(d);
                    }
                }
                dati.Clear();
                for (int i = 0; i < datiD.Count; i++)
                {
                    dati.Add(datiD[i]);
                }
                dataGrid1.Items.Refresh();
            }
            //Analog Selection
            if (combo.SelectedIndex == 1)
            {
                dati.Clear();
                for (int i = 0; i < datiBackUp.Count; i++)
                {
                    dati.Add(datiBackUp[i]);
                }

                for (int i = 0; i < dati.Count; i++)
                {
                    Dati d = dati[i];
                    if (d.type == "AO" || d.type == "AI")
                    {
                        datiA.Add(d);
                    }
                }
                dati.Clear();
                for (int i = 0; i < datiA.Count; i++)
                {
                    dati.Add(datiA[i]);
                }
                dataGrid1.Items.Refresh();
            }
            //All selection
            if (combo.SelectedIndex == 2)
            {
                dati.Clear();
                for (int i = 0; i < datiBackUp.Count; i++)
                {
                    dati.Add(datiBackUp[i]);
                }
                dataGrid1.Items.Refresh();
            }
        }
Ejemplo n.º 23
0
 public void add(Dati a)
 {
     elenco.Add(a);
 }