Beispiel #1
0
        private void BtSetFolder_Click(object sender, EventArgs e)
        {
            using (var fbd = new FolderBrowserDialog())
            {
                fbd.SelectedPath = IniUtils.GetConfig("Directories", "FixpackDir");
                DialogResult result;
                try
                {
                    result = fbd.ShowDialog();
                }
                catch (Exception exc)
                {
                    fbd.SelectedPath = "";
                    result           = fbd.ShowDialog();
                }

                if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
                {
                    IniUtils.SetConfig("Directories", "FixpackDir", fbd.SelectedPath);
                    folder           = fbd.SelectedPath;
                    LbSetFolder.Text = "Папка: " + fbd.SelectedPath;
                    (new ToolTip()).SetToolTip(LbSetFolder, LbSetFolder.Text);
                    subfolders = Directory.GetDirectories(folder);


                    MessageBox.Show("Найдено: " + subfolders.Length.ToString() + " патчей", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BtCreateFileScFromSc.Enabled    = true;
                    BtCreateFileScFromFiles.Enabled = true;
                    BtRNCheck.Enabled = true;
                    BtCheckFp.Enabled = true;
                }
            }
        }
Beispiel #2
0
        private static bool GetBookInfo(string id, out BookInfo info)
        {
            info = null;
            var filePath = IniUtils.Read(ConfigFile, id, FILEPATHITEMNAME).Trim();

            if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
            {
                IniUtils.Write(ConfigFile, id, "", "");
                return(false);
            }
            int    index;
            double offset;

            int.TryParse(IniUtils.Read(ConfigFile, id, CHAPTERINDEXITEMNAME, "0").Trim(), out index);
            double.TryParse(IniUtils.Read(ConfigFile, id, CHAPTEROFFSETITEMNAME, "0").Trim(), out offset);
            var name     = IniUtils.Read(ConfigFile, id, BOOKNAMEITEMNAME).Trim();
            var itemName = IniUtils.Read(ConfigFile, id, CHAPTERNAMEITEMNAME).Trim();

            info = new BookInfo()
            {
                BookId        = id,
                BookName      = name,
                ChapterName   = itemName,
                FilePath      = filePath,
                ChapterIndex  = index,
                ChapterOffset = offset
            };
            return(true);
        }
        private void Conectar()
        {
            try
            {
                var iniFile = IniUtils.LerArquivoIni();

                var stringConexao = "Persist Security Info=True;"
                                    + "server=" + iniFile["DbConfig"]["server"] + ";"
                                    + "port=" + iniFile["DbConfig"]["port"] + ";"
                                    + "database=" + iniFile["DbConfig"]["database"] + ";"
                                    + "uid=" + iniFile["DbConfig"]["uid"] + ";"
                                    + "pwd=" + iniFile["DbConfig"]["pwd"];

                var mysql = new MySqlConnection(stringConexao);
                try
                {
                    mysql.Open();
                }
                catch
                {
                    CriarSchemaBanco(iniFile["DbConfig"]["host"], iniFile["DbConfig"]["port"], iniFile["DbConfig"]["db"], iniFile["DbConfig"]["pwd"], iniFile["DbConfig"]["user"]);
                }
                finally
                {
                    mysql.Close();
                }
                ConectarNHibernate(stringConexao);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível conectar ao banco de dados.", ex);
            }
        }
Beispiel #4
0
 public static string GetConfig(ConfigKey key, string defaultValue = "")
 {
     if (!File.Exists(ConfigFile))
     {
         return(defaultValue);
     }
     return(IniUtils.Read(ConfigFile, CONFIGKEY, key.ToString(), defaultValue).Trim());
 }
Beispiel #5
0
 private static void SaveBookData(BookInfo info)
 {
     //文件地址
     IniUtils.Write(ConfigFile, info.BookId, FILEPATHITEMNAME, info.FilePath);
     IniUtils.Write(ConfigFile, info.BookId, CHAPTERINDEXITEMNAME, info.ChapterIndex.ToString());
     IniUtils.Write(ConfigFile, info.BookId, CHAPTEROFFSETITEMNAME, info.ChapterOffset.ToString());
     IniUtils.Write(ConfigFile, info.BookId, BOOKNAMEITEMNAME, info.BookName);
     IniUtils.Write(ConfigFile, info.BookId, CHAPTERNAMEITEMNAME, info.ChapterName);
 }
Beispiel #6
0
        public VSSForm()
        {
            InitializeComponent();
            Application.Idle += OnIdle;

            Connect();

            TbSourceFolder.Text = IniUtils.GetConfig("Folders", "Source");
            TbDestFolder.Text   = IniUtils.GetConfig("Folders", "Dest");
        }
Beispiel #7
0
        private void TsChangeVSSDatabase_Click(object sender, EventArgs e)
        {
            SetAttrDialog sad = new SetAttrDialog("База VSS");

            sad.ShowDialog();
            if (sad.Set)
            {
                IniUtils.SetConfig("Credentials", "Base", sad.Attr);
            }
            Connect();
        }
Beispiel #8
0
 public static void SetConfig(ConfigKey key, string value)
 {
     if (!File.Exists(ConfigFile))
     {
         using (var fs = File.Create(ConfigFile))
         {
             fs.Close();
         }
     }
     IniUtils.Write(ConfigFile, CONFIGKEY, key.ToString(), value);
 }
Beispiel #9
0
        private void TsSetCVSType_Click(object sender, EventArgs e)
        {
            SetAttrDialog sad = new SetAttrDialog("Тип системы контроля версий");

            sad.Attr = "VSS";
            sad.ShowDialog();
            if (sad.Set)
            {
                IniUtils.SetConfig("CVS", "CVSType", sad.Attr);
                Connect();
            }
        }
Beispiel #10
0
        private void TsChangeLoggingBase_Click(object sender, EventArgs e)
        {
            SetAttrDialog sad = new SetAttrDialog("TNS для базы, где ведется логирование");

            sad.Attr = Properties.Settings.Default.OraTNS;
            sad.ShowDialog();
            if (sad.Set)
            {
                IniUtils.SetConfig("Credentials", "CustomTNS", sad.Attr);
                Connect();
            }
        }
Beispiel #11
0
 private void DownloadVSSDestFolder()
 {
     using (FolderBrowserDialog fbd = new FolderBrowserDialog())
     {
         if (fbd.ShowDialog() == DialogResult.OK)
         {
             IniUtils.SetConfig("Directories", "WorkingFolder", fbd.SelectedPath);
             string localFolder = fbd.SelectedPath + "\\" + new DirectoryInfo(TbDestFolder.Text).Name;
             Directory.CreateDirectory(localFolder);
             DownloadVSSDestFolder(localFolder);
         }
     }
 }
Beispiel #12
0
        private void TsLoadOrder_Click(object sender, EventArgs e)
        {
            Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
            string folder;

            using (var ofd = new OpenFileDialog())
            {
                ofd.DefaultExt       = "xls";
                ofd.Filter           = "Файл Excel(*.XLS;*.XLSX)|*.XLS;*.XLSX|Все файлы (*.*)|*.*";
                ofd.InitialDirectory = IniUtils.GetConfig("Directories", "ExcelDir");
                DialogResult result;
                try
                {
                    result = ofd.ShowDialog();
                }
                catch (Exception exc)
                {
                    ofd.InitialDirectory = "";
                    result = ofd.ShowDialog();
                }

                if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(ofd.FileName))
                {
                    TbFolders.Text = "";
                    IniUtils.SetConfig("Directories", "ExcelDir", Path.GetDirectoryName(ofd.FileName));
                    folder = ofd.FileName;

                    Microsoft.Office.Interop.Excel.Workbook   xlWorkbook  = xlApp.Workbooks.Open(folder);
                    Microsoft.Office.Interop.Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
                    Microsoft.Office.Interop.Excel.Range      xlRange     = xlWorksheet.UsedRange;

                    int rowCount      = xlRange.Rows.Count;
                    int colCount      = xlRange.Columns.Count;
                    int patchColumn   = 2;
                    int firstPatchRow = 2;

                    for (int i = firstPatchRow; i <= rowCount; i++)
                    {
                        //write the value to the console
                        if (xlRange.Cells[i, patchColumn] != null && xlRange.Cells[i, patchColumn].Value2 != null)
                        {
                            TbFolders.Text += xlRange.Cells[i, patchColumn].Value2.ToString() + Environment.NewLine;
                        }
                    }

                    ExcelCleanup(xlRange, xlWorksheet, xlWorkbook, xlApp);
                }
            }
        }
