partial void DeleteHelpDesk_LastSearch(HelpDesk_LastSearch instance);
 partial void InsertHelpDesk_LastSearch(HelpDesk_LastSearch instance);
 partial void UpdateHelpDesk_LastSearch(HelpDesk_LastSearch instance);
Exemplo n.º 4
0
        private void SaveLastSearchCriteria(HelpDesk_LastSearch UpdateHelpDesk_LastSearch)
        {
            HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

            HelpDesk_LastSearch objHelpDesk_LastSearch = (from HelpDesk_LastSearches in objHelpDeskDALDataContext.HelpDesk_LastSearches
                                                                  where HelpDesk_LastSearches.PortalID == PortalId
                                                                  where HelpDesk_LastSearches.UserID == UserId
                                                                  select HelpDesk_LastSearches).FirstOrDefault();

            if (objHelpDesk_LastSearch == null)
            {
                objHelpDesk_LastSearch = new HelpDesk_LastSearch();
                objHelpDesk_LastSearch.UserID = UserId;
                objHelpDesk_LastSearch.PortalID = PortalId;
                objHelpDeskDALDataContext.HelpDesk_LastSearches.InsertOnSubmit(objHelpDesk_LastSearch);
                objHelpDeskDALDataContext.SubmitChanges();
            }

            objHelpDesk_LastSearch.AssignedRoleID = UpdateHelpDesk_LastSearch.AssignedRoleID;
            objHelpDesk_LastSearch.Categories = UpdateHelpDesk_LastSearch.Categories;
            objHelpDesk_LastSearch.CreatedDate = UpdateHelpDesk_LastSearch.CreatedDate;
            objHelpDesk_LastSearch.SearchText = UpdateHelpDesk_LastSearch.SearchText;
            objHelpDesk_LastSearch.DueDate = UpdateHelpDesk_LastSearch.DueDate;
            objHelpDesk_LastSearch.Priority = UpdateHelpDesk_LastSearch.Priority;
            objHelpDesk_LastSearch.Status = UpdateHelpDesk_LastSearch.Status;
            objHelpDesk_LastSearch.CurrentPage = UpdateHelpDesk_LastSearch.CurrentPage;
            objHelpDesk_LastSearch.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);

            objHelpDeskDALDataContext.SubmitChanges();
        }
Exemplo n.º 5
0
        private HelpDesk_LastSearch GetLastSearchCriteria()
        {
            HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

            HelpDesk_LastSearch objHelpDesk_LastSearch = (from HelpDesk_LastSearches in objHelpDeskDALDataContext.HelpDesk_LastSearches
                                                                  where HelpDesk_LastSearches.PortalID == PortalId
                                                                  where HelpDesk_LastSearches.UserID == UserId
                                                                  select HelpDesk_LastSearches).FirstOrDefault();

            if (objHelpDesk_LastSearch == null)
            {
                HelpDesk_LastSearch InsertHelpDesk_LastSearch = new HelpDesk_LastSearch();
                InsertHelpDesk_LastSearch.UserID = UserId;
                InsertHelpDesk_LastSearch.PortalID = PortalId;
                objHelpDeskDALDataContext.HelpDesk_LastSearches.InsertOnSubmit(InsertHelpDesk_LastSearch);

                // Only save is user is logged in
                if (UserId > -1)
                {
                    objHelpDeskDALDataContext.SubmitChanges();
                }

                return InsertHelpDesk_LastSearch;
            }
            else
            {
                return objHelpDesk_LastSearch;
            }
        }
