Exemplo n.º 1
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L5LR_GLRTFEAT_1634 Invoke(string ConnectionString, P_L5LR_GLRTFEAT_1634 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }
Exemplo n.º 2
0
        protected static FR_L5LR_GLRTFEAT_1634 Execute(DbConnection Connection, DbTransaction Transaction, P_L5LR_GLRTFEAT_1634 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            var returnStatus = new FR_L5LR_GLRTFEAT_1634();

            DbCommand command = Connection.CreateCommand();

            command.Connection  = Connection;
            command.Transaction = Transaction;
            var commandLocation = "CL5_VacationPlanner_LeaveRequest.Atomic.Retrieval.SQL.cls_Get_LeaveRequestsTimes_For_EmployeeAndTime.sql";

            command.CommandText = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(commandLocation)).ReadToEnd();
            CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ticket", securityTicket);
            command.CommandTimeout = QueryTimeout;
            CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "EmployeeID", Parameter.EmployeeID);
            CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "StartTime", Parameter.StartTime);
            CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "EndTime", Parameter.EndTime);


            List <L5LR_GLRTFEAT_1634> results = new List <L5LR_GLRTFEAT_1634>();
            var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
            var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader());

            try
            {
                reader.SetOrdinals(new string[] { "Comment", "StartTime", "EndTime", "CMN_BPT_EMP_Employee_LeaveRequestID" });
                while (reader.Read())
                {
                    L5LR_GLRTFEAT_1634 resultItem = new L5LR_GLRTFEAT_1634();
                    //0:Parameter Comment of type string
                    resultItem.Comment = reader.GetString(0);
                    //1:Parameter StartTime of type DateTime
                    resultItem.StartTime = reader.GetDate(1);
                    //2:Parameter EndTime of type DateTime
                    resultItem.EndTime = reader.GetDate(2);
                    //3:Parameter CMN_BPT_EMP_Employee_LeaveRequestID of type Guid
                    resultItem.CMN_BPT_EMP_Employee_LeaveRequestID = reader.GetGuid(3);

                    results.Add(resultItem);
                }
            }
            catch (Exception ex)
            {
                reader.Close();
                throw ex;
            }
            reader.Close();
            //Load all the dictionaries from the datatables
            loader.Load();

            returnStatus.Result = results.FirstOrDefault();
            return(returnStatus);
        }
Exemplo n.º 3
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_L5LR_GLRTFEAT_1634 Invoke(DbConnection Connection, DbTransaction Transaction, P_L5LR_GLRTFEAT_1634 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Exemplo n.º 4
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5LR_GLRTFEAT_1634 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5LR_GLRTFEAT_1634 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5LR_GLRTFEAT_1634 functionReturn = new FR_L5LR_GLRTFEAT_1634();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);


                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }
            return(functionReturn);
        }
