Stream stream = HttpContext.Current.Request.InputStream;
account = HttpContext.Current.Request.Params["Account"];
if (account == null || account == "")
{
account = "unknown";
}
desZipFilePrefix = ServiceHelp.getDesZipFileName(account);
fileSuffixNme = ".rar";
//讀取文件流將文件保存到服務器的特定目錄下
compressFilePath = OperateZipFile.writeCompressFile(stream, desZipFilePrefix + fileSuffixNme);
if (Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("DesFile")) == false)
{
Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("DesFile"));
}
deCompressFilePath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("DesFile"), desZipFilePrefix);
OperateZipFile.UnRar(deCompressFilePath, compressFilePath, desZipFilePrefix + fileSuffixNme);
//解析shapefile文件
FeatureShapeFileParse featureShapeFileParse = new FeatureShapeFileParse();
featureShapeFileParse.filePathForShp = featureShapeFileParse.getShpPath(deCompressFilePath);
featureShapeFileParse.filePathForShx = featureShapeFileParse.getShxPath(deCompressFilePath);
featureShapeFileParse.filePathForDbf = featureShapeFileParse.getDbfPath(deCompressFilePath);
List<ShpFileData> shpFileDataList = featureShapeFileParse.readShpFile();
List<DbfFileData> dbfFileDataList = featureShapeFileParse.readDbfile();
if (dbfFileDataList == null)
{
new Normal_AdminlogsDAL().SaveMapServiceLog(" 解壓失敗,或者文件為空");
return;
}
SurveyFeatureAddRequest surveyFeatureAddRequest = getSurveyFeatureAddRequest(shpFileDataList, dbfFileDataList);
string featureSql = string.Format(" INSERT INTO [PRO_PollingCheckLog]([P_ProID],[P_UserID],[P_CheckLogName],[P_StartTime],[P_EndTime],[P_Attributes],[P_LayerName],[P_FeatureName],[P_PicURI],[P_MediaURI],[P_Note],[P_StatusID],[P_CreateUserName],[P_CreateTime]) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}',getdate() ) ;",
surveyFeatureAddRequest.ProjectID, surveyFeatureAddRequest.SysUserId, surveyFeatureAddRequest.ProjectName, surveyFeatureAddRequest.SurveyTime, surveyFeatureAddRequest.SurveyTime,
surveyFeatureAddRequest.Attributes, surveyFeatureAddRequest.LayerName, surveyFeatureAddRequest.FeatureName, surveyFeatureAddRequest.PicURI, surveyFeatureAddRequest.MediaURI, surveyFeatureAddRequest.Note,
1, account);
int exerst = new SurveyFeatureDAL().InsertSurveyFeature(featureSql);
if (exerst > 0)
{
//刪除解壓後的臨時文件
deleteTempFile();
//記錄用戶操作日志
//new Normal_AdminlogsDAL().SaveLog(surveyFeatureAddRequest.SysUserId.ToString(), "項目名稱:" + surveyFeatureAddRequest.ProjectName + ",關聯地物信息已經上傳成功。");
}
else {
new Normal_AdminlogsDAL().SaveMapServiceLog("插入失敗");//Test
dbfFileDataList 總是等 null
你的壓縮文件是什麼類型,單獨執行解壓縮是否正確,或者報什麼錯誤。