Пример #1
0
        private static void Main(string[] args)
        {
            string modelName = @"e:\str.vtp";

            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model = null;

            try {
                model = TechModel.Load(modelName);
            } catch (Exception) {
                MessageBox.Show("Ошибка загрузки модели!");
                AuthenticationManager.Deauthenticate();
                return;
            }

            var presenations = model.Presentations;
            var prs          = model.Presentations[0];

            if (prs != null)
            {
                var newPrsn = presenations.Add("test");
                foreach (var oldItem in  prs.Items)
                {
                    var filter = model.Filters[oldItem.Name];
                    if (filter != null)
                    {
                        for (int i = 0; i < filter.Count; ++i)
                        {
                            var childCls = filter[i];
                            var newItem  = newPrsn.Items.Add(childCls.Name);
                            newItem.Description = childCls.Name + ": " + childCls.Description;
                            childrenPrsn(oldItem, newItem);
                        }
                    }
                    else
                    {
                        var newItem = newPrsn.Items.Add(oldItem.Name);
                        newItem.Description = oldItem.Description;
                        childrenPrsn(oldItem, newItem);
                    }
                }
            }


            model.Save(modelName);
            model.Close();

            AuthenticationManager.Deauthenticate();
            MessageBox.Show("Выполнено!");
        }
Пример #2
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\attr.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            foreach (TechClass cls in model.Classes)
            {
                foreach (TechClassMember mbr in cls.Members)
                {
                    if (mbr.Type == TechClassMemberType.Property)
                    {
                        var prop         = mbr as TechClassProperty;
                        var mRestriction = prop.ValueRestrictions as TechMeasurandValueRestrictions;
                        if (mRestriction != null && mRestriction.Precision >= 0)
                        {
                            logFile.WriteLine(cls.Name + "." + prop.Name);
                            continue;
                        }
                        var dRestriction = prop.ValueRestrictions as TechDoubleValueRestrictions;
                        if (dRestriction != null && mRestriction.Precision >= 0)
                        {
                            logFile.WriteLine(cls.Name + "." + prop.Name);
                            continue;
                        }
                    }
                }
            }
            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }
Пример #3
0
        private static void Main(string[] args)
        {
            if (args.Count() < 1)
            {
                return;
            }

            string modelName = args[0];

            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model = null;

            try {
                model = TechModel.Load(modelName);
            } catch (Exception) {
                MessageBox.Show("Ошибка загрузки модели!");
                AuthenticationManager.Deauthenticate();
                return;
            }

            foreach (var cls in model.Classes)
            {
                var missingRoles = cls.Permissions.Where(
                    p => p.Key != Guid.Empty &&
                    AuthenticationManager.Roles.All(r => r.Id != p.Key)
                    ).ToList();

                foreach (var missingRole in missingRoles)
                {
                    cls.Permissions.Clear(missingRole.Key);
                }

                foreach (var member in cls.Members)
                {
                    missingRoles = member.Permissions.Where(
                        p => p.Key != Guid.Empty &&
                        AuthenticationManager.Roles.All(r => r.Id != p.Key)
                        ).ToList();
                    foreach (var missingRole in missingRoles)
                    {
                        member.Permissions.Clear(missingRole.Key);
                    }
                }
            }
            model.Save(modelName);
            model.Close();

            AuthenticationManager.Deauthenticate();
            MessageBox.Show("Выполнено!");
        }
Пример #4
0
        private static void Main(string[] args)
        {
            string markerName = "ttplock";

            if (args.Count() < 1)
            {
                return;
            }

            string modelName = args[0];

            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model = null;

            try {
                model = TechModel.Load(modelName);
            } catch (Exception) {
                MessageBox.Show("Ошибка загрузки модели!");
                AuthenticationManager.Deauthenticate();
                return;
            }

            foreach (var cls in model.Classes)
            {
                foreach (var marker in cls.Markers)
                {
                    if (marker.Key.Name == markerName)
                    {
                        MessageBox.Show(cls.Name);
                    }
                }

                foreach (var member in cls.Members)
                {
                    foreach (var marker in member.Markers)
                    {
                        if (marker.Key.Name == markerName)
                        {
                            MessageBox.Show(cls.Name + "." + member.Name);
                        }
                    }
                }
            }
            model.Close();

            AuthenticationManager.Deauthenticate();
            MessageBox.Show("Выполнено!");
        }
