Esempio n. 1
0
 public Month FindAndCreateMonth(string monthName, int year)
 {
     var months = monthRepo.Fetch().Where(x => x.ObjectInfo.DeletedDate == null && x.Name == monthName && x.Year == year).ToList();
     if (months.Any())
     {
         return months.First();
     }
     var month = new Month
     {
         Id = 0,
         Name = monthName,
         Year = year,
         NumberOfEmployee = 0
     };
     monthRepo.Add(month);
     monthRepo.SaveChanges();
     return month;
 }
Esempio n. 2
0
 public void UpdateMonth(Month month)
 {
     var oldMonth = GetMonth(month.Id);
     oldMonth.Name = month.Name;
     oldMonth.Year = month.Year;
     oldMonth.Description = month.Description;
     monthRepo.SaveChanges();
 }
Esempio n. 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Months EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMonths(Month month)
 {
     base.AddObject("Months", month);
 }
Esempio n. 4
0
 public Month FindAndCreateMonth(string monthName, int year)
 {
     var months = FindMonths(x => x.Name.ToLower() == monthName.ToLower() && x.Year == year).ToList();
     if (months.Any()) {
         return months.First();
     }
     var totalEmployees = 0;
     var date = FindDate(monthName, year);
     if (date.HasValue) {
         var previousMonth = date.Value.AddMonths(-1);
         var preMonths = FindMonths(x => x.Name.ToLower() == previousMonth.ToString("MMMM").ToLower() && x.Year == previousMonth.Year).ToList();
         if (preMonths.Any()) {
             totalEmployees = preMonths.First().NumberOfEmployee;
         }
     }
     var month = new Month {
         Id = 0,
         Name = monthName,
         Year = year,
         NumberOfEmployee = totalEmployees
     };
     monthRepo.Add(month);
     monthRepo.SaveChanges();
     return month;
 }