Exemplo n.º 6
0
        private HelpDesk_LastSearch GetValuesFromSearchForm()
        {
            TextBox txtSearch = (TextBox)lvTasks.FindControl("txtSearch");
            DropDownList ddlStatus = (DropDownList)lvTasks.FindControl("ddlStatus");
            DropDownList ddlPriority = (DropDownList)lvTasks.FindControl("ddlPriority");
            DropDownList ddlAssigned = (DropDownList)lvTasks.FindControl("ddlAssigned");
            TextBox txtDue = (TextBox)lvTasks.FindControl("txtDue");
            TextBox txtCreated = (TextBox)lvTasks.FindControl("txtCreated");

            // Use an ExistingTasks object to pass the values to the Search method
            HelpDesk_LastSearch objHelpDesk_LastSearch = new HelpDesk_LastSearch();
            objHelpDesk_LastSearch.SearchText = (txtSearch.Text.Trim().Length == 0) ? null : txtSearch.Text.Trim();
            objHelpDesk_LastSearch.Status = (ddlStatus.SelectedValue == "All") ? null : ddlStatus.SelectedValue;
            objHelpDesk_LastSearch.AssignedRoleID = (ddlAssigned.SelectedValue == "-2") ? null : (int?)Convert.ToInt32(ddlAssigned.SelectedValue);
            objHelpDesk_LastSearch.Priority = (ddlPriority.SelectedValue == "All") ? null : ddlPriority.SelectedValue;

            // Created Date
            if (txtCreated.Text.Trim().Length > 4)
            {
                try
                {
                    DateTime dtCreated = Convert.ToDateTime(txtCreated.Text.Trim());
                    objHelpDesk_LastSearch.CreatedDate = dtCreated.AddDays(-1);
                }
                catch
                {
                    txtCreated.Text = "";
                }
            }
            else
            {
                txtCreated.Text = "";
            }

            // Due Date
            if (txtDue.Text.Trim().Length > 4)
            {
                try
                {
                    DateTime dtDue = Convert.ToDateTime(txtDue.Text.Trim());
                    objHelpDesk_LastSearch.DueDate = dtDue.AddDays(-1);
                }
                catch
                {
                    txtDue.Text = "";
                }
            }
            else
            {
                txtDue.Text = "";
            }

            // Get Category Tags
            string strCategories = GetTagsTreeExistingTasks();
            if (strCategories.Length > 0)
            {
                objHelpDesk_LastSearch.Categories = strCategories;
            }

            // Current Page
            objHelpDesk_LastSearch.CurrentPage = GetCurrentPage();

            // Page Size
            objHelpDesk_LastSearch.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);

            return objHelpDesk_LastSearch;
        }
Exemplo n.º 7
0
        protected void lvTasks_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            #region Search
            // Search
            if (e.CommandName == "Search")
            {
                HelpDesk_LastSearch objHelpDesk_LastSearch = GetValuesFromSearchForm();
                // Save Search Criteria
                SaveLastSearchCriteria(objHelpDesk_LastSearch);
                // Execute Search
                DisplayExistingTickets(SearchCriteria);
            }
            #endregion

            #region EmptyDataTemplateSearch
            //EmptyDataTemplateSearch        
            if (e.CommandName == "EmptyDataTemplateSearch")
            {
                TextBox txtSearch = (TextBox)e.Item.FindControl("txtSearch");
                DropDownList ddlStatus = (DropDownList)e.Item.FindControl("ddlStatus");
                DropDownList ddlPriority = (DropDownList)e.Item.FindControl("ddlPriority");
                DropDownList ddlAssigned = (DropDownList)e.Item.FindControl("ddlAssigned");
                TextBox txtDue = (TextBox)e.Item.FindControl("txtDue");
                TextBox txtCreated = (TextBox)e.Item.FindControl("txtCreated");

                // Use an ExistingTasks object to pass the values to the Search method
                HelpDesk_LastSearch objHelpDesk_LastSearch = new HelpDesk_LastSearch();
                objHelpDesk_LastSearch.SearchText = (txtSearch.Text.Trim().Length == 0) ? null : txtSearch.Text.Trim();
                objHelpDesk_LastSearch.Status = (ddlStatus.SelectedValue == "All") ? null : ddlStatus.SelectedValue;
                objHelpDesk_LastSearch.AssignedRoleID = (ddlAssigned.SelectedValue == "-2") ? null : (int?)Convert.ToInt32(ddlAssigned.SelectedValue);
                objHelpDesk_LastSearch.Priority = (ddlPriority.SelectedValue == "All") ? null : ddlPriority.SelectedValue;

                // Created Date
                if (txtCreated.Text.Trim().Length > 4)
                {
                    try
                    {
                        DateTime dtCreated = Convert.ToDateTime(txtCreated.Text.Trim());
                        objHelpDesk_LastSearch.CreatedDate = dtCreated.AddDays(-1);
                    }
                    catch
                    {
                        txtCreated.Text = "";
                    }
                }
                else
                {
                    txtCreated.Text = "";
                }

                // Due Date
                if (txtDue.Text.Trim().Length > 4)
                {
                    try
                    {
                        DateTime dtDue = Convert.ToDateTime(txtDue.Text.Trim());
                        objHelpDesk_LastSearch.DueDate = dtDue.AddDays(-1);
                    }
                    catch
                    {
                        txtDue.Text = "";
                    }
                }
                else
                {
                    txtDue.Text = "";
                }

                // Get Category Tags
                string strCategories = GetTagsTreeExistingTasks();
                if (strCategories.Length > 1)
                {
                    objHelpDesk_LastSearch.Categories = strCategories;
                }

                // Current Page
                objHelpDesk_LastSearch.CurrentPage = GetCurrentPage();

                // Page Size
                objHelpDesk_LastSearch.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);

                // Save Search Criteria
                SaveLastSearchCriteria(objHelpDesk_LastSearch);
                // Execute Search
                DisplayExistingTickets(SearchCriteria);
            }
            #endregion

        }
