Extra backup on my local device

This commit is contained in:
2015-10-10 17:14:24 +02:00
parent 46e6585495
commit b4e8089efc
7 changed files with 141 additions and 39 deletions

View File

@ -91,7 +91,7 @@ namespace CobXmlSupport
try
{
ShowCode FileWin = new ShowCode();
FileWin.Parent = null;
FileWin.FormParent = null;
//FileWin.Labeltext = usageName;
FileWin.Labeltext = fname;
FileWin.CodeShower.Text = File.ReadAllText(fname);

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Reflection;
namespace CobXmlSupport
{
@ -59,7 +60,6 @@ namespace CobXmlSupport
return " *" + S.strX(' ', 72 - 15 - this.FieldName.Length) + "------" + this.FieldName + "\r\n" +
moveCode +
"\r\n *" + S.strX(' ', 72 - 15 - this.FieldName.Length) + "------" + this.FieldName + "\r\n";
}
set{
moveCode = value;
@ -86,6 +86,11 @@ namespace CobXmlSupport
}
set{
moveFromCode = value;
// Debug för att se var datat fyll på
//StackTrace stackTrace = new StackTrace();
//MethodBase methBase = stackTrace.GetFrame(1).GetMethod();
//Debug.WriteLine("MoveFromCode -> "+ methBase.Name.ToString() + " calls MoveFromCode saving " + value);
// Debug för att se var datat fyll på
}
}
//Holding code-parts used when generating moves, from structure

View File