Beispiel #13
0
        public static bool GetCurrentBookInfo(out BookInfo info)
        {
            info = null;
            if (!File.Exists(ConfigFile))
            {
                return(false);
            }
            var id = IniUtils.Read(ConfigFile, CURRENTKEY, BOOKIDITEMNAME).Trim();

            if (string.IsNullOrEmpty(id))
            {
                return(false);
            }
            return(GetBookInfo(id, out info));
        }
Beispiel #14
0
        public PartialViewResult CadastraAdmin(string email, string senha)
        {
            var u       = new Usuario();
            var iniFile = IniUtils.LerArquivoIni();

            if (email.Equals(iniFile["AdminFirstUser"]["key"]) && senha.Equals(iniFile["AdminFirstUser"]["password"]))
            {
                u.Admin     = true;
                u.Email     = email;
                u.Nome      = "";
                u.Sobrenome = "";
                u.Senha     = senha;
                u.Cpf       = "";
            }
            return(PartialView("_CreateUser", DbConfig.Instance.UsuarioRepository.Save(u)));
        }
Beispiel #15
0
        private void BtMove_Click(object sender, EventArgs e)
        {
            IniUtils.SetConfig("Folders", "Source", TbSourceFolder.Text);
            IniUtils.SetConfig("Folders", "Dest", TbDestFolder.Text);
            string[] folders = TbFolders.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            threadsAmount   = folders.Length;
            threadsSucceded = 0;

            try
            {
                cvs.Move(TbSourceFolder.Text, TbDestFolder.Text, folders);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Beispiel #16
0
 public static void SaveCurrentBook(BookInfo info)
 {
     if (!File.Exists(ConfigFile))
     {
         using (var fs = File.Create(ConfigFile))
         {
             fs.Close();
         }
     }
     if (!string.IsNullOrEmpty(info.FilePath))
     {
         IniUtils.Write(ConfigFile, CURRENTKEY, BOOKIDITEMNAME, info.BookId);
         SaveBookData(info);
         return;
     }
     IniUtils.Write(ConfigFile, CURRENTKEY, BOOKIDITEMNAME, "");
 }
Beispiel #17
0
        public static List <BookInfo> GetAllBooks()
        {
            List <BookInfo> infos    = new List <BookInfo>();
            var             sections = IniUtils.ReadSections(ConfigFile);

            foreach (var section in sections)
            {
                if (section != CURRENTKEY && section != CONFIGKEY)
                {
                    BookInfo info;
                    if (GetBookInfo(section, out info))
                    {
                        infos.Add(info);
                    }
                }
            }
            return(infos);
        }
Beispiel #18
0
        private void Connect()
        {
            try
            {
                basePath = IniUtils.GetConfig("Credentials", "Base");
                string cvsType = IniUtils.GetConfig("CVS", "CVSType");
                if (String.IsNullOrWhiteSpace(cvsType))
                {
                    throw new ArgumentException("В настройках задайте тип системы контроля версий");
                }

                if (String.IsNullOrWhiteSpace(basePath))
                {
                    throw new ArgumentException("В настройках задайте правильный путь до " + cvsType);
                }
                cvs          = Activator.CreateInstance("CVSLib", "CVSLib.CVSTypes." + IniUtils.GetConfig("CVS", "CVSType")).Unwrap() as CVS;
                cvs.location = basePath;
                cvs.login    = Environment.UserName;
                cvs.Connect();
                //cvs = new VSS(basePath, Environment.UserName);
            }

            catch (COMException exc)
            {
                string message = VSSErrors.GetMessageByCode(exc.ErrorCode);
                MessageBox.Show(message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            catch (ArgumentException exc)
            {
                MessageBox.Show(exc.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #19
0
        private void BtDownload_Click(object sender, EventArgs e)
        {
            string workingFolder = IniUtils.GetConfig("Directories", "WorkingFolder");

            DownloadVSSDestFolder();
        }
Beispiel #20
0
 public static void DelBook(string id)
 {
     IniUtils.WriteSection(ConfigFile, id, "");
 }