Esempio n. 1
0
        private Sys_Device GetDeviceFill(Sys_Device device)
        {
            if (device == null)
            {
                device = new Sys_Device()
                {
                    ID         = Guid.NewGuid(),
                    CreateBy   = Yqun.Common.ContextCache.ApplicationContext.Current.UserName,
                    CreateTime = DateTime.Now
                };
            }

            device.Comment       = Comment.Text;
            device.LastEditBy    = Yqun.Common.ContextCache.ApplicationContext.Current.UserName;
            device.LastEditTime  = DateTime.Now;
            device.TestRoomCode  = TestRoom.SelectedValue.ToString();
            device.DeviceCompany = ComboCompany.Text;
            device.IsActive      = IsActive.Checked;
            device.DeviceType    = Universal.Checked ? DeviceTypeEnum.Universal : DeviceTypeEnum.Pressure;
            device.RemoteCode1   = RemoteCode1.Text;
            device.RemoteCode2   = RemoteCode2.Text;
            device.MachineCode   = MachineCode.Text;
            device.IsDYSF        = Electro.Checked;
            device.DeviceType    = Universal.Checked ? DeviceTypeEnum.Universal : DeviceTypeEnum.Pressure;
            device.Quantum       = string.IsNullOrEmpty(Quantum.Text) ? 0 : int.Parse(Quantum.Text);

            return(device);
        }
Esempio n. 2
0
        private List <SheetDevice> ConvertSource(DataTable table)
        {
            var result = new List <SheetDevice>();

            foreach (DataRow row in table.Rows)
            {
                var device = new Sys_Device()
                {
                    ID               = new Guid(row["ID"].ToString()),
                    ClientConfig     = row["ClientConfig"] as string,
                    DeviceType       = (DeviceTypeEnum)Convert.ToInt32(row["DeviceType"]),
                    IsDYSF           = Convert.ToBoolean(row["IsDYSF"]),
                    Comment          = row["Comment"] as string,
                    ConfigStatus     = Convert.IsDBNull(row["ConfigStatus"]) ? 0 : Convert.ToInt32(row["ConfigStatus"].ToString()),
                    ConfigUpdateTime = Convert.IsDBNull(row["ConfigUpdateTime"]) ? DateTime.MinValue : Convert.ToDateTime(row["ConfigUpdateTime"]),
                    CreateBy         = row["CreateBy"] as string,
                    CreateTime       = Convert.ToDateTime(row["CreateTime"]),
                    DeviceCompany    = row["DeviceCompany"] as string,
                    IsActive         = Convert.ToBoolean(row["IsActive"]),
                    LastEditBy       = row["LastEditBy"] as string,
                    LastEditTime     = Convert.ToDateTime(row["LastEditTime"]),
                    MachineCode      = row["MachineCode"] as string,
                    RemoteCode1      = row["RemoteCode1"] as string,
                    RemoteCode2      = row["RemoteCode2"] as string,
                    TestRoomCode     = row["TestRoomCode"] as string
                };

                var sheet = new SheetDevice()
                {
                    Device       = device,
                    SectionName  = row["标段名称"] as string,
                    UnitName     = row["单位名称"] as string,
                    TestRoomName = row["试验室名称"] as string,
                    SectionCode  = row["标段编码"] as string,
                    TestRoomCode = row["试验室编码"] as string,
                    UnitCode     = row["单位编码"] as string
                };

                result.Add(sheet);
            }

            return(result);
        }
