private void CreatePlatforms() { int clientCounter = 1; var initializedPlatforms = new Dictionary <int, _Platform>(); //saves for each iex that make connect the platform object. var testIdentifierLog = new Dictionary <int, string>(); foreach (TestsGroup group in _groupsList) { foreach (PlatformContext pContext in group.pContextList) { var iniFile = new AMS.Profile.Ini("C:\\Program Files\\IEX\\Tests\\TestsINI\\IEX" + pContext.iexNumber.ToString() + "\\Environment.ini"); _project = iniFile.GetValue("IEX" + pContext.iexNumber.ToString(), "PROJECT").ToString(); if (initializedPlatforms.ContainsKey(pContext.iexNumber)) //checks if platform already initialized { if (pContext.Platform == null) { pContext.Platform = initializedPlatforms[pContext.iexNumber]; //platform with iex number pContext.IexNumber already initialized, reference to that platform. } continue; } string testName = pContext.Tests[0].TestName; int testID = pContext.Tests[0].Identifier; foreach (TestData t in pContext.Tests) { if (t.GatewayIsClient) { testName = t.TestName; //gateway log will be in the test where it acts as client testID = t.Identifier; } } pContext.Platform = new _Platform(); if (pContext.Tests[0].Type == PlatformType.CL) { pContext.Platform.ID = "Client" + clientCounter.ToString(); clientCounter++; } else { pContext.Platform.ID = "Gateway"; } if (!testIdentifierLog.ContainsKey(testID)) { string now; DateTime date = DateTime.Now; now = date.ToString("dd/MM/yyyy HH:mm:ss tt"); now = now.Replace("/", "-").Replace("\\", "-").Replace(":", ".").Replace(" ", "_"); testIdentifierLog.Add(testID, testName + "_" + now); } pContext.LogPath = testIdentifierLog[testID]; pContext.Platform.Init(pContext.iexServer, pContext.LogPath, _project); //platform init initializedPlatforms.Add(pContext.iexNumber, pContext.Platform); } testIdentifierLog.Clear(); } }
public void IniWrite() { string file = Path + "\\" + account + ".ini"; FileStream tmp = File.Create(file.Replace(".ini", ".tmp")); FileStream ini; if (!File.Exists(file)) { ini = File.Create(file); ini.Dispose(); } AMS.Profile.Ini Init = new AMS.Profile.Ini(file); try { Init.SetValue("ROSTELECOM", "account", this.account); Init.SetValue("ROSTELECOM", "phone", this.phone); Init.SetValue("ROSTELECOM", "inn", this.inn); Init.SetValue("ROSTELECOM", "korobka", this.korobka); Init.SetValue("ROSTELECOM", "name", this.name); Init.SetValue("ROSTELECOM", "typedoc", this.typedoc); Init.SetValue("ROSTELECOM", "pagecount", this.pagecount); } catch { } tmp.Dispose(); File.Delete(file.Replace(".ini", ".tmp")); }
public void WriteIni() { AMS.Profile.Ini Init = new AMS.Profile.Ini(Application.StartupPath + "\\" + "AbonentPacket.ini"); Init.SetValue("FOLDERS", "JpegFiles", _FolderJpegFiles); Init.SetValue("FOLDERS", "WorkFiles", _FolderWorkFiles); Init.SetValue("EARCHIVE", "UserID", this._UserID); Init.SetValue("EARCHIVE", "DepartID", this._DepartID); Init.SetValue("EARCHIVE", "FormUser", this._User); Init.SetValue("EARCHIVE", "Korobka", this._Korobka); }
public static void ThreadSendFiles() { while (true) { try { if (System.IO.Directory.Exists(theForm._FolderJpegFiles)) { foreach (var file in Directory.GetFiles(theForm._FolderJpegFiles, "*.ini", SearchOption.TopDirectoryOnly)) { if (File.Exists(file.Replace(".ini", ".run"))) { continue; } if (File.Exists(file.Replace(".ini", ".tmp"))) { continue; } AMS.Profile.Ini Init = new AMS.Profile.Ini(file); Document doc = new Document(Init, theForm._FolderJpegFiles); FileStream fs1 = File.Create(file.Replace(".ini", ".run")); fs1.Dispose(); if (doc.SendToArchive() == 200) { FileStream fs = File.Create(file.Replace(".ini", ".200")); fs.Dispose(); File.Move(theForm._FolderJpegFiles + "\\" + doc.account + ".pdf", theForm._FolderWorkFiles + "\\" + doc.account + "-" + DateTime.Now.ToString("yyyyMMddHHmm") + ".pdf"); foreach (var del in Directory.GetFiles(theForm._FolderJpegFiles, doc.account + ".*", SearchOption.TopDirectoryOnly)) { File.Delete(del); } } else { FileStream fs = File.Create(file.Replace(".ini", ".err")); fs.Dispose(); } break; } } } catch (Exception ex) { AbonentPacket.Program.logger_main.Debug(ex.Message); AbonentPacket.Program.logger_main.Debug(ex.StackTrace); } Thread.Sleep(1000); // 10 sec } }
private void ReadLogFolderFromINI() { string iexServer = CmbGateway.Text.Split(' ')[1]; try { AMS.Profile.Ini iniFile = new AMS.Profile.Ini("C:\\Program Files\\IEX\\Tests\\TestsINI\\IEX" + iexServer + "\\Environment.ini"); logFolder = iniFile.GetValue("IEX" + iexServer, "LogDirectory").ToString(); } catch { MessageBox.Show("Failed to Get Log Folder From IEX_" + iexServer + " Environment.ini", "ERROR"); } }
//получение строки соединения с базой данных из ini файла public static string GetConnectionString() { string DATABASE_INI = HttpContext.Current.Server.MapPath("~/CR/CR/database.ini"); string INIT_INI = HttpContext.Current.Server.MapPath("~/CR/CR/init.ini"); AMS.Profile.Ini Init = new AMS.Profile.Ini(INIT_INI); string db = Init.GetValue("DATABASE", "db", ""); AMS.Profile.Ini database = new AMS.Profile.Ini(DATABASE_INI); string SID = database.GetValue(db, "SID", ""); string USER = database.GetValue(db, "USERNAME", ""); string PASSWORD = database.GetValue(db, "PASSWORD", ""); string path = "Data Source=" + SID + "; User ID=" + USER + "; Password="******";Unicode=true"; return(path); }
public Document(AMS.Profile.Ini Init, string Path) { this.Path = Path; try { this.account = Init.GetValue("ROSTELECOM", "account", this.account); this.phone = Init.GetValue("ROSTELECOM", "phone", this.phone); this.inn = Init.GetValue("ROSTELECOM", "inn", this.inn); this.korobka = Init.GetValue("ROSTELECOM", "korobka", this.korobka); this.name = Init.GetValue("ROSTELECOM", "name", this.name); this.typedoc = Init.GetValue("ROSTELECOM", "typedoc", this.typedoc); this.pagecount = Init.GetValue("ROSTELECOM", "pagecount", this.pagecount); } catch { } }
public void ReadIni() { string file = Application.StartupPath + "\\" + "AbonentPacket.ini"; FileStream ini; if (!File.Exists(file)) { ini = File.Create(file); ini.Dispose(); } AMS.Profile.Ini Init = new AMS.Profile.Ini(file); _FolderJpegFiles = Init.GetValue("FOLDERS", "JpegFiles", ""); _FolderWorkFiles = Init.GetValue("FOLDERS", "WorkFiles", ""); _UserID = Init.GetValue("EARCHIVE", "UserID", this._UserID); _DepartID = Init.GetValue("EARCHIVE", "DepartID", this._DepartID); _User = Init.GetValue("EARCHIVE", "FormUser", this._User); _Korobka = Init.GetValue("EARCHIVE", "Korobka", this._Korobka); }
public void IniRead() { string file = Path + "\\" + account + ".ini"; if (File.Exists(file)) { AMS.Profile.Ini Init = new AMS.Profile.Ini(file); try { this.account = Init.GetValue("ROSTELECOM", "account", this.account); this.phone = Init.GetValue("ROSTELECOM", "phone", this.phone); this.inn = Init.GetValue("ROSTELECOM", "inn", this.inn); this.korobka = Init.GetValue("ROSTELECOM", "korobka", this.korobka); this.name = Init.GetValue("ROSTELECOM", "name", this.name); this.typedoc = Init.GetValue("ROSTELECOM", "typedoc", this.typedoc); this.pagecount = Init.GetValue("ROSTELECOM", "pagecount", this.pagecount); } catch { } } }
void IExport.Run() { try { this.theLogger.Log("Export:Run"); AMS.Profile.Ini Ini = new AMS.Profile.Ini(AppDomain.CurrentDomain.BaseDirectory + "AgkExportSettings.ini"); if (!Ini.HasSection("COMMON")) { Ini.SetValue("COMMON", "AgkDataFolder", "C:\\Данные_АГК"); Ini.SetValue("COMMON", "CountPrevMonth", "1"); } string strAgkDataFolder = Ini.GetValue("COMMON", "AgkDataFolder", "C:\\Данные_АГК"); int countPrevMonth = Ini.GetValue("COMMON", "CountPrevMonth", 1); strAgkDataFolder.TrimEnd(new char[] { '\\' }); if (!Directory.Exists(strAgkDataFolder)) { Directory.CreateDirectory(strAgkDataFolder); } Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient("BasicHttpBinding_IHydroService"); const int TYPE_AGK = 6; foreach (var Site in theHydro.GetSiteList(TYPE_AGK)) { string strSiteFolder = strAgkDataFolder + "\\" + Site.SiteCode.ToString(); if (!Directory.Exists(strSiteFolder)) { Directory.CreateDirectory(strSiteFolder); theLogger.Log(strSiteFolder); } strSiteFolder = strSiteFolder + "\\уровни"; if (!Directory.Exists(strSiteFolder)) { Directory.CreateDirectory(strSiteFolder); theLogger.Log(strSiteFolder); } DateTime bgnDate = new DateTime(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month, countPrevMonth); DateTime endDate = new DateTime(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month, DateTime.DaysInMonth(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month)); const int WATER_LEVEL = 2; string strFileName = strSiteFolder + "\\" + Site.SiteCode.ToString() + "_" + bgnDate.ToString("yyyy_MM") + ".asc"; theLogger.Log(strFileName); var fileHandle = File.CreateText(strFileName); var DataValueList = theHydro.GetDataValues(Site.SiteId, bgnDate, endDate, WATER_LEVEL, null, null, null); if (DataValueList != null) { foreach (var item in DataValueList) { string line = item.Date.ToString("dd.MM.yyyy hh:mm:ss") + "\t" + item.Value.ToString() + "\tсм"; fileHandle.WriteLine(line); } } fileHandle.Close(); //for (DateTime currDate = bgnDate; currDate <= endDate; currDate.AddDays(1)) //{ // var DataValueList = theHydro.GetDataValues(Site.SiteId, TYPE_AGK, currDate, WATER_LEVEL, null, null); // foreach (var item in DataValueList) // { // } //} } this.theLogger.Log(strAgkDataFolder); } catch (Exception ex) { this.theLogger.Error(ex.Message); this.theLogger.Error(ex.Source); this.theLogger.Error(ex.StackTrace); } }
public ActionResult Telephone(string telephone) { try { AMS.Profile.Ini Ini = new AMS.Profile.Ini(AppDomain.CurrentDomain.BaseDirectory + "\\Callback.ini"); if (!Ini.HasSection("SMSC")) { Ini.SetValue("SMSC", "login", "mgerasim"); Ini.SetValue("SMSC", "psw", "zaq12wsx"); } string login = Ini.GetValue("SMSC", "login", "some-login"); string psw = Ini.GetValue("SMSC", "psw", "some-password"); string code = this.RandomString(4); string url = "http://smsc.ru/sys/send.php?login="******"&psw=" + psw + "&phones=" + telephone + "&mes=" + code; var request = (HttpWebRequest)WebRequest.Create(url); var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); var serializer = new JavaScriptSerializer(); // For simplicity just use Int32's max value. // You could always read the value from the config section mentioned above. serializer.MaxJsonLength = Int32.MaxValue; CallbackAspDotNetMvc.Models.User theUser = null; theUser = Models.User.GetByPhone(telephone); if (theUser == null) { theUser = new Models.User(); theUser.code = code; theUser.telephone = telephone; theUser.result = responseString; theUser.Save(); } else { theUser.code = code; theUser.result = responseString; theUser.Update(); } var resultData = new { telephone = telephone, result = responseString }; var result = new ContentResult { Content = serializer.Serialize(resultData), ContentType = "application/json" }; return(result); } catch (Exception ex) { var serializer = new JavaScriptSerializer(); // For simplicity just use Int32's max value. // You could always read the value from the config section mentioned above. serializer.MaxJsonLength = Int32.MaxValue; string err = ex.Message; if (ex.InnerException != null) { err += ex.InnerException.Message; } var resultData = new { telephone = telephone, error = err }; var result = new ContentResult { Content = serializer.Serialize(resultData), ContentType = "application/json" }; return(result); } return(View()); }