Beispiel #1
0
        public int GetAnimateWindowTime()
        {
            int dwTime = 5000;

            dwTime = Convert.ToInt32(SQLApp.GetIniFile(strFileName, "AnimateWindow", "AnimateTime"));
            return(dwTime);
        }
Beispiel #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);
        }
        public int CreateLinkServer(int indexFrom, int indexTo, string strDBFrom, string strDBTo)
        {
            string strSrvName  = GetDescriptionConfig(indexFrom);
            string strSrvAdd   = GetServerConfig(indexFrom);
            string strUser     = GetUserNameConfig(indexFrom);
            string strPassWord = GetPassWordConfig(indexFrom);

            string strSrvNameTo  = GetDescriptionConfig(indexTo);
            string strSrvAddTo   = GetServerConfig(indexFrom);
            string strUserTo     = GetUserNameConfig(indexTo);
            string strPassWordTo = GetPassWordConfig(indexTo);

            string strQuery = SQLApp.GetFile(strPath + "LinkServer.sql");

            strQuery = strQuery.Replace("@serverName@", strSrvName);
            strQuery = strQuery.Replace("@serverAddress@", strSrvAdd);
            strQuery = strQuery.Replace("@serverUser@", strUser);
            strQuery = strQuery.Replace("@serverPass@", strPassWord);
            strQuery = strQuery.Replace("@serverDB@", strDBFrom);

            strQuery = strQuery.Replace("@serverNameTo@", strSrvNameTo);
            strQuery = strQuery.Replace("@serverAddressTo@", strSrvAddTo);
            strQuery = strQuery.Replace("@serverUserTo@", strUserTo);
            strQuery = strQuery.Replace("@serverPassTo@", strPassWordTo);
            strQuery = strQuery.Replace("@serverDBTo@", strDBTo);

            return(SQLDBUtil.ExecuteNonQuery(strQuery));
        }
        //Ctrl + 0 View Connect Sql
        public void GetViewConnectToSQL(Window frmParent)
        {
            string    strQuery = SQLApp.GetFile(strPath + "ViewConnectSql.sql");
            DataTable dtSource = SQLDBUtil.GetDataTable(strQuery);

            ShowResultData(frmParent, dtSource, strQuery);
        }
        //public void LoadFunction(frmMain frmParent)
        //{
        //    ListViewItem obj = frmParent.lstFunction.SelectedItems.Cast<ListViewItem>().FirstOrDefault();
        //    if (obj == null) return;
        //    string strCnt = SQLApp.GetIniFile(strFileCfgScript, strDynPara, obj.Text + "Cnt");
        //    if (string.IsNullOrEmpty(strCnt)) return;
        //    int idxCnt = Convert.ToInt32(strCnt);
        //    Dictionary<string, string> dicPara = new Dictionary<string, string>();
        //    for (int i = 1; i <= idxCnt; i++)
        //    {
        //        string strName = SQLApp.GetIniFile(strFileCfgScript, strDynPara, obj.Text + "Name" + i);
        //        string strVal = SQLApp.GetIniFile(strFileCfgScript, strDynPara, obj.Text + "Val" + i);
        //        string strValList = SQLApp.GetIniFile(strFileCfgScript, strDynPara, obj.Text + "ValList" + i);
        //        MessageBoxResult result = MessageBoxResult.Cancel;
        //        if (strName.Contains("TableName"))
        //            result = PromptForm.ShowCombobox(obj.Text, strName, ref strVal);
        //        else if(!string.IsNullOrEmpty(strValList))
        //            result = PromptForm.ShowCombobox(obj.Text, strName, strValList.Split('|'), ref strVal);
        //        else
        //            result = PromptForm.ShowText(obj.Text, strName, ref strVal);
        //        if (result == MessageBoxResult.Cancel) return;
        //        dicPara.AddItem(strName, strVal);
        //    }
        //    string strQuery = SQLApp.GetFile(strPath + obj.Text + ".sql");
        //    foreach (KeyValuePair<string,string> item in dicPara)
        //    {
        //        strQuery = strQuery.Replace(item.Key, item.Value);
        //    }
        //    SQLDBUtil.GetDataSet(strQuery);
        //}
        #region Sync DB
        public DataSet SynchronizeTable(int indexFrom, int indexTo, string strDBFrom, string strDBTo)
        {
            int    iResult     = CreateLinkServer(indexFrom, indexTo, strDBFrom, strDBTo);
            string strSrvName  = GetDescriptionConfig(indexFrom);
            string strSrvAdd   = GetServerConfig(indexFrom);
            string strUser     = GetUserNameConfig(indexFrom);
            string strPassWord = GetPassWordConfig(indexFrom);

            string strSrvNameTo  = GetDescriptionConfig(indexTo);
            string strSrvAddTo   = GetServerConfig(indexFrom);
            string strUserTo     = GetUserNameConfig(indexTo);
            string strPassWordTo = GetPassWordConfig(indexTo);

            string strQuery = SQLApp.GetFile(strPath + "SyncDB.sql");

            strQuery = strQuery.Replace("@serverName@", strSrvName);
            strQuery = strQuery.Replace("@serverAddress@", strSrvAdd);
            strQuery = strQuery.Replace("@serverUser@", strUser);
            strQuery = strQuery.Replace("@serverPass@", strPassWord);
            strQuery = strQuery.Replace("@serverDB@", strDBFrom);

            strQuery = strQuery.Replace("@serverNameTo@", strSrvNameTo);
            strQuery = strQuery.Replace("@serverAddressTo@", strSrvAddTo);
            strQuery = strQuery.Replace("@serverUserTo@", strUserTo);
            strQuery = strQuery.Replace("@serverPassTo@", strPassWordTo);
            strQuery = strQuery.Replace("@serverDBTo@", strDBTo);

            return(SQLDBUtil.GetDataSet(strQuery));
        }
        //Ctrl + Shift + A : Create Module
        public void CreateMoudle()
        {
            string           str           = MethodInfo.GetCurrentMethod().Name;
            string           strModuleName = "";
            MessageBoxResult result        = PromptForm.ShowText(str, "Module Name", ref strModuleName);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strModuleDesc = "";

            result = PromptForm.ShowText(str, "Module Descreiption", ref strModuleDesc);
            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strModuleCode = "";

            result = PromptForm.ShowText(str, "Module Code", ref strModuleCode);
            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            if (!string.IsNullOrEmpty(strModuleName) && !string.IsNullOrEmpty(strModuleDesc) && !string.IsNullOrEmpty(strModuleCode))
            {
                string strQuery = SQLApp.GetFile(strPath + "CreateModule.sql");
                strQuery = strQuery.Replace("@ModuleName@", strModuleName);
                strQuery = strQuery.Replace("@ModuleCode@", strModuleCode);
                strQuery = strQuery.Replace("@ModuleDesc@", strModuleDesc);
                int iResult = SQLDBUtil.ExecuteNonQuery(strQuery);
                ShowMessenger(iResult);
            }
        }
Beispiel #7
0
 public string GetItemConfig(string keySection, string keyPrefix, int idx)
 {
     if (string.IsNullOrEmpty(keySection))
     {
         keySection = section;
     }
     return(SQLApp.GetIniFile(strFileName, keySection, keyPrefix + (idx + 1)));
 }
Beispiel #8
0
        public string GetThemeName()
        {
            string _themeName = SQLApp.GetIniFile(StrFileName, StrThemeApp, StrThemeName);

            if (string.IsNullOrEmpty(_themeName))
            {
                _themeName = Properties.Resources.ThemeName;
            }
            return(_themeName);
        }
Beispiel #9
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);
                }
            }
        }
        public string GetScriptCreateTable(string strDBName, string strTable)
        {
            string strQuery = SQLApp.GetFile(strPath + "CreateTable.sql");

            strQuery = strQuery.Replace("@tablename@", strTable);
            strQuery = strQuery.Replace("@schemaname@", strDBName);
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            if (dt != null && dt.Rows.Count > 0)
            {
                return(string.Format("{0}", dt.Rows[0][0]));
            }
            return("");
        }
        //Ctrl + Alt + T : Gen Script Create Table
        public void GenScriptCreateTable(Window frmParent)
        {
            string           str          = MethodInfo.GetCurrentMethod().Name;
            string           strTableName = "";
            MessageBoxResult result       = PromptForm.ShowCombobox(str, "Table Name", ref strTableName);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strQuery = SQLApp.GetFile(strPath + "GenCreateTable.sql");

            strQuery = strQuery.Replace("@TableName@", strTableName);
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            ShowResultData(frmParent, dt, strQuery);
        }
        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);
        }
        //Ctrl + 6: Gen Info / Controller
        public void GenInfoController()
        {
            string           str          = MethodInfo.GetCurrentMethod().Name;
            string           strTableName = "";
            MessageBoxResult result       = PromptForm.ShowCombobox(str, "Table Name", ref strTableName);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strType = string.Empty;

            result = PromptForm.ShowCombobox(str, "Gen Controller", new string[] { "YES", "NO" }, ref strType);
            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strQuery = SQLApp.GetFile(strPath + "GenInfo.sql");

            strQuery = strQuery.Replace("@TableName@", strTableName);
            strQuery = strQuery.Replace("@Version@", System.Windows.Forms.Application.ProductName + " - " + System.Windows.Forms.Application.ProductVersion);
            strQuery = strQuery.Replace("@CreatedDate@", DateTime.Now.ToShortDateString());
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            if (dt != null)
            {
                string strContent = Convert.ToString(dt.Rows[0][0]);
                SQLApp.WriteFile("D:\\" + strTableName + "Info.cs", strContent);
                //NotifycationAler aler = new NotifycationAler();
                //aler.ShowDialog();
            }
            if (strType == "YES")
            {
                strQuery = SQLApp.GetFile(strPath + "GenController.sql");
                strQuery = strQuery.Replace("@TableName@", strTableName);
                strQuery = strQuery.Replace("@Version@", System.Windows.Forms.Application.ProductName + " - " + System.Windows.Forms.Application.ProductVersion);
                strQuery = strQuery.Replace("@CreatedDate@", DateTime.Now.ToShortDateString());
                dt       = SQLDBUtil.GetDataTable(strQuery);
                if (dt != null)
                {
                    string strContent = Convert.ToString(dt.Rows[0][0]);
                    SQLApp.WriteFile("D:\\" + strTableName + "Controller.cs", strContent);
                }
            }
        }
