Пример #1
0
 public static object feedback(FeedbackType type, string content, string name = "", string contact = "")
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ReportApi.Feedback(type, content, name, contact)
         .Then(() => {
             dispatcher.dispatch(new MainNavigatorPopAction());
             CustomDialogUtils.showToast("反馈成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new FeedbackSuccessAction());
         })
         .Catch(error => {
             CustomDialogUtils.showToast("发送失败", Icons.sentiment_dissatisfied);
             dispatcher.dispatch(new FeedbackFailureAction());
         });
     }));
 }
Пример #2
0
 public static object reportItem(string itemId, string itemType, string reportContext)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ReportApi.ReportItem(itemId, itemType, reportContext)
         .Then(() => {
             dispatcher.dispatch(new MainNavigatorPopAction());
             CustomDialogUtils.showToast("举报成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new ReportItemSuccessAction());
         })
         .Catch(error => {
             CustomDialogUtils.showToast("举报失败", Icons.sentiment_dissatisfied);
             dispatcher.dispatch(new ReportItemFailureAction());
             Debug.Log(error);
         });
     }));
 }
Пример #3
0
        public async Task <IActionResult> Get(DateTime?fromDate, DateTime?toDate)
        {
            if (!fromDate.HasValue || !toDate.HasValue)
            {
                if (!fromDate.HasValue)
                {
                    ModelState.AddModelError("fromDate", "Required Date is null or empty.");
                }
                if (!toDate.HasValue)
                {
                    ModelState.AddModelError("toDate", "Required Date is null or empty.");
                }
                return(new BadRequestObjectResult(ModelState));
            }

            var dateSpanDays = (toDate.Value - fromDate.Value).TotalDays + 1;

            if (dateSpanDays > 31)
            {
                ModelState.AddModelError("", "Date timespan is more than 31 days.");
                return(new BadRequestObjectResult(ModelState));
            }

            var fromDateValue = fromDate.Value;
            var toDateValue   = toDate.Value;
            var partitionId   = CurrentPartitionId;

            var report = new ReportApi
            {
                FromDate    = fromDateValue,
                ToDate      = toDateValue,
                DaysInMonth = (int)dateSpanDays,
            };

            report.GroupTaskTotals = await EntityFrameworkQueryableExtensions.ToListAsync(DbContext.TaskItems.Where(ti => ti.Task.Group.PartitionId == partitionId && ti.Time > 0 && ti.Date >= fromDateValue && ti.Date <= toDateValue)
                                                                                          .OrderBy(ti => ti.Task.Group.Name).ThenBy(ti => ti.Task.Name).GroupBy(ti => new { Group = ti.Task.Group.Name, Task = ti.Task.Name })
                                                                                          .Select(gw => new ReportGroupTaskApi
            {
                Group = gw.Key.Group,
                Task = gw.Key.Task,
                MonthTotal = gw.Sum(ti => ti.Time),
            }).AsNoTracking());

            // Ny version der udnytter grupper opdelingen...
            //var groups = DbContext.Groups.Where(g => g.PartitionId == partitionId && g.Tasks.Any(t => t.Items.Where(i => i.Date >= fromDateValue && i.Date <= toDateValue).Count() > 0));
            //report.GroupTaskTotals = groups.Select(g => new ReportGroupTaskApi
            //{
            //    Group = g.Name,
            //    Task = g.Tasks.Select(t => t.Name).FirstOrDefault(),
            //});

            report.MonthTotal = await EntityFrameworkQueryableExtensions.SumAsync(DbContext.TaskItems.Where(ti => ti.Task.Group.PartitionId == partitionId && ti.Time > 0 && ti.Date >= fromDateValue && ti.Date <= toDateValue)
                                                                                  .Select(ti => (int)ti.Time));

            report.Users = DbContext.TaskItems.Where(ti => ti.Task.Group.PartitionId == partitionId && ti.Time > 0 && ti.Date >= fromDateValue && ti.Date <= toDateValue)
                           .OrderBy(ti => ti.User.FullName).GroupBy(ti => new { ti.User })
                           .Select(gw => new ReportUserApi
            {
                Id         = gw.Key.User.Id,
                FullName   = gw.Key.User.FullName,
                GroupTasks = gw.OrderBy(ti => ti.Task.Group.Name).ThenBy(ti => ti.Task.Name).GroupBy(ti => new { Group = ti.Task.Group.Name, Task = ti.Task.Name })
                             .Select(ggw => new ReportGroupTaskApi
                {
                    Group = ggw.Key.Group,
                    Task  = ggw.Key.Task,
                    Works = ggw.GroupBy(ti => ti.Date)
                            .Select(gdw => new ReportWorkApi
                    {
                        Day  = gdw.Key.Day,
                        Time = gdw.Sum(ti => ti.Time)
                    }).OrderBy(gdw => gdw.Day).ToList(),
                    MonthTotal = ggw.Sum(ti => (int)ti.Time)
                }).ToList(),
                MonthTotal = gw.Sum(ti => ti.Time)
            }).OrderBy(iu => iu.FullName).AsNoTracking().ToList();

            return(Json(report));
        }
