示例#1
0
 public override void Format(InetSongDb xmldb, Stream fw, IWaitDialog wait, object props)
 {
     using (PocketPCExporter exp = new PocketPCExporter(xmldb, fw, wait))
     {
         exp.Run();
     }
 }
        /// <summary>
        /// Starts the task impl. within the abstract Run() method in a separate thread.
        /// </summary>
        /// <param name="owner">IWin32Window. Owner of the displayed entertainment dialog</param>
        /// <param name="waitMessage">String. Message, to display while entertained.</param>
        /// <param name="allowCancel">Boolean. Set to false to prevent user from cancelling the operation.</param>
        /// <returns>DialogResult.
        /// DialogResult.Cancel, if the user cancelled the operation by closing the dialog.
        /// DialogResult.Abort, if the operation time out.
        /// DialogResult.OK, else.
        /// </returns>
        /// <exception cref="ArgumentNullException">If owner is null</exception>
        public DialogResult Start(IWin32Window owner, string waitMessage, bool allowCancel)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            p_operationThread = new Thread(this.Run);
            // if the thread generate some UI / visible components, they should use the current cultures:
            p_operationThread.CurrentCulture   = Thread.CurrentThread.CurrentCulture;
            p_operationThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;

            p_waitDialog = owner as IWaitDialog;
            Form f = owner as Form;

            if (p_waitDialog == null)
            {
                p_waitDialog = new EntertainmentDialog();
            }

            p_waitDialog.Initialize(this.p_workDone, this.p_operationTimeout, f != null ? f.Icon: null);
            p_operationThread.Start();
            DialogResult result = p_waitDialog.StartWaiting(owner, waitMessage, allowCancel);

            if (result != DialogResult.OK)                      // timeout, or cancelled by user
            {
                p_operationThread.Abort();                      // reqires the inerited classes to catch ThreadAbortException !
            }

            return(result);
        }
示例#3
0
        public static IWaitDialog CreateWaitDialog(IDialogHost dialogHost, DialogMode dialogMode, Dispatcher dispatcher)
        {
            IWaitDialog dialog = null;

            dispatcher.Invoke(new Action(() => dialog = new WaitProgressDialog(dialogHost, dialogMode, true, dispatcher)), DispatcherPriority.DataBind);
            return(dialog);
        }
示例#4
0
        public static Session CreateSession(IWaitDialog waitDialog)
        {
            var cancellationTokenSource = new CancellationTokenSource();
            var progress             = (IProgress <WaitDialogProgressData>) new ProgressAdapter(waitDialog, cancellationTokenSource);
            var cancellationCallback = new CancellationCallback(cancellationTokenSource);

            return(new Session(waitDialog, progress, cancellationTokenSource.Token, cancellationCallback));
        }
示例#5
0
 internal Session(IWaitDialog dialog, IProgress <WaitDialogProgressData> progress, CancellationToken token,
                  IWaitDialogCallback callback)
 {
     _dialog = dialog;
     Validate.IsNotNull(progress, nameof(progress));
     Progress = progress;
     UserCancellationToken = token;
     Callback = callback;
 }
示例#6
0
        public IWaitDialog CreateWaitDialog(DialogMode dialogMode, bool isIndeterminate = false)
        {
            IWaitDialog dialog = null;

            this.InvokeInUIThread(() =>
            {
                dialog = WaitProgressDialog.CreateWaitDialog(this.dialogHost, dialogMode, this.dispatcher, isIndeterminate);
                dialog.CloseWhenWorkerFinished = true;
            });
            return(dialog);
        }
示例#7
0
        public IWaitDialog CreateWaitDialog(DialogMode dialogMode)
        {
            IWaitDialog dialog = null;

            InvokeInUIThread(() =>
            {
                dialog = WaitProgressDialog.CreateWaitDialog(_dialogHost, dialogMode, _dispatcher);
                dialog.CloseWhenWorkerFinished = true;
            });
            return(dialog);
        }
示例#8
0
 public override void DownloadNew(SongDatabase db, int serverid, IWaitDialog dlg)
 {
     InetSongDb xmldb = new InetSongDb();
     object request = null;
     using (Stream fr = Read(ref request))
     {
         xmldb.Load(fr);
     }
     CloseRead(request);
     db.DownloadSongsFromServer(xmldb, serverid, dlg);
 }