Esempio n. 5
0
        public ActionResult RsmUser(int id)
        {
            var rsm = _userService.GetUser(id);
            ViewBag.UserName = rsm.Name;
            if (User.IsInRole("RSM"))
            {
                Session["BreadcrumbList"] = Utils.HtmlExtensions.SetBreadcrumbs((List<BreadcrumbModel>)Session["BreadcrumbList"], string.Format("/User/RsmUser/{0}", id), "Home");
            }
            else
            {
                Session["BreadcrumbList"] = Utils.HtmlExtensions.SetBreadcrumbs((List<BreadcrumbModel>)Session["BreadcrumbList"], string.Format("/User/RsmUser/{0}", id), "RSM");

            }
            var currentDate = DateTime.Now;
            var currentMonth = _masterService.FindAndCreateMonth(currentDate.ToString("MMMM"), currentDate.Year);
            DateTime currentmonth;
            DateTime nextMonth;
            var yearMonths = _masterService.FindMonths(year: currentDate.Year).ToList();
            var csmUsers = _userService.FindChilds(new List<int> { id });
            var csmIds = csmUsers.Select(x => x.Id).ToList();
            var products = _masterService.GetAllProducts().OrderBy(x => x.Id);
            var trainingLevels = Enumeration.GetAll<TrainingLevel>().ToList();
            var reportList = new List<ReportManpowerModel>();
            var monthCharts = new Dictionary<string, GraphModel>();
            var existMonths = new List<Month>();
            var currentYear = new DateTime(currentDate.Year, 1, 1);
            var productMonthManPower = products.ToDictionary(x => x.Id, x => 0);
            var allProductMonthManPower = products.ToDictionary(x => x.Id, x => 0);
            var janMonthManpowers = products.ToDictionary(x => x.Id, x => 0);
            for (int i = 1; i < currentDate.Month + 1; i++)
            {
                var indexMonth = new DateTime(currentDate.Year, i, 15);
                var existmonth =
                    yearMonths.SingleOrDefault(x => x.Year == currentDate.Year && x.Name.Equals(indexMonth.ToString("MMMM")));
                if (existmonth == null)
                    existmonth = new Month { Name = indexMonth.ToString("MMMM"), Year = currentDate.Year };
                existMonths.Add(existmonth);
            } var janMonth = existMonths.Single(x => x.Name == "January");
            foreach (var month in existMonths)
            {
                currentmonth = DateTime.Parse(string.Format("1 {0} {1}", month.Name, month.Year));
                nextMonth = currentmonth.AddMonths(1);
                if (month.Id != 0)
                {
                    var monthlyManPowerTarget = _manpowerTargetService.FindUserManpowerMonthTarget(csmIds, new List<int> { month.Id });
                    var totalManPower = _manpowerService.FindAllUserManpowers(csmIds, string.Empty).ToList();
                    var monthlyManPower = totalManPower.Where(
                            x =>
                            x.ObjectInfo.CreatedDate.Ticks < nextMonth.Ticks &&
                            (x.Profile.DateOfLeaving == null ||
                             x.Profile.DateOfLeaving.Value.Ticks >= currentmonth.Ticks)).ToList();
                    var groupProductMonthManPower = monthlyManPower.GroupBy(x => x.ProductId).ToList();
                    foreach (var product in products)
                    {
                        var monthProductManpower = groupProductMonthManPower.SingleOrDefault(x => x.Key == product.Id);
                        if (month.Name != currentDate.ToString("MMMM"))
                        {
                            productMonthManPower[product.Id] = productMonthManPower[product.Id] + (monthProductManpower != null ? monthProductManpower.Count() : 0);
                        }
                        if (month.Name == "January")
                        {
                            janMonthManpowers[product.Id] = janMonthManpowers[product.Id] + (monthProductManpower != null ? monthProductManpower.Count() : 0);
                        }
                        allProductMonthManPower[product.Id] = allProductMonthManPower[product.Id] +
                                                               (monthProductManpower != null ? monthProductManpower.Count() : 0);
                    }
                    var manPoersIds = totalManPower.Where(x => x.Type == "DSE").Select(x => x.Id);
                    var monthlyActualSales = _targetService.FindMonthlyTarget(manPoersIds, month.Id);
                    var graphModel = new GraphModel
                    {
                        ActualManPower = monthlyManPower.Count(),
                        PlanManPower = monthlyManPowerTarget.Sum(x => x.Planned),
                        Retail = monthlyActualSales.Sum(x => x.Actual)
                    };
                    monthCharts.Add(month.Name, graphModel);
                }
                else
                {
                    monthCharts.Add(month.Name, new GraphModel());
                }
            }
            foreach (var csm in csmUsers)
            {
                var dealerIds = _userDealerMapService.FindDealers(new List<int> { csm.Id }).Select(x => x.Id).ToList();
                var targets = _manpowerTargetService.FindDealerManpowerTargets(dealerIds, new List<int> { csm.Id }, currentMonth.Id).ToList();
                var manpowers =
                    _manpowerService.FindAllDealerManpowers(dealerIds, string.Empty).Where(
                        x => x.ObjectInfo.DeletedDate == null).Where(x => x.UserId == csm.Id).ToList();
                var targetList = new List<TotalManpower>();
                foreach (var product in products)
                {
                    targetList.Add(new TotalManpower
                    {
                        Plan = targets.Where(x => x.ProductId == product.Id).Sum(x => x.Planned),
                        Actual = manpowers.Count(x => x.ProductId == product.Id)
                    });
                }
                var trainingLevelList = new List<ManpowerTrainingLevel>();
                foreach (var level in trainingLevels)
                {
                    trainingLevelList.Add(new ManpowerTrainingLevel
                    {
                        Level = level.Value,
                        LevelCount = _profileService.FindProfilesByManPowerLevel(manpowers.Select(x => x.Id), level.Value).Count(),
                    });
                }
                reportList.Add(new ReportManpowerModel
                {
                    User = csm.Name,
                    UserUrl = string.Format("/User/CsmUser/{0}", csm.Id),
                    Manpowers = targetList,
                    TrainingLevels = trainingLevelList
                });
            }
            var productStatList = new List<ProductStateModel>();
            csmIds = _userService.FindChilds(new List<int> { id }).Select(x => x.Id).ToList();
            int totalNonExistManpower = 0, totalEmployee = 0;
            int totalActuals = 0, months = 1;
            foreach (var product in products)
            {
                var manpowers = _manpowerService.FindAllProductUserManpowers(csmIds, new List<int> { product.Id }).ToList();
                var productNonExitMnapowers = manpowers.Any() ? manpowers.Count(x => x.Profile.DateOfLeaving != null && x.Profile.DateOfLeaving.Value.Ticks > currentYear.Ticks) : 0;
                var noofManpowerProductMonth = allProductMonthManPower.Single(x => x.Key == product.Id).Value;
                totalEmployee = totalEmployee + noofManpowerProductMonth;
                totalNonExistManpower = totalNonExistManpower + productNonExitMnapowers;
                var dseManPowerIds = manpowers.Where(x => x.Type == "DSE").Select(x => x.Id).ToList();
                manpowers.RemoveAll(x => x.ObjectInfo.DeletedDate != null || x.Profile.DateOfLeaving != null);
                var manpowerIds = manpowers.Select(x => x.Id).ToList();
                var compmaps = _competencyProfileMapService.FindAllManpowerComap(manpowerIds);
                var actualManpowers = manpowers.Any() ? manpowers.Where(x => compmaps.Any(y => y.DealerManpowerId == x.Id)).ToList() : null;
                List<Target> monthTargets;
                monthTargets = _targetService.FindMonthlyTarget(dseManPowerIds, janMonth.Id).ToList();
                //monthTargets.RemoveAll(x => x.MonthId == currentMonth.Id);
                var noOfMonths = monthTargets.GroupBy(x => x.MonthId).Count();
                var productActuals = monthTargets.Sum(x => x.Actual);
                totalActuals = totalActuals + productActuals;
                months = Math.Max(months, noOfMonths);
                productStatList.Add(new ProductStateModel
                {
                    Product = product.Name,
                    Competency = actualManpowers != null && actualManpowers.Any() ? actualManpowers.Sum(x => compmaps.Where(y => y.DealerManpowerId == x.Id).Average(y => y.Score)) / actualManpowers.Count() * 20 : 0,
                    Productivity = janMonthManpowers[product.Id] != 0 ? Math.Round((double)productActuals / janMonthManpowers[product.Id], 2) : 0,
                    Attrition = allProductMonthManPower.Single(x => x.Key == product.Id).Value != 0 ? (productNonExitMnapowers / (allProductMonthManPower.Single(x => x.Key == product.Id).Value / (double)currentDate.Month)) * 100 : 0,
                    TotalCompetency = actualManpowers != null && actualManpowers.Any() ? actualManpowers.Sum(x => compmaps.Where(y => y.DealerManpowerId == x.Id).Average(y => y.Score)) * 20 : 0,
                    TotalManpowers = actualManpowers != null && actualManpowers.Any() ? actualManpowers.Count() : 0 // used for division
                });
            }
            foreach (var productStatModel in productStatList)
            {
                productStatModel.GrossCompetency = productStatList.Any() && productStatList.Sum(x => x.TotalManpowers) != 0 ? productStatList.Sum(x => x.TotalCompetency) / productStatList.Sum(x => x.TotalManpowers) : 0;
            }
            var model = new RsmUserViewModel
            {
                ReportManpower = new ReportManpowerViewModel
                {
                    ReportManpowers = reportList.OrderBy(x => x.User),
                    Products = products.Select(x => x.Name),
                    TrainingLevels = trainingLevels.Select(x => x.Value)
                },
                ProductStatistics = productStatList,
                MonthGaphModel = monthCharts,
                Attrition = totalEmployee != 0 ? (totalNonExistManpower / (totalEmployee / (double)currentDate.Month)) * 100 : 0,
                Productivity = totalActuals / (double)janMonthManpowers.Sum(x => x.Value)
            };
            ViewBag.List = Session["BreadcrumbList"];
            ViewBag.Role = "RSM";
            ViewBag.Id = id;
            ViewBag.Title = string.Format("{0}({1})", rsm.Name, rsm.Role);
            return View(model);
        }
Esempio n. 6
0
 /// <summary>
 /// Create a new Month object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="year">Initial value of the Year property.</param>
 /// <param name="objectInfo">Initial value of the ObjectInfo property.</param>
 /// <param name="numberOfEmployee">Initial value of the NumberOfEmployee property.</param>
 public static Month CreateMonth(global::System.Int32 id, global::System.String name, global::System.Int32 year, ObjectInfo objectInfo, global::System.Int32 numberOfEmployee)
 {
     Month month = new Month();
     month.Id = id;
     month.Name = name;
     month.Year = year;
     month.ObjectInfo = StructuralObject.VerifyComplexObjectIsNotNull(objectInfo, "ObjectInfo");
     month.NumberOfEmployee = numberOfEmployee;
     return month;
 }
