Beispiel #1
0
        private void GenerateSearchFields()
        {
            try
            {
                var di =
                    new DirectoryInfo(Path.Combine(Properties.Settings.Default.TFSLocalFolder, ModuleIDTextBox.Text));
                SharepointXlsHelper.RefreshDataDictionary();
                var metaData = new Model.Metadata(Path.Combine(di.FullName, "metadata.xml"));
                HashSet <string> mlsClassList = metaData.GetMlsMetadataClassList("Property");
                if (mlsClassList.Count == 0)
                {
                    mlsClassList = metaData.GetMlsMetadataClassList("PropertyResource");
                }
                foreach (var fi in di.GetFiles())
                {
                    if (fi.Name.ToLower().EndsWith(".sql"))
                    {
                        if (fi.Name.ToLower().EndsWith("ag.sql"))
                        {
                            bool agentClassFound = false;
                            var  classList       = metaData.GetMlsMetadataClassList("ActiveAgent");
                            if (classList.Any())
                            {
                                GenerateDefFile(fi.FullName, metaData, TRPTxtSelectFileTextBox.Text, "ActiveAgent");
                                agentClassFound = true;
                            }
                            classList = metaData.GetMlsMetadataClassList("Agent");
                            if (classList.Any())
                            {
                                var agentFilePath = fi.FullName.ToLower().Replace("ag.sql", "Agentag.sql");
                                File.Copy(fi.FullName, agentFilePath);
                                GenerateDefFile(agentFilePath, metaData, TRPTxtSelectFileTextBox.Text, "Agent");
                                agentClassFound = true;
                            }
                            if (!agentClassFound)
                            {
                                classList = metaData.GetMlsMetadataClassList("User");
                                if (classList.Any())
                                {
                                    GenerateDefFile(fi.FullName, metaData, TRPTxtSelectFileTextBox.Text, "User");
                                }
                            }
                        }
                        else if (fi.Name.ToLower().EndsWith("of.sql"))
                        {
                            var classList = metaData.GetMlsMetadataClassList("ActiveOffice");
                            if (classList.Any())
                            {
                                GenerateDefFile(fi.FullName, metaData, TRPTxtSelectFileTextBox.Text, "ActiveOffice");
                            }
                            classList = metaData.GetMlsMetadataClassList("Office");
                            if (classList.Any())
                            {
                                var filePath = fi.FullName.ToLower().Replace("of.sql", "Officeof.sql");
                                File.Copy(fi.FullName, filePath);
                                GenerateDefFile(filePath, metaData, TRPTxtSelectFileTextBox.Text, "Office");
                            }
                        }
                        else if (!fi.Name.ToLower().EndsWith("oh.sql"))
                        {
                            GenerateDefFile(fi.FullName, metaData, TRPTxtSelectFileTextBox.Text, "");
                        }
                    }
                }
                if (mlsClassList.Count > 0)
                {
                    string filePath = "";
                    foreach (var item in mlsClassList)
                    {
                        foreach (var fi in di.GetFiles().Where(fi => fi.Name.ToLower().EndsWith(".def")))
                        {
                            filePath = fi.FullName;
                            break;
                        }
                    }

                    foreach (var item in mlsClassList)
                    {
                        string visibleName = metaData.GetMlsMetadataClassVisibleName(item);
                        string newFilePath = SetDefName(filePath, visibleName);
                        GenerateDefFile(newFilePath, metaData, TRPTxtSelectFileTextBox.Text, item);
                    }
                    File.Delete(filePath);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace + ex.Source);
                _stopProgressDialog = true;
            }
        }
Beispiel #2
0
        private void GenerateDefFile(string defFilePath, Model.Metadata metaData, string traceFodler,
                                     string currentClassName)
        {
            var defParser = new DefController(defFilePath, metaData,
                                              traceFodler);

            if (!string.IsNullOrEmpty(currentClassName))
            {
                defParser.DefFile.ClassName = currentClassName;
            }
            string mlsClassName = defParser.DefFile.ClassName;

            if (defFilePath.ToLower().EndsWith(".sql"))
            {
                var classList = metaData.GetMlsMetadataClassList(mlsClassName);
                if (!classList.Any())
                {
                    if (defFilePath.ToLower().EndsWith("oh.sql"))
                    {
                        classList = metaData.GetMlsMetadataClassList("OpenHouse");
                        if (!classList.Any())
                        {
                            classList = metaData.GetMlsMetadataClassList("OPEN_HOUSE");
                        }
                    }
                }

                if (classList.Any())
                {
                    mlsClassName = classList.FirstOrDefault();
                    defParser.DefFile.ClassName    = mlsClassName;
                    defParser.DefFile.ResourceName = metaData.GetResourceNameByClassName(mlsClassName);
                }
            }
            if (defFilePath.ToLower().EndsWith(".def"))
            {
                defParser.LoadTraceFile();
            }
            defParser.GenerateStandardResultField();
            if (defFilePath.ToLower().EndsWith(".def"))
            {
                defParser.UpdateAllSearchField();
            }

            defParser.GenerateSearchSections();

            if (defFilePath.ToLower().EndsWith(".def"))
            {
                defParser.GenerateNonStandardResultField();
            }
            defParser.GenerateMlsRecordExSection();
            defParser.GenerateResultFieldSections();


            if (defFilePath.ToLower().EndsWith(".def"))
            {
                defParser.GenerateCategorySections();
                defParser.GenerateSortingSection();
                defParser.GeneratePictureScriptSection();
            }
            defParser.GenerateSecListSeciton();
            defParser.SaveDefFile();
            if (defFilePath.ToLower().EndsWith(".def"))
            {
                defParser.DefFile.SetKeyValue("BoardType", metaData.GetMlsMetadataClassVisibleName(mlsClassName),
                                              "Common");
                defParser.DefFile.SetKeyValue("Tcpip", "9", "Common");
            }
            defParser.DefFile.SetKeyValue("MetaDataversion", metaData.MetaDataVersion, "Common");
            defParser.DefFile = null;
            defParser         = null;
        }