Esempio n. 1
0
        public static bool AddLink(ref LinkConfigModel linkconfig)
        {
            bool b = false;

            try
            {
                string  path = Directory.GetCurrentDirectory() + "/Config.json";
                JObject config;
                using (StreamReader sr = new StreamReader(path))
                {
                    config = JObject.Parse(sr.ReadToEnd());
                    JArray list = (JArray)config["linklist"];
                    linkconfig.id = list.Count > 0 ?
                                    list.Select(a => (LinkConfigModel)m_opmemory.Deserialize(Convert.FromBase64String(a.ToString()))).ToList().Max(a => a.id) + 1 : 1;
                    list.Add(Convert.ToBase64String(m_opmemory.Serialize(linkconfig)));
                }
                using (StreamWriter sw = new StreamWriter(path))
                {
                    sw.Write(config.ToString());
                }
                b = true;
            }
            catch (Exception e)
            {
                SystemError.Error(e.Message);
            }
            return(b);
        }
Esempio n. 2
0
        void AddTreeNodeServer(LinkConfigModel linkconfig)
        {
            ISqlControl sqlcontrol = null;

            if (linkconfig.type == SqlTypeEmun.SqlServer)
            {
                sqlcontrol = new SqlServerControl();
            }
            m_treenodeserverlist.Add(new TreeNodeServer()
            {
                id               = linkconfig.id,
                text             = linkconfig.name,
                connectionstring = linkconfig.connectionstring,
                database         = linkconfig.database,
                type             = linkconfig.type,
                childer          = new ObservableCollection <TreeNodeDatabase>(),
                sqlcontrol       = sqlcontrol
            });
        }