private void BuildBenLinkDLINI(List <BenRecord> fileList) { string requestfilename = m_tempDirectoryName + "benlink.req"; string myINIFile = "[Signature]" + System.Environment.NewLine + "Program=BenLink" + System.Environment.NewLine + "FileType=Request" + System.Environment.NewLine + "FileVersion=1" + System.Environment.NewLine + System.Environment.NewLine + "[General]" + System.Environment.NewLine + "NbRequest=" + fileList.Count.ToString() + System.Environment.NewLine + System.Environment.NewLine + "[Device]" + System.Environment.NewLine + "DeviceType=5" + System.Environment.NewLine + "DeviceSN=" + m_serialNumber + System.Environment.NewLine + "NominalFrequency=60" + System.Environment.NewLine + "DataDirectory=" + m_tempDirectoryName + System.Environment.NewLine + System.Environment.NewLine + "CommAddress=1" + System.Environment.NewLine + "[ConnectionParam]" + System.Environment.NewLine + "AccessType=0" + System.Environment.NewLine + "UserName=0" + System.Environment.NewLine + "IPAddress=" + m_ipAddress + System.Environment.NewLine + "HangupTimeout=0"; int i = 1; foreach (BenRecord currec in fileList) { myINIFile += System.Environment.NewLine + System.Environment.NewLine + System.Environment.NewLine + "[Request" + i++ + "]" + System.Environment.NewLine + "RequestType=2" + System.Environment.NewLine + "RecordNum=" + currec.Id + System.Environment.NewLine + "SubBenNum=0" + System.Environment.NewLine + "Origin=1" + System.Environment.NewLine + "OptionFlags=2" + System.Environment.NewLine + "DataPath=" + m_tempDirectoryName + System.Environment.NewLine + "FileName=" + Get232Fn(currec.DateTime, currec.Id.ToString()); } try { System.IO.FileInfo file = new System.IO.FileInfo(requestfilename); file.Directory.Create(); FileSystem.WriteAllText(file.FullName, myINIFile, false, System.Text.Encoding.ASCII); } catch (Exception ex) { Program.Log("BuildBenLinkDLINI error: " + m_siteName + " - " + ex.ToString(), m_tempDirectoryName); throw new System.Exception("BuildBenLinkDLINI error: " + m_siteName + " - " + ex.ToString()); } }
private void BuildBenLinkDirINI() { string requestFileName = localPath + "\\benlink.req"; string myINIFile = "[Signature]" + System.Environment.NewLine + "Program=BenLink" + System.Environment.NewLine + "FileType=Request" + System.Environment.NewLine + "FileVersion=1" + System.Environment.NewLine + System.Environment.NewLine + "[General]" + System.Environment.NewLine + "NbRequest=1" + System.Environment.NewLine + System.Environment.NewLine + "[Device]" + System.Environment.NewLine + "DeviceType=5" + System.Environment.NewLine + "DeviceSN=" + serialNumber + System.Environment.NewLine + "NominalFrequency=60" + System.Environment.NewLine + "DataDirectory=" + localPath + '\\' + System.Environment.NewLine + System.Environment.NewLine + "[ConnectionParam]" + System.Environment.NewLine + "AccessType=0" + System.Environment.NewLine + "UserName=0" + System.Environment.NewLine + "CommAddress=1" + System.Environment.NewLine + "IPAddress=" + ipAddress + System.Environment.NewLine + "HangupTimeout=0" + System.Environment.NewLine + System.Environment.NewLine + "[Request1]" + System.Environment.NewLine + "RequestType=1" + System.Environment.NewLine + "Origin=1" + System.Environment.NewLine + "SubBens=1" + System.Environment.NewLine + "DataPath=" + localPath; try { System.IO.FileInfo file = new System.IO.FileInfo(requestFileName); file.Directory.Create(); FileSystem.WriteAllText(file.FullName, myINIFile, false, System.Text.Encoding.ASCII); } catch (Exception ex) { Program.Log("BuildBenLinkDirINI error: " + siteName + '-' + ex.ToString()); throw new SystemException("BuildBenLinkDirINI error: " + siteName + '-' + ex.ToString()); } }
private void FixCFGFiles(List <BenRecord> fileList) { try { string curFileName; string curFileContent; foreach (BenRecord curRec in fileList) { curFileName = localPath + "\\" + get232FN(curRec.rDateTime, serialNumber) + ".cfg"; if (FileSystem.FileExists(curFileName)) { curFileContent = FileSystem.ReadAllText(curFileName); FileSystem.WriteAllText(curFileName, siteName + curFileContent, false, System.Text.Encoding.ASCII); } } } catch (Exception ex) { Program.Log("fixcfgFiles error: " + siteName + " - " + ex.ToString()); throw new System.Exception("fixcfgFiles error: " + siteName + " - " + ex.ToString()); } }
private void BuildBenLinkDLINI(List <BenRecord> fileList) { string requestfilename = localPath + "\\benlink.req"; string myINIFile = "[Signature]" + System.Environment.NewLine + "Program=BenLink" + System.Environment.NewLine + "FileType=Request" + System.Environment.NewLine + "FileVersion=1" + System.Environment.NewLine + System.Environment.NewLine + "[General]" + System.Environment.NewLine + "NbRequest=" + fileList.Count.ToString() + System.Environment.NewLine + System.Environment.NewLine + "[Device]" + System.Environment.NewLine + "DeviceType=5" + System.Environment.NewLine + "DeviceSN=" + serialNumber + System.Environment.NewLine + "NominalFrequency=60" + System.Environment.NewLine + "DataDirectory=" + localPath + '\\' + System.Environment.NewLine + System.Environment.NewLine + "CommAddress=1" + System.Environment.NewLine + "[ConnectionParam]" + System.Environment.NewLine + "AccessType=0" + System.Environment.NewLine + "UserName=0" + System.Environment.NewLine + "IPAddress=" + ipAddress + System.Environment.NewLine + "HangupTimeout=0"; int i = 1; int curYear = DateTime.Now.Year; foreach (BenRecord currec in fileList) { if (currec.rDateTime.Year > curYear) { SendFileFromFutureNotification("Record ID: " + currec.rId); throw new System.Exception("FileID " + currec.rId + " at site " + siteName + " from the future. Fix DFR clock."); } if (currec.rDateTime > System.IO.File.GetLastWriteTime(lastFileDownloaded)) { //Program.Log("Compare: " + currec.rId + ' ' + currec.rDateTime.ToString() + " > " + System.IO.File.GetLastWriteTime(lastFileDownloaded)); myINIFile += System.Environment.NewLine + System.Environment.NewLine + System.Environment.NewLine + "[Request" + i++ + "]" + System.Environment.NewLine + "RequestType=2" + System.Environment.NewLine + "RecordNum=" + currec.rId + System.Environment.NewLine + "SubBenNum=0" + System.Environment.NewLine + "Origin=1" + System.Environment.NewLine + "OptionFlags=1" + System.Environment.NewLine + "DataPath=" + localPath + System.Environment.NewLine + "FileName=" + get232FN(currec.rDateTime, serialNumber); } //"FileName=" +currec.rDateTime.ToString("yyMMdd,HHmmssfff") +"," +tzoffset +"," +Replace(sitename, " ", "_") +"," +siteuser +",TVA" //working "FileName=" +siteuser +"-" +currec.rId +"-" +currec.rDateTime.ToString("yyMMdd-HHmmssfff") //using the property in the site base class for bens. //if it causes problems with the openFLE we may need to 2 folders one for the aux files and one for the //comtrade data itself. may want to consider making this a property in the app.config file. //"DataPath=" +Replace(localPath, "E:\ben", "E:\bencomtrade") +System.Environment.NewLine +_ } try { System.IO.FileInfo file = new System.IO.FileInfo(requestfilename); file.Directory.Create(); FileSystem.WriteAllText(file.FullName, myINIFile, false, System.Text.Encoding.ASCII); } catch (Exception ex) { Program.Log("BuildBenLinkDLINI error: " + siteName + " - " + ex.ToString()); throw new System.Exception("BuildBenLinkDLINI error: " + siteName + " - " + ex.ToString()); } }