public SigmaResultType ImportFile() { SigmaResultType result = new SigmaResultType(); try { var queryStr = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters; string fileType = queryStr["filetype"]; string filePath = queryStr["filepath"]; //string rootPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DocumentUpload"]; //string targetPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DocumentFolderRoot"]; string rootPath = ConfigMgr.GetImportFilePath(); filePath = rootPath + filePath; //fileType = "DrawingImage"; // ImportFile switch (fileType) { case "Drawing": //importDrawing importDrawing = new ImportDrawing(); ImportDrawingMgr importDrawing = new ImportDrawingMgr(); result = importDrawing.AddDrawing(filePath, ConfigMgr.GetExportFilePath()); break; case "DrawingImage": //ImportDrawing importDrawingImage = new ImportDrawing(); ImportDrawingMgr importDrawingImage = new ImportDrawingMgr(); //result = importDrawingImage.AddDrawingImage(filePath, targetPath); result = importDrawingImage.AddDrawingImage(filePath, ConfigMgr.GetTargetPath()); break; case "MTO": ImportMgr importMgr = new ImportMgr(); result = importMgr.ImportMTOFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "CostCode": CostCodeMgr costcodeMgr = new CostCodeMgr(); result = costcodeMgr.ImportCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "ProjectCostCode": CostCodeMgr projectcostcodeMgr = new CostCodeMgr(); result = projectcostcodeMgr.ImportProjectCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "ClientCostCode": CostCodeMgr clientcostcodeMgr = new CostCodeMgr(); result = clientcostcodeMgr.ImportClientCostCodeFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "HR": PersonnelMgr personnelMgr = new PersonnelMgr(); result = personnelMgr.ImportPersonnelFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "User": SigmaUserMgr sigmauserMgr = new SigmaUserMgr(); result = sigmauserMgr.ImportSigmaUserFromExcel(filePath, ConfigMgr.GetExportFilePath()); break; case "MeterialLibrary": ImportMgr importMeterial = new ImportMgr(); result = importMeterial.ImportMeterialLib(filePath, ConfigMgr.GetExportFilePath()); break; case "EquipmentLibrary": ImportMgr importEquipment = new ImportMgr(); result = importEquipment.ImportEquipmentLib(filePath, ConfigMgr.GetExportFilePath()); break; case "ConsumableLibrary": ImportMgr importConsumable = new ImportMgr(); result = importConsumable.ImportConsumableLib(filePath, ConfigMgr.GetExportFilePath()); break; case "DrawingType": ImportMgr importDrawingType = new ImportMgr(); result = importDrawingType.ImportDrawingTypeLib(filePath, ConfigMgr.GetExportFilePath()); break; default: break; } return result; } catch (Exception ex) { // Log Exception ExceptionHelper.logException(ex); result.IsSuccessful = false; result.ErrorMessage = ex.Message; return result; } }
public SigmaResultType UpdateDrawing(TypeDrawing objDrawingId) { TransactionScope scope = null; SigmaResultType result = new SigmaResultType(); SigmaResultType refresult = new SigmaResultType(); // Get connection string string connStr = ConnStrHelper.getDbConnString(); string UpdatedBy = "leebw"; // * Ref Drawing Check if (!string.IsNullOrEmpty(objDrawingId.ReferenceDrawings)) { string xlsRefDrawingno = objDrawingId.ReferenceDrawings; string[] arrRefDrawingno = xlsRefDrawingno.Split(','); foreach (string refdrawno in arrRefDrawingno) { refresult = GetDrawingByNumber(refdrawno.Trim()); if (refresult.AffectedRow < 1) { result.IsSuccessful = false; result.ErrorMessage = "Incorrect Reference Drawing"; return result; } } } // * Detail Drawing Check if (!string.IsNullOrEmpty(objDrawingId.DetailedDrawings)) { string xlsDetailDrawingno = objDrawingId.DetailedDrawings; string[] arrDetailDrawingno = xlsDetailDrawingno.Split(','); foreach (string detaildrawno in arrDetailDrawingno) { refresult = GetDrawingByNumber(detaildrawno.Trim()); if (refresult.AffectedRow < 1) { result.IsSuccessful = false; result.ErrorMessage = "Incorrect Detail Drawing"; return result; } } } // * Path 넘어오면 이미지 추가 - Image Add if (!string.IsNullOrEmpty(objDrawingId.FilePath)) { SigmaResultType imageresult = new SigmaResultType(); ImportDrawingMgr importDrawingImage = new ImportDrawingMgr(); //string rootPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DocumentUpload"]; //string targetPath = System.Web.Configuration.WebConfigurationManager.AppSettings["DocumentFolderRoot"]; string rootPath = ConfigMgr.GetImportFilePath(); string targetPath = ConfigMgr.GetTargetPath(); string filePath = rootPath + objDrawingId.FilePath; imageresult = importDrawingImage.AddDrawingImage(filePath, targetPath); } //-------------------------------------------------------------------------------------------------------- SqlParameter[] drawingParm = new SqlParameter[] { new SqlParameter("@DrawingId", objDrawingId.DrawingId), new SqlParameter("@CwpName", objDrawingId.CWP), new SqlParameter("@Name", objDrawingId.Name), new SqlParameter("@FileName", objDrawingId.FileName), new SqlParameter("@Title", objDrawingId.Title), new SqlParameter("@Description", objDrawingId.Description), new SqlParameter("@Revision", objDrawingId.Revision), new SqlParameter("@DrawingType", objDrawingId.DrawingType), new SqlParameter("@UpdatedBy", UpdatedBy), new SqlParameter("@ResultMsg", SqlDbType.VarChar, 100), // sp에서 output 설정했을 경우 new SqlParameter("RETURN_VALUE",SqlDbType.Int) // sp에서 return 값을 설정했을경우 사용 }; drawingParm[9].Direction = ParameterDirection.Output; drawingParm[10].Direction = ParameterDirection.ReturnValue; using (scope = new TransactionScope(TransactionScopeOption.Required)) { result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_UpdateDrawing", drawingParm); string resultMsg = (string)drawingParm[9].Value; int AffectedRow = (int)drawingParm[10].Value; if (AffectedRow > 0) { // Ref. Drawing 있다면 등록 if (!string.IsNullOrEmpty(objDrawingId.ReferenceDrawings)) { string xlsRefDrawingno = objDrawingId.ReferenceDrawings; string[] arrRefDrawingno = xlsRefDrawingno.Split(','); foreach (string refdrawno in arrRefDrawingno) { SqlParameter[] refdrawingParm = new SqlParameter[] { new SqlParameter("@RefDrawingNo", refdrawno.Trim()), new SqlParameter("@DrawingNo", objDrawingId.Name), new SqlParameter("@DetailDrawingNo", ""), new SqlParameter("@Revision", ""), new SqlParameter("@CreatedBy", UpdatedBy), new SqlParameter("RETURN_VALUE",SqlDbType.Int) // sp에서 return 값을 설정했을경우 사용 }; refdrawingParm[5].Direction = ParameterDirection.ReturnValue; //using (scope = new TransactionScope(TransactionScopeOption.RequiresNew)) //{ result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddReferenceDrawing", refdrawingParm); //int AffectedRow = (int)drawingParm[5].Value; AffectedRow = (int)refdrawingParm[5].Value; // scope.Complete(); //} } } // Detail Drawing 있다면 등록 if (!string.IsNullOrEmpty(objDrawingId.DetailedDrawings)) { string xlsDetailDrawingno = objDrawingId.DetailedDrawings; string[] arrDetailDrawingno = xlsDetailDrawingno.Split(','); foreach (string detaildrawno in arrDetailDrawingno) { SqlParameter[] detaildrawingParm = new SqlParameter[] { new SqlParameter("@DetailDrawingNo", detaildrawno.Trim()), new SqlParameter("@DrawingNo", objDrawingId.Name), new SqlParameter("@Revision", ""), new SqlParameter("@CreatedBy", UpdatedBy), new SqlParameter("RETURN_VALUE",SqlDbType.Int) // sp에서 return 값을 설정했을경우 사용 }; detaildrawingParm[4].Direction = ParameterDirection.ReturnValue; //using (scope = new TransactionScope(TransactionScopeOption.RequiresNew)) //{ result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddDetailDrawing", detaildrawingParm); AffectedRow = (int)detaildrawingParm[4].Value; // scope.Complete(); //} } } // Image 를 Upload 했다면 바로 Binding 처리 되도록 한다. if (!string.IsNullOrEmpty(objDrawingId.FilePath)) { SqlParameter[] drawingBindingParm = new SqlParameter[] { new SqlParameter("@DrawingId", objDrawingId.DrawingId), new SqlParameter("@UpdatedBy", objDrawingId.UpdatedBy), new SqlParameter("@ResultMsg", SqlDbType.VarChar, 100), // sp에서 output 설정했을 경우 new SqlParameter("RETURN_VALUE",SqlDbType.Int) // sp에서 return 값을 설정했을경우 사용 }; drawingBindingParm[2].Direction = ParameterDirection.Output; drawingBindingParm[3].Direction = ParameterDirection.ReturnValue; //DrawingID 번호 Return 받음 result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_UpdateBindingDrawingById", drawingBindingParm); //result.IsSuccessful = true; //result.ScalarValue = AffectedRow; } result.IsSuccessful = true; result.ScalarValue = AffectedRow; } else { result.IsSuccessful = false; result.ErrorMessage = resultMsg; } scope.Complete(); } return result; }