Beispiel #14
0
        public List <string> LoadConfigInitToList(string keySection = null)
        {
            List <string> lst = new List <string>();

            if (string.IsNullOrEmpty(keySection))
            {
                keySection = section;
            }
            string count = SQLApp.GetIniFile(strFileName, keySection, serverCnt);

            if (!string.IsNullOrEmpty(count))
            {
                for (int i = 0; i < Convert.ToInt32(count); i++)
                {
                    lst.Add(SQLApp.GetIniFile(strFileName, keySection, ServerDesc + (i + 1)));
                }
            }
            return(lst);
        }
Beispiel #15
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();
        }
 public void GetAllLanguage(Window frmParent)
 {
     try
     {
         string     sourceUrl = SQLApp.GetIniFile(strFileName, "SourceCode", "SourceUrl");
         string[]   listFiles = Directory.GetFiles(string.Format("{0}\\database\\seeds\\lang", sourceUrl), "*_lang.php", SearchOption.AllDirectories);
         DataTable  dtLang    = new DataTable("Language");
         DataColumn col       = new DataColumn("Group");
         dtLang.Columns.Add(col);
         col = new DataColumn("Key");
         dtLang.Columns.Add(col);
         col = new DataColumn("Text_vi");
         dtLang.Columns.Add(col);
         col = new DataColumn("Text_en");
         dtLang.Columns.Add(col);
         col = new DataColumn("Text_ja");
         dtLang.Columns.Add(col);
         foreach (string item in listFiles)
         {
             string strContent = SQLApp.ExecutedPowerShell(string.Format("php -r \"echo json_encode(require '{0}');\"", item));
             object obj        = JsonConvert.DeserializeObject(strContent);
             string objGroup   = (obj as Newtonsoft.Json.Linq.JObject).GetValue("group").ToString();
             Newtonsoft.Json.Linq.JArray objLang = (obj as Newtonsoft.Json.Linq.JObject).GetValue("lang") as Newtonsoft.Json.Linq.JArray;
             foreach (object objItem in objLang)
             {
                 DataRow dr = dtLang.NewRow();
                 dr["Group"]   = objGroup;
                 dr["Key"]     = (objItem as Newtonsoft.Json.Linq.JObject).GetValue("key").ToString();
                 dr["Text_vi"] = (objItem as Newtonsoft.Json.Linq.JObject).SelectToken("text.vi").ToString();
                 dr["Text_en"] = (objItem as Newtonsoft.Json.Linq.JObject).SelectToken("text.en").ToString();
                 dr["Text_ja"] = (objItem as Newtonsoft.Json.Linq.JObject).SelectToken("text.ja").ToString();
                 dtLang.Rows.Add(dr);
             }
         }
         ShowResultData(frmParent, dtLang);
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #17
0
 protected void ShowScriptCommand(string output, string strType)
 {
     if (strType.Equals("table"))
     {
         string[]  arr     = output.Split('\n');
         DataTable dtSoure = new DataTable();
         dtSoure.TableName = "Route List";
         int idx = 0;
         arr.ToList().ForEach(r =>
         {
             string[] row = r.Split('|');
             if (row.Length > 1)
             {
                 if (idx == 0)
                 {
                     row.Where(c => !string.IsNullOrEmpty(c.Trim())).ToList().ForEach(c =>
                     {
                         DataColumn col = new DataColumn(c.Trim(), typeof(string));
                         dtSoure.Columns.Add(col);
                     });
                 }
                 else
                 {
                     dtSoure.LoadDataRow(row.Where(c => !string.IsNullOrEmpty(c.Trim())).Select(c => c.Trim()).ToArray(), false);
                 }
                 idx++;
             }
         });
         ShowResultData(null, dtSoure);
     }
     else
     {
         SaveFileDialog saveFile = new SaveFileDialog();
         saveFile.Filter = "*." + strType.Replace("file", "");
         if (saveFile.ShowDialog() == DialogResult.OK)
         {
             SQLApp.WriteFile(saveFile.FileName, output);
         }
     }
 }
        //Ctrl + 1 tìm module
        public void FindModule(Window frmParent)
        {
            PromptForm._frmParent = frmParent;
            string           moduleName = "";
            MessageBoxResult result     = PromptForm.ShowText("Find Module", "ModuleName", ref moduleName);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strQuery = SQLApp.GetFile(strPath + "FindModule.sql");

            strQuery = strQuery.Replace("@ModuleName@", moduleName);
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            if (dt == null)
            {
                return;
            }
            dt.TableName = "STModules";
            ShowResultData(frmParent, dt, strQuery);
        }
Beispiel #19
0
 public string GetServerHistoryConfig()
 {
     return(SQLApp.GetIniFile(strFileName, "LoginHistory", "ServerOld"));
 }
Beispiel #20
0
 public void SetDBHistoryConfig(int idx, string strDBOld)
 {
     SQLApp.SetIniFile(strFileName, section, ServerDBOld + (idx + 1), strDBOld);
 }
Beispiel #21
0
 public void SetServerHistoryConfig(string strSVOld)
 {
     SQLApp.SetIniFile(strFileName, "LoginHistory", "ServerOld", strSVOld);
 }
Beispiel #22
0
 public string GetDescriptionConfig(int idx)
 {
     return(SQLApp.GetIniFile(strFileName, section, ServerDesc + (idx + 1)));
 }
Beispiel #23
0
 public string GetDBHistoryConfig(int idx)
 {
     return(SQLApp.GetIniFile(strFileName, section, ServerDBOld + (idx + 1)));
 }
Beispiel #24
0
 public string GetPassWordConfig(int idx)
 {
     return(SQLApp.GetIniFile(strFileName, section, ServerPWD + (idx + 1)));
 }
Beispiel #25
0
 public string GetUserNameConfig(int idx)
 {
     return(SQLApp.GetIniFile(strFileName, section, ServerUID + (idx + 1)));
 }
Beispiel #26
0
        public void GetConfigConnectSQL(string status, int idx = 0)
        {
            string cnt   = SQLApp.GetIniFile(strFileName, section, serverCnt);
            int    index = Convert.ToInt32(cnt);

            switch (status)
            {
            case "Add":
            case "Edit":
                string           strDesc = SQLApp.GetIniFile(strFileName, section, ServerDesc + idx);
                MessageBoxResult result  = PromptForm.ShowText("Description", "Description", ref strDesc);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
                string strServer = SQLApp.GetIniFile(strFileName, section, ServerName + idx);
                result = PromptForm.ShowText("Server", "Server", ref strServer);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
                string strUser = SQLApp.GetIniFile(strFileName, section, ServerUID + idx);
                result = PromptForm.ShowText("User", "User", ref strUser);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
                string strPass = SQLApp.GetIniFile(strFileName, section, ServerPWD + idx);
                result = PromptForm.ShowText("Pass", "Pass", ref strPass);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(strDesc) && !string.IsNullOrEmpty(strServer) && !string.IsNullOrEmpty(strUser))
                {
                    if (status == "Add")
                    {
                        index += 1;
                        SQLApp.SetIniFile(strFileName, section, serverCnt, index.ToString());
                    }
                    else
                    {
                        index = idx;
                    }
                    SQLApp.SetIniFile(strFileName, section, ServerDesc + index, strDesc);
                    SQLApp.SetIniFile(strFileName, section, ServerName + index, strServer);
                    SQLApp.SetIniFile(strFileName, section, ServerUID + index, strUser);
                    SQLApp.SetIniFile(strFileName, section, ServerPWD + index, strPass);
                    SQLApp.SetIniFile(strFileName, section, ServerDBOld + index, "");
                }
                break;

            case "Del":
                SQLApp.SetIniFile(strFileName, section, serverCnt, (index - 1).ToString());
                SQLApp.SetIniFile(strFileName, section, ServerDesc + idx, null);
                SQLApp.SetIniFile(strFileName, section, ServerName + idx, null);
                SQLApp.SetIniFile(strFileName, section, ServerUID + idx, null);
                SQLApp.SetIniFile(strFileName, section, ServerPWD + idx, null);
                SQLApp.SetIniFile(strFileName, section, ServerDBOld + idx, null);
                break;
            }
        }
Beispiel #27
0
 public void SetThemeName(string themeName)
 {
     SQLApp.SetIniFile(StrFileName, StrThemeApp, StrThemeName, themeName);
 }
Beispiel #28
0
 public string GetScriptCommandByFuncName(string strFuncName)
 {
     return(SQLApp.GetIniFile(string.Concat(strPath, "ScriptCommand.ini"), "Laravel", strFuncName));
 }