public async Task <bool> ModifyDeviceDiagnoseComponent(string serverip, object obj)
        {
            T_Diagnosis_Model t_model = obj as T_Diagnosis_Model;
            bool success = await _databaseComponent.Modify <T_Diagnosis_Model>(serverip, null, t_model);

            return(success);
        }
        public async Task <long> AddDeviceDiagnoseComponent(string serverip, object obj)
        {
            T_Diagnosis_Model t_model = obj as T_Diagnosis_Model;
            long id = await _databaseComponent.Add <T_Diagnosis_Model>(serverip, t_model);

            return(id);
        }
Exemplo n.º 3
0
        private async void SaveDevice(object para)
        {
            DeviceTreeItemViewModel device = para as DeviceTreeItemViewModel;

            if (device != null)
            {
                try
                {
                    WaitInfo = "模型保存中";
                    Status   = ViewModelStatus.Querying;
                    T_Diagnosis_Model t_model = DeviceDiagnoseComponent.ConvertToDB(device.DeviceDiagnoseComponent);
                    if (device.DeviceDiagnoseComponent.id == -1)
                    {
                        device.DeviceDiagnoseComponent.id = await _deviceDiagnoseTemplateService.AddDeviceDiagnoseComponent(device.ServerIP, t_model);
                    }
                    else
                    {
                        await _deviceDiagnoseTemplateService.ModifyDeviceDiagnoseComponent(device.ServerIP, t_model);
                    }
                }
                catch (Exception ex)
                {
                    _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("设备诊断模型保存", ex));
                }
                finally
                {
                    Status = ViewModelStatus.None;
                }
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }