Ejemplo n.º 1
0
        /// <summary>
        /// Get the available incharge employee´s activities pending for approval
        /// </summary>
        /// <param name="employeeID">Approver Employee Identifier</param>
        /// <param name="projectID">Activities target project</param>
        /// <returns>List if the activities to be approved,</returns>
        public List <T> GetActivitiesToApprove <T>(int employeeID, string projectID)
            where T : SOFTTEK.SCMS.Entity.SRA.Activity, new()
        {
            List <T> activitiesToApprove = new List <T>();

            return(context.Execute(() =>
            {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser = System.Configuration.ConfigurationManager.AppSettings["S_APP_UID"];
                    dataSource.Initialize();

                    var results = dataSource.GetActivitiesToApprove(employeeID, projectID);

                    results.ForEach(a => activitiesToApprove.Add(new T
                    {
                        ActivityCode = a.ActivityCode,
                        ApprovedAt = a.ApprovedAt,
                        ApprovedBy = a.ApprovedBy,
                        ApprovedComments = a.ApprovedComments,
                        Details = a.Details,
                        Effort = a.Effort,
                        Employee = a.Employee,
                        ExecutedAt = a.ExecutedAt,
                        Identifier = a.Identifier,
                        Jornade = a.Jornade,
                        Project = a.Project,
                        ReportedAt = a.ReportedAt,
                        State = a.State
                    }));
                }
                return activitiesToApprove;
            }, "Retrieve the incharge employee´s activities to approve"));
        }
Ejemplo n.º 2
0
        public SOFTTEK.SCMS.Entity.Security.Token Register(SOFTTEK.SCMS.Entity.Security.User user)
        {
            SOFTTEK.SCMS.Entity.Security.Token authorizationToken = null;

            return(context.Execute(() => {
                Entity.User decryptedUser = new Entity.User(user, SCMS.Foundation.Security.EncryptionStatus.EncryptionStatusDecrypted, symmetricCipherProvider);



                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SCMS";
                    dataSource.DefaultUser = new System.Configuration.AppSettingsReader().GetValue("S_APP_UID", typeof(string)).ToString();
                    dataSource.Initialize();

                    authorizationToken = dataSource.CreateUser(decryptedUser);
                }
                if (authorizationToken != null)
                {
                    Business.Entity.Token encryptedToken = new Entity.Token(authorizationToken, SCMS.Foundation.Security.EncryptionStatus.EncryptionStatusEncrypted, symmetricCipherProvider);
                    return encryptedToken;
                }
                return null;
            }, "Register an user for the provided user credentials, and retrieve the default authorization profile."));
        }
Ejemplo n.º 3
0
 public SOFTTEK.SCMS.Entity.Shared.Employee GetEmployeeInfoForToken()
 {
     SOFTTEK.SCMS.Entity.Shared.Employee employee = null;
     return(context.Execute(() =>
     {
         using (dataSource = new SRADataContext(context.SecurityContext))
         {
             dataSource.ConnectionString = "SRA";
             dataSource.DefaultUser = new System.Configuration.AppSettingsReader().GetValue("S_APP_UID", typeof(string)).ToString();
             dataSource.Initialize();
             employee = dataSource.GetEmployeeWithToken();
         }
         return employee;
     }, "Retrieve the employee information for the user related to the provided token."));
 }
