Пример #1
0
        public static T_Diagnosis_Model ConvertToDB(DeviceDiagnoseComponent model)
        {
            T_Diagnosis_Model t_model = new T_Diagnosis_Model();

            t_model.id   = model.id;
            t_model.Name = model.Name;
            t_model.Guid = model.Guid;
            if (model.Component != null)
            {
                t_model.Structure = JsonConvert.SerializeObject(model.Component);//可能有问题
            }
            else
            {
                t_model.Structure = null;
            }

            return(t_model);
        }
Пример #2
0
        public static DeviceDiagnoseComponent ConvertFromDB(T_Diagnosis_Model t_model)
        {
            DeviceDiagnoseComponent model = new DeviceDiagnoseComponent();

            model.id   = t_model.id;
            model.Name = t_model.Name;
            model.Guid = t_model.Guid;
            if (!string.IsNullOrWhiteSpace(t_model.Structure))
            {
                model.Component = JsonConvert.DeserializeObject <DeviceDiagnoseClass>(t_model.Structure);
            }
            else
            {
                model.Component = new DeviceDiagnoseClass();
            }
            //修复一些不进行json的字段
            foreach (var shaft in model.Component.Shafts)
            {
                shaft.Component.Parent = model.Component;
                shaft.Component.InitMachComponents();
            }
            return(model);
        }