当前位置: 首页>>代码示例>>C#>>正文


C# Users.ToString方法代码示例

本文整理汇总了C#中Users.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Users.ToString方法的具体用法?C# Users.ToString怎么用?C# Users.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Users的用法示例。


在下文中一共展示了Users.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: exportHours

        public static string exportHours(Users.StudentWorker Student, Schedule.Shift payPeriod)
        {
            if (!File.Exists(TEMPLATE_FOLDER + "\\" + "monthly_sheet.html"))
                throw new ExportException("Monthly template file does not exist!");

            string[] templateLines;
            try
            {
                templateLines = File.ReadAllLines(TEMPLATE_FOLDER + "\\" + "monthly_sheet.html");
            }

            catch (Exception E)
            {
                throw new ExportException("Could not open template file - " + E.Message);
            }

            var sb = new StringBuilder(String.Join(Environment.NewLine, templateLines));

            // YAY FUN HARDCODED PEDANTIC STUFF!
            sb.Replace("{STUDENT_NAME}", Student.ToString());
            sb.Replace("{STUDENT_ID}", Student.ID.ToString());
            sb.Replace("{PAY_PERIOD}", payPeriod.shiftStart.ToString("MM/dd/yy") + " - " + payPeriod.shiftEnd.ToString("MM/dd/yy"));
            sb.Replace("{DEPARTMENT}", "Career Services - Student Worker");

            DateTime weekLabel = new DateTime(payPeriod.shiftStart.Year, payPeriod.shiftStart.Month, payPeriod.shiftStart.Day, 0, 0, 0);
            DateTime shiftEnd = new DateTime(payPeriod.shiftEnd.Year, payPeriod.shiftEnd.Month, payPeriod.shiftEnd.Day, 23, 59, 59);
            DateTime weekStart = new DateTime(payPeriod.shiftStart.Year, payPeriod.shiftStart.Month, 1, 0, 0, 0);
            weekStart = weekStart.AddDays(((int)DayOfWeek.Monday - (int)weekStart.DayOfWeek));

            double payPeriodTotalHours = 0;
            double weeklyHours = 0;

            for (int i = 1; i < 6; i++)
            {

                sb.Replace("{WEEK_" + i + "}", weekStart.Month + "/" + weekStart.Day);
                weekStart = weekStart.AddDays(7);

                Schedule.WorkWeek curWeek = null;
                Student.weeksWorked.TryGetValue(Schedule.WorkWeek.workWeekID(weekLabel), out curWeek);
                weekLabel = weekLabel.AddDays(7);

                int j = 1;
                if ((int)weekLabel.DayOfWeek != 1 && i == 1)
                    j = (int)weekLabel.DayOfWeek;

                if (j > 1)
                    for (int k = 1; k < j; k++)
                        sb.Replace(String.Format("{{{0}_{1}}}", ((DayOfWeek)(k)).ToString().ToUpper(), i), "");

                for (; j < 6; j++)
                {
                    if (curWeek == null)
                    {
                        var test = (String.Format("{{{0}_{1}}}", ((DayOfWeek)(j)).ToString().ToUpper(), i));
                        sb.Replace(test, "");
                    }
                    else
                    {
                        var curDay = curWeek.shiftsOnDay((DayOfWeek)j);
                        if (curDay.Count == 0 || curDay[0].shiftStart > shiftEnd /* weekLabel.AddDays(-7).AddDays(j) > shiftEnd*/)
                            sb.Replace(String.Format("{{{0}_{1}}}", ((DayOfWeek)(j)).ToString().ToUpper(), i), "");
                        else
                        {
                            StringBuilder dayBuild = new StringBuilder();
                            foreach (Schedule.Shift s in curDay)
                            {
                                dayBuild.Append(s.shiftStart.ToString("h:mmt").ToLower() + " - " + s.shiftEnd.ToString("h:mmt").ToLower() + "<br/>");
                                weeklyHours += s.timeWorked.TotalHours;
                            }
                            sb.Replace(String.Format("{{{0}_{1}}}", ((DayOfWeek)(j)).ToString().ToUpper(), i), dayBuild.ToString());
                        }
                    }
                }

                if (curWeek != null)
                {
                    sb.Replace("{TOTAL_" + i + "}", Math.Round(weeklyHours, 1).ToString());
                    payPeriodTotalHours += weeklyHours;
                    weeklyHours = 0;
                }
                else
                    sb.Replace("{TOTAL_" + i + "}", "0");
            }
            sb.Replace("{TOT_HRS}", Math.Round(payPeriodTotalHours, 2).ToString());

            string fileName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(payPeriod.shiftStart.Month) + "_" + payPeriod.shiftStart.Year;
            return saveExport(fileName, Student.userName, sb.ToString());
        }
开发者ID:RaidMax,项目名称:TLog,代码行数:89,代码来源:Export.cs


注:本文中的Users.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。