Ejemplo n.º 1
0
 private void AddUniqueID(string fileName, string connString)
 {
     string            selectCommand = "Select User from " + fileName;
     SQLExecutor       sqlData       = new SQLExecutor();
     List <SqlResults> sqlResults    = sqlData.DataExecutor(selectCommand, connString);
     List <string>     uniqueIds     = sqlResults[0].GetColumnValueAsString("User");
 }
Ejemplo n.º 2
0
        public void ProcessFoxproFiles()
        {
            String strSearch = "MessageBox";

            this.parentForm.Invoke((MethodInvoker) delegate {
                this.parentForm.ClearTextBoxes();
            });

            string selectCommandPrefix = "Select Refno, methods from ";

            List <string> filesInOrder = files.OrderByDescending(s => s).ToList();

            foreach (string file in filesInOrder)
            {
                string      file1         = "C:\\source\\scx_vcx\\application.vcx";
                SQLExecutor sqlData       = new SQLExecutor();
                string      selectCommand = selectCommandPrefix + file + ";";

                List <SqlResults> sqlResults = sqlData.DataExecutor(selectCommand, connString);

                int loop = 2;

                if (sqlResults.Count() > 0)
                {
                    List <Tuple <int, string> > methodsWithId = sqlResults[0].GetMethodsWithId();

                    List <string> newMethods = new List <string>();
                    StringBuilder sb         = new StringBuilder();
                    Debug.WriteLine("##>>" + file + "Methods:" + methodsWithId.Count.ToString());

                    for (int i = 0; i < methodsWithId.Count; i++)
                    {
                        Tuple <int, string> rec = methodsWithId[i];

                        sb.Clear();
                        bool bAppend = false;
                        //string method = methods[i];
                        int    pKey   = rec.Item1;
                        string method = rec.Item2.ToString();
                        Debug.WriteLine("##>>\t" + pKey.ToString());

                        newMethods.Add(method);

                        if (method == string.Empty)
                        {
                            continue;
                        }

                        List <string> methodLines = method.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None).ToList();
                        methodLines = RemoveSplitLines(methodLines);

                        for (int j = 0; j < methodLines.Count; j++)
                        {
                            Debug.WriteLine("##>>\t\t" + j.ToString());

                            Match mtch;
                            mtch = Regex.Match(methodLines[j], strSearch, RegexOptions.IgnoreCase);

                            if (mtch.Success == true)
                            {
                                if (methodLines[j][methodLines[j].Length - 1] == ';')
                                {
                                    int    stIndex      = j;
                                    string strMultiLine = methodLines[j];
                                    strMultiLine  = methodLines[j].Replace(";", string.Empty);
                                    strMultiLine += GetFullFoxproLineBin(methodLines, ref j);
                                    if (stIndex < j)
                                    {
                                        for (int k = stIndex + 1; k < j; k++)
                                        {
                                            newMethods[k] = "";
                                        }
                                    }
                                }


                                string newLine = "";// ProcessMessageBoxes(methodLines[j]);

                                if (!methodLines[j].ToUpper().Contains("sm_get_text_by_text"))
                                {
                                    newLine = ProcessMessageBoxes(methodLines[j]);
                                }
                                else
                                {
                                    int iiii = 0;
                                }

                                sb.AppendLine(newLine);
                                bAppend = true;
                            }
                            else
                            {
                                sb.AppendLine(methodLines[j]);
                            }
                        }

                        newMethods[i] = sb.ToString();

                        if (bAppend)
                        {
                            byte[] bytes           = Encoding.Default.GetBytes(newMethods[i]);
                            string newMethodInUTF8 = Encoding.UTF8.GetString(bytes);
                            bytes = Encoding.Default.GetBytes(method);
                            string oldMethodInUTF8 = Encoding.UTF8.GetString(bytes);
                            int    id = pKey;//this should be the primary key
                            string fileNameToWrite = file;
                            WriteMethodToFile(file, id, newMethodInUTF8, bAppend, oldMethodInUTF8);
                        }
                        else
                        {
                            byte[] bytes           = Encoding.Default.GetBytes(newMethods[i]);
                            string newMethodInUTF8 = Encoding.UTF8.GetString(bytes);
                            int    id = pKey;//this should be the primary key
                            string fileNameToWrite = file;
                            WriteMethodToFile(file, id, newMethodInUTF8);
                        }

                        Application.DoEvents();
                    }
                }
            }
        }