示例#9
0
        public IWaitDialog CreateWaitDialog(string message, string readyMessage, DialogMode dialogMode)
        {
            IWaitDialog dialog = null;

            InvokeInUIThread(() =>
            {
                dialog = WaitProgressDialog.CreateWaitDialog(_dialogHost, dialogMode, _dispatcher);
                dialog.CloseWhenWorkerFinished = false;
                dialog.Message      = message;
                dialog.ReadyMessage = readyMessage;
            });
            return(dialog);
        }
示例#10
0
        void InitTask(IWaitDialog dlg)
        {
            dlg.SetTitle(R.TipInit);
            dlg.SetInfo(R.ConnectSqlServer);
            if (!Db.Open())
            {
                Db.Close();
                Db = null;
                this.Error(R.ErrorSqlServerNotConnect);
                Invoke(new InitFail(ShowServerManager), new object[] { true });
                return;
            }
            else
            {
                try{
                    Db.ExcuteSQL("use heroes;");
                }catch (Exception e) {
                    this.Error("" + e);
                    Db.Close();
                    Db = null;
                    Invoke(new InitFail(ShowServerManager), new object[] { true });
                    return;
                }
            }
            dlg.SetInfo(R.TipReadText);
            var HeroesText = new HeroesTextHelper();

            HeroesText.Read(Config.GameText, Config.PatchText);
            //
            dlg.SetInfo(R.TipReadItem);
            //读取物品
            try{
                DataHelper.ReadData(HeroesText);
            }catch (Exception e) {
                this.Error("ReadData\n" + e);
            }
            if (Searcher == null)
            {
                Searcher = new SearchHelper(DataHelper.Items);
            }
            else
            {
                Searcher.Attch(DataHelper.Items);
            }
//			MessageBox.Show("count="+DataHelper.Items.Count);
            dlg.SetInfo(R.TipReadUsers);
            Invoke(new InitOk(InitAllMenus));
            //读取用户
            ReadUsers(true);
        }
        public State(IWaitDialog waitDialog, ThreadedWaitDialogProgressData initialProgress, IVsSolution4 solution)
        {
            _waitDialog      = waitDialog;
            _currentProgress = initialProgress;
            Solution         = solution;

            _projectsToLoad = new HashSet <Guid>();
            _loadedProjects = new HashSet <Guid>();

            _projectsToUnload = new HashSet <Guid>();
            _unloadedProjects = new HashSet <Guid>();

            ProjectsVisitedWhileLoading          = new HashSet <Guid>();
            RequiresProjectDependencyCalculation = true;
        }
示例#12
0
 //public void Run(SongDatabase db, string filename, int? serverid)
 public override void Parse(Stream fr, InetSongDb xmldb, IWaitDialog wait)
 {
     XslCompiledTransform xslt = new XslCompiledTransform();
     xslt.Load(XmlReader.Create(new StringReader(xsls.zp6_to_zp8)));
     XmlDocument result = new XmlDocument();
     StringBuilder sb = new StringBuilder();
     XmlDocument zp6doc = new XmlDocument();
     zp6doc.Load(fr);
     if (zp6doc.DocumentElement.LocalName != "zpevnik_data" && zp6doc.DocumentElement.LocalName != "zpevnik") throw new Exception("Špatný formát vstupního souboru");
     xslt.Transform(zp6doc, XmlWriter.Create(sb));
     using (StringReader sr = new StringReader(sb.ToString()))
     {
         xmldb.Load(XmlTextReader.Create(sr));
     }
     //db.ImportSongs(sr, serverid);
 }