Esempio n. 7
0
 public ActionResult DseRetailTrend(int csmId, int dealerId)
 {
     var dealer = _masterService.GetDealer(dealerId);
     var reprtRetailModel = new ReprtRetailModel();
     List<DealerManpower> manpowers;
     manpowers = _manpowerService.FindDealerManpowers(dealerId, csmId).ToList();
     var currentDate = DateTime.Now;
     var months = new List<Month>();
     var totalmonths = _masterService.FindMonths(year: currentDate.Year).ToList();
     for (int i = 0; i < 12; i++)
     {
         var montTime = new DateTime(currentDate.Year, i + 1, 15);
         var montName = montTime.ToString("MMMM");
         var month = totalmonths.SingleOrDefault(x => x.Name.Equals(montName) && x.Year == currentDate.Year);
         if (month == null)
             month = new Month { Name = montName };
         months.Add(month);
     }
     var reportReatils = new List<ReportReatil>();
     var yTd = new Dictionary<int, YearTarget>();
     var year = currentDate.Year.ToString();
     foreach (var dealerManpower in manpowers)
     {
         int i = 0;
         foreach (var month in months)
         {
             i++;
             var reportReatilModel = new ReportReatil();
             var targets = _targetService.FindTarget(dealerManpower.Id, month.Id).ToList();
             if (targets.Any())
             {
                 reportReatilModel.Actual = targets.Sum(x => x.Actual);
                 reportReatilModel.T1 = targets.Sum(x => x.Target1);
                 reportReatilModel.T2 = targets.Sum(x => x.Target2);
             }
             else
             {
                 reportReatilModel.Actual = 0;
                 reportReatilModel.T1 = 0;
                 reportReatilModel.T2 = 0;
             }
             reportReatilModel.Month = month.Name;
             reportReatilModel.MonthNumber = i;
             reportReatilModel.Type = dealerManpower.Type;
             reportReatilModel.ManPowerName = dealerManpower.Name;
             reportReatilModel.ManPowerId = dealerManpower.Id;
             reportReatils.Add(reportReatilModel);
         }
         var yearTarget = dealerManpower.YearTargets.SingleOrDefault(x => x.Year == year && x.DealerManpowerId == dealerManpower.Id && x.ObjectInfo.DeletedDate == null);
         if (yearTarget != null)
         {
             yTd.Add(dealerManpower.Id, yearTarget);
         }
         else
         {
             yTd.Add(dealerManpower.Id, new YearTarget());
         }
     }
     reprtRetailModel.YTD = yTd;
     reprtRetailModel.CsmId = csmId;
     reprtRetailModel.Id = dealerId;
     reprtRetailModel.Name = dealer.Name;
     reprtRetailModel.ReportReatils = reportReatils.GroupBy(x => x.ManPowerId).ToDictionary(x => x.Key, y => y.OrderBy(z => z.MonthNumber).ToList());
     ViewBag.List = Session["BreadcrumbList"];
     return View(reprtRetailModel);
 }
