public void GivenALittleZipFile_WhenTheZipFileIsAdded_ThenTheZipFileIsAddedToTheRepository() { _zipFileService.CreateLittleZipFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>()); _zipFileRepository.Verify(s => s.Create(It.IsAny <ZipFile>()), Times.Once()); }
public void SaveToDatabase(IXmlFileService xmlFileService, IZipFileService zipFileService, IConFileService conFileService, IDocTypeService docTypeService, IManCoService manCoService, ApplicationInfo appInfo) { try { NexdoxMessaging.SendMessage(" Adding Data to SQL Database", true, this); foreach (ZipPackage zp in Statics.zipPackage) { switch (Path.GetExtension(zp.FileName).ToLower()) { case ".xml": DocType docType = docTypeService.GetDocType(zp.DocumentType); if (docType == null) { throw new Exception(string.Format("Document type {0} not found in unity database", zp.DocumentType)); } ManCo manCo = manCoService.GetManCo(zp.ManCoID); if (manCo == null) { throw new Exception(string.Format("Man Co {0} not found in unity database", zp.ManCoID)); } xmlFileService.CreateXmlFile( Statics.zipPackage.DocumentSetID.ToString(), zp.FileName, zp.ParentZipFileName, zp.Offshore, docType.Id, manCo.Id, 0, string.Empty, zp.FileName, DateTime.Now, appInfo.NexdoxGlobalRunID.ToString(), File.GetLastWriteTime(appInfo.InputPath)); break; case ".zip": if (zp.IsBigZip) { zipFileService.CreateBigZipFile(Statics.zipPackage.DocumentSetID.ToString(), zp.FileName, File.GetLastWriteTime(appInfo.InputPath)); } else { zipFileService.CreateLittleZipFile(Statics.zipPackage.DocumentSetID.ToString(), zp.FileName, zp.ParentZipFileName, File.GetLastWriteTime(appInfo.InputPath)); } break; case ".con": conFileService.CreateConFile(Statics.zipPackage.DocumentSetID.ToString(), zp.FileName, zp.ParentZipFileName, File.GetLastWriteTime(appInfo.InputPath)); break; } /*SqlCommand sqlComm = new SqlCommand("sp_InsertInputFile", sqlConn); * sqlComm.CommandType = CommandType.StoredProcedure; * * SqlParameter InputFileName = sqlComm.Parameters.Add("@INPUTFILENAME", SqlDbType.VarChar); * InputFileName.Direction = ParameterDirection.Input; * InputFileName.Value = zp.FileName; * * SqlParameter DocType = sqlComm.Parameters.Add("@DOCTYPE", SqlDbType.VarChar); * DocType.Direction = ParameterDirection.Input; * DocType.Value = zp.DocumentType; * * SqlParameter ParentDocFileName = sqlComm.Parameters.Add("@PARENTDOCFILENAME", SqlDbType.VarChar); * ParentDocFileName.Direction = ParameterDirection.Input; * ParentDocFileName.Value = zp.ParentZipFileName; * * SqlParameter BigZip = sqlComm.Parameters.Add("@BIGZIP", SqlDbType.Bit); * BigZip.Direction = ParameterDirection.Input; * BigZip.Value = zp.IsBigZip; * * SqlParameter LittleZip = sqlComm.Parameters.Add("@LITTLEZIP", SqlDbType.Bit); * LittleZip.Direction = ParameterDirection.Input; * LittleZip.Value = zp.IsLittleZip; * * SqlParameter DocumentSetID = sqlComm.Parameters.Add("@DOCUMENTSET_ID", SqlDbType.UniqueIdentifier); * DocumentSetID.Direction = ParameterDirection.Input; * DocumentSetID.Value = Statics.zipPackage.DocumentSetID; * * SqlParameter OffShore = sqlComm.Parameters.Add("@OFFSHORE", SqlDbType.Bit); * OffShore.Direction = ParameterDirection.Input; * OffShore.Value = zp.Offshore; * * SqlParameter ManCo = sqlComm.Parameters.Add("@MANCO", SqlDbType.VarChar); * ManCo.Direction = ParameterDirection.Input; * ManCo.Value = zp.ManCoID.ToString(); * * SqlParameter Domicile = sqlComm.Parameters.Add("@DOMICILE", SqlDbType.VarChar); * Domicile.Direction = ParameterDirection.Input; * Domicile.Value = zp.Domicile; * * SqlParameter StatusID = sqlComm.Parameters.Add("@STATUS_ID", SqlDbType.Int); * StatusID.Direction = ParameterDirection.Input; * StatusID.Value = zp.StatusID; * * SqlParameter InputDateCreation = sqlComm.Parameters.Add("@INPUTCREATIONDATE", SqlDbType.DateTime); * InputDateCreation.Direction = ParameterDirection.Input; * InputDateCreation.Value = zp.InputCreationDate; * * SqlDataReader myReader = sqlComm.ExecuteReader(); * myReader.Close();*/ } } catch (Exception e) { throw NexdoxMessaging.Exception(e.Message, this); } }