public void SaveConfig(EnumConfigType cfgType, object[] listObj)
        {
            if (listObj == null)
            {
                throw new Exception(string.Format("保存的{0}数据为空", cfgType.ToString()));
            }
            string fileSaved = null;
            object objSaved  = null;

            switch (cfgType)
            {
            case EnumConfigType.HardwareCfg:
                //fileSaved = File_HardwareCfg;
                //objSaved=new HardwareCfgManager() {  }
                break;

            case EnumConfigType.SoftwareCfg:
                fileSaved = File_SoftwareCfg;
                break;

            case EnumConfigType.SystemParaCfg:

                break;

            case EnumConfigType.UserCfg:

                break;

            default:
                break;
            }
            string json_str = JsonConvert.SerializeObject(objSaved);

            File.WriteAllText(fileSaved, json_str);
        }
Exemple #2
0
        public void SaveConfig(EnumConfigType cfgType, object[] listObj)
        {
            if (listObj == null)
            {
                throw new Exception(string.Format("保存的{0}数据为空", cfgType.ToString()));
            }
            string fileSaved = null;
            object objSaved  = null;

            switch (cfgType)
            {
            case EnumConfigType.HardwareCfg:
                fileSaved = File_HardwareCfg;
                //objSaved=new HardwareCfgManager() {  }
                break;

            case EnumConfigType.PrescriptionCfg:
                fileSaved = File_PrescriptionCfg;
                objSaved  = new PrescriptionCfgManager();
                (objSaved as PrescriptionCfgManager).Prescriptions = listObj as PrescriptionGridModel[];
                PrescriptionCfgMgr = objSaved as PrescriptionCfgManager;
                break;

            case EnumConfigType.SoftwareCfg:
                fileSaved = File_SoftwareCfg;
                break;

            case EnumConfigType.UserCfg:
                fileSaved = File_UserCfg;
                objSaved  = new UserCfgManager();
                (objSaved as UserCfgManager).Users = listObj as UserModel[];
                UserCfgMgr = objSaved as UserCfgManager;
                break;

            case EnumConfigType.SystemParaCfg:
                fileSaved = File_SystemParaCfg;
                objSaved  = new SystemParaCfgManager();
                (objSaved as SystemParaCfgManager).SystemParaModels = listObj as SystemParaModel[];
                SystemParaCfgMgr = objSaved as SystemParaCfgManager;
                break;

            default:
                break;
            }
            string json_str = JsonConvert.SerializeObject(objSaved);

            File.WriteAllText(fileSaved, json_str);
            //using (FileStream fs = File.Open(fileSaved, FileMode.Create, FileAccess.Write))
            //{
            //    using (StreamWriter wr = new StreamWriter(fs))
            //    {
            //        wr.Write(json_str);
            //        wr.Close();
            //    }
            //    fs.Flush();
            //    fs.Close();
            //}
        }
Exemple #3
0
        public void SaveConfig(EnumConfigType cfgType, object[] listObj)
        {
            if (listObj == null)
            {
                throw new Exception(string.Format("保存的{0}数据为空", cfgType.ToString()));
            }
            string fileSaved = null;
            object objSaved  = null;

            switch (cfgType)
            {
            case EnumConfigType.HardwareCfg:
                //fileSaved = File_HardwareCfg;
                //objSaved=new HardwareCfgManager() {  }
                break;

            case EnumConfigType.SoftwareCfg:
                fileSaved = File_SoftwareCfg;

                break;

            case EnumConfigType.SystemParaCfg:
                fileSaved = File_SystemParaCfg;
                objSaved  = new SystemParaCfgManager();
                (objSaved as SystemParaCfgManager).SystemParaModels = listObj as SystemParaModel[];
                SystemParaCfgMgr = objSaved as SystemParaCfgManager;
                break;

            case EnumConfigType.UserCfg:
                fileSaved = File_UserCfg;
                objSaved  = new UserCfgManager();
                (objSaved as UserCfgManager).Users = listObj as UserModel[];
                break;

            case EnumConfigType.ProcessPara:
                //File.WriteAllText(File_ProcessPara, ProcessData.ToString());
                return;

            default:
                break;
            }
            string json_str = JsonConvert.SerializeObject(objSaved);

            File.WriteAllText(fileSaved, json_str);
        }
Exemple #4
0
        public void SaveConfig(EnumConfigType cfgType, object[] listObj)
        {
            if (listObj == null)
            {
                throw new Exception(string.Format("保存的{0}数据为空", cfgType.ToString()));
            }
            string fileSaved = null;
            object objSaved  = null;

            switch (cfgType)
            {
            case EnumConfigType.ParaCfg:
                fileSaved = File_ParaCfg;
                objSaved  = new ParaManager();
                (objSaved as ParaManager).ParaCfgs = listObj as ParaModel[];
                break;

            default:
                break;
            }
            string json_str = JsonConvert.SerializeObject(objSaved);

            File.WriteAllText(fileSaved, json_str);
        }