Пример #5
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\log.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            Regex rx = new Regex(@"^[a-z0-9_]+$");


            foreach (TechClass cls in model.Classes)
            {
                if (!rx.IsMatch(cls.Name))
                {
                    logFile.WriteLine(cls.Name);
                }
                foreach (TechClassMember mbr in cls.Members)
                {
                    if (!rx.IsMatch(mbr.Name))
                    {
                        logFile.WriteLine(cls.Name + "." + mbr.Name);
                    }
                }
            }
            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }
Пример #6
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\commentlist.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            logFile.WriteLine("СПИСОК КОММЕНТАРИЕВ:");
            logFile.WriteLine("--------------------------------------");
            foreach (TechClass cls in model.Classes)
            {
                if (cls.Description != String.Empty)
                {
                    logFile.WriteLine("    " + cls.Name + ": " + cls.Description);
                }

                foreach (TechClassMember mbr in cls.Members)
                {
                    if (mbr.Description != String.Empty)
                    {
                        logFile.WriteLine("    " + cls.Name + "." + mbr.Name + ": " + mbr.Description);
                    }
                }
            }
            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }
Пример #7
0
        public static void Main(string[] args)
        {
            var fileName = (args.Count() > 0) ? args[0] : String.Empty;

            if (File.Exists(fileName))
            {
                try {
                    AuthenticationManager.Authenticate();
                } catch (Exception) {
                    Console.Write("Ошибка авторизации!");
                    Console.Write("Нажмите любую клавишу для продолжения . . . ");
                    Console.ReadKey(true);
                    return;
                }
                Console.WriteLine("Введите имя глобальноый функции:");
                var funcName = Console.ReadLine();

                if (!String.IsNullOrEmpty(funcName))
                {
                    var model = TechModel.Load(fileName);
                    if (model != null)
                    {
                        var globalFunc = model.Functions[funcName];
                        if (globalFunc != null)
                        {
                            globalFunc.IsSystem = !globalFunc.IsSystem;
                            model.Save(fileName);
                        }
                        else
                        {
                            Console.WriteLine("Глобальная функция с указанным именем не существует");
                        }
                        model.Close();
                    }
                    else
                    {
                        Console.WriteLine("Невозможно открыть объектную модель Вертикаль");
                    }
                }
                AuthenticationManager.Deauthenticate();
            }
            else
            {
                Console.WriteLine("Указанный файл не существует");
            }

            Console.Write("Нажмите любую клавишу для продолжения . . . ");
            Console.ReadKey(true);
        }
Пример #8
0
        private static void Main(string[] args)
        {
            var fileName = (args.Count() > 0) ? args[0] : String.Empty;

            if (File.Exists(fileName))
            {
                try {
                    AuthenticationManager.Authenticate();
                } catch (Exception) {
                    Console.Write("Ошибка авторизации!");
                    Console.Write("Нажмите любую клавишу для продолжения . . . ");
                    Console.ReadKey(true);
                    return;
                }
                Console.WriteLine("Введите имя маркера:");
                var markername = Console.ReadLine();
                Console.WriteLine();
                if (markername.Count() >= 1)
                {
                    var model = TechModel.Load(fileName);
                    if (model != null)
                    {
                        var marker = model.Markers[markername];
                        if (marker != null)
                        {
                            marker.IsSystem = !marker.IsSystem;
                            model.Save(fileName);
                        }
                        else
                        {
                            Console.WriteLine("Маркер с указанным именем не существует");
                        }
                        model.Close();
                    }
                    else
                    {
                        Console.WriteLine("Невозможно открыть объектную модель Вертикаль");
                    }
                }
                AuthenticationManager.Deauthenticate();
            }
            else
            {
                Console.WriteLine("Указанный файл не существует");
            }

            Console.Write("Нажмите любую клавишу для продолжения . . . ");
            Console.ReadKey(true);
        }
