Exemple #1
0
        public void ZipFileS2(string _processby, Main2 main)
        {
            string sPath = Application.StartupPath + "\\Output\\" + Main2.outputFolder;
            string dPath = Application.StartupPath + "\\Output\\AFT_" + main.batchfile + "_" + _processby + ".zip";

            DeleteZipfile();
            ZipFile.CreateFromDirectory(sPath, dPath);
            Ionic.Zip.ZipFile zips = new Ionic.Zip.ZipFile(dPath);
            zips.AddItem(Application.StartupPath + "\\Head");
            zips.Save();
            // CopyZipFile2(_processby, main);
            DeleteFiles(".SQL");
        }
Exemple #2
0
        public void ZipFileS(string _processby, CBS main)
        {
            string sPath = Application.StartupPath + "\\" + Form1.banks + "\\Output\\" + CBS.outputFolder;
            string dPath = Application.StartupPath + "\\" + Form1.banks + "\\AFT_" + Form1.banks.ToUpper() + "_" + main.batchfile + "_" + _processby + "_" + CBS.outputFolder.ToUpper() + ".zip";

            //deleting existing file
            if (File.Exists(dPath))
            {
                File.Delete(dPath);
            }
            //create zip file
            ZipFile.CreateFromDirectory(sPath, dPath);

            Ionic.Zip.ZipFile zips = new Ionic.Zip.ZipFile(dPath);
            //Adding order file to zip file
            zips.AddItem(Application.StartupPath + "\\" + Form1.banks + "\\Head");

            zips.Save();
            DeleteSQl();
        }
Exemple #3
0
        private void meshToText(string _fileName, string _destinationPath, Ionic.Zip.ZipFile _newZip)
        {
            string path                 = _destinationPath + "\\" + _fileName;
            string meshName             = getMeshFileName(_fileName);
            string txtFolderDestination = goUpOneDirectoryRelative(_fileName) + "/" + meshName.Replace('.', '_');
            string newDirectoryPath     = _destinationPath + "\\" + meshName.Replace('.', '-');

            System.IO.DirectoryInfo             di  = System.IO.Directory.CreateDirectory(newDirectoryPath);
            coretechlib.CartoMapReaderDotNetOld cmr = new coretechlib.CartoMapReaderDotNetOld();
            try
            {
                System.Object[] cmrLoad   = cmr.LoadCartoMap(path);
                System.Object[] cmrInfo   = cmr.GetCartoMapInfo();
                System.Object[] cmrExtend = cmr.GetCartoMapExtendedData();

                string vertexPath        = newDirectoryPath + "\\" + "VertexInfo.txt";
                string trianglePath      = newDirectoryPath + "\\" + "TriangleInfo.txt";
                string colorGroupPath    = newDirectoryPath + "\\" + "colorGroupInfo.txt";
                string huePath           = newDirectoryPath + "\\" + "hueInfo.txt";
                string mapInfoPath       = newDirectoryPath + "\\" + "mapInfo.txt";
                string verticesStatePath = newDirectoryPath + "\\" + "verticesStateInfo.txt";
                string triangleStatePath = newDirectoryPath + "\\" + "triangleStateInfo.txt";
                string vertexAttrPath    = newDirectoryPath + "\\" + "vertexAttrInfo.txt";

                if (cmrLoad[10] != null)
                {
                    string[] vertexInfo = cmrLoad[10].ToString().Split(',');
                    System.IO.File.WriteAllLines(vertexPath, vertexInfo);
                }
                if (cmrLoad[11] != null)
                {
                    string[] triangleInfo = cmrLoad[11].ToString().Split(',');
                    System.IO.File.WriteAllLines(trianglePath, triangleInfo);
                }
                if (cmrLoad[12] != null)
                {
                    string[] colorGroupinfo = cmrLoad[12].ToString().Split(',');
                    System.IO.File.WriteAllLines(colorGroupPath, colorGroupinfo);
                }
                if (cmrLoad[13] != null)
                {
                    string[] hueInfo = cmrLoad[13].ToString().Split(',');
                    System.IO.File.WriteAllLines(huePath, hueInfo);
                }
                if (cmrInfo[21] != null)
                {
                    string[] mapInfo = cmrInfo[21].ToString().Split(',');
                    System.IO.File.WriteAllLines(mapInfoPath, mapInfo);
                }
                if (cmrExtend[2] != null)
                {
                    string[] verticesState = cmrExtend[2].ToString().Split(',');
                    System.IO.File.WriteAllLines(verticesStatePath, verticesState);
                }
                if (cmrExtend[3] != null)
                {
                    string[] triangleState = cmrExtend[3].ToString().Split(',');
                    System.IO.File.WriteAllLines(triangleStatePath, triangleState);
                }
                if (cmrExtend[4] != null)
                {
                    string[] vertexAttributes = cmrExtend[4].ToString().Split(',');
                    System.IO.File.WriteAllLines(vertexAttrPath, vertexAttributes);
                }

                if (!System.IO.Directory.Exists(txtFolderDestination) && cmrLoad[10] != null)
                {
                    if (!txtBox_Input.Text.Contains("Processed_"))
                    {
                        _newZip.AddItem(newDirectoryPath, txtFolderDestination);
                    }
                }
            }
            catch (System.Runtime.InteropServices.SEHException)
            {
                //Catch so we can prevent error.
            }
            cmr = null;
        }