Ejemplo n.º 4
0
        public List <SOFTTEK.SCMS.Entity.SRA.Mobile.HomeItem> GetMenuItems()
        {
            List <SOFTTEK.SCMS.Entity.SRA.Mobile.HomeItem> menuItems = new List <SOFTTEK.SCMS.Entity.SRA.Mobile.HomeItem>();

            return(context.Execute(() => {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser = new System.Configuration.AppSettingsReader().GetValue("S_APP_UID", typeof(string)).ToString();
                    dataSource.Initialize();

                    menuItems = dataSource.GetMobileHomeItems <SOFTTEK.SCMS.Entity.SRA.Mobile.HomeItem>();
                }
                return menuItems;
            }, "Retrieve menu items for the provided APP Identifier."));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Approve a non approved registede activity.
        /// </summary>
        /// <param name="activityID">Activity Identifier</param>
        /// <returns></returns>
        public T ApproveActivity <T>(long activityID, SOFTTEK.SCMS.Entity.Shared.Employee approver, string comments)
            where T : SOFTTEK.SCMS.Entity.SRA.Activity, new()
        {
            T changedActivity =
                context.Execute(() =>
            {
                T targetActivity = new T();
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser      = System.Configuration.ConfigurationManager.AppSettings["S_APP_UID"];
                    dataSource.Initialize();

                    var result = dataSource.GetActivityByID(activityID);

                    targetActivity = new T
                    {
                        ActivityCode     = result.ActivityCode,
                        ApprovedAt       = result.ApprovedAt,
                        ApprovedBy       = result.ApprovedBy,
                        ApprovedComments = result.ApprovedComments,
                        Details          = result.Details,
                        Effort           = result.Effort,
                        Employee         = result.Employee,
                        ExecutedAt       = result.ExecutedAt,
                        Identifier       = result.Identifier,
                        Jornade          = result.Jornade,
                        Project          = result.Project,
                        ReportedAt       = result.ReportedAt,
                        State            = result.State
                    };
                }
                return(targetActivity);
            }, "Retrieve information for an activity to be updated");

            ValidateModifiableActivityState(changedActivity);
            ValidateApproval(changedActivity, approver);

            changedActivity.State            = APPROVED_ACTIVITY_STATE;
            changedActivity.ApprovedAt       = DateTime.Now;
            changedActivity.ApprovedComments = comments;

            changedActivity = UpdateActivity <T>(changedActivity);

            return(changedActivity);
        }
Ejemplo n.º 6
0
        public List <SOFTTEK.SCMS.Entity.Shared.Parameter <string> > GetParametersForCategory(string category)
        {
            List <SOFTTEK.SCMS.Entity.Shared.Parameter <string> > parameters = new List <SOFTTEK.SCMS.Entity.Shared.Parameter <string> >();

            return(context.Execute(() =>
            {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser = new System.Configuration.AppSettingsReader().GetValue("S_APP_UID", typeof(string)).ToString();
                    dataSource.Initialize();

                    parameters = dataSource.GetParametersForCategory <string>(category);
                }
                return parameters;
            }, "Get parameters for the provided category identifier."));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Register an activity for approval.
        /// </summary>
        /// <param name="permitsAndAbsences">permitsAndAbsences Insert Model information Permits and Absences</param>
        /// <returns>Registered activity information.</returns>
        public List <SOFTTEK.SCMS.Entity.SRA.PermitsAndAbsences> RegisterPermitsAnsAbsences(SOFTTEK.SCMS.Entity.SRA.PermitsAndAbsences permitsAndAbsences)
        {
            List <SOFTTEK.SCMS.Entity.SRA.PermitsAndAbsences> activities = new List <SOFTTEK.SCMS.Entity.SRA.PermitsAndAbsences>();

            ValidatePermitsAndAAbsences(permitsAndAbsences);

            return(context.Execute(() =>
            {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser = System.Configuration.ConfigurationManager.AppSettings["S_APP_UID"];
                    dataSource.Initialize();
                    var result = dataSource.RegisterPermitsAndAbsences(permitsAndAbsences);
                    activities = result;
                }
                return activities;
            }, "Register an Permits and absences for aprov"));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Get all the activities reported by an employee in a period.
        /// </summary>
        /// <param name="employeeId">Employee Identifier</param>
        /// <returns></returns>
        public List <SOFTTEK.SCMS.Entity.SRA.PermitsAndAbsences> GetPermitsAndAbsencesForEmployeeId(int employeeId)
        {
            List <SOFTTEK.SCMS.Entity.SRA.PermitsAndAbsences> activities = new List <SOFTTEK.SCMS.Entity.SRA.PermitsAndAbsences>();

            return(context.Execute(() =>
            {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser = System.Configuration.ConfigurationManager.AppSettings["S_APP_UID"];
                    dataSource.Initialize();

                    var results = dataSource.GetPermitsAndAbsences(employeeId);
                    activities = results;
                }

                return activities;
            }, "Retrieve the registered activities for the employee corresponding to the provided employee identifier."));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Register an activity for approval.
        /// </summary>
        /// <param name="activity">Activity information</param>
        /// <returns>Registered activity information.</returns>
        public T RegisterActivity <T>(SOFTTEK.SCMS.Entity.SRA.Activity activity)
            where T : SOFTTEK.SCMS.Entity.SRA.Activity, new()
        {
            T registeredActivity = new T();

            ValidateReportedActivityEffort(activity);
            ValidateReportedActivityInformation(activity);

            return(context.Execute(() =>
            {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser = System.Configuration.ConfigurationManager.AppSettings["S_APP_UID"];
                    dataSource.Initialize();

                    var result = dataSource.RegisterActivity(activity);

                    registeredActivity = new T
                    {
                        ActivityCode = result.ActivityCode,
                        ApprovedAt = result.ApprovedAt,
                        ApprovedBy = result.ApprovedBy,
                        ApprovedComments = result.ApprovedComments,
                        Details = result.Details,
                        Effort = result.Effort,
                        Employee = result.Employee,
                        ExecutedAt = result.ExecutedAt,
                        Identifier = result.Identifier,
                        Jornade = result.Jornade,
                        Project = result.Project,
                        ReportedAt = result.ReportedAt,
                        State = result.State
                    };
                }
                return registeredActivity;
            }, "Register an activity for approval"));
        }
