Пример #1
0
 private void Export_Click(object sender, EventArgs e)
 {
     ExportType E = new ExportType();
     if (SzCount.Checked) E.Sz = true;
     if (PelletCount.Checked) E.Pellet = true;
     if (MedCount.Checked) E.Med = true;
     if (MealCheck.Checked) E.Meal = true;
     if (SzTimes.Checked) E.SzTime = true;
     if (DetailList.Checked) E.DetailList = true;
     if (Notes.Checked) E.Notes = true;
     if (SzSvBox.Checked) E.SeverityIndx = true;
     if (BloodDraw.Checked) E.BloodDraw = true;
     if (BloodDrawList.Checked) E.BloodDrawList = true;
     SaveFileDialog F = new SaveFileDialog();
     F.DefaultExt = ".pjt";
     F.InitialDirectory = "D:\\";
     if (F.ShowDialog() == DialogResult.OK)
     {
         pjt.ExportData(F.FileName, E);
     }
 }
Пример #2
0
        public void ExportData(string Fname, ExportType E)
        {
            //Open File
            StreamWriter F = new StreamWriter(Fname);
            F.AutoFlush = true;
            //
            Sort();
            int c;
            string st, st2, st3;
            DateTime Earliest = Files[0].Start.Date;
            DateTime Latest = Files[Files.Count - 1].Start.Date;
            st = Earliest.ToShortDateString() + "," + Earliest.ToShortTimeString();
            F.WriteLine(st);
            if (E.DetailList)
            {

                foreach (AnimalType A in Animals)
                {
                    F.WriteLine(A.ID);
                    DateTime LastDate = Earliest;
                    foreach (SeizureType S in A.Sz)
                    {
                        foreach (ImportantDateType I in A.ImportantDates)
                        {
                            if ((DateTime.Compare(I.Date, LastDate) > 0) && (DateTime.Compare(I.Date, S.d) <= 0))
                            {
                                F.WriteLine(I.Date.ToShortDateString() + ", " + I.LabelID);
                            }
                        }
                        F.WriteLine(S.d.ToShortDateString() + ", " + S.t.ToString() + ", " + S.Notes);
                        LastDate = S.d;
                    }

                    foreach (ImportantDateType I in A.ImportantDates)
                    {
                        if ((DateTime.Compare(I.Date, LastDate) > 0))
                        {
                            F.WriteLine(I.Date.ToShortDateString() + ", " + I.LabelID.ToString());
                        }
                    }
                }
            F.Close();
                return;
            }
            if (E.BloodDrawList)
            {
                foreach (AnimalType A in Animals)
                {
                    foreach (BloodDrawType B in A.BloodDraws)
                    {
                        st = A.ID + ',' + B.dt.Date.ToString("MM/dd/yyyy") + " " + B.EnteredTime.ToString() + "," + B.ID;
                        F.WriteLine(st);
                    }
                }
                F.Close();
                return;
            }
            st = "Animal";
            /* for (DateTime i = Earliest; i <= Latest; i=i.AddDays(1))
            {
                st += "," + i.ToShortDateString();
                Console.WriteLine(st);
            }
            F.WriteLine(st);*/
            foreach (AnimalType A in Animals)
            {
                if (E.Sz) //Add up daily seizure count.
                {
                    st = A.ID;
                    for (DateTime i = Earliest; i <= Latest; i = i.AddDays(1))
                    {
                        c = 0;
                        foreach (SeizureType S in A.Sz)
                        {
                            if (DateTime.Compare(i.Date, S.d.Date) == 0) c++;
                        }
                        st += "," + c;
                    }
                    F.WriteLine(st);
                }
                if (E.SzTime)
                {
                    st = A.ID;
                    foreach (SeizureType S in A.Sz)
                    {
                        st += ", " + Math.Round(S.d.Subtract(Earliest).TotalHours + S.t.TotalHours, 2).ToString();
                    }
                    F.WriteLine(st);
                }
                if (E.SeverityIndx)
                    st = A.ID;
                foreach (SeizureType S in A.Sz)
                {
                    st += ", " + S.Severity.ToString();
                }
                F.WriteLine(st);
                if (E.Notes)
                {
                    st = A.ID;
                    foreach (SeizureType S in A.Sz)
                    {
                        st += "," + S.Notes;
                    }
                    F.WriteLine(st);
                }
                if (E.Meal)
                {
                    st = A.ID;
                    st2 = A.ID;
                    st3 = A.ID;
                    foreach (MealType M in A.Meals)
                    {
                        st += ", " + Math.Floor(M.d.Subtract(Earliest).TotalHours).ToString();
                        if (M.type == "M")
                        {
                            st2 += ", 1";
                        }
                        else
                        {
                            st2 += ", 0";
                        }
                        if (E.Pellet)
                        {
                            st3 += ", " + M.pelletcount.ToString();
                        }
                    }
                    F.WriteLine(st);
                    F.WriteLine(st2);
                    F.WriteLine(st3);
                }
                if (E.BloodDraw)
                {
                    st = "BDT," + A.ID; //Blood Draw Time
                    st2 = "BDL," + A.ID; //Blood Draw Label
                    foreach (BloodDrawType B in A.BloodDraws)
                    {
                        st += "," + Math.Round(B.dt.Date.Subtract(Earliest).TotalHours + B.EnteredTime.TotalHours, 2).ToString();
                        st2 += "," + B.ID;
                    }
                    F.WriteLine(st);
                    F.WriteLine(st2);
                }
                if (E.Pellet)
                {
                    st = "PLRT," + A.ID;  //Pellet Removal Time
                    st2 = "PLRC," + A.ID;  //Pellet Removal Count
                    foreach (RemovalType R in A.Removals)
                    {
                        st += "," + Math.Round(R.dt.Subtract(Earliest).TotalHours,2).ToString();
                        st2 += "," + R.count.ToString();
                    }
                    F.WriteLine(st);
                    F.WriteLine(st2);
                }
            }
            F.Close();
        }