Example #1
0
        static void Main(string[] args)
        {
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            var settings = new MongoDB.Driver.MongoServerSettings();

            var address = new MongoDB.Driver.MongoServerAddress(Properties.Settings.Default.Server, Properties.Settings.Default.Port);

            settings.Server = address;

            MongoDB.Driver.MongoServer server = new MongoDB.Driver.MongoServer(settings);


            var           client   = new MongoDB.Driver.MongoClient();
            MongoDatabase database = server.GetDatabase("mc2db");

            Console.WriteLine("Aloitetaan...");
            var now    = MC2DateTimeValue.Now().ToLocalTime();
            var nowStr = string.Format("{0:0000}-{1:00}-{2:00}-{3:00}-{4:00}-{5:00}",
                                       now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

            var logFile = Path.Combine(string.Format("{0}_{1}.txt", Properties.Settings.Default.ExcelPath + "\\Log", nowStr));

            if (!Directory.Exists(Path.GetDirectoryName(logFile)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(logFile));
            }
            var x = new PayrollExport(logFile, database);

            x.ExportDocuments();
            Console.WriteLine("Valmis...aikaa kului {0} minuuttia", sw.Elapsed.TotalMinutes);
        }
Example #2
0
        /// <summary>
        /// Appends entrytype hours or amounts to a worksheet
        /// </summary>
        /// <typeparam name="EntryType">Abcence, Day or Timesheet</typeparam>
        /// <param name="worksheet">Worksheet to append work hours or amounts</param>
        /// <param name="row">Row position where to start</param>
        /// <returns>Row position where to start next data to be written</returns>
        private int AppendTimesheetAndAbcenceAndDayDataToWorksheet <EntryType>(ExcelWorksheet worksheet, int row) where EntryType : EntryToPayroll
        {
            var collection = this as EntriesToPayroll <EntryType>;

            foreach (EntryType item in collection)
            {
                worksheet.Cells[row, DateExcelColumn].Value = Convert.ToDateTime(item.StartDate).ToString(ExcelDateFormat);

                if (typeof(EntryType) == typeof(Timesheet))
                {
                    if ((item as Timesheet).IsTimesheetEntryDetail == false)
                    {
                        worksheet.Cells[row, StartTimeExcelColumn].Value = Convert.ToDateTime(item.StartDate).ToString(ExcelTimeFormat);
                        worksheet.Cells[row, EndTimeExcelColumn].Value   = Convert.ToDateTime(item.EndDate).ToString(ExcelTimeFormat);
                    }
                }
                else
                {
                    worksheet.Cells[row, StartTimeExcelColumn].Value = Convert.ToDateTime(item.StartDate).ToString(ExcelTimeFormat);
                    worksheet.Cells[row, EndTimeExcelColumn].Value   = Convert.ToDateTime(item.EndDate).ToString(ExcelTimeFormat);
                }
                worksheet.Cells[row, NameExcelColumn].Value        = item.UserName;
                worksheet.Cells[row, UserIdExcelColumn].Value      = item.UserIdentifier;
                worksheet.Cells[row, HoursExcelColumn].Value       = PayrollExport.MillisecondsToHours((int)item.Hours);
                worksheet.Cells[row, PayTypeNameExcelColumn].Value = item.PayTypeName;
                worksheet.Cells[row, PayTypeExcelColumn].Value     = item.PayTypeId;
                if (typeof(EntryType) == typeof(Absence) == false)
                {
                    worksheet.Cells[row, ProjectExcelColumn].Value = (item as Timesheet).ProjectNumber;
                }
                worksheet.Cells[row, ApprovedByWorkerExcelColumn].Value  = item.ApprovedByWorker;
                worksheet.Cells[row, ApprovedByManagerExcelColumn].Value = item.ApprovedByManager;
                worksheet.Cells[row, ObjectIdExcelColumn].Value          = item._id;
                //if (typeof(EntryType) == typeof(Absence) == false)
                {
                    worksheet.Cells[row, ProfitCenterExcelColumn].Value = item.ProfitCenter;
                }
                row++;
            }
            return(row);
        }