Ejemplo n.º 10
0
        public SOFTTEK.SCMS.Entity.Security.Token GetToken()
        {
            SOFTTEK.SCMS.Entity.Security.Token authorizationToken = null;
            return(context.Execute(() =>
            {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SCMS";
                    dataSource.DefaultUser = new System.Configuration.AppSettingsReader().GetValue("S_APP_UID", typeof(string)).ToString();
                    dataSource.Initialize();

                    authorizationToken = dataSource.GetToken();
                }

                if (authorizationToken != null)
                {
                    Business.Entity.Token encryptedToken = new Entity.Token(authorizationToken, SCMS.Foundation.Security.EncryptionStatus.EncryptionStatusEncrypted, symmetricCipherProvider);
                    return encryptedToken;
                }

                return null;
            }, "Retrieve the authorization token information for the provided token identifier and device identifier."));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Get all the activities reported by an employee in a period.
        /// </summary>
        /// <param name="employeeId">Employee Identifier</param>
        /// <param name="from">Period start date</param>
        /// <param name="to">Period end date</param>
        /// <returns></returns>
        public List <T> GetActivitiesForEmployeeIdInPeriod <T>(int employeeId, DateTime from, DateTime to)
            where T : SOFTTEK.SCMS.Entity.SRA.Activity, new()
        {
            List <T> activities = new List <T>();

            return(context.Execute(() =>
            {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser = System.Configuration.ConfigurationManager.AppSettings["S_APP_UID"];
                    dataSource.Initialize();

                    var results = dataSource.GetActivities(employeeId, from, to);

                    results.ForEach(a => activities.Add(new T
                    {
                        ActivityCode = a.ActivityCode,
                        ApprovedAt = a.ApprovedAt,
                        ApprovedBy = a.ApprovedBy,
                        ApprovedComments = a.ApprovedComments,
                        Details = a.Details,
                        Effort = a.Effort,
                        Employee = a.Employee,
                        ExecutedAt = a.ExecutedAt,
                        Identifier = a.Identifier,
                        Jornade = a.Jornade,
                        Project = a.Project,
                        ReportedAt = a.ReportedAt,
                        State = a.State
                    }));
                }

                return activities;
            }, "Retrieve the registered activities for the employee corresponding to the provided employee identifier."));
        }
Ejemplo n.º 12
0
        public bool SetEmployeeImage(string ftpURL, int employeeID)
        {
            bool result = false;

            return(context.Execute(() =>
            {
                using (dataSource = new SRADataContext(context.SecurityContext))
                {
                    dataSource.ConnectionString = "SRA";
                    dataSource.DefaultUser = new System.Configuration.AppSettingsReader().GetValue("S_APP_UID", typeof(string)).ToString();

                    dataSource.Initialize();
                    SOFTTEK.SCMS.Entity.Shared.Employee employee = dataSource.GetEmployeeById(employeeID);
                    if (employee != null)
                    {
                        employee.ImageURL = ftpURL;
                        result = dataSource.UpdateEmployee(employee);
                    }
                    ;

                    return result;
                }
            }, "Upload to the images repository, the provided binary image file."));
        }