Exemplo n.º 8
0
        // Existing Tickets

        #region DisplayExistingTickets
        private void DisplayExistingTickets(HelpDesk_LastSearch objLastSearch)
        {
            string[] UsersRoles = UserInfo.Roles;
            List<int> UsersRoleIDs = new List<int>();
            string strSearchText = (objLastSearch.SearchText == null) ? "" : objLastSearch.SearchText;

            HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

            IQueryable<ExistingTasks> result = from HelpDesk_Tasks in objHelpDeskDALDataContext.HelpDesk_Tasks
                                               where HelpDesk_Tasks.PortalID == PortalId
                                               orderby HelpDesk_Tasks.CreatedDate descending
                                               select new ExistingTasks
                                               {
                                                   TaskID = HelpDesk_Tasks.TaskID,
                                                   Status = HelpDesk_Tasks.Status,
                                                   Priority = HelpDesk_Tasks.Priority,
                                                   DueDate = HelpDesk_Tasks.DueDate,
                                                   CreatedDate = HelpDesk_Tasks.CreatedDate,
                                                   Assigned = HelpDesk_Tasks.AssignedRoleID.ToString(),
                                                   Description = HelpDesk_Tasks.Description,
                                                   Requester = HelpDesk_Tasks.RequesterUserID.ToString(),
                                                   RequesterName = HelpDesk_Tasks.RequesterName
                                               };

            #region Only show users the records they should see
            // Only show users the records they should see
            if (!(UserInfo.IsInRole(GetAdminRole()) || UserInfo.IsInRole("Administrators") || UserInfo.IsSuperUser))
            {
                RoleController objRoleController = new RoleController();
				foreach (RoleInfo objRoleInfo in objRoleController.GetUserRoles(UserInfo, true))
                {
                    UsersRoleIDs.Add(objRoleInfo.RoleID);
                }

                result = from UsersRecords in result
                         where Convert.ToInt32(UsersRecords.Requester) == UserId ||
                         UsersRoleIDs.Contains(Convert.ToInt32(UsersRecords.Assigned))
                         select UsersRecords;
            }
            #endregion

            #region Filter Status
            // Filter Status
            if (objLastSearch.Status != null)
            {
                result = from Status in result
                         where Status.Status == objLastSearch.Status
                         select Status;
            }
            #endregion

            #region Filter Priority
            // Filter Priority
            if (objLastSearch.Priority != null)
            {
                result = from Priority in result
                         where Priority.Priority == objLastSearch.Priority
                         select Priority;
            }
            #endregion

            #region Filter Assigned
            // Filter Assigned
            if (objLastSearch.AssignedRoleID.HasValue)
            {
                if (!(objLastSearch.AssignedRoleID == -2))
                {
                    result = from Assigned in result
                             where Assigned.Assigned == objLastSearch.AssignedRoleID.ToString()
                             select Assigned;
                }
            }
            #endregion

            #region Filter DueDate
            // Filter DueDate
            if (objLastSearch.DueDate.HasValue)
            {
                result = from objDueDate in result
                         where objDueDate.DueDate > objLastSearch.DueDate
                         select objDueDate;
            }
            #endregion

            #region Filter CreatedDate
            // Filter CreatedDate
            if (objLastSearch.CreatedDate.HasValue)
            {
                result = from CreatedDate in result
                         where CreatedDate.CreatedDate > objLastSearch.CreatedDate
                         select CreatedDate;
            }
            #endregion

            #region Filter TextBox (Search)
            // Filter TextBox
            if (strSearchText.Trim().Length > 0)
            {
                result = (from Search in result
                          join details in objHelpDeskDALDataContext.HelpDesk_TaskDetails
                          on Search.TaskID equals details.TaskID into joined
                          from leftjoin in joined.DefaultIfEmpty()
                          where Search.Description.Contains(strSearchText) ||
                          Search.RequesterName.Contains(strSearchText) ||
                          Search.TaskID.ToString().Contains(strSearchText) ||
                          leftjoin.Description.Contains(strSearchText)
                          select Search).Distinct();
            }
            #endregion

            // Convert the results to a list because the query to filter the tags 
            // must be made after the preceeding query results have been pulled from the database
            List<ExistingTasks> FinalResult = result.Distinct().ToList();

            #region Filter Tags
            // Filter Tags
            if (objLastSearch.Categories != null)
            {
                char[] delimiterChars = { ',' };
                string[] ArrStrCategories = objLastSearch.Categories.Split(delimiterChars);
                // Convert the Categories selected from the Tags tree to an array of integers
                int[] ArrIntHelpDesk = Array.ConvertAll<string, int>(ArrStrCategories, new Converter<string, int>(ConvertStringToInt));

                // Perform a query that does in intersect between all the R7.HelpDesk selected and all the categories that each TaskID has
                // The number of values that match must equal the number of values that were selected in the Tags tree
                FinalResult = (from Categories in FinalResult.AsQueryable()
                               where ((from HelpDesk_TaskCategories in objHelpDeskDALDataContext.HelpDesk_TaskCategories
                                       where HelpDesk_TaskCategories.TaskID == Categories.TaskID
                                       select HelpDesk_TaskCategories.CategoryID).ToArray<int>()).Intersect(ArrIntHelpDesk).Count() == ArrIntHelpDesk.Length
                               select Categories).ToList();
            }
            #endregion

            #region Sort
            switch (SortExpression)
            {
                case "TaskID":
                case "TaskID ASC":
                    FinalResult = FinalResult.AsEnumerable().OrderBy(p => p.TaskID).ToList();
                    break;
                case "TaskID DESC":
                    FinalResult = FinalResult.AsEnumerable().OrderByDescending(p => p.TaskID).ToList();
                    break;
                case "Status":
                case "Status ASC":
                    FinalResult = FinalResult.AsEnumerable().OrderBy(p => p.Status).ToList();
                    break;
                case "Status DESC":
                    FinalResult = FinalResult.AsEnumerable().OrderByDescending(p => p.Status).ToList();
                    break;
                case "Priority":
                case "Priority ASC":
                    FinalResult = FinalResult.AsEnumerable().OrderBy(p => p.Priority).ToList();
                    break;
                case "Priority DESC":
                    FinalResult = FinalResult.AsEnumerable().OrderByDescending(p => p.Priority).ToList();
                    break;
                case "DueDate":
                case "DueDate ASC":
                    FinalResult = FinalResult.AsEnumerable().OrderBy(p => p.DueDate).ToList();
                    break;
                case "DueDate DESC":
                    FinalResult = FinalResult.AsEnumerable().OrderByDescending(p => p.DueDate).ToList();
                    break;
                case "CreatedDate":
                case "CreatedDate ASC":
                    FinalResult = FinalResult.AsEnumerable().OrderBy(p => p.CreatedDate).ToList();
                    break;
                case "CreatedDate DESC":
                    FinalResult = FinalResult.AsEnumerable().OrderByDescending(p => p.CreatedDate).ToList();
                    break;
                case "Assigned":
                case "Assigned ASC":
                    FinalResult = FinalResult.AsEnumerable().OrderBy(p => p.Assigned).ToList();
                    break;
                case "Assigned DESC":
                    FinalResult = FinalResult.AsEnumerable().OrderByDescending(p => p.Assigned).ToList();
                    break;
                case "Description":
                case "Description ASC":
                    FinalResult = FinalResult.AsEnumerable().OrderBy(p => p.Description).ToList();
                    break;
                case "Description DESC":
                    FinalResult = FinalResult.AsEnumerable().OrderByDescending(p => p.Description).ToList();
                    break;
                case "Requester":
                case "Requester ASC":
                    FinalResult = FinalResult.AsEnumerable().OrderBy(p => p.RequesterName).ToList();
                    break;
                case "Requester DESC":
                    FinalResult = FinalResult.AsEnumerable().OrderByDescending(p => p.RequesterName).ToList();
                    break;
            }
            #endregion

            #region Paging
            int intPageSize = (objLastSearch.PageSize != null) ? Convert.ToInt32(objLastSearch.PageSize) : Convert.ToInt32(ddlPageSize.SelectedValue);
            int intCurrentPage = (Convert.ToInt32(objLastSearch.CurrentPage) == 0) ? 1 : Convert.ToInt32(objLastSearch.CurrentPage);

            //Paging
            int intTotalPages = 1;
            int intRecords = FinalResult.Count();
            if ((intRecords > 0) && (intRecords > intPageSize))
            {
                intTotalPages = (intRecords / intPageSize);

                // If there are more records add 1 to page count
                if (intRecords % intPageSize > 0)
                {
                    intTotalPages += 1;
                }

                // If Current Page is -1 then it is intended to be set to last page
                if (intCurrentPage == -1)
                {
                    intCurrentPage = intTotalPages;
                    HelpDesk_LastSearch objHelpDesk_LastSearch = GetLastSearchCriteria();
                    objHelpDesk_LastSearch.CurrentPage = intCurrentPage;
                    SaveLastSearchCriteria(objHelpDesk_LastSearch);
                }

                // Show and hide buttons
                lnkFirst.Visible = (intCurrentPage > 1);
                lnkPrevious.Visible = (intCurrentPage > 1);
                lnkNext.Visible = (intCurrentPage != intTotalPages);
                lnkLast.Visible = (intCurrentPage != intTotalPages);
            }
            #endregion

            // If the current page is greater than the number of pages
            // reset to page one and save 
            if (intCurrentPage > intTotalPages)
            {
                intCurrentPage = 1;
                HelpDesk_LastSearch objHelpDesk_LastSearch = GetLastSearchCriteria();
                objHelpDesk_LastSearch.CurrentPage = intCurrentPage;
                SaveLastSearchCriteria(objHelpDesk_LastSearch);

                lnkPrevious.Visible = true;
            }

            // Display Records
            lvTasks.DataSource = FinalResult.Skip((intCurrentPage - 1) * intPageSize).Take(intPageSize);
            lvTasks.DataBind();

            // Display paging panel
            pnlPaging.Visible = (intTotalPages > 1);

            // Set CurrentPage
            CurrentPage = intCurrentPage.ToString();

            #region Page number list
            List<ListPage> pageList = new List<ListPage>();

            int nStartRange = intCurrentPage > 10 ? intCurrentPage - 10 : 1;
            if (intTotalPages - nStartRange < 19)
                nStartRange = intTotalPages > 19 ? intTotalPages - 19 : 1;

            for (int nPage = nStartRange; nPage < nStartRange + 20 && nPage <= intTotalPages; nPage++)
                pageList.Add(new ListPage { PageNumber = nPage });
            PagingDataList.DataSource = pageList;
            PagingDataList.DataBind();
            #endregion
        }