Пример #9
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\tostringlist.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            logFile.WriteLine("СПИСОК ФУНКЦИЙ ToString:");
            logFile.WriteLine("--------------------------------------");
            foreach (TechClass cls in model.Classes)
            {
                if (cls.ToStringFunction.Body != String.Empty)
                {
                    logFile.WriteLine(cls.Name);
                    logFile.WriteLine("--------------------------------------");
                    logFile.WriteLine(cls.ToStringFunction.Body);
                    logFile.WriteLine("--------------------------------------");
                    logFile.WriteLine();
                }
            }
            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }
Пример #10
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\calcattr.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            logFile.WriteLine("СПИСОК ВЫЧИСЛЯЕМЫХ АТРИБУТОВ:");
            logFile.WriteLine("--------------------------------------");
            foreach (TechClass cls in model.Classes)
            {
                foreach (TechClassMember mbr in cls.Members)
                {
                    var prop = mbr as TechClassProperty;
                    if (prop != null && prop.ValueType.Id == TechMeasurandValue.ComplexValueType.Id)
                    {
                        logFile.WriteLine("    " + cls.Name + "." + mbr.Name);
                    }
                }
            }
            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }
Пример #11
0
        private static void Main(string[] args)
        {
            if (args.Count() < 2)
            {
                return;
            }

            string modelName = args[0];

            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model = null;

            try {
                model = TechModel.Load(modelName);
            } catch (Exception) {
                MessageBox.Show("Ошибка загрузки модели!");
                AuthenticationManager.Deauthenticate();
                return;
            }

            for (int i = args.Count() - 1; i > 0; --i)
            {
                try {
                    TechDocument document = TechDocument.Load(args[i], model);
                    document.Save(args[i]);
                    document.Close();
                } catch (Exception) {
                    MessageBox.Show("Ошибка загрузки документа!");
                    continue;
                }
            }
            model.Close();

            AuthenticationManager.Deauthenticate();
            MessageBox.Show("Выполнено!");
        }
Пример #12
0
		private static void Main(string[] args)
		{
			if (args.Count() < 2)
				return;
				
			string modelName    = args[0];		
			string currentClass = args[1];			
			string baseClass = (args.Count() < 3) ? "" : args[2];
			
			try {
				AuthenticationManager.Authenticate();
			} catch(Exception) {
				MessageBox.Show("Ошибка авторизации!");		
				return;
			}
			
			TechModel model = null;
			try {
				model	 = TechModel.Load(modelName);
			} catch(Exception) {
				MessageBox.Show("Ошибка загрузки модели!");		
				AuthenticationManager.Deauthenticate();
				return;
			}
						
						
			if (baseClass != String.Empty)
				model.Classes[currentClass].BaseClass = model.Classes[baseClass];
			else
				model.Classes[currentClass].BaseClass = null;
			
			model.Save(modelName);
			model.Close();
			
			AuthenticationManager.Deauthenticate();
			MessageBox.Show("Выполнено!");				
		}
Пример #13
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
                System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\attr.txt");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\attrlist.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            logFile.WriteLine("СПИСОК АТРИБУТОВ СО СПИСКАМИ ЗНАЧЕНИЙ:");
            logFile.WriteLine("--------------------------------------");
            foreach (TechClass cls in model.Classes)
            {
                foreach (TechClassMember mbr in cls.Members)
                {
                    if (mbr.Type != TechClassMemberType.Function)
                    {
                        var attr = mbr as TechClassAttribute;

                        var doubleRestr = attr.ValueRestrictions as TechDoubleValueRestrictions;
                        if (doubleRestr != null && doubleRestr.Type == TechValueRestrictionType.List)
                        {
                            logFile.WriteLine("    " + cls.Name + "." + attr.Name);
                        }

                        var intRestr = attr.ValueRestrictions as TechIntegerValueRestrictions;
                        if (intRestr != null && intRestr.Type == TechValueRestrictionType.List)
                        {
                            logFile.WriteLine("    " + cls.Name + "." + attr.Name);
                        }

                        var measRestr = attr.ValueRestrictions as TechMeasurandValueRestrictions;
                        if (measRestr != null && measRestr.Type == TechValueRestrictionType.List)
                        {
                            logFile.WriteLine("    " + cls.Name + "." + attr.Name);
                        }

                        var strRestr = attr.ValueRestrictions as TechStringValueRestrictions;
                        if (strRestr != null && strRestr.Type == TechValueRestrictionType.List)
                        {
                            logFile.WriteLine("    " + cls.Name + "." + attr.Name);
                        }
                    }
                }
            }
            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }
