UpdateCardId() public static method

public static UpdateCardId ( string cardId, string updatedId, SQLiteConnection connection ) : bool
cardId string
updatedId string
connection System.Data.SQLite.SQLiteConnection
return bool
コード例 #1
0
        private void ConvertButton_Click(object sender, EventArgs e)
        {
            bool            updateCdb    = cdbchk.Checked;
            bool            updateScript = patchchk.Checked;
            bool            updateImage  = imagechk.Checked;
            List <string[]> updateCards  = UpdateCardsList.Items.OfType <string[]>().ToList();

            if (patchchk.Checked)
            {
                if (!Directory.Exists("DevPatch"))
                {
                    Directory.CreateDirectory("DevPatch");
                }
                if (!Directory.Exists("DevPatch\\script"))
                {
                    Directory.CreateDirectory("DevPatch\\script");
                }
                if (!Directory.Exists("DevPatch\\pics"))
                {
                    Directory.CreateDirectory("DevPatch\\pics");
                }
                if (!Directory.Exists("DevPatch\\pics\\thumbnail"))
                {
                    Directory.CreateDirectory("DevPatch\\pics\\thumbnail");
                }
            }

            foreach (var updateCard in updateCards)
            {
                if (updateCdb)
                {
                    string str  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
                    string str2 = Path.Combine(str, "cards.cdb");
                    if (!File.Exists(str2))
                    {
                        MessageBox.Show("cards.cdb not found.");
                        return;
                    }

                    var connection = new SQLiteConnection("Data Source=" + str2);
                    connection.Open();

                    SQLiteCommands.UpdateCardId(updateCard[0], updateCard[1], connection);

                    connection.Close();

                    if (patchchk.Checked)
                    {
                        File.Copy(str2, "DevPatch\\cards.cdb", true);
                    }
                }

                if (updateImage)
                {
                    string       mainDir            = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
                    const string picFolderName      = "pics";
                    const string tumbnailFolderName = "pics\\thumbnail";
                    string       picName            = updateCard[0] + ".jpg";
                    string       newPicName         = updateCard[1] + ".jpg";

                    string imagePath             = Path.Combine(mainDir, picFolderName, picName);
                    string newImagePath          = Path.Combine(mainDir, picFolderName, newPicName);
                    string thumbnailImagePath    = Path.Combine(mainDir, tumbnailFolderName, picName);
                    string newthumbnailImagePath = Path.Combine(mainDir, tumbnailFolderName, newPicName);

                    if (File.Exists(imagePath) && !File.Exists(newImagePath))
                    {
                        File.Move(imagePath, newImagePath);
                    }
                    if (File.Exists(thumbnailImagePath) && !File.Exists(newthumbnailImagePath))
                    {
                        File.Move(thumbnailImagePath, newthumbnailImagePath);
                    }
                    if (patchchk.Checked)
                    {
                        if (File.Exists(newImagePath))
                        {
                            File.Copy(newImagePath, Path.Combine("DevPatch\\pics", newPicName), true);
                        }
                        if (File.Exists(newthumbnailImagePath))
                        {
                            File.Copy(newthumbnailImagePath, Path.Combine("DevPatch\\pics\\thumbnail", newPicName), true);
                        }
                    }
                }

                if (updateScript)
                {
                    string       mainDir          = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
                    const string scriptFolderName = "script";
                    string       scriptName       = "c" + updateCard[0] + ".lua";
                    string       newScriptName    = "c" + updateCard[1] + ".lua";

                    string scriptPath    = Path.Combine(mainDir, scriptFolderName, scriptName);
                    string newScriptPath = Path.Combine(mainDir, scriptFolderName, newScriptName);

                    if (File.Exists(scriptPath))
                    {
                        File.Move(scriptPath, newScriptPath);

                        //needs testing id replacing
                        string scriptFile = File.ReadAllText(newScriptPath);
                        scriptFile = scriptFile.Replace(updateCard[0], updateCard[1]);
                        File.WriteAllText(newScriptPath, scriptFile);

                        if (patchchk.Checked)
                        {
                            if (File.Exists(newScriptPath))
                            {
                                File.Copy(newScriptPath, Path.Combine("DevPatch\\script", newScriptName), true);
                            }
                        }
                    }
                }

                Program.CardData.RenameKey(Convert.ToInt32(updateCard[0]), Convert.ToInt32(updateCard[1]));
            }
            UpdateCardsList.Items.Clear();
            MessageBox.Show("Complete.");
        }
