Ejemplo n.º 1
0
 private void ThemedWindow_Loaded(object sender, RoutedEventArgs e)
 {
     //DXSplashScreen.Close();
     //LoadingDecorator loading = new LoadingDecorator();
     ////loading.spl
     //loading.Visibility = Visibility.Visible;
     //SQLApp.ShowAnimate(this.Handle, Util.FunctionList.GetAnimateWindowTime());
     //InputGesture gesture = new KeyGesture(Key.D1, ModifierKeys.Alt, "ALT+D1");
     //string hex = "637E5FC15EZ8831";
     //hex = "A4167B221DFC2D3";
     //System.Security.Cryptography.SymmetricAlgorithm algorithm = System.Security.Cryptography.DES.Create();
     //System.Security.Cryptography.DESCryptoServiceProvider desCrypto = new System.Security.Cryptography.DESCryptoServiceProvider();
     //algorithm.Padding = System.Security.Cryptography.PaddingMode.Zeros;
     //System.Security.Cryptography.ICryptoTransform transform = algorithm.CreateDecryptor();
     //System.IO.MemoryStream stream = new System.IO.MemoryStream();
     //System.Security.Cryptography.CryptoStream stream2 = new System.Security.Cryptography.CryptoStream(stream, transform, System.Security.Cryptography.CryptoStreamMode.Write);
     //byte[] bytes = new ASCIIEncoding().GetBytes(hex);
     //stream2.Write(bytes, 0, bytes.Length);
     //stream2.FlushFinalBlock();
     //byte[] buffer = stream.ToArray();
     //stream2.Close();
     //List<string> funcHotKeysIni = SQLApp.GetKeysIniFile(System.Windows.Forms.Application.StartupPath + "\\config.ini", "HotKeyApp");
     //Parallel.ForEach(funcHotKeysIni, (item) =>
     //{
     //    InputBinding inputBinding = new KeyBinding(mainViewModel.KeyBindingCommand, Key.D1, ModifierKeys.Alt);
     //    inputBinding.CommandParameter = "Alt+D1";
     //    InputBindings.Add(inputBinding);
     //});
     //if (_waitIndicatorService != null)
     //    _waitIndicatorService.HideSplashScreen();
     SQLAppWaitingDialog.HideDialog();
     //InputBinding inputBinding = new KeyBinding(mainViewModel.KeyBindingCommand, Key.Enter, ModifierKeys.None);
     //inputBinding.CommandParameter = "None+Enter";
     //lstFunction.InputBindings.Add(inputBinding);
 }
Ejemplo n.º 2
0
        public void ExecuteScriptFile(Window frmParent)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                string   allLines = File.ReadAllText(openFile.FileName);
                string[] allChar  = new string[] { ";" + Environment.NewLine };
                string[] arrLines = allLines.Split(allChar, StringSplitOptions.None);
                SQLAppWaitingDialog.ShowDialog();
                foreach (string line in arrLines)
                {
                    try
                    {
                        SQLDBUtil.ExecuteNonQuery(line);
                    }
                    catch (Exception ex)
                    {
                        SQLAppWaitingDialog.HideDialog();
                        ShowMessengeWarning("Có lỗi xảy ra");
                    }
                }
                SQLAppWaitingDialog.HideDialog();
                ShowMessengeInfo("Thành công");
            }
        }
Ejemplo n.º 3
0
        public void ChangeDbLaravel(Window frmParent)
        {
            if (!CheckSelectedDB())
            {
                return;
            }

            string sourceUrl = GetSourceCodePath();
            string filePath  = Directory.GetFiles(sourceUrl, "*.env").FirstOrDefault();

            string[] lines  = File.ReadAllLines(filePath);
            string[] lstDBs = SQLDBUtil.GetDataTableByDataSet(SQLDBUtil.GetAllDatabases()).Select().Select(x => x[0].ToString()).ToArray();
            string   DBVal  = lines.ToList().Find(x => x.StartsWith("DB_DATABASE")).Split('=').LastOrDefault();

            if (PromptForm.ShowCombobox("Change Database Name", "Database Name", lstDBs, ref DBVal) == MessageBoxResult.OK)
            {
                SQLAppWaitingDialog.ShowDialog();
                int idx = lines.ToList().FindIndex(x => x.StartsWith("DB_DATABASE"));
                lines[idx] = string.Format("{0}={1}", "DB_DATABASE", DBVal);
                File.WriteAllLines(filePath, lines);
                FunctionListObject functionObj = new FunctionListObject();
                functionObj.FuncName = "CmdLaravelConfigCache";
                ExecutedScriptCommand(functionObj, frmParent);
                SQLAppWaitingDialog.HideDialog();
            }
        }
Ejemplo n.º 4
0
        private void ExecutedScriptCommand(FunctionListObject functionObj, Window frmParent)
        {
            //string funcName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            //Lấy tên function hiện tại
            string strScript = GetScriptCommandByFuncName(functionObj.FuncName);

            strScript = GenerateScriptWithParameters(functionObj, strScript, frmParent);
            if (string.IsNullOrEmpty(strScript))
            {
                ShowMessengeInfo("Không có mã thực thi");
                return;
            }
            SQLAppWaitingDialog.ShowDialog();
            string sourceUrl = GetSourceCodePath();
            string output    = SQLApp.ExecutedPowerShell(string.Format("cd {0} {1} {2}", sourceUrl, Environment.NewLine, strScript));
            string strType   = SQLApp.GetIniFile(strFileCfgScript, strDynPara, functionObj.Name + "Show");

            if (!string.IsNullOrEmpty(strType))
            {
                ShowScriptCommand(output, strType);
                SQLAppWaitingDialog.HideDialog();
                return;
            }
            SQLAppWaitingDialog.HideDialog();
            ShowMessengeInfo(output);
        }
Ejemplo n.º 5
0
        public void MoveFileFolder(Window frmParent)
        {
            string sourceUrl = GetSourceCodePath();

            SQLAppWaitingDialog.ShowDialog();
            List <string> funcKeysIni = SQLApp.GetKeysIniFile(strPath, "FileToFolder");

            foreach (string item in funcKeysIni)
            {
                string strText = SQLApp.GetIniFile(strPath, "FileToFolder", item);

                string[] arr = item.Split('.');

                DirectoryInfo directory = Directory.CreateDirectory(sourceUrl + "/" + string.Join("/", arr));

                foreach (string file in strText.Split('|'))
                {
                    string[] lstFile = Directory.GetFiles(sourceUrl + "/" + arr.FirstOrDefault(), file, SearchOption.AllDirectories);

                    foreach (var filePath in lstFile)
                    {
                        string[] lines = File.ReadAllLines(filePath);

                        for (int i = 0; i < lines.Length - 1; i++)
                        {
                            foreach (string item1 in funcKeysIni)
                            {
                                string[] arr1 = item1.Split('.');
                                if (lines[i].Contains("App\\" + arr1.FirstOrDefault()))
                                {
                                    lines[i].Replace("App\\" + arr1.FirstOrDefault(), "App\\" + string.Join("\\", arr1));
                                }
                            }
                        }
                        File.WriteAllLines(filePath, lines);

                        File.Move(filePath, directory.FullName);
                    }
                }
            }
            SQLAppWaitingDialog.HideDialog();
        }