Пример #14
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
                System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\attr.txt");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\attr.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            int count = 0;

            foreach (TechClass cls in model.Classes)
            {
                foreach (TechClassMember mbr in cls.Members)
                {
                    if (mbr.Type == TechClassMemberType.Property)
                    {
                        var prop = mbr as TechClassProperty;

                        var  getter      = model.VBSFunctions[model.VBSFunctions.GetPropertyGetterName(prop)];
                        bool isBadGetter = !String.IsNullOrEmpty(getter) &&
                                           !Regex.IsMatch(getter, "function\\s+" + prop.Name + "_get\\s*\\(", RegexOptions.IgnoreCase);

                        if (isBadGetter)
                        {
                            logFile.WriteLine(cls.Name + "." + prop.Name + " (Геттер)");

                            Regex rx = new Regex("function\\s+([a-zA-Z0-9_-]*)\\s*\\(",
                                                 RegexOptions.Compiled | RegexOptions.IgnoreCase);
                            Match matche = rx.Match(getter);
                            var   func   = matche.Groups[1].Captures[0].ToString();

                            Regex rgx = new Regex("function\\s+" + func + "\\s*\\(");
                            getter = rgx.Replace(getter, "function " + prop.Name + "_get(");

                            Regex rgy = new Regex(func + "\\s*=");
                            getter = rgy.Replace(getter, prop.Name + "_get =");

                            logFile.WriteLine(func);
                            logFile.WriteLine(getter);
                        }

                        var  setter      = model.VBSFunctions[model.VBSFunctions.GetPropertySetterName(prop)];
                        bool isBadSetter = !String.IsNullOrEmpty(setter) &&
                                           !Regex.IsMatch(setter, "function\\s+" + prop.Name + "_set\\s*\\(", RegexOptions.IgnoreCase);

                        if (isBadSetter)
                        {
                            logFile.WriteLine(cls.Name + "." + prop.Name + " (Сеттер)");

                            Regex rx = new Regex("function\\s+([a-zA-Z0-9_-]*)\\s*\\(",
                                                 RegexOptions.Compiled | RegexOptions.IgnoreCase);

                            Match matche = rx.Match(setter);
                            var   func   = matche.Groups[1].Captures[0].ToString();

                            Regex rgx = new Regex("function\\s+" + func + "\\s*\\(");
                            getter = rgx.Replace(setter, "function " + prop.Name + "_set(");

                            Regex rgy = new Regex(func + "\\s*=");
                            getter = rgy.Replace(setter, prop.Name + "_set =");

                            logFile.WriteLine(func);
                            logFile.WriteLine(setter);
                        }

                        if (isBadGetter || isBadSetter)
                        {
                            ++count;
                            logFile.WriteLine();
                        }
                    }
                }
            }
            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.WriteLine("ИТОГО АТРИБУТОВ: " + count);
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }
Пример #15
0
        private static void Main(string[] args)
        {
            string modelName = @"d:\str.vtp";
            string str       = "sub_material";

            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model = null;

            try {
                model = TechModel.Load(modelName);
            } catch (Exception) {
                MessageBox.Show("Ошибка загрузки модели!");
                AuthenticationManager.Deauthenticate();
                return;
            }

            var presenations = model.Presentations;

            foreach (var prs in presenations)
            {
                foreach (var item in prs.Items)
                {
                    bool ret    = false;
                    var  filter = model.Filters[item.Name];
                    if (filter != null)
                    {
                        for (int i = 0; i < filter.Count; ++i)
                        {
                            var childCls = filter[i];
                            if (str == childCls.Name)
                            {
                                ret = true;
                                break;
                            }
                        }
                    }
                    else if (str == item.Name)
                    {
                        ret = true;
                    }

                    if (!ret)
                    {
                        ret = childrenPrsn(item, str);
                    }

                    if (ret)
                    {
                        MessageBox.Show("Найден класс в дереве:\n    " + prs.DisplayName);
                        break;
                    }
                }
            }
            model.Close();

            AuthenticationManager.Deauthenticate();
            MessageBox.Show("Выполнено!");
        }
