Пример #1
0
        //Helper Functions
        private void SearchFieldListGenerator(List <string> Standard, List <string> TCS, List <string> NonStandard)
        {
            int NonSTDCounter = 1;

            SearchField[] varies = new SearchField[200];
            for (int i = 0; i < 200; i++)
            {
                varies[i] = new SearchField();
            }


            int  index     = 0;
            int  fieldflag = 0;
            int  indexstop = 0;
            int  skipadd   = 0;
            bool exists    = false;

            foreach (string field in Standard)
            {
                string[] parts = field.Split('=');
                if (parts[1].Trim() != "")
                {
                    if ((!parts[0].Contains(";")) || (!parts[1].Contains(";")))
                    {
                        for (int i = 0; i < SearchFieldList.Count; i++)
                        {
                            if (SearchFieldList[i].getFldName().ToLower() == parts[1].ToLower())
                            {
                                skipadd = 1;
                                break;
                            }
                        }
                        if (skipadd == 0)
                        {
                            varies[index].setFLDName(parts[1]);

                            for (int zzz = 0; zzz < STDFieldNameList.Count(); zzz++)
                            {
                                if (STDFieldNameList[zzz].ToLower() == parts[0].ToLower())
                                {
                                    varies[index].setSTDFldMapping(STDFieldNameList[zzz]);
                                    exists = true;
                                }
                            }

                            if (!exists)
                            {
                                varies[index].setSTDFldMapping("");
                            }

                            SearchFieldList.Add(varies[index]);

                            exists = false;
                        }
                        skipadd = 0;
                        index++;
                    }
                }
            }

            foreach (string field2 in TCS)
            {
                string[] parts2 = field2.Split('=');
                if (parts2[1].Trim() != "")
                {
                    for (int i = 0; i < SearchFieldList.Count; i++)
                    {
                        if (SearchFieldList[i].getFldName().ToLower() == parts2[0].ToLower())
                        {
                            fieldflag = 1;
                            indexstop = i;
                            break;
                        }
                    }

                    if ((!parts2[0].Contains(";")) || (!parts2[1].Contains(";")))
                    {
                        if (fieldflag == 1)
                        {
                            SearchFieldList[indexstop].setTCSFldMapping(parts2[1]);
                        }
                        else
                        {
                            varies[index].setFLDName(parts2[0]);
                            varies[index].setTCSFldMapping(parts2[1]);
                            SearchFieldList.Add(varies[index]);
                            index++;
                        }
                    }

                    fieldflag = 0;
                }
            }

            foreach (string field3 in NonStandard)
            {
                string[] parts3 = field3.Split('=');
                if (parts3[1].Trim() != "")
                {
                    for (int j = 0; j < SearchFieldList.Count; j++)
                    {
                    }



                    for (int i = 0; i < SearchFieldList.Count; i++)
                    {
                        if (SearchFieldList[i].getFldName().ToLower() == parts3[0].ToLower())
                        {
                            fieldflag = 1;
                            indexstop = i;
                            break;
                        }
                    }

                    if ((!parts3[0].Contains(";")) || (!parts3[1].Contains(";")))
                    {
                        if (fieldflag == 1)
                        {
                            SearchFieldList[indexstop].setNonSTDFldMapping(parts3[1]);
                            SearchFieldList[indexstop].setNonSTDPos(NonSTDCounter);
                            NonSTDCounter++;
                        }
                        else
                        {
                            varies[index].setFLDName(parts3[0]);
                            varies[index].setNonSTDFldMapping(parts3[1]);
                            varies[index].setNonSTDPos(NonSTDCounter);
                            SearchFieldList.Add(varies[index]);
                            index++;
                            NonSTDCounter++;
                        }
                    }
                    fieldflag = 0;
                }
            }
        }
Пример #2
0
 //mutators
 public void addField(SearchField element)
 {
     Fields.Add(element);
 }
Пример #3
0
        public void deleteField(string Name)
        {
            SearchField temp = new SearchField();
            //bool changemade = false;
            int FieldOrder = -10;
            int FieldIndex = -10;

            //Get the position of selected field
            for (int i = 0; i < this.size(); i++)
            {
                if (((SearchField)this.atIndex(i)).getFldName().ToLower() == Name.ToLower())
                {
                    if (((SearchField)this.atIndex(i)).getNonSTDPos() > 0)
                    {
                        FieldOrder = ((SearchField)this.atIndex(i)).getNonSTDPos();
                        FieldIndex = i;
                    }
                }
            }

            //If not 0, move all fields with a higher order, one spot lower
            if ((FieldOrder >= 1) && (FieldIndex != -10))
            {
                for (int i = 0; i < this.size(); i++)
                {
                    if (((SearchField)this.atIndex(i)).getNonSTDPos() > FieldOrder)
                    {
                        ((SearchField)this.atIndex(i)).setNonSTDPos(((SearchField)this.atIndex(i)).getNonSTDPos() - 1);
                        //-100 translates to 0 for this function
                    }
                }
                ((SearchField)this.atIndex(FieldIndex)).setNonSTDPos(-100);
                //changemade = true;
            }



            for (int i = 0; i < this.size(); i++)
            {
                if (((SearchField)this.atIndex(i)).getFldName().ToLower() == Name.ToLower())
                {
                    temp.setFLDName(Name);
                    temp.setSystemName(((SearchField)this.atIndex(i)).getSystemName());
                    temp.setFldDef(((SearchField)this.atIndex(i)).getFldDef());
                    List <List <string> > FieldScript = ((SearchField)this.atIndex(i)).getFldScript();
                    for (int m = 0; m < FieldScript.Count; m++)
                    {
                        temp.addFldScript(FieldScript[m]);
                    }
                    temp.setNonSTDFldMapping(((SearchField)this.atIndex(i)).getNonSTDFldMapping());
                    temp.setSTDFldMapping(((SearchField)this.atIndex(i)).getSTDFldMapping());
                    temp.setTCSFldMapping(((SearchField)this.atIndex(i)).getTCSFldMapping());

                    //this.deleteField(temp, i);

                    Fields.RemoveAt(i);
                    fieldsDeleted.Add(temp);
                    break;
                }
            }
        }