示例#13
0
        public override void Parse(Stream fr, InetSongDb db, IWaitDialog wait)
        {
            using (StreamReader sr = new StreamReader(fr, m_encoding))
            {
                foreach (string fulltext in SongStreamSplitter.SplitSongs(sr, m_splitProps))
                {
                    if (fulltext.Trim() == "") continue;
                    SongData song = SongDataAnalyser.AnalyseSongData(fulltext, m_dataProps);
                    song.OrigText = SongTextAnalyser.NormalizeSongText(song.SongText, m_textProps);
                    DbTools.AddSongRow(song, db);
                    if (wait.Canceled) return;
                    wait.Message("Zpracována píseò " + song.Title);
                }
                /*
                List<string> lines = new List<string>();
                while (!sr.EndOfStream) lines.Add(sr.ReadLine().TrimEnd());
                int i = 0;
                while (lines.Count > 0 && lines[lines.Count - 1] == "") lines.RemoveAt(lines.Count - 1);

                while (i < lines.Count)
                {
                    List<string> songlines = new List<string>();
                    while (i < lines.Count && lines[i] == "") i++; // preskoc prazdne
                    for (; ; )
                    {
                        if (i + 1 < lines.Count && lines[i] == "" && lines[i + 1] == "") break;
                        if (i >= lines.Count) break;
                        songlines.Add(lines[i]);
                        i++;                      
                    }
                    if (songlines.Count > 0)
                    {
                        InetSongDb.songRow song = db.song.NewsongRow();
                        song.author = song.title = song.groupname = song.songtext = "";
                        song.lang = "cz";
                        SongTextAnalyser.AnalyseSongHeader(songlines, song);
                        song.songtext = SongTextAnalyser.NormalizeSongText(String.Join("\n", songlines.ToArray()));
                        db.song.AddsongRow(song);
                    }
                }
                */
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (p_workDone != null)
                {
                    p_workDone.Set();
                    p_workDone.Dispose();
                }

                p_workDone = null;

                var disposable = p_waitDialog as EntertainmentDialog;
                if (disposable != null)
                {
                    disposable.Dispose();
                }

                p_waitDialog = null;
            }
        }
示例#15
0
        public PocketPCExporter(InetSongDb xmldb, Stream fw, IWaitDialog wait)
        {
            m_filename = Path.Combine(DbManager.DbPath, "tmp" + DateTime.Now.Ticks + ".db3");
            m_xmldb = xmldb;
            m_fw = fw;
            m_wait = wait;
            m_conn = new SQLiteConnection(String.Format("Data Source={0};New=True;Version=3", m_filename));
            m_insertGroup = new SQLiteCommand("INSERT INTO groupnames (groupname) VALUES (@group)", m_conn);
            m_insertGroup.Parameters.Add("@group", DbType.String);

            m_insertSongName = new SQLiteCommand("INSERT INTO songnames (id, songname, groupname) VALUES (@id, @song, @group)", m_conn);
            m_insertSongName.Parameters.Add("@id", DbType.Int32);
            m_insertSongName.Parameters.Add("@song", DbType.String);
            m_insertSongName.Parameters.Add("@group", DbType.String);

            m_insertSongDetail = new SQLiteCommand("INSERT INTO songdetails (id, songtext, author, remark) VALUES (@id, @songtext, @author, @remark)", m_conn);
            m_insertSongDetail.Parameters.Add("@id", DbType.Int32);
            m_insertSongDetail.Parameters.Add("@songtext", DbType.String);
            m_insertSongDetail.Parameters.Add("@author", DbType.String);
            m_insertSongDetail.Parameters.Add("@remark", DbType.String);
        }
示例#16
0
 public virtual void UploadWhole(SongDatabase db, int serverid, IWaitDialog dlg)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#17
0
 public override void UploadWhole(SongDatabase db, int serverid, IWaitDialog dlg)
 {
     InetSongDb xmldb = new InetSongDb();
     object request = null;
     using (Stream fw = Write(ref request))
     {
         db.PublishAllSongs(serverid, xmldb, dlg);
         xmldb.Save(fw);
     }
     CloseWrite(request);
 }
 public abstract void Format(InetSongDb db, Stream fw, IWaitDialog wait, object props);
示例#19
0
 private void AddModalAction(object action, string message)
 {
     _ModalActionsRunning.Add(action, message);
     if (_CurrentWaitDialog == null)
     {
         _CurrentWaitDialog = _Dialogs.CreateWaitDialog();
         ShowWaitingDialog(_CurrentWaitDialog, message);
     }
             
 }
