Ejemplo n.º 1
0
        /// <summary>
        /// 生成查询Div的html
        /// </summary>
        /// <returns></returns>
        public ActionResult SearchDiv()
        {
            HttpCookie cookie = GetCookie();
            var        w      = cookie.Values["week"];

            if (w == null || w == "null")
            {
                ViewBag.SelectedYearWeek = (DateTime.Now.Year * 100 + WeekHelper.GetWeekOfYear(DateTime.Now)).ToString();
            }
            else
            {
                ViewBag.SelectedYearWeek = cookie.Values["week"];
            }

            ViewBag.SelectedUserId = cookie.Values["userId"];
            var f = cookie.Values["isForeign"];

            if (f == null || f == "null")
            {
                ViewBag.SelectedIsForeign = "0";
            }
            else
            {
                ViewBag.SelectedIsForeign = cookie.Values["isForeign"];
            }

            ViewBag.YearWeek = DateTime.Now.Year * 100 + WeekHelper.GetWeekOfYear(DateTime.Now);
            UserAndWeekInfo userWeek = new UserAndWeekInfo();

            return(PartialView("_SearchDiv", userWeek));
        }
Ejemplo n.º 2
0
        public override decimal TotalUnits()
        {
            var periods = new List <Tuple <DateTime, DateTime> >();

            var startTimeWithCharge = new DateTime(StartTimeWithCharge.Year, StartTimeWithCharge.Month, StartTimeWithCharge.Day, 8, 0, 0);

            if (StartTimeWithCharge > new DateTime(StartTimeWithCharge.Year, StartTimeWithCharge.Month, StartTimeWithCharge.Day, 18, 0, 0))
            {
                // If the start time is after the end of the charge period then we move for the next day at 8 am
                startTimeWithCharge = WeekHelper.MoveNextDay(startTimeWithCharge);
            }

            while (startTimeWithCharge < EndTimeWithCharge)
            {
                if (WeekHelper.IsWeekday(startTimeWithCharge))
                {
                    //add range to end of day
                    periods.Add(Tuple.Create(startTimeWithCharge,
                                             WeekHelper.MoveToEndOfDay(startTimeWithCharge)));
                }

                // move to next day at 8 am
                startTimeWithCharge = WeekHelper.MoveNextDay(startTimeWithCharge);
            }

            return((decimal)ChargeCalculator.CalculatePeriod(periods, StartTimeWithCharge, EndTimeWithCharge));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取查询条件
        /// </summary>
        /// <returns></returns>
        public string GetSearchCondition()
        {
            string condition = " IsForeign=" + IsForeign.ToString();

            if (UserId.Trim() != "")
            {
                condition += " AND UserId='" + UserId + "' ";
            }

            if (IsOneWeek)
            {
                condition += " AND Week=" + Week.ToString();
            }
            else
            {
                if (StartDate.Trim() != "")
                {
                    DateTime start;
                    if (DateTime.TryParse(EndDate, out start))
                    {
                        condition += " AND Week >= " + WeekHelper.GetWeekOfYear(start).ToString();
                    }
                }
                if (EndDate.Trim() != "")
                {
                    DateTime end;
                    if (DateTime.TryParse(EndDate, out end))
                    {
                        condition += " AND Week <= " + WeekHelper.GetWeekOfYear(end).ToString();
                    }
                }
            }

            return(condition);
        }
Ejemplo n.º 4
0
        public FileResult Download(string id, string week, string project)
        {
            log.Info("Preview下载word");
            string tempFileName         = string.Format("{0}.docx", Guid.NewGuid().ToString());
            string absolutePath         = Path.Combine(Path.GetTempPath(), tempFileName);
            Uri    uri                  = new Uri(Request.Url.GetLeftPart(UriPartial.Authority)).Append("Preview/Index/" + id + "?week=" + week + "&project=" + HttpUtility.UrlEncode(project)); //  /" + id.ToString()
            string baseDirectory        = Directory.GetParent(Request.PhysicalApplicationPath).ToString();
            NameValueCollection headers = Request.Headers;

            try
            {
                string file = DocumentModel.Load(uri.ToString(), baseDirectory, new Identity
                {
                    Headers = headers
                }).SaveAs(absolutePath);
            }
            catch (Exception ex)
            {
                log.Error("Preview下载word出错", ex);
            }
            DateTime start, end;

            WeekHelper.GetWeekStartEnd(int.Parse(week), out start, out end);
            string downloadName = "产品周报" + start.ToString("yyyy-MM-dd") + "至" + start.ToString("yyyy-MM-dd");

            return(File(absolutePath, MimeMapping.GetMimeMapping(".docx"), downloadName + ".docx"));
        }
Ejemplo n.º 5
0
        public FileResult DownloadWordHtml(string id, string week, string project)
        {
            string absolutePath = Path.Combine(Request.PhysicalApplicationPath, "WordHtml\\" + Guid.NewGuid().ToString() + ".doc");
            //Uri uri = new Uri(Request.Url.GetLeftPart(UriPartial.Authority)).Append("Preview/WordHtml/" + id + "?week=" + week + "&project=" + HttpUtility.UrlEncode(project));
            Uri       uri    = new Uri(Request.Url.GetLeftPart(UriPartial.Authority)).Append("Preview/Index/" + id + "?week=" + week + "&project=" + HttpUtility.UrlEncode(project));
            WebClient client = new WebClient();

            client.DownloadFile(uri, absolutePath);

            DateTime start, end;

            WeekHelper.GetWeekStartEnd(int.Parse(week), out start, out end);
            string downloadName = "产品周报" + start.ToString("yyyy-MM-dd") + "至" + start.ToString("yyyy-MM-dd");

            return(File(absolutePath, MimeMapping.GetMimeMapping(".doc"), downloadName + ".doc"));
        }
Ejemplo n.º 6
0
        private HttpCookie GetCookie()
        {
            HttpCookie cookie = HttpContext.Request.Cookies["SearchInfo"];

            if (cookie == null)
            {
                cookie = new HttpCookie("SearchInfo");

                cookie.Values["week"]      = DateTime.Now.Year.ToString() + WeekHelper.GetWeekOfYear(DateTime.Now).ToString();
                cookie.Values["userId"]    = CacheFoxData.UserList.Count > 0 ? CacheFoxData.UserList[0].UserId : "";
                cookie.Values["isForeign"] = "0";
            }
            cookie.Expires = DateTime.Now.AddDays(30);
            HttpContext.Response.Cookies.Add(cookie);

            return(cookie);
        }
Ejemplo n.º 7
0
        protected void InitYear()
        {
            int year    = 2016;
            int maxYear = 2030;

            for (; year <= maxYear; year++)
            {
                DateTime firstDay = new DateTime(year, 1, 1);
                int      maxWeek  = WeekHelper.GetLastWeekNum(year);
                int      yearWeek;
                DateTime start, end;
                int      week = 1;
                yearWeek = year * 100 + week;
                WeekHelper.GetWeekStartEnd(firstDay, out start, out end);
                InsertData(yearWeek, year, week, start, end);//插入第一周
                week++;
                int addDay = 7;
                if (firstDay.DayOfWeek == DayOfWeek.Sunday) //1月1号是星期天
                {
                    firstDay = firstDay.AddDays(8);         //下一周星期一
                }
                else
                {
                    firstDay = firstDay.AddDays(addDay);
                }
                while (true)
                {
                    yearWeek = year * 100 + week;
                    WeekHelper.GetWeekStartEnd(firstDay, out start, out end);
                    InsertData(yearWeek, year, week, start, end);
                    week++;
                    firstDay = firstDay.AddDays(addDay);
                    if (firstDay.Year > year)
                    {
                        break;
                    }//如果是下一年,结束
                }
            }

            LabelMsg.Text = "生成成功";
        }
Ejemplo n.º 8
0
        public ActionResult WriteWeekly()
        {
            DateTime weekStartDate = WeekHelper.GetMondayDate();
            DateTime weekEndDate   = WeekHelper.GetSundayDate();

            string userInfoSID = Request.Cookies["userInfoSID"].Value;

            Model.UserInfo userInfo = Common.SerializeHelper.DeserializeToObject <Model.UserInfo>(MemcacheHelper.Get(userInfoSID).ToString());

            Model.Weekly weekly = weeklyService.LoadEntities(w => w.SubTime >= weekStartDate &&
                                                             w.SubTime <= weekEndDate &&
                                                             w.UserId == userInfo.ID).FirstOrDefault();


            if (weekly == null)
            {
                return(View());
            }
            //return View();
            return(RedirectToAction("Index", "Weekly"));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 对时命令
        /// </summary>
        private byte[] TimeCheck(byte[] data)
        {
            DateTime daydate  = DateTime.Now;
            string   bates01  = "93," + int.Parse(daydate.ToString("yy")).ToString("X") + "," + daydate.Month.ToString("X") + "," + daydate.Day.ToString("X") + "," + WeekHelper.ConvertDateToWeek(daydate).ToString("00") + "," + daydate.Hour.ToString("X") + "," + daydate.Minute.ToString("X") + "," + daydate.Second.ToString("X");
            string   batesstr = "7b,7b," + ByteHelper.ByteToString(ByteHelper.TenToHex(bates01)).Trim(' ').Replace(' ', ',') + "," + ByteHelper.CRC16_String(ByteHelper.TenToHex(bates01)) + ",7d,7d";

            byte[] SendData = ByteHelper.TenToHex(batesstr);//固定值
            TxtLogHelper.WriteLog("对时回复命令内容:" + batesstr, "TCP");
            ConsoleWriteLine("对时回复命令内容:" + batesstr, 1);
            return(SendData);
        }
Ejemplo n.º 10
0
        private ReportData GetReportData(string id, string week, string project)
        {
            string userId   = "";
            string yearWeek = "";

            if (string.IsNullOrEmpty(id))
            {
                HttpCookie cookie = GetCookie();
                userId   = cookie.Values["userId"];
                yearWeek = cookie.Values["week"];
                //string isForeign = cookie.Values["isForeign"];
            }
            else
            {
                userId   = id;
                yearWeek = week;
            }
            string whereCondition = " where Week=" + yearWeek;

            if (userId != "all")
            {
                whereCondition += " and UserId='" + userId + "' ";
            }
            string whereConditionNoProjectName = whereCondition;

            MySqlParameter[] parameters = null;
            if (!string.IsNullOrEmpty(project))
            {
                MySqlParameter param = new MySqlParameter("@project", MySqlDbType.VarString, 50);
                whereCondition += " and ProjectName like @project ";
                param.Value     = "%" + project.Trim() + "%";
                parameters      = new MySqlParameter[1];
                parameters[0]   = param;
            }
            string limit = " "; //" limit 0, 1000";
            int    t, p;

            ReportData report = new ReportData();

            DateTime start, end;

            WeekHelper.GetWeekStartEnd(int.Parse(yearWeek), out start, out end);
            string reportName = "产品周报_" + start.ToString("yyyyMMdd") + "-" + end.ToString("yyyyMMdd");

            if (userId == "all")
            {
                reportName += "_所有人";
            }
            else
            {
                string userName = CacheFoxData.UserList.FirstOrDefault(u => u.UserId == userId).UserName;
                reportName += "_" + userName;
            }
            if (!string.IsNullOrWhiteSpace(project))
            {
                reportName += "_项目:" + project;
            }
            else
            {
                //reportName += "_所有项目";
            }
            ViewBag.ReportTitle              = reportName;
            report.ReportName                = ""; //SqlDbHelper.GetReportName(whereCondition);
            report.ProjectInfoList           = SqlDbHelper.GetProjectInfoList(whereCondition, limit, parameters, out t, out p);
            report.SummaryTargetStrategyList = SqlDbHelper.GetSummaryTargetStrategy(whereCondition, limit, parameters, out t, out p);
            report.SummaryVersionList        = SqlDbHelper.GetSummaryVersion(whereCondition, limit, parameters, out t, out p);

            report.SummaryFeedbackList = SqlDbHelper.GetSummaryFeedback(whereConditionNoProjectName, limit, null, out t, out p);
            report.SummarySuggestList  = SqlDbHelper.GetSummarySuggest(whereConditionNoProjectName, limit, null, out t, out p);

            report.AffairProductList = SqlDbHelper.GetAffairProduct(whereConditionNoProjectName, limit, null, out t, out p);
            report.TeamworkInfoList  = SqlDbHelper.GetTeamworkInfoList(whereConditionNoProjectName, limit, null, out t, out p);
            report.AssistInfoList    = SqlDbHelper.GetAssistInfoList(whereConditionNoProjectName, limit, null, out t, out p);
            return(report);
        }