Hi guys,
I want to share getdata concept by accessing WCF.
My ViewModel is MonthlyReportDto.
public class MonthlyReportDto
{
public int Month { get; set; }
public int Year { get; set; }
public int NewWorkOrder { get; set; }
{
public int Month { get; set; }
public int Year { get; set; }
public int NewWorkOrder { get; set; }
public int Goal { get; set; }
public int MonthlyClosedWO { get; set; }
}
public MonthlyReportDto[] getMonthlyData_noPM(int? categoryId)
{
List<MonthlyReportDto> rep = new List<MonthlyReportDto>();
{
List<MonthlyReportDto> rep = new List<MonthlyReportDto>();
DateTime currdate;
currdate = DateTime.Now;
currdate = DateTime.Now;
int firstmonth = currdate.AddMonths(-36).Month; //Data for 3 years
int firstyear = currdate.AddMonths(-36).Year;
int[] chkMonthfirst = new int[(12 - firstmonth)+1];
int ix = 0;
for (int m = firstmonth; m <= 12; m++)
{
chkMonthfirst[ix] = m;
ix++;
}
int[] chkMonth = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
int firstyear = currdate.AddMonths(-36).Year;
int[] chkMonthfirst = new int[(12 - firstmonth)+1];
int ix = 0;
for (int m = firstmonth; m <= 12; m++)
{
chkMonthfirst[ix] = m;
ix++;
}
int[] chkMonth = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
int currentMonth = currdate.Month;
int currentYear = currdate.Year;
int currentYear = currdate.Year;
// get first year and increment by 1 till i am on current year
List<int> totalyear = new List<int>();
for (int i = firstyear; i <= currentYear; i++)
{
totalyear.Add(i);
for (int i = firstyear; i <= currentYear; i++)
{
totalyear.Add(i);
}
foreach (var t in totalyear)
{
{
if (t == firstyear)
{
foreach (var m in chkMonthfirst)
{
//calculates the total days in a month
int days = DateTime.DaysInMonth(t, m);
{
foreach (var m in chkMonthfirst)
{
//calculates the total days in a month
int days = DateTime.DaysInMonth(t, m);
//gives the enddate for a month
string dateString = m + "/" + days + "/" + t + " 11:59:59 PM";
DateTime currentDate = DateTime.ParseExact(dateString, "M/d/yyyy h:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture); //DateTime.Parse( DateTime.Parse(m + "/" + days + "/" + t + " 11:59:59 PM");
DateTime currentDate = DateTime.ParseExact(dateString, "M/d/yyyy h:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture); //DateTime.Parse( DateTime.Parse(m + "/" + days + "/" + t + " 11:59:59 PM");
var goal = db.goal.Where(c => c.Month == m && c.Year == t).FirstOrDefault();
MonthlyReportDto r = new MonthlyReportDto();
// select all workorders closed in that month and year
#region
r.MonthlyClosedWO = db.fac_generalwork_request.Where(c => c.Status == "CLOSED" && c.ClosedDate.Value.Month == m && c.ClosedDate.Value.Year == t && c.PreventiveMaintenance == "N").Count();
//r.TotalOpenWorkOrder = db.fac_generalwork_request.Where(c => c.SubmittedDate.Value <= currentDate && c.Status != "CLOSED" && c.PreventiveMaintenance == "N").Count();
r.TotalOpenWorkOrder = db.fac_generalwork_request.Where(c => c.SubmittedDate.Value <= currentDate && c.PreventiveMaintenance == "N").ToList()
.Where(c => currentDate < Convert.ToDateTime(c.ClosedDate) || c.Status != "CLOSED").Count();
//r.TotalOpenWorkOrder = db.fac_generalwork_request.Where(c => c.SubmittedDate.Value <= currentDate && c.Status != "CLOSED" && c.PreventiveMaintenance == "N").Count();
r.TotalOpenWorkOrder = db.fac_generalwork_request.Where(c => c.SubmittedDate.Value <= currentDate && c.PreventiveMaintenance == "N").ToList()
.Where(c => currentDate < Convert.ToDateTime(c.ClosedDate) || c.Status != "CLOSED").Count();
r.NewWorkOrder = db.fac_generalwork_request.Where(c => c.SubmittedDate.Value.Month == m && c.SubmittedDate.Value.Year == t && c.PreventiveMaintenance == "N").Count();
#endregion
#endregion
r.Month = m;
r.Goal = goal == null ? 0 : goal.GoalNumber.Value;
r.Year = t;
r.Goal = goal == null ? 0 : goal.GoalNumber.Value;
r.Year = t;
if (r.Month == 1)
r.mont = "Jan";
else if (r.Month == 2)
r.mont = "Feb";
else if (r.Month == 3)
r.mont = "Mar";
else if (r.Month == 4)
r.mont = "Apr";
else if (r.Month == 5)
r.mont = "May";
else if (r.Month == 6)
r.mont = "Jun";
else if (r.Month == 7)
r.mont = "July";
else if (r.Month == 8)
r.mont = "Aug";
else if (r.Month == 9)
r.mont = "Sep";
else if (r.Month == 10)
r.mont = "Oct";
else if (r.Month == 11)
r.mont = "Nov";
else if (r.Month == 12)
r.mont = "Dec";
r.mont = "Jan";
else if (r.Month == 2)
r.mont = "Feb";
else if (r.Month == 3)
r.mont = "Mar";
else if (r.Month == 4)
r.mont = "Apr";
else if (r.Month == 5)
r.mont = "May";
else if (r.Month == 6)
r.mont = "Jun";
else if (r.Month == 7)
r.mont = "July";
else if (r.Month == 8)
r.mont = "Aug";
else if (r.Month == 9)
r.mont = "Sep";
else if (r.Month == 10)
r.mont = "Oct";
else if (r.Month == 11)
r.mont = "Nov";
else if (r.Month == 12)
r.mont = "Dec";
r.yearandmonth = r.mont + " " + r.Year;
rep.Add(r);
rep.Add(r);
}
}
}
return rep.ToArray();
}
}
}
return rep.ToArray();
}
Then push your chart control.
No comments:
Post a Comment