示例#20
0
 internal ProgressAdapter(IWaitDialog dialog, CancellationTokenSource cancellationTokenSource)
 {
     Validate.IsNotNull(dialog, nameof(dialog));
     _dialog = dialog;
     _cancellationTokenSource = cancellationTokenSource;
 }
示例#21
0
        private void RemoveModalAction(object action)
        {
            bool changeMessage = _CurrentWaitDialog.Title == _ModalActionsRunning[action];

            _ModalActionsRunning.Remove(action);
            if (_ModalActionsRunning.Count == 0)
            {
                Action closeDialog = () => CloseWaitingDialog(_CurrentWaitDialog);
                Dispatcher.CurrentDispatcher.Invoke(closeDialog);
                _CurrentWaitDialog = null;
                _RunningBackgroundTask = false;
                ProcessUIWorkQueue();
            }
            else if (changeMessage)
            {
                Action changeAction = () => _CurrentWaitDialog.Title = _ModalActionsRunning.Values.FirstOrDefault();
                Dispatcher.CurrentDispatcher.Invoke(changeAction);
            }       
        }
        public void Format(InetSongDb db, object props, IWaitDialog wait)
        {
            DirectorySongExporterProperties p = (DirectorySongExporterProperties)props;
            IStreamSongFormatter songfmt = GetStreamFormatter();
            string directory = p.FolderName;
            DirectorySongHolder dsh = new DirectorySongHolder(db.Songs);
            // nejdrive zapiseme index
            wait.Message("Zapisuji " + m_indexFileName);
            if (m_writeIndex)
            {
                using (FileStream fsw = new FileStream(Path.Combine(directory, m_indexFileName), FileMode.Create))
                {
                    using (StreamWriter fw = new StreamWriter(fsw, m_encoding))
                    {
                        WriteIndexFile(fw, dsh);
                    }
                }
            }

            // pak skupinove soubory
            if (m_writeGroups)
            {
                foreach (GroupOfSongs grp in dsh.Groups.Values)
                {
                    string path = Path.Combine(directory, MakeTemplate(m_groupFileMask, grp));
                    try { Directory.CreateDirectory(Path.GetDirectoryName(path)); }
                    catch (Exception) { }

                    wait.Message("Zapisuji " + path);
                    if (wait.Canceled) return;

                    using (FileStream fsw = new FileStream(path, FileMode.Create))
                    {
                        using (StreamWriter fw = new StreamWriter(fsw, m_encoding))
                        {
                            WriteGroupFile(fw, grp, dsh);
                        }
                    }
                }
            }

            // pisne - nejdrive zgrupovane
            if (m_writeGroupedSongs)
            {
                foreach (GroupOfSongs grp in dsh.Groups.Values)
                {
                    string path = Path.Combine(directory, MakeTemplate(m_groupedSongsFileMask, grp));
                    try { Directory.CreateDirectory(Path.GetDirectoryName(path)); }
                    catch (Exception) { }

                    wait.Message("Zapisuji " + path);
                    if (wait.Canceled) return;

                    InetSongDb tmp = new InetSongDb();
                    foreach (SongData song in grp.Songs)
                    {
                        DbTools.AddSongRow(song, tmp);
                    }
                    using (FileStream fw = new FileStream(path, FileMode.Create))
                    {
                        songfmt.Format(tmp, fw, wait, props);
                    }
                }
            }

            // pisne - po jedne
            if (m_writeSeparateSongs)
            {
                foreach (SongData song in db.Songs)
                {
                    string path = Path.Combine(directory, MakeTemplate(m_songFileMask, song, dsh));
                    try { Directory.CreateDirectory(Path.GetDirectoryName(path)); }
                    catch (Exception) { }

                    wait.Message("Zapisuji " + path);
                    if (wait.Canceled) return;

                    InetSongDb tmp = new InetSongDb();
                    DbTools.AddSongRow(song, tmp);
                    using (FileStream fw = new FileStream(path, FileMode.Create))
                    {
                        songfmt.Format(tmp, fw, wait, props);
                    }
                }
            }
        }
