Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
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();
        }