Example #1
0
        private void scrambleTextPrism()
        {
            string line = string.Empty;

            TextReader    reader = new StreamReader(File.OpenRead(_fileName));
            StringBuilder sb     = new StringBuilder();

            try
            {
                while ((line = reader.ReadLine()) != null)
                {
                    string _scrambledssn = "";
                    string _start        = line.Substring(0, 1);
                    if (_start.Trim().Equals("2"))
                    {
                        string _realssn = line.Substring(11, 10);
                        _realssn      = ScrambleDAL.GetSSN(_realssn);
                        _scrambledssn = ScrambleDAL.scrambledData(_realssn, _key).PadLeft(10, '0');
                        if (!_scrambledssn.Equals(""))
                        {
                            line = line.Substring(0, 11) + _scrambledssn + line.Substring(21, (line.Length - 21));
                        }
                    }
                    sb.AppendLine(line);
                }
                exportScrambledTextFile(sb.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                reader.Close();
            }
        }
Example #2
0
        private void scrambleTextNormal()
        {
            string _Pattern = @"(?<ssn>\d{3}-\d{2}-\d{4})";
            string line     = string.Empty;

            TextReader    reader = new StreamReader(File.OpenRead(_fileName));
            StringBuilder sb     = new StringBuilder();

            try
            {
                while ((line = reader.ReadLine()) != null)
                {
                    Match parsed = Regex.Match(line, _Pattern);
                    if (parsed.Success)
                    {
                        string _scrambledssn = "";
                        string _realssn      = parsed.Groups["ssn"].Value.ToString();
                        _scrambledssn = ScrambleDAL.scrambledData(_realssn, _key);
                        if (!_scrambledssn.Equals(""))
                        {
                            line = line.Replace(_realssn, _scrambledssn);
                        }
                    }
                    sb.AppendLine(line);
                }
                exportScrambledTextFile(sb.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                reader.Close();
            }
        }
Example #3
0
        public void scrambleExcelFile()
        {
            string _oldv = string.Empty;

            try
            {
                myExcel = new Excel.Application();

                myExcel.Workbooks.Open(_fileName, missing, missing, missing, missing, missing,
                                       missing, missing, missing, missing, missing, missing,
                                       missing, missing, missing);


                foreach (Excel.Worksheet sheet in myExcel.Sheets)
                {
                    if ((sheet.Name).Contains(_sheetname))
                    {
                        sheet.Select(Type.Missing);
                    }
                }

                Excel.Worksheet ws = (Excel.Worksheet)myExcel.ActiveSheet;
                _startIndex = 1;
                _endIndex   = ws.Cells.Find("*", System.Reflection.Missing.Value,
                                            System.Reflection.Missing.Value, System.Reflection.Missing.Value,
                                            Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlPrevious,
                                            false, System.Reflection.Missing.Value, System.Reflection.Missing.Value).Row;

                ScrambleDAL.openDB();
                for (int i = _startIndex; i <= _endIndex; i++)
                {
                    if (((Excel.Range)ws.Cells[i, _columnNumber]).Value2 != null)
                    {
                        _oldv = ((Excel.Range)ws.Cells[i, _columnNumber]).Value2.ToString();


                        string _newv = string.Empty;
                        if ((!_wageWorks) && (!_watsonWyatts) && matchSSN(_oldv))
                        {
                            _newv = ScrambleDAL.scrambledData(_oldv, _key);
                        }
                        else if (_wageWorks && matchSSN(_oldv))
                        {
                            string _ln = ((Excel.Range)ws.Cells[i, _lnamecolumnNumber]).Value2.ToString();
                            _ln   = _ln.Substring(0, 3);
                            _newv = ScrambleDAL.scrambledDataCREF(_oldv, _ln, _key);
                        }
                        else if (_watsonWyatts && matchSSN(_oldv))
                        {
                            string _emplStatus = ((Excel.Range)ws.Cells[i, _empStatuscolumnNumber]).Value2.ToString();
                            if (_emplStatus.Trim().Equals("R"))
                            {
                                _newv = ScrambleDAL.scrambledData(_oldv, _key).Substring(5, 4);
                            }
                            else
                            {
                                _newv = _oldv;
                            }
                        }
                        else if (!matchSSN(_oldv))
                        {
                            _newv = _oldv;
                        }
                        ((Excel.Range)ws.Cells[i, _columnNumber]).Value2 = _newv;
                    }
                }
                foreach (Excel.Workbook wb in myExcel.Workbooks)
                {
                    wb.Save();
                }
            }
            catch (Exception ex)
            {
                foreach (Excel.Workbook wb in myExcel.Workbooks)
                {
                    wb.Saved = true;
                }
                throw ex;
            }
            finally
            {
                ScrambleDAL.closeDB();
                Close(myExcel);
            }
        }