Exemplo n.º 1
0
        public static void GenerateBirthdayInboxMessage(DatabaseConnection dbConn, int UserID, int NoticeDaysBefore, int NoticeDaysAfter)
        {
            if (NoticeDaysBefore < 0)
            {
                NoticeDaysBefore = 30;
            }
            if (NoticeDaysAfter < 0)
            {
                NoticeDaysAfter = 30;
            }

            const string INBOX_TYPE        = EInbox.INBOX_TYPE_DATE_OF_BIRTH;
            DBFilter     DateOfBirthFilter = new DBFilter();

            DateOfBirthFilter.add(AppUtils.AddRankDBTerm(UserID, "EmpID", true));

            //DateOfBirthFilter.add(new Match("EmpDateOfBirth", ">=", AppUtils.ServerDateTime().Date.AddYears(-YEAR_DIFFERENT).AddDays(-NOTICEDAYSAFTER)));
            //DateOfBirthFilter.add(new Match("EmpDateOfBirth", "<=", AppUtils.ServerDateTime().Date.AddYears(-YEAR_DIFFERENT).AddDays(NOTICEDAYSBEFORE)));

            DBFilter existsInboxFilter = new DBFilter();

            existsInboxFilter.add(new MatchField(EEmpPersonalInfo.db.dbclass.tableName + ".EmpID", EInbox.db.dbclass.tableName + ".EmpID"));
            existsInboxFilter.add(new MatchField(EEmpPersonalInfo.db.dbclass.tableName + ".EmpID", EInbox.db.dbclass.tableName + ".InboxRelatedRecID"));
            existsInboxFilter.add(new MatchField(EEmpPersonalInfo.db.dbclass.tableName + ".EmpDateOfBirth", EInbox.db.dbclass.tableName + ".InboxRelatedReferenceDate"));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxType", INBOX_TYPE));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".UserID", UserID));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxCreateDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-(NoticeDaysBefore + NoticeDaysAfter))));
            Exists existsInbox = new Exists(EInbox.db.dbclass.tableName, existsInboxFilter, true);

            DateOfBirthFilter.add(existsInbox);

            DBFilter existsEmpTerminationFilter = new DBFilter();

            existsEmpTerminationFilter.add(new MatchField(EEmpPersonalInfo.db.dbclass.tableName + ".EmpID", EEmpTermination.db.dbclass.tableName + ".EmpID"));
            existsEmpTerminationFilter.add(new Match("EmpTermLastDate", "<=", AppUtils.ServerDateTime().Date));
            Exists notExistsEmpTermination = new Exists(EEmpTermination.db.dbclass.tableName, existsEmpTerminationFilter, true);

            DateOfBirthFilter.add(notExistsEmpTermination);

            System.Collections.ArrayList empInfoList = EEmpPersonalInfo.db.select(dbConn, DateOfBirthFilter);
            DateTime BirthdayPeriodFrom = AppUtils.ServerDateTime().Date.AddDays(-NoticeDaysAfter);
            DateTime BirthdayPeriodTo   = AppUtils.ServerDateTime().Date.AddDays(NoticeDaysBefore);

            foreach (EEmpPersonalInfo empInfo in empInfoList)
            {
                DateTime dateOfBirth = empInfo.EmpDateOfBirth;
                int      yearCount   = 0;
                while (dateOfBirth <= BirthdayPeriodFrom)
                {
                    yearCount++;
                    dateOfBirth = empInfo.EmpDateOfBirth.AddYears(yearCount);
                }
                if (dateOfBirth <= BirthdayPeriodTo)
                {
                    EInbox.CreateAndSaveInboxMessage(dbConn, UserID, 0, empInfo.EmpID, empInfo.EmpID, string.Empty, INBOX_TYPE, string.Empty, string.Empty, empInfo.EmpDateOfBirth);
                }
            }
        }
Exemplo n.º 2
0
        public static EInbox CreateAndSaveInboxMessage(DatabaseConnection dbConn, int ToUserID, int FromUserID, int EmpID, int RelatedRecID, string FromUserName, string InboxMessageType, string InboxSubject, string InboxMessage, DateTime RelatedReferenceDate)
        {
            EInbox inbox = new EInbox();

            inbox.UserID                    = ToUserID;
            inbox.InboxFromUserID           = 0;
            inbox.InboxFromUserName         = string.Empty;
            inbox.EmpID                     = EmpID;
            inbox.InboxRelatedRecID         = RelatedRecID;
            inbox.InboxRelatedReferenceDate = RelatedReferenceDate;
            inbox.InboxType                 = InboxMessageType;
            inbox.InboxSubject              = InboxSubject;
            inbox.InboxMessage              = InboxMessage;
            inbox.InboxCreateDate           = AppUtils.ServerDateTime();
            EInbox.db.insert(dbConn, inbox);
            return(inbox);
        }