Esempio n. 3
0
        public bool AddDevice(Sys_Device device)
        {
            var sql = "INSERT INTO [dbo].[sys_devices]" +
                      " ([ID]" +
                      ", [MachineCode]" +
                      ", [DeviceType]" +
                      ", [CreateTime]" +
                      ", [CreateBy]" +
                      ", [DeviceCompany]" +
                      ", [IsDYSF]" +
                      ", [RemoteCode1]" +
                      ", [RemoteCode2]" +
                      ", [Comment]" +
                      ", [IsActive]" +
                      ", [LastEditBy]" +
                      ", [LastEditTime]" +
                      ", [TestRoomCode]" +
                      ", [Quantum])" +
                      " VALUES" +
                      " (@ID" +
                      " ,@MachineCode" +
                      " ,@DeviceType" +
                      " ,@CreateTime" +
                      " ,@CreateBy" +
                      " ,@DeviceCompany" +
                      " ,@IsDYSF" +
                      " ,@RemoteCode1" +
                      " ,@RemoteCode2" +
                      " ,@Comment" +
                      " ,@IsActive" +
                      " ,@LastEditBy" +
                      " ,@LastEditTime" +
                      " ,@TestRoomCode" +
                      " ,@Quantum)";

            var command = GetDbCommand(sql);

            command.Parameters.Add(new SqlParameter("@ID", device.ID.ToString()));
            command.Parameters.Add(new SqlParameter("@MachineCode", device.MachineCode));
            command.Parameters.Add(new SqlParameter("@DeviceType", (int)device.DeviceType));
            command.Parameters.Add(new SqlParameter("@CreateTime", device.CreateTime));
            command.Parameters.Add(new SqlParameter("@CreateBy", device.CreateBy));
            command.Parameters.Add(new SqlParameter("@DeviceCompany", device.DeviceCompany));
            command.Parameters.Add(new SqlParameter("@IsDYSF", device.IsDYSF));
            command.Parameters.Add(new SqlParameter("@RemoteCode1", device.RemoteCode1));
            command.Parameters.Add(new SqlParameter("@RemoteCode2", device.RemoteCode2));
            command.Parameters.Add(new SqlParameter("@Comment", device.Comment));
            //command.Parameters.Add(new SqlParameter("@ClientConfig", device.ClientConfig));
            //command.Parameters.Add(new SqlParameter("@ConfigUpdateTime", null));
            //command.Parameters.Add(new SqlParameter("@ConfigStatus", device.ConfigStatus));
            command.Parameters.Add(new SqlParameter("@IsActive", device.IsActive));
            command.Parameters.Add(new SqlParameter("@LastEditBy", device.LastEditBy));
            command.Parameters.Add(new SqlParameter("@LastEditTime", device.LastEditTime));
            command.Parameters.Add(new SqlParameter("@TestRoomCode", device.TestRoomCode));
            command.Parameters.Add(new SqlParameter("@Quantum", device.Quantum));

            try
            {
                if (command.Connection.State != ConnectionState.Open)
                {
                    command.Connection.Open();
                }

                var result = command.ExecuteNonQuery();
                if (result > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
            finally
            {
                try
                {
                    command.Connection.Close();
                }
                catch (Exception) { }
            }

            Logger.Error("添加设备没有成功。");
            return(false);
        }
Esempio n. 4
0
        public bool EditDevice(Sys_Device device)
        {
            var sql = "UPDATE [dbo].[sys_devices]" +
                      " SET " +
                      "  [DeviceType] = @DeviceType" +
                      " ,[IsDYSF] = @IsDYSF" +
                      " ,[RemoteCode1] = @RemoteCode1" +
                      " ,[RemoteCode2] = @RemoteCode2" +
                      " ,[DeviceCompany] = @DeviceCompany" +
                      " ,[Comment] = @Comment" +
                      " ,[IsActive] = @IsActive" +
                      " ,[LastEditBy] = @LastEditBy" +
                      " ,[LastEditTime] = @LastEditTime" +
                      " ,[TestRoomCode] = @TestRoomCode" +
                      " ,[Quantum] = @Quantum" +
                      " ,[MachineCode] = @MachineCode" +
                      " WHERE ID = @ID";

            var command = GetDbCommand(sql);

            command.Parameters.Add(new SqlParameter("@ID", device.ID.ToString()));
            command.Parameters.Add(new SqlParameter("@DeviceType", (int)device.DeviceType));
            command.Parameters.Add(new SqlParameter("@IsDYSF", device.IsDYSF));
            command.Parameters.Add(new SqlParameter("@RemoteCode1", device.RemoteCode1));
            command.Parameters.Add(new SqlParameter("@RemoteCode2", device.RemoteCode2));
            command.Parameters.Add(new SqlParameter("@DeviceCompany", device.DeviceCompany));
            command.Parameters.Add(new SqlParameter("@Comment", device.Comment));
            command.Parameters.Add(new SqlParameter("@IsActive", device.IsActive));
            command.Parameters.Add(new SqlParameter("@LastEditBy", device.LastEditBy));
            command.Parameters.Add(new SqlParameter("@LastEditTime", device.LastEditTime));
            command.Parameters.Add(new SqlParameter("@TestRoomCode", device.TestRoomCode));
            command.Parameters.Add(new SqlParameter("@Quantum", device.Quantum));
            command.Parameters.Add(new SqlParameter("@MachineCode", device.MachineCode));

            try
            {
                if (command.Connection.State != ConnectionState.Open)
                {
                    command.Connection.Open();
                }

                var result = command.ExecuteNonQuery();
                if (result > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
            finally
            {
                try
                {
                    command.Connection.Close();
                }
                catch (Exception) { }
            }

            Logger.Error("添加设备没有成功。ID:" + device.ID);
            return(false);
        }
Esempio n. 5
0
 public static bool?EditDevice(Sys_Device device)
 {
     return(Agent.CallService("Yqun.BO.BusinessManager.dll", "EditDevice", new object[] { device }) as bool?);
 }