示例#23
0
 protected override void Dispose(bool disposing)
 {
     lock (this._syncRoot)
     {
         if (!this._isDisposed)
         {
             this._isDisposed = true;
             if (this._coreWaitDialog != null)
             {
                 this._coreWaitDialog.CompleteRequest();
                 Marshal.ReleaseComObject(this._coreWaitDialog);
                 this._coreWaitDialog = null;
             }
         }
     }
 }
示例#24
0
 public void ShowDialog(IWin32Window owner)
 {
     bool flag = false;
     HandleRef ref2 = new HandleRef(owner, (owner != null) ? owner.Handle : Microsoft.ManagementConsole.Interop.NativeMethods.GetDesktopWindow());
     lock (this._syncRoot)
     {
         if (this._coreWaitDialog != null)
         {
             throw new InvalidOperationException(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.AdvancedWaitDialogShowDialogTwiceNotAllowed));
         }
         if (this._isDisposed)
         {
             throw new ObjectDisposedException(this.Name);
         }
         System.Type typeFromCLSID = System.Type.GetTypeFromCLSID(_waitDialogClsid);
         this._coreWaitDialog = (IWaitDialog) Activator.CreateInstance(typeFromCLSID);
         flag = this._completed;
         if (!flag)
         {
             this._coreWaitDialog.UpdateTitle(this._title);
             this._coreWaitDialog.SetCancelable(this._canCancel);
             this._coreWaitDialog.UpdateProgress(this._workProcessed, this._totalWork, this._statusText);
         }
     }
     try
     {
         if (!flag)
         {
             this._coreWaitDialog.RunModal(ref2.Handle, (uint) this._displayDelayMSecs, (uint) this._minimumDisplayTimeMSecs, this._cancelCallback);
         }
     }
     finally
     {
         lock (this._syncRoot)
         {
             this._completed = false;
             if (this._coreWaitDialog != null)
             {
                 Marshal.ReleaseComObject(this._coreWaitDialog);
                 this._coreWaitDialog = null;
             }
         }
     }
 }
示例#25
0
 /// <summary>
 /// Ends the wait dialog.
 /// </summary>
 /// <param name="dialog">The dialog.</param>
 /// <returns>Returns <see langword="true"/> if the task was canceled by the user</returns>
 public static bool EndWaitDialog(this IWaitDialog dialog)
 {
     Requires.NotNull(dialog, nameof(dialog));
     dialog.EndWaitDialog(out var canceled);
     return(canceled);
 }
示例#26
0
        private void ShowWaitingDialog(IWaitDialog waitDialog, string message)
        {
            waitDialog.Title = message;
            _RegionManager.Regions[CoreRegionNames.PopupRegion].Add(waitDialog);
            _RegionManager.Regions[CoreRegionNames.PopupRegion].Activate(waitDialog);

            var eventArgs = _EventAggregator.CreateEvent<IPopupChangedEvent>();
            eventArgs.SetShow(true);
            _EventAggregator.Publish(eventArgs);
            _WaitDialogVisible = true;
        }
示例#27
0
 public void PublishAllSongs(int serverid, InetSongDb xmldb, IWaitDialog dlg)
 {
     xmldb.Songs.Clear();
     var songs = new List<SongData>(this.LoadSongs(null, null, "song.server_id=" + serverid.ToString()));
     using (SQLiteTransaction tran = m_conn.BeginTransaction())
     {
         foreach (var song in songs)
         {
             ProcessPublishSong(tran, xmldb, song, dlg);
         }
         ExecuteNonQuery("delete from deletedsong where server_id=@sid", "sid", serverid);
         tran.Commit();
     }
 }
示例#28
0
 public override void UploadChanges(SongDatabase db, int serverid, IWaitDialog dlg)
 {
     InetSongDb xmldb = new InetSongDb();
     object req1 = null;
     using (Stream fr = Read(ref req1)) xmldb.Load(fr);
     CloseRead(req1);
     object request = null;
     using (Stream fw = Write(ref request))
     {
         db.PublishSongsChanges(serverid, xmldb, dlg);
         xmldb.Save(fw);
     }
     CloseWrite(request);
 }
