コード例 #1
0
 //Button Extend Time
 private void btnExtendTime_MouseUp(object sender, MouseEventArgs e)
 {
     DataSample = new Classes.StaticStrengthTestDS(GlobalVariables.leftSerialPort);
     torqueArray = new List<double>();
     powerStepTestDataSet = new BasicProgramDataSet();
 }
コード例 #2
0
        public void PopulateXmlfile(BasicProgramDataSet ProgramData, int TotalTables, string ProgramName)
        {
            DataSet DataTables = new DataSet();

            string UserId;
            if (GlobalVariables.LoggedInUser != null)
            {
                UserId = GlobalVariables.LoggedInUser.id.ToString();
            }
            else
            {
                UserId = "0";
            }

            string directory = "C:\\XmlData\\" + UserId;
            //string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\XmlData\\" + UserId;
            if (!System.IO.Directory.Exists(directory))
                System.IO.Directory.CreateDirectory(directory);

            string timeStamp = DateTime.Now.ToString("yyyyMMddHHmm");
            string FileName = directory + "\\" + ProgramName + timeStamp + ".xml";
            if (!System.IO.File.Exists(FileName))
            {
                System.IO.FileStream fs = System.IO.File.Create(FileName);
                fs.Close();
            }
            else
            {
                System.IO.File.Delete(FileName);
                System.IO.FileStream fs = System.IO.File.Create(FileName);
                fs.Close();
            }

            //Copy DataTables to Main DataSet
            for (int jj = 0; jj < TotalTables; jj++)
            {
                if (ProgramData.Tables[jj].Rows.Count == 0)
                {
                    for (int kk = 0; kk < 50; kk++)
                    {
                        ProgramData.AddNewRow(jj, 0, 0, 0);
                    }
                }
                DataTable dtCopy = ProgramData.Tables[jj].Copy();
                DataTables.Tables.Add(dtCopy);
            }

            try
            {
                DataTables.WriteXml(FileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception caught in WriteXML: {0}", ex.ToString());
            }
        }