@ -62,7 +62,7 @@ namespace CobXmlSupport
////-------------------------
public readonly string NOMOVE = "NoMove";
private readonly bool MOVEFROM = true;
//private readonly bool MOVEFROM = true;
public string FldPref
{
@ -252,14 +252,17 @@ namespace CobXmlSupport
if (Cc.WorkDicOut.TryGetValue(rw.FieldName, out fieldOutCompl))
{
rw.MoveFromCode = fieldOutCompl;
//Debug.WriteLine("Existerarnde fält: " + rw.FieldName + " Kod : " + fieldOutCompl);
}
else
{
Cc.WorkDicOut.Add(rw.FieldName, "");
//Debug.WriteLine("Upplagt fält: " + rw.FieldName);
}
}
if (rw.Move_FromCode == null) { rw.MoveFromCode = " "; }
Cc.WorkDicOut[rw.FieldName] = rw.Move_FromCode;
FieldList.Add(rw.FieldName, objNr++);
}
// Prefill with possibly filled out code
@ -860,7 +863,7 @@ namespace CobXmlSupport
string IndVarText = " *--------------------------------------------------*\r\n * Extra indexvariabler för occurs-taggar --------*\r\n *--------------------------------------------------*";
string slask = "";
genCode = new ShowCode();
genCode.Parent = this;
genCode.FormParent = this;
genCode.Labeltext = "Creating Initialization Code";
savedFile SF = new savedFile();
@ -915,9 +918,9 @@ namespace CobXmlSupport
Dictionary<string, string> indexNames = new Dictionary<string, string>();
//string IndVarText = " *--------------------------------------------------*\r\n * Extra indexvariabler för occurs-taggar --------*\r\n *--------------------------------------------------*";
string slask = "";
//string slask = "";
genCode = new ShowCode();
genCode.Parent = this;
genCode.FormParent = this;
genCode.Labeltext = "Creating Initialization Code";
savedFile SF = new savedFile();
@ -986,7 +989,7 @@ namespace CobXmlSupport
genCode.CodeShower.Text += " PERFORM VARYING " + indTxt + " FROM 1 BY 1\r\n UNTIL " +
indTxt + "\r\n > " + tmpQfh.qualCobRow.occNum.ToString() + "\r\n"; // +tmpQfh.indexRedText;
if (tmpQfh.qualCobRow.isOccurs) slask = "";
//if (tmpQfh.qualCobRow.isOccurs) slask = "";
}
}
@ -1471,7 +1474,7 @@ namespace CobXmlSupport
string IndVarText = " *--------------------------------------------------*\r\n * Extra indexvariabler för occurs-taggar --------*\r\n *--------------------------------------------------*";
string slask = "";
genMoves = new ShowCode();
genMoves.Parent = this;
genMoves.FormParent = this;
genMoves.Labeltext = "Creating \"move to\" Code";
// CreateComment(genMoves.CodeShower, "Moves to", "Tommy Öman", "Fordonsdata Nordic AB");
@ -1521,7 +1524,7 @@ namespace CobXmlSupport
string aktIndList = "", slask = "", slask2 = "", struktMove = ""; ;
IndexState Is = new IndexState(indexNames, rowList);
genExtMoves = new ShowCode();
genExtMoves.Parent = this;
genExtMoves.FormParent = this;
genExtMoves.Labeltext = "Creating \"move to (with loop)\" Code";
savedFile SF = new savedFile();
@ -1766,7 +1769,7 @@ namespace CobXmlSupport
string aktIndList = "", slask = "", slask2 = "";
IndexState Is = new IndexState(indexNames, rowList, false);
fromMoves = new ShowCode();
fromMoves.Parent = this;
fromMoves.FormParent = this;
fromMoves.Labeltext = "Creating \"move from\" Code";
savedFile SF = new savedFile();
@ -1944,7 +1947,7 @@ namespace CobXmlSupport
string occParIndRows = "";
IndexState Is = new IndexState(indexNames, rowList, false);
fromToMoves = new ShowCode();
fromToMoves.Parent = this;
fromToMoves.FormParent = this;
fromToMoves.Labeltext = "Creating \"move From - To\" Code";
savedFile SF = new savedFile();
@ -2203,7 +2206,7 @@ namespace CobXmlSupport
//Create showing window
fromToMoves = new ShowCode();
fromToMoves.Parent = this;
fromToMoves.FormParent = this;
if (!justOut)
{
fromToMoves.Labeltext = "Created \"move From To\" Code";
@ -2304,14 +2307,14 @@ namespace CobXmlSupport
if (!justOut)
{
fromToMoves.CodeShower.Text += " TO " + tmpQfh.ToExpString();
if (tmpQfh.qualCobRow.MoveFromCode != null && tmpQfh.qualCobRow.Move_FromCode.Trim().Length > 0)
if (tmpQfh.qualCobRow.Move_FromCode != null && tmpQfh.qualCobRow.Move_FromCode.Trim().Length > 0)
{
fromToMoves.CodeShower.Text += tmpQfh.qualCobRow.MoveFromCode + "\r\n";
}
}
else
{
if (tmpQfh.qualCobRow.MoveFromCode != null && tmpQfh.qualCobRow.Move_FromCode.Trim().Length > 0)
if (tmpQfh.qualCobRow.Move_FromCode != null && tmpQfh.qualCobRow.Move_FromCode.Trim().Length > 0)
{
//if (tmpQfh.qualCobRow.MoveFromCode.IndexOf("<?>") > -1 || tmpQfh.qualCobRow.MoveFromCode.IndexOf("<NYPOST>") > -1)
//{
@ -2410,7 +2413,7 @@ namespace CobXmlSupport
//Create showing window
loadResWords();
fromToMoves = new ShowCode();
fromToMoves.Parent = this;
fromToMoves.FormParent = this;
fromToMoves.Labeltext = "Cobol \"reserved\" Words";
savedFile SF = new savedFile();
@ -2471,7 +2474,7 @@ namespace CobXmlSupport
{
//Create showing window
fromToMoves = new ShowCode();
fromToMoves.Parent = this;
fromToMoves.FormParent = this;
fromToMoves.BSynch = true;
fromToMoves.Labeltext = "Cobol \"CrossRef\" List";

View File

@ -2,20 +2,48 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
namespace CobXmlSupport
{
static class Program
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
bool createdNew = true;
using (Mutex mutex = new Mutex(true, "GenCobCode", out createdNew))
{
if (createdNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new GenCobCode());
}
else
{
Process current = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcessesByName(current.ProcessName))
{
if (process.Id != current.Id)
{
SetForegroundWindow(process.MainWindowHandle);
break;
}
}
}
}
}
}
}

