Beispiel #1
0
        protected static FR_L5ST_GSTFSTI_1641 Execute(DbConnection Connection, DbTransaction Transaction, P_L5ST_GSTFSTI_1641 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5ST_GSTFSTI_1641();
            returnValue.Result = new L5ST_GSTFSTI_1641();


            ORM_CMN_PPS_ShiftTemplate.Query shiftTemplateQuery = new ORM_CMN_PPS_ShiftTemplate.Query();
            shiftTemplateQuery.Tenant_RefID            = securityTicket.TenantID;
            shiftTemplateQuery.IsDeleted               = false;
            shiftTemplateQuery.CMN_PPS_ShiftTemplateID = Parameter.ShiftTemplateID;
            List <ORM_CMN_PPS_ShiftTemplate> shiftTemplates = ORM_CMN_PPS_ShiftTemplate.Query.Search(Connection, Transaction, shiftTemplateQuery);


            ORM_CMN_PPS_ShiftTemplate shiftTemplate = shiftTemplates[0];
            L5ST_GSTFT_1610           templateItem  = new L5ST_GSTFT_1610();
            templateItem.CMN_PPS_ShiftTemplateID = shiftTemplate.CMN_PPS_ShiftTemplateID;
            templateItem.CMN_STR_Office_RefID    = shiftTemplate.CMN_STR_Office_RefID;
            templateItem.CMN_STR_Workarea_RefID  = shiftTemplate.CMN_STR_Workarea_RefID;
            templateItem.CMN_STR_Workplace_RefID = shiftTemplate.CMN_STR_Workplace_RefID;
            templateItem.ShiftTemplate_Name      = shiftTemplate.ShiftTemplate_Name;
            templateItem.ShiftTemplate_ShortName = shiftTemplate.ShiftTemplate_ShortName;

            ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query workdetailsQuery = new ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query();
            workdetailsQuery.IsDeleted    = false;
            workdetailsQuery.Tenant_RefID = securityTicket.TenantID;
            workdetailsQuery.CMN_PPS_ShiftTemplate_RefID = shiftTemplate.CMN_PPS_ShiftTemplateID;
            List <ORM_CMN_PPS_ShiftTemplate_WorkDetail> workDetails = ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query.Search(Connection, Transaction, workdetailsQuery);
            if (workDetails != null && workDetails.Count != 0)
            {
                int    startingTime  = 0;
                int    endingTime    = 0;
                int    brakeTime     = 0;
                double totalWorkTime = 0;
                foreach (var workDetail in workDetails)
                {
                    if (startingTime == 0 || startingTime > workDetail.ShiftStart_Offset_sec)
                    {
                        startingTime = (int)workDetail.ShiftStart_Offset_sec;
                    }
                    if (endingTime < workDetail.ShiftStart_Offset_sec + workDetail.Duration_in_sec)
                    {
                        endingTime = (int)workDetail.ShiftStart_Offset_sec + (int)workDetail.Duration_in_sec;
                    }

                    totalWorkTime += workDetail.Duration_in_sec;
                }
                templateItem.BrakeTime = CronExtender.secondsToTime(brakeTime);
                templateItem.EndTime   = CronExtender.secondsToTime(endingTime);
                templateItem.StartTime = CronExtender.secondsToTime(startingTime);
                templateItem.Worktime  = CronExtender.secondsToTime(Int32.Parse(totalWorkTime.ToString()));
            }



            returnValue.Result.ShiftTemplate = templateItem;


            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_L5ST_GSTFT_1610_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5ST_GSTFT_1610_Array();

            List <L5ST_GSTFT_1610> shiftTemplatesReturn = new List <L5ST_GSTFT_1610>();

            ORM_CMN_PPS_ShiftTemplate.Query shiftTemplateQuery = new ORM_CMN_PPS_ShiftTemplate.Query();
            shiftTemplateQuery.Tenant_RefID = securityTicket.TenantID;
            shiftTemplateQuery.IsDeleted    = false;
            List <ORM_CMN_PPS_ShiftTemplate> shiftTemplates = ORM_CMN_PPS_ShiftTemplate.Query.Search(Connection, Transaction, shiftTemplateQuery);
            foreach (var shiftTemplate in shiftTemplates)
            {
                L5ST_GSTFT_1610 templateItem = new L5ST_GSTFT_1610();
                templateItem.CMN_PPS_ShiftTemplateID = shiftTemplate.CMN_PPS_ShiftTemplateID;
                templateItem.CMN_STR_Office_RefID    = shiftTemplate.CMN_STR_Office_RefID;
                templateItem.CMN_STR_Workarea_RefID  = shiftTemplate.CMN_STR_Workarea_RefID;
                templateItem.CMN_STR_Workplace_RefID = shiftTemplate.CMN_STR_Workplace_RefID;
                templateItem.ShiftTemplate_Name      = shiftTemplate.ShiftTemplate_Name;
                templateItem.ShiftTemplate_ShortName = shiftTemplate.ShiftTemplate_ShortName;
                templateItem.Default_AllowedBreakTimeTemplate_RefID = shiftTemplate.Default_AllowedBreakTimeTemplate_RefID;
                templateItem.DisplayColor = shiftTemplate.DisplayColor;

                ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query workdetailsQuery = new ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query();
                workdetailsQuery.IsDeleted    = false;
                workdetailsQuery.Tenant_RefID = securityTicket.TenantID;
                workdetailsQuery.CMN_PPS_ShiftTemplate_RefID = shiftTemplate.CMN_PPS_ShiftTemplateID;
                List <ORM_CMN_PPS_ShiftTemplate_WorkDetail> workDetails = ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query.Search(Connection, Transaction, workdetailsQuery);
                if (workDetails != null && workDetails.Count != 0)
                {
                    int    startingTime  = 0;
                    int    endingTime    = 0;
                    double totalWorkTime = 0;
                    foreach (var workDetail in workDetails)
                    {
                        if (startingTime == 0 || (startingTime > workDetail.ShiftStart_Offset_sec && workDetail.ShiftStart_Offset_sec != 0))
                        {
                            startingTime = (int)workDetail.ShiftStart_Offset_sec;
                        }
                        if (endingTime < workDetail.ShiftStart_Offset_sec + workDetail.Duration_in_sec)
                        {
                            endingTime = (int)workDetail.ShiftStart_Offset_sec + (int)workDetail.Duration_in_sec;
                        }

                        totalWorkTime += workDetail.Duration_in_sec;
                    }

                    templateItem.EndTime   = CronExtender.secondsToTime(endingTime);
                    templateItem.StartTime = CronExtender.secondsToTime(startingTime);
                    templateItem.Worktime  = CronExtender.secondsToTime(Int32.Parse(totalWorkTime.ToString()));
                }
                else
                {
                    templateItem.EndTime   = CronExtender.secondsToTime(0);
                    templateItem.StartTime = CronExtender.secondsToTime(0);
                    templateItem.Worktime  = CronExtender.secondsToTime(0);
                }
                int brakeTime = 0;
                if (shiftTemplate.Default_AllowedBreakTimeTemplate_RefID != Guid.Empty)
                {
                    P_L5BR_GBMFTID_1537 par = new P_L5BR_GBMFTID_1537();
                    par.CMN_PPS_BreakTime_TemplateID = shiftTemplate.Default_AllowedBreakTimeTemplate_RefID;
                    L5BR_GBMFTID_1537 breakModel = cls_Get_BreakModels_For_TemplateID.Invoke(Connection, Transaction, par, securityTicket).Result;
                    brakeTime = breakModel.BreakModel.Duration;
                    templateItem.BrakeTime = CronExtender.secondsToTime(brakeTime);
                    templateItem.Worktime  = CronExtender.secondsToTime(CronExtender.timeToSeconds(templateItem.Worktime) - brakeTime);
                }
                else
                {
                    templateItem.BrakeTime = CronExtender.secondsToTime(0);
                }
                P_L5ST_GSTQFST_1516 param = new P_L5ST_GSTQFST_1516();
                param.ShiftTemplateID       = shiftTemplate.CMN_PPS_ShiftTemplateID;
                templateItem.Qualifications = cls_Get_ShiftQualifications_For_ShiftTemplateID.Invoke(Connection, Transaction, param, securityTicket).Result;

                shiftTemplatesReturn.Add(templateItem);
            }

            returnValue.Result = shiftTemplatesReturn.ToArray();



            //Put your code here
            return(returnValue);

            #endregion UserCode
        }