Beispiel #1
0
 public EditSyncConfigDialog(SyncConfigViewModel syncConfig)
 {
     InitializeComponent();
     DataContext = this;
     if (null != syncConfig)
     {
         SyncConfig = syncConfig;
     }
 }
Beispiel #2
0
        /// <summary>
        /// 修改同步配置
        /// </summary>
        /// <param name="syncConfig"></param>
        /// <returns></returns>
        private int ModifySyncConfig(SyncConfigViewModel syncConfig)
        {
            var row = SQLite.ExecuteNonQuery("UPDATE media_sync_config SET PC_PATH = @PcPath, MOBILE_PATH = @MobilePath, ENABLE = @Enable WHERE ID = @Id",
                                             new List <SQLiteParameter> {
                new SQLiteParameter("@PcPath", syncConfig.PcPath),
                new SQLiteParameter("@MobilePath", syncConfig.MobilePath),
                new SQLiteParameter("@Enable", syncConfig.Enable),
                new SQLiteParameter("@Id", syncConfig.Id)
            });

            return(row);
        }
Beispiel #3
0
        /// <summary>
        /// 新增同步配置
        /// </summary>
        /// <param name="syncConfig"></param>
        /// <returns></returns>
        private int SaveSyncConfig(SyncConfigViewModel syncConfig)
        {
            if (string.IsNullOrEmpty(syncConfig.PcPath) || string.IsNullOrEmpty(syncConfig.MobilePath))
            {
                return(0);
            }

            var row = SQLite.ExecuteNonQuery("INSERT INTO media_sync_config(ID, PC_PATH, MOBILE_PATH, ENABLE) VALUES ((SELECT IFNULL(MAX(ID), 0)+1 FROM media_sync_config), @PcPath, @MobilePath, @Enable)",
                                             new List <SQLiteParameter> {
                new SQLiteParameter("@PcPath", syncConfig.PcPath),
                new SQLiteParameter("@MobilePath", syncConfig.MobilePath),
                new SQLiteParameter("@Enable", syncConfig.Enable)
            });

            if (row > 0)
            {
                //查询最新添加的记录ID
                var newID = SQLite.sqlone("SELECT MAX(id) FROM media_sync_config", null);
                syncConfig.Id = Convert.ToInt32(newID);
            }
            return(row);
        }