private static Project loadOldProjectFile(string file) { Project p = new Project(false); Logger.Log("Unzipping file " + file + "..."); unzipFile(file); string projectFile;// = Path.GetDirectoryName(file) + "\\Temp\\" + Path.GetFileName(file); string directory = Path.GetDirectoryName(file); string[] files = Directory.GetFiles(Path.Combine (directory,"Temp"),"*.gprj"); string scriptFile = Path.Combine(directory, "Temp\\user_logics.php"); projectFile = files[0]; StreamReader sr = null; int lineCounter = 0; try { sr = new StreamReader(projectFile); string line, section1, propValue, propName, path, prevPath = ""; bool first = true; bool firstcom = true; bool firstOth = true; string[] lineFields, pathFields; Dictionary<string, string> nodeProps = new Dictionary<string, string>(); int pathLength; while (!sr.EndOfStream) { line = sr.ReadLine(); if (line.Length < 1) continue; lineFields = line.Split(new string[] { "###" }, StringSplitOptions.None); section1 = lineFields[0]; path = getPathString(section1); propValue = lineFields[1]; pathFields = section1.Split(';'); pathLength = pathFields.Length; propName = pathFields[pathLength - 1]; switch (pathFields[0]) { case "Progetto": if (propName.ToLower() == "false") continue; if (!nodeProps.ContainsKey(propName)) nodeProps.Add(propName, propValue); else Logger.Log("Attenzione! Chiave " + propName + "ripetuta per il nodo " + path); break; case "Memoria Globale": if (first) { p.addPropertiesGPRJ(nodeProps); nodeProps.Clear(); prevPath = path; first = false; } if (path == prevPath) { if (!nodeProps.ContainsKey(propName) && !Regex.IsMatch(propName, "false|true", RegexOptions.IgnoreCase) && !String.IsNullOrWhiteSpace(propValue)) nodeProps.Add(propName, propValue); } else { p.VarTree.addVarNodeGPRJ(prevPath, nodeProps); nodeProps.Clear(); nodeProps.Add(propName, propValue); } prevPath = path; break; case "Comunicazione": if (firstcom) { p.VarTree.addVarNodeGPRJ(prevPath, nodeProps); prevPath = path; nodeProps.Clear(); firstcom = false; } if (path == prevPath) { if (!nodeProps.ContainsKey(propName) && !Regex.IsMatch(propName, "false|true", RegexOptions.IgnoreCase) && !String.IsNullOrWhiteSpace(propValue)) nodeProps.Add(propName, propValue); } else { p.ComTree.addComNodeGPRJ(prevPath, nodeProps); nodeProps.Clear(); nodeProps.Add(propName, propValue); } prevPath = path; break; case "Altro": if (firstOth) { if (pathFields[1] == "User") continue; p.ComTree.addComNodeGPRJ(prevPath, nodeProps); prevPath = path; nodeProps.Clear(); firstOth = false; } if (path == prevPath) { if (!nodeProps.ContainsKey(propName) && !Regex.IsMatch(propName, "false|true", RegexOptions.IgnoreCase) && !String.IsNullOrWhiteSpace(propValue)) nodeProps.Add(propName, propValue); } else { p.OtherTree.addReport61850NodeGPRJ(prevPath, nodeProps); nodeProps.Clear(); nodeProps.Add(propName, propValue); } prevPath = path; break; } lineCounter++; } sr.Close(); loadOldScriptFile(p, scriptFile); FileManager.deleteDir(Path.GetDirectoryName(file) + "\\Temp"); } catch (Exception e) { Logger.Log("Errore durante il caricamento del file " + file + " sulla linea: " + lineCounter + "-" + e.Message + " -" + e.StackTrace); } finally { if (sr != null) sr.Close(); } return p; }