View File

@ -17,6 +17,8 @@ namespace CobXmlSupport
public partial class ShowCode : Form
{
private GenCobCode parentWindow=null;
public readonly string CSV = ".csv";
public readonly string DIF = ".dif";
public readonly string JSON = ".json";
@ -67,9 +69,8 @@ namespace CobXmlSupport
}
}
private GenCobCode parentWindow;
public GenCobCode Parent
public GenCobCode FormParent
{
get { return parentWindow; }
set { parentWindow = value; }
@ -104,7 +105,14 @@ namespace CobXmlSupport
{
codeCompleter Cc = new codeCompleter(parentWindow.CmbLastFile.Text, parentWindow.FldPref);
string fieldCompl = "";
this.CodeShower.Text = " InPath = " + Cc.PathId + "\r\n InFile = " + Cc.FileId + "\r\n codeFile = " + Cc.CcFileInId + "\r\n codePath = " + Cc.PathId + Cc.CcFileInId + "\r\n -------------- \r\n" + this.CodeShower.Text;
this.CodeShower.Text = " InPath = " +
Cc.PathId + "\r\n InFile = " +
Cc.FileId + "\r\n codeFile = " +
Cc.CcFileInId + "\r\n codePath = " +
Cc.PathId +
Cc.CcFileInId + "\r\n -------------- \r\n" +
this.CodeShower.Text;
Cc.TryFill_In_Dic();
foreach (CobRow cr in parentWindow.RowList)
@ -127,7 +135,12 @@ namespace CobXmlSupport
refreshWindow("IN");
this.CodeShower.Text = " InPath = " + Cc.PathId + "\r\n InFile = " + Cc.FileId + "\r\n codeFile = " + Cc.CcFileInId + "\r\n codePath = " + Cc.PathId + Cc.CcFileInId + "\r\n -------------- \r\n" + this.CodeShower.Text;
this.CodeShower.Text = " InPath = " +
Cc.PathId + "\r\n InFile = " +
Cc.FileId + "\r\n codeFile = " +
Cc.CcFileInId + "\r\n codePath = " +
Cc.PathId +
Cc.CcFileInId + "\r\n -------------- \r\n" + this.CodeShower.Text;
}
@ -311,7 +324,13 @@ namespace CobXmlSupport
{
codeCompleter Cc = new codeCompleter(parentWindow.CmbLastFile.Text, parentWindow.FldPref);
string fieldCompl = "";
this.CodeShower.Text = " InPath = " + Cc.PathId + "\r\n InFile = " + Cc.FileId + "\r\n codeFile = " + Cc.CcFileOutId + "\r\n codePath = " + Cc.PathId + Cc.CcFileOutId + "\r\n -------------- \r\n" + this.CodeShower.Text;
this.CodeShower.Text = " InPath = " +
Cc.PathId + "\r\n InFile = " +
Cc.FileId + "\r\n codeFile = " +
Cc.CcFileOutId + "\r\n codePath = " +
Cc.PathId +
Cc.CcFileOutId + "\r\n -------------- \r\n" + this.CodeShower.Text;
Cc.TryFill_Out_Dic();
// wrkDic = new Dictionary<string, string>();
@ -335,7 +354,12 @@ namespace CobXmlSupport
refreshWindow("OUT");
this.CodeShower.Text = " InPath = " + Cc.PathId + "\r\n InFile = " + Cc.FileId + "\r\n codeFile = " + Cc.CcFileOutId + "\r\n codePath = " + Cc.PathId + Cc.CcFileOutId + "\r\n -------------- \r\n" + this.CodeShower.Text;
this.CodeShower.Text = " InPath = " +
Cc.PathId + "\r\n InFile = " +
Cc.FileId + "\r\n codeFile = " +
Cc.CcFileOutId + "\r\n codePath = " +
Cc.PathId +
Cc.CcFileOutId + "\r\n -------------- \r\n" + this.CodeShower.Text;
}
private void btnSaveAktualText_Click(object sender, EventArgs e)

View File

@ -9,6 +9,8 @@ namespace CobXmlSupport
{
public class codeCompleter
{
private readonly string LocBackup = "C:\\CCBackup\\";
private Dictionary<string, string> __wrkDicIn = null;
private Dictionary<string, string> __wrkDicOut = null;
private string __FieldPrefix;
@ -113,10 +115,10 @@ namespace CobXmlSupport
__ccFileOutIdNoSuff = __fileId.Substring(0, __fileId.LastIndexOf(".")) + ".Out" + gPrefix;
}
private string backupSuffix()
private string backupSuffix(bool rideOver=false)
{
string tmpSuff = "";
if (S.ettingUserCodeBcup)
if (S.ettingUserCodeBcup||rideOver)
{
tmpSuff = "." +
(DateTime.Now.Year - 2000).ToString("00") +
@ -133,6 +135,17 @@ namespace CobXmlSupport
return tmpSuff;
}
private string SafeBackPath()
{
return LocBackup +
"BC"+
(DateTime.Now.Year - 2000).ToString("00") +
DateTime.Now.Month.ToString("00") +
DateTime.Now.Day.ToString("00") +
"\\";
}
public void TryFill_In_Dic()
{
@ -173,18 +186,31 @@ namespace CobXmlSupport
public void Save_In_Dic()
{
string ccFileInId = __jsonPathId + __ccFileInId;
if (Directory.Exists(__jsonPathId + @"\JsonBackup\")) { }
if (Directory.Exists(__jsonPathId + @"JsonBackup\")) { }
else
{
Directory.CreateDirectory(__jsonPathId + @"\JsonBackup\");
Directory.CreateDirectory(__jsonPathId + @"JsonBackup\");
}
string ccFileInBackup = __jsonPathId + @"\JsonBackup\" + __ccFileInIdNoSuff + backupSuffix();
//Panik-backup
if (Directory.Exists(SafeBackPath())) { }
else
{
Directory.CreateDirectory(SafeBackPath());
}
string ccFileInPanikBackup = SafeBackPath() + __ccFileInIdNoSuff + backupSuffix(true);
//Panik-backup
string ccFileInBackup = __jsonPathId + @"JsonBackup\" + __ccFileInIdNoSuff + backupSuffix();
if (__filePathId.Trim() == "") { }
else
{
if (File.Exists(ccFileInId))
{
File.Copy(ccFileInId, ccFileInPanikBackup);
if (File.Exists(ccFileInBackup))
{
File.Delete(ccFileInBackup);
@ -195,21 +221,36 @@ namespace CobXmlSupport
}
}
public void Save_Out_Dic()
{
string ccFileOutId = __jsonPathId + __ccFileOutId;
if (Directory.Exists(__jsonPathId + @"\JsonBackup\")) { }
if (Directory.Exists(__jsonPathId + @"JsonBackup\")) { }
else
{
Directory.CreateDirectory(__jsonPathId + @"\JsonBackup\");
Directory.CreateDirectory(__jsonPathId + @"JsonBackup\");
}
string ccFileOutBackup = __jsonPathId + @"\JsonBackup\" + __ccFileOutIdNoSuff + backupSuffix();
//Panik-backup
if (Directory.Exists(SafeBackPath())) { }
else
{
Directory.CreateDirectory(SafeBackPath());
}
string ccFileOutPanikBackup = SafeBackPath() + __ccFileOutIdNoSuff + backupSuffix(true);
//Panik-backup
string ccFileOutBackup = __jsonPathId + @"JsonBackup\" + __ccFileOutIdNoSuff + backupSuffix();
if (__filePathId.Trim() == "") { }
else
{
if (File.Exists(ccFileOutId))
{
File.Copy(ccFileOutId, ccFileOutPanikBackup);
if (File.Exists(ccFileOutBackup))
{
File.Delete(ccFileOutBackup);

View File

@ -128,7 +128,8 @@ namespace CobXmlSupport
txtUserName.Text = value;
}
}
public string CompanyName
public string SettingsCompanyName
{
get
{