Exemple #1
0
        private TimeSpan ExportItemsCsv(string fileName)
        {
            TimeSpan ts = new TimeSpan(0);

            using (StreamWriter w = new StreamWriter(fileName, false, Encoding.Default))
            {
                w.WriteLine("PROJEKT;POLOŽKA;DOBA;DATUM;KALENDÁŘ");
                Log.Write($"Export CSV Items count: {lvAppointments.Items.Count} ");
                foreach (ListViewItem li in lvAppointments.Items)
                {
                    Log.Write($"Export CSV Items: Item: {li.Text}, CHecked: {li.Checked} ");
                    if (!li.Checked)
                    {
                        continue;
                    }
                    if (li.Tag is ProjectInfo)
                    {
                        Log.Write($"Skipping project");
                        continue;
                    }
                    else
                    {
                        if (li.Tag is AppointmentInfo)
                        {
                            AppointmentInfo pi       = li.Tag as AppointmentInfo;
                            TimeSpan        duration = pi.Appointment.End - pi.Appointment.Start;
                            w.WriteLine($"{pi.Project};{pi.Subject};{duration};{pi.Appointment.Start};{pi.FolderInfo}");
                            ts += duration;
                        }
                    }
                }
            }

            return(ts);
        }
Exemple #2
0
        private TimeSpan ExportItemsHtml(string fileName)
        {
            TimeSpan ts = new TimeSpan(0);

            Log.Write($"Export Items HTML, total time is now {ts}");
            using (StreamWriter w = new StreamWriter(fileName))
            {
                w.WriteLine("<html><head><meta charset=\"UTF-8\"><title>Export z Outlooku</title></head><body><table cellspacing=0><tr><td style=\"font-weight:bold;width:480px;padding-right:50px\">Projekt</td><td style=\"font-weight:bold;width:200px;padding-right:50px;\">Doba</td><td style=\"font-weight:bold;width:200px;\">Datum</td><td style=\"font-weight:bold;width:350px;\">Kalendář</td></tr>");
                foreach (ListViewItem li in lvAppointments.Items)
                {
                    if (!li.Checked)
                    {
                        continue;
                    }
                    if (li.Tag is ProjectInfo)
                    {
                        ProjectInfo p = li.Tag as ProjectInfo;

                        if (AllAppointments.Any(x => x.Enabled && x.Project == p.Name))
                        {
                            var duration = Tools.GetDuration(AllAppointments, p.Name);
                            if (ShowProjectsOnly)
                            {
                                ts += duration;
                            }
                            w.WriteLine(string.Format("<tr style=\"background-color:lightblue;\"><td><b>{0}</b></td><td><b>{1}</b></td><td><b></b></td><td><b></b></td></tr>", p.Name, duration.TotalHours.ToString()));
                        }
                    }
                    else
                    if (li.Tag is AppointmentInfo)
                    {
                        AppointmentInfo pi       = li.Tag as AppointmentInfo;
                        TimeSpan        duration = pi.Appointment.End - pi.Appointment.Start;
                        w.WriteLine(string.Format("<tr><td><i>{0}</i></td><td><i>{1}</i></td><td><i>{2}</i></td><td><i>{3}</i></td></tr>", pi.Subject, duration.TotalHours.ToString(), pi.Appointment.Start.ToShortDateString(), pi.FolderInfo.ToString()));
                        ts += duration;
                        Log.Write($"Export Items HTML, duration of {pi.Appointment.Subject} is {duration}, total is {ts}");
                    }
                }

                w.WriteLine(string.Format("<tr style=\"background-color:red\"><td><b><i>{0}</i></b></td><td><b><i>{1}</i></b></td><td><b><i></i></b></td><td><b></b></td></tr>", "CELKEM", ts.TotalHours.ToString()));
                w.WriteLine("</table></body></html>");
            }

            return(ts);
        }
Exemple #3
0
        private void processProject(ListViewItem listViewItem)
        {
            foreach (ListViewItem item in lvAppointments.Items)
            {
                AppointmentInfo ai = item.Tag as AppointmentInfo;
                if (ai != null)
                {
                    if (ai.Project == ((ProjectInfo)listViewItem.Tag).Name)
                    {
                        item.Checked = listViewItem.Checked;
                        ai.Enabled   = item.Checked;
                    }
                }
            }

            TimeSpan duration = Tools.GetDuration(AllAppointments, ((ProjectInfo)listViewItem.Tag).Name);

            listViewItem.SubItems[1].Text = duration.TotalHours.ToString();
            recomputeTotal();
        }
Exemple #4
0
        private void processItem(ListViewItem listViewItem)
        {
            ListViewItem    projectItem = null;
            AppointmentInfo aitem       = (AppointmentInfo)listViewItem.Tag;

            TimeSpan duration = new TimeSpan(0);

            foreach (ListViewItem item in lvAppointments.Items)
            {
                ProjectInfo pi = item.Tag as ProjectInfo;
                if (pi != null)
                {
                    if (pi.Name == aitem.Project)
                    {
                        projectItem = item;
                        break;
                    }
                }
            }

            foreach (ListViewItem item in lvAppointments.Items)
            {
                if (item.Checked)
                {
                    AppointmentInfo ai = item.Tag as AppointmentInfo;
                    if (ai != null)
                    {
                        if (ai.Project == aitem.Project)
                        {
                            duration += ai.Appointment.End - ai.Appointment.Start;
                        }
                    }
                }
            }
            projectItem.SubItems[1].Text = Tools.GetDuration(AllAppointments, aitem.Project).TotalHours.ToString();

            recomputeTotal();
        }
Exemple #5
0
        private void lvKalendare_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            MAPIFolderInfo fi = e.Item.Tag as MAPIFolderInfo;

            if (fi != null)
            {
                if ((e.Item.Checked) && (!AllMAPIFolders.Any(f => f.ToString() == fi.ToString())))
                {
                    AllMAPIFolders.Add(fi);
                }
                else
                {
                    if (AllMAPIFolders.Any(f => f.ToString() == fi.ToString()))
                    {
                        AllMAPIFolders.Remove(fi);
                    }
                }

                if (fi.WasProcessed)
                {
                    foreach (ListViewItem li in lvAppointments.Items)
                    {
                        AppointmentInfo ai = li.Tag as AppointmentInfo;
                        if (ai != null)
                        {
                            if (ai.FolderInfo == fi)
                            {
                                li.Checked = e.Item.Checked;
                                ai.Enabled = e.Item.Checked;
                            }
                        }
                    }

                    recomputeTotal();
                }
            }
        }