コード例 #2
0
        private void ConvertButton_Click(object sender, EventArgs e)
        {
            ConvertButton.Enabled = false;
            bool            updateCdb    = cdbchk.Checked;
            bool            updateScript = patchchk.Checked;
            bool            updateImage  = imagechk.Checked;
            List <string[]> updateCards  = UpdateCardsList.Items.OfType <string[]>().ToList();

            if (patchchk.Checked)
            {
                if (!Directory.Exists("DevPatch"))
                {
                    Directory.CreateDirectory("DevPatch");
                }
                if (!Directory.Exists("DevPatch\\script"))
                {
                    Directory.CreateDirectory("DevPatch\\script");
                }
                if (!Directory.Exists("DevPatch\\pics"))
                {
                    Directory.CreateDirectory("DevPatch\\pics");
                }
                if (!Directory.Exists("DevPatch\\pics\\thumbnail"))
                {
                    Directory.CreateDirectory("DevPatch\\pics\\thumbnail");
                }
            }

            string str = "cards.cdb";

            foreach (var updateCard in updateCards)
            {
                if (updateCdb)
                {
                    if (!File.Exists(str))
                    {
                        MessageBox.Show("cards.cdb not found.");
                        return;
                    }

                    int cardid = Int32.Parse(updateCard[0]);
                    int newid  = Int32.Parse(updateCard[1]);
                    CardManager.RenameKey(cardid, newid);

                    CardInfos card = CardManager.GetCard(newid);
                    card.Id = newid;
                    if (chkremovepre.Checked)
                    {
                        card.Ot = card.Ot & 0x03;
                    }

                    CardManager.UpdateOrAddCard(card);

                    var connection = new SQLiteConnection("Data Source=" + str);
                    connection.Open();

                    SQLiteCommands.UpdateCardId(updateCard[0], updateCard[1], connection);
                    if (chkremovepre.Checked)
                    {
                        SQLiteCommands.UpdateCardOt(updateCard[1], card.Ot.ToString(), connection);
                    }

                    connection.Close();
                }

                if (updateImage)
                {
                    string       mainDir            = Directory.GetCurrentDirectory();;
                    const string picFolderName      = "pics";
                    const string tumbnailFolderName = "pics\\thumbnail";
                    string       picName            = updateCard[0] + ".png";
                    string       newPicName         = updateCard[1] + ".png";

                    string imagePath             = Path.Combine(mainDir, picFolderName, picName);
                    string newImagePath          = Path.Combine(mainDir, picFolderName, newPicName);
                    string thumbnailImagePath    = Path.Combine(mainDir, tumbnailFolderName, picName);
                    string newthumbnailImagePath = Path.Combine(mainDir, tumbnailFolderName, newPicName);

                    if (File.Exists(imagePath) && !File.Exists(newImagePath))
                    {
                        File.Move(imagePath, newImagePath);
                    }
                    if (File.Exists(thumbnailImagePath) && !File.Exists(newthumbnailImagePath))
                    {
                        File.Move(thumbnailImagePath, newthumbnailImagePath);
                    }
                    if (patchchk.Checked)
                    {
                        if (File.Exists(newImagePath))
                        {
                            File.Copy(newImagePath, Path.Combine("DevPatch\\pics", newPicName), true);
                        }
                        if (File.Exists(newthumbnailImagePath))
                        {
                            File.Copy(newthumbnailImagePath, Path.Combine("DevPatch\\pics\\thumbnail", newPicName), true);
                        }
                    }
                }

                if (updateScript)
                {
                    string       mainDir          = Directory.GetCurrentDirectory();;
                    const string scriptFolderName = "script";
                    string       scriptName       = "c" + updateCard[0] + ".lua";
                    string       newScriptName    = "c" + updateCard[1] + ".lua";

                    string scriptPath    = Path.Combine(mainDir, scriptFolderName, scriptName);
                    string newScriptPath = Path.Combine(mainDir, scriptFolderName, newScriptName);

                    if (File.Exists(scriptPath))
                    {
                        File.Move(scriptPath, newScriptPath);

                        //needs testing id replacing
                        string scriptFile = File.ReadAllText(newScriptPath);
                        scriptFile = scriptFile.Replace(updateCard[0], updateCard[1]);
                        File.WriteAllText(newScriptPath, scriptFile);

                        if (patchchk.Checked)
                        {
                            if (File.Exists(newScriptPath))
                            {
                                File.Copy(newScriptPath, Path.Combine("DevPatch\\script", newScriptName), true);
                            }
                        }
                    }
                }
            }
            if (patchchk.Checked)
            {
                File.Copy(str, "DevPatch\\cards.cdb", true);
            }
            UpdateCardsList.Items.Clear();
            MessageBox.Show("Complete.");
            ConvertButton.Enabled = true;
        }