Ejemplo n.º 1
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.º 2
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.º 3
0
        public void ShowFunctionList(string strFuncName, Window frmParent)
        {
            string sourceUrl = SQLApp.GetIniFile(strFileName, "SourceCode", "SourceUrl");
            bool   isReturn  = false;

            if (string.IsNullOrEmpty(sourceUrl) || !Directory.Exists(sourceUrl))
            {
                isReturn = true;
                FolderBrowserDialog folder = new FolderBrowserDialog();
                if (folder.ShowDialog() == DialogResult.OK)
                {
                    SQLApp.SetIniFile(strFileName, "SourceCode", "SourceUrl", folder.SelectedPath);
                    isReturn = false;
                }
            }
            if (isReturn)
            {
                return;
            }
            List <string>             lstFuncs       = SQLApp.GetKeysIniFile(strCfgScriptName, strFuncName, 3000);
            List <FunctionListObject> lstObjectFuncs = new List <FunctionListObject>();

            lstFuncs.ForEach(x =>
            {
                string caption = SQLApp.GetIniFile(strCfgScriptName, "Captions", x);
                if (string.IsNullOrEmpty(caption))
                {
                    caption = string.Join(" ", x.ToUpper().Split('_'));
                }
                lstObjectFuncs.Add(new FunctionListObject {
                    Name = x, Text = caption
                });
            });
            PromptForm._frmParent = frmParent;
            string           value         = string.Empty;
            MessageBoxResult messageResult = PromptForm.ShowCombobox("Function List In Source", "Function Name", lstObjectFuncs.Select(x => x.Text).ToArray(), ref value);

            if (messageResult == MessageBoxResult.OK)
            {
                FunctionListObject functionObj  = lstObjectFuncs.Find(x => x.Text.Equals(value));
                string             strKey       = (functionObj != null) ? functionObj.Name : string.Empty;
                string             functionName = SQLApp.GetIniFile(strCfgScriptName, strFuncName, strKey);
                if (functionName.StartsWith("Cmd"))
                {
                    functionObj.FuncName = functionName;
                    ExecutedScriptCommand(functionObj, frmParent);
                }
                else
                {
                    CallMethodName(functionName, frmParent);
                }
            }
        }
Ejemplo n.º 4
0
        public void LoadQueryPath(FunctionListObject obj, Window frmParent)
        {
            string strQuery = SQLApp.GetFile(obj.Path);

            strQuery = GenerateScriptWithParameters(obj, strQuery, frmParent);
            if (string.IsNullOrEmpty(strQuery))
            {
                return;
            }
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            if (dt == null)
            {
                return;
            }
            ShowResultData(frmParent, dt, strQuery);
        }