Ejemplo n.º 1
0
        public async Task <JsonResult> ListArchiveWithFilter([FromQuery] string User)
        {
            var loggedUser = HttpContext.User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            var workloads = new List <string>();

            string filtered_user = (User == null || User == "") ? loggedUser : User;

            var existentWorkloads = await Util.ConnectToRemoteService <List <WorkloadsByUserViewModel> >(HttpMethod.Get, Util.KanbanURL + "api/workload/listarchivewithfilter?uniqueName=" + filtered_user, filtered_user, "");

            UsageTelemetry.Track(filtered_user, ArdaUsage.Archive_User);

            var dados = existentWorkloads.Where(x => x._WorkloadIsWorkload == true)
                        .Select(x => new {
                id          = x._WorkloadID,
                title       = x._WorkloadTitle,
                start       = x._WorkloadStartDate.ToString("dd/MM/yyyy"),
                end         = x._WorkloadEndDate.ToString("dd/MM/yyyy"),
                hours       = x._WorkloadHours,
                attachments = x._WorkloadAttachments,
                tag         = x._WorkloadExpertise,
                status      = x._WorkloadStatus,
                users       = x._WorkloadUsers,
                textual     = x._WorkloadTitle + " (Started in " + x._WorkloadStartDate.ToString("dd/MM/yyyy") + " and Ending in " + x._WorkloadEndDate.ToString("dd/MM/yyyy") + ", with  " + x._WorkloadHours + " hours spent on this."
            })
                        .Distinct()
                        .ToList();

            return(Json(dados));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Old()
        {
            var    user       = User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;
            var    userStatus = Util.ConnectToRemoteService <int>(HttpMethod.Get, Util.PermissionsURL + "api/useroperations/getuserstatus", user, string.Empty).Result;
            string token      = null;

            ViewBag.User       = user;
            ViewBag.UserStatus = userStatus;

            if (!Startup.IsSimpleAuthForDemo)
            {
                try
                {
                    Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult result = await TokenManager.GetAccessToken(HttpContext);

                    token         = result.AccessToken;
                    ViewBag.Token = token;

                    if (userStatus == 0)
                    {
                        StoreUserInfo(user, token);
                    }
                }
                catch (Microsoft.IdentityModel.Clients.ActiveDirectory.AdalSilentTokenAcquisitionException)
                {
                    return(Redirect("/Account/SignIn"));
                }
            }

            UsageTelemetry.Track(user, ArdaUsage.Dashboard_Index);

            return(View());
        }
Ejemplo n.º 3
0
        public IActionResult Index()
        {
            var user = User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            UsageTelemetry.Track(user, ArdaUsage.Archive_Index);

            return(View());
        }
Ejemplo n.º 4
0
        public IActionResult TimeConsuming()
        {
            var uniqueName = HttpContext.User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            UsageTelemetry.Track(uniqueName, ArdaUsage.Report_Show);

            return(View());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Submit([FromForm] string workloadTitle, [FromForm] string workloadDate, [FromForm] string workloadDescription)
        {
            var user = this.GetCurrentUser();

            UsageTelemetry.Track(user, ArdaUsage.Userform_Submit);

            await CreateWorkload(workloadTitle, DateTime.Parse(workloadDate), workloadDescription);

            return(RedirectToAction("Index", "Dashboard"));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Index()
        {
            var user = User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            ViewBag.User       = user;
            ViewBag.UserStatus = 2;

            UsageTelemetry.Track(user, ArdaUsage.Dashboard_Index);

            return(View());
        }
Ejemplo n.º 7
0
        public IActionResult Workspace(string workspace)
        {
            var user = User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            ViewBag.User  = user;
            ViewBag.Title = workspace.ToUpper();
            ViewBag.Work  = workspace.ToLower();

            UsageTelemetry.Track(user, ArdaUsage.Work_Index);

            return(View());
        }
Ejemplo n.º 8
0
        public async Task <WorkloadViewModel> AddSimpleV3([FromBody] WorkloadSimpleViewModel work)
        {
            if (work == null)
            {
                throw new ArgumentOutOfRangeException(nameof(work));
            }

            if (work.Title == null || work.Title == "")
            {
                throw new ArgumentOutOfRangeException(nameof(work.Title));
            }

            var uniqueName = this.GetCurrentUser();
            var now        = DateTime.Now;
            var today      = new DateTime(now.Year, now.Month, now.Day);

            WorkloadViewModel workload = new WorkloadViewModel2()
            {
                WBID = (work.Id == Guid.Empty) ? Guid.NewGuid() : work.Id,

                WBTitle       = work.Title,
                WBDescription = work.Description,
                WBStatus      = (work.Status.HasValue) ? work.Status.Value : 0,

                WBCreatedBy   = uniqueName,
                WBCreatedDate = DateTime.Now,

                WBStartDate = today,
                WBEndDate   = today,
                WBUsers     = new string[] { uniqueName },

                WBIsWorkload = true,

                WBActivity     = Guid.Empty,
                WBComplexity   = 0,
                WBExpertise    = 0,
                WBFilesList    = null,
                WBMetrics      = null,
                WBTechnologies = null
            };

            var response = await Util.ConnectToRemoteService(HttpMethod.Post, Util.KanbanURL + "api/workload/add", uniqueName, "", workload);

            UsageTelemetry.Track(uniqueName, ArdaUsage.Workload_Add);

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception($"ConnectToRemote(Kanban/api/workload/add) failed with HTTP ${response.StatusCode}");
            }

            return(workload);
        }
Ejemplo n.º 9
0
        public async Task <WorkloadViewModel> AddSimple(ICollection <IFormFile> WBFiles, WorkloadViewModel2 workload)
        {
            //Owner:
            var uniqueName = HttpContext.User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            workload.WBActivity   = Guid.Empty;
            workload.WBComplexity = 0;
            workload.WBExpertise  = 0;

            //Complete WB fields:
            workload.WBCreatedBy   = uniqueName;
            workload.WBCreatedDate = DateTime.Now;

            var now   = DateTime.Now;
            var today = new DateTime(now.Year, now.Month, now.Day);

            workload.WBStartDate = today;
            workload.WBEndDate   = today;

            // Myself
            workload.WBUsers = new string[] { uniqueName };

            // Sometimes /Workload/Guid fails or takes a long time to return
            if (workload.WBID == Guid.Empty)
            {
                workload.WBID = Guid.NewGuid();
            }

            var response = await Util.ConnectToRemoteService(HttpMethod.Post, Util.KanbanURL + "api/workload/add", uniqueName, "", workload);

            await Assign(workload.WBID, workload.Tag, uniqueName);

            UsageTelemetry.Track(uniqueName, ArdaUsage.Workload_Add);

            if (!response.IsSuccessStatusCode)
            {
                throw new Exception($"ConnectToRemote(Kanban/api/workload/add) failed with HTTP ${response.StatusCode}");
            }

            return(workload);
        }
Ejemplo n.º 10
0
        public async Task <HttpResponseMessage> AddAppointment(AppointmentViewModel appointment)
        {
            if (appointment == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            // Converting the T&E value to Decimal before save process
            decimal TE = 0;

            Decimal.TryParse(Request.Form["_AppointmentTE"], NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint, new CultureInfo("pt-BR"), out TE);
            appointment._AppointmentTE = TE;

            //DateTime date;
            //if(DateTime.TryParse(Request.Form["_AppointmentDate"], new CultureInfo("pt-BR"), DateTimeStyles.AllowWhiteSpaces, out date))
            //{
            //    appointment._AppointmentDate = date;
            //}

            if (appointment._AppointmentDate == DateTime.MinValue)
            {
                // there can be some problems due to date formatting
                throw new Exception("invalid date range");
            }

            var uniqueName = HttpContext.User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            var responseAboutAdd = await Util.ConnectToRemoteService(HttpMethod.Post, Util.KanbanURL + "api/appointment/add", uniqueName, "", appointment);

            UsageTelemetry.Track(uniqueName, ArdaUsage.Appointment_Add);

            if (responseAboutAdd.IsSuccessStatusCode)
            {
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            else
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Ejemplo n.º 11
0
        public IActionResult New(string template)
        {
            var user = this.GetCurrentUser();

            ViewBag.Title = "Title";

            switch (template.ToLower())
            {
            case "event":
                ViewBag.Title      = "Event Name";
                ViewBag.ReportName = "_sampleEventReport";
                break;

            case "customer":
                ViewBag.Title      = "Report Title";
                ViewBag.ReportName = "_sampleCustomerReport";
                break;
            }

            UsageTelemetry.Track(user, ArdaUsage.Userform_Index);

            return(View());
        }
Ejemplo n.º 12
0
        public async Task <HttpResponseMessage> Add(ICollection <IFormFile> WBFiles, WorkloadViewModel2 workload)
        {
            //Owner:
            var uniqueName = HttpContext.User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            //Complete WB fields:
            workload.WBCreatedBy   = uniqueName;
            workload.WBCreatedDate = DateTime.Now;
            //Iterate over files:
            if (WBFiles.Count > 0)
            {
                List <Tuple <Guid, string, string> > fileList = await UploadNewFiles(WBFiles);

                //Adds the file lists to the workload object:
                workload.WBFilesList = fileList;
            }

            // Sometimes /Workload/Guid fails or takes a long time to return
            if (workload.WBID == Guid.Empty)
            {
                workload.WBID = Guid.NewGuid();
            }

            var response = await Util.ConnectToRemoteService(HttpMethod.Post, Util.KanbanURL + "api/workload/add", uniqueName, "", workload);

            UsageTelemetry.Track(uniqueName, ArdaUsage.Workload_Add);

            if (!response.IsSuccessStatusCode)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            await Assign(workload.WBID, workload.Tag, uniqueName);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }