private static string BuildCommandFile(string docPath, FileInfo fileInfo) { try { //blanked in an attempt to handle the weird random saving string tempPath = ""; tempPath = XLtools.TempPath(); string commandFileLoc = tempPath + "VC.command"; //Create stream and add to file. StreamWriter sw = new StreamWriter(commandFileLoc, false, System.Text.Encoding.Default); sw.WriteLine("<<MODE=FILE>>"); sw.WriteLine("<<FILE=" + docPath + ">>"); sw.WriteLine("<<LEVEL01=" + fileInfo.Cabinet + ">>"); foreach (IndexPair i in fileInfo.Indexes) { sw.WriteLine("<<" + i.index + "=" + i.value + ">>"); } sw.Flush(); sw.Close(); //return the location of our new command file. return(commandFileLoc); } catch (Exception ex) { XLtools.LogException("XLVC-BuildCommandFile with FileInfo", ex.ToString()); return(null); } }
private static string BuildCommandFile(string docPath, string cabinet = "", string client = "", string status = "", string sender = "", string section = "", string desc = "", string docDate = null, IndexPair additionalIndex1 = null, IndexPair additionalIndex2 = null) { try { if (docDate == null) { docDate = DateTime.Now.ToString("dd/MM/yyyy"); } //blanked in an attempt to handle the weird random saving string tempPath = ""; tempPath = XLtools.TempPath(); string commandFileLoc = tempPath + "VC.command"; string statusIndex = ""; string toBeIndex = ""; XDocument settingsDoc = XLtools.settingsDoc; //query the setting files and try to find a match XElement setting = (from index in settingsDoc.Descendants("Indexes") select index).FirstOrDefault(); foreach (XElement xIndex in setting.Descendants("Index")) { if (xIndex.AttributeValueNull("Type") == "Status") { statusIndex = xIndex.Value; } if (xIndex.AttributeValueNull("Type") == "ToBe") { toBeIndex = xIndex.Value; } } //Create stream and add to file. StreamWriter sw = new StreamWriter(commandFileLoc, false, System.Text.Encoding.Default); sw.WriteLine("<<MODE=FILE>>"); sw.WriteLine("<<FILE=" + docPath + ">>"); sw.WriteLine("<<LEVEL01=" + cabinet + ">>"); sw.WriteLine("<<INDEX02=" + client + ">>"); sw.WriteLine("<<INDEX03=" + desc + ">>"); sw.WriteLine("<<INDEX09=" + section + ">>"); sw.WriteLine("<<INDEX20=" + docDate + ">>"); sw.WriteLine("<<INDEX" + statusIndex + "=" + status + ">>"); sw.WriteLine("<<INDEX" + toBeIndex + "=" + sender + ">>"); if (additionalIndex1 != null) { sw.WriteLine("<<" + additionalIndex1.index + "=" + additionalIndex1.value + ">>"); } if (additionalIndex2 != null) { sw.WriteLine("<<" + additionalIndex2.index + "=" + additionalIndex2.value + ">>"); } sw.Flush(); sw.Close(); //return the location of our new command file. return(commandFileLoc); } catch (Exception ex) { XLtools.LogException("XLVC-BuildCommandFile", ex.ToString()); return(null); } }