Esempio n. 8
0
        public ActionResult Dealer(int dealerId, int csmId)
        {
            Session["BreadcrumbList"] =
                Utils.HtmlExtensions.SetBreadcrumbs((List<BreadcrumbModel>)Session["BreadcrumbList"],
                                                    string.Format("/Dealer/Dealer?dealerId={0}&csmId={1}", dealerId,
                                                                  csmId), "Dealer");
            var currentDate = DateTime.Now;

            var currentMonth = _masterService.FindAndCreateMonth(currentDate.ToString("MMMM"), currentDate.Year);
            var allManpower = manpowerService.FindAllDealerManpowers(new List<int> { dealerId }, new List<int> { csmId });
            var excludeManpower = allManpower.Where(x => x.ObjectInfo.DeletedDate != null && x.Profile.DateOfLeaving == null);
            allManpower = allManpower.Except(excludeManpower);
            var manpowerUsers = allManpower.Where(x => x.DealerId == dealerId && x.UserId == csmId && x.ObjectInfo.DeletedDate == null).ToList();
            var yearMonths = _masterService.FindMonths(year: currentDate.Year);
            var existMonths = new List<Month>();
            var currentYear = new DateTime(currentDate.Year, 1, 1);
            var products = _masterService.GetAllProducts().OrderBy(x => x.Id).ToList();
            var productMonthManPower = products.ToDictionary(x => x.Id, x => 0);
            var allProductMonthManPower = products.ToDictionary(x => x.Id, x => 0);
            var janMonthManpowers = products.ToDictionary(x => x.Id, x => 0);
            for (int i = 1; i < currentDate.Month + 1; i++)
            {
                var month = new DateTime(currentDate.Year, i, 15);
                var existMonth =
                    yearMonths.SingleOrDefault(x => x.Name.Equals(month.ToString("MMMM")) && x.Year == month.Year);
                if (existMonth == null)
                    existMonth = new Month { Name = month.ToString("MMMM"), Year = month.Year };
                existMonths.Add(existMonth);
            }
            var janMonth = existMonths.Single(x => x.Name == "January");
            var monthCharts = new Dictionary<string, GraphModel>();
            foreach (var yearMonth in existMonths)
            {
                var currentmonth = DateTime.Parse(string.Format("1 {0} {1}", yearMonth.Name, yearMonth.Year));
                var nextMonth = currentmonth.AddMonths(1);

                if (yearMonth.Id != 0)
                {
                    var planManPowerTarget = manpowerTargetService.FindDealerManpowerTargets(
                            x => x.UserId == csmId && x.MonthId == yearMonth.Id && x.DealerId == dealerId).Sum(x => x.Planned);

                    var manpowers1 = allManpower.Where(
                              x =>
                              x.ObjectInfo.CreatedDate.Ticks < nextMonth.Ticks &&
                              (x.Profile.DateOfLeaving == null ||
                               x.Profile.DateOfLeaving.Value.Ticks >= currentmonth.Ticks))
                              .ToList();
                    var groupProductMonthManPower = manpowers1.GroupBy(x => x.ProductId);
                    foreach (var product in products)
                    {
                        var monthProductManpower = groupProductMonthManPower.SingleOrDefault(x => x.Key == product.Id);
                        if (yearMonth.Name != currentDate.ToString("MMMM"))
                        {
                            productMonthManPower[product.Id] = productMonthManPower[product.Id] + (monthProductManpower != null ? monthProductManpower.Count() : 0);
                        }
                        if (yearMonth.Name == "January")
                        {
                            janMonthManpowers[product.Id] = janMonthManpowers[product.Id] + (monthProductManpower != null ? monthProductManpower.Count() : 0);
                        }
                        allProductMonthManPower[product.Id] = allProductMonthManPower[product.Id] +
                                                               (monthProductManpower != null ? monthProductManpower.Count() : 0);
                    }
                    var manPoersIds = allManpower.Where(x => x.Type == "DSE").Select(x => x.Id);
                    var monthlyActualSales = targetService.FindMonthlyTarget(manPoersIds, yearMonth.Id);

                    var graphModel = new GraphModel
                    {
                        ActualManPower = manpowers1.Count,
                        PlanManPower = planManPowerTarget,
                        Retail = monthlyActualSales.Sum(x => x.Actual)
                    };
                    monthCharts.Add(yearMonth.Name, graphModel);
                }
                else
                {
                    monthCharts.Add(yearMonth.Name, new GraphModel());
                }
            }

            var trainingLevels = Enumeration.GetAll<TrainingLevel>().ToList();
            var reportList = new List<ReportManpowerModel>();

            var targets = manpowerTargetService.FindDealerManpowerTargets(x => x.DealerId == dealerId && x.UserId == csmId).ToList();
            var targetList = products.Select(product => new TotalManpower
            {
                Plan = targets.Where(x => x.ProductId == product.Id && x.MonthId == currentMonth.Id).Sum(x => x.Planned),
                Actual = manpowerUsers.Count(x => x.ProductId == product.Id)
            }).ToList();
            var trainingLevelList = trainingLevels.Select(level => new ManpowerTrainingLevel
            {
                Level = level.Value,
                LevelCount = manpowerUsers.Count(x => x.Profile.TrainingLevel == level.Value)
            }).ToList();
            reportList.Add(new ReportManpowerModel
            {
                Manpowers = targetList,
                TrainingLevels = trainingLevelList
            });
            var productStatList = new List<ProductStateModel>();
            int totalNonExistManpower = 0, totalEmployee = 0, totalProductiveEmployee = 0;
            int totalActuals = 0, months = 1;
            foreach (var product in products)
            {

                var manpowers = manpowerService.FindAllDealerManpowers(x => x.UserId == csmId && x.DealerId == dealerId && x.ProductId == product.Id).ToList();
                var productNonExitMnapowers = manpowers.Any() ? manpowers.Count(x => x.Profile.DateOfLeaving != null && x.Profile.DateOfLeaving.Value.Ticks > currentYear.Ticks) : 0;
                var noofManpowerProductMonth = allProductMonthManPower.Single(x => x.Key == product.Id).Value;
                totalEmployee = totalEmployee + noofManpowerProductMonth;
                totalNonExistManpower = totalNonExistManpower + productNonExitMnapowers;
                var dseManPowerIds = manpowers.Where(x => x.Type == "DSE").Select(x => x.Id).ToList();
                manpowers.RemoveAll(x => x.ObjectInfo.DeletedDate != null || x.Profile.DateOfLeaving != null);
                var actualManpowers = manpowers.Any() ? manpowers.Where(x => x.CompetencyProfileMaps.Any()) : null;
                List<Repository.Target> monthTargets;
                monthTargets = targetService.FindMonthlyTarget(dseManPowerIds, janMonth.Id).ToList();
                //monthTargets.RemoveAll(x => x.MonthId == currentMonth.Id);
                var noOfMonths = monthTargets.GroupBy(x => x.MonthId).Count();
                var productActuals = monthTargets.Sum(x => x.Actual);
                totalActuals = totalActuals + productActuals;
                months = Math.Max(months, noOfMonths);
                productStatList.Add(new ProductStateModel
                {
                    Product = product.Name,
                    Competency = actualManpowers != null && actualManpowers.Any() ? actualManpowers.Sum(x => x.CompetencyProfileMaps.Average(y => y.Score)) / actualManpowers.Count() * 20 : 0,
                    Productivity = noOfMonths != 0 && janMonthManpowers[product.Id] != 0 ? Math.Round((double)productActuals / janMonthManpowers[product.Id], 2) : 0,
                    Attrition = allProductMonthManPower.Single(x => x.Key == product.Id).Value != 0 ? (productNonExitMnapowers / (allProductMonthManPower.Single(x => x.Key == product.Id).Value / (double)currentDate.Month)) * 100 : 0,
                    TotalCompetency = actualManpowers != null && actualManpowers.Any() ? actualManpowers.Sum(x => x.CompetencyProfileMaps.Average(y => y.Score)) * 20 : 0,
                    TotalManpowers = actualManpowers != null && actualManpowers.Any() ? actualManpowers.Count() : 0 // used for division
                });
            }
            foreach (var productStatModel in productStatList)
            {
                productStatModel.GrossCompetency = productStatList.Sum(x => x.TotalManpowers) != 0 ? productStatList.Sum(x => x.TotalCompetency) / productStatList.Sum(x => x.TotalManpowers) : 0;
            }
            var model = new CsmUserViewModel
            {
                ReportManpower = new ReportManpowerViewModel
                {
                    ReportManpowers = reportList,
                    Products = products.Select(x => x.Name),
                    TrainingLevels = trainingLevels.Select(x => x.Value)
                },
                ProductStatistics = productStatList,
                MonthGaphModel = monthCharts,
                CsmId = csmId,
                Attrition = totalEmployee != 0 ? (totalNonExistManpower / (totalEmployee / (double)currentDate.Month)) * 100 : 0,
                Productivity = totalActuals / (double)janMonthManpowers.Sum(x => x.Value)
            };
            ViewBag.DealerId = dealerId;
            ViewBag.CsmId = csmId;
            ViewBag.List = Session["BreadcrumbList"];
            var dealer = _masterService.GetDealer(dealerId);
            ViewBag.UserName = dealer.Name;
            ViewBag.Title = string.Format("{0}({1})", dealer.Name, "Dealer");
            return View(model);
        }
