/// <summary> /// save Data to File /// </summary> /// <param name="FileName">the FileName to use for save</param> /// <param name="FileVersion">optional File-Version to apply - use "" to apply DLL-Version</param> /// <returns>TRUE on success, FALSE on error</returns> private bool _SaveToFile(string FileName, string FileVersion) { // something set in FileName? Exit if not... if (FileName.Trim() == "") { return(false); } DDPro.Software.Net20.Library.Rijndael _cipher = new DDPro.Software.Net20.Library.Rijndael(System.Text.Encoding.UTF8); // get dataset-data string _innerXML = _int_DataSet.GetXml(); StringBuilder _FileCont = new StringBuilder(); _FileCont.AppendLine("CUX = Ciphered User XML"); // set File-Version by Assembly-Number if (FileVersion == "") // no Version specified - use DLL-Version { _FileCont.AppendLine("Version = " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major.ToString() + "." + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString()); } else // Version is specified { _FileCont.AppendLine("Version = " + FileVersion); } _FileCont.AppendLine("Index = " + _set_IdxMode.ToString()); // specify used index _FileCont.AppendLine("-| start |-"); // set StartData-Tag // start Data-Block string _cDat = _cipher.EasyEncrypt(_innerXML, _set_DataCipherPhrase); // add linebreak every 60 signs in Data long _strLen = _cDat.Length; double _runCycles = (_strLen / 60); int _runs = Convert.ToInt32(Math.Floor(_runCycles)); for (long i = 0; i <= _runs; i++) { if ((i * 60) > int.MaxValue) // if not "runable" cycle { return(false); // exit on too many cycles } if (i == _runs) // last cycle - take the rest { _FileCont.AppendLine(_cDat.Substring(Convert.ToInt32(i * 60))); // add 60 signs } else // regular cycle - write 60 signs { _FileCont.AppendLine(_cDat.Substring(Convert.ToInt32(i * 60), 60)); // add 60 signs } } // end Data-Block _FileCont.AppendLine("-| end |-"); // _FileCont.AppendLine( "" ); // 4 debug // _FileCont.AppendLine( _cDat ); // 4 debug // write data to file if (!_fileWriter(FileName, _FileCont.ToString())) { return(false); } // everything has worked, data is saved _int_DataSet.AcceptChanges(); // remind save return(true); }
private string GetColumnControlId() { string controlId = ""; if (IndexColumn >= 0 && IndexColumn <= 9) { controlId = "ctl0" + IndexColumn.ToString(); } if (IndexColumn >= 10 && IndexColumn <= 99) { controlId = "ctl" + IndexColumn.ToString(); } return(controlId); }