Exemplo n.º 1
0
        /// <summary>
        /// Get all user with admin right
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="sessionTicket"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public List <Employee_Model> GetUsers(string connectionString, string sessionTicket, out TransactionalInformation transaction)
        {
            var method = MethodInfo.GetCurrentMethod();
            var ipInfo = Util.GetIPInfo(HttpContext.Current.Request);

            List <Employee_Model> usersM = new List <Employee_Model>();

            transaction = new TransactionalInformation();
            var userSecurityTicket = VerifySessionToken(sessionTicket);

            try
            {
                var users = cls_Get_Employees.Invoke(connectionString, userSecurityTicket).Result.Where(st => st.employee_rights == "mm.docconect.mm.app.master").OrderBy(nm => nm.employee_name);
                foreach (var user in users)
                {
                    Employee_Model userM = new Employee_Model();
                    userM.id   = user.employee_id;
                    userM.name = user.employee_name;
                    usersM.Add(userM);
                }
            }
            catch (Exception ex)
            {
                Logger.LogInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, userSecurityTicket, ex));

                transaction.ReturnMessage = new List <string>();
                string errorMessage = ex.Message;
                transaction.ReturnStatus = false;
                transaction.ReturnMessage.Add(errorMessage);
                transaction.IsAuthenicated = true;
                transaction.IsException    = true;
            }

            return(usersM);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get all users/Employees for user list
        /// </summary>
        /// <param name="sort_parameter"></param>
        /// <param name="connectionString"></param>
        /// <param name="sessionTicket"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public Employee_Model[] GetEmployees(ElasticParameterObject sort_parameter, string connectionString, string sessionTicket, out TransactionalInformation transaction)
        {
            var method = MethodInfo.GetCurrentMethod();
            var ipInfo = Util.GetIPInfo(HttpContext.Current.Request);

            transaction = new TransactionalInformation();
            var userSecurityTicket = VerifySessionToken(sessionTicket);

            try
            {
                var employees = cls_Get_Employees.Invoke(connectionString, userSecurityTicket).Result;
                if (employees.Length != 0)
                {
                    var response = employees.Select(emp =>
                    {
                        var email_contact = emp.Contact == null ? null : emp.Contact.Where(c => c.Type == "Email").SingleOrDefault();
                        var phone_contact = emp.Contact == null ? null : emp.Contact.Where(c => c.Type == "Phone").SingleOrDefault();

                        Employee_Model employee = new Employee_Model()
                        {
                            id         = emp.employee_id,
                            name       = emp.employee_name,
                            email      = email_contact == null ? "" : email_contact.Content,
                            phone      = phone_contact == null ? "" : phone_contact.Content,
                            is_admin   = emp.employee_rights == "mm.docconect.mm.app.master",
                            group_name = String.IsNullOrEmpty(emp.employee_name) ? "" : emp.employee_name.Substring(0, 1).ToUpper()
                        };

                        return(employee);
                    }).ToArray();

                    if (!sort_parameter.isAsc)
                    {
                        response = response.Reverse().ToArray();
                    }

                    return(response);
                }
            }
            catch (Exception ex)
            {
                Logger.LogInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, userSecurityTicket, ex));

                transaction.ReturnMessage = new List <string>();
                string errorMessage = ex.Message;
                transaction.ReturnStatus = false;
                transaction.ReturnMessage.Add(errorMessage);
                transaction.IsAuthenicated = true;
                transaction.IsException    = true;
            }

            return(new Employee_Model[] { });
        }
Exemplo n.º 3
0
 public static double CalculateSalary(Employee_Model employee)
 {
     if (employee.contractTypeName == "MonthlySalaryEmployee")
     {
         var employeeSalary = new Employee().ExecuteCreation(Enum_ContractTypes.MonthlySalary, employee.monthlySalary);
         return(employeeSalary.Salary());
     }
     else
     {
         var employeeSalary = new Employee().ExecuteCreation(Enum_ContractTypes.HourlySalary, employee.hourlySalary);
         return(employeeSalary.Salary());
     }
 }