Exemplo n.º 5
0
        protected static FR_L6LR_VNL_M_1429 Execute(DbConnection Connection, DbTransaction Transaction, P_L6LR_VNL_M_1429 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6LR_VNL_M_1429();

            var calculationTimeframe = cls_Get_CalculationTimeFramesForTenant.Invoke(Connection, Transaction, securityTicket).Result.FirstOrDefault();
            #region  get events
            P_L5LR_EV_TSD_1047 param = new P_L5LR_EV_TSD_1047
            {
                EndDate   = Parameter.EndDate,
                StartDate = Parameter.StartDate
            };
            var forbiddingEvents = cls_Get_Events_for_Timespan_Data.Invoke(Connection, Transaction, param, securityTicket).Result.Where(e => e.forbiddenLeaveTypes != null && e.forbiddenLeaveTypes.FirstOrDefault(f => f.CMN_BPT_STA_AbsenceReasonID == Parameter.AbsenceTypeID) != null);

            #endregion

            #region basic validation
            if (Parameter.ForPerson == Guid.Empty || Parameter.ForPerson == null)
            {
                returnValue.Result = new L6LR_VNL_M_1429 {
                    isInvalidPerson = true
                };
                return(returnValue);
            }
            else if (Parameter.AbsenceTypeID == Guid.Empty || Parameter.AbsenceTypeID == null)
            {
                returnValue.Result = new L6LR_VNL_M_1429 {
                    isInvalidAbsenceReason = true
                };
                return(returnValue);
            }
            if (Parameter.StartDate == Parameter.EndDate)
            {
                returnValue.Result = new L6LR_VNL_M_1429 {
                    isSamedate = true
                };
                return(returnValue);
            }
            if (Parameter.StartDate == DateTime.MinValue || Parameter.EndDate == DateTime.MinValue)
            {
                returnValue.Result = new L6LR_VNL_M_1429 {
                    isInvalidDatePairGiven = true
                };
                return(returnValue);
            }
            if (Parameter.EndDate < Parameter.EndDate)
            {
                returnValue.Result = new L6LR_VNL_M_1429 {
                    isEndTimeLover = true
                };
                return(returnValue);
            }
            #endregion basic validation

            var employeeAndLrData = cls_Get_Employees_And_LeaveRequestData_For_IDList.Invoke(Connection, Transaction, new P_L5EM_GEALRDFIDL_1138 {
                EmployeeIDList = new Guid[] { Parameter.ForPerson }
            }, securityTicket).Result.FirstOrDefault();
            var contract = employeeAndLrData.WorkingContract2LeaveRequest.FirstOrDefault(c => c.CMN_BPT_STA_AbsenceReasonID == Parameter.AbsenceTypeID);
            if (contract == null)
            {
                var reason = cls_get_Active_AbsenceReason_For_TenantID.Invoke(Connection, Transaction, securityTicket).Result.FirstOrDefault(r => r.CMN_BPT_STA_AbsenceReasonID == Parameter.AbsenceTypeID);
                if (reason.IsAllowedAbsence)//WTF?
                {
                    returnValue.Result = new L6LR_VNL_M_1429 {
                        isInvalidAbsenceReason = true
                    };
                    return(returnValue);
                }
                else
                {
                    if (forbiddingEvents.Count() > 0)
                    {
                        returnValue.Result = new L6LR_VNL_M_1429 {
                            isIntersectingWithForbiddenEvent = true
                        };
                        returnValue.Result.errorDaysInfo = new List <DateTime>();
                        returnValue.Result.errorDaysInfo.Add(forbiddingEvents.ToArray()[0].repetitions[0].Start);
                        return(returnValue);
                    }
                    else
                    {
                        returnValue.Result = new L6LR_VNL_M_1429 {
                            isValidationPassed = true
                        };
                        return(returnValue);
                    }
                }
            }

            var statistisParam = new P_L6LR_GLRS_M_1706
            {
                AbsenceResonID     = Parameter.AbsenceTypeID,
                EndDate            = Parameter.EndDate,
                ForPerson          = Parameter.ForPerson,
                SavedLeaveDuration = 0,
                StartDate          = Parameter.StartDate
            };
            var statistics = cls_Get_Leave_Statistics_Mobile.Invoke(Connection, Transaction, statistisParam, securityTicket).Result;
            if (statistics.PlannedAndTaken + statistics.ThisRequest > contract.ContractAllowedAbsence_per_Month + statistics.FromLastyear + statistics.adjustment && contract.IsAllowedAbsence)
            {
                returnValue.Result = new L6LR_VNL_M_1429 {
                    isMoreDaysThanAllowed = true
                };
                return(returnValue);
            }
            else if (forbiddingEvents.Count() > 0)
            {
                returnValue.Result = new L6LR_VNL_M_1429 {
                    isIntersectingWithForbiddenEvent = true
                };
                return(returnValue);
            }
            else
            {
                var p = new P_L5LR_GLRTFEAT_1634();
                p.EndTime    = Parameter.EndDate;
                p.StartTime  = Parameter.StartDate;
                p.EmployeeID = Parameter.ForPerson;
                var res = cls_Get_LeaveRequestsTimes_For_EmployeeAndTime.Invoke(Connection, Transaction, p, securityTicket).Result;

                if (res != null)
                {
                    returnValue.Result = new L6LR_VNL_M_1429 {
                        isIntersectingWithLeaveRequest = true
                    };
                    returnValue.Result.errorDaysInfo = new List <DateTime>();
                    returnValue.Result.errorDaysInfo.Add(res.StartTime);
                    returnValue.Result.errorDaysInfo.Add(res.EndTime);
                    return(returnValue);
                }
            }

            returnValue.Result = new L6LR_VNL_M_1429 {
                isValidationPassed = true
            };
            return(returnValue);

            #endregion UserCode
        }