2016-08-02 11 views
1

私はチケットダッシュボードを作成しました。私は管理者アカウントでログインした後、2つのチケット要約を表示します。 1つは「あなたのチケット要約」で、もう1つは「すべてのチケット要約」です。今、私は管理者アカウントに他のアカウントのチケットの要約(例えばthis)を見せたいと思っていますが、チケットダッシュボードに追加する方法がわかりません。果樹園に新しいチケットサマリーを追加するには?

答えて

1

あなたは以前の投稿のコメントとして質問したと思います!しかしとにかく、

そうするいくつかのアプローチがあります。 Orchard Collaborationはウィジェットを使用して、チケットサマリー(ユーザーと管理者の両方)を表します。メインロジックは、モジュール/ Orchard.CRM.Core/DriversのDashboardDriverにあります。

private DriverResult DisplayDetail(DashboardPart part, dynamic shapeHelper) 
    { 
     if (this.services.WorkContext.CurrentUser == null) 
     { 
      return null; 
     } 

     var contentQuery = this.services.ContentManager.HqlQuery().ForVersion(VersionOptions.Published); 
     var statusRecords = this.basicDataService.GetStatusRecords().OrderBy(c => c.OrderId).ToList(); 

     DashboardViewModel model = new DashboardViewModel(); 
     model.CurrentUserId = this.services.WorkContext.CurrentUser.Id; 
     model.IsCustomer = this.crmContentOwnershipService.IsCurrentUserCustomer(); 
     model.IsOperator = this.services.Authorizer.Authorize(Permissions.OperatorPermission); 
     dynamic state = new JObject(); 

     // Query items created by customer 
     if (model.IsCustomer) 
     { 
      // Ticket contentType 
      state.ContentTypes = "Ticket"; 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, "Content", "ContentTypes", state); 

      state.RequestingUser_Id = model.CurrentUserId.ToString(CultureInfo.InvariantCulture); 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, TicketFieldsFilter.CategoryName, TicketFieldsFilter.RequestingUserType, state); 

      var userTicketsCountByStateIds = groupQuery.GetCount(contentQuery, "TicketPartRecord", "StatusRecord.Id"); 

      model.CurrentUserRequestingTickets = new Collection<dynamic>(); 
      CRMHelper.AddStatusGroupRecordsToModel(statusRecords, userTicketsCountByStateIds, model.CurrentUserRequestingTickets); 

      // overrude items of current users 
      state.MaxDueDate = DateTime.UtcNow.Date; 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, TicketFieldsFilter.CategoryName, TicketFieldsFilter.TicketDueDateType, state); 
      model.CurrentUserOverrudeRequestingTicketCount = contentQuery.Count(); 
     } 

     // Query the counts of the current user tickets group by stateId 
     // ******************************************************* 
     if (model.IsOperator) 
     { 
      // Ticket contentType 
      state.ContentTypes = "Ticket"; 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, "Content", "ContentTypes", state); 

      dynamic temp = new 
      { 
       Users = new int[] { model.CurrentUserId }, 
       Teams = new int[] { }, 
       BusinessUnits = new int[] { }, 
       AccessType = ContentItemPermissionAccessTypes.Assignee 
      }; 

      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, ContentItemPermissionFilter.CategoryName, ContentItemPermissionFilter.AnySelectedUserTeamBusinessUnit, temp); 

      var userTicketsCountByStateIds = groupQuery.GetCount(contentQuery, "TicketPartRecord", "StatusRecord.Id"); 

      model.CurrentUserTickets = new Collection<dynamic>(); 
      CRMHelper.AddStatusGroupRecordsToModel(statusRecords, userTicketsCountByStateIds, model.CurrentUserTickets); 

      // overrude items of current users 
      state.MaxDueDate = DateTime.UtcNow.Date; 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, TicketFieldsFilter.CategoryName, TicketFieldsFilter.TicketDueDateType, state); 
      model.CurrentUserOverrudeItemsCount = contentQuery.Count(); 
      //******************************************************* 
     } 

     bool isAdmin = this.services.Authorizer.Authorize(Permissions.AdvancedOperatorPermission); 

     if (isAdmin) 
     { 
      // Query the counts of the whole tickets in the system based on stateId 
      state = new JObject(); 

      contentQuery = this.services.ContentManager.HqlQuery().ForVersion(VersionOptions.Published); 

      state.ContentTypes = "Ticket"; 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, "Content", "ContentTypes", state); 
      var ticketCountsByStateIds = groupQuery.GetCount(contentQuery, "TicketPartRecord", "StatusRecord.Id"); 

      model.AllTickets = new Collection<dynamic>(); 
      CRMHelper.AddStatusGroupRecordsToModel(statusRecords, ticketCountsByStateIds, model.AllTickets); 

      state.MaxDueDate = DateTime.UtcNow.Date; 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, TicketFieldsFilter.CategoryName, TicketFieldsFilter.TicketDueDateType, state); 
      model.AllOverrudeItemsCount = contentQuery.Count(); 
     } 

     // get items without any owner 
     contentQuery = this.services.ContentManager.HqlQuery().ForVersion(VersionOptions.Published); 
     state.ContentTypes = "Ticket"; 
     contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, "Content", "ContentTypes", state); 
     contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, ContentItemPermissionFilter.CategoryName, "ContentItemPermissionPartRecord.ItemsWithoutAnyOwner", state); 
     model.AllItemsWithoutOwnerCount = contentQuery.Count(); 

     // get overrude items count 

     // display 
     // 1) Number of your open, new, in progress, and closed tickets 
     // 2) number of the unassigned, new, open, in progress and closed tickets in the system. 
     return ContentShape("Parts_Dashboard", 
      () => shapeHelper.Parts_Dashboard(
       Model: model 
       )); 
    } 