Esempio n. 9
0
        private ReprtRetailModel RsmDealerTrend(int id)
        {
            var rsm = _userService.GetUser(id);
            var csms = _userService.FindChilds(new List<int> { rsm.Id });
            var csmIds = csms.Select(x => x.Id).ToList();
            var dealers = _userDealerMapServiceService.FindDealers(csmIds).Distinct();
            var currentDate = DateTime.Now;
            var months = new List<Month>();
            var totalmonths = _masterService.FindMonths(year: currentDate.Year).ToList();
            var yTd = new Dictionary<int, YearTarget>();
            for (int i = 0; i < 12; i++)
            {
                var montTime = new DateTime(currentDate.Year, i + 1, 15);
                var montName = montTime.ToString("MMMM");
                var month = totalmonths.SingleOrDefault(x => x.Name.Equals(montName) && x.Year == currentDate.Year);
                if (month == null)
                    month = new Month { Name = montName };
                months.Add(month);
            }
            var reportReatils = new List<ReportReatil>();
            foreach (var dealer in dealers)
            {
                var manpowerIds = _dealerManpowerService.FindAllDealerManpowers(new List<int> { dealer.Id }, csmIds).Where(x => x.Type == "DSE").Select(x => x.Id).ToList();
                int i = 0, ytdActual = 0, ytdTarget1 = 0, ytdTarget2 = 0;
                foreach (var month in months)
                {
                    i++;
                    var reportReatilModel = new ReportReatil();
                    var targets = _targetService.FindMonthlyTarget(manpowerIds, month.Id).ToList();
                    if (targets.Any())
                    {
                        int sumActual = targets.Sum(x => x.Actual); ytdActual = ytdActual + sumActual;
                        int sumTarget1 = targets.Sum(x => x.Target1);
                        ytdTarget1 = ytdTarget1 + sumTarget1;
                        int sumTarget2 = targets.Sum(x => x.Target2);
                        ytdTarget2 = ytdTarget2 + sumTarget2;
                        reportReatilModel.Actual = sumActual;
                        reportReatilModel.T1 = sumTarget1;
                        reportReatilModel.T2 = sumTarget2;
                    }
                    else
                    {
                        reportReatilModel.Actual = 0;
                        reportReatilModel.T1 = 0;
                        reportReatilModel.T2 = 0;
                    }
                    reportReatilModel.Month = month.Name;
                    reportReatilModel.MonthNumber = i;
                    reportReatilModel.ManPowerName = dealer.Name;
                    reportReatilModel.ManPowerId = dealer.Id;
                    reportReatils.Add(reportReatilModel);

                }
                yTd.Add(dealer.Id, new YearTarget { Actual = ytdActual, Target1 = ytdTarget1, Target2 = ytdTarget2 });
            }
            var reprtRetailModel = new ReprtRetailModel();
            reprtRetailModel.Id = id;
            reprtRetailModel.Role = "RSM";
            reprtRetailModel.YTD = yTd;
            reprtRetailModel.Name = rsm.Name;
            reprtRetailModel.ReportReatils = reportReatils.GroupBy(x => x.ManPowerId).ToDictionary(x => x.Key, y => y.OrderBy(z => z.MonthNumber).ToList());
            return reprtRetailModel;
        }
Esempio n. 10
0
 private ReprtRetailModel StateWiseRetailTrend(int id)
 {
     var rm = _userService.GetUser(id);
     var regionmaps = rm.UserRegionMaps.ToList();
     var regions = regionmaps.Select(x => x.Region);
     var states = regions.SelectMany(x => x.States).ToList();
     var rsms = _userService.FindUsers(x => x.ParentId == id);
     var csms = _userService.FindUsers(x => rsms.Any(y => y.Id == x.ParentId));
     var userDealerMaps = csms.SelectMany(x => x.UserDealerMaps);
     var dealers = userDealerMaps.Select(x => x.Dealer).Distinct().ToList();
     var currentDate = DateTime.Now;
     var months = new List<Month>();
     var totalmonths = _masterService.FindMonths(currentDate.Year).ToList();
     var yTd = new Dictionary<int, YearTarget>();
     for (int i = 0; i < 12; i++)
     {
         var montTime = new DateTime(currentDate.Year, i + 1, 15);
         var montName = montTime.ToString("MMMM");
         var month = totalmonths.SingleOrDefault(x => x.Name.Equals(montName) && x.Year == currentDate.Year);
         if (month == null)
             month = new Month { Name = montName };
         months.Add(month);
     }
     var reportReatils = new List<ReportReatil>();
     foreach (var state in states)
     {
         var stateDealers = dealers.Where(x => x.StateId == state.Id).ToList();
         var dealerIds = stateDealers.Select(x => x.Id);
         var manpowerIds = _dealerManpowerService.FindAllDealerManpowers(dealerIds, "DSE").Select(x => x.Id).ToList();
         int i = 0, ytdActual = 0, ytdTarget1 = 0, ytdTarget2 = 0;
         foreach (var month in months)
         {
             i++;
             var reportReatilModel = new ReportReatil();
             var targets = _targetService.FindMonthlyTarget(manpowerIds, month.Id).ToList();
             if (targets.Any())
             {
                 int sumActual = targets.Sum(x => x.Actual); ytdActual = ytdActual + sumActual;
                 int sumTarget1 = targets.Sum(x => x.Target1);
                 ytdTarget1 = ytdTarget1 + sumTarget1;
                 int sumTarget2 = targets.Sum(x => x.Target2);
                 ytdTarget2 = ytdTarget2 + sumTarget2;
                 reportReatilModel.Actual = sumActual;
                 reportReatilModel.T1 = sumTarget1;
                 reportReatilModel.T2 = sumTarget2;
             }
             else
             {
                 reportReatilModel.Actual = 0;
                 reportReatilModel.T1 = 0;
                 reportReatilModel.T2 = 0;
             }
             reportReatilModel.Month = month.Name;
             reportReatilModel.MonthNumber = i;
             reportReatilModel.ManPowerName = state.Name;
             reportReatilModel.ManPowerId = state.Id;
             reportReatils.Add(reportReatilModel);
         }
         yTd.Add(state.Id, new YearTarget { Actual = ytdActual, Target1 = ytdTarget1, Target2 = ytdTarget2 });
     }
     var reprtRetailModel = new ReprtRetailModel();
     reprtRetailModel.Id = id;
     reprtRetailModel.Role = "RM";
     reprtRetailModel.YTD = yTd;
     reprtRetailModel.Name = rm.Name;
     reprtRetailModel.ReportReatils = reportReatils.GroupBy(x => x.ManPowerId).ToDictionary(x => x.Key, y => y.OrderBy(z => z.MonthNumber).ToList());
     return reprtRetailModel;
 }
