public ActionResult queryData(string startTime, string endTime) { Response.ContentType = "application/json"; JObject result = new JObject(); JObject obj = new JObject(); DateTime?startTimeDate = null; DateTime?endTimeDate = null; if (string.IsNullOrEmpty(startTime)) { startTimeDate = DateTime.Now.AddDays(-30); } else if (startTime.Length == 8) { startTimeDate = DateTime.Parse( $"{startTime.Substring(0, 4)}-{startTime.Substring(4, 2)}-{startTime.Substring(6, 2)}"); } else { obj.Add("success", false); obj.Add("msg", "日期格式错误,请重新输入"); result.Add("result", obj); return(Content(result.ToString())); } if (string.IsNullOrEmpty(endTime)) { endTimeDate = DateTime.Now; } else if (endTime.Length == 8) { endTimeDate = DateTime.Parse($"{endTime.Substring(0, 4)}-{endTime.Substring(4, 2)}-{endTime.Substring(6, 2)}") .AddDays(1); } else { obj.Add("success", false); obj.Add("msg", "日期格式错误,请重新输入"); result.Add("result", obj); return(Content(result.ToString())); } var choices = choiceService.GetChoiceByTime(startTimeDate.Value, endTimeDate.Value); var dict = areaExtendParamsService.GetAreaDict(); JArray array = new JArray(); foreach (var q in choices) { DisplayChoice display = DisplayChoice.GetDisplayChoiceFromNormakChoice(q); Console.WriteLine(q.Id); display.FirstChoice = dict[q.FirstChoice]; array.Add(JObject.FromObject(display)); } return(Content(array.ToString())); }
public ActionResult queryDataToExcel(string startTime, string endTime, string fileName) { JObject result = new JObject(); JObject obj = new JObject(); DateTime?startTimeDate = null; DateTime?endTimeDate = null; if (string.IsNullOrEmpty(startTime)) { startTimeDate = DateTime.Now.AddDays(-30); } else if (startTime.Length == 8) { startTimeDate = DateTime.Parse( $"{startTime.Substring(0, 4)}-{startTime.Substring(4, 2)}-{startTime.Substring(6, 2)}"); } else { obj.Add("success", false); obj.Add("msg", "日期格式错误,请重新输入"); result.Add("result", obj); return(Content(result.ToString())); } if (string.IsNullOrEmpty(endTime)) { endTimeDate = DateTime.Now; } else if (endTime.Length == 8) { endTimeDate = DateTime.Parse($"{endTime.Substring(0, 4)}-{endTime.Substring(4, 2)}-{endTime.Substring(6, 2)}") .AddDays(1); } else { obj.Add("success", false); obj.Add("msg", "日期格式错误,请重新输入"); result.Add("result", obj); return(Content(result.ToString())); } var choices = choiceService.GetChoiceByTime(startTimeDate.Value, endTimeDate.Value); var dict = areaExtendParamsService.GetAreaDict(); JArray array = new JArray(); StringBuilder builder = new StringBuilder(); builder.Append("<table border='1' cellspacing='0' cellpadding='0'>"); builder.Append("<thead><th>时间</th><th>用户名</th><th>区域</th><th>楼层</th><th>房屋结构</th><th>是否专业设计</th><th>施工质量</th><th>建造年代</th><th>输出结果</th><th>来源</th></thead>"); foreach (var q in choices) { DisplayChoice display = DisplayChoice.GetDisplayChoiceFromNormakChoice(q); Console.WriteLine(q.Id); display.FirstChoice = dict[q.FirstChoice]; builder.Append("<tr><td>"); builder.Append(display.DisplayCreateDate); builder.Append("</td><td>"); builder.Append(display.DisplayUserName); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.FirstChoice); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.Address); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.DisplaySecondChoice); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.DisplayThirdChoice); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.DisplayForthChoice); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.DisplayFifthChoice); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.DisplaySixth); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.DisplayMinorResult); builder.Append("</td>"); builder.Append("<td>"); builder.Append(display.DisplayFromType); builder.Append("</td></tr>"); } builder.Append("</tbody>"); builder.Append("</table>"); byte[] fileContents = Encoding.GetEncoding("GB2312").GetBytes(builder.ToString()); return(File(fileContents, "application/vnd.ms-excel", fileName)); }
public Bitmap Construct(out Dictionary <string, RectangleF> Borders) { if (serviceObjectNew) { serviceObjectNew = false; } else { die("This object has been used. Dispose this, create and use a new Service object."); } var theCloudBitmap = new Bitmap(width, height); var gImage = Graphics.FromImage(theCloudBitmap); gImage.TextRenderingHint = TextRenderingHint.AntiAlias; Center = new PointF(theCloudBitmap.Width / 2f, theCloudBitmap.Height / 2f); if (Angle != 0) { gImage.Rotate(Center, Angle); } weightSpan = highestWeight - lowestWeight; if (MaximumFontSize < MinimumFontSize) { die("MaximumFontSize is less than MinimumFontSize"); } fontHeightSpan = MaximumFontSize - MinimumFontSize; gImage.Clear(ColorChoice.GetBackGroundColor()); foreach (var tag in tagsSorted) { var fontToApply = new Font(SelectedFont, CalculateFontSize(tag.Value)); var stringBounds = gImage.MeasureString(tag.Key, fontToApply); var format = DisplayChoice.GetFormat(); var isVertical = format.FormatFlags.HasFlag(StringFormatFlags.DirectionVertical); if (isVertical) { var stringWidth = stringBounds.Width; stringBounds.Width = stringBounds.Height; stringBounds.Height = stringWidth; } var topLeft = CalculateWhere(stringBounds); /* Strategy chosen display format, failed to be placed */ if (topLeft.Equals(spiralEndSentinel)) { WordsSkipped.Add(tag.Key, tag.Value); continue; } var textCenter = isVertical & VerticalTextRight ? new PointF(topLeft.X + (stringBounds.Width / 2f), topLeft.Y + (stringBounds.Height / 2f)) : topLeft; var currentBrush = new SolidBrush(ColorChoice.GetCurrentColor()); if (isVertical & VerticalTextRight) { gImage.Rotate(textCenter, -180); } gImage.DrawString(tag.Key, fontToApply, currentBrush, topLeft, format); if (isVertical & VerticalTextRight) { gImage.Rotate(textCenter, 180); } if (ShowWordBoundaries) { gImage.DrawRectangle(new Pen(currentBrush), topLeft.X, topLeft.Y, stringBounds.Width, stringBounds.Height); } Occupied.Add(new RectangleF(topLeft, stringBounds)); } gImage.Dispose(); Occupied.RemoveRange(0, 4); if (Crop) { theCloudBitmap = CropAndTranslate(theCloudBitmap); } Borders = Occupied .Zip(tagsSorted.Keys.Where(word => !WordsSkipped.ContainsKey(word)), (rect, tag) => new { rect, tag }) .ToDictionary(x => x.tag, x => x.rect); return(theCloudBitmap); }