新しいウィジェットを作成する必要があります。 DashboardDriverは、ログインしたユーザーのチケットと、すべてのチケットの概要を表します。新しいウィジェットでは、ユーザーのサマリーチケットのみを表すことができます。新しいウィジェットにはUserIdプロパティが必要で、ログインしたユーザーの代わりにそのユーザーのチケット要約を表します。このようなもの:

 private DriverResult DisplayDetail(NewUserDashboardPart part, dynamic shapeHelper) 
    { 
     if (this.services.WorkContext.CurrentUser == null) 
     { 
      return null; 
     } 

     var contentQuery = this.services.ContentManager.HqlQuery().ForVersion(VersionOptions.Published); 
     var statusRecords = this.basicDataService.GetStatusRecords().OrderBy(c => c.OrderId).ToList(); 

     DashboardViewModel model = new DashboardViewModel(); 
     model.CurrentUserId = NewUserDashboardPart.UserId; 
     dynamic state = new JObject(); 

     // Query the counts of the current user tickets group by stateId 
     // ******************************************************* 
      // Ticket contentType 
      state.ContentTypes = "Ticket"; 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, "Content", "ContentTypes", state); 

      dynamic temp = new 
      { 
       Users = new int[] { model.CurrentUserId }, 
       Teams = new int[] { }, 
       BusinessUnits = new int[] { }, 
       AccessType = ContentItemPermissionAccessTypes.Assignee 
      }; 

      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, ContentItemPermissionFilter.CategoryName, ContentItemPermissionFilter.AnySelectedUserTeamBusinessUnit, temp); 

      var userTicketsCountByStateIds = groupQuery.GetCount(contentQuery, "TicketPartRecord", "StatusRecord.Id"); 

      model.CurrentUserTickets = new Collection<dynamic>(); 
      CRMHelper.AddStatusGroupRecordsToModel(statusRecords, userTicketsCountByStateIds, model.CurrentUserTickets); 

      // overrude items of current users 
      state.MaxDueDate = DateTime.UtcNow.Date; 
      contentQuery = this.projectionManagerWithDynamicSort.ApplyFilter(contentQuery, TicketFieldsFilter.CategoryName, TicketFieldsFilter.TicketDueDateType, state); 
      model.CurrentUserOverrudeItemsCount = contentQuery.Count(); 
      //******************************************************* 

     // display 
     // 1) Number of your open, new, in progress, and closed tickets 
     // 2) number of the unassigned, new, open, in progress and closed tickets in the system. 
     return ContentShape("Parts_Dashboard", 
      () => shapeHelper.Parts_Dashboard(
       Model: model 
       )); 
    } 
関連する問題