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);
        }
Exemplo n.º 2
0
        private async void ShowWin()
        {
            if (DevicesIsSelected == true)
            {
                EditDeviceClassWin win = new EditDeviceClassWin(SelectedDevice);
                win.ShowDialog();

                T_DeviceDiagnose t_model = DeviceDiagnoseClass.ConvertToDB(SelectedDevice);
                if (SelectedDevice.id == -1)
                {
                    var id = await _databaseComponent.Add <T_DeviceDiagnose>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedDevice.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_DeviceDiagnose>(ServerIP, null, t_model);
                }
            }
            else if (ShaftsIsSelected == true)
            {
                EditShaftClassWin win = new EditShaftClassWin(SelectedShaft);
                win.ShowDialog();

                T_Shaft t_model = ShaftClass.ConvertToDB(SelectedShaft);
                if (SelectedShaft.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Shaft>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedShaft.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Shaft>(ServerIP, null, t_model);
                }
            }
            else if (BearingsIsSelected == true)
            {
                EditBearingClassWin win = new EditBearingClassWin(SelectedBearing);
                win.ShowDialog();

                T_Bearing t_model = BearingClass.ConvertToDB(SelectedBearing);
                if (SelectedBearing.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Bearing>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedBearing.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Bearing>(ServerIP, null, t_model);
                }
            }
            else if (BeltsIsSelected == true)
            {
                EditBeltClassWin win = new EditBeltClassWin(SelectedBelt);
                win.ShowDialog();

                T_Belt t_model = BeltClass.ConvertToDB(SelectedBelt);
                if (SelectedBelt.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Belt>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedBelt.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Belt>(ServerIP, null, t_model);
                }
            }
            else if (GearsIsSelected == true)
            {
                ;
                EditGearClassWin win = new EditGearClassWin(SelectedGear);
                win.ShowDialog();

                T_Gear t_model = GearClass.ConvertToDB(SelectedGear);
                if (SelectedGear.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Gear>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedGear.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Gear>(ServerIP, null, t_model);
                }
            }
            else if (ImpellersIsSelected == true)
            {
                EditImpellerClassWin win = new EditImpellerClassWin(SelectedImpeller);
                win.ShowDialog();

                T_Impeller t_model = ImpellerClass.ConvertToDB(SelectedImpeller);
                if (SelectedImpeller.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Impeller>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedImpeller.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Impeller>(ServerIP, null, t_model);
                }
            }
            else if (MotorsIsSelected == true)
            {
                EditMotorClassWin win = new EditMotorClassWin(SelectedMotor);
                win.ShowDialog();

                T_Motor t_model = MotorClass.ConvertToDB(SelectedMotor);
                if (SelectedMotor.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Motor>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedMotor.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Motor>(ServerIP, null, t_model);
                }
            }
        }