Пример #16
0
        private static void Main(string[] args)
        {
            string markerName = "isObsolete";

            if (args.Count() < 1)
            {
                return;
            }

            string modelName = args[0];

            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model = null;

            try {
                model = TechModel.Load(modelName);
            } catch (Exception) {
                MessageBox.Show("Ошибка загрузки модели!");
                AuthenticationManager.Deauthenticate();
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\commentlist.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            foreach (var cls in model.Classes)
            {
                foreach (var marker in cls.Markers)
                {
                    if (marker.Key.Name == markerName)
                    {
                        logFile.WriteLine("    " + cls.Name + ": " + cls.Markers.Get(markerName).ToString());
                    }
                }

                foreach (var member in cls.Members)
                {
                    foreach (var marker in member.Markers)
                    {
                        if (marker.Key.Name == markerName)
                        {
                            logFile.WriteLine("  " + cls.Name + "." + member.Name + ": " + member.Markers.Get(markerName).ToString());
                        }
                    }
                }
            }
            model.Close();
            logFile.Close();

            AuthenticationManager.Deauthenticate();
            MessageBox.Show("Выполнено!");
        }
Пример #17
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\namelist.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            foreach (TechClass cls in model.Classes)
            {
                if (cls.DisplayName != String.Empty)
                {
                    logFile.WriteLine("    " + cls.Name + "(Экранное имя): " + cls.DisplayName);
                }
                if (cls.Description != String.Empty)
                {
                    logFile.WriteLine("    " + cls.Name + "(Комментарий): " + cls.Description);
                }
                foreach (var group in cls.Appearance.AttributesGroups)
                {
                    if (group.Name != String.Empty)
                    {
                        logFile.WriteLine("    " + cls.Name + "(Группа): " + group.Name);
                    }
                }

                foreach (TechClassMember mbr in cls.Members)
                {
                    if (mbr.Description != String.Empty)
                    {
                        logFile.WriteLine("    " + cls.Name + "." + mbr.Name + "(Экранное имя): " + mbr.DisplayName);
                    }
                    if (mbr.Description != String.Empty)
                    {
                        logFile.WriteLine("    " + cls.Name + "." + mbr.Name + "(Комментарий): " + mbr.Description);
                    }
                }
            }

            foreach (var flt in model.Filters)
            {
                if (flt.DisplayName != String.Empty)
                {
                    logFile.WriteLine("    " + flt.Name + "(Экранное имя): " + flt.DisplayName);
                }
                if (flt.Description != String.Empty)
                {
                    logFile.WriteLine("    " + flt.Name + "(Комментарий): " + flt.Description);
                }
            }

            foreach (var func in model.Functions)
            {
                if (func.DisplayName != String.Empty)
                {
                    logFile.WriteLine("    " + func.Name + "(Экранное имя): " + func.DisplayName);
                }
                if (func.Description != String.Empty)
                {
                    logFile.WriteLine("    " + func.Name + "(Комментарий): " + func.Description);
                }
            }

            foreach (var num in model.Numerators)
            {
                if (num.DisplayName != String.Empty)
                {
                    logFile.WriteLine("    " + num.Name + "(Экранное имя): " + num.DisplayName);
                }
                if (num.Description != String.Empty)
                {
                    logFile.WriteLine("    " + num.Name + "(Комментарий): " + num.Description);
                }
            }

            foreach (var marker in model.Markers)
            {
                if (marker.DisplayName != String.Empty)
                {
                    logFile.WriteLine("    " + marker.Name + "(Экранное имя): " + marker.DisplayName);
                }
                if (marker.Description != String.Empty)
                {
                    logFile.WriteLine("    " + marker.Name + "(Комментарий): " + marker.Description);
                }
            }

            foreach (var tree in model.Presentations)
            {
                if (tree.DisplayName != String.Empty)
                {
                    logFile.WriteLine("    " + tree.Name + "(Экранное имя): " + tree.DisplayName);
                }
                if (tree.Description != String.Empty)
                {
                    logFile.WriteLine("    " + tree.Name + "(Комментарий): " + tree.Description);
                }
            }

            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }
