Exemple #1
0
        public void Main()
        {
            string reportPath = string.Empty;
            string shiftPath  = string.Empty;
            string outputPth  = string.Empty;

            reportSelector.Invoke((MethodInvoker)(() => reportPath = reportSelector.Value));
            shiftSelector.Invoke((MethodInvoker)(() => shiftPath = shiftSelector.Value));
            outputSelector.Invoke((MethodInvoker)(() => outputPth = outputSelector.Value));
            int durationIndex = 0; int year = 0; int month = 0; int day = 0;

            this.duration.Invoke((MethodInvoker)(() => durationIndex = this.duration.SelectedIndex));
            this.year.Invoke((MethodInvoker)(() => year = int.Parse(this.year.SelectedItem.Text)));
            this.month.Invoke((MethodInvoker)(() => month = this.month.SelectedIndex + 1));
            this.day.Invoke((MethodInvoker)(() => day = this.day.SelectedIndex + 1));

            var duration = durationIndex == 0 ? new TimeSpan(0, 15, 0) : new TimeSpan(0, 30, 0);

            var manager = new Manager
            {
                ReportPath  = reportPath,
                ShiftPath   = shiftPath,
                CurrentDate = PersianDate.FromShamsi(year, month, day),
                OutputPath  = outputPth,
                Duration    = duration
            };

            manager.ReadData();
            manager.CalculateCounts();

            execteBtn.Invoke((MethodInvoker)(() => execteBtn.Enabled = true));
            waiting.Invoke((MethodInvoker)(() => waiting.Visible = false));
            waiting.Invoke((MethodInvoker)(() => waiting.StopWaiting()));
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var manager = new Manager
            {
                ReportPath  = @"C:\Users\mehdi\Desktop\outbound\report\Report.xlsx",
                ShiftPath   = @"C:\Users\mehdi\Desktop\outbound\report\Shift.xlsx",
                CurrentDate = PersianDate.FromShamsi(1395, 8, 25)
            };

            manager.ReadData();
            manager.CalculateCounts();
        }
Exemple #3
0
        public ShiftType?GetShiftType(TimeInterval interval, PersianDate date)
        {
            var shift = from s in Shifts
                        where s.PersianDate == date
                        where s.Interval.Include(interval)
                        select s;

            if (shift.Any() && shift.Count() == 1)
            {
                return(shift.First().Type);
            }
            return(null);
        }
Exemple #4
0
        private void ReadOutboundCalls()
        {
            FileInfo       fileInfo = new FileInfo(ReportPath);
            ExcelWorksheet worksheet;

            using (ExcelPackage package = new ExcelPackage(fileInfo))
            {
                try
                {
                    if (fileInfo.Exists)
                    {
                        worksheet = package.Workbook.Worksheets[1];
                        for (int i = 2; i <= worksheet.Dimension.End.Row; i++)
                        {
                            string type         = worksheet.Cells[i, 4].Text;
                            string answerTime   = worksheet.Cells[i, 6].Text;
                            string duration     = worksheet.Cells[i, 7].Text;
                            string calledNumber = worksheet.Cells[i, 3].Text;
                            if (type.ToLower().Contains("outbound") && !answerTime.ToLower().Contains("null") && duration != "0" &&
                                calledNumber.Length > 3 && calledNumber.All(char.IsDigit))
                            {
                                string number      = worksheet.Cells[i, 2].Text;
                                var    startAnswer = worksheet.Cells[i, 5].Text.ToString().Split(' ');
                                var    date        = startAnswer[0].Split('/');
                                var    time        = startAnswer[1].Split(':');
                                var    month       = int.Parse(date[0]);
                                var    day         = int.Parse(date[1]);
                                var    year        = int.Parse(date[2]);
                                var    hour        = int.Parse(time[0]);
                                var    min         = int.Parse(time[1]);
                                var    callDate    = PersianDate.FromMiladi(year < 2000 ? 2000 + year : year, month, day);
                                var    callTime    = new TimeSpan(hour, min, 0);
                                var    call        = new Call
                                {
                                    Number = number,
                                    Date   = callDate,
                                    Time   = callTime
                                };
                                OutboundCalls.Add(call);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new Exception("Error in reading report File\n" + e.Message);
                }
            }
        }
Exemple #5
0
 public Shift(TimeInterval interval, PersianDate date, ShiftType type)
 {
     Interval    = interval;
     PersianDate = date;
     Type        = type;
 }