Example #1
0
        // GET: SalesManagement/Sale
        public ActionResult Dashboard()
        {
            DashboardDetails _details = new DashboardDetails();

            _details.InitializeSalesSetting();
            return(View());
        }
Example #2
0
        public async Task <IHttpActionResult> GetDashbaordDetails()
        {
            try
            {
                DashboardDetails dashboardDetails = new DashboardDetails();
                var userList = await userRepository.GetAllUsers();

                var bookList = await booksRepository.GetAllBooks();

                if (userList != null)
                {
                    var blockedBooks = userList.Sum(x => x.BlockedCopies);
                    dashboardDetails.RegisteredUsers   = userList.Count;
                    dashboardDetails.BlockedBooksCount = blockedBooks;
                }
                if (bookList != null)
                {
                    dashboardDetails.IssuedBooksCount = bookList.Sum(x => x.AvailableCopies);
                }
                dashboardDetails.ConfigrationValuesCount = 3;

                return(Ok(dashboardDetails));
            }
            catch (Exception e)
            {
                loggers.LogError(e);
                return(InternalServerError());
            }
        }
        public JsonResult DashboardDetails()
        {
            DashboardDetails obj = new DashboardDetails();

            CSvc = new BALCommon(ConStr);
            obj  = CSvc.GetDashboardDetails(_OrgnisationID, _Financialyearid, DateTime.Now);
            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public async Task <bool> Sendmail(string userId)
        {
            var _dashboard = (TempData["DashBoardUser"]) as string;
            DashboardDetails deserialized = JsonConvert.DeserializeObject <DashboardDetails>(_dashboard);

            TempData.Keep();
            var           _user = deserialized.users;
            var           user  = userId.Split('|');
            List <string> list  = new List <string>();

            foreach (var u in user)
            {
                if (u != "")
                {
                    var userMail = _user.Where(x => x.UserID == Int32.Parse(u)).FirstOrDefault();
                    //SendEmail(userMail.UserKey, "test");
                    list.Add(userMail.UserKey);
                }
            }
            using (HttpClient client = new HttpClient())
            {
                var token = HttpContext.Request.Headers["Authorization"];
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                string endpoint = "https://localhost:44335/Auth/sendmail";

                StringContent content = new StringContent(JsonConvert.SerializeObject(list), Encoding.UTF8, "application/json");
                using (var Response = await client.PostAsync(endpoint, content))
                {
                    if (Response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        using (HttpContent _content = Response.Content)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
Example #5
0
        public static SuperEventDetails CreateObject(PayLoad payLoad)
        {
            SuperEventDetails superEventDetail = new SuperEventDetails();

            foreach (Event _event in payLoad.Data)
            {
                if (_event.AdditionalDetails == null)
                {
                    _event.AdditionalDetails = new AdditionalDetails();
                }

                List <EventDetailHeader> gett = new List <EventDetailHeader>();

                var eventDetailHeader = new EventDetailHeader()
                {
                    EventID            = _event.EventID,
                    NextStreamPosition = payLoad.NextStreamPosition,
                    EventTimeStamp     = _event.EventTimestamp
                };

                superEventDetail.EventDetailHeaders.Add(eventDetailHeader);

                switch (_event.ObjectType)
                {
                case "SHEET":
                    var sheetDetail = new SheetDetails()
                    {
                        EventID                = _event.EventID,
                        ObjectID               = _event.ObjectID,
                        Action                 = _event.Action,
                        SourceObjectID         = _event.AdditionalDetails.SourceObjectID,
                        SourceGlobaltemplateID = _event.AdditionalDetails.SourceGlobalTemplateID,
                        SourcetemplateID       = _event.AdditionalDetails.SourceTemplateID,
                        Source                 = _event.AdditionalDetails.Source,
                        SourceType             = _event.AdditionalDetails.SourceType,
                        SheetName              = _event.AdditionalDetails.SheetName,
                        NewName                = _event.AdditionalDetails.NewName,
                        OldName                = _event.AdditionalDetails.OldName,
                        AccessLevel            = _event.AdditionalDetails.AccessLevel,
                        UserIDInitiator        = _event.AdditionalDetails.UserID,

                        GroupID               = _event.AdditionalDetails.GroupID,
                        WorkSpaceID           = _event.AdditionalDetails.WorkSpaceID,
                        OldUserID             = _event.AdditionalDetails.OldUserID,
                        OldAccessLevel        = _event.AdditionalDetails.OldAccessLevel,
                        NewUserID             = _event.AdditionalDetails.NewUserID,
                        NewAccessLevel        = _event.AdditionalDetails.NewAccessLevel,
                        RecipientEmail        = _event.AdditionalDetails.RecipientEmail,
                        RecipientGroupID      = _event.AdditionalDetails.RecipientGroupID,
                        FormatType            = _event.AdditionalDetails.FormatType,
                        RowCount              = _event.AdditionalDetails.RowCount,
                        IncludeAttachments    = _event.AdditionalDetails.IncludeAttachments,
                        IncludeDiscussions    = _event.AdditionalDetails.IncludeDiscussions,
                        SourceSheetID         = _event.AdditionalDetails.SourceSheetID,
                        DestinationSheetID    = _event.AdditionalDetails.DestinationSheetID,
                        RowsMoved             = _event.AdditionalDetails.RowsMoved,
                        RowsCopied            = _event.AdditionalDetails.RowsCopied,
                        CelllinkSourceSheetID = _event.AdditionalDetails.CelllinkSourceSheetID,
                        NewParentContainerID  = _event.AdditionalDetails.NewParentContainerID,
                        ParentContainerID     = _event.AdditionalDetails.ParentContainerID,
                        FolderName            = _event.AdditionalDetails.FolderName,
                        RequestUserID         = _event.AdditionalDetails.RequestUserID,
                        SendCompletionEmail   = _event.AdditionalDetails.SendCompletionEmail,
                        UserIDImpacted        = _event.AdditionalDetails.UserIDImpacted,
                        EventTimestamp        = _event.AdditionalDetails.EventTimeStamp
                    };
                    superEventDetail.SheetDetails.Add(sheetDetail);
                    break;

                case "REPORT":
                    var reportDetail = new ReportDetails()
                    {
                        EventID  = _event.EventID,
                        ObjectID = _event.ObjectID,
                        Action   = _event.Action,

                        ReportName             = _event.AdditionalDetails.ReportName,
                        SourceObjectID         = _event.AdditionalDetails.SourceObjectID,
                        SourceGlobaltemplateID = _event.AdditionalDetails.SourceGlobalTemplateID,
                        SourceType             = _event.AdditionalDetails.SourceType,
                        NewName              = _event.AdditionalDetails.NewName,
                        OldName              = _event.AdditionalDetails.OldName,
                        AccessLevel          = _event.AdditionalDetails.AccessLevel,
                        UserID               = _event.AdditionalDetails.UserID,
                        GroupID              = _event.AdditionalDetails.GroupID,
                        WorkSpaceID          = _event.AdditionalDetails.WorkSpaceID,
                        OldUserID            = _event.AdditionalDetails.OldUserID,
                        OldAccessLevel       = _event.AdditionalDetails.OldAccessLevel,
                        NewUserID            = _event.AdditionalDetails.NewUserID,
                        NewAccessLevel       = _event.AdditionalDetails.NewAccessLevel,
                        NewParentContainerID = _event.AdditionalDetails.NewParentContainerID,
                        ParentContainerID    = _event.AdditionalDetails.ParentContainerID,
                        FolderName           = _event.AdditionalDetails.FolderName,
                        RecipientEmail       = _event.AdditionalDetails.RecipientEmail,
                        RecipientGroupID     = _event.AdditionalDetails.RecipientGroupID,
                        FormatType           = _event.AdditionalDetails.FormatType,
                        UserIDImpacted       = _event.AdditionalDetails.UserIDImpacted,
                        UserIDInitiator      = _event.UserID,
                        EventTimestamp       = _event.EventTimestamp,
                        RequestUserID        = _event.RequestUserID,
                        Source               = _event.Source
                    };

                    superEventDetail.ReportDetails.Add(reportDetail);
                    break;

                case "ATTACHMENT":
                    var attachmentDetail = new AttachmentDetails()
                    {
                        EventID               = _event.EventID,
                        ObjectID              = _event.ObjectID,
                        Action                = _event.Action,
                        SheetID               = _event.AdditionalDetails.SheetID,
                        WorkSpaceID           = _event.AdditionalDetails.WorkSpaceID,
                        AttachmentName        = _event.AdditionalDetails.AttachmentName,
                        MultifileDownloadname = _event.AdditionalDetails.MultifileDownloadName,
                        RecipientEmail        = _event.AdditionalDetails.RecipientEmail,
                        RecipientGroupID      = _event.AdditionalDetails.RecipientGroupID,
                        UserIDInitiator       = _event.UserID,
                        EventTimestamp        = _event.EventTimestamp,
                        RequestUserID         = _event.RequestUserID,
                        Source                = _event.Source,
                    };
                    superEventDetail.AttachmentDetails.Add(attachmentDetail);
                    break;

                case "USER":
                    var userDetail = new UserDetails()
                    {
                        EventID         = _event.EventID,
                        ObjectID        = _event.ObjectID,
                        Action          = _event.Action,
                        UserTypes       = _event.AdditionalDetails.UserTypes,
                        EmailAddress    = _event.AdditionalDetails.EmailAddress,
                        DeclineReason   = _event.AdditionalDetails.DeclineReason,
                        OldownerUserID  = _event.AdditionalDetails.OldOwnerUserID,
                        NewownerUserID  = _event.AdditionalDetails.NewOwnerUserID,
                        UserIDInitiator = _event.UserID,
                        EventTimestamp  = _event.EventTimestamp,
                        RequestUserID   = _event.RequestUserID,
                        Source          = _event.Source,
                    };
                    superEventDetail.UserDetails.Add(userDetail);
                    break;

                case "DISCUSSION":
                    var discussionDetail = new DiscussionDetails()
                    {
                        EventID            = _event.EventID,
                        ObjectID           = _event.ObjectID,
                        Action             = _event.Action,
                        SheetRowID         = _event.AdditionalDetails.SheetRowID,
                        SheetID            = _event.AdditionalDetails.SheetID,
                        WorkSpaceID        = _event.AdditionalDetails.WorkSpaceID,
                        RecipientEmail     = _event.AdditionalDetails.RecipientEmail,
                        RecipientGroupID   = _event.AdditionalDetails.RecipientGroupID,
                        IncludeAttachments = _event.AdditionalDetails.IncludeAttachments,
                        UserIDInitiator    = _event.UserID,
                        EventTimestamp     = _event.EventTimestamp,
                        RequestUserID      = _event.RequestUserID,
                        Source             = _event.Source,
                    };
                    superEventDetail.DiscussionDetails.Add(discussionDetail);
                    break;

                case "DASHBOARD":
                    var dashboardDetail = new DashboardDetails()
                    {
                        EventID                = _event.EventID,
                        ObjectID               = _event.ObjectID,
                        Action                 = _event.Action,
                        DashboardName          = _event.AdditionalDetails.DashboardName,
                        SourceGlobalTemplateID = _event.AdditionalDetails.SourceGlobalTemplateID,
                        SourceObjectID         = _event.AdditionalDetails.SourceObjectID,
                        SourceType             = _event.AdditionalDetails.SourceType,
                        AccessibleBy           = _event.AdditionalDetails.AccessibleBy,
                        PublishType            = _event.AdditionalDetails.PublishType,
                        PublishFormat          = _event.AdditionalDetails.PublishFormat,
                        AccessLevel            = _event.AdditionalDetails.AccessLevel,
                        UserID                 = _event.AdditionalDetails.UserID,
                        GroupID                = _event.AdditionalDetails.GroupID,
                        WorkspaceID            = _event.AdditionalDetails.WorkSpaceID,
                        OldUserID              = _event.AdditionalDetails.OldUserID,
                        OldAccessLevel         = _event.AdditionalDetails.OldAccessLevel,
                        NewUserID              = _event.AdditionalDetails.NewUserID,
                        NewAccessLevel         = _event.AdditionalDetails.NewAccessLevel,
                        NewparentContainerID   = _event.AdditionalDetails.NewParentContainerID,
                        ParentContainerID      = _event.AdditionalDetails.ParentContainerID,
                        FolderName             = _event.AdditionalDetails.FolderName,
                        OldName                = _event.AdditionalDetails.OldName,
                        NewName                = _event.AdditionalDetails.NewName,
                        UserIDInitiator        = _event.UserID,
                        EventTimestamp         = _event.EventTimestamp,
                        RequestUserID          = _event.RequestUserID,
                        Source                 = _event.Source,
                    };
                    superEventDetail.DashboardDetails.Add(dashboardDetail);
                    break;

                case "FOLDER":
                    var folderDetail = new FolderDetails()
                    {
                        EventID             = _event.EventID,
                        ObjectID            = _event.ObjectID,
                        Action              = _event.Action,
                        FolderName          = _event.AdditionalDetails.FolderName,
                        SourceFolderID      = _event.AdditionalDetails.SourceFolderID,
                        OldName             = _event.AdditionalDetails.OldName,
                        NewName             = _event.AdditionalDetails.NewName,
                        SendCompletionEmail = _event.AdditionalDetails.SendCompletionEmail,
                        IncludeAttachments  = _event.AdditionalDetails.IncludeAttachments,
                        FormatType          = _event.AdditionalDetails.FormatType,
                        UserIDInitiator     = _event.UserID,
                        EventTimestamp      = _event.EventTimestamp,
                        RequestUserID       = _event.RequestUserID,
                        Source              = _event.Source,
                    };
                    superEventDetail.FolderDetails.Add(folderDetail);
                    break;

                case "FORM":
                    var formDetail = new FormDetails()
                    {
                        EventID         = _event.EventID,
                        ObjectID        = _event.ObjectID,
                        Action          = _event.Action,
                        FormName        = _event.AdditionalDetails.FolderName,
                        SheetID         = _event.AdditionalDetails.SheetID,
                        UserIDInitiator = _event.UserID,
                        EventTimestamp  = _event.EventTimestamp,
                        RequestUserID   = _event.RequestUserID,
                        Source          = _event.Source,
                    };
                    superEventDetail.FormDetails.Add(formDetail);
                    break;

                case "UPDATE REQUEST":
                    var updateRequestDetail = new UpdateRequestDetails()
                    {
                        EventID            = _event.EventID,
                        ObjectID           = _event.ObjectID,
                        Action             = _event.Action,
                        SheetID            = _event.AdditionalDetails.SheetID,
                        RowCounts          = _event.AdditionalDetails.RowCount.ToString(),
                        IncludeAttachments = _event.AdditionalDetails.IncludeAttachments,
                        IncludeDiscussions = _event.AdditionalDetails.IncludeDiscussions,
                        UserIDInitiator    = _event.UserID,
                        EventTimestamp     = _event.EventTimestamp,
                        RequestUserID      = _event.RequestUserID,
                        Source             = _event.Source,
                    };
                    superEventDetail.UpdateRequestDetails.Add(updateRequestDetail);
                    break;

                case "WORKSPACE":
                    var workspaceDetail = new WorkSpaceDetails()
                    {
                        EventID             = _event.EventID,
                        ObjectID            = _event.ObjectID,
                        Action              = _event.Action,
                        OldName             = _event.AdditionalDetails.OldName,
                        NewName             = _event.AdditionalDetails.NewName,
                        AccessLevel         = _event.AdditionalDetails.AccessLevel,
                        UserID              = _event.AdditionalDetails.UserID,
                        GroupID             = _event.AdditionalDetails.GroupID,
                        IncludeAttachments  = _event.AdditionalDetails.IncludeAttachments,
                        SendCompletionEmail = _event.AdditionalDetails.SendCompletionEmail,
                        FormatType          = _event.AdditionalDetails.FormatType,
                        UserIDInitiator     = _event.UserID,
                        EventTimestamp      = _event.EventTimestamp,
                        RequestUserID       = _event.RequestUserID,
                        Source              = _event.Source,
                    };
                    superEventDetail.WorkSpaceDetails.Add(workspaceDetail);
                    break;

                case "ACCESSTOKEN":
                    var accessTokenDetails = new AccessTokenDetails()
                    {
                        EventID                  = _event.EventID,
                        ObjectID                 = _event.ObjectID,
                        Action                   = _event.Action,
                        TokenName                = _event.AdditionalDetails.TokenName,
                        TokenDisplayValue        = _event.AdditionalDetails.TokenDisplayValue,
                        TokenExpirationTimestamp = _event.AdditionalDetails.TokenExpirationTimestamp,
                        AccessScopes             = _event.AdditionalDetails.AccessScopes,
                        AppClientID              = _event.AdditionalDetails.AppClientID,
                        AppName                  = _event.AdditionalDetails.AppName,
                        TokenUserID              = _event.AdditionalDetails.TokenUserID,
                        UserIDInitiator          = _event.UserID,
                        EventTimestamp           = _event.EventTimestamp,
                        RequestUserID            = _event.RequestUserID,
                        Source                   = _event.Source,
                    };
                    superEventDetail.AccessTokenDetails.Add(accessTokenDetails);
                    break;

                case "ACCOUNT":
                    var accountDetails = new AccountDetails()
                    {
                        EventID          = _event.EventID,
                        ObjectID         = _event.ObjectID,
                        Action           = _event.Action,
                        NewContactUserID = _event.AdditionalDetails.NewContactUserID,
                        OldContactUserID = _event.AdditionalDetails.OldContactUserID,
                        NewName          = _event.AdditionalDetails.NewName,
                        OldName          = _event.AdditionalDetails.OldName,
                        UserIDInitiator  = _event.UserID,
                        EventTimestamp   = _event.EventTimestamp,
                        RequestUserID    = _event.RequestUserID,
                        Source           = _event.Source,
                    };
                    superEventDetail.AccountDetails.Add(accountDetails);
                    break;

                case "GROUP":
                    var groupDetails = new GroupDetails()
                    {
                        EventID         = _event.EventID,
                        ObjectID        = _event.ObjectID,
                        Action          = _event.Action,
                        GroupName       = _event.AdditionalDetails.GroupName,
                        OldName         = _event.AdditionalDetails.OldName,
                        NewName         = _event.AdditionalDetails.NewName,
                        OldownerUserID  = _event.AdditionalDetails.OldOwnerUserID,
                        NewownerUserID  = _event.AdditionalDetails.NewOwnerUserID,
                        MemberUserID    = _event.AdditionalDetails.MemberUserID,
                        UserIDInitiator = _event.UserID,
                        EventTimestamp  = _event.EventTimestamp,
                        RequestUserID   = _event.RequestUserID,
                        Source          = _event.Source,
                    };
                    superEventDetail.GroupDetails.Add(groupDetails);
                    break;
                }
            }
            return(superEventDetail);
        }
Example #6
0
        public async Task <string> DashboardDetails(string currentMonth)
        {
            try
            {
                ViewBag.Iscalled = 2;
                string csv         = "";
                string csvdata     = "";
                Month  myEnum      = (Month)Enum.Parse(typeof(Month), currentMonth);
                var    monthNumber = (int)myEnum;
                monthNumber           = monthNumber + 1;
                ViewBag.SelectedMonth = monthNumber;
                string strMonthNumber = "";
                if (monthNumber < 10)
                {
                    strMonthNumber = "0" + monthNumber.ToString();
                }
                else
                {
                    strMonthNumber = monthNumber.ToString();
                }
                string month   = "-" + strMonthNumber + "-" + DateTime.Today.Year.ToString();
                var    content = (TempData["user"]) as string;
                TempData.Keep();
                User _user = JsonConvert.DeserializeObject <User>(content);
                using (HttpClient client = new HttpClient())
                {
                    var token = HttpContext.Request.Headers["Authorization"];

                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                    string endpoint = "https://localhost:44335/Auth/Dashboard/" + monthNumber.ToString();

                    int days = DateTime.DaysInMonth(DateTime.Today.Year, monthNumber);

                    ViewBag.Current = month;
                    using (var Response = await client.GetAsync(endpoint))
                    {
                        if (Response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            using (HttpContent _content = Response.Content)
                            {
                                Task <string>    result       = _content.ReadAsStringAsync();
                                string           _dashboard   = result.Result.Replace("result", "users");
                                DashboardDetails deserialized = JsonConvert.DeserializeObject <DashboardDetails>(_dashboard);

                                //_user = deserialized.result;
                                //TempData["user"] = JsonConvert.SerializeObject(_user);
                                //ViewBag.Name = _user.firstName + " " + _user.lastName;

                                var holiday = GetHolidayForMonth(monthNumber);
                                var users   = deserialized.users;
                                TempData["DashBoardUser"] = _dashboard;

                                int    trcolorcount = 1;
                                string trcolor      = "background-color: lemonchiffon;";
                                string color        = "";
                                string table        = "";
                                string head         = "<tr><th></th><th>Name</th><th style='display:none'></th>";
                                csv = "Name,";
                                for (int k = 1; k <= days; k++)
                                {
                                    if (k < 10)
                                    {
                                        head = head + "<th>0" + k + "</th>";
                                        csv  = csv + "0" + k + ",";
                                    }
                                    else
                                    {
                                        head = head + "<th>" + k + "</th>";
                                        csv  = csv + k + ",";
                                    }
                                }
                                head = head + "<th>BurnedEffort</th><th>ActualEffort</th><th>PendingHours</th></tr >";
                                csv  = csv + "BurnedEffort,ActualEffort,PendingHours" + Environment.NewLine;
                                foreach (var user in users)
                                {
                                    if ((trcolorcount % 2) == 0)
                                    {
                                        color = trcolor;
                                    }
                                    else
                                    {
                                        color = "background-color: white;";
                                    }
                                    trcolorcount++;
                                    table   = table + "<tr style='" + color + "'><td><input type='checkbox' class='form-check' /></td><td>" + user.Username + "</td><td style='display: none'>" + user.UserID + "</td>";
                                    csvdata = csvdata + user.Username + ",";
                                    var     time        = user.timeEntries;
                                    decimal totalHours  = 0;
                                    decimal burnedHours = 0;
                                    decimal leaveHours  = 0;
                                    for (var i = 1; i <= days; i++)
                                    {
                                        string day = "";
                                        if (i < 10)
                                        {
                                            day = "0" + i.ToString() + month;
                                        }
                                        else
                                        {
                                            day = i.ToString() + month;
                                        }
                                        var entry  = time.Where(x => x.date.ToShortDateString() == day).FirstOrDefault();
                                        var offday = Convert.ToDateTime(day);
                                        if (holiday.Result.Where(x => x == i).Any())
                                        {
                                            table   = table + "<td style='color:red'>H</td>";
                                            csvdata = csvdata + "Holiday,";
                                            continue;
                                        }
                                        if (offday.DayOfWeek == DayOfWeek.Saturday)
                                        {
                                            table   = table + "<td style='color:red'>Sa</td>";
                                            csvdata = csvdata + "Saturday,";
                                        }
                                        else if (offday.DayOfWeek == DayOfWeek.Sunday)
                                        {
                                            table   = table + "<td style='color:red'>Su</td>";
                                            csvdata = csvdata + "Sunday,";
                                        }
                                        else
                                        {
                                            totalHours = totalHours + Convert.ToDecimal(6.5);
                                            if (entry != null)
                                            {
                                                if (entry.IsOff == false)
                                                {
                                                    burnedHours = burnedHours + entry.hours;
                                                    //if (_user.isAdmin == false)
                                                    //    table = table + "<td onclick='ShowModal(" + user.UserID + "," + i.ToString() + ")'>" + entry.hours + "</td>";
                                                    //else
                                                    table   = table + "<td>" + entry.hours + "</td>";
                                                    csvdata = csvdata + entry.hours + ",";
                                                }
                                                else
                                                {
                                                    if (entry.IsHalfday)
                                                    {
                                                        table       = table + "<td>" + entry.hours + "</td>";
                                                        leaveHours  = leaveHours + Convert.ToDecimal(3.25);
                                                        burnedHours = burnedHours + Convert.ToDecimal(3.25);
                                                        csvdata     = csvdata + entry.hours + ",";
                                                    }
                                                    else
                                                    {
                                                        table      = table + "<td>L</td>";
                                                        csvdata    = csvdata + "Leave,";
                                                        leaveHours = leaveHours + Convert.ToDecimal(6.5);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (_user.isAdmin == false)
                                                {
                                                    table = table + "<td onclick='ShowModal(" + user.UserID + "," + i + ")'>0</td>";
                                                }
                                                else
                                                {
                                                    table = table + "<td>0</td>";
                                                }
                                                csvdata = csvdata + "0,";
                                            }
                                        }
                                    }
                                    var pending = totalHours - (burnedHours + leaveHours);
                                    table   = table = table + "<td>" + burnedHours + "/" + leaveHours + "</td><td>" + totalHours.ToString() + "</td><td>" + pending + "</td>";
                                    table   = table + "</tr>";
                                    csvdata = csvdata + burnedHours + "/" + leaveHours + "," + totalHours.ToString() + Environment.NewLine;
                                }
                                TempData["Download"] = csv + csvdata;
                                return(table + "|" + head);
                            }

                            //return result;
                        }
                        else if (Response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                        {
                            return("404");
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Example #7
0
        public JsonResult GetSalesStatusChartData(int Days)
        {
            DashboardDetails _details = new DashboardDetails();

            return(Json(_details.GetSalesStatusData(Days), JsonRequestBehavior.AllowGet));
        }
        internal static appData GetMachineConnectData(DateTime dateVal)
        {
            SqlConnection conn             = ConnectionManager.GetConnection();
            DataTable     dt               = new DataTable();
            DataTable     dtMachine        = new DataTable();
            DataTable     dtDashboard      = new DataTable();
            DataTable     dtPartCount      = new DataTable();
            DataTable     dtTimes          = new DataTable();
            DataTable     dtStoppages      = new DataTable();
            DataTable     dtAlarmsDatails  = new DataTable();
            DataTable     dtAlarmsSummary  = new DataTable();
            DataTable     dtAlarmsSolution = new DataTable();

            appData appData = new appData();

            appData.Shifts         = new List <Shift>();
            appData.PlantMachine   = new List <PlantMachines>();
            appData.AlarmsSolution = new List <AlarmSolution>();
            var ss = dateVal.ToString("yyyy-MM-dd");

            try
            {
                var cmd = new SqlCommand("[dbo].[FocasWeb_ViewShift&HourwiseSummary]", conn);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 120;
                cmd.Parameters.AddWithValue("@Date", dateVal.ToString("yyyy-MM-dd"));//dateVal);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        int   shiftId = 0;
                        Shift shift   = new Shift();
                        if (int.TryParse(rdr["ShiftID"].ToString(), out shiftId))
                        {
                            shift.ShiftId = shiftId;
                        }
                        shift.ShiftName = rdr["ShiftName"].ToString();
                        appData.Shifts.Add(shift);
                    }
                    rdr.NextResult();
                    while (rdr.Read())
                    {
                        int           plantId       = 0;
                        PlantMachines plantMachines = new PlantMachines();
                        if (int.TryParse(rdr["PlantCode"].ToString(), out plantId))
                        {
                            plantMachines.PlantID = plantId;
                        }
                        plantMachines.PlantName = rdr["Plantid"].ToString();
                        appData.PlantMachine.Add(plantMachines);
                    }
                    rdr.NextResult();

                    //--MachineInformation---
                    dtMachine.Load(rdr);
                    //---Dashboard Information-----
                    dtDashboard.Load(rdr);
                    //-----PartCount Information---
                    dtPartCount.Load(rdr);

                    dtTimes.Load(rdr);

                    dtStoppages.Load(rdr);

                    dtAlarmsDatails.Load(rdr);

                    dtAlarmsSummary.Load(rdr);

                    //dtAlarmsSolution.Load(rdr);

                    if (dtMachine.Rows.Count > 0)
                    {
                        for (int i = 0; i < appData.PlantMachine.Count; i++)
                        {
                            appData.PlantMachine[i].Machines = new List <Machine>();
                            foreach (DataRow item in dtMachine.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "'"))
                            {
                                int     machineId = 0;
                                Machine machine   = new Machine();
                                if (int.TryParse(item["MCInterface"].ToString(), out machineId))
                                {
                                    machine.MachineID = machineId;//Convert.ToInt32(item["MCInterface"].ToString());
                                }
                                machine.MachineName = item["MachineId"].ToString();
                                machine.LastProgram = item["RunningPart"].ToString();
                                machine.Downtime    = item["Stoppages"].ToString();
                                machine.Status      = item["McStatus"].ToString();
                                machine.Color       = item["color"].ToString();
                                if (int.TryParse(item["PartsCount"].ToString(), out machineId))
                                {
                                    machine.PartsCount = machineId;// int.Parse(item["PartsCount"].ToString());
                                }
                                machine.MachineMTB = item["MachineMTB"].ToString().ToUpper();

                                appData.PlantMachine[i].Machines.Add(machine);
                            }
                        }

                        appData.appDataList = new List <AppDataList>();
                        AppDataList appdataDay = new AppDataList();
                        appdataDay.Key     = dateVal.ToString("yyyy-MM-dd");
                        appdataDay.DayData = new List <DayData>();

                        for (int i = 0; i < appData.PlantMachine.Count; i++)
                        {
                            foreach (Machine item in appData.PlantMachine[i].Machines)
                            {
                                DayData dayData1 = new DayData();
                                dayData1.DataDate    = DateTime.Now.Date;
                                dayData1.MachineID   = item.MachineID;
                                dayData1.MachineName = item.MachineName;
                                dayData1.PlantID     = appData.PlantMachine[i].PlantID;
                                dayData1.PlantName   = appData.PlantMachine[i].PlantName;

                                dayData1.PartsCountData     = new List <PartsCountData>();
                                dayData1.PartCountChartData = new List <PartCountChartData>();

                                dayData1.TimesData      = new List <TimesData>();
                                dayData1.TimesChartData = new List <TimesChartData>();

                                dayData1.StoppagesData = new List <StoppagesData>();
                                dayData1.AlarmsDetails = new List <AlarmData>();
                                dayData1.AlarmsSummary = new List <AlarmData>();

                                dayData1.DashboardData = new DashboardData();
                                dayData1.DashboardData.DashboardDetails = new List <DashboardDetails>();
                                foreach (DataRow item1 in dtDashboard.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "'"))
                                {
                                    DashboardDetails dashboardDetails = new DashboardDetails();
                                    dashboardDetails.NavId         = item1["NavID"].ToString();
                                    dashboardDetails.ColHeaderText = item1["DisplayName"].ToString();

                                    dashboardDetails.ShiftData = new List <string>();
                                    foreach (var shifts in appData.Shifts)
                                    {
                                        dashboardDetails.ShiftData.Add(item1[shifts.ShiftName].ToString());
                                    }

                                    //dashboardDetails.ShiftData.Add(item1["A"].ToString());
                                    //dashboardDetails.ShiftData.Add(item1["B"].ToString());
                                    //dashboardDetails.ShiftData.Add(item1["C"].ToString());


                                    if (item1["NavID"].ToString().Equals("menu.partsCount", StringComparison.OrdinalIgnoreCase))
                                    {
                                        dayData1.DashboardData.PartCount = item1["DayValue"].ToString();
                                    }
                                    else if (item1["NavID"].ToString().Equals("menu.downtime", StringComparison.OrdinalIgnoreCase))
                                    {
                                        dayData1.DashboardData.DownTime = item1["DayValue"].ToString();
                                    }
                                    dayData1.DashboardData.DashboardDetails.Add(dashboardDetails);
                                }

                                dayData1.PartsCountData = new List <PartsCountData>();

                                //for each shift and machine fill the part count data
                                foreach (Shift shift in appData.Shifts)
                                {
                                    PartsCountData     partCountData      = new PartsCountData();
                                    PartCountChartData partCountChartData = new PartCountChartData();
                                    partCountData.ShiftId   = partCountChartData.ShiftId = shift.ShiftId;
                                    partCountData.ShiftName = partCountChartData.ShiftName = shift.ShiftName;

                                    partCountData.details        = new List <PartsCountDetails>();
                                    partCountChartData.ChartData = new Chart <PartsCountSeries>();

                                    partCountChartData.ChartData.categories = new List <string>();
                                    partCountChartData.ChartData.series     = new List <PartsCountSeries>();

                                    var datarow = dtPartCount.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId);

                                    //----for part count chart----START--
                                    List <string> programs = datarow.Select(r => r["ProgramID"].ToString()).Distinct().ToList();
                                    programs.Remove("");
                                    List <int> id = datarow.Select(rr => Convert.ToInt32(rr["HourID"].ToString())).Distinct().ToList();
                                    foreach (string prog in programs)
                                    {
                                        List <int> dataSeries = new List <int>();
                                        id.ForEach(o => dataSeries.Add(0));//dataSeries.Add(int.MinValue));

                                        PartsCountSeries prog1 = new PartsCountSeries()
                                        {
                                            name = prog, data = dataSeries
                                        };
                                        partCountChartData.ChartData.series.Add(prog1);
                                        foreach (DataRow row in datarow.Where(r => r["ProgramID"].ToString() == prog))
                                        {
                                            int hourId = Int32.Parse(row["HourID"].ToString()) - 1;
                                            dataSeries[hourId] = Int32.Parse(row["PartCount"].ToString());
                                        }
                                    }
                                    //----for part count chart----END--
                                    foreach (DataRow item1 in datarow)
                                    {
                                        PartsCountDetails partShift = new PartsCountDetails();
                                        partShift.HourText   = Convert.ToDateTime(item1["HourStart"].ToString()).ToString("htt").ToLower() + "-" + Convert.ToDateTime(item1["HourEnd"].ToString()).ToString("htt").ToLower();
                                        partShift.Program    = item1["ProgramID"].ToString();
                                        partShift.PartsCount = item1["PartCount"].ToString();
                                        partCountData.details.Add(partShift);

                                        //----for part count chart------
                                        if (partCountChartData.ChartData.categories.Contains(partShift.HourText) == false)
                                        {
                                            partCountChartData.ChartData.categories.Add(partShift.HourText);
                                        }
                                    }
                                    dayData1.PartsCountData.Add(partCountData);
                                    dayData1.PartCountChartData.Add(partCountChartData);
                                }

                                dayData1.TimesData = new List <TimesData>();
                                //for each shift and machine fill the times data
                                foreach (Shift shift in appData.Shifts)
                                {
                                    TimesData      timeData  = new TimesData();
                                    TimesChartData timeChart = new TimesChartData();
                                    timeData.ShiftId   = timeChart.ShiftId = shift.ShiftId;
                                    timeData.ShiftName = timeChart.ShiftName = shift.ShiftName;

                                    timeData.details = new List <TimesDetails>();

                                    timeChart.ChartData = new Chart <TimeDataSeries>();
                                    TimeDataSeries power = new TimeDataSeries()
                                    {
                                        name = "Power On Time", data = new List <int>()
                                    };
                                    TimeDataSeries operating = new TimeDataSeries()
                                    {
                                        name = "Operating Time", data = new List <int>()
                                    };
                                    TimeDataSeries cutting = new TimeDataSeries()
                                    {
                                        name = "CuttingTime", data = new List <int>()
                                    };

                                    timeChart.ChartData.categories = new List <string>();
                                    timeChart.ChartData.series     = new List <TimeDataSeries>();
                                    timeChart.ChartData.series.Add(power);
                                    timeChart.ChartData.series.Add(operating);
                                    timeChart.ChartData.series.Add(cutting);



                                    foreach (DataRow item1 in dtTimes.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId))
                                    {
                                        TimesDetails timeShift = new TimesDetails();

                                        timeShift.HourText = Convert.ToDateTime(item1["HourStart"].ToString()).ToString("htt").ToLower() + "-" + Convert.ToDateTime(item1["HourEnd"].ToString()).ToString("htt").ToLower();

                                        timeShift.PowerNo   = item1["PowerOntime"].ToString();
                                        timeShift.Operating = item1["OperatingTime"].ToString();
                                        timeShift.Cutting   = item1["CuttingTime"].ToString();
                                        timeData.TotalPOT   = item1["TotalPOT"].ToString();
                                        timeData.TotalOT    = item1["TotalOT"].ToString();
                                        timeData.TotalCT    = item1["TotalCT"].ToString();
                                        timeData.details.Add(timeShift);

                                        //for chart
                                        timeChart.ChartData.categories.Add(timeShift.HourText);
                                        power.data.Add(int.Parse(item1["PowerOntimeInt"].ToString()));
                                        operating.data.Add(int.Parse(item1["OperatingTimeInt"].ToString()));
                                        cutting.data.Add(int.Parse(item1["CuttingTimeInt"].ToString()));
                                    }
                                    dayData1.TimesData.Add(timeData);
                                    dayData1.TimesChartData.Add(timeChart);
                                }

                                dayData1.StoppagesData = new List <StoppagesData>();
                                //for each shift and machine fill the stoppages data
                                foreach (Shift shift in appData.Shifts)
                                {
                                    StoppagesData stoppageData = new StoppagesData();
                                    stoppageData.ShiftId   = shift.ShiftId;
                                    stoppageData.ShiftName = shift.ShiftName;
                                    stoppageData.details   = new List <StoppagesDetails>();
                                    foreach (DataRow item1 in dtStoppages.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId))
                                    {
                                        StoppagesDetails stoppageShift = new StoppagesDetails();
                                        if (string.IsNullOrEmpty(item1["BatchStart"].ToString()))
                                        {
                                            stoppageShift.Fromtime = null;// Convert.ToDateTime(item1["BatchStart"].ToString());
                                        }
                                        else
                                        {
                                            stoppageShift.Fromtime = Convert.ToDateTime(item1["BatchStart"].ToString());
                                        }
                                        if (string.IsNullOrEmpty(item1["BatchEnd"].ToString()))
                                        {
                                            stoppageShift.ToTime = null;// Convert.ToDateTime(item1["BatchEnd"].ToString());
                                        }
                                        else
                                        {
                                            stoppageShift.ToTime = Convert.ToDateTime(item1["BatchEnd"].ToString());
                                        }
                                        stoppageShift.Duration = item1["Stoppagetime"].ToString();
                                        stoppageData.details.Add(stoppageShift);
                                    }
                                    dayData1.StoppagesData.Add(stoppageData);
                                }

                                //-----for each Alarm Details--------------------
                                foreach (Shift shift in appData.Shifts)
                                {
                                    AlarmData alarmData = new AlarmData();
                                    alarmData.ShiftId   = shift.ShiftId;
                                    alarmData.ShiftName = shift.ShiftName;
                                    alarmData.details   = new List <AlarmDetails>();
                                    foreach (DataRow item1 in dtAlarmsDatails.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId))
                                    {
                                        int          alarm        = 0;
                                        AlarmDetails alarmDetails = new AlarmDetails();
                                        if (int.TryParse(item1["AlarmNo"].ToString(), out alarm))
                                        {
                                            alarmDetails.alarmNo = alarm;
                                        }
                                        if (string.IsNullOrEmpty(item1["Fromtime"].ToString()))
                                        {
                                            alarmDetails.StartTime = null;// Convert.ToDateTime(item1["Fromtime"].ToString());
                                        }
                                        else
                                        {
                                            alarmDetails.StartTime = Convert.ToDateTime(item1["Fromtime"].ToString());
                                        }

                                        if (string.IsNullOrEmpty(item1["Totime"].ToString()))
                                        {
                                            alarmDetails.EndTime = null;// Convert.ToDateTime(item1["Totime"].ToString());
                                        }
                                        else
                                        {
                                            alarmDetails.EndTime = Convert.ToDateTime(item1["Totime"].ToString());
                                        }
                                        alarmDetails.Duration = item1["Duration"].ToString();
                                        alarmDetails.Message  = item1["AlarmMSG"].ToString();
                                        if (int.TryParse(item1["Shiftcount"].ToString(), out alarm))
                                        {
                                            alarmData.shiftCount = alarm;
                                        }
                                        alarmData.TotalDuration = item1["Totalduration"].ToString();
                                        alarmData.details.Add(alarmDetails);
                                    }
                                    dayData1.AlarmsDetails.Add(alarmData);
                                }
                                //---for each Alarm Summary--------------
                                foreach (Shift shift in appData.Shifts)
                                {
                                    AlarmData alarmData = new AlarmData();
                                    alarmData.ShiftId   = shift.ShiftId;
                                    alarmData.ShiftName = shift.ShiftName;
                                    alarmData.details   = new List <AlarmDetails>();
                                    foreach (DataRow item1 in dtAlarmsSummary.Select("PlantID = '" + appData.PlantMachine[i].PlantName + "' AND Machineid = '" + item.MachineName + "' AND Shiftid = " + shift.ShiftId))
                                    {
                                        int          alarm        = 0;
                                        AlarmDetails alarmDetails = new AlarmDetails();
                                        if (int.TryParse(item1["AlarmNo"].ToString(), out alarm))
                                        {
                                            alarmDetails.alarmNo = alarm;
                                        }
                                        if (string.IsNullOrEmpty(item1["Lastseen"].ToString()))
                                        {
                                            alarmDetails.LastSeen = null;// Convert.ToDateTime(item1["Lastseen"].ToString());
                                        }
                                        else
                                        {
                                            alarmDetails.LastSeen = Convert.ToDateTime(item1["Lastseen"].ToString());
                                        }
                                        alarmDetails.Message = item1["AlarmMSG"].ToString();
                                        if (int.TryParse(item1["NoOfOccurences"].ToString(), out alarm))
                                        {
                                            alarmDetails.NoOfOcc = alarm;
                                        }
                                        alarmData.details.Add(alarmDetails);
                                    }
                                    dayData1.AlarmsSummary.Add(alarmData);
                                }
                                appdataDay.DayData.Add(dayData1);
                            }
                        }
                        appData.appDataList.Add(appdataDay);
                    }
                    //if (dtAlarmsSolution.Columns.Count > 0)
                    //{
                    //    foreach (DataRow item in dtAlarmsSolution.Rows)
                    //    {
                    //        int slNo = 0;
                    //        AlarmSolution alarmSolution = new AlarmSolution();
                    //        if (int.TryParse(item["Slno"].ToString(), out slNo))
                    //            alarmSolution.SlNo = slNo;
                    //        if (int.TryParse(item["AlarmNo"].ToString(), out slNo))
                    //            alarmSolution.AlarmNo = slNo;
                    //        alarmSolution.ImageName = item["FilePath"].ToString();
                    //        alarmSolution.Description = item["Description"].ToString();
                    //        alarmSolution.Cause = item["Cause"].ToString();
                    //        alarmSolution.Solution = item["Solution"].ToString();
                    //        alarmSolution.MTB = item["MTB"].ToString().ToUpper();
                    //        appData.AlarmsSolution.Add(alarmSolution);
                    //    }
                    //}
                }
                if (!rdr.IsClosed)
                {
                    rdr.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.ToString());
            }

            finally
            {
                conn.Close();
            }
            return(appData);
        }
Example #9
0
        /// <summary>
        /// Maps the dashboard details data.
        /// </summary>
        /// <param name="alertAndMessageDetails">The alert and message details.</param>
        /// <param name="embarkStats">The embark stats.</param>
        /// <returns>
        /// dashboard details
        /// </returns>
        private static DashboardDetails MapDashboardDetailsData(AlertsAndMessagesDetail alertAndMessageDetails, EmbarkationStatistics embarkStats)
        {
            var dashboardDetails = new DashboardDetails();
            dashboardDetails.AlertAndMessageDetail = alertAndMessageDetails;
            dashboardDetails.EmbarkationStatistics = embarkStats;

            return dashboardDetails;
        }