public ErrorInfo SaveData(List <List <DailyAttendanceData> > list, List <SummaryAttendanceData> list_sum, DateTime kijundate)
        {
            string AvoidPath = string.Empty;
            var    errorinfo = ExcelOperation.DeleteExcelFile(this.ExcelPath, out AvoidPath);

            if (errorinfo.HasError)
            {
                return(errorinfo);
            }

            IWorkbook workbook = new XSSFWorkbook();

            using (var fs = new FileStream(this.ExcelPath, FileMode.OpenOrCreate))
            {
                errorinfo = this.SaveSumAttendanceData(list_sum, workbook, out workbook);

                foreach (var item in list)
                {
                    int getudoyyyymm = item.Max(x => x.GetudoYYYYMM);
                    errorinfo = this.SaveExcelSheet(getudoyyyymm, item, workbook, out workbook);
                    if (errorinfo.HasError)
                    {
                        return(errorinfo);
                    }
                }
                workbook.Write(fs);
            }

            File.Delete(AvoidPath);
            return(errorinfo);
        }
Esempio n. 2
0
        private ErrorInfo GetHolidays(string ExcelPath)
        {
            FileStream file;
            ErrorInfo  errorinfo = new ErrorInfo();

            errorinfo = ExcelOperation.OpenExcelFile(ExcelPath, out file);
            if (errorinfo.HasError)
            {
                return(errorinfo);
            }
            errorinfo = GetHolidayList(file, out HolidayList);
            if (errorinfo.HasError)
            {
                return(errorinfo);
            }
            errorinfo = ExcelOperation.ReleaseExcelFile(file);
            return(errorinfo);
        }
        public ErrorInfo GetInitAttendanceData(MasterGetudo getudorecord, out List <List <DailyAttendanceData> > attendanceDataBox, out List <SummaryAttendanceData> summaryAttendanceList)
        {
            attendanceDataBox     = new List <List <DailyAttendanceData> >();
            summaryAttendanceList = new List <SummaryAttendanceData>();
            var errorinfo = new ErrorInfo();

            if (getudorecord.GetudoYYYYMM == 0)
            {
                errorinfo.HasError    = true;
                errorinfo.ErrorReason = "月度の値が不正です。";
                return(errorinfo);
            }

            FileStream file;

            errorinfo = ExcelOperation.OpenExcelFile(ExcelPath, out file);
            if (errorinfo.HasError)
            {
                return(errorinfo);
            }
            errorinfo = GetAttendanceDataList(file, out attendanceDataBox, out summaryAttendanceList);
            if (errorinfo.HasError)
            {
                return(errorinfo);
            }
            errorinfo = ExcelOperation.ReleaseExcelFile(file);

            if (!attendanceDataBox.Any() ||
                attendanceDataBox.Count(x => x.Count(r => r.GetudoYYYYMM == getudorecord.GetudoYYYYMM) != 0) == 0)
            {
                var list = new List <DailyAttendanceData>();
                errorinfo = GetInitMonthlyData(getudorecord, out list);
                attendanceDataBox.Add(list);
            }

            return(errorinfo);
        }