Пример #4
0
 public void Init()
 {
     instance = new ReportApi(new TestConfig());
 }
Пример #5
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     AlbumApi               = new AlbumApi(this);
     AnmmarApi              = new AnmmarApi(this);
     AnnouncementApi        = new AnnouncementApi(this);
     AssessmentsMessages    = new AssessmentsMessages(this);
     AttendanceApi          = new AttendanceApi(this);
     AuthorizationApi       = new AuthorizationApi(this);
     BadgeApi               = new BadgeApi(this);
     BehaviourApi           = new BehaviourApi(this);
     CalendarApi            = new CalendarApi(this);
     CertificateApi         = new CertificateApi(this);
     ClassApi               = new ClassApi(this);
     ConfigurationMangerApi = new ConfigurationMangerApi(this);
     CopyApi                 = new CopyApi(this);
     CourseApi               = new CourseApi(this);
     CourseCatalogueApi      = new CourseCatalogueApi(this);
     CourseGroupAuthors      = new CourseGroupAuthors(this);
     CourseImageApi          = new CourseImageApi(this);
     CourseRequestsApi       = new CourseRequestsApi(this);
     CoursesProgress         = new CoursesProgress(this);
     DiscussionApi           = new DiscussionApi(this);
     EduShareApi             = new EduShareApi(this);
     EvaluationApi           = new EvaluationApi(this);
     EventApi                = new EventApi(this);
     FileApi                 = new FileApi(this);
     FormsTemplatesApi       = new FormsTemplatesApi(this);
     GradeApi                = new GradeApi(this);
     GradeBookApi            = new GradeBookApi(this);
     HelpApi                 = new HelpApi(this);
     IenApi                  = new IenApi(this);
     InvitationApi           = new InvitationApi(this);
     InviteApi               = new InviteApi(this);
     LanguageApi             = new LanguageApi(this);
     LearningObjectivesApi   = new LearningObjectivesApi(this);
     LearningPathApi         = new LearningPathApi(this);
     LTILMSConsumerApi       = new LTILMSConsumerApi(this);
     MaterialApi             = new MaterialApi(this);
     MaterialSeenByUser      = new MaterialSeenByUser(this);
     MembersApi              = new MembersApi(this);
     MentorApi               = new MentorApi(this);
     NotificationsApi        = new NotificationsApi(this);
     OfferApi                = new OfferApi(this);
     Office365               = new Office365(this);
     OfficeAddInApi          = new OfficeAddInApi(this);
     Onenote                 = new Onenote(this);
     OrganizationUserAPI     = new OrganizationUserAPI(this);
     OutcomesApi             = new OutcomesApi(this);
     PointsApi               = new PointsApi(this);
     PollApi                 = new PollApi(this);
     PrerequisitesApi        = new PrerequisitesApi(this);
     QtiInteroperability     = new QtiInteroperability(this);
     QuestionBankApi         = new QuestionBankApi(this);
     ReflectionApi           = new ReflectionApi(this);
     RelatedCoursesApi       = new RelatedCoursesApi(this);
     ReportApi               = new ReportApi(this);
     RoleManagementApi       = new RoleManagementApi(this);
     ScheduleVisitApi        = new ScheduleVisitApi(this);
     SchoolTypeApi           = new SchoolTypeApi(this);
     SessionApi              = new SessionApi(this);
     SpaceApi                = new SpaceApi(this);
     StudentApi              = new StudentApi(this);
     SubjectApi              = new SubjectApi(this);
     SystemAdministrationApi = new SystemAdministrationApi(this);
     SystemReportsApi        = new SystemReportsApi(this);
     TagsApi                 = new TagsApi(this);
     Themes                  = new Themes(this);
     TimeTableApi            = new TimeTableApi(this);
     ToolConsumerProfileApi  = new ToolConsumerProfileApi(this);
     TourApi                 = new TourApi(this);
     TrackApi                = new TrackApi(this);
     TrainingPlanApi         = new TrainingPlanApi(this);
     UserApi                 = new UserApi(this);
     UserProfileApi          = new UserProfileApi(this);
     UserProgressApi         = new UserProgressApi(this);
     UserSettingsApi         = new UserSettingsApi(this);
     WallApi                 = new WallApi(this);
     BaseUri                 = new System.Uri("https://xwinji.azurewebsites.net");
     SerializationSettings   = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new  List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
