CopyDB() public static method

复制数据库
public static CopyDB ( string DB, bool ignore ) : int
DB string 复制到的数据库
ignore bool 是否忽略存在
return int
Beispiel #1
0
 //撤销
 public void Undo()
 {
     if (undoSQL.Count == 0)
     {
         return;
     }
     DataBase.Command(dataform.GetOpenFile(), undoSQL[undoSQL.Count - 1]);
     undoSQL.RemoveAt(undoSQL.Count - 1);
     if (undoModified[undoModified.Count - 1].modifiled)
     {
         FileModified lastmodify = undoModified[undoModified.Count - 1];
         YGOUtil.CardRename(lastmodify.oldid, lastmodify.newid, dataform.GetPath(), lastmodify.delold);
     }
     undoModified.RemoveAt(undoModified.Count - 1);
     if (undoDeleted[undoDeleted.Count - 1].deleted)
     {
         FileDeleted lastdelete = undoDeleted[undoDeleted.Count - 1];
         foreach (long id in lastdelete.ids)
         {
             YGOUtil.CardDelete(id, dataform.GetPath(), YGOUtil.DeleteOption.RESTORE);
         }
     }
     undoDeleted.RemoveAt(undoDeleted.Count - 1);
     if (undoCopied[undoCopied.Count - 1].copied)
     {
         DBcopied lastcopied = undoCopied[undoCopied.Count - 1];
         DataBase.DeleteDB(dataform.GetOpenFile(), lastcopied.NewCards);
         DataBase.CopyDB(dataform.GetOpenFile(), !lastcopied.replace, lastcopied.OldCards);
     }
     undoCopied.RemoveAt(undoCopied.Count - 1);
     dataform.Search(true);
 }
Beispiel #2
0
        public void ExportData(string path, string zipname, string _cdbfile)
        {
            int i = 0;

            Card[] cards = cardlist;
            if (cards == null || cards.Length == 0)
            {
                return;
            }
            int     count   = cards.Length;
            YgoPath ygopath = new YgoPath(path);
            string  name    = Path.GetFileNameWithoutExtension(zipname);
            //数据库
            string cdbfile = zipname + ".cdb";
            //说明
            string readme = MyPath.Combine(path, name + ".txt");
            //新卡ydk
            string deckydk = ygopath.GetYdk(name);

            File.Delete(cdbfile);
            DataBase.Create(cdbfile);
            DataBase.CopyDB(cdbfile, false, cardlist);

            if (File.Exists(zipname))
            {
                File.Delete(zipname);
            }
            using (ZipStorer zips = ZipStorer.Create(zipname, ""))
            {
                zips.AddFile(cdbfile, Path.GetFileNameWithoutExtension(_cdbfile) + ".cdb", "");
                if (File.Exists(readme))
                {
                    zips.AddFile(readme, "readme_" + name + ".txt", "");
                }
                if (File.Exists(deckydk))
                {
                    zips.AddFile(deckydk, "deck/" + name + ".ydk", "");
                }
                foreach (Card c in cards)
                {
                    i++;
                    worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
                    string[] files = ygopath.GetCardfiles(c.id);
                    foreach (string file in files)
                    {
                        if (File.Exists(file))
                        {
                            zips.AddFile(file, file.Replace(path, ""), "");
                        }
                    }
                }
            }
            File.Delete(cdbfile);
        }
Beispiel #3
0
            public bool Excute(params object[] args)
            {
                if (!this.dataform.CheckOpen())
                {
                    return(false);
                }

                Card[] cards = (Card[])args[0];

                if (cards == null || cards.Length == 0)
                {
                    return(false);
                }

                bool replace = false;

                Card[] oldcards = DataBase.Read(this.dataform.GetOpenFile(), true, "");
                if (oldcards != null && oldcards.Length != 0)
                {
                    int i = 0;
                    foreach (Card oc in oldcards)
                    {
                        foreach (Card c in cards)
                        {
                            if (c.id == oc.id)
                            {
                                i += 1;
                                if (i == 1)
                                {
                                    replace = MyMsg.Question(LMSG.IfReplaceExistingCard);
                                    break;
                                }
                            }
                        }
                        if (i > 0)
                        {
                            break;
                        }
                    }
                }
                DataBase.CopyDB(this.dataform.GetOpenFile(), !replace, cards);
                this.copied   = true;
                this.newCards = cards;
                this.replace  = replace;
                this.oldCards = oldcards;
                return(true);
            }
Beispiel #4
0
 public void Undo()
 {
     DataBase.DeleteDB(dataform.GetOpenFile(), this.NewCards);
     DataBase.CopyDB(dataform.GetOpenFile(), !this.replace, this.OldCards);
 }
Beispiel #5
0
 public void Undo()
 {
     _ = DataBase.DeleteDB(dataform.GetOpenFile(), newCards);
     _ = DataBase.CopyDB(dataform.GetOpenFile(), !replace, oldCards);
 }