Пример #4
0
        public void updateNamefor(string Name, string NewName)
        {
            SearchField           temp          = new SearchField();
            List <List <string> > UpdatedScript = new List <List <string> >();
            int saveindex = -1;

            if (!doesSystemNameExist(NewName) && (NewName != ""))
            {
                for (int i = 0; i < this.size(); i++)
                {
                    if (((SearchField)this.atIndex(i)).getFldName().ToLower() == Name.ToLower())
                    {
                        temp.setFLDName(Name);
                        temp.setSystemName(((SearchField)this.atIndex(i)).getSystemName());
                        temp.setFldDef(((SearchField)this.atIndex(i)).getFldDef());
                        List <List <string> > FieldScript = ((SearchField)this.atIndex(i)).getFldScript();
                        for (int m = 0; m < FieldScript.Count; m++)
                        {
                            temp.addFldScript(FieldScript[m]);
                        }
                        temp.setNonSTDFldMapping(((SearchField)this.atIndex(i)).getNonSTDFldMapping());
                        temp.setSTDFldMapping(((SearchField)this.atIndex(i)).getSTDFldMapping());
                        temp.setTCSFldMapping(((SearchField)this.atIndex(i)).getTCSFldMapping());

                        //this.deleteField(temp, i);
                        fieldsDeleted.Add(temp);

                        ((SearchField)this.atIndex(i)).setFLDName(NewName);
                        ((SearchField)this.atIndex(i)).ModifiedYes();
                        UpdatedScript = ((SearchField)this.atIndex(i)).getFldScript();
                        saveindex     = i;
                        break;
                    }
                }


                for (int k = 0; k < UpdatedScript.Count; k++)
                {
                    for (int j = 0; j < UpdatedScript[k].Count; j++)
                    {
                        if ((!UpdatedScript[k][j].StartsWith(";")) && (UpdatedScript[k][j].ToLower().Contains("ifval")) && (UpdatedScript[k][j].ToLower().Contains("\"\\fields." + Name.ToLower() + "\\\"")))
                        {
                            UpdatedScript[k][j] = UpdatedScript[k][j].Replace(Name, NewName);
                        }
                        else if ((!UpdatedScript[k][j].StartsWith(";")) && (UpdatedScript[k][j].ToLower().Contains("ifnval")) && (UpdatedScript[k][j].ToLower().Contains("\"\\fields." + Name.ToLower() + "\\\"")))
                        {
                            UpdatedScript[k][j] = UpdatedScript[k][j].Replace(Name, NewName);
                        }
                        else if ((!UpdatedScript[k][j].StartsWith(";")) && (UpdatedScript[k][j].ToLower().Contains("ifinc")) && (UpdatedScript[k][j].ToLower().Contains("\"\\fields." + Name.ToLower() + "\\")))
                        {
                            UpdatedScript[k][j] = UpdatedScript[k][j].Replace(Name, NewName);
                        }
                        else if ((!UpdatedScript[k][j].StartsWith(";")) && (UpdatedScript[k][j].ToLower().Contains("ifinfield")) && (UpdatedScript[k][j].ToLower().Contains("\"\\fields." + Name.ToLower() + "\\")))
                        {
                            UpdatedScript[k][j] = UpdatedScript[k][j].Replace(Name, NewName);
                        }
                        else if ((!UpdatedScript[k][j].StartsWith(";")) && (UpdatedScript[k][j].ToLower().Contains("transval")) && (UpdatedScript[k][j].ToLower().Contains("\"\\fields." + Name.ToLower() + "\\")))
                        {
                            UpdatedScript[k][j] = UpdatedScript[k][j].Replace(Name, NewName);
                        }
                        else if ((!UpdatedScript[k][j].StartsWith(";")) && (UpdatedScript[k][j].ToLower().Contains("setfield")) && (UpdatedScript[k][j].ToLower().Contains("\"\\fields." + Name.ToLower() + "\\")))
                        {
                            UpdatedScript[k][j] = UpdatedScript[k][j].Replace(Name, NewName);
                        }
                        else if ((!UpdatedScript[k][j].StartsWith(";")) && (UpdatedScript[k][j].ToLower().Contains("label")) && (UpdatedScript[k][j].ToLower().Contains(Name.ToLower())))
                        {
                            UpdatedScript[k][j] = UpdatedScript[k][j].Replace(Name, NewName);
                        }
                        else if ((!UpdatedScript[k][j].StartsWith(";")) && (UpdatedScript[k][j].ToLower().Contains("goto")) && (UpdatedScript[k][j].ToLower().Contains(Name.ToLower())))
                        {
                            UpdatedScript[k][j] = UpdatedScript[k][j].Replace(Name, NewName);
                        }
                    }
                }


                if ((saveindex >= 0) && (saveindex < this.size()) && (saveindex == 0))
                {
                    for (int k = 0; k < UpdatedScript.Count; k++)
                    {
                        ((SearchField)this.atIndex(saveindex)).setFldScript(UpdatedScript[k], k);
                    }
                    ((SearchField)this.atIndex(saveindex)).ModifiedYes();
                }
            }
        }