Пример #18
0
        public static void Main(string[] args)
        {
            var fileName = (args.Count() > 0) ? args[0] : String.Empty;

            if (File.Exists(fileName))
            {
                try {
                    AuthenticationManager.Authenticate();
                } catch (Exception) {
                    Console.Write("Ошибка авторизации!");
                    Console.Write("Нажмите любую клавишу для продолжения . . . ");
                    Console.ReadKey(true);
                    return;
                }
                Console.WriteLine("Введите имя класса, атрибута или функции в формате\n<Имя класс>.<Имя атрибута или функции>:");
                var item = Console.ReadLine();
                Console.WriteLine();
                var items = item.Split('.');

                if (items.Count() >= 1)
                {
                    var model = TechModel.Load(fileName);
                    if (model != null)
                    {
                        String    className = items[0];
                        TechClass cls       = model.Classes[className];
                        if (cls != null)
                        {
                            if (items.Count() >= 2)
                            {
                                String          attrName = items[1];
                                TechClassMember mbr      = cls.Members[attrName];
                                if (mbr != null)
                                {
                                    mbr.IsSystem = !mbr.IsSystem;
                                    model.Save(fileName);
                                }
                                else
                                {
                                    Console.WriteLine("Атрибут или функция с указанным именем не существует");
                                }
                            }
                            else
                            {
                                cls.IsSystem = !cls.IsSystem;
                                model.Save(fileName);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Класс с указанным именем не существует");
                        }
                        model.Close();
                    }
                    else
                    {
                        Console.WriteLine("Невозможно открыть объектную модель Вертикаль");
                    }
                }
                AuthenticationManager.Deauthenticate();
            }
            else
            {
                Console.WriteLine("Указанный файл не существует");
            }

            Console.Write("Нажмите любую клавишу для продолжения . . . ");
            Console.ReadKey(true);
        }
Пример #19
0
        private static void Main(string[] args)
        {
            try {
                AuthenticationManager.Authenticate();
            } catch (Exception) {
                MessageBox.Show("Ошибка авторизации!");
                return;
            }

            TechModel model;

            try {
                model = TechModel.Load("d:\\structure.vtp");
            } catch (Exception) {
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка загрузки модели!");
                return;
            }

            System.IO.StreamWriter logFile;
            try {
                logFile = new System.IO.StreamWriter(@"D:\log.txt");
            } catch (Exception) {
                model.Close();
                AuthenticationManager.Deauthenticate();
                MessageBox.Show("Ошибка создания файла!");
                return;
            }

            int count = 0;

            foreach (TechClass cls in model.Classes)
            {
                foreach (TechClassMember mbr in cls.Members)
                {
                    var prop = mbr as TechClassProperty;
                    if (prop != null)
                    {
                        var getter = model.VBSFunctions[model.VBSFunctions.GetPropertyGetterName(prop)];
                        var setter = model.VBSFunctions[model.VBSFunctions.GetPropertySetterName(prop)];
                        if (getter != String.Empty || setter != String.Empty)
                        {
                            logFile.WriteLine(cls.Name + "." + mbr.Name);
                            logFile.WriteLine("-----------------------------------------------------------");
                            logFile.WriteLine(getter);
                            logFile.WriteLine(setter);
                        }
                    }

                    var func = mbr as TechClassFunction;
                    if (func != null)
                    {
                        var body = model.VBSFunctions[model.VBSFunctions.GetFunctionName(func)];
                        if (body != String.Empty)
                        {
                            logFile.WriteLine(cls.Name + "." + mbr.Name);
                            logFile.WriteLine("-----------------------------------------------------------");
                            logFile.WriteLine(body);
                        }
                    }
                }
            }
            model.Close();
            AuthenticationManager.Deauthenticate();
            logFile.Close();
            MessageBox.Show("Выполнено!");
        }