private string ExportStock() { try { var para = HttpContext.Current.Request.Params; string EventId = FormatParamValue(para["eventId"]); string searchSql = FormatParamValue(para["SearchOptionValue"]).Trim(); DataTable dataExport = new DataTable(); WEventUserMappingBLL wEventUserMappingBLL = new WEventUserMappingBLL(this.CurrentUserInfo); QuesQuestionsBLL quesQuestionsBLL = new QuesQuestionsBLL(this.CurrentUserInfo); dataExport = wEventUserMappingBLL.SearchEventUserList(EventId, searchSql).Tables[0]; //var service = new LEventSignUpBLL(loggingSessionInfo); //GetResponseParams<LEventSignUpEntity> dataList = service.GetEventApplies(para["eventId"] ?? "", 0, 10000); //IList<LEventSignUpEntity> data2 = new List<LEventSignUpEntity>(); int dataTotalCount = 0; var data2 = dataExport.Rows; dataTotalCount = dataExport.Rows.Count; IList <List <string> > source = new List <List <string> >(); for (var i = 0; i < dataExport.Rows.Count; i++) { var tmpHt = new List <string>(); var dr = dataExport.Rows[i]; for (var c = 1; c < dataExport.Columns.Count; c++) { tmpHt.Add(dr[c] == null ? "" : dr[c].ToString()); } source.Add(tmpHt); } if (source == null || source.Count == 0) { return(string.Empty); } var fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + _random.Next(1, 100).ToString() + ".xls"; var full_path = ExportDir + fileName; var sw = new FileStream(full_path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); var Writer = new StreamWriter(sw, System.Text.Encoding.UTF8); System.Collections.Generic.List <string> headers = new List <string>(); string[] header_nex = new string[] { }; for (var i = 1; i < dataExport.Columns.Count; i++) { var col = dataExport.Columns[i]; string colName = wEventUserMappingBLL.GetQuestionsDesc(EventId, col.ColumnName); headers.Add(colName); } var data = source; ExportHtmlExcel <List <string> >(Writer, headers.ToArray(), data, obj => { return(obj); }, null); Writer.Close(); sw.Close(); return(fileName); } catch (Exception ex) { PageLog.Current.Write(ex); return(null); } }
/// <summary> /// 活动报名表数据获取 /// </summary> public string getEventApplyQues() { string ReqContent = string.Empty; string content = string.Empty; var respObj = new getEventApplyQuesRespData(); string respStr = string.Empty; try { ReqContent = Request["ReqContent"]; ReqContent = HttpUtility.HtmlDecode(ReqContent); var reqContentObj = ReqContent.DeserializeJSONTo <getEventApplyQuesReqData>(); Loggers.Debug(new DebugLogInfo() { Message = string.Format( "getEventApplyQues ReqContent:{0}", ReqContent) }); if (!string.IsNullOrEmpty(reqContentObj.common.customerId)) { customerId = reqContentObj.common.customerId; } LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); var service = new WEventUserMappingBLL(loggingSessionInfo); GetResponseParams <QuestionnaireEntity> returnDataObj = service.getEventApplyQues( reqContentObj.special.eventId); var contentObj = new getEventApplyQuesRespContentData(); respObj.code = returnDataObj.Code; respObj.description = returnDataObj.Description; if (returnDataObj.Flag == "1" && returnDataObj.Params != null) { contentObj.questionCount = Default.ToStr(returnDataObj.Params.QuestionCount); // questions if (returnDataObj.Params.QuesQuestionEntityList != null) { contentObj.questions = new List <getEventApplyQuesRespQuestionData>(); foreach (var tmpQuestion in returnDataObj.Params.QuesQuestionEntityList) { if (tmpQuestion == null) { continue; } var tmpQues = new getEventApplyQuesRespQuestionData(); tmpQues.questionId = Default.ToStr(tmpQuestion.QuestionID); tmpQues.isSaveOutEvent = Default.ToStr(tmpQuestion.IsSaveOutEvent); tmpQues.cookieName = Default.ToStr(tmpQuestion.CookieName); tmpQues.questionText = Default.ToStr(tmpQuestion.QuestionDesc); tmpQues.questionType = Default.ToStr(tmpQuestion.QuestionType); tmpQues.minSelected = Default.ToStr(tmpQuestion.MinSelected); tmpQues.maxSelected = Default.ToStr(tmpQuestion.MaxSelected); tmpQues.isRequired = Default.ToStr(tmpQuestion.IsRequired); tmpQues.isFinished = Default.ToStr(tmpQuestion.IsFinished); // options if (tmpQuestion.QuesOptionEntityList != null) { tmpQues.options = new List <getEventApplyQuesRespOptionData>(); foreach (var tmpOption in tmpQuestion.QuesOptionEntityList) { if (tmpOption == null) { continue; } var tmpOp = new getEventApplyQuesRespOptionData(); tmpOp.optionId = Default.ToStr(tmpOption.OptionsID); tmpOp.optionText = Default.ToStr(tmpOption.OptionsText); tmpOp.isSelected = Default.ToStr(tmpOption.IsSelect); tmpQues.options.Add(tmpOp); } } contentObj.questions.Add(tmpQues); } } } respObj.content = contentObj; LEventsBLL eventServer = new LEventsBLL(loggingSessionInfo); LEventsEntity eventInfo = new LEventsEntity(); eventInfo = eventServer.GetByID(reqContentObj.special.eventId); respObj.content.imageUrl = eventInfo.URL; Loggers.Debug(new DebugLogInfo() { Message = string.Format( "getEventApplyQues RespContent:{0}", respObj.ToJSON()) }); } catch (Exception ex) { respObj.code = "103"; respObj.description = "数据库操作错误"; //respObj.exception = ex.ToString(); } content = respObj.ToJSON(); return(content); }