Example #1
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("Выполнено!");
        }
Example #2
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("Выполнено!");
        }
Example #3
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("Выполнено!");				
		}