Exemplo n.º 1
0
        public void WriteLog(decimal[,] logArray)
        {
            var CA_dt = new System.Data.DataTable($"iteration_{iteration}");

            for (int i = 0; i < WidthField; i++)
            {
                CA_dt.Columns.Add();
            }
            for (int i = 0; i < HeightField; i++)
            {
                var dr = CA_dt.NewRow();
                //dr[0] = i;
                for (int j = 0; j < WidthField; j++)
                {
                    dr[j] = logArray[i, j];
                }
                CA_dt.Rows.Add(dr);
            }

            var pop_row = CA_dt.NewRow();

            pop_row[0] = "Population:";
            pop_row[1] = population;
            CA_dt.Rows.Add(pop_row);
            var wb = new XLWorkbook();

            wb.Worksheets.Add(CA_dt).Columns().AdjustToContents();

            wb.SaveAs($"../../Uploads/logs/{iteration}_iteration.xlsx");
        }
Exemplo n.º 2
0
        private void setgisxml(ref System.Data.DataTable dt, IGroupLayer pGroupLayer)
        {
            ICompositeLayer comLayer = pGroupLayer as ICompositeLayer;

            System.Data.DataRow dr;
            for (int i = 0; i < comLayer.Count; i++)
            {
                ILayer player = comLayer.get_Layer(i);
                if (player is IGroupLayer)
                {
                    dr    = dt.NewRow();
                    dr[0] = "layer";
                    dr[1] = player.Name;
                    dr[2] = player.Visible.ToString();
                    dt.Rows.Add(dr);
                    setgisxml(ref dt, player as IGroupLayer);
                }
                else
                {
                    dr    = dt.NewRow();
                    dr[0] = "layer";
                    dr[1] = player.Name;
                    dr[2] = player.Visible.ToString();
                    dt.Rows.Add(dr);
                }
            }
        }
Exemplo n.º 3
0
        public static System.Data.DataTable GetStatus()
        {
            System.Data.DataTable dt = new System.Data.DataTable("States");
            dt.Columns.Add("Key", typeof(byte));
            dt.Columns.Add("Value", typeof(string));

            System.Data.DataRow dr = dt.NewRow();
            dr[0] = 1;
            dr[1] = "TEKLİF HAZIRLANIYOR";
            dt.Rows.Add(dr);

            dr    = dt.NewRow();
            dr[0] = 2;
            dr[1] = "TEKLİF ONAY BEKLİYOR";
            dt.Rows.Add(dr);

            dr    = dt.NewRow();
            dr[0] = 3;
            dr[1] = "TEKLİF ONAYLANDI";
            dt.Rows.Add(dr);

            dr    = dt.NewRow();
            dr[0] = 4;
            dr[1] = "TEKLİF İPTAL EDİLDİ";
            dt.Rows.Add(dr);

            return(dt);
        }
        public static System.Collections.ArrayList GetData()
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("abc", typeof(string));
            dt.Columns.Add("def", typeof(int));

            System.Data.DataRow dr = dt.NewRow();
            dr["abc"] = "test1";
            dr["def"] = 123;
            dt.Rows.Add(dr);


            dr        = dt.NewRow();
            dr["abc"] = "test2";
            dr["def"] = 456;
            dt.Rows.Add(dr);

            System.Data.DataSet ds = new System.Data.DataSet();
            ds.Tables.Add(dt);

            cSessionData ObjectToSerialize1 = new cSessionData("key1", "value1");
            cSessionData ObjectToSerialize2 = new cSessionData("key2", "value2");
            cSessionData ObjectToSerialize3 = new cSessionData("key3", dt);

            System.Collections.ArrayList al = new System.Collections.ArrayList();
            al.Add(ObjectToSerialize1);
            al.Add(ObjectToSerialize2);
            al.Add(ObjectToSerialize3);
            return(al);
        }
Exemplo n.º 5
0
        /**
         *  @brief      SetDataボタン処理
         *  @param[in]  object  sender
         *  @param[in]  EventArgs   e
         *  @return     void
         *  @note       10行4列のデータを dataGird1 に設定
         */
        private void Btn_SetData_Click(object sender, RoutedEventArgs e)
        {
            // DataTable 列の Header作成
            dtTbl.Columns.Add("Column0");
            dtTbl.Columns.Add("Column1");
            dtTbl.Columns.Add("Column2");
            dtTbl.Columns.Add("Column3");

            // DataTable 10行4列データ作成
            for (int i = 0; i < 10; i++)
            {
                var row = dtTbl.NewRow();
                for (int j = 0; j < dtTbl.Columns.Count; j++)
                {
                    row[j] = "r=" + i.ToString() + " ," + "column=" + j.ToString();
                }
                dtTbl.Rows.Add(row);
            }

            // DataTable を DataGrid に反映
            this.dataGrid1.DataContext = dtTbl;     // ItemsSource は Binding 指定 なので、ここで DataTable と Binding

            Btn_AddData.IsEnabled    = true;
            BtnDelLastData.IsEnabled = true;
            Btn_ChgData.IsEnabled    = true;
        }
Exemplo n.º 6
0
        public void Load(System.IO.FileStream file)
        {
            cod        = Util.LoadInt(file);
            x          = Util.LoadInt(file);
            y          = Util.LoadInt(file);
            tipoMesa   = Util.LoadBool(file);
            estado     = Util.LoadInt(file);
            juntadaCon = Util.LoadInt(file);
            int numLineas = Util.LoadInt(file);

            lineas.Clear();
            for (int i = 0; i < numLineas; i++)
            {
                Linea l = new Linea();
                l.Load(file);
                lineas.Add(l);

                System.Data.DataRow miDataRow = dataLineas.NewRow();
                Articulo            a         = GestorArticulos.getArticulo(l.CodArticulo);
                miDataRow["Nombre"] = a.Desc;
                miDataRow["Precio"] = a.PvpConIva;
                miDataRow["Estado"] = l.getEstadoString();
                dataLineas.Rows.Add(miDataRow);
            }
        }
Exemplo n.º 7
0
        protected void Bind_RunDown()
        {
            dtRunDown = new System.Data.DataTable();
            dtRunDown.Columns.Add("SeqNo", typeof(string));
            dtRunDown.Columns.Add("Name", typeof(string));
            dtRunDown.Columns.Add("CheckDateTime", typeof(string));

            System.Data.DataRow drow = null;
            ///資料
            drow          = dtRunDown.NewRow();
            drow["SeqNo"] = "1";
            drow["Name"]  = "身高體重";
            dtRunDown.Rows.Add(drow);
            drow          = dtRunDown.NewRow();
            drow["SeqNo"] = "2";
            drow["Name"]  = "視力";
            dtRunDown.Rows.Add(drow);
            drow          = dtRunDown.NewRow();
            drow["SeqNo"] = "3";
            drow["Name"]  = "腰臀圍";
            dtRunDown.Rows.Add(drow);
            //
            GridView2.DataSource = dtRunDown;
            GridView2.DataBind();
        }
Exemplo n.º 8
0
        public System.Data.DataTable GetDataTable()
        {
            switch (_type)
            {
            case PageDataType.DataTable:
                return(_dataTable);

            case PageDataType.Xml:
                return(Xy.Tools.IO.XML.ConvertXMLFileToDataSet(_dataXml.CreateNavigator().OuterXml));

            case PageDataType.String:
            case PageDataType.Array:
                System.Data.DataTable _tempTable = new System.Data.DataTable();
                _tempTable.Columns.Add(_name);
                if (_type == PageDataType.String)
                {
                    System.Data.DataRow _tempRow = _tempTable.NewRow();
                    _tempRow[_name] = _dataString;
                    _tempTable.Rows.Add(_tempRow);
                }
                else
                {
                    for (int i = 0; i < _dataArray.Length; i++)
                    {
                        System.Data.DataRow _tempRow = _tempTable.NewRow();
                        _tempRow[_name] = _dataArray.GetValue(i).ToString();
                        _tempTable.Rows.Add(_tempRow);
                    }
                }
                return(_tempTable);
            }
            return(null);
        }
Exemplo n.º 9
0
        protected string get_rundown_detail()
        {
            string str_detail_item = string.Empty;

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("detail_item_name", typeof(string));
            dt.Columns.Add("detail_item_value", typeof(string));

            System.Data.DataRow drow = null;
            ///資料
            drow = dt.NewRow();
            drow["detail_item_name"]  = "身高";
            drow["detail_item_value"] = "180";
            dt.Rows.Add(drow);

            drow = dt.NewRow();
            drow["detail_item_name"]  = "體重";
            drow["detail_item_value"] = "60";
            dt.Rows.Add(drow);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                str_detail_item += dr["detail_item_name"].ToString() + ":";
                str_detail_item += dr["detail_item_value"].ToString();
                str_detail_item += "</br>";
            }

            return(str_detail_item);
        }
Exemplo n.º 10
0
        public static void TestDataTable()
        {
            Console.WriteLine("\n## TestC, DataTable");

            System.Data.DataTable dataTable = new System.Data.DataTable();
            dataTable.Columns.Add("Column1");
            dataTable.Columns.Add("Column2");

            System.Data.DataRow dataRow = dataTable.NewRow();
            dataRow["Column1"] = "Hello";
            dataRow["Column2"] = "World";
            dataTable.Rows.Add(dataRow);

            dataRow            = dataTable.NewRow();
            dataRow["Column1"] = "Bonjour";
            dataRow["Column2"] = "le monde";
            dataTable.Rows.Add(dataRow);

            string json = JsonConvert.SerializeObject(dataTable);

            Console.WriteLine("Json: " + json);

            {
                string myTemplate = @"
                {{
                tb = " + json + @"
                }}
[
  { {{ for tbr in tb }}
    ""N"": {{tbr.Column1}},
    ""M"": {{tbr.Column2}}
  }{{if for.last; ; else; "",""; end}}{{end}}
]
{{tb}}
";

                var template = Template.Parse(myTemplate);
                var result   = template.Render();
                Console.WriteLine(result);
            }
            {
                var parsed = JsonConvert.DeserializeObject(json);
                Console.WriteLine("Parsed: " + parsed);

                string myTemplate = @"
[
  { {{ for tbr in tb }}
    ""N"": {{tbr.Column1}},
    ""M"": {{tbr.Column2}}
  }{{if for.last; ; else; "",""; end}}{{end}}
]
{{tb}}
";

                var template = Template.Parse(myTemplate);
                var result   = template.Render(new { tb = parsed });
                Console.WriteLine(result);
            }
        }
Exemplo n.º 11
0
 private void bNew_OnClick(object sender, EventArgs e)
 {
     System.Data.DataRow newRow = dtValues.NewRow();
     newRow["X"] = false;
     newRow[m_strFileExtensionField] = " ";
     newRow[m_strBeginCommentField]  = " ";
     newRow[m_strEndCommentField]    = " ";
     dtValues.Rows.Add(newRow);
     dtValues.AcceptChanges();
 }
Exemplo n.º 12
0
        protected string create_rundown(string RegNo)
        {
            string strrtn = string.Empty;

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("SeqNo", typeof(string));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("CheckDateTime", typeof(string));

            System.Data.DataRow drow = null;
            ///資料
            drow                  = dt.NewRow();
            drow["SeqNo"]         = "1";
            drow["Name"]          = "身高體重";
            drow["CheckDateTime"] = "2016/08/29 08:00";
            dt.Rows.Add(drow);
            drow                  = dt.NewRow();
            drow["SeqNo"]         = "2";
            drow["Name"]          = "視力";
            drow["CheckDateTime"] = "2016/08/29 08:10";
            dt.Rows.Add(drow);
            drow                  = dt.NewRow();
            drow["SeqNo"]         = "3";
            drow["Name"]          = "腰臀圍";
            drow["CheckDateTime"] = "";
            dt.Rows.Add(drow);
            drow                  = dt.NewRow();
            drow["SeqNo"]         = "4";
            drow["Name"]          = "繳費";
            drow["CheckDateTime"] = "";
            dt.Rows.Add(drow);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string strName          = dr["Name"].ToString();
                string strCheckDateTime = dr["CheckDateTime"].ToString();

                if (strCheckDateTime != null && strCheckDateTime != "")
                {
                    strrtn += "<span class=\"label label-success\">" + strName + "</span>";
                }
                else
                {
                    strrtn += "<span class=\"label label-warning\">" + strName + "</span>";
                }

                int i = dt.Rows.IndexOf(dr);
                if (dt.Rows.IndexOf(dr) != dt.Rows.Count - 1)
                {
                    strrtn += ">";
                }
            }

            return(strrtn);
        }
