Exemple #1
0
 internal ATT_HALF_DAY(WriteBackContext Context, string StudentId, DateTime AbsenceDate, string YearLevel, string AmCode, string PmCode)
     : base(Context)
 {
     this.StudentId   = StudentId ?? throw new ArgumentNullException(nameof(StudentId));
     this.AbsenceDate = AbsenceDate;
     this.YearLevel   = YearLevel ?? throw new ArgumentNullException(nameof(YearLevel));
     this.AmCode      = AmCode ?? throw new ArgumentNullException(nameof(AmCode));
     this.PmCode      = PmCode ?? throw new ArgumentNullException(nameof(PmCode));
 }
        internal ATT_HALF_DAYDataSet(WriteBackContext Context)
            : base(Context)
        {
            cache = new Lazy <Tuple <string, DateTime, DateTime, List <ATT_HALF_DAY> > >(LoadCache);

            schoolName = new Lazy <string>(() => cache.Value.Item1);
            fromDate   = new Lazy <DateTime>(() => cache.Value.Item2);
            toDate     = new Lazy <DateTime>(() => cache.Value.Item3);
        }
Exemple #3
0
 public ATT_HALF_DAYWriter(WriteBackContext Context, WriteBackDataSet <ATT_HALF_DAY> DataSet, string SchoolName, DateTime FromDate, DateTime ToDate)
     : base(Context, DataSet, new string[] {
     SchoolName,
     FromDate.ToString("yyyyMMdd"),
     ToDate.ToString("yyyyMMdd"),
     string.Empty,
     string.Empty,
 })
 {
     schoolName = SchoolName;
     fromDate   = FromDate;
     toDate     = ToDate;
 }
        public static WriteBackResponse Create(WriteBackContext Context, IWriteBackDataSet DataSet)
        {
            // no response if the directory doesn't exit
            if (!Directory.Exists(Context.WriteBackResponsesDirectory))
                return null;

            var prefixPattern = $"{Context.EduHubContext.EduHubSiteIdentifier}_{DataSet.Name}.*";

            var latestResponse = Directory.GetFiles(Context.WriteBackResponsesDirectory, prefixPattern)
                .Where(p =>
                    p.EndsWith(".RESPONSE-SUCCESS", StringComparison.OrdinalIgnoreCase) ||
                    p.EndsWith(".RESPONSE-ERROR", StringComparison.OrdinalIgnoreCase))
                .Select(p => new
                {
                    path = p,
                    age = File.GetCreationTime(p),
                })
                .OrderByDescending(p => p.age)
                .FirstOrDefault();

            // no response
            if (latestResponse == null)
                return null;

            var isSuccess = latestResponse.path.EndsWith(".RESPONSE-SUCCESS", StringComparison.OrdinalIgnoreCase);
            var records = WriteBackResponseRecord.Load(latestResponse.path);

            string message;
            if (!isSuccess)
                message = "Write-Back Failed. See Records for details.";
            else if (records.Count > 0)
                message = records[0].ErrorText;
            else
                message = "Success";

            return new WriteBackResponse(DataSet, latestResponse.path, latestResponse.age, isSuccess, message, records);
        }
Exemple #5
0
 internal WriteBackEntity(WriteBackContext Context)
 {
     this.Context = Context;
 }
 internal WriteBackDataSet(WriteBackContext Context)
 {
     this.Context = Context;
     Items        = new Lazy <List <T> >(Load);
 }