CodeCompleter class created
This commit is contained in:
@ -91,68 +91,34 @@ namespace CobXmlSupport
|
||||
|
||||
private void btnSynch_Click(object sender, EventArgs e)
|
||||
{
|
||||
Dictionary<string, string> wrkDic = null, newDic = null;
|
||||
string codeComplement = "", fieldCompl = "", codeComplInit = "";
|
||||
string inFile = parentWindow.CmbLastFile.Text.Substring(parentWindow.CmbLastFile.Text.LastIndexOf("\\") + 1);
|
||||
string inPath = parentWindow.CmbLastFile.Text.Substring(0, parentWindow.CmbLastFile.Text.LastIndexOf("\\") + 1);
|
||||
// string codeFile = inFile.Substring(0, inFile.LastIndexOf(".")) + DIF;
|
||||
string jsonFile = inFile.Substring(0, inFile.LastIndexOf(".")) + JSON;
|
||||
this.CodeShower.Text = " InPath = " + inPath + "\r\n InFile = " + inFile + "\r\n codeFile = " + jsonFile + "\r\n codePath = " + inPath + jsonFile + "\r\n -------------- \r\n" + this.CodeShower.Text;
|
||||
Dictionary<string, string> wrkDic = null;
|
||||
codeCompleter Cc = new codeCompleter(parentWindow.CmbLastFile.Text);
|
||||
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;
|
||||
Cc.TryFill_In_Dic();
|
||||
|
||||
if (File.Exists(inPath + jsonFile))
|
||||
{
|
||||
codeComplement = File.ReadAllText(inPath + jsonFile);
|
||||
}
|
||||
|
||||
if (codeComplement.Length > 0)
|
||||
{
|
||||
wrkDic = moveJsonFieldDictionary(codeComplement);
|
||||
}
|
||||
|
||||
newDic = new Dictionary<string, string>();
|
||||
// wrkDic = new Dictionary<string, string>();
|
||||
foreach (CobRow cr in parentWindow.RowList)
|
||||
{
|
||||
if (!cr.isAttribute && !cr.SampleStr.Equals(parentWindow.NOMOVE))
|
||||
{
|
||||
if (wrkDic != null && wrkDic.Count > 0)
|
||||
if (Cc.WorkDicIn != null && Cc.WorkDicIn.Count > 0)
|
||||
{
|
||||
if (wrkDic.TryGetValue(cr.FieldName, out fieldCompl))
|
||||
if (Cc.WorkDicIn.TryGetValue(cr.FieldName, out fieldCompl))
|
||||
{
|
||||
cr.MoveCode = fieldCompl;
|
||||
}
|
||||
}
|
||||
|
||||
newDic.Add(cr.FieldName, cr.MoveCode);
|
||||
if (cr.MoveCode == null) { cr.MoveCode = " "; }
|
||||
Cc.WorkDicIn[cr.FieldName]=cr.MoveCode;
|
||||
}
|
||||
}
|
||||
|
||||
string njsonObj = createJsonFromDic(newDic);
|
||||
string backupfile;
|
||||
|
||||
if (S.ettingUserCodeBcup)
|
||||
{
|
||||
backupfile = inPath + inFile.Substring(0, inFile.LastIndexOf(".")) + "." +
|
||||
(DateTime.Now.Year - 2000).ToString("00") +
|
||||
DateTime.Now.Month.ToString("00") +
|
||||
DateTime.Now.Day.ToString("00") + "T" +
|
||||
DateTime.Now.Hour.ToString("00") +
|
||||
DateTime.Now.Minute.ToString("00") +
|
||||
DateTime.Now.Second.ToString("00") + DIF;
|
||||
}
|
||||
else
|
||||
{
|
||||
backupfile = inPath + inFile.Substring(0, inFile.LastIndexOf(".")) + ".backup" + JSON;
|
||||
File.Delete(backupfile);
|
||||
}
|
||||
|
||||
if (File.Exists(inPath + jsonFile))
|
||||
{
|
||||
File.Move(inPath + jsonFile, backupfile);
|
||||
}
|
||||
File.WriteAllText(inPath + jsonFile, njsonObj);
|
||||
Cc.Save_In_Dic();
|
||||
|
||||
refreshWindow();
|
||||
this.CodeShower.Text = " InPath = " + inPath + "\r\n InFile = " + inFile + "\r\n codeFile = " + jsonFile + "\r\n codePath = " + inPath + jsonFile + "\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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user