Exemplo n.º 13
0
        public void AddDataGridRows()
        {
            System.Data.DataRow ContentEntry = CourseTable.NewRow();
            ContentEntry["Start"]       = pcrTopicStart.Text;
            ContentEntry["Topics"]      = txtTopicName.Text;
            ContentEntry["Classes"]     = txtNumTopicPeriods.Text;
            ContentEntry["Preparation"] = txtTopicPreparation.Text;

            CourseTable.Rows.Add(ContentEntry);
            dgPreview.ItemsSource = CourseTable.DefaultView;
        }
Exemplo n.º 14
0
        protected void btnExportForCRM_Click(object sender, EventArgs e)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"SupplierId"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"BusinessName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"SupplierServices"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Address"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"CityName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"Phone"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"ContactPhone"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"ContactName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"Email"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"SupplierType"), typeof(string)));

            List <SupplierUI> suppliers   = new List <SupplierUI>();
            string            searchName  = "%" + txtSearchName.Text.Trim() + "%";
            string            searchPhone = "%" + txtSearchPhone.Text.Trim() + "%";

            suppliers = SupplierController.GetAllSuppliersUI(true, searchName, searchPhone);

            foreach (SupplierUI supplier in suppliers)
            {
                int i = 0;
                System.Data.DataRow row = dt.NewRow();
                row[i++] = supplier.SupplierId;
                row[i++] = supplier.BusinessName;

                row[i++] = getSupplierServices(supplier);
                row[i++] = supplier.Street + " " + supplier.HouseNum;
                row[i++] = supplier.CityName;
                row[i++] = "=\"" + supplier.Phone + "\"";
                row[i++] = "=\"" + supplier.ContactPhone + "\"";
                row[i++] = supplier.ContactName;
                row[i++] = supplier.Email;
                row[i++] = supplier.IsProduct ? SuppliersStrings.GetText(@"IsProduct") : SuppliersStrings.GetText(@"IsService");
                dt.Rows.Add(row);
            }
            System.Data.DataRow sumRow = dt.NewRow();
            sumRow[0] = SuppliersStrings.GetText(@"SumSumPerMonth") + " " + suppliers.Sum(o => o.SumPerMonth);
            dt.Rows.Add(sumRow);
            SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true);

            Response.Clear();
            Response.AddHeader(@"content-disposition", @"attachment;filename=SuppliersExportForCRM_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
            Response.Charset         = @"UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = ex.FileContentType;
            Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            Response.Write(ex.ToString());
            Response.End();
        }
Exemplo n.º 15
0
 private void InitMedSort()
 {
     System.Data.DataTable dt;
     objSVC.GetMedSort(out dt);
     this.m_objViewer.m_cmbMedSort.DisplayMember = "ITEMCATNAME_VCHR";
     this.m_objViewer.m_cmbMedSort.ValueMember   = "ITEMCATID_CHR";
     System.Data.DataRow dr = dt.NewRow();
     dr["ITEMCATNAME_VCHR"] = "所有";
     dr["ITEMCATID_CHR"]    = "%";
     dt.Rows.InsertAt(dr, 0);
     this.m_objViewer.m_cmbMedSort.DataSource    = dt;
     this.m_objViewer.m_cmbMedSort.SelectedIndex = 0;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                System.Data.DataTable  dt  = new System.Data.DataTable();
                System.Data.DataColumn col = new System.Data.DataColumn("date");
                dt.Columns.Add(col);
                System.Data.DataColumn col2 = new System.Data.DataColumn("UserID");
                dt.Columns.Add(col2);
                System.Data.DataColumn col3 = new System.Data.DataColumn("type");
                dt.Columns.Add(col3);
                if (Request["type"] == "3")
                {
                    for (int i = 0; i < 12; i++)
                    {
                        System.Data.DataRow row = dt.NewRow();
                        row["date"]   = DateTime.Now.AddMonths(-i).ToString("yyyy-MM-dd");
                        row["UserID"] = Request["UserID"];
                        row["type"]   = Request["type"];
                        dt.Rows.Add(row);
                    }
                }
                else if (Request["type"] == "2")
                {
                    for (int i = 0; i < 4; i++)
                    {
                        System.Data.DataRow row = dt.NewRow();
                        row["date"]   = DateTime.Now.AddDays(-(i * 7)).ToString("yyyy-MM-dd");
                        row["UserID"] = Request["UserID"];
                        row["type"]   = Request["type"];
                        dt.Rows.Add(row);
                    }
                }
                else
                {
                    for (int i = 0; i < 31; i++)
                    {
                        System.Data.DataRow row = dt.NewRow();
                        row["date"]   = DateTime.Now.AddDays(-i).ToString("yyyy-MM-dd");
                        row["UserID"] = Request["UserID"];
                        row["type"]   = Request["type"];
                        dt.Rows.Add(row);
                    }
                }


                DataList1.DataSource = dt;
                DataList1.DataBind();
            }
        }
Exemplo n.º 17
0
        public static void ToCSV(string path, string[,] data)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            int row = data.GetLength(0);
            int column = data.GetLength(1);
            for (int j = 0; j < column; j++)
            {
                dt.Columns.Add(data[0, j], typeof(String));
            }

            for (int i = 0; i < row; i++)   //含表头
            {
                dt.Rows.Add(dt.NewRow());
                for (int j = 0; j < column; j++)
                {
                    if (!String.IsNullOrEmpty(data[i, j]))
                    {
                        dt.Rows[i][j] = "\"" + data[i, j].Replace("\"", "\"\"") + "\"";
                    }
                }
            }
            dt.AcceptChanges();

            CsvOptions options = new CsvOptions("String[,]", ',', data.GetLength(1));
            CsvEngine.DataTableToCsv(dt, path, options);
        }
Exemplo n.º 18
0
        public System.Data.DataTable GetRandomPasswords()
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("id", typeof(int));
            dt.Columns.Add("password", typeof(string));
            dt.Columns.Add("des3", typeof(string));


            System.Data.DataRow dr = null;


            AbstractPasswordOptions passwordOptions = new SwissPasswordOptions();

            for (int i = 0; i < 1000; ++i)
            {
                dr       = dt.NewRow();
                dr["id"] = i + 1;
                string pw = PasswordGenerator.RandomPassword(passwordOptions);
                dr["password"] = pw;
                dr["des3"]     = Cryptography.DES.Encrypt(pw);

                dt.Rows.Add(dr);
            }

            return(dt);
        }
Exemplo n.º 19
0
 private static void AddNewRow(System.Data.DataTable dt, int id, string text = null)
 {
     System.Data.DataRow drNew = dt.NewRow();
     drNew[0] = id;
     drNew[1] = text;
     dt.Rows.Add(drNew);
 }
Exemplo n.º 20
0
        public static void Init()
        {
            dataTable = new System.Data.DataTable("Ivas");
            System.Data.DataColumn myDataColumn;

            myDataColumn = new System.Data.DataColumn();
            myDataColumn.DataType = System.Type.GetType("System.Int32");
            myDataColumn.ColumnName = "Codigo";
            dataTable.Columns.Add(myDataColumn);

            myDataColumn = new System.Data.DataColumn();
            myDataColumn.DataType = System.Type.GetType("System.Int32");
            myDataColumn.ColumnName = "Porcentaje";
            dataTable.Columns.Add(myDataColumn);

            dataTable.PrimaryKey = new System.Data.DataColumn[]{dataTable.Columns["Codigo"]} ;

            System.Data.DataRow dataRow ;
            for ( int i = 0 ; i < 5 ; i++ )
            {
                dataRow = dataTable.NewRow();
                dataRow["Codigo"] = i+1 ;
                dataRow["Porcentaje"] = 0 ;
                dataTable.Rows.Add(dataRow);
            }
        }
Exemplo n.º 21
0
		public System.Data.DataTable DataReaderToDataTable(MySqlDataReader Reader)
		{
			System.Data.DataTable dt = new System.Data.DataTable();
			System.Data.DataColumn dc;
			System.Data.DataRow dr;
			ArrayList arr = new ArrayList();
			int i;

			for(i=0;i<Reader.FieldCount;i++)
			{
				dc = new System.Data.DataColumn();

				dc.ColumnName = Reader.GetName(i);					
				arr.Add(dc.ColumnName);

				dt.Columns.Add(dc);
			}
			
			while(Reader.Read())
			{
				dr = dt.NewRow();

				for (i=0;i<Reader.FieldCount;i++)
				{
					dr[(string)arr[i]] = Reader[i].ToString();
				}
				dt.Rows.Add(dr);
			}

			Reader.Close();
			return dt;
		}