Пример #6
0
        private static IEnumerable <string> CreatePdfReportHtml(Translate translate, bool showGroupColl, string organizationLogo, string organizationName, string organizationAddress, string reportTitle, string reportSubTitle, string reportText, ReportApi report)
        {
            foreach (var style in GenericCssStyles.GetDefaultInlineStyles())
            {
                yield return(style);
            }

            yield return("<html class='html'>");

            yield return("<body class='body'>");

            yield return("<div class='vertical-logo'>");

            yield return(translate.Get("REPORT.POWERED_BY") + " <span class='logo-sorting'>Sorting</span><span class='logo-time'>time</span>");

            yield return("</div>");

            yield return("<div class='container'>");

            yield return("<div class='body-content'>");

            yield return("<div class='row'>");

            yield return("    <div class='col-md-3'>");

            yield return("        <div>");

            yield return("            <div class='report-logo'>" + organizationLogo != null ? "<img src='" + organizationLogo + "' />" : "" + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("    <div class='col-md-6'>");

            yield return("        <div>");

            yield return("            <div class='report-title'>" + reportTitle + "</div>");

            yield return("        </div>");

            yield return("        <div class='default-margin'>");

            yield return("            <div class='report-sub-title'>" + reportSubTitle + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("    <div class='col-md-3'>");

            yield return("        <div>");

            yield return("            <div class='organisation-name'>" + organizationName + "</div>");

            yield return("        </div>");

            yield return("        <div class='default-margin'>");

            yield return("            <div class='organisation-address'>" + organizationAddress?.ToHtml() + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("</div>");

            yield return("<div class='row'>");

            yield return("    <div class='col-md-12'>");

            yield return("        <div class='large-margin'>");

            yield return("            <div class='report-text'>" + reportText?.ToHtml() + "</div>");

            yield return("        </div>");

            yield return("    </div>");

            yield return("</div>");

            yield return("<div class='row'>");

            yield return("<div class='col-md-12'>");

            yield return("    <table class='table'>");

            yield return("        <tbody>");

            yield return("            <tr>");

            if (showGroupColl)
            {
                yield return("            <th class='table-head'>" + translate.Get("REPORT.GROUP") + "</th>");
            }
            yield return("                <th class='table-head'>" + translate.Get("REPORT.TASK") + "</th>");

            yield return("                <th class='table-head-right'>" + translate.Get("REPORT.TIME") + (report.GroupTaskTotals.Count() > 1 ? " <small class='small'>(" + report.MonthTotal.ToTimeFormat() + ")</small>": "") + "</th>");

            yield return("            </tr>");

            foreach (var groupTaskTotal in report.GroupTaskTotals)
            {
                yield return("            <tr>");

                if (showGroupColl)
                {
                    yield return("            <td class='table-data'>" + groupTaskTotal.Group + "</td>");
                }
                yield return("                <td class='table-data'>" + groupTaskTotal.Task + "</td>");

                yield return("                <td class='table-data-right'>" + groupTaskTotal.MonthTotal.ToTimeFormat() + "</td>");

                yield return("            </tr>");
            }

            yield return("        </tbody>");

            yield return("    </table>");

            yield return("</div>");

            yield return("</div>");

            yield return("<div class='row'>");

            yield return("<div class='col-md-12'>");

            yield return("    <table class='table'>");

            yield return("        <tbody>");

            yield return("            <tr>");

            yield return("                <th class='table-head' colspan='" + (report.DaysInMonth + (showGroupColl ? 3 : 2)) + "'>" + translate.Get("REPORT.PERSON_TIME") + "</th>");

            yield return("            </tr>");

            foreach (var user in report.Users)
            {
                yield return("            <tr>");

                yield return("                <td class='table-data' colspan='" + (report.DaysInMonth + (showGroupColl ? 3 : 2)) + "'>" + user.FullName + (user.GroupTasks.Count() > 1 ? " <small class='small'>(" + user.MonthTotal.ToTimeFormat() + ")</small>" : "") + "</td>");

                yield return("            </tr>");

                yield return("            <tr class='sub-table'>");

                yield return("                <th class='sub-table-head-first' ></th>");

                if (showGroupColl)
                {
                    yield return("            <th class='sub-table-head-names1'>" + translate.Get("REPORT.GROUP") + "</th>");
                }
                yield return("                <th class='" + (showGroupColl ? "sub-table-head-names2" : "sub-table-head-names1") + "'>" + translate.Get("REPORT.TASK") + "</th>");

                for (int day = 1; day <= report.DaysInMonth; day++)
                {
                    yield return("            <th class='sub-table-head-numbers'>" + day + "</th>");
                }
                yield return("            </tr>");

                foreach (var groupTask in user.GroupTasks)
                {
                    yield return("            <tr class='sub-table'>");

                    yield return("                <td class='table-group-task-first'></td>");

                    if (showGroupColl)
                    {
                        yield return("            <td class='table-group-task-names1'>" + groupTask.Group + "</td>");
                    }
                    yield return("                <td class='" + (showGroupColl ? "table-group-task-names2" : "table-group-task-names1") + "'>" + groupTask.Task + " <small class='small'>(" + groupTask.MonthTotal.ToTimeFormat() + ")</small></td>");

                    for (int day = 1; day <= report.DaysInMonth; day++)
                    {
                        var currentWork = groupTask.Works.Where(w => w.Day == day).Select(w => w.Time).SingleOrDefault();
                        yield return("            <td class='table-group-task-time'>" + currentWork?.ToTimeFormat() + "</td>");
                    }
                    yield return("            </tr>");
                }
                yield return("            <tr>");

                yield return("                <td class='table-space-first'></td>");

                yield return("                <td class='table-space' colspan='" + (report.DaysInMonth + (showGroupColl ? 2 : 1)) + "'></td>");

                yield return("            </tr>");
            }

            yield return("        </tbody>");

            yield return("    </table>");

            yield return("</div>");

            yield return("</div>");

            yield return("</div>");

            yield return("</div>");

            yield return("</body></html>");
        }
Пример #7
0
        public async static Task <MemoryStream> CreateReportStream(Translate translate, bool showGroupColl, string organizationLogo, string organizationName, string organizationAddress, string reportTitle, string reportSubTitle, string reportText, ReportApi report)
        {
            var styles = new List <KeyValuePair <string, string> >();

            styles.AddRange(GenericCssStyles.GetDefaultStyles());
            styles.AddRange(GenericCssStyles.GetSortingtimeLogoStyles());
            styles.AddRange(GetReportHtmlStyles());

            return(await CreatePdfReportHtml(translate, showGroupColl, organizationLogo, organizationName, organizationAddress, reportTitle, reportSubTitle, reportText, report).ToHtmlStreamAddStyle(styles));
        }
 public void Init()
 {
     instance = new ReportApi();
 }