示例#1
0
        protected static FR_L5ST_GSTFSPI_1037 Execute(DbConnection Connection, DbTransaction Transaction, P_L5ST_GSTFSPI_1037 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5ST_GSTFSPI_1037();
            returnValue.Result = new L5ST_GSTFSPI_1037();

            L5CM_GCSFT_1157      company              = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            L6TN_GSFT_1017       settingsForTenant    = cls_Get_Settings_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            StructureBuilderUtil structureBuilderUtil = new StructureBuilderUtil();
            TreeNodeUtil         treeNodeUtil         = new TreeNodeUtil();
            List <Guid>          structurePartsList   = new List <Guid>();
            structurePartsList.Add(Parameter.StructurePartID);

            structureBuilderUtil.company         = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;;
            structureBuilderUtil.sessionToken    = securityTicket.SessionTicket;
            structureBuilderUtil.addEmployees    = false;
            structureBuilderUtil.employees       = cls_Get_Employees_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            structureBuilderUtil.sessionSettings = cls_Get_Settings_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            structureBuilderUtil.startDate       = cls_Get_CalculationTimeFramesForTenant.Invoke(Connection, Transaction, securityTicket).Result.Min(x => x.CalculationTimeframe_StartDate).Date;
            structureBuilderUtil.endDate         = DateTime.Now;
            structureBuilderUtil.hidenNodeType   = CompanyStructureType.None;

            EmployeeUtils employeeUtil = new EmployeeUtils();
            structureBuilderUtil.employeeUtil = employeeUtil;

            List <Node>            companyStructure        = structureBuilderUtil.organizeData(DateTime.Now);
            List <L5ST_GSTFT_1610> remainingShiftTemplates = new List <L5ST_GSTFT_1610>();
            List <L5ST_GSTFT_1610> tempShiftTemplates      = new List <L5ST_GSTFT_1610>();

            Node foundNode = treeNodeUtil.findNodeForID(companyStructure[0], Parameter.StructurePartID);
            if (foundNode != null)
            {
                treeNodeUtil.getParentIDsForStructurePart(foundNode, structurePartsList);

                L5ST_GSTFT_1610[] shiftTemplates = cls_Get_ShiftTemplates_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;

                foreach (var structureID in structurePartsList)
                {
                    tempShiftTemplates = shiftTemplates.Where(i => (i.CMN_STR_Office_RefID == structureID && structureID != Guid.Empty) || (i.CMN_STR_Workarea_RefID == structureID && structureID != Guid.Empty) || (i.CMN_STR_Workplace_RefID == structureID && structureID != Guid.Empty) || (i.CMN_STR_Workplace_RefID == Guid.Empty && i.CMN_STR_Workarea_RefID == Guid.Empty && i.CMN_STR_Office_RefID == Guid.Empty)).ToList();
                    foreach (var shiftTemplate in tempShiftTemplates)
                    {
                        if (!remainingShiftTemplates.Contains(shiftTemplate))
                        {
                            remainingShiftTemplates.Add(shiftTemplate);
                        }
                    }
                }
            }
            returnValue.Result.ShiftTemplates = remainingShiftTemplates.ToArray();

            //Put your code here
            return(returnValue);

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

            StructureBuilderUtil structureBuilderUtil = new StructureBuilderUtil();
            TreeNodeUtil         treeNodeUtil         = new TreeNodeUtil();

            structureBuilderUtil.company         = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;;
            structureBuilderUtil.sessionToken    = securityTicket.SessionTicket;
            structureBuilderUtil.addEmployees    = false;
            structureBuilderUtil.sessionSettings = cls_Get_Settings_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            structureBuilderUtil.startDate       = cls_Get_CalculationTimeFramesForTenant.Invoke(Connection, Transaction, securityTicket).Result.Min(x => x.CalculationTimeframe_StartDate).Date;
            structureBuilderUtil.endDate         = DateTime.Now;
            structureBuilderUtil.hidenNodeType   = CompanyStructureType.None;
            structureBuilderUtil.employees       = new L5EM_GEFT_0959[0];

            EmployeeUtils employeeUtil = new EmployeeUtils();
            structureBuilderUtil.employeeUtil = employeeUtil;
            returnValue.Result = new L5CM_CSNU_1524();
            List <Node> companyStructure = structureBuilderUtil.organizeData(DateTime.Now);

            Node node = treeNodeUtil.findNodeForID(companyStructure[0], Parameter.ParentRefID);
            if (node != null && node.Children.Count != 0)
            {
                if (node.Children[0].data is L5OF_GOFT_1157)
                {
                    var officeQuery = new ORM_CMN_STR_Office.Query();
                    officeQuery.Tenant_RefID     = securityTicket.TenantID;
                    officeQuery.IsDeleted        = false;
                    officeQuery.Office_ShortName = Parameter.ShortName;
                    var officeQueryRes = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQuery);

                    if (officeQueryRes.Count > 0)
                    {
                        if (officeQueryRes.Count > 0)
                        {
                            returnValue.Result.OfficeID        = officeQueryRes[0].CMN_STR_OfficeID;
                            returnValue.Result.OfficeShortName = officeQueryRes[0].Office_ShortName;
                        }
                    }
                }
                else if (node.Children[0].data is L5WA_GWAFT_1201)
                {
                    var workareaQuery = new ORM_CMN_STR_PPS_WorkArea.Query();
                    workareaQuery.Tenant_RefID = securityTicket.TenantID;
                    workareaQuery.IsDeleted    = false;
                    workareaQuery.ShortName    = Parameter.ShortName;
                    if (node.data is L5WA_GWAFT_1201)
                    {
                        workareaQuery.Parent_RefID = Parameter.ParentRefID;
                    }
                    else
                    {
                        workareaQuery.Office_RefID = Parameter.ParentRefID;
                    }

                    var workareaQueryRes = ORM_CMN_STR_PPS_WorkArea.Query.Search(Connection, Transaction, workareaQuery);
                    if (workareaQueryRes.Count > 0)
                    {
                        returnValue.Result.WorkAreaID        = workareaQueryRes[0].CMN_STR_PPS_WorkAreaID;
                        returnValue.Result.WorkAreaShortName = workareaQueryRes[0].ShortName;
                    }
                }
                else if (node.Children[0].data is L5WP_GWFT_1203)
                {
                    var workplaceQuery = new ORM_CMN_STR_PPS_Workplace.Query();
                    workplaceQuery.Tenant_RefID   = securityTicket.TenantID;
                    workplaceQuery.IsDeleted      = false;
                    workplaceQuery.ShortName      = Parameter.ShortName;
                    workplaceQuery.WorkArea_RefID = Parameter.ParentRefID;
                    var workplaceQueryRes = ORM_CMN_STR_PPS_Workplace.Query.Search(Connection, Transaction, workplaceQuery);
                    if (workplaceQueryRes.Count > 0)
                    {
                        if (workplaceQueryRes.Count > 0)
                        {
                            returnValue.Result.WorkPlaceID        = workplaceQueryRes[0].CMN_STR_PPS_WorkplaceID;
                            returnValue.Result.WorkPlaceShortName = workplaceQueryRes[0].ShortName;
                        }
                    }
                }
            }


            return(returnValue);

            #endregion UserCode
        }