Exemplo n.º 22
0
        private void DataGrid_Initialized(object sender, System.EventArgs e)
        {
            // TODO: Delete all this code and replace it with a simple query when database is available.

            SourceDataTable = new System.Data.DataTable("Priorities");
            SourceDataTable.Columns.Add(new System.Data.DataColumn("ID", System.Type.GetType("System.Int32")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Name", System.Type.GetType("System.String")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Value", System.Type.GetType("System.Int32")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Active", System.Type.GetType("System.Boolean")));

            System.Action<int, string, int, bool> AddNewRow = (id, name, value, active) =>
                {
                    var row = SourceDataTable.NewRow();
                    row["ID"] = id;
                    row["Name"] = name;
                    row["Value"] = value;
                    row["Active"] = active;
                    SourceDataTable.Rows.Add(row);
                };

            AddNewRow(1, "Haute", 1, true);
            AddNewRow(2, "Moyenne", 2, true);
            AddNewRow(3, "Faible", 3, true);

            Save();
        }
Exemplo n.º 23
0
        public System.Data.DataTable DataReaderToDataTable(MySqlDataReader Reader)
        {
            System.Data.DataTable  dt = new System.Data.DataTable();
            System.Data.DataColumn dc;
            System.Data.DataRow    dr;
            ArrayList arr = new ArrayList();
            int       i;

            for (i = 0; i < Reader.FieldCount; i++)
            {
                dc = new System.Data.DataColumn();

                dc.ColumnName = Reader.GetName(i);
                arr.Add(dc.ColumnName);

                dt.Columns.Add(dc);
            }

            while (Reader.Read())
            {
                dr = dt.NewRow();

                for (i = 0; i < Reader.FieldCount; i++)
                {
                    dr[(string)arr[i]] = Reader[i].ToString();
                }
                dt.Rows.Add(dr);
            }

            Reader.Close();
            return(dt);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Read data types from csv file
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public System.Data.DataTable readDataTypes(string filePath)
        {
            string mappingFile = filePath + @"\variableMapping.xlsx";

            System.Data.DataTable mappedDataTypes = new System.Data.DataTable();
            mappedDataTypes.Columns.Add("Name", typeof(string));
            mappedDataTypes.Columns.Add("Description", typeof(string));
            mappedDataTypes.Columns.Add("SystemType", typeof(string));
            mappedDataTypes.Columns.Add("DisplayPattern", typeof(string));
            mappedDataTypes.Columns.Add("DataTypesId", typeof(long));

            if (File.Exists(filePath + "\\datatypes.csv"))
            {
                StreamReader reader = new StreamReader(filePath + "\\datatypes.csv");

                string line = "";
                //jump over the first row
                line = reader.ReadLine();

                while ((line = reader.ReadLine()) != null)
                {
                    // (char)59 = ';'
                    string[] vars = line.Split((char)59);

                    System.Data.DataRow newRow = mappedDataTypes.NewRow();
                    newRow["Name"]           = vars[0];
                    newRow["Description"]    = vars[1];
                    newRow["SystemType"]     = vars[2];
                    newRow["DisplayPattern"] = vars[3];
                    mappedDataTypes.Rows.Add(newRow);
                }
            }

            return(mappedDataTypes);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 将返回数据转装成DataTable
        /// </summary>
        /// <returns></returns>
        private System.Data.DataTable BrowseResultInfo()
        {
            System.Data.DataTable dgTable = new System.Data.DataTable();
            try
            {
                dgTable.Columns.Clear();       //清空头信息
                dgTable.Rows.Clear();          //清空行记录

                dgTable.Columns.Add(config.ReadConfigValue("MGM", "NL_Code_Sender"), typeof(string));
                dgTable.Columns.Add(config.ReadConfigValue("MGM", "NL_Code_Reciver"), typeof(string));
                dgTable.Columns.Add(config.ReadConfigValue("MGM", "NL_Code_Title"), typeof(string));
                dgTable.Columns.Add(config.ReadConfigValue("MGM", "NL_Code_Content"), typeof(string));
                dgTable.Columns.Add(config.ReadConfigValue("MGM", "NL_Code_Date"), typeof(DateTime));

                for (int i = 0; i < mResult.GetLength(0); i++)
                {
                    System.Data.DataRow dgRow = dgTable.NewRow();

                    dgRow[config.ReadConfigValue("MGM", "NL_Code_Sender")]  = mResult[i, 1].oContent.ToString();
                    dgRow[config.ReadConfigValue("MGM", "NL_Code_Reciver")] = mResult[i, 2].oContent.ToString();
                    dgRow[config.ReadConfigValue("MGM", "NL_Code_Title")]   = mResult[i, 3].oContent.ToString();
                    dgRow[config.ReadConfigValue("MGM", "NL_Code_Content")] = mResult[i, 4].oContent.ToString();
                    dgRow[config.ReadConfigValue("MGM", "NL_Code_Date")]    = mResult[i, 5].oContent.ToString();

                    dgTable.Rows.Add(dgRow);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(dgTable);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 将个人应用加入表(Table)
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="appDt"></param>
        public void AppendUserApps(Guid userID, System.Data.DataTable appDt)
        {
            var userApps = GetUserDataRows(userID);

            foreach (var userApp in userApps)
            {
                if (appDt.Select("ID='" + userApp["ID"].ToString() + "'").Length == 0)
                {
                    System.Data.DataRow dr = appDt.NewRow();
                    dr["ID"]       = userApp["ID"];
                    dr["ParentID"] = userApp["ParentID"];
                    dr["RoleID"]   = userApp["RoleID"];
                    dr["AppID"]    = userApp["AppID"];
                    dr["Title"]    = userApp["Title"];
                    dr["Params"]   = userApp["Params"];
                    dr["Sort"]     = userApp["Sort"];
                    dr["Ico"]      = userApp["Ico"];
                    dr["Type"]     = 1;
                    dr["Address"]  = userApp["Address"];
                    dr["OpenMode"] = userApp["OpenMode"];
                    dr["Width"]    = userApp["Width"];
                    dr["Height"]   = userApp["Height"];
                    dr["Params1"]  = userApp["Params1"];
                    dr["Manager"]  = userApp["Manager"];
                    appDt.Rows.Add(dr);
                }
            }
        }
Exemplo n.º 27
0
        private void ExportPopDataBtn_Click(object sender, EventArgs e)
        {
            var statistic_dt = new System.Data.DataTable($"iteration_{iteration}");
            var Columns      = new string[] { "Iteration", "Average Population", "_", "Iteration_", "Tcycle coincides" };

            for (int i = 0; i < 5; i++)
            {
                statistic_dt.Columns.Add(Columns[i]);
            }

            for (int i = 0; i < N1; i++)
            {
                var dr = statistic_dt.NewRow();
                //dr[0] = i;

                dr[0] = i;
                dr[1] = populationStatistic[i];
                dr[2] = "";
                dr[3] = populationTCycleStatistic.Count - i <= 0 ? "" : populationTCycleStatistic[i].iteration.ToString();
                dr[4] = populationTCycleStatistic.Count - i <= 0 ? "": populationTCycleStatistic[i].population.ToString();

                statistic_dt.Rows.Add(dr);
            }

            var wb = new XLWorkbook();

            wb.Worksheets.Add(statistic_dt).Columns().AdjustToContents();

            wb.SaveAs($"../../Uploads/logs/{iteration}_populationStatistic.xlsx");
        }
Exemplo n.º 28
0
        public System.Data.DataTable ListaServidoresCompletaApp(bool IncluirValorInicial = true)
        {
            DLSoftware DataLayerSoftware = new DLSoftware();

            System.Data.DataTable Resultados = new System.Data.DataTable();

            Resultados.Columns.Add("Srv_Id");
            Resultados.Columns.Add("Srv_Nombre");
            Resultados.Columns.Add("EsPropietaria");

            foreach (System.Data.DataRow dr in DataLayerSoftware.getServidoresCompletaApp(IncluirValorInicial).Rows)
            {
                System.Data.DataRow drN;

                drN    = Resultados.NewRow();
                drN[0] = dr[0].ToString();
                drN[1] = dr[1].ToString();
                drN[2] = "";

                Resultados.Rows.Add(drN);
            }

            Resultados.AcceptChanges();

            return(Resultados);
        }
Exemplo n.º 29
0
        public static System.Data.DataTable GetDataTabelFromExcelFile(string fileName, int startRowIndex)
        {
            System.Data.DataTable dataSource = new System.Data.DataTable();
            dataSource.Columns.Add("Index", typeof(string));
            dataSource.Columns.Add("IndexNPOI", typeof(string));
            dataSource.Columns.Add("Name", typeof(string));
            dataSource.Columns.Add("Description", typeof(string));
            dataSource.Columns.Add("HexString", typeof(string));

            // 获取Workbook。
            NPOI.SS.UserModel.IWorkbook workbook = NPOIExtension.GetWorkbookFromExcelFile(fileName);
            if (workbook == null)
            {
                return(dataSource);
            }

            // 获取Sheet
            NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);
            for (int i = startRowIndex; i < sheet.LastRowNum; i++)
            {
                NPOI.SS.UserModel.IRow row           = sheet.GetRow(i);
                System.Data.DataRow    dataSourceRow = dataSource.NewRow();
                dataSource.Rows.Add(dataSourceRow);
                for (int j = 0; j < dataSource.Columns.Count; j++)
                {
                    dataSourceRow[j] = row.GetCell(j).ToString();
                }
            }
            return(dataSource);
        }
Exemplo n.º 30
0
        private System.Data.DataTable GetAllBenchmarks()
        {
            HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
            //HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.Load(@"");
            HtmlAgilityPack.HtmlDocument doc = web.Load(@"http://benchmarksgame.alioth.debian.org/");

            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Url", typeof(string));

            System.Data.DataRow dr = null;

            foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//section[1]//li/a[@href]"))
            {
                dr = dt.NewRow();
                // System.Console.WriteLine(link);
                dr["Name"] = System.Web.HttpUtility.HtmlDecode(link.InnerText);
                dr["Url"] = link.Attributes["href"].Value;

                dt.Rows.Add(dr);
            } // Next link

            System.Data.DataView dv = dt.DefaultView;
            dv.Sort = "Name ASC";
            System.Data.DataTable sortedDT = dv.ToTable();

            return sortedDT;
        }
Exemplo n.º 31
0
        public static System.Data.DataTable GetBlockPropertiesTable([NotNull] this BlockTableRecord dynBtr)
        {
            var t = dynBtr.Database.TransactionManager.TopTransaction;

            using var bpt = GetBPT(dynBtr, t);
            if (bpt == null)
            {
                return(null);
            }
            var dTable  = new System.Data.DataTable($"Таблица свойств блока {dynBtr.Name}");
            var columns = GetColumns(bpt);

            dTable.Columns.AddRange(columns.ToArray());
            foreach (BlockPropertiesTableRow bptRow in bpt.Rows)
            {
                var row = dTable.NewRow();
                for (var i = 0; i < columns.Count; i++)
                {
                    var col = columns[i];
                    if (string.IsNullOrEmpty(col.ColumnName))
                    {
                        continue;
                    }
                    var bptCol = bpt.Columns[i];
                    var tv     = bptRow[bptCol];
                    var val    = tv.AsArray()[0].Value;
                    row[col] = val;
                }

                dTable.Rows.Add(row);
            }

            return(dTable);
        }
Exemplo n.º 32
0
        private bool bSalvaDadosInternet(bool bProxy, string strProxyHost, string strProxyPort, bool bProxyAutentication, string strProxyUser, string strProxyPassword)
        {
            bool bRetorno = true;

            System.Data.DataSet   dtstProxy = new System.Data.DataSet(DATASET_NAME);
            System.Data.DataTable dttbProxy = new System.Data.DataTable(DATASET_PROXY_NAME);
            dttbProxy.Columns.Add(DATASET_HOST_NAME);
            dttbProxy.Columns.Add(DATASET_PORT_NAME);
            dttbProxy.Columns.Add(DATASET_USER_NAME);
            dttbProxy.Columns.Add(DATASET_PASSWORD_NAME);
            dtstProxy.Tables.Add(dttbProxy);

            System.Data.DataRow dtrwProxy = dttbProxy.NewRow();
            dtrwProxy[DATASET_HOST_NAME]     = strProxyHost;
            dtrwProxy[DATASET_PORT_NAME]     = strProxyPort;
            dtrwProxy[DATASET_USER_NAME]     = strProxyUser;
            dtrwProxy[DATASET_PASSWORD_NAME] = strProxyPassword;
            dttbProxy.Rows.Add(dtrwProxy);

            try{
                dtstProxy.WriteXml(m_strFileConfigPath + m_strFileConfigName);
            }catch {
                bRetorno = false;
            }
            return(bRetorno);
        }
Exemplo n.º 33
0
        public System.Data.DataTable ToTable()
        {
            var tb = new System.Data.DataTable(this.Name);

            foreach (var c in this.Columns)
            {
                tb.Columns.Add(c.ToColumn());
            }

            foreach (var r in this.Rows)
            {
                var row = tb.NewRow();

                foreach (var item in r.ItemArray)
                {
                    if (!string.IsNullOrWhiteSpace(item.Value))
                    {
                        try
                        {
                            var column = tb.Columns[item.ColumnName];
                            if (column.DataType.FullName.Equals("System.Byte[]", StringComparison.OrdinalIgnoreCase))
                            {
                                row[item.ColumnName] = !string.IsNullOrWhiteSpace(item.Value) ?Convert.FromBase64String(item.Value):null;
                            }
                            else if (column.DataType.FullName.Equals("System.DateTime", StringComparison.OrdinalIgnoreCase))
                            {
                                if (string.IsNullOrWhiteSpace(item.Value) == false)
                                {
                                    var s = item.Value.IndexOf('/');
                                    //如果/在第三个后,则表示为天/月/年
                                    if (s == 2)
                                    {
                                        row[item.ColumnName] = DateTime.ParseExact(item.Value, "dd/MM/yyyy HH:mm:ss", null);
                                    }
                                    else if (s > 2)
                                    {
                                        row[item.ColumnName] = DateTime.ParseExact(item.Value, "yyyy/MM/dd HH:mm:ss", null);
                                    }
                                    else
                                    {
                                        row[item.ColumnName] = DateTime.Parse(item.Value);
                                    }
                                }
                            }
                            else
                            {
                                row[item.ColumnName] = item.Value;
                            }
                        }
                        catch (Exception ex)
                        {
                            System.Diagnostics.Debug.WriteLine(ex.Message);
                        }
                    }
                }
                tb.Rows.Add(row);
            }

            return(tb);
        }
Exemplo n.º 34
0
        static void Main(string[] args)
        {
            var dt = new System.Data.DataTable();

            dt.Columns.Add("name");
            dt.Columns.Add("videotitle");
            dt.Columns.Add("link");
            dt.Columns.Add("thumb");

            for (int i = 0, j = 5; i <= j; i++)
            {
                var row = dt.NewRow();
                row["name"]       = string.Format("video {0}", i);
                row["videotitle"] = string.Format("video {0}", i);
                row["link"]       = string.Format("/someurl/video{0}.avi", i);
                row["thumb"]      = string.Format("/someurl/video{0}.png", i);
                dt.Rows.Add(row);
            }
            var xmlDoc = CreatePlaylist(dt);

            Console.WriteLine(XDocToStringWithDeclaration(xmlDoc));


            Console.WriteLine("{0}Finished... Press a key", Environment.NewLine);
            Console.ReadKey();
        }
Exemplo n.º 35
0
        protected override void Execute(CodeActivityContext context)
        {
            var inputString = InputString.Get(context);
            var delimiter   = Delimiter.Get(context);

            var strArray = inputString.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

            // Declare DataTable object.
            var dt = new System.Data.DataTable();

            // Add columns to the DataTable
            dt.Columns.Add("LINENUMBER", typeof(String));
            dt.Columns.Add("PARTNUMBER", typeof(String));
            dt.Columns.Add("DESCRIPTION", typeof(String));
            dt.Columns.Add("ORDERQTY", typeof(String));
            dt.Columns.Add("UNITPRICE", typeof(String));

            // Add strings from string array to datatable
            foreach (string str in strArray)
            {
                var drow = dt.NewRow();   // Here you will get an actual instance of a DataRow

                var strArrayTemp = str.Split(new string[] { delimiter }, StringSplitOptions.None);

                drow[0] = strArrayTemp[0];
                drow[1] = strArrayTemp[1];
                drow[2] = strArrayTemp[2];
                drow[3] = strArrayTemp[3];
                drow[4] = strArrayTemp[4];

                dt.Rows.Add(drow);             // Don't forget to add the row to the DataTable.
            }

            dtOutput.Set(context, dt);
        }
Exemplo n.º 36
0
 /// <summary>
 /// Export data from CSV file given the full filename.
 /// </summary>
 /// <param name="FileName">CSV file</param>
 /// <returns>DataTable containing data from CSV file. All columns are in string type.</returns>
 public static System.Data.DataTable CSVToDataTable(string FileName)
 {
     #region logic
     System.Data.DataTable result = new System.Data.DataTable();
     System.IO.StreamReader fileReader = null;
     if (!System.IO.File.Exists(FileName))
     {
         throw new System.IO.IOException("File not found!");
     }
     if (new System.IO.FileInfo(FileName).Length == 0)
     {
         throw new Exception("File is EMPTY!");
     }
     try
     {
         fileReader = new System.IO.StreamReader(FileName);
         List<string> headers = RowToList(fileReader.ReadLine());
         foreach (string header in headers)
         {
             System.Data.DataColumn tempColumn = new System.Data.DataColumn();
             tempColumn.ColumnName = header;
             tempColumn.DataType = Type.GetType("System.String");
             result.Columns.Add(tempColumn);
             tempColumn = null;
         }
         string singleRow = "";
         while ((singleRow = fileReader.ReadLine()) != null)
         {
             System.Data.DataRow tempRow = result.NewRow();
             List<string> dataInList = RowToList(singleRow);
             for (int i = 0; i < result.Columns.Count; i++)
             {
                 tempRow.ItemArray[i] = dataInList[i];
             }
         }
     }
     #endregion
     #region exception handling
     catch (Exception AllEx)
     {
         throw AllEx;
     }
     finally
     {
         if (fileReader.BaseStream.CanRead)
         {
             fileReader.Close();
         }
         fileReader = null;
     }
     #endregion
     return result;
 }
Exemplo n.º 37
0
        public void EvaluatorTestArrayDictDataRow()
        {
            var eval = new ExpressionEvaluator();
              //Create an array, a dictionary and a data row and add them to Globals
              eval.Globals["primes"] = new int[] { 3, 5, 7, 11, 13 };
              var nums = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
              nums["one"] = "1";
              nums["two"] = "2";
              nums["three"] = "3";
              eval.Globals["nums"] = nums;
              var t = new System.Data.DataTable();
              t.Columns.Add("Name", typeof(string));
              t.Columns.Add("Age", typeof(int));
              var row = t.NewRow();
              row["Name"] = "John";
              row["Age"] = 30;
              eval.Globals["row"] = row;

              string script;
              object result;

              //Test array
              script = @"primes[3]";
              result = eval.Evaluate(script);
              Assert.AreEqual(11, result, "Unexpected computation result");
              script = @"
            primes[3] = 12345
            primes[3]";
              result = eval.Evaluate(script);
              Assert.AreEqual(12345, result, "Unexpected computation result");

              //Test dict
              script = @"nums['three'] + nums['two'] + nums['one']";
              result = eval.Evaluate(script);
              Assert.AreEqual("321", result, "Unexpected computation result");
              script = @"
            nums['two'] = '22'
            nums['three'] + nums['two'] + nums['one']
            ";
              result = eval.Evaluate(script);
              Assert.AreEqual("3221", result, "Unexpected computation result");

              //Test data row
              script = @"row['Name'] + ', ' + row['age']";
              result = eval.Evaluate(script);
              Assert.AreEqual("John, 30", result, "Unexpected computation result");
              script = @"
            row['Name'] = 'Jon'
            row['Name'] + ', ' + row['age']";
              result = eval.Evaluate(script);
              Assert.AreEqual("Jon, 30", result, "Unexpected computation result");
        }
Exemplo n.º 38
0
        private void TasksListView_Initialized(object sender, System.EventArgs e)
        {
            var table = new System.Data.DataTable("Tasks");
            table.Columns.Add(new System.Data.DataColumn("Name"));
            table.Columns.Add(new System.Data.DataColumn("DeadlineID"));
            table.Columns.Add(new System.Data.DataColumn("PriorityID"));
            table.Columns.Add(new System.Data.DataColumn("Completion"));

            var row1 = table.NewRow();
            row1["Name"] = "Rapport du TP3";
            row1["DeadlineID"] = 1;
            row1["PriorityID"] = 1;
            row1["Completion"] = 0.15;
            table.Rows.Add(row1);

            var row2 = table.NewRow();
            row2["Name"] = "Entrevue pour un stage";
            row2["DeadlineID"] = 2;
            row2["PriorityID"] = 2;
            row2["Completion"] = 0;
            table.Rows.Add(row2);

            TasksListView.ItemsSource = table.DefaultView;
        }
Exemplo n.º 39
0
        public void LoadWithFieldMap()
        {
            MockRepository mocks = new MockRepository();
            FFLib.Data.DBProviders.IDBProvider dbprovider = mocks.Stub<FFLib.Data.DBProviders.IDBProvider>();
            FFLib.Data.IDBConnection Conn = mocks.Stub<FFLib.Data.IDBConnection>();
            FFLib.Data.DBTable<TestDTO2> dtoTable;
            TestDTO2 expected = new TestDTO2();
            expected.XID = 1;

            System.Data.DataTable dr = new System.Data.DataTable();
            dr.Columns.Add("ID", typeof(int));
            dr.Columns.Add("Name", typeof(String));
            dr.Columns.Add("Status", typeof(string));
            dr.Columns.Add("CreateDate", typeof(DateTime));
            System.Data.DataRow drRow = dr.NewRow();
            drRow["ID"] = 1;
            drRow["Name"] = "test";
            drRow["Status"] = "open";
            drRow["CreateDate"] = DateTime.Now;
            dr.Rows.Add(drRow);

            System.Data.IDataReader idr = dr.CreateDataReader();

            using (mocks.Record())
            {
                dbprovider.Stub(x => x.ExecuteReader(null, null, null)).IgnoreArguments().Repeat.Any().Return(idr);
                Conn.Open();
                LastCall.Repeat.Any();
                Conn.Stub(x => x.InTrx).Repeat.Any().Return(false);
                Conn.Stub(x => x.dbProvider).Return((FFLib.Data.DBProviders.IDBProvider)dbprovider).Repeat.Any();
                Conn.Stub(x => x.State).Repeat.Any().Return(System.Data.ConnectionState.Closed);
            }

            using (mocks.Playback())
            {
                dtoTable = new FFLib.Data.DBTable<TestDTO2>(Conn);
                TestDTO2 result = dtoTable.Load(1);
                Assert.AreEqual(expected.XID, result.XID);
            }
        }
Exemplo n.º 40
0
        private void btnTestAll_Click(object sender, System.EventArgs e)
        {
            dt = CreateTable();

            string correct = "Brokers México, Intermediario de Aseguro,S.A.";
            string broken = "Brokers México, Intermediario de Aseguro,S.A."; // Get text from database

            correct = this.txtCorrect.Text;
            broken = this.txtWrong.Text;

            System.Text.EncodingInfo[] encs = System.Text.Encoding.GetEncodings();
            for (int i = 0; i < encs.Length; ++i)
            {

                for (int j = 0; j < encs.Length; ++j)
                {
                    System.Data.DataRow dr = dt.NewRow();

                    dr["SourceEncoding"] = encs[i].CodePage;
                    dr["TargetEncoding"] = encs[j].CodePage;

                    System.Text.Encoding enci = System.Text.Encoding.GetEncoding(encs[i].CodePage);
                    System.Text.Encoding encj = System.Text.Encoding.GetEncoding(encs[j].CodePage);

                    byte[] encoded = enci.GetBytes(broken);
                    string corrected = encj.GetString(encoded);

                    dr["Result"] = corrected;

                    dr["SourceEncodingName"] = enci.BodyName;
                    dr["TargetEncodingName"] = encj.BodyName;

                    if (System.StringComparer.InvariantCultureIgnoreCase.Equals(correct, corrected))
                        dt.Rows.Add(dr);
                } // Next j

            } // Next i

            this.dgvResult.DataSource = dt;
        }
        public virtual void ProcessCommand(OSAE.OSAEMethod method)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.DataRow row;
            dt.Columns.Add("method_name", typeof(string));
            dt.Columns.Add("object_name", typeof(string));
            dt.Columns.Add("parameter_1", typeof(string));
            dt.Columns.Add("parameter_2", typeof(string));
            dt.Columns.Add("address", typeof(string));
            dt.Columns.Add("object_owner", typeof(string));

            row = dt.NewRow();
            row["method_name"] = method.MethodName;
            row["object_name"] = method.ObjectName;
            row["parameter_1"] = method.Parameter1;
            row["parameter_2"] = method.Parameter2;
            row["address"] = method.Address;
            row["object_owner"] = method.Owner;
            dt.Rows.Add(row);

            _view.ProcessCommand(dt);
        }
Exemplo n.º 42
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            Guid rolId = new Guid(ddlBusquedaRoles.SelectedValue);
            System.Data.DataRow row = null;

            List<Usuario> result = Usuario.Buscar(txtBusquedaNombre.Text, txtBusquedaPrimerNombre.Text, txtBusquedaPrimerApellido.Text, rolId);

            System.Data.DataTable tablaUsuarios = new System.Data.DataTable();
            tablaUsuarios.Columns.Add("Id");
            tablaUsuarios.Columns.Add("NombreUsuario");
            foreach (Usuario actual in result)
            {
                row = tablaUsuarios.NewRow();
                row["Id"] = actual.Id.ToString();
                row["NombreUsuario"] = actual.NombreUsuario;
                tablaUsuarios.Rows.Add(row);
            }

            tablaUsuarios.AcceptChanges();

            gvUsuarios.DataSource = tablaUsuarios;

            gvUsuarios.DataBind();
        }
Exemplo n.º 43
0
        public static void exportTblScripts(DeviceFile.DeviceScripts[] fScripts, String filename)
        {
            DTBL tblScripts= new DTBL("Scripts");
            setupTblScripts( tblScripts);

            System.Data.DataRow myNewRow;

            for (int i = 0; i < fScripts.Length; i++)
            {
                myNewRow = tblScripts.NewRow();

                myNewRow["ScriptNumber"] = fScripts[i].ScriptNumber; //UInt16();
                myNewRow["ScriptName"] = fScripts[i].ScriptName; //String();
                myNewRow["ScriptVersion"] = fScripts[i].ScriptVersion; //UInt16();
                myNewRow["UNUSED1"] = fScripts[i].UNUSED1; //UInt32();
                myNewRow["ScriptLength"] = fScripts[i].ScriptLength; //UInt16();
                myNewRow["Script"] = fScripts[i].Script;  //Unit16[];
                myNewRow["Comment"] = fScripts[i].Comment; //String();

                tblScripts.Rows.Add(myNewRow);
            }

            tblScripts.WriteXml(filename, System.Data.XmlWriteMode.WriteSchema);
        }
Exemplo n.º 44
0
        public void updateGridView()
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("Задача");
            dt.Columns.Add("В работе");
            dt.Columns.Add("На доработке");
            dt.Columns.Add("Срок сдачи");
            //dt.Columns.Add("Статус");
            dt.Columns.Add("Сдана");
            dt.Columns.Add("Просрочена на");
            DateTime defaultTime = new DateTime(1, 1, 1);
            TimeSpan exceedTime;
            Task task;

            for (int i = 0; i < TasksDict.Count; i++)
            {
                task = TasksDict.ElementAt(i).Value;
                var row = dt.NewRow();
                row["Задача"] = task.name;
                //row["Статус"] = task.status;
                row["В работе"] = task.workTime;
                row["На доработке"] = task.correctingTime;
                row["Срок сдачи"] = task.deadline.ToShortDateString() + ", " + task.deadline.ToShortTimeString(); ;
                if (task.finishDate == defaultTime)
                {
                    row["Сдана"] = "Не сдано";
                    exceedTime = (task.deadline - System.DateTime.Now);
                }
                else
                {
                    row["Сдана"] = task.finishDate.ToShortDateString() + ", " + task.finishDate.ToShortTimeString();
                    exceedTime = (task.deadline - task.finishDate);
                }
                if (exceedTime.TotalSeconds < 0)
                {
                    row["Просрочена на"] = -exceedTime.Days + " дн " + -exceedTime.Hours + " ч " + -exceedTime.Minutes + " мин";
                }
                else
                    row["Просрочена на"] = "Не просрочена";
                dt.Rows.Add(row);
            }

            TasksGridView.ItemsSource = dt.DefaultView;
        }
Exemplo n.º 45
0
        /// <summary>
        /// Loads the data from the source. Can be an excel address or a range.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="hasHeaders"></param>
        /// <returns><see cref="Table"/></returns>
        public Table From(object source, bool hasHeaders = true) {
            try {
                IRange range = ExcelExt.GetRange(source);
                if (range.Count == 1) {
                    IListObject listObject = range.ListObject;
                    if (listObject != null) {
                        IExcel excel = range.Application;
                        range = excel[listObject.HeaderRowRange, listObject.DataBodyRange];
                    } else {
                        range = range.CurrentRegion;
                    }
                }

                var values = (object[,])range.Value2 ?? new object[1, 1];
                int clen = values.GetLength(1);
                int rlen = values.GetLength(0);

                _table = new System.Data.DataTable();
                _columns = _table.Columns;
                int irow = hasHeaders ? 2 : 1;
                for (var icol = 0; icol++ < clen; ) {
                    Type coltype = GetColumnType(values, irow, icol);

                    object colvalue = hasHeaders ?
                        values[1, icol]
                        : (icol + 1);

                    string colname = colvalue == null ?
                        string.Empty
                        : colvalue.ToString();

                    _columns.Add(new System.Data.DataColumn(colname, coltype));
                }

                _rowsall = _table.Rows;
                for (int r = hasHeaders ? 1 : 0; r++ < rlen; ) {
                    System.Data.DataRow row = _table.NewRow();
                    for (var c = 0; c < clen; c++)
                        row[c] = values[r, c + 1];

                    _rowsall.Add(row);
                }

                _hasheaders = hasHeaders;
                _cells = (ICells)range;
                return this;
            } catch (SeleniumException) {
                throw;
            } catch (Exception ex) {
                throw new SeleniumException(ex);
            }
        }
Exemplo n.º 46
0
        public override void ValidateUrl()
        {
            switch (Request.GroupString["class"]) {
                case "entity":
                    switch (Request.GroupString["type"]) {
                        case "list":
                            short _typeID = Convert.ToInt16(Request.GroupString["id"]);

                            int _totalCout = -1;

                            int _pageIndex = 0,_pageSize = 20;
                            string _where = string.Empty, _order = string.Empty, _filters = string.Empty;
                            if (!string.IsNullOrEmpty(Request.Form["PageIndex"])) _pageIndex = Convert.ToInt32(Request.Form["PageIndex"]);
                            if (!string.IsNullOrEmpty(Request.Form["PageSize"])) _pageSize = Convert.ToInt32(Request.Form["PageSize"]);
                            if (!string.IsNullOrEmpty(Request.Form["Where"])) _where = Request.Form["Where"];
                            if (!string.IsNullOrEmpty(Request.Form["Order"])) _order = Request.Form["Order"];
                            if (!string.IsNullOrEmpty(Request.Form["Filter"])) _filters = Request.Form["Filter"].Trim(',') + ',';

                            XiaoYang.Entity.EntityHelper _helper = new Entity.EntityHelper(_typeID);

                            PageData.AddXyDataModel("EntityType", Entity.EntityType.GetInstance(_typeID));
                            System.Data.DataTable _dt = new System.Data.DataTable();
                            _dt.Columns.Add("Name", typeof(string));
                            _dt.Columns.Add("Key", typeof(string));
                            _dt.Columns.Add("IsShow", typeof(bool));
                            for (int i = 0; i < _helper.CacheInstance.AttributeKeys.Length; i++) {
                                System.Data.DataRow _row = _dt.NewRow();
                                _row["Name"] = _helper.CacheInstance.AttributeNames[i];
                                _row["Key"] = _helper.CacheInstance.AttributeKeys[i];
                                _row["IsShow"] = _filters.IndexOf(_helper.CacheInstance.AttributeKeys[i] + ',') != -1;
                                _dt.Rows.Add(_row);
                            }
                            PageData.Add("Attributes", _dt);
                            XiaoYang.Entity.EntityCollection _ec = _helper.GetList(_where, _pageIndex, _pageSize, _order, ref _totalCout);
                            PageData.AddEntireXyDataModel("EntityList", _ec);
                            PageData["EntityList"].CreatePagination(_pageIndex, _pageSize, _totalCout, 9);
                            break;
                        case "add":
                            XiaoYang.Entity.EntityHelper _addHelper = new Entity.EntityHelper(Convert.ToInt16(Request.GroupString["id"]));
                            long _addID = _addHelper.Add(Request.Form);
                            Response.Write("{status:'success',message:'Success',returnURL:'/entity_edit_" + _addID + "." + WebSetting.Config["ext"] + "'}");
                            Response.Redirect("/entity_edit_" + _addID + "." + WebSetting.Config["ext"] + "#successed");
                            break;
                        case "edit":
                            Entity.EntityBase _editEntity = Entity.EntityBase.GetInstance(Convert.ToInt64(Request.GroupString["id"]));
                            XiaoYang.Entity.EntityHelper _editHelper = new Entity.EntityHelper(_editEntity.TypeID);
                            _editHelper.Edit(Request.Form, _editEntity.ID);
                            Response.Redirect("/entity_edit_" + _editEntity.ID + "." + WebSetting.Config["ext"] + "#successed");
                            break;
                        case "del":
                            Entity.EntityBase _delEntity = Entity.EntityBase.GetInstance(Convert.ToInt64(Request.GroupString["id"]));
                            XiaoYang.Entity.EntityHelper _delHelper = new Entity.EntityHelper(_delEntity.TypeID);
                            _delHelper.Del(_delEntity.ID);
                            break;
                    }
                    break;
                case "type":
                    switch (Request.GroupString["type"]) {
                        case "add":
                            XiaoYang.Entity.EntityType.Add(Request.Form);
                            break;
                        case "getattr":
                            Xy.Web.Control.DataControl _dc = new Xy.Web.Control.DataControl();
                            System.Collections.Specialized.NameValueCollection _dcInitTag = new System.Collections.Specialized.NameValueCollection();
                            Xy.Web.HTMLContainer _dcData = new Xy.Web.HTMLContainer(WebSetting.Encoding);
                            Xy.Web.HTMLContainer _dcContent = new Xy.Web.HTMLContainer(WebSetting.Encoding);
                            _dcInitTag.Add("Provider", "Procedure");
                            _dcInitTag.Add("Command", @"select [PostAttribute].*, [PostType].[IsActive] from [PostAttribute] left join [PostType] on [PostAttribute].[TypeID] = [PostType].[ID] where [TypeID] = @TypeID");
                            _dcInitTag.Add("Parameter", @"{ TypeID=""" + Request.QueryString["ID"] + @"|i"" }");
                            _dcInitTag.Add("EnableScript", "True");
                            _dcInitTag.Add("EnableCode", "True");
                            _dcInitTag.Add("Xslt", "attributelist.xslt");
                            _dc.Init(_dcInitTag, "PostAttributeControl", 999);
                            _dc.InnerData = _dcData;
                            _dc.Handle(ThreadEntity, this, _dcContent);
                            Response.Write(_dcContent);
                            break;
                        case "active":
                            XiaoYang.Entity.EntityType.EditActive(Request.Form);
                            break;
                        case "multi":
                            XiaoYang.Entity.EntityType.EditWebRelated(Request.Form);
                            break;
                        case "display":
                            XiaoYang.Entity.EntityType.EditDisplay(Request.Form);
                            break;
                        case "del":
                            XiaoYang.Entity.EntityType.Del(Convert.ToInt16(Request.Form["ID"]));
                            break;
                    }
                    break;
                case "attr":
                    switch (Request.GroupString["type"]) {
                        case "add":
                            XiaoYang.Entity.EntityAttribute.Add(Request.Form);
                            break;
                        case "edit":
                            XiaoYang.Entity.EntityAttribute.Edit(Request.Form);
                            break;
                        case "del":
                            XiaoYang.Entity.EntityAttribute.Del(Request.Form);
                            break;
                    }
                    break;
            }
        }
Exemplo n.º 47
0
 public System.Data.DataTable GetDataTable()
 {
     switch (_type) {
         case PageDataType.DataTable:
             return _dataTable;
         case PageDataType.Xml:
             return Xy.Tools.IO.XML.ConvertXMLFileToDataSet(_dataXml.CreateNavigator().OuterXml);
         case PageDataType.String:
         case PageDataType.Array:
             System.Data.DataTable _tempTable = new System.Data.DataTable();
             _tempTable.Columns.Add(_name);
             if (_type == PageDataType.String) {
                 System.Data.DataRow _tempRow = _tempTable.NewRow();
                 _tempRow[_name] = _dataString;
                 _tempTable.Rows.Add(_tempRow);
             } else {
                 for (int i = 0; i < _dataArray.Length; i++) {
                     System.Data.DataRow _tempRow = _tempTable.NewRow();
                     _tempRow[_name] = _dataArray.GetValue(i).ToString();
                     _tempTable.Rows.Add(_tempRow);
                 }
             }
             return _tempTable;
     }
     return null;
 }
Exemplo n.º 48
0
        private System.Data.DataTable GetData(string path)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            string baseURL = "http://benchmarksgame.alioth.debian.org/";
            string URL = baseURL + path;

            dt.Columns.Add("url", typeof(string));
            dt.Columns.Add("Rubrique", typeof(string));
            System.Data.DataRow dr = null;

            HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
            //HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.Load(@"");
            HtmlAgilityPack.HtmlDocument doc = web.Load(URL);

            string rubrique = null;
            bool haveHeaders = false;

            foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//table[1]//tr"))
            {
                dr = dt.NewRow();
                // System.Console.WriteLine(link);

                HtmlAgilityPack.HtmlNode a = link.SelectSingleNode("./th[@colspan=\"3\"]//a");

                if (a != null)
                {
                    rubrique = a.InnerText;
                    // System.Console.WriteLine(rubrique);
                    continue;
                } // End if (a != null)

                var tableHeaders = link.SelectNodes("./th");

                if (tableHeaders != null)
                {
                    if (haveHeaders)
                        continue;

                    int count = 0;
                    foreach (HtmlAgilityPack.HtmlNode th in tableHeaders)
                    {
                        count++;
                        string colname= th.InnerText.Trim(new char[] { ' ', '\t', '\r', '\n' });
                        // System.Console.WriteLine(colname);

                        if (string.IsNullOrEmpty(colname))
                            colname = "COLUMN_" + count.ToString();

                        if (!dt.Columns.Contains(colname))
                        {
                            dt.Columns.Add(colname, typeof(string));
                        }

                    } // Next th

                    continue;
                } // End if (tableHeaders != null)

                var tableData = link.SelectNodes("./td");

                if (tableData != null)
                {

                    dr = dt.NewRow();

                    dr["url"] = path;
                    dr["Rubrique"] = rubrique;

                    int count = 1;
                    foreach (HtmlAgilityPack.HtmlNode td in tableData)
                    {
                        count++;
                        string val = td.InnerText.Trim(new char[] { ' ', '\t', '\r', '\n' });
                        val = System.Web.HttpUtility.HtmlDecode(val);
                        val = val.Replace(",", "");

                        dr[count] = val;
                    } // Next td

                    dt.Rows.Add(dr);
                    continue;
                } // End if (tableData != null)

                // System.Console.WriteLine(link);

                // dr["Name"] = System.Web.HttpUtility.HtmlDecode(link.InnerText);
                // dr["Url"] = link.Attributes["href"].Value;

            } // Next link

            return dt;
        }
Exemplo n.º 49
0
        private System.Data.DataSet CreateDataSet(CompanyGroup.Dto.WebshopModule.PriceList from)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add("CannotCancel", typeof(bool));
            dt.Columns.Add("Currency", typeof(string));
            dt.Columns.Add("DataAreaId", typeof(string));
            dt.Columns.Add("Description", typeof(string));
            dt.Columns.Add("EndOfSales", typeof(bool));
            dt.Columns.Add("FirstLevelCategoryId", typeof(string));
            dt.Columns.Add("FirstLevelCategoryName", typeof(string));
            dt.Columns.Add("GarantyMode", typeof(string));
            dt.Columns.Add("GarantyTime", typeof(string));
            dt.Columns.Add("InnerStock", typeof(int));
            dt.Columns.Add("ItemName", typeof(string));
            dt.Columns.Add("ManufacturerId", typeof(string));
            dt.Columns.Add("ManufacturerName", typeof(string));
            dt.Columns.Add("New", typeof(bool));
            dt.Columns.Add("OuterStock", typeof(int));
            dt.Columns.Add("PartNumber", typeof(string));
            dt.Columns.Add("Price", typeof(int));
            dt.Columns.Add("ProductId", typeof(string));
            dt.Columns.Add("PurchaseInProgress", typeof(bool));
            dt.Columns.Add("SecondLevelCategoryId", typeof(string));
            dt.Columns.Add("SecondLevelCategoryName", typeof(string));
            dt.Columns.Add("ShippingDate", typeof(DateTime));
            dt.Columns.Add("ThirdLevelCategoryId", typeof(string));
            dt.Columns.Add("ThirdLevelCategoryName", typeof(string));

            foreach (CompanyGroup.Dto.WebshopModule.PriceListItem item in from.Items)
            {
                System.Data.DataRow row = dt.NewRow();

                row["CannotCancel"] = item.CannotCancel;
                row["Currency"] = item.Currency;
                row["DataAreaId"] = item.DataAreaId;
                row["Description"] = item.Description;
                row["EndOfSales"] = item.EndOfSales;
                row["FirstLevelCategoryId"] = item.FirstLevelCategory.Id;
                row["FirstLevelCategoryName"] = item.FirstLevelCategory.Name;
                row["GarantyMode"] = item.GarantyMode;
                row["GarantyTime"] = item.GarantyTime;
                row["InnerStock"] = item.InnerStock;
                row["ItemName"] = item.ItemName;
                row["ManufacturerId"] = item.Manufacturer.Id;
                row["ManufacturerName"] = item.Manufacturer.Name;
                row["New"] = item.New;
                row["OuterStock"] = item.OuterStock;
                row["PartNumber"] = item.PartNumber;
                row["Price"] = item.Price;
                row["ProductId"] = item.ProductId;
                row["PurchaseInProgress"] = item.PurchaseInProgress;
                row["SecondLevelCategoryId"] = item.SecondLevelCategory.Id;
                row["SecondLevelCategoryName"] = item.SecondLevelCategory.Name;
                row["ShippingDate"] = item.ShippingDate;
                row["ThirdLevelCategoryId"] = item.ThirdLevelCategory.Id;
                row["ThirdLevelCategoryName"] = item.ThirdLevelCategory.Name;

                dt.Rows.Add(row);
            }

            System.Data.DataSet ds = new System.Data.DataSet();

            ds.Tables.Add(dt);

            return ds;
        }
Exemplo n.º 50
0
        public static void UpdateAllHp2(string symbol, string where = null)
        {
            bool deleteFirst = true;
            if (deleteFirst)
            {
                foreach (char dealType in Parameters.AllDealTypes)
                {
                    for (int i = 0; i < TestParameters.CandidateParameter4Db.BatchTps.Length; ++i)
                    {
                        for (int j = 0; j < TestParameters.CandidateParameter4Db.BatchSls.Length; ++j)
                        {
                            string sql = string.Format("DELETE FROM {0}_HP WHERE {1} AND DealType = '{2}' AND Tp = '{3}' AND Sl = '{4}'",
                                symbol,
                                string.IsNullOrEmpty(where) ? "1=1" : where,
                                dealType, TestParameters.CandidateParameter4Db.BatchTps[i], TestParameters.CandidateParameter4Db.BatchSls[j]);
                            WekaUtils.Instance.WriteLog(sql);
                            DbHelper.Instance.ExecuteNonQuery(sql);
                        }
                    }
                }
            }

            System.Data.DataTable dt2 = new System.Data.DataTable();
            dt2.Columns.Add(new System.Data.DataColumn("Time", typeof(long)));
            dt2.Columns.Add(new System.Data.DataColumn("DealType", typeof(string)));
            dt2.Columns.Add(new System.Data.DataColumn("Tp", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("Sl", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("hp", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("hp_date", typeof(DateTime)));

            System.Data.DataTable dt = GetUpdateHpMainTable(symbol, where);

            var simulationData = SimulationData.Instance.Init(symbol);
            ISimulateStrategy[,] strategys = new ISimulateStrategy[TestParameters.CandidateParameter4Db.BatchTps.Length, TestParameters.CandidateParameter4Db.BatchSls.Length];
            for (int i = 0; i < TestParameters.CandidateParameter4Db.BatchTps.Length; ++i)
            {
                for (int j = 0; j < TestParameters.CandidateParameter4Db.BatchSls.Length; ++j)
                {
                    int tp = TestParameters.CandidateParameter4Db.BatchTps[i];
                    int sl = TestParameters.CandidateParameter4Db.BatchSls[j];

                    strategys[i, j] = new TpSlM1SimulateStrategy(symbol, tp * 0.0001, sl * 0.0001, simulationData);
                }
            }
            foreach (System.Data.DataRow row in dt.Rows)
            {
                DateTime date = (DateTime)row["Date"];
                System.Console.WriteLine(string.Format("Now updatehp of {0}", date.ToString(Parameters.DateTimeFormat)));

                foreach (char dealType in Parameters.AllDealTypes)
                {
                    int?[,] hps = new int?[TestParameters.CandidateParameter4Db.BatchTps.Length, TestParameters.CandidateParameter4Db.BatchSls.Length];
                    DateTime?[,] hpDates = new DateTime?[TestParameters.CandidateParameter4Db.BatchTps.Length, TestParameters.CandidateParameter4Db.BatchSls.Length];
                    for (int i = 0; i < TestParameters.CandidateParameter4Db.BatchTps.Length; ++i)
                    {
                        for (int j = 0; j < TestParameters.CandidateParameter4Db.BatchSls.Length; ++j)
                        {
                            hps[i, j] = -1;
                        }
                    }

                    for (int i = 0; i < TestParameters.CandidateParameter4Db.BatchTps.Length; ++i)
                    {
                        for (int j = 0; j < TestParameters.CandidateParameter4Db.BatchSls.Length; ++j)
                        {
                            if (hps[i, j] != -1)
                                continue;

                            ISimulateStrategy strategy = strategys[i, j];

                            DateTime? closeDate;
                            bool? hp;
                            if (dealType == 'B')
                                hp = strategy.DoBuy(date, (double)row["Close"], out closeDate);
                            else if (dealType == 'S')
                                hp = strategy.DoSell(date, (double)row["Close"], out closeDate);
                            else
                                throw new ArgumentException("Invalid dealtype of " + dealType);

                            if (hp.HasValue)
                            {
                                if (hp.Value)
                                {
                                    // tp
                                    for (int jj = j; jj < TestParameters.CandidateParameter4Db.BatchSls.Length; ++jj)
                                    {
                                        hps[i, jj] = 1;
                                        hpDates[i, jj] = closeDate.Value;
                                    }
                                }
                                else
                                {
                                    for (int ii = i; ii < TestParameters.CandidateParameter4Db.BatchTps.Length; ++ii)
                                    {
                                        hps[ii, j] = 0;
                                        hpDates[ii, j] = closeDate.Value;
                                    }
                                }
                            }
                            else
                            {
                                for (int ii = i; ii < TestParameters.CandidateParameter4Db.BatchTps.Length; ++ii)
                                    for (int jj = j; jj < TestParameters.CandidateParameter4Db.BatchSls.Length; ++jj)
                                    {
                                        hps[ii, jj] = null;
                                        hpDates[ii, jj] = null;
                                    }
                            }
                        }
                    }

                    for (int i = 0; i < TestParameters.CandidateParameter4Db.BatchTps.Length; ++i)
                    {
                        for (int j = 0; j < TestParameters.CandidateParameter4Db.BatchSls.Length; ++j)
                        {
                            System.Data.DataRow row2 = dt2.NewRow();
                            row2["Time"] = row["Time"];
                            row2["DealType"] = dealType;
                            row2["Tp"] = TestParameters.CandidateParameter4Db.BatchTps[i];
                            row2["Sl"] = TestParameters.CandidateParameter4Db.BatchSls[j];
                            row2["hp"] = hps[i, j] == null ? (object)System.DBNull.Value : hps[i, j].Value;
                            row2["hp_date"] = hpDates[i, j] == null ? (object)System.DBNull.Value : hpDates[i, j].Value;
                            dt2.Rows.Add(row2);
                        }
                    }
                }

                if (dt2.Rows.Count > 50000)
                {
                    DbHelper.Instance.BulkCopy(dt2, string.Format("{0}_HP", symbol));
                    dt2.Rows.Clear();
                }
            }
            DbHelper.Instance.BulkCopy(dt2, string.Format("{0}_HP", symbol));
            dt2.Rows.Clear();
        }
Exemplo n.º 51
0
        public void SqlLiteTests()
        {
            using (var con = new System.Data.SQLite.SQLiteConnection())
            {
                con.ConnectionString = "Data Source=:memory:";
                con.Open();

                var mydt = new System.Data.DataTable("testdt");
                mydt.Columns.Add("one", typeof(int));
                mydt.Columns.Add("two", typeof(int));

                var data = new int[][] { new int[] { 1, 2 }, new int[] { 3, 4 }, new int[] { 5, 6 } };
                foreach (var drow in data)
                {
                    var row = mydt.NewRow();
                    row["one"] = drow[0];
                    row["two"] = drow[1];
                    mydt.Rows.Add(row);
                }

                con.LoadDataTable(mydt);

                var results = con.GetScalar<int>("select count(*) from testdt where one > 1");
                Assert.AreEqual(2, results);
            }
        }
Exemplo n.º 52
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //1.基本設定
            NameValueCollection config = new NameValueCollection();
            config.Add("appId", APP_ID);
            config.Add("secret", APP_SECRET);
            config.Add("redirect_uri", REDIRECT_URI);
            //config.Add("log_path", "d:\\data.log");

            //2.實體化
            FunBuddy f8d = null;
            try
            {
                f8d = new FunBuddy(config);
            }
            catch (ApiException ex)
            {
                Panel1.Visible = false;
                Panel2.Visible = true;
                lblCode.Text = ex.code.ToString();
                lblMessage.Text = ex.message;
                return;
            }

            //3.取得access token (在session裡)
            JObject session = f8d.getSession();
            if (session == null)
            {
                Response.Redirect(f8d.getLoginUrl());
                return;
            }

            //4.取得帳號資料
            try
            {
                JObject me = f8d.api("v1/me/account", "GET", new NameValueCollection());
                lblAccount.Text = me["pid"].ToString();
                lblName.Text = me["username"].ToString();
                Access_Token = f8d.getAccessToken();
                lblAccessToken.Text = Access_Token;
                lblUid.Text = me["uid"].ToString();
            }
            catch (ApiException ex)
            {
                Panel1.Visible = false;
                Panel2.Visible = true;
                lblCode.Text = ex.code.ToString();
                lblMessage.Text = ex.message;
            }

            //5.調用api(ex. 取得好友)
            NameValueCollection param = new NameValueCollection();
            param.Add("start","0");
            param.Add("count","10");
            JObject result = f8d.api("v1/me/friends", "GET", param);
            var q = from p in result.Properties()
                    select p;

            System.Data.DataTable data = new System.Data.DataTable();
            data.Columns.Add("uid");
            data.Columns.Add("username");
            foreach (JProperty friend in q)
            {
                System.Data.DataRow tr = data.NewRow();
                tr["uid"] = result[friend.Name]["uid"].ToString();
                tr["username"] = result[friend.Name]["username"].ToString();
                data.Rows.Add(tr);
            }
            GridView1.DataSource = data;
            GridView1.DataBind();
            //logoutUrl = $fun->getLogoutUrl();
        }
Exemplo n.º 53
0
    public override void DebugPrint(string Directory, Dictionary<int, Catchment> Catchments)
    {
      if (ExtraOutput & Update)
      {
        using (ShapeWriter sw = new ShapeWriter(Path.Combine(Directory, Name + "_debug.shp")))
        {
          System.Data.DataTable dt = new System.Data.DataTable();
          dt.Columns.Add("ID15", typeof(int));
          dt.Columns.Add("LakeName", typeof(string));
          dt.Columns.Add("NitrateReduction", typeof(double));
          dt.Columns.Add("NitrateConcentration", typeof(double));
          dt.Columns.Add("FlushingRatio", typeof(double));
          foreach (var c in Catchments.Values.Where(c => c.BigLake != null))
          {
            var row = dt.NewRow();
            row[0] = c.ID;
            row[1] = c.BigLake.Name;
            row[2] = c.BigLake.NitrateReduction.Average;
            row[3] = c.BigLake.NitrateConcentration.Average;
            row[4] = c.BigLake.FlushingRatio.Average;
            sw.Write(new GeoRefData() { Geometry = c.Geometry, Data = row });

            using (StreamWriter st = new StreamWriter(Path.Combine(Directory, Name) +"_" + c.ID + "_debug.csv"))
            {
              st.WriteLine("Time;NitrateReduction;NitrateContration;FlushingRatio");
              for (int i = 0; i < c.BigLake.NitrateReduction.Items.Count; i++)
              {
                st.WriteLine(c.BigLake.NitrateReduction.Items[i].Time.ToString() + ";" + c.BigLake.NitrateReduction.Items[i].Value + ";" + c.BigLake.NitrateConcentration.Items[i].Value + ";" + c.BigLake.FlushingRatio.Items[i].Value);
              }
            }
          }
        }
      }
    }
Exemplo n.º 54
0
        public static void ConvertHpDataToSingleTable(string symbol, char dealType, int tp, int sl, bool forceDelete = false)
        {
            string sql;
            int n = 0;
            if (!forceDelete)
            {
                sql = string.Format("SELECT COUNT(*) FROM {0}_HP WHERE DealType = '{1}' AND Tp = {2} AND Sl = {3}", symbol, dealType, tp, sl);
                n = (int)DbHelper.Instance.ExecuteScalar(sql);
                if (n > 5000)
                {
                    return;
                }
            }
            if (forceDelete || n > 0)
            {
                sql = string.Format("DELETE FROM {0}_HP WHERE DealType = '{1}' AND Tp = {2} AND Sl = {3}", symbol, dealType, tp, sl);
                DbHelper.Instance.ExecuteNonQuery(sql);
            }
            sql = string.Format("SELECT Time, {1}_hp_{2}_{3}, {1}_hp_date_{2}_{3} FROM {0}_M5", symbol, dealType, tp, sl);
            var dt = DbHelper.Instance.ExecuteDataTable(sql);

            System.Data.DataTable dt2 = new System.Data.DataTable();
            dt2.Columns.Add(new System.Data.DataColumn("Time", typeof(long)));
            dt2.Columns.Add(new System.Data.DataColumn("DealType", typeof(string)));
            dt2.Columns.Add(new System.Data.DataColumn("Tp", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("Sl", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("hp", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("hp_date", typeof(DateTime)));
            foreach (System.Data.DataRow row in dt.Rows)
            {
                System.Data.DataRow row2 = dt2.NewRow();
                row2["Time"] = row[0];
                row2["DealType"] = dealType;
                row2["Tp"] = tp;
                row2["Sl"] = sl;
                row2["hp"] = row[1];
                row2["hp_date"] = row[2];
                dt2.Rows.Add(row2);
            }

            DbHelper.Instance.BulkCopy(dt2, string.Format("{0}_HP", symbol));
            //            var txn = DbHelper.Instance.BeginTransaction();
            //            foreach (System.Data.DataRow row in dt.Rows)
            //            {
            //                sql = string.Format(@"INSERT INTO {0}_HP ([Time],[DealType],[Tp],[Sl],[hp],[hp_date])
            //                    VALUES
            //                    (@Time,@DealType,@Tp,@Sl,@hp,@hp_date)", symbol);
            //                var cmd = new System.Data.SqlClient.SqlCommand(sql);
            //                cmd.Parameters.AddWithValue("@Time", row[0]);
            //                cmd.Parameters.AddWithValue("@DealType", dealType);
            //                cmd.Parameters.AddWithValue("@Tp", tp);
            //                cmd.Parameters.AddWithValue("@Sl", sl);
            //                cmd.Parameters.AddWithValue("@hp", row[1]);
            //                cmd.Parameters.AddWithValue("@hp_date", row[2]);
            //                cmd.Transaction = txn as System.Data.SqlClient.SqlTransaction;
            //                DbHelper.Instance.ExecuteNonQuery(cmd);
            //            }
            //            DbHelper.Instance.CommitTransaction(txn);
        }
Exemplo n.º 55
0
        private void btnTest_Click(object sender, System.EventArgs e)
        {
            lol();
            dt = CreateTable();

            string correct = "Brokers México, Intermediario de Aseguro,S.A.";
            string broken = "Brokers México, Intermediario de Aseguro,S.A."; // Get text from database

            correct = this.txtCorrect.Text;
            broken = this.txtWrong.Text;

            // For reference
            // https://msdn.microsoft.com/en-us/library/system.text.encodinginfo.getencoding(v=vs.110).aspx
            int[] encs = new int[] {
                 20127 // US-ASCII
                ,28591 // iso-8859-1 Western European (ISO)
                ,28592 // iso-8859-2 Central European (ISO)
                ,28593 // iso-8859-3 Latin 3 (ISO)
                ,28594 // iso-8859-4 Baltic (ISO)
                ,28595 // iso-8859-5 Cyrillic (ISO)
                ,28596 // iso-8859-6 Arabic (ISO)
                ,28597 // iso-8859-7 Greek (ISO)
                ,28598 // iso-8859-8 Hebrew (ISO-Visual)
                ,28599 // iso-8859-9 Turkish (ISO)
                ,28603 // iso-8859-13 Estonian (ISO)
                ,28605 // iso-8859-15 Latin 9 (ISO)

                ,1250 // windows-1250 Central European (Windows)
                ,1251 // windows-1251 Cyrillic (Windows)
                ,1252 // Windows-1252 Western European (Windows)
                ,1253 // windows-1253 Greek (Windows)
                ,1254 // windows-1254 Turkish (Windows)
                ,1255 // windows-1255 Hebrew (Windows)
                ,1256 // windows-1256 Arabic (Windows)
                ,1257 // windows-1257 Baltic (Windows)
                ,1258 // windows-1258 Vietnamese (Windows)

                ,20866 // Cyrillic (KOI8-R)
                ,21866 // Cyrillic (KOI8-U)

                ,65000 // UTF-7
                ,65001 // UTF-8
                ,1200 // UTF-16
                ,1201 // Unicode (Big-Endian)

                ,12000 // UTF-32
                ,12001 // UTF-32BE (UTF-32 Big-Endian)
            };

            for (int i = 0; i < encs.Length; ++i)
            {

                for (int j = 0; j < encs.Length; ++j)
                {
                    System.Data.DataRow dr = dt.NewRow();

                    dr["SourceEncoding"] = encs[i];
                    dr["TargetEncoding"] = encs[j];

                    System.Text.Encoding enci = System.Text.Encoding.GetEncoding(encs[i]);
                    System.Text.Encoding encj = System.Text.Encoding.GetEncoding(encs[j]);

                    byte[] encoded = enci.GetBytes(broken);
                    string corrected = encj.GetString(encoded);

                    dr["Result"] = corrected;

                    dr["SourceEncodingName"] = enci.BodyName;
                    dr["TargetEncodingName"] = encj.BodyName;

                    if (System.StringComparer.InvariantCultureIgnoreCase.Equals(correct, corrected))
                        dt.Rows.Add(dr);
                } // Next j

            } // Next i

            this.dgvResult.DataSource = dt;
        }
Exemplo n.º 56
0
        private static string AddMergeData(string tag, int recipientCount)
        {
            string[] domains = new string[] { "aol.com", "yahoo.com", "gmail.com", "hotmail.com" };
            //string[] domains = new string[] { "scott.com", "scott.com", "scott.com", "scott.com" };
            string emailFormat = "{0}." + tag + "@{1}";

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add(new System.Data.DataColumn("recipid"));
            dt.Columns.Add(new System.Data.DataColumn("listquality"));
            dt.Columns.Add(new System.Data.DataColumn("name"));
            dt.Columns.Add(new System.Data.DataColumn("email"));
            dt.Columns.Add(new System.Data.DataColumn("amount"));
            dt.Columns.Add(new System.Data.DataColumn("ticketInfo"));
            dt.Columns.Add(new System.Data.DataColumn("replyto"));
            dt.Columns.Add(new System.Data.DataColumn("sentfrom"));
            dt.Columns.Add(new System.Data.DataColumn("sentfromdisplay"));

            System.Data.DataRow dr = null;
            Random ran = new Random(1000);
            string id = "0";

            for (int i = 0; i < recipientCount; i++)
            {
                dr = dt.NewRow();
                id = ran.Next().ToString();
                int quarter = (int)(recipientCount * .25);

                if (i <= quarter)
                {
                    dr.ItemArray = new Object[] { id, "3", "scott carnley", string.Format(emailFormat, i.ToString(), domains[0]), "$345.45", "One ticket for the greatest show on earth.", "*****@*****.**", "*****@*****.**", "Administrator" };
                }
                else if (i <= (quarter * 2))
                {
                    dr.ItemArray = new Object[] { id, "3", "scott carnley", string.Format(emailFormat, i.ToString(), domains[1]), "$345.45", "One ticket for the greatest show on earth.", "*****@*****.**", "*****@*****.**", "Administrator" };
                }
                else if (i <= (quarter * 3))
                {
                    dr.ItemArray = new Object[] { id, "3", "scott carnley", string.Format(emailFormat, i.ToString(), domains[2]), "$345.45", "One ticket for the greatest show on earth.", "*****@*****.**", "*****@*****.**", "Administrator" };
                }
                else if (i <= recipientCount)
                {
                    dr.ItemArray = new Object[] { id, "3", "scott carnley", string.Format(emailFormat, i.ToString(), domains[3]), "$345.45", "One ticket for the greatest show on earth.", "*****@*****.**", "*****@*****.**", "Administrator" };
                }

                dt.Rows.Add(dr);
            }

            dt.DefaultView.Sort = "recipid asc";
            System.Data.DataSet ds = new System.Data.DataSet();
            ds.Tables.Add(dt.DefaultView.ToTable());

            return ds.GetXml();
        }
Exemplo n.º 57
0
    public void Mike11ObservationsTest()
    {
      Model Mshe = new Model(@"D:\DK_information\M11_omr4-7\XY_M11_detailed\Mike11\DK5_2013_inv.she");
      List<DetailedMike11> actual;
      actual = Mshe.Results.Mike11Observations;

      System.Data.DataTable dt = new System.Data.DataTable();

      dt.Columns.Add("Name", typeof(string));
      dt.Columns.Add("Branch", typeof(string));
      dt.Columns.Add("Chainage", typeof(double));

      using (HydroNumerics.Geometry.Shapes.ShapeWriter sw = new Geometry.Shapes.ShapeWriter(@"d:\temp\detailedm11Points_DK5.shp"))
      {
        foreach (var m11 in actual)
        {
          var data = dt.NewRow();
          data[0]= m11.Name;
          data[1] = m11.Branch;
          data[2]=m11.Chainage;
          sw.Write(new Geometry.GeoRefData() { Geometry = m11.Location, Data = data });
        }
      }
    }
Exemplo n.º 58
0
        public static void UpdateHp(string symbol, char dealType, int tp, int sl, string where, System.Data.DataTable dt = null, bool deleteFirst = false)
        {
            if (dt == null)
            {
                dt = GetUpdateHpMainTable(symbol, where);
            }
            System.Console.WriteLine(string.Format("UpdateHp of {0}_{1}_{2}_{3}", symbol, dealType, tp, sl));

            if (deleteFirst)
            {
                string sql = string.Format("DELETE FROM {0}_HP WHERE DealType = '{1}' AND Tp = {2} AND Sl = {3} AND {4}",
                    symbol, dealType, tp, sl,
                    string.IsNullOrEmpty(where) ? "1=1" : where);
                DbHelper.Instance.ExecuteNonQuery(sql);
            }

            ISimulateStrategy strategy;// = new TpSlSimulateStrategy(0.0070, 0.0035);
            var simulationData = SimulationData.Instance.Init(symbol);
            strategy = new TpSlM1SimulateStrategy(symbol, tp * 0.0001, sl * 0.0001, simulationData);
            //strategy = new BreakEvenM1SimulateStrategy(0.0080, 0.0030, 0.0030);
            //strategy = new PriceProbSimulationStrategy(60, 0.0600);

            System.Data.DataTable dt2 = new System.Data.DataTable();
            dt2.Columns.Add(new System.Data.DataColumn("Time", typeof(long)));
            dt2.Columns.Add(new System.Data.DataColumn("DealType", typeof(string)));
            dt2.Columns.Add(new System.Data.DataColumn("Tp", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("Sl", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("hp", typeof(int)));
            dt2.Columns.Add(new System.Data.DataColumn("hp_date", typeof(DateTime)));
            foreach (System.Data.DataRow row in dt.Rows)
            {
                DateTime date = (DateTime)row["Date"];

                DateTime? closeDate;
                bool? hp;
                if (dealType == 'B')
                    hp = strategy.DoBuy(date, (double)row["Close"], out closeDate);
                else if (dealType == 'S')
                    hp = strategy.DoSell(date, (double)row["Close"], out closeDate);
                else
                    throw new ArgumentException("Invalid dealtype of " + dealType);

                System.Data.DataRow row2 = dt2.NewRow();
                row2["Time"] = row["Time"];
                row2["DealType"] = dealType;
                row2["Tp"] = tp;
                row2["Sl"] = sl;
                row2["hp"] = hp == null ? (object)System.DBNull.Value : hp;
                row2["hp_date"] = closeDate == null ? (object)System.DBNull.Value : closeDate;
                dt2.Rows.Add(row2);
            }
            DbHelper.Instance.BulkCopy(dt2, string.Format("{0}_HP", symbol));
            //System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback((o) =>
            //    {
            //        System.Console.WriteLine(string.Format("UpdateWriteHp Start of {0}_{1}_{2}_{3}", symbol, dealType, tp, sl));
            //        DbHelper.Instance.BulkCopy(dt2, string.Format("{0}_HP", symbol));
            //        System.Console.WriteLine(string.Format("UpdateWriteHp End of {0}_{1}_{2}_{3}", symbol, dealType, tp, sl));
            //    }));
        }
Exemplo n.º 59
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            List<NFMT.Charts.ChartModel> list = new List<NFMT.Charts.ChartModel>();
            NFMT.Charts.ChartModel model = new NFMT.Charts.ChartModel();
            //X横向轴说明数据
            model.XAxis.Categories.Add("一月");
            model.XAxis.Categories.Add("二月");
            model.XAxis.Categories.Add("三月");
            model.XAxis.Categories.Add("四月");
            model.XAxis.Categories.Add("五月");
            model.XAxis.Categories.Add("六月");
            model.XAxis.Categories.Add("七月");
            model.XAxis.Categories.Add("八月");
            model.XAxis.Categories.Add("九月");
            model.XAxis.Categories.Add("十月");
            model.XAxis.Categories.Add("十一月");
            model.XAxis.Categories.Add("十二月");

            //主标题
            model.Title ="2013年迈科入库表";
            //model.Title.X.Add("-20");

            model.SubTitle = "副标题";

            //Y轴数据
            model.YAxis.Title ="重量(吨)";
            model.Tooltip = "吨";
            //model.YAxis.PlotLines.Value.Add("0");
            //model.YAxis.PlotLines.Width.Add("1");
            //model.YAxis.PlotLines.Color.Add("#808080");

            //提示框数据单位
            //model.Tooltip.ValueSuffix.Add("吨");

            //图形选项配置数据
            //model.Legend.Layout.Add("vertical");
            //model.Legend.Align.Add("right");
            //model.Legend.VerticalAlign.Add("middle");
            //model.Legend.BorderWidth.Add("0");

            //线性数据
            //model.Series["铜"]["12000, 12300, 26000, 15822, 15201, 18005, 25001, 25410, 12546, 21542, 15800, 16500"];

            //model.Series.Add("铜");
            //model.Series.Add("铝");
            //model.Series.Add("锌");
            //model.Series.Add("其他");
            //model.Series.Add("12000, 12300, 26000, 15822, 15201, 18005, 25001, 25410, 12546, 21542, 15800, 16500");
            //model.Series.Add("2000, 1300, 2000, 5822, 5201, 8005, 5001, 5410, 2546, 1542, 5800, 6500");
            //model.Series.Add("1500, 2300, 6000, 1822, 1201, 1005, 2001, 1410, 1546, 5542, 5800, 2500");
            //model.Series.Add("5841, 2800, 1200, 1422, 800, 2000, 1200, 1810, 1500, 5181, 2800, 5500");

            //NFMT.Data.DAL.BDStyleDAL dal = new NFMT.Data.DAL.BDStyleDAL();

            //for (int i = 15; i < 17; i++)
            //{
            //    NFMT.Common.IModel bDStyle = dal.Get(NFMT.Common.DefaultValue.SysUser, i).ReturnValue as NFMT.Common.IModel;
            //    model.Series.Add(i.ToString(), bDStyle);
            //}
            //model.Series.Add("Name:铝", "Data:12000, 12300, 26000, 15822, 15201, 18005, 25001, 25410, 12546, 21542, 15800, 16500");
            //model.Series.Add("Name:锌", "Data:12000, 12300, 26000, 15822, 15201, 18005, 25001, 25410, 12546, 21542, 15800, 16500");
            //model.Series.Add("Name:其他", "Data:12000, 12300, 26000, 15822, 15201, 18005, 25001, 25410, 12546, 21542, 15800, 16500");

            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.DataColumn column = new System.Data.DataColumn("asset");
            dt.Columns.Add(column);

            column = new System.Data.DataColumn("一月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("二月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("三月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("四月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("五月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("六月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("七月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("八月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("九月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("十月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("十一月");
            dt.Columns.Add(column);
            column = new System.Data.DataColumn("十二月");
            dt.Columns.Add(column);

            System.Random random = new Random();
            System.Data.DataRow row = null;

            row = dt.NewRow();
            row[0] = "铜";
            for (int i = 1; i < 13; i++)
            {
                row[i] = random.Next(10000, 30000);
            }
            dt.Rows.Add(row);

            row = dt.NewRow();
            row[0] = "锌";
            for (int i = 1; i < 13; i++)
            {
                row[i] = random.Next(2000, 20000);
            }
            dt.Rows.Add(row);

            dt.TableName = "Series";
            model.SourceTable = dt;

            string postData = NFMT.Charts.ChartJson.CreateJosn(model);
            context.Response.Write(postData);
        }
Exemplo n.º 60
0
		public System.Data.DataTable DataSearch(string SearchKey, string SortField, SortOption SortOrder)
		{
			MySqlDataReader myReader = Search(SearchKey,SortField,SortOption.Ascending);
			
			System.Data.DataTable dt = new System.Data.DataTable("tblProductAttribute");

			dt.Columns.Add("ProductAttributeID");
			dt.Columns.Add("ProductAttributeCode");
			dt.Columns.Add("ProductAttributeName");
				
			while (myReader.Read())
			{
				System.Data.DataRow dr = dt.NewRow();

				dr["ProductAttributeID"] = myReader.GetInt16(0);
				dr["ProductAttributeCode"] = myReader.GetString(1);
				dr["ProductAttributeName"] = myReader.GetString(2);
					
				dt.Rows.Add(dr);
			}
			
			myReader.Close();

			return dt;
		}