Exemplo n.º 3
0
        public static void GenerateWorkPermitExpiryInboxMessage(DatabaseConnection dbConn, int UserID, int NoticeDaysBefore, int NoticeDaysAfter)
        {
            if (NoticeDaysBefore < 0)
            {
                NoticeDaysBefore = 30;
            }
            if (NoticeDaysAfter < 0)
            {
                NoticeDaysAfter = 30;
            }

            const string INBOX_TYPE             = EInbox.INBOX_TYPE_WORKPERMITEXPIRY;
            DBFilter     WorkPermitExpiryFilter = new DBFilter();

            WorkPermitExpiryFilter.add(AppUtils.AddRankDBTerm(UserID, "EmpID", true));

            WorkPermitExpiryFilter.add(new Match("EmpPermitExpiryDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-NoticeDaysAfter)));
            WorkPermitExpiryFilter.add(new Match("EmpPermitExpiryDate", "<=", AppUtils.ServerDateTime().Date.AddDays(NoticeDaysBefore)));

            DBFilter existsInboxFilter = new DBFilter();

            existsInboxFilter.add(new MatchField(EEmpPermit.db.dbclass.tableName + ".EmpID", EInbox.db.dbclass.tableName + ".EmpID"));
            existsInboxFilter.add(new MatchField(EEmpPermit.db.dbclass.tableName + ".EmpPermitID", EInbox.db.dbclass.tableName + ".InboxRelatedRecID"));
            existsInboxFilter.add(new MatchField(EEmpPermit.db.dbclass.tableName + ".EmpPermitExpiryDate", EInbox.db.dbclass.tableName + ".InboxRelatedReferenceDate"));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxType", INBOX_TYPE));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".UserID", UserID));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxCreateDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-(NoticeDaysBefore + NoticeDaysAfter))));
            Exists existsInbox = new Exists(EInbox.db.dbclass.tableName, existsInboxFilter, true);

            WorkPermitExpiryFilter.add(existsInbox);

            DBFilter existsEmpTerminationFilter = new DBFilter();

            existsEmpTerminationFilter.add(new MatchField(EEmpPermit.db.dbclass.tableName + ".EmpID", EEmpTermination.db.dbclass.tableName + ".EmpID"));
            existsEmpTerminationFilter.add(new Match("EmpTermLastDate", "<=", AppUtils.ServerDateTime().Date));
            Exists notExistsEmpTermination = new Exists(EEmpTermination.db.dbclass.tableName, existsEmpTerminationFilter, true);

            WorkPermitExpiryFilter.add(notExistsEmpTermination);

            System.Collections.ArrayList empInfoList = EEmpPermit.db.select(dbConn, WorkPermitExpiryFilter);
            foreach (EEmpPermit empWorkPermit in empInfoList)
            {
                EInbox.CreateAndSaveInboxMessage(dbConn, UserID, 0, empWorkPermit.EmpID, empWorkPermit.EmpPermitID, string.Empty, INBOX_TYPE, string.Empty, string.Empty, empWorkPermit.EmpPermitExpiryDate);
            }
        }
Exemplo n.º 4
0
        public static void GenerateTerminationInboxMessage(DatabaseConnection dbConn, int UserID, int NoticeDaysBefore, int NoticeDaysAfter)
        {
            if (NoticeDaysBefore < 0)
            {
                NoticeDaysBefore = 15;
            }
            if (NoticeDaysAfter < 0)
            {
                NoticeDaysAfter = 15;
            }

            const string INBOX_TYPE        = EInbox.INBOX_TYPE_TERMINATION;
            DBFilter     TerminationFilter = new DBFilter();

            TerminationFilter.add(AppUtils.AddRankDBTerm(UserID, "EmpID", true));

            TerminationFilter.add(new Match("EmpTermLastDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-NoticeDaysAfter)));
            TerminationFilter.add(new Match("EmpTermLastDate", "<=", AppUtils.ServerDateTime().Date.AddDays(NoticeDaysBefore)));

            DBFilter existsInboxFilter = new DBFilter();

            existsInboxFilter.add(new MatchField(EEmpTermination.db.dbclass.tableName + ".EmpID", EInbox.db.dbclass.tableName + ".EmpID"));
            existsInboxFilter.add(new MatchField(EEmpTermination.db.dbclass.tableName + ".EmpTermID", EInbox.db.dbclass.tableName + ".InboxRelatedRecID"));
            existsInboxFilter.add(new MatchField(EEmpTermination.db.dbclass.tableName + ".EmpTermLastDate", EInbox.db.dbclass.tableName + ".InboxRelatedReferenceDate"));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxType", INBOX_TYPE));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".UserID", UserID));
            existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxCreateDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-(NoticeDaysBefore + NoticeDaysAfter))));
            Exists existsInbox = new Exists(EInbox.db.dbclass.tableName, existsInboxFilter, true);

            TerminationFilter.add(existsInbox);


            System.Collections.ArrayList empInfoList = EEmpTermination.db.select(dbConn, TerminationFilter);
            foreach (EEmpTermination empTerm in empInfoList)
            {
                //EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                //empInfo.EmpID = empTerm.EmpID;
                //if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                EInbox.CreateAndSaveInboxMessage(dbConn, UserID, 0, empTerm.EmpID, empTerm.EmpTermID, string.Empty, INBOX_TYPE, string.Empty, string.Empty, empTerm.EmpTermLastDate);
            }
        }
Exemplo n.º 5
0
    protected void UploadFromInbox(int InboxID)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        if (bankFileCutOffDateTime < currentDateTime)
        {
            errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_SAAS_FILE_SUBMIT_AFTER_CUTOFF, new string[] { bankFileCutOffDateTime.ToString("HH:mm") }));
            return;
        }

        HROne.Lib.Entities.EInbox o = new HROne.Lib.Entities.EInbox();
        o.InboxID = InboxID;
        if (HROne.Lib.Entities.EInbox.db.select(dbConn, o))
        {
            if (!o.UserID.Equals(user.UserID))
            {
                Response.Redirect("~/AccessDeny.aspx");
            }

            System.Collections.Generic.List <string> inboxTypeArray = new System.Collections.Generic.List <string>(o.InboxType.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));

            if (inboxTypeArray.Contains(HROne.Lib.Entities.EInbox.INBOX_TYPE_FOR_ECHANNEL) && !inboxTypeArray.Contains(HROne.Lib.Entities.EInbox.INBOX_TYPE_FOR_ECHANNEL_SUBMITTED))
            {
                string uploadFolder = uploadFolder = AppUtils.GetDocumentUploadFolder(dbConn);

                DBFilter attachmentFilter = new DBFilter();
                attachmentFilter.add(new Match("InboxID", o.InboxID));
                ArrayList attachmentList = HROne.Lib.Entities.EInboxAttachment.db.select(dbConn, attachmentFilter);

                HROne.Lib.Entities.EInboxAttachment attachment = (HROne.Lib.Entities.EInboxAttachment)attachmentList[0];

                string documentFilePath = attachment.GetDocumentPhysicalPath(dbConn);
                string transferFilePath = documentFilePath;

                string strTmpFolder = HROne.Common.Folder.GetOrCreateSessionTempFolder(Session.SessionID).FullName;;  //Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
                string strTmpFile   = System.IO.Path.Combine(strTmpFolder, currentDateTime.ToString("~yyyyMMddHHmmss_") + attachment.InboxAttachmentOriginalFileName);

                if (attachment.InboxAttachmentIsCompressed)
                {
                    transferFilePath = attachment.GetExtractedFilePath(dbConn);
                    System.IO.File.Move(transferFilePath, strTmpFile);
                }
                else
                {
                    System.IO.File.Copy(transferFilePath, strTmpFile);
                }
                try
                {
                    UploadToMasterDB(strTmpFile);
                    inboxTypeArray.Add(HROne.Lib.Entities.EInbox.INBOX_TYPE_FOR_ECHANNEL_SUBMITTED);
                    o.InboxType = string.Join("|", inboxTypeArray.ToArray());
                    HROne.Lib.Entities.EInbox.db.update(dbConn, o);
                }
                catch (Exception ex)
                {
                    System.IO.File.Delete(strTmpFile);
                    errors.addError(ex.Message);
                }
            }
            else
            {
                errors.addError("File is already submitted");
            }
        }
    }