Create launcher shortcut for RDesktop

388

Had a similar issue with xfreerdp client. Passing parameters from the command line using the terminal works, but could not make it work at first using a desktop launcher (shorcut, in Windows terminology). The solution was to create a script to call the client:

~/bin/RDPWindows.sh:

xfreerdp /d: /u:username /p:password /v:10.10.10.10 /size:100% /dynamic-resolution

Then, creating a launcher pointing to the script works just fine.

Share:
388

Related videos on Youtube

chamara
Author by

chamara

Updated on September 18, 2022

Comments

  • chamara
    chamara over 1 year

    I'm trying to update a single value in the database using Entity Framework code-first.

    It's throwing the following error:

    Attaching an entity of type 'WarehouseAPI.Core.DataEntities.Models.TaskDetail' failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be because some entities are new and have not yet received database-generated key values. In this case use the 'Add' method or the 'Added' entity state to track the graph and then set the state of non-new entities to 'Unchanged' or 'Modified' as appropriate.

    [Table("tblTaskDetail")]
    public partial class tblTaskDetail
    {
        [Key]
        public int TaskDetailID { get; set; }
    
        public int? ScheduleId { get; set; }
    
        [Required]
        [StringLength(50)]
        public string RobotID { get; set; }
    
        public Guid? SessionID { get; set; }
    
        [Required]
        [StringLength(50)]
        public string TaskStatus { get; set; }
    
        [Column(TypeName = "datetime2")]
        public DateTime? TaskScheduledOn { get; set; }
    
        [StringLength(250)]
        public string TaskSummary { get; set; }
    
        [Column(TypeName = "datetime2")]
        public DateTime? TaskStartedOnUtc { get; set; }
    
        [Column(TypeName = "datetime2")]
        public DateTime? TaskCompletedOnUtc { get; set; }
    }
    
    public class TaskDetail
    {
        public int TaskDetailID { get; set; }
        public int? ScheduleId { get; set; }
        public string RobotID { get; set; }
        public Guid? SessionID { get; set; }
        public string TaskStatus { get; set; }
        public DateTime TaskScheduledOn { get; set; }
        public string TaskSummary { get; set; }
        public DateTime TaskStartedOnUtc { get; set; }
        public DateTime TaskCompletedOnUtc { get; set; }
    }
    
    public class TaskDetailMapper:EntityTypeConfiguration<TaskDetail>
    {
        public TaskDetailMapper()
        {
            this.ToTable("tblTaskDetail");
            this.HasKey(hk => hk.TaskDetailID);
            this.Property(o => o.RobotID).HasColumnName("RobotID");
            this.Property(o => o.ScheduleId).HasColumnName("ScheduleId");
            this.Property(o => o.SessionID).HasColumnName("SessionID");
            this.Property(o => o.TaskCompletedOnUtc).HasColumnName("TaskCompletedOnUtc");
            this.Property(o => o.TaskDetailID).HasColumnName("TaskDetailID");
            this.Property(o => o.TaskScheduledOn).HasColumnName("TaskScheduledOn");
            this.Property(o => o.TaskStartedOnUtc).HasColumnName("TaskStartedOnUtc");
            this.Property(o => o.TaskStatus).HasColumnName("TaskStatus");
            this.Property(o => o.TaskSummary).HasColumnName("TaskSummary");
        }
    }
    
    public partial class WarehouseAPIContext : DbContext
    {
        public WarehouseAPIContext() : base("name=WarehouseAPIContext")
        {
        }
    
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new TaskDetailMapper());
        }
    }
    
    public class TaskDetailRepository:APIRepository<TaskDetail>
    {
        WarehouseAPIContext _context;
    
        public TaskDetailRepository(WarehouseAPIContext context):base(context)
        {
            _context = context;
        }
    
        public TaskDetail UpdateTaskStartingTime(TaskDetail entity)
        {
            try
            {
                var taskDetail = new TaskDetail() { TaskStartedOnUtc = entity.TaskStartedOnUtc, TaskStatus = entity.TaskStatus,SessionID = entity.SessionID, TaskDetailID = entity.TaskDetailID };
    
                 dbSet.Attach(taskDetail);    // THROWS THE ERROR
                _context.Entry(taskDetail).Property(x => x.TaskStartedOnUtc).IsModified = true;
                _context.SaveChanges();
    
                return entity;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
    
    public class APIRepository<T> where T:class
    {
            internal WarehouseAPIContext wContext;
            internal DbSet<T> dbSet;
    
            public APIRepository(WarehouseAPIContext context)
            {
                wContext = context;
                dbSet = context.Set<T>();
            }
    
            public virtual T Update(T entity)
            {
                try
                {
                    var entry = wContext.Entry(entity);
                    dbSet.Attach(entity);
                    entry.State = EntityState.Modified;
                    wContext.SaveChanges();
                    return entity;
                }
                catch (Exception ex)
                {
                    //ExceptionHandler.Handle(ex);
                    return null;
                }
            }
    }
    
    • Developer
      Developer over 7 years
      Is that entity already available in the context cache? Are you loading that entity from database in some other place in the same context? Also why two context objects - dbSet and _context. I think, when you use .Entry, you can skip the .Attach part
  • guntbert
    guntbert about 10 years
    This doesn't create a shortcut.
  • Alan
    Alan over 3 years
    Good solution - I should have thought of that! Alan.