Esempio n. 1
0
        public virtual ActionResult Update()
        {
            var tasks = this.DeserializeObject <IEnumerable <Models.TaskViewModel> >("models").FirstOrDefault();

            if (tasks != null)
            {
                int result = 0; bool status = false;
                try
                {
                    ValidationMapper <Models.TaskViewModel, Scheduler> mapperObj = new ValidationMapper <Models.TaskViewModel, Scheduler>();
                    var dalObj = new DALRepository();
                    result = dalObj.UpdateSchedularEvent(mapperObj.Translate(tasks));
                    if (result == 1)
                    {
                        return(this.Jsonp(tasks));
                    }
                    else
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Error Occured');</script>"));
                    }
                }
                catch
                {
                    return(Json(new { success = status }));
                }
            }

            return(this.Jsonp(tasks));
        }
Esempio n. 2
0
        public JsonResult RegisterAdmin(Models.Admin admin)
        {
            int status;

            admin.UserName = admin.FullName;
            if (ModelState.IsValid)
            {
                ValidationMapper <Models.Admin, Admin> mapperObj = new ValidationMapper <Models.Admin, Admin>();
                var dalObj = new DALRepository();

                status = dalObj.RegisterAdmin(mapperObj.Translate(admin));
                if (status == 1)
                {
                    Session["userName"] = admin.UserName;
                    Session["Role"]     = "Admin";
                    status = 1;
                }
                else
                {
                    status = 0;
                }
            }
            else
            {
                status = -1;
            }
            return(Json(status, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        //testcase pipeline stages report for Google charts
        public JsonResult PipelineStageTestcaseDetails()
        {
            ValidationMapper <TestCase, Models.TestCase>           mapperObj = new ValidationMapper <TestCase, Models.TestCase>();
            ValidationMapper <PipelineStage, Models.PipeLineStage> mapperObjForPipelineStage = new ValidationMapper <PipelineStage, Models.PipeLineStage>();

            var dalObj           = new DALRepository();
            var TestCaseListList = dalObj.GetTestCaseDetails();
            var PipelineList     = dalObj.GetPipeLineStage();

            var testcaseTableRows = new List <Models.TestCase>();

            if (TestCaseListList.Any())
            {
                foreach (var ts in TestCaseListList)
                {
                    testcaseTableRows.Add(mapperObj.Translate(ts));
                }
            }
            List <Models.TwoArgumentStringInt> dataPoint = new List <Models.TwoArgumentStringInt>();

            foreach (var onepipe in PipelineList)
            {
                var count = 0;
                foreach (var onetest in TestCaseListList)
                {
                    if (onepipe.PipelineStageId == onetest.PipelineStageId)
                    {
                        count += 1;
                    }
                }
                dataPoint.Add(new Models.TwoArgumentStringInt(onepipe.PipelineStage1, count));
            }
            return(Json(dataPoint, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public Object RegretClicked(int annID, int userID)
        {
            DALRepository        mydal = new DALRepository();
            JavaScriptSerializer js    = new JavaScriptSerializer();
            var k = js.Serialize(mydal.RegretClicked(annID, userID));

            return(k);
        }
Esempio n. 5
0
        public ActionResult GetTestCaseById(int id)
        {
            ValidationMapper <TestCase, Models.TestCase> mapperObj = new ValidationMapper <TestCase, Models.TestCase>();
            var dalObj   = new DALRepository();
            var tstCase  = dalObj.GetTestCasesById(id);
            var tstCasem = new Models.TestCase();

            if (tstCase != null)
            {
                tstCasem = mapperObj.Translate(tstCase);
                return(Json(tstCasem, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Esempio n. 6
0
        public ActionResult GetPipelineStageById(int id)
        {
            ValidationMapper <PipelineStage, Models.PipeLineStage> mapperObj = new ValidationMapper <PipelineStage, Models.PipeLineStage>();
            var dalObj    = new DALRepository();
            var pipelist  = dalObj.GetPipelineById(id);
            var mpipelist = new List <Models.PipeLineStage>();

            if (pipelist != null)
            {
                mpipelist.Add(mapperObj.Translate(pipelist));
                return(Json(mpipelist, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Esempio n. 7
0
        public ActionResult GetTestSuiteById(int id)
        {
            ValidationMapper <TestSuite, Models.TestSuites> mapperObj = new ValidationMapper <TestSuite, Models.TestSuites>();
            var dalObj    = new DALRepository();
            var tstSuite  = dalObj.GetTestSuiteById(id);
            var testSuite = new Models.TestSuites();

            if (tstSuite != null)
            {
                testSuite = mapperObj.Translate(tstSuite);
                return(Json(testSuite, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Esempio n. 8
0
        //used in googlecharts dashboard
        public ActionResult GetTestCasesForToday()
        {
            int today = DateTime.Today.Day;
            ValidationMapper <TestCaseLog, Models.TestCaseLog> mapperObj = new ValidationMapper <TestCaseLog, Models.TestCaseLog>();
            var dalObj = new DALRepository();
            var TestCaselogList_today = dalObj.GetTestCaseLogentries_Today();

            List <Models.TwoArgumentDataPoint> dataPointsForSkipped = new List <Models.TwoArgumentDataPoint>();
            List <Models.TwoArgumentDataPoint> dataPointsForPassed  = new List <Models.TwoArgumentDataPoint>();
            List <Models.TwoArgumentDataPoint> dataPointsForFailed  = new List <Models.TwoArgumentDataPoint>();

            int Skippedcount = 0;
            int passedCount  = 0;
            int failedCount  = 0;

            try
            {
                if (TestCaselogList_today.Any())
                {
                    foreach (var item in TestCaselogList_today)
                    {
                        if (item.ResultType == 1)
                        {
                            passedCount += 1;
                        }
                        if (item.ResultType == 2)
                        {
                            failedCount += 1;
                        }
                        if (item.ResultType == 3)
                        {
                            Skippedcount += 1;
                        }
                    }
                    dataPointsForSkipped.Add(new Models.TwoArgumentDataPoint(today, Skippedcount));
                    dataPointsForPassed.Add(new Models.TwoArgumentDataPoint(today, passedCount));
                    dataPointsForFailed.Add(new Models.TwoArgumentDataPoint(today, failedCount));
                }
            }
            catch
            {
                return(RedirectToAction("Error"));
            }
            ViewBag.DataPointsSkipped = JsonConvert.SerializeObject(dataPointsForSkipped);
            ViewBag.DataPointsPassed  = JsonConvert.SerializeObject(dataPointsForPassed);
            ViewBag.DataPointsFailed  = JsonConvert.SerializeObject(dataPointsForFailed);
            return(Json(new { dataPointsForSkipped, dataPointsForPassed, dataPointsForFailed }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 9
0
        public JsonResult LoginAdmin(Models.Admin user)
        {
            int status = 0;
            ValidationMapper <Models.Admin, Admin> mapperObj = new ValidationMapper <Models.Admin, Admin>();
            var dalObj = new DALRepository();

            var loginData = dalObj.GetAdminCredentials(mapperObj.Translate(user));

            if (loginData != null)
            {
                Session["userName"] = loginData.UserName;
                Session["Role"]     = "Admin";
                status = 1;
            }
            return(Json(status, JsonRequestBehavior.AllowGet));
        }
Esempio n. 10
0
        public JsonResult GetTestCaseDetails()
        {
            ValidationMapper <TestCase, Models.TestCase> mapperObj = new ValidationMapper <TestCase, Models.TestCase>();
            var dalObj       = new DALRepository();
            var testCaseList = dalObj.GetTestCases();
            var testCases    = new List <Models.TestCase>();

            if (testCaseList.Any())
            {
                foreach (var ts in testCaseList)
                {
                    testCases.Add(mapperObj.Translate(ts));
                }
                return(Json(testCases.ToList(), JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Esempio n. 11
0
        public JsonResult DeleteTestCase(Models.TestCase testCase)
        {
            int result = 0; bool status = false;

            try
            {
                var dalObj = new DALRepository();
                result = dalObj.DeleteTestcase(testCase.TestCaseId);
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 12
0
        public JsonResult GetCalendarEvents()
        {
            ValidationMapper <Scheduler, Models.TaskViewModel> mapperObj = new ValidationMapper <Scheduler, Models.TaskViewModel>();
            var dalObj        = new DALRepository();
            var testSuiteList = dalObj.GetSchedulerEvents();
            var testSuites    = new List <Models.TaskViewModel>();

            if (testSuiteList.Any())
            {
                foreach (var ts in testSuiteList)
                {
                    testSuites.Add(mapperObj.Translate(ts));
                }
                var data = testSuites.ToList();

                return(this.Jsonp(data));
            }
            return(null);
        }
Esempio n. 13
0
        public ActionResult SaveValueCheckParams(Models.TestCaseParameterValueCheck vc)
        {
            int result = 0; bool status = false;

            try
            {
                ValidationMapper <Models.TestCaseParameterValueCheck, TestCaseParameterValueCheck> mapperObj = new ValidationMapper <Models.TestCaseParameterValueCheck, TestCaseParameterValueCheck>();
                var dalObj = new DALRepository();
                result = dalObj.SaveValueCheckParams(mapperObj.Translate(vc));
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 14
0
        public ActionResult SaveFKParameters(Models.TestCaseParameterForeignKey ppk)
        {
            int result = 0; bool status = false;

            try
            {
                ValidationMapper <Models.TestCaseParameterForeignKey, TestCaseParameterForeignKey> mapperObj = new ValidationMapper <Models.TestCaseParameterForeignKey, TestCaseParameterForeignKey>();
                var dalObj = new DALRepository();
                result = dalObj.SaveFKParams(mapperObj.Translate(ppk));
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 15
0
        public JsonResult UpdateTestCase(Models.TestCase testcase)
        {
            int result = 0; bool status = false;

            try
            {
                ValidationMapper <Models.TestCase, TestCase> mapperObj = new ValidationMapper <Models.TestCase, TestCase>();
                var dalObj = new DALRepository();
                result = dalObj.UpdatedTestcase(mapperObj.Translate(testcase));
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 16
0
        public JsonResult DeletePipeline(Models.PipeLineStage pipeline)
        {
            int result = 0; bool status = false;

            try
            {
                ValidationMapper <PipelineStage, Models.PipeLineStage> mapperObj = new ValidationMapper <PipelineStage, Models.PipeLineStage>();
                var dalObj = new DALRepository();
                result = dalObj.DeletePipeline(pipeline.PipelineStageId);
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 17
0
        public JsonResult DeleteTestSuite(Models.TestSuites testSuite)
        {
            int result = 0; bool status = false;

            try
            {
                ValidationMapper <TestSuite, Models.TestSuites> mapperObj = new ValidationMapper <TestSuite, Models.TestSuites>();
                var dalObj = new DALRepository();
                result = dalObj.DeleteTestsuite(testSuite.TestSuiteId);
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 18
0
        public JsonResult kendoGettestcases()
        {
            ValidationMapper <TestCase, Models.TestCase> mapperObj = new ValidationMapper <TestCase, Models.TestCase>();
            var dalObj        = new DALRepository();
            var testSuiteList = dalObj.Gettestsuitechilds();
            var records       = new List <Models.TestCase>();

            if (testSuiteList.Any())
            {
                foreach (var ts in testSuiteList)
                {
                    records.Add(mapperObj.Translate(ts));
                }
            }
            var data = records.ToList();

            var pageSize = data.Count();

            return(Json(new { data, pageSize }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 19
0
        public JsonResult GetTestCaseTypeDetails()
        {
            ValidationMapper <TestCaseType, Models.TestCaseType> mapperObj = new ValidationMapper <TestCaseType, Models.TestCaseType>();
            var dalObj  = new DALRepository();
            var lst     = dalObj.GetTestCaseTypes();
            var typelst = new List <Models.TestCaseType>();

            if (lst.Any())
            {
                foreach (var ts in lst)
                {
                    typelst.Add(mapperObj.Translate(ts));
                }
                var data = typelst.ToList();
                ViewBag.testCasetypelist = data;
                var pageSize = data.Count();
                return(Json(new { data, pageSize }, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Esempio n. 20
0
        public JsonResult DeleteCalendarEvent(Models.Event eve)
        {
            int result = 0; bool status = false;

            try
            {
                ValidationMapper <Models.Event, Event> mapperObj = new ValidationMapper <Models.Event, Event>();
                var dalObj = new DALRepository();
                result = dalObj.DeleteEvent(eve.TaskID);
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 21
0
        public JsonResult GetPipeLinestageDetails()
        {
            ValidationMapper <PipelineStage, Models.PipeLineStage> mapperObj = new ValidationMapper <PipelineStage, Models.PipeLineStage>();
            var dalObj            = new DALRepository();
            var pipelineStageList = dalObj.GetPipeLineStage();
            var stages            = new List <Models.PipeLineStage>();

            if (pipelineStageList.Any())
            {
                foreach (var ts in pipelineStageList)
                {
                    stages.Add(mapperObj.Translate(ts));
                }
                var data = stages.ToList();
                ViewBag.pipelinelist = data;
                var pageSize = data.Count();
                return(Json(new { data, pageSize }, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Esempio n. 22
0
        public JsonResult UpdateCalendarEvent(Models.Event data)
        {
            int result = 0; bool status = false;

            try
            {
                ValidationMapper <Models.Event, Event> mapperObj = new ValidationMapper <Models.Event, Event>();
                var dalObj = new DALRepository();
                result = dalObj.SaveEvent(mapperObj.Translate(data));
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 23
0
        public JsonResult jqueryGettestsuites(int?page, int?limit, string sortBy, string direction, Models.TestSuites testsuit)
        {
            ValidationMapper <TestSuite, Models.TestSuites> mapperObj = new ValidationMapper <TestSuite, Models.TestSuites>();
            var dalObj        = new DALRepository();
            var testSuiteList = dalObj.GetTestSuites();
            var query         = testSuiteList.Select(p => new Models.TestSuites
            {
                TestSuiteId          = p.TestSuiteId,
                TestSuite1           = p.TestSuite1,
                TestSuiteDescription = p.TestSuiteDescription,
                TestSuiteOwner       = p.TestSuiteOwner,
                CreatedBy            = p.CreatedBy,
                CreatedDate          = p.CreatedDate,
                IsActive             = p.IsActive,
            });

            if (!string.IsNullOrWhiteSpace(testsuit.TestSuite1))
            {
                query = query.Where(q => q.TestSuite1.Contains(testsuit.TestSuite1));
            }

            if (testsuit.IsActive)
            {
                query = query.Where(q => q.IsActive.Equals(testsuit.IsActive));
            }
            if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
            {
                if (direction.Trim().ToLower() == "asc")
                {
                    switch (sortBy.Trim().ToLower())
                    {
                    case "testsuite1":
                        query = query.OrderBy(q => q.TestSuite1);
                        break;

                    case "createddate":
                        query = query.OrderBy(q => q.CreatedDate);
                        break;

                    case "testsuiteid":
                        query = query.OrderBy(q => q.TestSuiteId);
                        break;
                    }
                }
                else
                {
                    switch (sortBy.Trim().ToLower())
                    {
                    case "testsuite1":
                        query = query.OrderByDescending(q => q.TestSuite1);
                        break;

                    case "createddate":
                        query = query.OrderByDescending(q => q.CreatedDate);
                        break;

                    case "testsuiteid":
                        query = query.OrderByDescending(q => q.TestSuiteId);
                        break;
                    }
                }
            }
            else
            {
                query = query.OrderBy(q => q.TestSuiteId);
            }
            var records = new List <Models.TestSuites>();
            var total   = records.Count();

            total = query.Count();
            if (page.HasValue && limit.HasValue)
            {
                int start = (page.Value - 1) * limit.Value;
                records = query.Skip(start).Take(limit.Value).ToList();
            }
            else
            {
                records = query.ToList();
            }
            return(this.Json(new { records, total }, JsonRequestBehavior.AllowGet));
            //if (testSuiteList.Any())
            //{
            //    foreach (var ts in testSuiteList)
            //    {
            //        records.Add(mapperObj.Translate(ts));
            //    }
            //}
            //return this.Json(new { records, total }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 24
0
        public JsonResult jqueryGettestcases(int Id, int?page, int?limit, string sortBy, string direction, Models.TestCase testcas)
        {
            ValidationMapper <TestCase, Models.TestCase> mapperObj = new ValidationMapper <TestCase, Models.TestCase>();
            var dalObj        = new DALRepository();
            var testSuiteList = dalObj.Gettestsuitechilds();
            var records       = new List <Models.TestCase>();
            var query         = testSuiteList.Select(p => new Models.TestCase
            {
                TestCaseId      = p.TestCaseId,
                TestCaseTypeId  = p.TestCaseTypeId,
                TestSuiteId     = p.TestSuiteId,
                TestCaseName    = p.TestCaseName,
                CreatedBy       = p.CreatedBy,
                CreatedDate     = p.CreatedDate,
                IsActive        = p.IsActive,
                PipelineStageId = p.PipelineStageId,
                Description     = p.Description,
                IsObsolete      = p.IsObsolete,
                ObsoleteReason  = p.ObsoleteReason
            });

            if (Id != 0)
            {
                query = query.Where(q => q.TestSuiteId == Id);
            }
            if (!string.IsNullOrWhiteSpace(testcas.TestCaseName))
            {
                query = query.Where(q => q.TestCaseName.Contains(testcas.TestCaseName));
            }

            if (testcas.IsActive)
            {
                query = query.Where(q => q.IsActive.Equals(testcas.IsActive));
            }
            if (testcas.IsObsolete)
            {
                query = query.Where(q => q.IsObsolete.Equals(testcas.IsObsolete));
            }
            if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
            {
                if (direction.Trim().ToLower() == "asc")
                {
                    switch (sortBy.Trim().ToLower())
                    {
                    case "testcasename":
                        query = query.OrderBy(q => q.TestCaseName);
                        break;

                    case "createddate":
                        query = query.OrderBy(q => q.CreatedDate);
                        break;

                    case "testsuiteid":
                        query = query.OrderBy(q => q.TestSuiteId);
                        break;

                    case "testcasetypeid":
                        query = query.OrderBy(q => q.TestCaseTypeId);
                        break;

                    case "pipelinestageid":
                        query = query.OrderBy(q => q.PipelineStageId);
                        break;

                    case "testcaseid":
                        query = query.OrderBy(q => q.TestCaseId);
                        break;
                    }
                }
                else
                {
                    switch (sortBy.Trim().ToLower())
                    {
                    case "testcasename":
                        query = query.OrderByDescending(q => q.TestCaseName);
                        break;

                    case "createddate":
                        query = query.OrderByDescending(q => q.CreatedDate);
                        break;

                    case "testsuiteid":
                        query = query.OrderByDescending(q => q.TestSuiteId);
                        break;

                    case "testcasetypeid":
                        query = query.OrderByDescending(q => q.TestCaseTypeId);
                        break;

                    case "pipelinestageid":
                        query = query.OrderByDescending(q => q.PipelineStageId);
                        break;

                    case "testcaseid":
                        query = query.OrderByDescending(q => q.TestCaseId);
                        break;
                    }
                }
            }
            else
            {
                query = query.OrderBy(q => q.TestCaseId);
            }
            var total = query.Count();

            if (page.HasValue && limit.HasValue)
            {
                int start = (page.Value - 1) * limit.Value;
                records = query.Skip(start).Take(limit.Value).ToList();
            }
            else
            {
                records = query.ToList();
            }
            return(this.Json(new { records, total }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 25
0
        public ActionResult GetLastMonthEfficiency()
        {
            int LastMonth = 0;
            int thisYear  = 0;

            //int thisMonth = 5;
            if (DateTime.Today.Month == 1)
            {
                LastMonth = 12;
                thisYear  = DateTime.Today.Year - 1;
            }
            else
            {
                LastMonth = DateTime.Today.Month - 1;
                thisYear  = DateTime.Today.Year;
            }

            DateTime startDate = new DateTime(2016, 01, 01, 0, 0, 0);
            DateTime endDate   = new DateTime(2016, 01, 01, 0, 0, 0);

            int[] MonthArrayInt  = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            int[] MonthArraydays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
            if ((thisYear % 4 == 0 && thisYear % 100 != 0) || (thisYear % 400 == 0))
            {
                MonthArraydays[1] = 29;
            }

            double EfficiencyForPassedTestCases = 0.0;

            // int NumberOfTestCasesFired = 0;

            for (int i = 0; i < 12; i++)
            {
                if (LastMonth == MonthArrayInt[i])
                {
                    startDate = new DateTime(thisYear, MonthArrayInt[i], 01, 0, 0, 0);
                    endDate   = new DateTime(thisYear, MonthArrayInt[i], MonthArraydays[i], 0, 0, 0);
                }
            }

            ValidationMapper <TestCaseLog, Models.TestCaseLog> mapperObj = new ValidationMapper <TestCaseLog, Models.TestCaseLog>();

            var dalObj          = new DALRepository();
            var TestCaselogList = dalObj.GetTestCaseLogentries(startDate, endDate);

            //var testCaseList = new List<Models.TestCaseLog>();
            List <Models.TwoArgumentDataPoint> dataPointsToSend = new List <Models.TwoArgumentDataPoint>();

            var datesList = TestCaselogList.Select(d => (Convert.ToDateTime(d.CreatedDate)).Date).Distinct();

            try
            {
                if (datesList.Any())
                {
                    foreach (var ts in datesList)
                    {
                        int PassedTestCasescount = 0;
                        int TestCaseCount        = 0;

                        if (ts >= startDate.Date & ts <= endDate.Date)
                        {
                            int day = ts.Day;
                            foreach (var tsl in TestCaselogList)
                            {
                                if (ts == (Convert.ToDateTime(tsl.CreatedDate)).Date)
                                {
                                    if (tsl.ResultType == 1)
                                    {
                                        PassedTestCasescount += 1;
                                    }
                                    if (tsl.ResultType != 3 & tsl.ResultType != null)
                                    {
                                        TestCaseCount += 1;
                                    }
                                }
                            }
                            EfficiencyForPassedTestCases = ((PassedTestCasescount * 100.00) / TestCaseCount);
                            EfficiencyForPassedTestCases = Math.Round(EfficiencyForPassedTestCases, 2);
                            dataPointsToSend.Add(new Models.TwoArgumentDataPoint(day, EfficiencyForPassedTestCases));
                        }
                    }
                }
            }
            catch
            {
                return(RedirectToAction("Error"));
            }
            //ViewBag.DataPoints = JsonConvert.SerializeObject(dataPointsToSend);
            return(Json(dataPointsToSend, JsonRequestBehavior.AllowGet));
        }
Esempio n. 26
0
        public ActionResult Charts()
        {
            string newFileName = "D:\\application till register\\Application\\Application\\Content\\Chart.TSV";


            if (System.IO.File.Exists(newFileName))
            {
                System.IO.File.Delete(newFileName);
            }

            int thisMonth = DateTime.Today.Month;
            //int thisMonth = 5;
            int thisYear = DateTime.Today.Year;

            DateTime startDate = new DateTime(2016, 01, 01, 0, 0, 0);
            DateTime endDate   = new DateTime(2016, 01, 01, 0, 0, 0);

            int[] MonthArrayInt  = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            int[] MonthArraydays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
            if ((thisYear % 4 == 0 && thisYear % 100 != 0) || (thisYear % 400 == 0))
            {
                MonthArraydays[1] = 29;
            }
            double EfficiencyForPassedTestCases = 0.0;

            for (int i = 0; i < 12; i++)
            {
                if (thisMonth == MonthArrayInt[i])
                {
                    startDate = new DateTime(thisYear, MonthArrayInt[i], 01, 0, 0, 0);
                    endDate   = new DateTime(thisYear, MonthArrayInt[i], MonthArraydays[i], 0, 0, 0);
                }
            }
            var dalObj          = new DALRepository();
            var TestCaselogList = dalObj.GetTestCaseLogentries(startDate, endDate);

            var datesList = TestCaselogList.Select(d => (Convert.ToDateTime(d.CreatedDate)).Date).Distinct();

            try
            {
                if (datesList.Any())
                {
                    foreach (var ts in datesList)
                    {
                        int PassedTestCasescount = 0;
                        int TestCaseCount        = 0;

                        if (ts >= startDate.Date & ts <= endDate.Date)
                        {
                            int day = ts.Day;
                            foreach (var tsl in TestCaselogList)
                            {
                                if (ts == (Convert.ToDateTime(tsl.CreatedDate)).Date)
                                {
                                    if (tsl.ResultType == 1)
                                    {
                                        PassedTestCasescount += 1;
                                    }
                                    if (tsl.ResultType != 3 & tsl.ResultType != null)
                                    {
                                        TestCaseCount += 1;
                                    }
                                }
                            }
                            EfficiencyForPassedTestCases = ((PassedTestCasescount * 100.00) / TestCaseCount);
                            EfficiencyForPassedTestCases = Math.Round(EfficiencyForPassedTestCases, 2);

                            /****************Insering data into csv file*************************/

                            string clientDetails = day + "\t" + EfficiencyForPassedTestCases + Environment.NewLine;
                            if (!System.IO.File.Exists(newFileName))
                            {
                                string clientHeader = "day" + "\t" + "efficiency" + Environment.NewLine;
                                System.IO.File.WriteAllText(newFileName, clientHeader);
                            }
                            System.IO.File.AppendAllText(newFileName, clientDetails);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Error"));
            }

            return(View());
        }