示例#29
0
 public void ImportNewSongs(InetSongDb db, int? serverid, IWaitDialog dlg)
 {
     WantOpen();
     int imported = 0;
     using (var tran = m_conn.BeginTransaction())
     {
         foreach (var song in db.Songs)
         {
             var scopy = song.Clone();
             scopy.NetID = null;
             InsertSong(tran, scopy, serverid, true);
             imported++;
         }
         tran.Commit();
     }
     dlg.Message(String.Format("Importováno {0} písní", imported));
 }
 public abstract void Parse(Stream fr, InetSongDb db, IWaitDialog wait);
示例#31
0
 private void ProcessPublishSong(SQLiteTransaction tran, InetSongDb xmldb, SongData song, IWaitDialog dlg)
 {
     if (song.NetID != null)
     {
         xmldb.UpdateSongByNetID(song);
         ExecuteNonQuery("update song set published=@published, localmodified=0 where id=@id",
             "published", DateTime.UtcNow, "id", song.LocalID);
     }
     else
     {
         xmldb.AddSongWithNewNetID(song);
         ExecuteNonQuery("update song set published=@published, localmodified=0, netID=@netid where id=@id",
             "published", DateTime.UtcNow, "id", song.LocalID, "netid", song.NetID);
     }
     dlg.Message(String.Format("Publikuji píseò {0}, netID={1}", song.Title, song.NetID));
 }
示例#32
0
 /// <summary>
 /// Ends the wait dialog.
 /// </summary>
 /// <param name="dialog">The dialog.</param>
 /// <returns>Returns <see langword="true"/> if the task was canceled by the user</returns>
 public static bool EndWaitDialog(this IWaitDialog dialog)
 {
     Validate.IsNotNull(dialog, nameof(dialog));
     dialog.EndWaitDialog(out var canceled);
     return(canceled);
 }
示例#33
0
        public override void Format(InetSongDb db, Stream fw, IWaitDialog wait, object props)
        {
            TextFileDynamicProperties p = (TextFileDynamicProperties)props;
            List<SongData> songs = new List<SongData>();
            foreach (SongData row in db.Songs)
            {
                songs.Add(row);
            }
            songs.Sort(Sorting.GetComparison(p.Order));

            using (StreamWriter sw = new StreamWriter(fw, m_encoding))
            {
                DumpFileBegin(sw);
                bool wassong = false;
                foreach (SongData row in songs)
                {
                    if (wassong) DumpSongSeparator(sw);
                    DumpSongBegin(row, sw);
                    RunTextFormatting(row.SongText, sw);
                    DumpSongEnd(row, sw);
                    wassong = true;
                }
                DumpFileEnd(sw);
            }
        }
 public void Parse(object props, InetSongDb db, IWaitDialog wait)
 {
     MultipleStreamImporterProperties p = (MultipleStreamImporterProperties)props;
     List<string> files = new List<string>();
     files.AddRange(p.FileNames.Files);
     if (p.FileName != "") files.Add(p.FileName);
     foreach (string filename in files)
     {
         wait.Message("Importuji soubor " + filename);
         if (wait.Canceled) return;
         using (FileStream fr = new FileStream(filename, FileMode.Open))
         {
             if (filename.ToLower().EndsWith(".gz") || filename.ToLower().EndsWith(".xgz"))
             {
                 using (GZipStream gr = new GZipStream(fr, CompressionMode.Decompress))
                 {
                     Parse(gr, db, wait);
                 }
             }
             else
             {
                 Parse(fr, db, wait);
             }
         }
     }
     if (p.URL != "")
     {
         WebRequest req = WebRequest.Create(p.URL);
         WebResponse resp = req.GetResponse();
         using (Stream fr = resp.GetResponseStream())
         {
             Parse(fr, db, wait);
         }
         resp.Close();
     }
 }
示例#35
0
 /// <summary>
 /// Creates an instance of an <see cref="IWaitDialog"/>.
 /// </summary>
 /// <param name="waitDialog">The wait dialog.</param>
 public void CreateInstance(out IWaitDialog waitDialog)
 {
     waitDialog = new WaitDialog();
 }
 public void CreateInstance(out IWaitDialog dialog)
 {
     dialog = new WaitDialogServiceWrapper();
 }
