Esempio n. 1
0
        public void CloseModelConnection()
        {
            try
            {
                scERwin.PersistenceUnits.Clear();
                SCAPI.Sessions scSessionCol = scERwin.Sessions;
                foreach (SCAPI.Session scSes in scSessionCol)
                {
                    scSes.Close();
                }

                while (scSessionCol.Count > 0)
                {
                    scSessionCol.Remove(0);
                }

                scPersistenceUnit = null;
                //scSession.Close();
                Logger.PrintLC("Session closed successfully.", 2);
            }
            catch (Exception exp)
            {
                Logger.PrintLC("Could not close the Session.", 2);
            }
        }
Esempio n. 2
0
        public bool openModelConnection(string ERw)
        {
            if (ERw == null)
            {
                return(false);
            }
            if (!File.Exists(ERw))
            {
                Logger.PrintLC("Could not find file: " + ERw, 2);
                return(false);
            }

            try
            {
                DatabaseN = new List <string>();
                SchemaN   = new List <string> {
                    "SYSADM", "SYSFUN", "SYSIBM", "SYSPROC", "SYSTOOLS"
                };
                fileERwin = ERw;
                FileOps.RemoveAttributes(ERw);
                fileInfoERwin = new FileInfo(fileERwin);
                scERwin       = new SCAPI.Application();

                scPersistenceUnit = scERwin.PersistenceUnits.Add(ERw, "RDO=No");

                scSession = scERwin.Sessions.Add();
                scSession.Open(scPersistenceUnit);
                Logger.PrintLC("Connection opened.", 2);
                return(true);
            }
            catch (Exception exp)
            {
                Logger.PrintLC("Connection opening error: " + exp.Message, 2);
                return(false);
            }
        }