Esempio n. 11
0
        private ReprtRetailModel HqTrend(int id)
        {
            var hq = _userService.GetUser(id);
            var rms = _userService.FindUsersByRole("RM", x => x.UserRegionMaps).OrderBy(x => x.Name).ToList();
            var currentDate = DateTime.Now;
            string crmonth = DateTime.Now.AddMonths(0).ToString("MMMM");
            var months = new List<Month>();
            var totalmonths = _masterService.FindMonths(year: currentDate.Year).ToList();
            var crtMnthId = _masterService.FindMonthIDByName(currentDate.Year, crmonth);
            var yTd = new Dictionary<int, YearTarget>();
            for (int i = 0; i < 12; i++)
            {
                var monthTime = new DateTime(currentDate.Year, i + 1, 15);
                var monthName = monthTime.ToString("MMMM");
                var month = totalmonths.SingleOrDefault(x => x.Name.Equals(monthName) && x.Year == currentDate.Year);
                if (month == null)
                    month = new Month { Name = monthName };
                months.Add(month);
            }
            var reportReatils = new List<ReportReatil>();
            foreach (var rm in rms)
            {
                var rsms = _userService.FindUsers(x => x.ParentId == rm.Id).ToList();
                var csms = _userService.FindUsers(x => rsms.Any(y => y.Id == x.ParentId)).ToList();
                var csmIds = csms.Select(x => x.Id).ToList();
                var manpowerIds = _dealerManpowerService.FindAllUserManpowers(csmIds, "DSE").Select(x => x.Id).ToList();
                int i = 0, ytdActual = 0, ytdTarget1 = 0, ytdTarget2 = 0;
                foreach (var month in months)
                {
                    i++;
                    var reportReatilModel = new ReportReatil();
                    var targets = _targetService.FindMonthlyTarget(manpowerIds, month.Id).ToList();
                    var crtTargets = _targetService.FindMonthlyTarget(manpowerIds, crtMnthId.Id).ToList();
                    if (targets.Any())
                    {
                        int sumActual = targets.Sum(x => x.Actual);
                        ytdActual = ytdActual + sumActual;
                        int sumTarget1 = targets.Sum(x => x.Target1);
                        ytdTarget1 = ytdTarget1 + sumTarget1;
                        int sumTarget2 = targets.Sum(x => x.Target2);
                        ytdTarget2 = ytdTarget2 + sumTarget2;
                        reportReatilModel.Actual = sumActual;
                        reportReatilModel.T1 = sumTarget1;
                        reportReatilModel.T2 = sumTarget2;
                        if (crtTargets.Any() && month.Name == crmonth)
                        {

                            int sumCrtTarget1 = crtTargets.Sum(x => x.Target1);
                            int sumCrtTarget2 = crtTargets.Sum(x => x.Target2);
                            int sumCrtActual = crtTargets.Sum(x => x.Actual);
                            reportReatilModel.CrntmnthTgt1 = sumCrtTarget1;
                            reportReatilModel.CrntmnthTgt2 = sumCrtTarget2;
                            reportReatilModel.CrntmnthActual = sumCrtActual;

                        }

                    }
                    else
                    {
                        reportReatilModel.Actual = 0;
                        reportReatilModel.T1 = 0;
                        reportReatilModel.T2 = 0;
                    }
                    reportReatilModel.Month = month.Name;
                    reportReatilModel.MonthNumber = i;
                    reportReatilModel.ManPowerName = string.Format("{0}({1})", rm.UserRegionMaps.First().Region.Name, rm.Name);
                    reportReatilModel.ManPowerId = rm.Id;
                    reportReatils.Add(reportReatilModel);

                }
                yTd.Add(rm.Id, new YearTarget { Actual = ytdActual, Target1 = ytdTarget1, Target2 = ytdTarget2 });
            }
            var reprtRetailModel = new ReprtRetailModel();
            reprtRetailModel.Id = id;
            reprtRetailModel.Role = "HQ";
            reprtRetailModel.YTD = yTd;
            reprtRetailModel.Name = hq.Name;
            reprtRetailModel.ReportReatils = reportReatils.GroupBy(x => x.ManPowerId).ToDictionary(x => x.Key, y => y.OrderBy(z => z.MonthNumber).ToList());
            return reprtRetailModel;
        }
