<% '########################################################################################### '코드와 텍스트 구분자 'return : String '########################################################################################### Function CDSplit() CDSplit = Trim("∮") End Function '########################################################################################### 'Item 구분자 'return : String '########################################################################################### Function LBSplit() LBSplit = Trim("∑") End Function '########################################################################################### '로그인 여부 체크 함수 'return : void '########################################################################################### Function Login(rurl) If Session("ID")="" Or Session("userID")="" Or Session("userName")="" Or Session("Grade")="" Then Response.Redirect LOGINURL & "?rurl=" & rurl End If End Function '########################################################################################### '관리자 여부 체크 함수 'return : void '########################################################################################### Function ADCheck() 'Grade 1 관리자 'Grade 2 사용자 If Session("Grade")<>"1" Then call_msg("권한이 없습니다") Response.End End If End Function '########################################################################################### '로그아웃 'return : void '########################################################################################### Sub Logout() Session("ID")="" Session("userID")="" Session("Grade")="" Session("userName")="" Session.Contents.RemoveAll() Session.Abandon End Sub '########################################################################################### 'URL Redirect 'return : void '########################################################################################### Function call_Url(url,msg) Response.Write "" & vbCRLF Response.Write "" & vbCrLF Response.Write "" & PROGRAMTITLE & "" & vbCrlf Response.Write "" & vbCrlf Response.Write "" & vbCrLF Response.Write "" & vbCrLF Response.Write "" & vbCrLF Response.Write "" & vbCrlf Response.Write "" End Function '########################################################################################### 'URL Redirect 'return : void '########################################################################################### Function call_msg(msg) Response.Write "" & vbCRLF Response.Write "" & vbCrLF Response.Write "" & SurveyTitle & "" & vbCrlf Response.Write "" & vbCrlf Response.Write "" & vbCrLF Response.Write "" & vbCrLF Response.Write "" & vbCrLF Response.Write "" & vbCrlf Response.Write "" End Function '########################################################################################### '사용자 등급 'return : string '########################################################################################### Function memberGrade(grade) Select Case grade Case "1" memberGrade = "관리자" Case "2" memberGrade = "사용자" Case Else memberGrade = "사용자" End Select End Function '###################################################################################### 'Survey Code 생성 'return : string '###################################################################################### Function makeCode() Dim Codes,Days Dim PCode,EChar,IntCode Dim PSQL Dim params(0) Days = Date Days = Replace(Days,"-","") Days = Mid(Days,3,Len(Days)) Codes = "P" & Days PSQL = "SELECT [code] FROM [Survey] WHERE [code] LIKE '%"&Codes&"%' Order By ID desc" Set DefaultDBHelper = New clsDBHelper Set Rs = DefaultDBHelper.ExecSQLReturnRS(PSQL,Nothing,GetDBStr()) If Rs.Eof Or Rs.Bof Then Codes = Codes & "01" Else EChar = Right(Rs(0),1) If IsNumeric(EChar)=True Then IntCode = Rs(0) Else IntCode = Left(Rs(0),Len(Rs(0))-1) End if IntCode = Right(IntCode,Len(IntCode)-1) IntCode = CDbl(intCode)+1 Codes = "P"&IntCode End If Rs.Close Set Rs = Nothing DefaultDBHelper.Dispose Set DefaultDBHelper = Nothing makeCode = Codes End Function '###################################################################################### '설문 유형 'return : string '###################################################################################### Function getQType(strs) Select Case strs Case "single" getQType="단수" Case "multi" getQType="복수" Case "text" getQType="장문" Case "string" getQType="단문" Case "scale" getQType="척도" Case "attribute" getQType="단수속성" Case "mattribute" getQType="복수속성" Case "rank" getQType="순위" Case "price" getQType="금액" Case "number" getQType="숫자" Case "sum" getQType="합계" Case "blank" getQType="설명" Case "info" getQType="개인정보입력" Case "agree" getQType="개인정보동의" End Select End Function '###################################################################################### '설문 유형 'return : string '###################################################################################### Function getSType(strs) Select Case strs Case "단수" getSType="single" Case "복수" getSType="multi" Case "단문" getSType="string" Case "장문" getSType="text" Case "척도" getSType="scale" Case "단수속성" getSType="attribute" Case "복수속성" getSType="mattribute" Case "순위" getSType="rank" Case "금액" getSType="price" Case "숫자" getSType="number" Case "합계" getSType="sum" Case "설명" getSType="blank" Case "개인정보입력" getSType="info" Case "개인정보동의" getSType="agree" End Select End Function '###################################################################################### 'Table 존재 여부 검사 'return : boolean '###################################################################################### Function checkTable(tableNm) Dim SQL,rsTable SQL = "SELECT [NAME] FROM sysobjects WHERE [xtype]='U' AND [name]='" & tableNm & "'" Set RsTable = Server.CreateObject("ADODB.Recordset") DBConnect1() RsTable.Open SQL,DBConn,3,1,1 If RsTable.Eof or RsTable.Bof Then checkTable=false else checkTable=true End if RsTable.Close Set RsTable = Nothing DBClose() End Function '###################################################################################### 'Table 존재 여부 검사 'return : boolean '###################################################################################### Function checkTable1(tableNm) Dim SQL,rsTable SQL = "SELECT [NAME] FROM sysobjects WHERE [xtype]='U' AND [name]='" & tableNm & "'" Set RsTable = Server.CreateObject("ADODB.Recordset") DBConnect1() RsTable.Open SQL,DBConn,3,1,1 If RsTable.Eof or RsTable.Bof Then checkTable1=false else checkTable1=true End if RsTable.Close Set RsTable = Nothing DBClose() End Function '########################################################################################### 'Table내의 필드이름 확인 'return : boolean '########################################################################################### Function checkField1(fieldNm,tableNm) Dim Tvars,SQL Dim rsField Tvars = replace(tableNm,"[","") Tvars = replace(Tvars,"]","") DBConnect1() Set rsField = Server.CreateObject("ADODB.Recordset") SQL = "select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = '" & Trim(Tvars) &"' and column_name='" & trim(fieldNm) & "'" RsField.Open SQL,DBConn,3,1,1 If RsField.Eof or RsField.Bof Then checkField1=false else checkField1=true End if RsField.Close DBClose() End Function '########################################################################################### 'Table내의 컬럼 이름 변경 'return : boolean '########################################################################################### Function changeColName(name1,name2,tableNm) Dim SQL,ixCnt If varType(name1)=8192 And varType(name2)=8192 Then SQL = "" For ixCnt=LBound(name1) To UBound(name1) If checkField1(name1(ixCnt),tableNm)=True And checkField1(name2(ixCnt),tableNm)=False Then SQL = "EXEC sp_rename '"&tableNm&"."&name1(ixCnt)&"', '"&name2(ixCnt)&"', 'COLUMN'" & vbCrLf & " GO" End If Next If SQL<>"" Then ExecuteSQL2 SQL changeColName = True Else changeColName = False End If ElseIf varType(name1)=8204 And varType(name2)=8204 Then SQL = "" For ixCnt=LBound(name1) To UBound(name1) If checkField1(name1(ixCnt),tableNm)=True And checkField1(name2(ixCnt),tableNm)=False Then SQL = "EXEC sp_rename '"&tableNm&"."&name1(ixCnt)&"', '"&name2(ixCnt)&"', 'COLUMN'" & vbCrLf & " GO" End If Next If SQL<>"" Then ExecuteSQL2 SQL changeColName = True Else changeColName = False End If Else If checkField1(name1,tableNm)=True And checkField1(name2,tableNm)=False Then SQL = "EXEC sp_rename '"&tableNm&"."&name1&"', '"&name2&"', 'COLUMN'" ExecuteSQL2 SQL changeColName = True Else changeColName = False End If End IF End Function '########################################################################################### 'Table내의 컬럼 데이터 변경 'return : boolean '########################################################################################### Function changeCol(colName,colType,tableNm) Dim SQL,ixCnt If varType(colName)=8192 Or varType(colName)=8204 Then SQL = "" For ixCnt=Lbound(colName) To UBound(colName) If checkField1(colName(ixCnt),tableNm) Then If varType(colType)=8192 Or varType(colType)=204 Then SQL = SQL & "ALTER TABLE ["&tableNm&"] ALTER COLUMN ["&colName(ixCnt)&"] "&colType(ixCnt)&" ;" Else SQL = SQL & "ALTER TABLE ["&tableNm&"] ALTER COLUMN ["&colName(ixCnt)&"] "&colType&" ;" End If End IF Next If SQL<>"" Then DBConnect1() ExecuteSQL1 SQL changeCol = True DBClose() Else changeCol = False End IF Else If checkField1(colName,tableNm) Then DBConnect1() SQL = "ALTER TABLE ["&tableNm&"] ALTER COLUMN ["&colName&"] "&colType&" ;" ExecuteSQL1 SQL changeCol = True DBClose() Else changeCol = False End If End If End Function '########################################################################################### 'Table내의 컬럼 삭제 'return : boolean '########################################################################################### Function delCol(colName,tableNm) Dim SQL If checkField1(colName,tableNm) Then DBConnect1() SQL = "ALTER TABLE ["&tableNm&"] DROP COLUMN ["&colName&"];" ExecuteSQL1 SQL delCol = True Else delCol = False End IF DBClose() End Function '########################################################################################### 'Table내의 컬럼 여러개 삭제 'return : boolean '########################################################################################### Function delCols(colNames,tableNm) Dim SQL,ixCnt If checkTable1(tableNm)=True Then If varType(colNames)=8192 Or varType(colNames)=8204 Then For ixCnt=Lbound(colNames) To UBound(colNames) If checkField1(colNames(ixCnt),tableNm)=True Then SQL = SQL & "ALTER TABLE ["&tableNm&"] DROP COLUMN ["&colNames(ixCnt)&"];" End IF Next Else If checkField1(colNames,tableNm)=True Then SQL = "ALTER TABLE ["&tableNm&"] DROP COLUMN ["&colNames&"];" End IF End If If SQL<>"" Then DBConnect1() ExecuteSQL1 SQL DBClose() delCols = True Else delCols = False End If Else delCols = False End IF End Function '########################################################################################### 'Table내의 컬럼 추가 'return : boolean '########################################################################################### Function addCol(colName,colType,tableNm) Dim SQL If checkTable1(tableNm)=True And checkField1(colName,tableNm)=False Then DBConnect1() SQL = "ALTER TABLE ["&tableNm&"] ADD ["&colName&"] "&colType&" ;" ExecuteSQL1 SQL addCol = True Else addCol = False End IF DBClose() End Function '########################################################################################### 'Table내의 컬럼 여러개 추가 'return : boolean '########################################################################################### Function addCols(colNames,colTypes,tableNm) Dim SQL Dim ixCnt If checkTable1(tableNm)=True Then SQL = "" '컬럼이름이 배열이 전달된 경우 If varType(colNames)=8192 Or varType(colNames)=8204 Then For ixCnt=Lbound(colNames) To UBound(colNames) '컬림 이름이 없는 경우 If checkField1(colNames(ixCnt),tableNm)=False Then '컬럼 타잎도 배열인경우 If varType(colTypes)=8192 Then SQL = SQL & "ALTER TABLE ["&tableNm&"] ADD ["&colNames(ixCnt)&"] "&colTypes(ixCnt)&" ;" Else SQL = SQL & "ALTER TABLE ["&tableNm&"] ADD ["&colNames(ixCnt)&"] "&colTypes&" ;" End If End IF Next Else If checkField1(colNames,tableNm)=False Then SQL = "ALTER TABLE ["&tableNm&"] ADD ["&colNames&"] "&colTypes&" ;" End IF End If If SQL<>"" Then DBConnect1() ExecuteSQL1 SQL DBClose() addCols = True Else addCols = False End IF Else addCols = False End IF End Function '########################################################################################### 'Table내의 컬럼 갯수 세기 'return : number '########################################################################################### Function countCols(tableNm) Dim SQL,Rs SQL ="SELECT COUNT(name) as COL_COUNT FROM "&DB_NAME1&".sys.columns WHERE object_id = OBJECT_ID('"&tableNm&"')" If DBFlag=False Then DBConnect1() End If Set Rs = Server.CreateObject("ADODB.Recordset") Rs.Open SQL,DBConn,3,1,1 If Rs.Eof Or Rs.Bof Then countCols = 0 Else countCols = Rs(0) End IF Rs.Close Set Rs = Nothing DBClose() End Function '########################################################################################### '설문의 순서를 만듬 'return : void '########################################################################################### Function makeSurveyMap(code) Dim PSQL Dim params(0) Dim jsSurvey,rjsSurvey,xSurvey Dim jCnt Dim cVar,nVar,pVar PSQL = "SELECT [ID],[variable] FROM [Question] WHERE [code]=? ORDER BY LID" params(0) = Array("@code",adVarWChar,adParamInput,Len(code),code) Set DefaultDBHelper = New clsDBHelper Set Rs = DefaultDBHelper.ExecSQLReturnRS(PSQL,params,GetDBStr()) If Not Rs.Eof And Not Rs.Bof Then Set jsSurvey = New aspJSON Set rjsSurvey = New aspJSON Set xSurvey = New aspJSON cVar = "" nVar = "" pVar = "" For jCnt=0 To Rs.Recordcount-1 cVar = Rs("variable") If jCnt=0 Then jsSurvey.data.Add "index",cVar xSurvey.data.Add "index",jCnt End If If jCnt< Rs.RecordCount Then rs.MoveNext If Not Rs.Eof Then nVar = Rs("variable") Else nVar = "" End IF Else nVar = "" End If If cVar <> "" Then If nVar<>"" Then jsSurvey.data.Add cVar, nVar xSurvey.data.Add cVar,jCnt+1 Else jsSurvey.data.Add cVar, "SURVEY_END" xSurvey.data.Add cVar,jCnt+1 xSurvey.data.Add "SURVEY_END",jCnt+2 End If If jCnt=0 Then rjsSurvey.data.Add cVar, "index" pVar = cVar Else rjsSurvey.data.Add cVar, pVar pVar = cVar End If End IF Next WriteUTF_File "/Project/"&code&"/include/map.json",jsSurvey.JSONoutput() WriteUTF_File "/Project/"&code&"/include/rmap.json",rjsSurvey.JSONoutput() WriteUTF_File "/Project/"&code&"/include/xmap.json",XSurvey.JSONoutput() Set jsSurvey = Nothing End If Rs.Close Set Rs = Nothing DefaultDBHelper.Dispose Set DefaultDBHelper = Nothing End Function '########################################################################################### '로직 파일 생성 'return : void '########################################################################################### Function createNLogic(code) Dim PSQL Dim params(0) Dim Qjson,Quota,sample,QPage Dim SourceFile,LogicFile,LogicBody,SourceBody Dim jCnt Dim cVar,nVar Quota = "" QPage = "" sample = "" PSQL = "SELECT [ID],[variable],[n_logic] FROM [Question] WHERE [code]=? AND [n_logic]<>'"&Chr(34)&Chr(34)&"' ORDER BY LID" params(0) = Array("@code",adVarWChar,adParamInput,Len(code),code) LogicFile = "/Project/"&code&"/include/nlogic.asp" SourceFile = "/Template/include/nlogic.asp" Set Qjson = getQuotaInfo(code) If Qjson.data("check")<>"" Then QPage = Qjson.data("check") Quota = Qjson.data("quota") sample = Qjson.data("sample") End If Set QJson = Nothing Set DefaultDBHelper = New clsDBHelper Set Rs = DefaultDBHelper.ExecSQLReturnRS(PSQL,params,GetDBStr()) If Not Rs.Eof And Not Rs.Bof Then LogicBody = "" For jCnt=0 To Rs.Recordcount-1 cVar = Rs("variable") LogicBody = LogicBody & vbTab LogicBody = LogicBody & "Case " & Chr(34) & cVar & Chr(34) & vbCrLF LogicBody = LogicBody & vbTab & vbTab LogicBody = LogicBody & rs("n_logic") & vbCrLF rs.MoveNext Next Else LogicBody = "" End If SourceBody = ReadUTF_File(sourceFile) WriteUTF_File LogicFile,Replace(SourceBody,"[@LOGIC]",LogicBody) Rs.Close Set Rs = Nothing DefaultDBHelper.Dispose Set DefaultDBHelper = Nothing End Function '########################################################################################### '로직 파일 생성 'return : void '########################################################################################### Function createPLogic(code) Dim PSQL Dim params(0) Dim SourceFile,LogicFile,LogicBody,SourceBody Dim jCnt Dim cVar,nVar PSQL = "SELECT [ID],[variable],[p_logic] FROM [Question] WHERE [code]=? AND [p_logic]<>'"&Chr(34)&Chr(34)&"' ORDER BY LID" params(0) = Array("@code",adVarWChar,adParamInput,Len(code),code) LogicFile = "/Project/"&code&"/include/plogic.asp" SourceFile = "/Template/include/plogic.asp" Set DefaultDBHelper = New clsDBHelper Set Rs = DefaultDBHelper.ExecSQLReturnRS(PSQL,params,GetDBStr()) If Not Rs.Eof And Not Rs.Bof Then LogicBody = "" For jCnt=0 To Rs.Recordcount-1 cVar = Rs("variable") LogicBody = LogicBody & " Case " & Chr(34) & cVar & Chr(34) & vbCrLF LogicBody = LogicBody & " " & rs("p_logic") & vbCrLF rs.MoveNext Next Else LogicBody = "" End If SourceBody = ReadUTF_File(sourceFile) WriteUTF_File LogicFile,Replace(SourceBody,"[@LOGIC]",LogicBody) Rs.Close Set Rs = Nothing DefaultDBHelper.Dispose Set DefaultDBHelper = Nothing End Function '########################################################################################### '데이터맵 파일 생성 'return : void '########################################################################################### Function createDataMap(code) Dim PSQL Dim params(0) Dim dbmapFile,mapStr,sourceStr Dim jCnt,xCnt Dim cVar,jsonObj dbmapFile = "/Survey/Map/"&code&".map" mapStr = getVariableQuery(code,"") sourceStr = "[IDX],[IDKey],[Interviewer],[StartDate],[UpdateDate],[EndDate],[Page],[OutPage],[IPName],[ResType]," WriteUTF_File dbmapFile,sourceStr & mapStr Set jsonOBJ = Nothing End Function '########################################################################################### 'Survey 변수정보 가져오기 'return : string '########################################################################################### Function getVariableQuery(code,variable) Dim PSQL Dim params Dim mapStr Dim jCnt,xCnt Dim cVar,jsonObj,iCnt,jsonObj1 mapStr = "" If variable = "" Then ReDim params(0) PSQL = "SELECT [ID],[variable],[template],[item],[attribute],[etc],[sumvalue],[minvalue] FROM [Question] WHERE [code]=? ORDER BY LID" params(0) = Array("@code",adVarWChar,adParamInput,Len(code),code) Else ReDim params(2) PSQL = "SELECT [ID],[variable],[template],[item],[attribute],[etc],[sumvalue],[minvalue] FROM [Question] WHERE [code]=? And [LID]>=(SELECT LID FROM [Question] WHERE [code]=? AND [variable]=?) ORDER BY LID" params(0) = Array("@code",adVarWChar,adParamInput,Len(code),code) params(1) = Array("@code",adVarWChar,adParamInput,Len(code),code) params(2) = Array("@variable",adVarWChar,adParamInput,Len(variable),variable) End IF Set DefaultDBHelper = New clsDBHelper Set Rs = DefaultDBHelper.ExecSQLReturnRS(PSQL,params,GetDBStr()) If Not Rs.Eof And Not Rs.Bof Then mapStr = "" Set jsonObj = New aspJSON Set jsonObj1 = New aspJSON For jCnt=0 To Rs.Recordcount-1 cVar = Rs("variable") If mapStr<>"" And rs("template")<>"blank" Then mapStr = mapStr & "," Select Case Rs("template") '단수 Case "single" mapStr = mapStr & "[" & cVar & "]" '기타 처리 If rs("etc")="1" Then mapStr = mapStr & ",[T" & cVar & "]" '복수 Case "multi" jsonOBJ.loadJSON(rs("item")) For Each icnt In jsonOBJ.data If icnt>0 Then mapStr = mapStr & "," If InStr(jsonOBJ.data(icnt).item("text"),"*OTHER")>0 Then '기타 확인 mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" mapStr = mapStr & ",[T" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" Else mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" End IF Next jsonOBJ.data.RemoveAll '장문 Case "text" mapStr = mapStr & "[" & cVar & "]" '단문 Case "string" If rs("sumvalue")<>"""" And rs("sumvalue")<>"1" Then For iCnt=1 To CInt(rs("sumvalue")) If icnt>1 Then mapStr = mapStr & "," mapStr = mapStr & "[" & cVar & "_" & CStr(iCnt) & "]" Next Else mapStr = mapStr & "[" & cVar & "]" End If '척도 Case "scale" mapStr = mapStr & "[" & cVar & "]" '단수 속성 Case "attribute" '속성은 기타 추가 안됨 jsonOBJ.loadJSON(rs("attribute")) For Each icnt In jsonOBJ.data If icnt>0 Then mapStr = mapStr & "," mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" Next jsonOBJ.data.RemoveAll '복수 속성 Case "mattribute" '속성은 기타 추가 안됨 jsonOBJ.loadJSON(rs("attribute")) jsonOBJ1.loadJSON(rs("item")) For Each icnt In jsonOBJ.data 'If icnt>0 Then mapStr = mapStr & "," For Each xCnt In jsonOBJ1.data 'If iCnt>0 And xCnt>0 Then mapStr = mapStr & "," If iCnt>0 Or xCnt>0 Then mapStr = mapStr & "," mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "_" & jsonOBJ1.data(xcnt).item("code") & "]" Next Next jsonOBJ.data.RemoveAll jsonOBJ1.data.RemoveAll '순위 Case "rank" jsonOBJ.loadJSON(rs("attribute")) For Each icnt In jsonOBJ.data If icnt>0 Then mapStr = mapStr & "," mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" Next jsonOBJ.data.RemoveAll '금액 Case "price" mapStr = mapStr & "[" & cVar & "]" '숫자 Case "number" mapStr = mapStr & "[" & cVar & "]" '합계 Case "sum" jsonOBJ.loadJSON(rs("attribute")) For Each icnt In jsonOBJ.data If icnt>0 Then mapStr = mapStr & "," mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" Next mapStr = mapStr & ",[" & cVar & "_SUM]" jsonOBJ.data.RemoveAll '안내 화면 Case "blank" 'mapStr = "" '개인정보 입력 - 복수와 동일한 형태 Case "info" jsonOBJ.loadJSON(rs("item")) For Each icnt In jsonOBJ.data If icnt>0 Then mapStr = mapStr & "," If InStr(jsonOBJ.data(icnt).item("text"),"*OTHER")>0 Then '기타 확인 mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" mapStr = mapStr & ",[T" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" Else mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" End IF Next jsonOBJ.data.RemoveAll '개인정보 수집 동의 - 복수와 동일한 형태 Case "agree" jsonOBJ.loadJSON(rs("item")) For Each icnt In jsonOBJ.data If icnt>0 Then mapStr = mapStr & "," If InStr(jsonOBJ.data(icnt).item("text"),"*OTHER")>0 Then '기타 확인 mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" mapStr = mapStr & ",[T" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" Else mapStr = mapStr & "[" & cVar & "_" & jsonOBJ.data(icnt).item("code") & "]" End IF Next jsonOBJ.data.RemoveAll Case Else mapStr = mapStr & "[" & cVar & "]" End Select rs.MoveNext Next Else mapStr = "" End If getVariableQuery = mapStr Rs.Close Set Rs = Nothing DefaultDBHelper.Dispose Set DefaultDBHelper = Nothing End Function '########################################################################################### 'Survey 정보 가져오기 'return : JSON Object '########################################################################################### Function getSurveyInfo(code) Dim surveyObj Set surveyObj = New aspJSON If FileChecker("/Survey/Status/"&code&".json") Then surveyObj.loadJSON(SITENAME&"/Survey/Status/"&code&".json") End If Set getSurveyInfo = surveyObj End Function '########################################################################################### 'Quota 정보 가져오기 'return : JSON Object '########################################################################################### Function getQuotaInfo(code) Dim surveyObj Set surveyObj = New aspJSON If FileChecker("/Survey/Quota/"&code&".json") Then surveyObj.loadJSON(SITENAME&"/Survey/Quota/"&code&".json") End If Set getQuotaInfo = surveyObj End Function '########################################################################################### '변수 item 가져오기 'return : JSON String '########################################################################################### Function getQuestionItem(code,variable) Dim SQL,Rs Dim params(1) Dim variableName If InStr(variable,"_")>0 Then variableName = Split(variableName,"_")(0) Else variableName = variable End If SQL = "SELECT [ID],[variable],[template],[item],[attribute],[etc] FROM [Question] WHERE [code]=? AND [variable]=? ORDER BY LID" params(0) = Array("@code",adVarWChar,adParamInput,Len(code),code) params(1) = Array("@variable",adVarWChar,adParamInput,Len(variableName),variableName) Set DefaultDBHelper = New clsDBHelper Set Rs = DefaultDBHelper.ExecSQLReturnRS(SQL,params,GetDBStr()) If Not Rs.Eof And Not Rs.Bof Then getQuestionItem = Rs("item") Else getQuestionItem = "" End If Rs.Close Set Rs = Nothing DefaultDBHelper.Dispose Set DefaultDBHelper = Nothing End Function Function loadQuestionItem(code,variable) If FileChecker("../Project/"&code&"/codeLabel/"&variable&"_COD.json") Then loadQuestionItem = ReadUTF_File("../Project/"&code&"/codeLabel/"&variable&"_COD.json") Else loadQuestionItem = "" End If End Function '########################################################################################### '쿼터 정보 중 일부 가져오기 '@code : Project Code 'return : integer '########################################################################################### Function getQuotaSamples(code) Dim SQL,Rs Dim params(0) SQL = "SELECT [code],[quotaVariable],[quotaCheck],[samples],[types] FROM [Quota] WHERE [code]=? " params(0) = Array("@code",adVarWChar,adParamInput,Len(code),code) Set DefaultDBHelper = New clsDBHelper Set Rs = DefaultDBHelper.ExecSQLReturnRS(SQL,params,GetDBStr()) If Not Rs.Eof And Not Rs.Bof Then getQuotaSamples = Rs("samples") Else getQuotaSamples = "" End If Rs.Close Set Rs = Nothing DefaultDBHelper.Dispose Set DefaultDBHelper = Nothing End Function '########################################################################################### '설문 DB의 응답수 가져오기 '@code : Project Code '@Qry : Where 조건 'return : integer '########################################################################################### Function getQuota(code,Qry) Dim SQL,Rs,i,j If Qry="" Then 'SQL = "SELECT Count(idx) FROM [Dat_"& code &"] WHERE [ResType]<>'TEST' AND status in (10) " SQL = "SELECT Count(idx) FROM [Dat_"& code &"] WHERE status in (10) " Else 'SQL = "SELECT Count(idx) FROM [Dat_"& code &"] WHERE [ResType]<>'TEST' AND status in (10) and " & Qry SQL = "SELECT Count(idx) FROM [Dat_"& code &"] WHERE status in (10) and " & Qry End If Set Rs = Server.CreateObject("ADODB.Recordset") DBConnect1() Rs.Open SQL,DBConn,3,1,1 if Not Rs.Eof OR Not Rs.Bof Then getQuota = Rs(0) Else getQuota = 0 End if Rs.Close Set Rs = Nothing DBClose() End Function '########################################################################################### '설문 DB의 할당 수 가져오기 '@code : Project Code '@Qry : Where 조건 'return : integer '########################################################################################### Function getLimit(code,Qry) Dim SQL,Rs,i,j If Qry="" Then SQL = "SELECT Sum(Limit) FROM [Q_"& code & "]" Else SQL = "SELECT Sum(Limit) FROM [Q_"& code & "] WHERE " & Qry End If Set Rs = Server.CreateObject("ADODB.Recordset") DBConnect1() Rs.Open SQL,DBConn,3,1,1 if Not Rs.Eof OR Not Rs.Bof Then getLimit = Rs(0) Else getLimit = 0 End if Rs.Close Set Rs = Nothing DBClose() End Function '########################################################################################### '설문 응답값 가져와서 질문에 보여주기 '@title : 질문 Text 'return : String '########################################################################################### Function ConvertRESLabel(title) Dim tmpStr1,tmpStr2,vStr,rStr,RFlag,XCnt XCnt=0 rStr = title RFlag = True ' If InStr(title,"[#")>0 And InStr(title,"#]")>0 Then ' ConvertRESLabel = tmpStr1 & Chr(34) & Chr(38) & "getRESValue(" & Chr(34) & vStr & Chr(34) & ")" & Chr(38) & Chr(34) & tmpStr2 ' Else ' ConvertRESLabel = title ' End If If InStr(title,"[#")>0 And InStr(title,"#]")>0 Then Do While RFlag=True If (InStr(rStr,"[#")>0 And InStr(rStr,"#]")>0) Then tmpStr1 = Left(rStr,InStr(rStr,"[#")-1) tmpStr2 = Mid(rStr,InStr(rStr,"#]")+2,Len(rStr)) vStr = Replace(Replace(rStr,tmpStr1 & "[#",""),"#]"&tmpStr2,"") rStr = tmpStr1 & Chr(34) & Chr(38) & "getRESValue(" & Chr(34) & vStr & Chr(34) & ")" & Chr(38) & Chr(34) & tmpStr2 XCnt=XCnt+1 Else RFlag = False Exit Do XCnt=XCnt+1 End IF Loop If Right(rStr,2)="&"&Chr(34) Then ' rStr = Left(rStr,Len(rStr)-2) End If End If ConvertRESLabel = rStr End Function '########################################################################################### '" 을 ˝ 로 변경해줌 ASP 파일 아웃풋을 위해 처리 '@resText : Text 'return : String '########################################################################################### Function ConverTextForASP(resText) ConverTextForASP = Replace(resText,Chr(34),"˝") End Function Function ConvertHtmlQuot(resText) resText = Replace(resText,"=" & Chr(34),"='") resText = Replace(resText,Chr(34)&">","'>") resText = Replace(resText,Chr(34)&" ","' ") resText = Replace(resText,Chr(34)&Chr(34),"""") resText = Replace(resText,Chr(34),""") resText = Replace(resText,vbCRLF,"
") ConvertHtmlQuot =resText End Function ' Function ConvertHtmlQuot(resText) ' resText = Replace(resText,"=" & Chr(34),"='") ' resText = Replace(resText,Chr(34)&">","'>") ' resText = Replace(resText,Chr(34)&" ","' ") ' End Function Function RemoveOTHER(resText) RemoveOTHER = Replace(Replace(resText,"*OTHER",""),"*NONE","") End Function '########################################################################################### '개인정보 입력 관련 내용 처리 '########################################################################################### Function getInfoType(numbers) Select Case numbers Case "1" getInfoType = "이름" Case "2" getInfoType = "연락처" Case "3" getInfoType = "연령" Case "4" getInfoType = "주소" Case "5" getInfoType = "이메일" Case "11" getInfoType = "개인 정보 관련 사항" Case "12" getInfoType = "고유식별 정보 관련 사항" Case "13" getInfoType = "경제/사회 정보" Case "14" getInfoType = "개인정보 3자 제공" Case "15" getInfoType = "개인정보 보유 기간" Case "19" getInfoType = "서명" End Select End Function %>