示例#37
0
        private void CloseWaitingDialog(IWaitDialog waitDialog)
        {
            if (!_WaitDialogVisible)
            {
                return;
            }

            _RegionManager.Regions[CoreRegionNames.PopupRegion].Remove(waitDialog);

            var eventArgs = _EventAggregator.CreateEvent<IPopupChangedEvent>();
            _EventAggregator.Publish(eventArgs);
            _WaitDialogVisible = false;
        }
示例#38
0
 public void DownloadSongsFromServer(InetSongDb db, int? serverid, IWaitDialog dlg)
 {
     WantOpen();
     int imported = 0;
     ExecuteNonQuery("delete from songdata where song_id = (select song.id from song where song.server_id=@sid and song.localmodified=0)", "sid", serverid);
     ExecuteNonQuery("delete from song where song.server_id=@sid and song.localmodified=0", "sid", serverid);
     List<string> modifiedNetIds = new List<string>();
     using (var reader = ExecuteReader("select netID from song where server_id=@sid and localmodified=1", "sid", serverid))
     {
         while (reader.Read())
         {
             modifiedNetIds.Add(reader.SafeString(0));
         }
         reader.Close();
     }
     foreach (var song in db.Songs)
     {
         if (modifiedNetIds.Contains(song.NetID))
         {
             dlg.Message(String.Format("Ignoruji zmìnìnou píseò {0}, netID={1}", song.Title, song.NetID));
         }
         else
         {
             InsertSong(song, serverid, false);
             imported++;
         }
     }
     dlg.Message(String.Format("Importováno {0} písní", imported));
 }
示例#39
0
 public override void Parse(Stream fr, InetSongDb xmldb, IWaitDialog wait)
 {
     xmldb.Load(fr);
 }
示例#40
0
 public void PublishSongsChanges(int serverid, InetSongDb xmldb, IWaitDialog dlg)
 {
     var songs = new List<SongData>(this.LoadSongs(null, null, "song.server_id=" + serverid.ToString() + " and song.localmodified=1"));
     using (SQLiteTransaction tran = m_conn.BeginTransaction())
     {
         foreach (var song in songs)
         {
             ProcessPublishSong(tran, xmldb, song, dlg);
         }
         using (var reader = ExecuteReader("select ID, song_netID from deletedsong where server_id=@sid", "sid", serverid))
         {
             while (reader.Read())
             {
                 int id = reader.SafeInt(0);
                 string netid = reader.SafeString(1);
                 xmldb.DeleteSongByNetID(netid);
                 dlg.Message(String.Format("Mažu píseò netID={0}", netid));
             }
         }
         ExecuteNonQuery("delete from deletedsong where server_id=@sid", "sid", serverid);
         tran.Commit();
     }
 }
 public void Format(InetSongDb db, object props, IWaitDialog wait)
 {
     string filename = ((SingleFileDynamicProperties)props).FileName;
     using (FileStream fw = new FileStream(filename, FileMode.Create))
     {
         Format(db, fw, wait, props);
     }
 }
示例#42
0
 public void LoadServers(IWaitDialog dlg)
 {
     using (var reader = ExecuteReader("select id, url from serverlist"))
     {
         while (reader.Read())
         {
             WebRequest req = WebRequest.Create(reader.SafeString(1));
             using (var resp = req.GetResponse())
             {
                 using (var strm = resp.GetResponseStream())
                 {
                     XmlDocument doc = new XmlDocument();
                     doc.Load(strm);
                     foreach (XmlElement elem in doc.SelectNodes("/ServerList/Server/Url"))
                     {
                         string url = elem.InnerText;
                         if ("0" == ExecuteScalar("select count(*) from server where url=@url", "url", url).ToString())
                         {
                             var ss = new XmlSongServer { URL = url };
                             InsertServer(ss);
                             dlg.Message(String.Format("Pøidávám server {0}", ss));
                         }
                     }
                 }
             }
         }
     }
 }
示例#43
0
 public override void Format(InetSongDb xmldb, Stream fw, IWaitDialog wait, object props)
 {
     xmldb.Save(fw);
 }