Esempio n. 12
0
        private CsmAttritionModel CsmAttritions(int csmId)
        {
            var csm = _userService.GetUser(csmId);
            var dealers = csm.UserDealerMaps.Select(x => x.Dealer).ToList();
            var currentDate = DateTime.Now;
            var currentYear = new DateTime(currentDate.Year, 1, 1);
            var attHeads = _masterService.GetAllAttritionHeaders().ToList();
            var delaerCsmattritionModels = new List<DelaerCsmattritionModel>();
            int maintotalemployee = 0;
            int maintotalNonExistManpower = 0;
            var products = _masterService.GetAllProducts().OrderBy(x => x.Id).ToList();
            var productMonthManPower = products.ToDictionary(x => x.Id, x => 0);
            foreach (var dealer in dealers)
            {
                var allProductMonthManPower = products.ToDictionary(x => x.Id, x => 0);
                var allManpower = _manpowerService.FindAllDealerManpowers(new List<int> { dealer.Id }, new List<int> { csmId }).ToList();
                var yearMonths = _masterService.FindMonths(year: currentDate.Year).ToList();
                var existMonths = new List<Month>();

                for (int i = 1; i < currentDate.Month + 1; i++)
                {
                    var month = new DateTime(currentDate.Year, i, 15);
                    var existMonth =
                        yearMonths.SingleOrDefault(x => x.Name.Equals(month.ToString("MMMM")) && x.Year == month.Year);
                    if (existMonth == null)
                        existMonth = new Month { Name = month.ToString("MMMM"), Year = month.Year };
                    existMonths.Add(existMonth);
                }
                foreach (var yearMonth in existMonths)
                {
                    var currentmonth = DateTime.Parse(string.Format("1 {0} {1}", yearMonth.Name, yearMonth.Year));
                    var nextMonth = currentmonth.AddMonths(1);

                    if (yearMonth.Id != 0)
                    {
                        var manpowers1 =
                              allManpower.Where(
                                  x =>
                                  x.ObjectInfo.CreatedDate.Ticks < nextMonth.Ticks &&
                                  (x.Profile.DateOfLeaving == null ||
                                   x.Profile.DateOfLeaving.Value.Ticks >= currentmonth.Ticks))
                                  .ToList();
                        var groupProductMonthManPower = manpowers1.GroupBy(x => x.ProductId).ToList();
                        foreach (var product in products)
                        {
                            var monthProductManpower = groupProductMonthManPower.SingleOrDefault(x => x.Key == product.Id);
                            if (yearMonth.Name != currentDate.ToString("MMMM"))
                            {
                                productMonthManPower[product.Id] = productMonthManPower[product.Id] + (monthProductManpower != null ? monthProductManpower.Count() : 0);
                            }
                            allProductMonthManPower[product.Id] = allProductMonthManPower[product.Id] +
                                                                   (monthProductManpower != null ? monthProductManpower.Count() : 0);
                        }
                    }
                }
                var delaerCsmattritionModel = new DelaerCsmattritionModel();
                int totalNonExistManpower = 0, totalEmployee = 0;
                int productNonExitMnapowers1 = 0;
                List<DealerManpower> manpowers;
                var productNonExitMnapowers = 0;
                foreach (var product in products)
                {
                    manpowers = _manpowerService.FindAllDealerManpowers(x => x.UserId == csmId && x.DealerId == dealer.Id && x.ProductId == product.Id).ToList();
                    productNonExitMnapowers = manpowers.Any() ? manpowers.Count(x => x.Profile.DateOfLeaving != null && x.Profile.DateOfLeaving.Value.Ticks > currentYear.Ticks) : 0;
                    var noofManpowerProductMonth = allProductMonthManPower.Single(x => x.Key == product.Id).Value;
                    totalEmployee = totalEmployee + noofManpowerProductMonth;
                    productNonExitMnapowers1 = productNonExitMnapowers1 + productNonExitMnapowers;
                }
                totalNonExistManpower = totalNonExistManpower + productNonExitMnapowers1;
                var attritionCountCsmModels = new List<AttritionCountCsmModel>();
                var attritionRate = new Dictionary<int, decimal>();
                foreach (var attHead in attHeads)
                {
                    var attheadManPowerLeft = allManpower.Count(
                                x =>
                                 x.AttritionProfileMap != null && x.AttritionProfileMap.Attrition.AttritionHead.Id == attHead.Id && x.Profile.DateOfLeaving != null && x.Profile.DateOfLeaving.Value.Ticks > currentYear.Ticks);
                    var attRate = totalEmployee != 0 ? (attheadManPowerLeft / (totalEmployee / (double)currentDate.Month)) : 0;

                    attritionRate.Add(attHead.Id, (decimal)attRate);
                }
                foreach (var product in products)
                {
                    foreach (var atthead in attHeads)
                    {
                        var count = allManpower.Count(
                            x =>
                            x.ProductId == product.Id && x.AttritionProfileMap != null && x.AttritionProfileMap.Attrition.AttritionHead.Id == atthead.Id && x.Profile.DateOfLeaving != null && x.Profile.DateOfLeaving.Value.Ticks > currentYear.Ticks);
                        var attritionCountCsmModel = new AttritionCountCsmModel();
                        attritionCountCsmModel.AttrionId = atthead.Id;
                        attritionCountCsmModel.ProductId = product.Id;
                        attritionCountCsmModel.NoOfAttriton = count;
                        attritionCountCsmModels.Add(attritionCountCsmModel);
                    }
                }
                delaerCsmattritionModel.DealerId = dealer.Id;
                delaerCsmattritionModel.DealerName = dealer.Name;
                delaerCsmattritionModel.AttritionRate = attritionRate;
                delaerCsmattritionModel.TotalAttration = Convert.ToDouble(totalEmployee != 0 ? (totalNonExistManpower / (totalEmployee / (double)currentDate.Month)) * 100 : 0);
                delaerCsmattritionModel.AttritionCountCsmModels = attritionCountCsmModels;
                delaerCsmattritionModels.Add(delaerCsmattritionModel);
            }
            var csmAttritionModel = new CsmAttritionModel();
            csmAttritionModel.Id = csmId;
            csmAttritionModel.Name = csm.Name;
            csmAttritionModel.DelaerCsmattritionModels = delaerCsmattritionModels.OrderBy(x => x.DealerName);
            csmAttritionModel.FinalTotalAttrition = Convert.ToDouble(maintotalemployee != 0 ? (maintotalNonExistManpower / (maintotalemployee / (double)currentDate.Month)) * 100 : 0);
            csmAttritionModel.Attritions = attHeads.ToDictionary(x => x.Id, x => x.Category);
            csmAttritionModel.Products = products.ToDictionary(x => x.Id, x => x.Name);
            return csmAttritionModel;
        }