Exemple #4
0
        private void extractData(string _pathToZip, string _destinationPath, Ionic.Zip.ZipFile _newZip, List <string> _folderList, List <string> _fileList, List <string> _zipList, List <string> _internalZipList, string _pathOfNewZip, bool _keepUnproccessedData, ref List <string> _summaryText)
        {
            string pathToAdd           = makeRelative(_pathToZip, txtBox_Input.Text);
            string visiTagRelativePath = "";
            int    padLength           = 105 - pathToAdd.Length;
            int    numOfExtractions    = 0;
            bool   isVisiTagLoadError  = false;

            if (padLength < 0)
            {
                padLength = 0;
            }
            try
            {
                using (Ionic.Zip.ZipFile zip = Ionic.Zip.ZipFile.Read(_pathToZip))
                {
                    zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestSpeed;

                    foreach (Ionic.Zip.ZipEntry ze in zip)
                    {//Look at each entry and see if it is a match to extract.
                        string fileName             = ze.FileName;
                        bool   isThereItemToExtract = isThereMatch(fileName.ToLower(), _folderList, _fileList);
                        bool   isItInternalZip      = isMatchingZip(fileName.ToLower(), _internalZipList);

                        if (fileName.EndsWith("WiseTag/"))
                        {
                            visiTagRelativePath = ze.FileName;
                        }

                        if (isThereItemToExtract || isItInternalZip)
                        {
                            numOfExtractions++;
                            string pathOfFileToExtract = (_destinationPath + "\\" + ze.FileName).Replace('/', '\\');
                            string pathInNewZipFile    = goUpOneDirectoryRelative(ze.FileName);
                            ze.Extract(_destinationPath, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
                            if (fileName.EndsWith(".mesh"))
                            {
                                meshToText(fileName, _destinationPath, _newZip);
                                if (_keepUnproccessedData)
                                {
                                    _newZip.AddItem(pathOfFileToExtract, pathInNewZipFile);
                                }
                            }
                            else
                            {
                                if (!(fileName.Contains("/WiseTag/") && (_keepUnproccessedData == false)))
                                {
                                    _newZip.AddItem(pathOfFileToExtract, pathInNewZipFile);
                                }
                            }
                            if (isItInternalZip)
                            {
                                using (Ionic.Zip.ZipFile internalZip = Ionic.Zip.ZipFile.Read(pathOfFileToExtract))
                                {
                                    internalZip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestSpeed;
                                    foreach (Ionic.Zip.ZipEntry zie in internalZip)
                                    {
                                        string internalFileName = zie.FileName;
                                        if (isThereMatch(internalFileName.ToLower(), _folderList, _fileList))
                                        {
                                            string extractionPath = goUpOneDirectoryAbsolute(pathOfFileToExtract);             //path of where to extract the internal zip contents.
                                            string filePath       = (extractionPath + "\\" + zie.FileName).Replace('/', '\\'); //path of directory to be saved inside the zipfile
                                            zie.Extract(extractionPath, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
                                            _newZip.AddItem(filePath, pathInNewZipFile);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    _newZip.Save();
                }
            }
            catch (Ionic.Zip.BadReadException)
            {//If zip file is unreadable.
                string name = getLastDirectoryName(_pathToZip);
                if (name.Contains(".zip"))
                {
                    _summaryText.Add(pathToAdd + "Unable to Read".PadLeft(padLength));
                    txtbox_Summary.AppendText(pathToAdd + "Unable to Read".PadLeft(padLength) + "\r\n");
                    txtbox_Summary.Update();
                    System.IO.File.Delete(_newZip.Name);
                }
            }
            catch (Ionic.Zip.ZipException)
            {//If zip file is unreadable.
                string name = getLastDirectoryName(_pathToZip);
                if (name.Contains(".zip"))
                {
                    _summaryText.Add(pathToAdd + "Unable to Read".PadLeft(padLength));
                    txtbox_Summary.AppendText(pathToAdd + "Unable To Read".PadLeft(padLength) + "\r\n");
                    txtbox_Summary.Update();
                    System.IO.File.Delete(_newZip.Name);
                }
            }
            string visiTagDirectory = "";

            getVisiTagPath(_destinationPath, ref visiTagDirectory);
            try
            {
                if (System.IO.Directory.Exists(visiTagDirectory))
                {
                    coretechlib.CartoMapReaderDotNet cmrdn = new coretechlib.CartoMapReaderDotNet();
                    string visiTagDirectoryOpen            = visiTagDirectory + "\\";
                    uint[] visiTagIDs = cmrdn.GetAllVisiTagIDs(visiTagDirectoryOpen);
                    if (visiTagIDs.Length != 0)
                    {
                        visiTagToText(visiTagIDs, visiTagDirectory, _destinationPath, visiTagRelativePath, _newZip, ref isVisiTagLoadError);
                    }
                    cmrdn = null;
                }
            }
            catch (System.Runtime.InteropServices.SEHException)
            {
            }
            if (numOfExtractions == 0)
            {
                _summaryText.Add(pathToAdd + "No Data".PadLeft(padLength));
                txtbox_Summary.AppendText(pathToAdd + "No Data".PadLeft(padLength) + "\r\n");
                txtbox_Summary.Update();
                System.IO.File.Delete(_newZip.Name);
            }
            else if (isVisiTagLoadError)
            {
                _summaryText.Add(pathToAdd + "Unable to Read VisiTag".PadLeft(padLength));
                txtbox_Summary.AppendText(pathToAdd + "Unable to read VisiTag".PadLeft(padLength) + "\r\n");
                txtbox_Summary.Update();
            }
            else
            {
                _summaryText.Add(pathToAdd + "Success".PadLeft(padLength));
                txtbox_Summary.AppendText(pathToAdd + "Success".PadLeft(padLength) + "\r\n");
                txtbox_Summary.Update();
            }
            deleteTempEntries(_destinationPath, _zipList);
        }
Exemple #5
0
        private void visiTagToText(uint[] _visiTagIDs, string _pathToVisiTag, string _destinationPath, string _fileName, Ionic.Zip.ZipFile _newZip, ref bool _isVisiTagLoadError)
        {
            string visiTagExportDirectory = _pathToVisiTag + "\\VisiTagExport";
            string fileNameWithoutWiseTag = goUpOneDirectoryRelative(goUpOneDirectoryRelative(_fileName));
            string txtFolderDestination   = fileNameWithoutWiseTag + "/VisiTagExport";

            coretechlib.CartoMapReaderDotNet cmr = new coretechlib.CartoMapReaderDotNet();
            System.IO.DirectoryInfo          di  = System.IO.Directory.CreateDirectory(visiTagExportDirectory);

            string allPosPath = visiTagExportDirectory + "\\AllPositions.txt";
            //string EndEmperiumPosPath = visiTagExportDirectory + "\\EndEmperium.txt";
            string VisiTagInfoPath     = visiTagExportDirectory + "\\VisiTagInfo.txt";
            string VisiTagSessionsPath = visiTagExportDirectory + "\\VisiTagSessions.txt";

            var allPositionsText = new List <string>();
            //var endEmperiumPosText = new List<string>();
            var visiTagInfoText     = new List <string>();
            var visiTagSessionsText = new List <string>();


            int numOfFilesRead = 0;

            allPositionsText.Add("\tVisiTagID\tSessionID\tAllPosTimeStamp\tAllPosValidStatus\tX\tY\tZ");
            //endEmperiumPosText.Add("\tVisiTagID\tSessionID\tEndEmpPosTimeStamp\tEndEmpValidStatus\tX\tY\tZ");
            visiTagSessionsText.Add("\tVisiTagID\tSessionID\tStartTs\tEndTs\tPresetID\tMapID");

            for (int i = 0; i < _visiTagIDs.Length; i++)
            {
                try
                {
                    object[] loadVisiTag = cmr.LoadVisiTagData(_pathToVisiTag + "\\", _visiTagIDs[i]);
                    string   statusText  = (string)loadVisiTag[0]; //Success or Error
                    if (statusText == "Success")
                    {
                        numOfFilesRead++;
                        Int32  sessionID            = (Int32)loadVisiTag[1];                  //Session ID for synchronization with RF and CF recordings
                        string ablatingCatheterName = (string)loadVisiTag[3];                 //Ablation catheter name as String value
                        Int32[,] ablatingChannelsID = (Int32[, ])loadVisiTag[4];              //unipolar ID, bipolar ID (if not a bipolar channel, bipolarID = -1)
                        Int32[] startEndTimestamp = (Int32[])loadVisiTag[5];                  //Start and end VisiTag timestamps
                        Int32[] mapIDs            = (Int32[])loadVisiTag[6];                  //the selected map when the ablation was performed
                        Int32[][,] ablationIntervalsPerChannel = (Int32[][, ])loadVisiTag[7]; //used in multi electrode ablation - single list for focal catheter
                        bool     isForceCatheter          = (bool)loadVisiTag[8];             // Indicates if this is a Biosense batheter with eeprom or external on(Only Bionsense Catheter are allowed)
                        bool     isMultiElectrodeCatheter = (bool)loadVisiTag[9];             //Used for nMarq catheter
                        bool     isTGA               = (bool)loadVisiTag[10];                 //Is temperature guided ablation used.
                        Int32    presetID            = (Int32)loadVisiTag[11];                //User setup settings ID. The settings stored in CARTO Data Table - CONFIG_VISI_TAG_PRESET_TABLE
                        string[] touchAtStartSession = (string[])loadVisiTag[12];             //Could be one of: "In Touch", "Not In Touch", "Unknown", "Not Supported" -this is part of the TPI capability
                        //All the catheter positions included in this session.
                        UInt32[][][] allPositionTimestamps = (UInt32[][][])loadVisiTag[13];
                        Double[][][,] allPositions = (Double[][][, ])loadVisiTag[14];
                        Int32[][][] allPositionValidStatuses = (Int32[][][])loadVisiTag[15];   //Valid status per timestamp
                        //All the catheter positions included in this session.
                        //UInt32[][][] endExperiumTimestamps = (UInt32[][][])loadVisiTag[16];
                        //Double[][][,] endExperiumPositions = (Double[][][,])loadVisiTag[17];
                        //Int32[][][] endExperiumValidStatuses = (Int32[][][])loadVisiTag[18];
                        //Three typed data indices for synchronization between Visitag Vatheter positions, RF Ablation data, and Catheter Force Data.
                        for (int x = 0; x < allPositions.Length; x++)
                        {
                            for (int y = 0; y < allPositions[x].Length; y++)
                            {
                                for (int z0 = 0; z0 < allPositions[x][y].GetLength(0); z0++)
                                {
                                    for (int z1 = 0; z1 < allPositions[x][y].GetLength(1); z1 += 3)
                                    {
                                        allPositionsText.Add("\t" + _visiTagIDs[i] + "\t" + sessionID + "\t" + allPositionTimestamps[x][y][z0] + "\t" + allPositionValidStatuses[x][y][z0] + "\t" + string.Format("{0:0.000}", allPositions[x][y][z0, z1]) + "\t" + string.Format("{0:0.000}", allPositions[x][y][z0, z1 + 1]) + "\t" + string.Format("{0:0.000}", allPositions[x][y][z0, z1 + 2]));
                                    }
                                }
                            }
                        }

                        /*for (int x = 0; x < endExperiumPositions.Length; x++)
                         * {
                         *  for (int y = 0; y < endExperiumPositions[x].Length; y++)
                         *  {
                         *      for (int z0 = 0; z0 < endExperiumPositions[x][y].GetLength(0); z0++)
                         *      {
                         *          for (int z1 = 0; z1 < endExperiumPositions[x][y].GetLength(1); z1 += 3)
                         *          {
                         *              endEmperiumPosText.Add("\t" + _visiTagIDs[i] + "\t" + sessionID + "\t" + endExperiumTimestamps[x][y][z0] + "\t" + endExperiumValidStatuses[x][y][z0] + "\t" + string.Format("{0:0.000}", endExperiumPositions[x][y][z0, z1]) + "\t" + string.Format("{0:0.000}", endExperiumPositions[x][y][z0, z1 + 1]) + "\t" + string.Format("{0:0.000}", endExperiumPositions[x][y][z0, z1 + 2]));
                         *          }
                         *      }
                         *  }
                         * }*/
                        visiTagSessionsText.Add("\t" + _visiTagIDs[i] + "\t" + sessionID + "\t" + startEndTimestamp[0] + "\t" + startEndTimestamp[1] + "\t" + presetID + "\t" + mapIDs[0]);
                        if (i == 0)
                        {
                            string ablatingChannelsIDString = "AblatingChannelsIDs: ";
                            visiTagInfoText.Add("AblatingCatheterName: " + ablatingCatheterName);
                            if (touchAtStartSession.Length > 0)
                            {
                                visiTagInfoText.Add("TouchAtStartSession: " + touchAtStartSession[0]);
                            }
                            else
                            {
                                visiTagInfoText.Add("TouchAtStartSession: null");
                            }
                            for (int j = 0; j < ablatingChannelsID.GetLength(0); j++)
                            {
                                for (int k = 0; k < ablatingChannelsID.GetLength(1); k++)
                                {
                                    ablatingChannelsIDString += ablatingChannelsID[i, j].ToString() + "\t";
                                }
                            }
                            visiTagInfoText.Add(ablatingChannelsIDString);
                            visiTagInfoText.Add("IsForceCatheter: " + isForceCatheter);
                            visiTagInfoText.Add("IsMultiElectrodeCatheter: " + isMultiElectrodeCatheter);
                            visiTagInfoText.Add("IsTGA: " + isTGA);
                        }
                    }
                }
                catch (System.Runtime.InteropServices.SEHException)
                {
                }
                catch (System.IndexOutOfRangeException)
                {
                }
            }

            System.IO.File.WriteAllLines(allPosPath, allPositionsText);
            //System.IO.File.WriteAllLines(EndEmperiumPosPath, endEmperiumPosText.ToArray());
            System.IO.File.WriteAllLines(VisiTagSessionsPath, visiTagSessionsText.ToArray());
            System.IO.File.WriteAllLines(VisiTagInfoPath, visiTagInfoText.ToArray());

            if (!System.IO.Directory.Exists(txtFolderDestination))
            {
                if (!txtBox_Input.Text.Contains("Processed_"))
                {
                    _newZip.AddItem(visiTagExportDirectory, txtFolderDestination);
                }
            }
            if (numOfFilesRead == 0)
            {
                _isVisiTagLoadError = true;
            }
            _newZip.Save();
            cmr = null;
        }