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