Esempio n. 13
0
        public ActionResult PdfDseRetailTrend(int csmId, int dealerId)
        {
            var dealer = _masterService.GetDealer(dealerId);
            var reprtRetailModel = new ReprtRetailModel();
            var manpowers = _manpowerService.FindDealerManpowers(dealerId: dealerId, csmId: csmId).Where(x => x.Type.Equals("DSE"));
            var currentDate = DateTime.Now;
            var months = new List<Month>();
            var totalmonths = _masterService.FindMonths(year: currentDate.Year).ToList();
            for (int i = 0; i < 12; i++)
            {
                var montTime = new DateTime(currentDate.Year, i + 1, 15);
                var montName = montTime.ToString("MMMM");
                var month = totalmonths.SingleOrDefault(x => x.Name.Equals(montName) && x.Year == currentDate.Year);
                if (month == null)
                    month = new Month { Name = montName };
                months.Add(month);
            }
            var reportReatils = new List<ReportReatil>();
            var yTd = new Dictionary<int, YearTarget>();
            var year = currentDate.Year.ToString();
            foreach (var dealerManpower in manpowers)
            {
                int i = 0;
                foreach (var month in months)
                {
                    i++;
                    var reportReatilModel = new ReportReatil();
                    var targets = _targetService.FindTarget(dealerManpowerId: dealerManpower.Id, monthId: month.Id).ToList();
                    if (targets.Any())
                    {
                        reportReatilModel.Actual = targets.Sum(x => x.Actual);
                        reportReatilModel.T1 = targets.Sum(x => x.Target1);
                        reportReatilModel.T2 = targets.Sum(x => x.Target2);
                    }
                    else
                    {
                        reportReatilModel.Actual = 0;
                        reportReatilModel.T1 = 0;
                        reportReatilModel.T2 = 0;
                    }
                    reportReatilModel.Month = month.Name;
                    reportReatilModel.MonthNumber = i;
                    reportReatilModel.Type = dealerManpower.Type;
                    reportReatilModel.ManPowerName = dealerManpower.Name;
                    reportReatilModel.ManPowerId = dealerManpower.Id;
                    reportReatils.Add(reportReatilModel);

                }
                var yearTarget = dealerManpower.YearTargets.SingleOrDefault(x => x.Year == year && x.DealerManpowerId == dealerManpower.Id && x.ObjectInfo.DeletedDate == null);
                if (yearTarget != null)
                {
                    yTd.Add(dealerManpower.Id, yearTarget);
                }
                else
                {
                    yTd.Add(dealerManpower.Id, new YearTarget());
                }
            }
            reprtRetailModel.YTD = yTd;
            reprtRetailModel.CsmId = csmId;
            reprtRetailModel.Id = dealerId;
            reprtRetailModel.Name = dealer.Name;
            reprtRetailModel.ReportReatils = reportReatils.GroupBy(x => x.ManPowerId).ToDictionary(x => x.Key, y => y.OrderBy(z => z.MonthNumber).ToList());
            var viewString = RenderViewToString("PdfDseRetailTrend", reprtRetailModel);
            var absolutePath = WkhtmlWrapper.CreatePdf(viewString, Server.MapPath("/tmp"),
                                                                   FileService.CreateTempFilePath("pdf"), "Portrait", WkhtmlWrapper.PaperSize.A4);
            var fileContents = FileService.ReadBytesFromAbsolutePath(absolutePath);
            FileService.DeleteFile(absolutePath);
            return File(fileContents, "application/pdf", "Retail-Trends.pdf");
        }
Esempio n. 14
0
        public ActionResult ExcelDseRetailTrend(int csmId, int dealerId)
        {
            var dealer = _masterService.GetDealer(dealerId);
            var reprtRetailModel = new ReprtRetailModel();
            var manpowers = _manpowerService.FindDealerManpowers(dealerId: dealerId, csmId: csmId).Where(x => x.Type.Equals("DSE"));
            var currentDate = DateTime.Now;
            var months = new List<Month>();
            var totalmonths = _masterService.FindMonths(year: currentDate.Year).ToList();
            for (int i = 0; i < 12; i++)
            {
                var montTime = new DateTime(currentDate.Year, i + 1, 15);
                var montName = montTime.ToString("MMMM");
                var month = totalmonths.SingleOrDefault(x => x.Name.Equals(montName) && x.Year == currentDate.Year);
                if (month == null)
                    month = new Month { Name = montName };
                months.Add(month);
            }
            var reportReatils = new List<ReportReatil>();
            var yTd = new Dictionary<int, YearTarget>();
            var year = currentDate.Year.ToString();
            foreach (var dealerManpower in manpowers)
            {
                int i = 0;
                foreach (var month in months)
                {
                    i++;
                    var reportReatilModel = new ReportReatil();
                    var targets = _targetService.FindTarget(dealerManpowerId: dealerManpower.Id, monthId: month.Id).ToList();
                    if (targets.Any())
                    {
                        reportReatilModel.Actual = targets.Sum(x => x.Actual);
                        reportReatilModel.T1 = targets.Sum(x => x.Target1);
                        reportReatilModel.T2 = targets.Sum(x => x.Target2);
                    }
                    else
                    {
                        reportReatilModel.Actual = 0;
                        reportReatilModel.T1 = 0;
                        reportReatilModel.T2 = 0;
                    }
                    reportReatilModel.Month = month.Name;
                    reportReatilModel.MonthNumber = i;
                    reportReatilModel.Type = dealerManpower.Type;
                    reportReatilModel.ManPowerName = dealerManpower.Name;
                    reportReatilModel.ManPowerId = dealerManpower.Id;
                    reportReatils.Add(reportReatilModel);
                }
                var yearTarget = dealerManpower.YearTargets.SingleOrDefault(x => x.Year == year && x.DealerManpowerId == dealerManpower.Id && x.ObjectInfo.DeletedDate == null);
                if (yearTarget != null)
                {
                    yTd.Add(dealerManpower.Id, yearTarget);
                }
                else
                {
                    yTd.Add(dealerManpower.Id, new YearTarget());
                }

            }
            reprtRetailModel.YTD = yTd;
            reprtRetailModel.CsmId = csmId;
            reprtRetailModel.Id = dealerId;
            reprtRetailModel.Name = dealer.Name;
            reprtRetailModel.ReportReatils = reportReatils.GroupBy(x => x.ManPowerId).ToDictionary(x => x.Key, y => y.OrderBy(z => z.MonthNumber).ToList());

            var tempPath = FileService.GetDownloadFilePath("xlsx");
            var excelFilePath = FileService.ConvertToAbsolute(tempPath);
            var converter = new RetailTrendConverter();
            converter.GenerateExcel(excelFilePath, reprtRetailModel);
            var fileContent = FileService.ReadBytesFromAbsolutePath(excelFilePath);
            FileService.DeleteFile(excelFilePath);
            return File(fileContent, "application/octet-stream", "Retail-Trends.xlsx");
        }
Esempio n. 15
0
 public static string SaveRetailFile(HttpPostedFileBase httpPostedFileBase, Dealer dealer, Month month, User csm)
 {
     var directory = "/File/" + csm.Name;
     if (string.IsNullOrEmpty(httpPostedFileBase.FileName))
         return string.Empty;
     var ext = httpPostedFileBase.FileName.Split('.').LastOrDefault() ?? "";
     var absoluteDirectory = ConvertToAbsolute(directory);
     if (!Directory.Exists(absoluteDirectory))
         Directory.CreateDirectory(absoluteDirectory);
     var temppath = string.Format("{0}/{1}", directory, string.Format("{0}.{1}", Guid.NewGuid(), ext));
     var absolutepath = ConvertToAbsolute(temppath);
     httpPostedFileBase.SaveAs(absolutepath);
     return temppath;
 }