public void TestCreate() { using (var stream = new System.IO.MemoryStream()) using (var cfile = new CFile(stream)) { #if !NET_STANDARD Assert.Equal("Windows-1252", cfile.Encoding.WebName); #else Assert.Equal("utf-8", cfile.Encoding.WebName); #endif Assert.Equal(0, cfile.Length); Assert.Equal(0, cfile.Position); Assert.Equal(false, cfile.EOF); Assert.Equal(-1, cfile.Read()); Assert.Equal(true, cfile.EOF); } using (var stream = new System.IO.MemoryStream()) using (var cfile = new CFile(stream, Encoding.UTF8)) { Assert.Equal("utf-8", cfile.Encoding.WebName); Assert.Equal(0, cfile.Length); Assert.Equal(0, cfile.Position); Assert.Equal(false, cfile.EOF); Assert.Equal(-1, cfile.Read()); Assert.Equal(true, cfile.EOF); } }
private string GetGridConfigurationByID(int gridID) { string file = HttpContext.Current.Server.MapPath("../Js/Mods.Core.Hst.Grid." + gridID + ".js"); string fileContent = CFile.Read(file); if (fileContent != "") { return(fileContent); } return(""); }
public void TestCreate() { var stream = new System.IO.MemoryStream(); using (var cfile = new CFile(stream)) { Assert.AreEqual(0, cfile.Length); Assert.AreEqual(0, cfile.Position); Assert.AreEqual(false, cfile.EOF); Assert.AreEqual(-1, cfile.Read()); Assert.AreEqual(true, cfile.EOF); } }
public void Load() { List <CStudent> _oStudents = new List <CStudent>(); CFile oFile = new CFile(); string sRecords = oFile.Read(); string[] arStudents = sRecords.Split('|'); foreach (string sRecord in arStudents) { CStudent oStudent = new CStudent(sRecord); this.Add(oStudent); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string instantid = ""; if (context.Request["instantid"] != null) { instantid = context.Request["instantid"].ToString(); } string file = context.Server.MapPath("../Js/Mods.VouchersExt.ARegisterAppendix.js"); string fileContent = CFile.Read(file); fileContent = fileContent.Replace("[INSTANT]", instantid); context.Response.Write(fileContent); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string instantid = ""; if (context.Request["instant"] != null) { instantid = context.Request["instant"].ToString(); } string entry = instantid.EndsWith("Entry") ? "Entry" : ""; string file = context.Server.MapPath(string.Format("../Js/Mods.Items.Simple{0}.js", entry)); string fileContent = CFile.Read(file); fileContent = fileContent.Replace("[INSTANT]", instantid); context.Response.Write(fileContent); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var instantid = ""; if (context.Request["instantid"] != null) { instantid = context.Request["instantid"].ToString(); } string file = context.Server.MapPath("../Js/Mods.ACore.GroupBaseEntry.js"); string fileContent = CFile.Read(file); fileContent = fileContent.Replace("[INSTANT]", instantid); context.Response.Write(fileContent); }
public void ProcessRequest(HttpContext context) { try { context.Response.ContentType = "text/plain"; string instantid = ""; if (context.Request["instantid"] != null) { instantid = context.Request["instantid"].ToString(); } string file = context.Server.MapPath("Js/Mods.Report.Filter.js"); string fileContent = CFile.Read(file); fileContent = fileContent.Replace("[INSTANT]", instantid); context.Response.Write(fileContent); context.Response.Flush(); } catch (Exception ex) { CLogManager.WritePL("ReportHandler", ex.ToString()); } }
public List <string> FindUrlsList() { try { CFile oFile = new CFile(msFilePath); string e = oFile.Read(); CTextUrlSearch oSearch = new CTextUrlSearch(); List <string> voList = oSearch.GetLinks(e); foreach (var oUrl in voList) { _urList.Add(oUrl); } } catch (System.Exception ex) { CFile oFile = new CFile(); oFile.WriteLog(ex.Message, "error.log"); Console.WriteLine(ex.Message); throw; } return(_urList); }
private void ShowProp() { string strFilePath; String strLine; String[] arrLine; DataTable DT = new DataTable("Table"); DT.Columns.Add("c_prop", System.Type.GetType("System.String")); DT.Columns.Add("c_value", System.Type.GetType("System.String")); DataRow NewRows; ArrayList arrProtocol; String[] strFiles; String[] strLines; strFilePath = cConfig.getappSettings(Config.SettingField.DataSyncDir.ToString()); strFiles = Directory.GetFiles(strFilePath, "act_*.txt"); int c_count; c_count = strFiles.GetLength(0); if (c_count > 0) { Array.Sort(strFiles); foreach (String fname in strFiles) { strFilePath = fname; } CFile FileData = new CFile(strFilePath); List <String> arrLines = FileData.Read(); //strLines = File.ReadAllLines(strFilePath); for (int i = 0; i < arrLines.Count; i++) { strLine = arrLines[i]; //strLine = strLine.Replace(".", ","); arrLine = strLine.Split(';'); if (arrLine[0].ToString() == _arrListIndex[lstProp.SelectedIndex].ToString()) { arrProtocol = cConfig.getObjectProtocol(lstProp.SelectedItem.ToString(), Convert.ToInt16(arrLine[1].ToString())); /// Время записи показаний в счетчике NewRows = DT.NewRow(); NewRows["c_prop"] = "Время"; NewRows["c_value"] = arrLine[2]; DT.Rows.Add(NewRows); int mapIndex = 3; foreach (Config.SysObjectProtocolMap Protocol in arrProtocol) { NewRows = DT.NewRow(); NewRows["c_prop"] = Protocol.Description; NewRows["c_value"] = arrLine[mapIndex + Protocol.Index]; DT.Rows.Add(NewRows); } grdProp.DataSource = DT; grdProp.Columns["c_prop"].HeaderText = "Параметр"; grdProp.Columns["c_value"].HeaderText = "Значение"; grdProp.Columns["c_prop"].Width = 200; } strLine = ""; } } }
public void TestReadBytes() { byte[] buff = new byte[3]; using (var cfile = new CFile(BuildStream("èaà\nüî"))) { Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 168, 97 }, buff); Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 160, 10 }, buff); Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 188, 195 }, buff); Assert.Equal(1, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 174, 188, 195 }, buff); Assert.Equal(0, cfile.Read(buff, 0, 3)); Assert.Equal(0, cfile.Read(buff, 0, 3)); Assert.Equal(true, cfile.EOF); } #if !NET_STANDARD using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) { Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 232, 97, 224 }, buff); Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 10, 252, 238 }, buff); Assert.Equal(0, cfile.Read(buff, 0, 3)); Assert.Equal(true, cfile.EOF); } #endif using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) { Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 168, 97 }, buff); Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 160, 10 }, buff); Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 188, 195 }, buff); Assert.Equal(1, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 174, 188, 195 }, buff); Assert.Equal(0, cfile.Read(buff, 0, 3)); Assert.Equal(true, cfile.EOF); } #if !NET_STANDARD using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) { Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 232, 97, 224 }, buff); Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 10, 252, 238 }, buff); Assert.Equal(0, cfile.Read(buff, 0, 3)); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) { Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 168, 97 }, buff); Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 160, 10 }, buff); Assert.Equal(3, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 195, 188, 195 }, buff); Assert.Equal(1, cfile.Read(buff, 0, 3)); Assert.Equal(new byte[] { 174, 188, 195 }, buff); Assert.Equal(0, cfile.Read(buff, 0, 3)); Assert.Equal(true, cfile.EOF); } #endif }
public void TestRead() { using (var cfile = new CFile(BuildStream("èaà\nüî"))) { Assert.Equal(195, cfile.Read()); Assert.Equal(168, cfile.Read()); Assert.Equal(97, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(160, cfile.Read()); Assert.Equal(10, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(188, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(174, cfile.Read()); Assert.Equal(-1, cfile.Read()); Assert.Equal(-1, cfile.Read()); Assert.Equal(true, cfile.EOF); } #if !NET_STANDARD using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) { Assert.Equal(232, cfile.Read()); Assert.Equal(97, cfile.Read()); Assert.Equal(224, cfile.Read()); Assert.Equal(10, cfile.Read()); Assert.Equal(252, cfile.Read()); Assert.Equal(238, cfile.Read()); Assert.Equal(-1, cfile.Read()); Assert.Equal(true, cfile.EOF); } #endif using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) { Assert.Equal(195, cfile.Read()); Assert.Equal(168, cfile.Read()); Assert.Equal(97, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(160, cfile.Read()); Assert.Equal(10, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(188, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(174, cfile.Read()); Assert.Equal(-1, cfile.Read()); Assert.Equal(true, cfile.EOF); } #if !NET_STANDARD using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) { Assert.Equal(232, cfile.Read()); Assert.Equal(97, cfile.Read()); Assert.Equal(224, cfile.Read()); Assert.Equal(10, cfile.Read()); Assert.Equal(252, cfile.Read()); Assert.Equal(238, cfile.Read()); Assert.Equal(-1, cfile.Read()); Assert.Equal(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) { Assert.Equal(195, cfile.Read()); Assert.Equal(168, cfile.Read()); Assert.Equal(97, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(160, cfile.Read()); Assert.Equal(10, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(188, cfile.Read()); Assert.Equal(195, cfile.Read()); Assert.Equal(174, cfile.Read()); Assert.Equal(-1, cfile.Read()); Assert.Equal(true, cfile.EOF); } #endif }
public void TestRead() { using (var cfile = new CFile(BuildStream("èaà\nüî"))) { Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(168, cfile.Read()); Assert.AreEqual(97, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(160, cfile.Read()); Assert.AreEqual(10, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(188, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(174, cfile.Read()); Assert.AreEqual(-1, cfile.Read()); Assert.AreEqual(-1, cfile.Read()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) { Assert.AreEqual(232, cfile.Read()); Assert.AreEqual(97, cfile.Read()); Assert.AreEqual(224, cfile.Read()); Assert.AreEqual(10, cfile.Read()); Assert.AreEqual(252, cfile.Read()); Assert.AreEqual(238, cfile.Read()); Assert.AreEqual(-1, cfile.Read()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) { Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(168, cfile.Read()); Assert.AreEqual(97, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(160, cfile.Read()); Assert.AreEqual(10, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(188, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(174, cfile.Read()); Assert.AreEqual(-1, cfile.Read()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) { Assert.AreEqual(232, cfile.Read()); Assert.AreEqual(97, cfile.Read()); Assert.AreEqual(224, cfile.Read()); Assert.AreEqual(10, cfile.Read()); Assert.AreEqual(252, cfile.Read()); Assert.AreEqual(238, cfile.Read()); Assert.AreEqual(-1, cfile.Read()); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) { Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(168, cfile.Read()); Assert.AreEqual(97, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(160, cfile.Read()); Assert.AreEqual(10, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(188, cfile.Read()); Assert.AreEqual(195, cfile.Read()); Assert.AreEqual(174, cfile.Read()); Assert.AreEqual(-1, cfile.Read()); Assert.AreEqual(true, cfile.EOF); } }
public void TestReadBytes() { byte[] buff = new byte[3]; using (var cfile = new CFile(BuildStream("èaà\nüî"))) { Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 168, 97 }, buff); Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 160, 10}, buff); Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 188, 195 }, buff); Assert.AreEqual(1, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 174, 188, 195 }, buff); Assert.AreEqual(0, cfile.Read(buff, 0, 3)); Assert.AreEqual(0, cfile.Read(buff, 0, 3)); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) { Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 232, 97, 224 }, buff); Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 10, 252, 238 }, buff); Assert.AreEqual(0, cfile.Read(buff, 0, 3)); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) { Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 168, 97 }, buff); Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 160, 10 }, buff); Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 188, 195 }, buff); Assert.AreEqual(1, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 174, 188, 195 }, buff); Assert.AreEqual(0, cfile.Read(buff, 0, 3)); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) { Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 232, 97, 224 }, buff); Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 10, 252, 238 }, buff); Assert.AreEqual(0, cfile.Read(buff, 0, 3)); Assert.AreEqual(true, cfile.EOF); } using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) { Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 168, 97 }, buff); Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 160, 10 }, buff); Assert.AreEqual(3, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 195, 188, 195 }, buff); Assert.AreEqual(1, cfile.Read(buff, 0, 3)); CollectionAssert.AreEqual(new byte[] { 174, 188, 195 }, buff); Assert.AreEqual(0, cfile.Read(buff, 0, 3)); Assert.AreEqual(true, cfile.EOF); } }
/// <summary> /// Demo regime /// </summary> private void TerminalRefreshDemo() { Config cConf = new Config(); arrInfoLine = new ArrayList(); String strLine; String[] arrLine; string DirPath = cConf.getappSettings(Config.SettingField.DataSyncDir.ToString()); CFile FileDemo = new CFile(DirPath + "/demo_act.txt"); CFile FileDemoNew = new CFile(DirPath + "/demo_act.txt"); arrLineDemo = FileDemo.Read(); /* Прогресс */ statusProgress.Visible = true; statusProgress.Value = 0; TermFile cFileObj = new TermFile(); int c_count = arrLineDemo.Count; int c_Rand; Random fixRand = new Random(); c_Rand = fixRand.Next(1, 7); for (int i = 0; i < c_count; i++) { Thread.Sleep(1000); statusProgress.Step = (80 / c_count); statusProgress.PerformStep(); //arrInfoLine.Add(arrLineDemo[i]); strLine = arrLineDemo[i]; //strLine = strLine.Replace(".", ","); arrLine = strLine.Split(';'); strLine = ""; double dd; int idd; int l_count = arrLine.Length; for (int a = 0; a < l_count; a++) { if (a == 2) { arrLine[a] = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; } //if (a == 13 || a==14 ||a==15) if (a > 10 && Char.IsDigit(Convert.ToChar(arrLine[a].Substring(0, 1)))) { try { dd = Convert.ToDouble(arrLine[a]); dd = dd + (dd / 100 * 0.5); arrLine[a] = dd.ToString(); } catch { idd = Convert.ToInt16(arrLine[a]); idd = idd + (idd / 100 * l_count); arrLine[a] = idd.ToString(); } } } strLine = String.Join(";", arrLine); strLine = strLine.Replace(",", "."); if (i <= c_Rand - 1) { cFileObj.AddLine(strLine); } FileDemoNew.AddLine(strLine); } cFileObj.Write(); FileDemoNew.Write(false); _tCount++; LogFileSave(arrInfoLine); statusProgress.Visible = false; lblTCount.Text = _tCount.ToString(); lblError.Text = _tError.ToString(); }