public void UpdateProjectNestedGroup() { var properties = new Dictionary <string, string> { { "Version", "2.0.0.0" }, { "Description", "Nested Version" } }; var projectPath = @"samples\NestedGroup.xml"; var updater = new ProjectUpdater(); updater.Properties = properties; updater.Logger = Output.WriteLine; updater.UpdateProject(projectPath); }
public void UpdateProjectSampleLibrary() { var properties = new Dictionary <string, string> { { "Version", "2.0.0.0" }, { "Copyright", "Copyright 2018 LoreSoft" } }; var projectPath = @"samples\SampleLibrary.xml"; var updater = new ProjectUpdater(); updater.Properties = properties; updater.Logger = Output.WriteLine; updater.UpdateProject(projectPath); }
public bool Register(Document doc, ProjectUpdater pUpdater) { bool registered = false; try { if (!UpdaterRegistry.IsUpdaterRegistered(updaterId, doc)) { UpdaterRegistry.RegisterUpdater(this, doc); LogUtil.AppendLog("Revision Updater Registered."); registered = true; } } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("DoorUpdater-Register:" + ex.Message); } return(registered); }
/// <summary> /// /// </summary> /// <param name="doc"></param> /// <param name="pUpdater"></param> /// <returns></returns> public bool Register(Document doc, ProjectUpdater pUpdater) { var registered = false; try { if (!UpdaterRegistry.IsUpdaterRegistered(updaterId, doc)) { UpdaterRegistry.RegisterUpdater(this, doc); RefreshTriggers(doc, pUpdater); Log.AppendLog(LogMessageType.INFO, "Door Updater Registered."); registered = true; } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } return(registered); }
/// <summary> /// Appelé après la création d'un nouveau fichier. /// </summary> /// <param name="fileName">Nom du fichier.</param> protected override void FinishFile(string fileName) { /* Ajoute le fichier dans TFS */ base.FinishFile(fileName); if (string.IsNullOrEmpty(_csprojFileName)) { return; } /* Chemin relatif au csproj */ string localFileName = ProjectFileUtils.GetProjectRelativeFileName(fileName, _csprojFileName); /* Met à jour le fichier csproj. */ ProjectUpdater .Create(TfsManager.Client) .AddItem(_csprojFileName, new ProjectItem { ItemPath = localFileName, BuildAction = BuildActions.Compile }); }
public void AddProjectReadSide_Id_Test() { var newGuid = Guid.NewGuid(); var name = "TName2"; var options = new DbContextOptionsBuilder <ModelContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; var projectContext = Mock.Of <ConsumeContext <IProjectAdded> >(x => x.Message.Id == newGuid && x.Message.Name == name); using (IModelUpdater context = new ModelContext(options)) { var projectUpdater = new ProjectUpdater(context); Task.Run(() => projectUpdater.Consume(projectContext)).Wait(); } using (IModelReader context = new ModelContext(options)) { Assert.AreEqual("ProjectModel-" + newGuid.ToString(), context.Projects.Single(x => x.AggregateId == newGuid).Id); } }
public SingleObjectModel CompleteActivity(string projectUID, string activityUID, [FromBody] object body) { try { base.RequireBody(body); var bodyAsJson = JsonObject.Parse(body); var project = Project.Parse(projectUID); Activity activity = project.GetActivity(activityUID); DateTime completedDate = bodyAsJson.Get <DateTime>("actualEndDate", DateTime.Today); activity.Update(bodyAsJson); ProjectUpdater.Complete(activity, completedDate); return(new SingleObjectModel(this.Request, activity.ToResponse())); } catch (Exception e) { throw base.CreateHttpException(e); } }
private void buttonRequest_Click(object sender, RoutedEventArgs e) { try { //update configuration if (AppCommand.Instance.Configurations.ContainsKey(reportingInfo.DocId.ToString())) { var updaterFound = from updater in AppCommand.Instance.Configurations[reportingInfo.DocId.ToString()].ProjectUpdaters where updater.UpdaterId == DTMUpdater.updaterGuid.ToString() select updater; if (updaterFound.Count() > 0) { ProjectUpdater updater = updaterFound.First(); int updaterIndex = AppCommand.Instance.Configurations[reportingInfo.DocId.ToString()].ProjectUpdaters.IndexOf(updater); var triggerFound = from trigger in updater.CategoryTriggers where trigger._id == reportingInfo.TriggerId select trigger; if (triggerFound.Count() > 0) { CategoryTrigger trigger = triggerFound.First(); int triggerIndex = AppCommand.Instance.Configurations[reportingInfo.DocId.ToString()].ProjectUpdaters[updaterIndex].CategoryTriggers.IndexOf(trigger); RequestQueue queue = new RequestQueue(Guid.NewGuid().ToString(), trigger._id, RequestState.Requested.ToString(), Environment.UserName, reportingInfo.ReportingUniqueId); AppCommand.Instance.Configurations[reportingInfo.DocId.ToString()].ProjectUpdaters[updaterIndex].CategoryTriggers[triggerIndex].Requests.Add(queue); string content = ""; string errMsg = ""; HttpStatusCode status = ServerUtil.PostRequestQueues(out content, out errMsg, queue); } } } this.Close(); } catch (Exception ex) { string message = ex.Message; MessageBox.Show("Failed to ignore warning window.\n" + ex.Message, "Warning Window", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public static bool CancelOpening(string centralFile, Configuration config) { bool cancel = false; try { if (singleSessionActivated && openedDocuments.Count > 0) { return(true); } var updaterFound = from updater in config.updaters where updater.updaterId.ToLower() == updaterGuid.ToString().ToLower() select updater; if (updaterFound.Count() > 0) { ProjectUpdater ssUpdater = updaterFound.First(); if (ssUpdater.isUpdaterOn) { if (openedDocuments.Count > 0) { cancel = true; } else { //first opening single file that will activate the single session singleFile = centralFile; singleSessionActivated = true; } } } } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("CancelOpening:" + ex.Message); } return(cancel); }
public void AddProjectReadSide_Test() { var newGuid = Guid.NewGuid(); //string connectionString = ConfigurationManager.ConnectionStrings["LocalDbReadStore"].ConnectionString; var options = new DbContextOptionsBuilder <ModelContext>() //.UseSqlServer(connectionString) .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; var projectContext = Mock.Of <ConsumeContext <IProjectAdded> >(x => x.Message.Id == newGuid && x.Message.Name == "TName1"); using (IModelUpdater context = new ModelContext(options)) { var projectUpdater = new ProjectUpdater(context); Task.Run(() => projectUpdater.Consume(projectContext)).Wait(); } using (IModelReader context = new ModelContext(options)) { Assert.AreEqual(1, context.Projects.Where(x => x.AggregateId == newGuid).Count()); } }
public void CollectingPackagesFromExistingSources_Reads_AllSourcesProperly() { var projectUpdater = new ProjectUpdater(@"C:\dev\viessmann", @"C:\dev\viessmann\contrib", @"C:\Program Files (x86)\Configit Quote 11.0\Services\Configit.Quote.Web\bin"); projectUpdater.Consolidate(); }
private DTMConfigurations GetConfiguration(Document doc) { DTMConfigurations config = new DTMConfigurations(); try { string projectFileId = DataStorageUtil.GetProjectFileId(doc).ToString(); string centralPath = FileInfoUtil.GetCentralFilePath(doc); if (projectFileId == Guid.Empty.ToString()) { //first time use List <ProjectFile> items = ServerUtil.GetProjectFiles("centralpath/" + centralPath); if (items.Count > 0) { //import file info by central path ProjectFile projectFile = items.First(); bool found = ServerUtil.GetConfiguration(projectFile._id, out config); projectFileId = projectFile._id; } else { //create file info projectFileId = Guid.NewGuid().ToString(); Project projectInfo = FileInfoUtil.GetProjectInfo(centralPath); List <Project> projects = ServerUtil.GetProjects(""); var projectFound = from p in projects where p.ProjectNumber == projectInfo.ProjectNumber && p.ProjectName == projectInfo.ProjectName select p; if (projectFound.Count() > 0) { projectInfo = projectFound.First(); } else { projectInfo._id = Guid.NewGuid().ToString(); } ProjectFile pFile = new ProjectFile(projectFileId, centralPath, projectInfo._id, projectInfo); config.ProjectFileInfo = pFile; ProjectUpdater pUpdater = new ProjectUpdater(Guid.NewGuid().ToString(), DTMUpdater.updaterGuid.ToString(), dtmUpdater.GetUpdaterName(), addInGuid.ToString(), addInName, false, pFile._id); foreach (string categoryName in updaterCategories) { CategoryTrigger catTrigger = new CategoryTrigger(Guid.NewGuid().ToString(), categoryName, pUpdater._id, false, Environment.UserName, DateTime.Now); pUpdater.CategoryTriggers.Add(catTrigger); } config.ProjectUpdaters.Add(pUpdater); string content = ""; string errMsg = ""; HttpStatusCode status = ServerUtil.PostConfiguration(out content, out errMsg, config); } bool stored = DataStorageUtil.StoreProjectFileId(doc, new Guid(projectFileId)); } else { bool found = ServerUtil.GetConfiguration(projectFileId, out config); } } catch (Exception ex) { string message = ex.Message; MessageBox.Show("Failed to get configuration.\n" + ex.Message, "Get Configuration from Database", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(config); }
/// <summary> /// /// </summary> /// <param name="doc"></param> /// <param name="pUpdater"></param> public void RefreshTriggers(Document doc, ProjectUpdater pUpdater) { try { var centralPath = FileInfoUtil.GetCentralFilePath(doc); var configId = ""; if (MissionControlSetup.Configurations.ContainsKey(centralPath)) { configId = MissionControlSetup.Configurations[centralPath].Id; } UpdaterRegistry.RemoveDocumentTriggers(_updaterId, doc); var elementsToDelete = _reportingElements.Where(x => x.CentralPath == centralPath).ToList(); if (elementsToDelete.Any()) { foreach (var eInfo in elementsToDelete) { _reportingElements.Remove(eInfo); } } foreach (var trigger in pUpdater.CategoryTriggers) { if (!trigger.IsEnabled) { continue; } var catFilter = new ElementCategoryFilter(_catDictionary[trigger.CategoryName]); UpdaterRegistry.AddTrigger(_updaterId, catFilter, Element.GetChangeTypeAny()); UpdaterRegistry.AddTrigger(_updaterId, catFilter, Element.GetChangeTypeElementAddition()); UpdaterRegistry.AddTrigger(_updaterId, catFilter, Element.GetChangeTypeElementDeletion()); switch (trigger.CategoryName) { case "Grids": { GridUtils.CollectGridExtents(doc, centralPath); if (GridUtils.gridParameters.ContainsKey(centralPath)) { foreach (var paramId in GridUtils.gridParameters[centralPath]) { UpdaterRegistry.AddTrigger(_updaterId, catFilter, Element.GetChangeTypeParameter(paramId)); } } var elements = new FilteredElementCollector(doc) .WherePasses(catFilter) .WhereElementIsNotElementType() .ToElements(); foreach (var element in elements) { var reportingInfo = new ReportingElementInfo( configId, UpdaterGuid.ToString(), centralPath, trigger.CategoryName, trigger.Description, element.Id, element.UniqueId); _reportingElements.Add(reportingInfo); } } break; case "Views": { var viewTemplates = new FilteredElementCollector(doc) .WherePasses(catFilter) .WhereElementIsNotElementType() .Cast <View>() .Where(x => x.IsTemplate) .ToList(); if (viewTemplates.Any()) { foreach (var view in viewTemplates) { var reportingInfo = new ReportingElementInfo( configId, UpdaterGuid.ToString(), centralPath, trigger.CategoryName, trigger.Description, view.Id, view.UniqueId); _reportingElements.Add(reportingInfo); } } } break; default: { var elements = new FilteredElementCollector(doc) .WherePasses(catFilter) .WhereElementIsNotElementType() .ToElements(); foreach (var element in elements) { var reportingInfo = new ReportingElementInfo( configId, UpdaterGuid.ToString(), centralPath, trigger.CategoryName, trigger.Description, element.Id, element.UniqueId); _reportingElements.Add(reportingInfo); } } break; } } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } }
void DoUpdate() { ProjectUpdater.Update(_project, _update); }
internal void RefreshTriggers(Document doc, ProjectUpdater pUpdater) { try { Guid docId = DataStorageUtil.GetProjectFileId(doc); UpdaterRegistry.RemoveDocumentTriggers(updaterId, doc); var elementsToDelete = from eInfo in reportingElements where eInfo.DocId == docId select eInfo; if (elementsToDelete.Count() > 0) { List <ReportingElementInfo> elementsInfo = elementsToDelete.ToList(); foreach (ReportingElementInfo eInfo in elementsInfo) { reportingElements.Remove(eInfo); } } foreach (CategoryTrigger trigger in pUpdater.CategoryTriggers) { if (trigger.IsEnabled) { ElementCategoryFilter catFilter = new ElementCategoryFilter(catDictionary[trigger.CategoryName]); UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeAny()); if (trigger.CategoryName == "Grids") { GridUtils.CollectGridExtents(doc, docId); if (GridUtils.gridParameters.ContainsKey(docId)) { foreach (ElementId paramId in GridUtils.gridParameters[docId]) { UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeParameter(paramId)); } } FilteredElementCollector collector = new FilteredElementCollector(doc); List <Element> elements = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().ToList(); foreach (Element element in elements) { ReportingElementInfo reportingInfo = new ReportingElementInfo(docId, trigger._id, trigger.CategoryName, element.Id, element.UniqueId); reportingElements.Add(reportingInfo); } } else if (trigger.CategoryName == "Views") { FilteredElementCollector collector = new FilteredElementCollector(doc); List <View> views = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().Cast <View>().ToList(); var viewTemplates = from view in views where view.IsTemplate select view; if (viewTemplates.Count() > 0) { foreach (Element view in viewTemplates) { ReportingElementInfo reportingInfo = new ReportingElementInfo(docId, trigger._id, trigger.CategoryName, view.Id, view.UniqueId); reportingElements.Add(reportingInfo); } } } else { FilteredElementCollector collector = new FilteredElementCollector(doc); List <Element> elements = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().ToList(); foreach (Element element in elements) { ReportingElementInfo reportingInfo = new ReportingElementInfo(docId, trigger._id, trigger.CategoryName, element.Id, element.UniqueId); reportingElements.Add(reportingInfo); } } } } if (registeredUpdaters.ContainsKey(docId)) { registeredUpdaters.Remove(docId); } registeredUpdaters.Add(docId, pUpdater); } catch (Exception ex) { string message = ex.Message; MessageBox.Show("Failed to refresh triggers\n" + ex.Message, "DTM Updater", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void buttonEdit_Click(object sender, RoutedEventArgs e) { try { //update category trigger settings bool settingsUpdated = false; string centralPath = reportingInfo.CentralPath; if (AppCommand.Instance.ConfigDictionary.ContainsKey(centralPath)) { Configuration config = AppCommand.Instance.ConfigDictionary[centralPath]; var updaterFound = from updater in config.updaters where updater.updaterId.ToLower() == reportingInfo.UpdaterId.ToLower() select updater; if (updaterFound.Count() > 0) { ProjectUpdater pUpdater = updaterFound.First(); int updaterIndex = config.updaters.IndexOf(pUpdater); var triggerFound = from trigger in pUpdater.CategoryTriggers where trigger.categoryName == reportingInfo.CategoryName select trigger; if (triggerFound.Count() > 0) { CategoryTrigger cTrigger = triggerFound.First(); int triggerIndex = pUpdater.CategoryTriggers.IndexOf(cTrigger); config.updaters[updaterIndex].CategoryTriggers[triggerIndex].isEnabled = false; AppCommand.Instance.ConfigDictionary.Remove(centralPath); AppCommand.Instance.ConfigDictionary.Add(centralPath, config); //refresh category trigger AppCommand.Instance.DTMUpdaterInstance.Unregister(currentDoc); AppCommand.Instance.DTMUpdaterInstance.Register(currentDoc, config.updaters[updaterIndex]); settingsUpdated = true; } } } if (settingsUpdated) { //database updated TriggerRecord record = new TriggerRecord() { configId = reportingInfo.ConfigId, centralPath = reportingInfo.CentralPath, updaterId = reportingInfo.UpdaterId, categoryName = reportingInfo.CategoryName, elementUniqueId = reportingInfo.ReportingUniqueId, edited = DateTime.Now, editedBy = Environment.UserName }; string content; string errMessage; HttpStatusCode status = ServerUtil.PostTriggerRecords(out content, out errMessage, record); this.DialogResult = false; } this.Close(); } catch (Exception ex) { LogUtil.AppendLog("DTMWindow-buttonEdit_Click:" + ex.Message); } }
public static HttpStatusCode UpdateProjectUpdater(out string content, out string errorMessage, ProjectUpdater updater, string id) { HttpStatusCode status = HttpStatusCode.Unused; content = ""; errorMessage = ""; try { var client = new RestClient(RestApiBaseUrl); var request = new RestRequest(apiVersion + "/" + ControllerType.projectupdaters.ToString() + "/" + id, Method.PUT); request.RequestFormat = RestSharp.DataFormat.Json; request.AddBody(updater); IRestResponse response = client.Execute(request); content = response.Content; errorMessage = response.ErrorMessage; status = response.StatusCode; } catch (Exception ex) { string message = ex.Message; MessageBox.Show("Failed to update items in projectupdaters:id=" + id + "\n" + ex.Message, "Server Util: Update Project Updater", MessageBoxButton.OK, MessageBoxImage.Warning); } return(status); }
public void RefreshTriggers(Document doc, ProjectUpdater pUpdater) { try { string centralPath = FileInfoUtil.GetCentralFilePath(doc); string configId = ""; if (AppCommand.Instance.ConfigDictionary.ContainsKey(centralPath)) { configId = AppCommand.Instance.ConfigDictionary[centralPath]._id; } UpdaterRegistry.RemoveDocumentTriggers(updaterId, doc); var elementsToDelete = from eInfo in reportingElements where eInfo.CentralPath == centralPath select eInfo; if (elementsToDelete.Count() > 0) { List <ReportingElementInfo> elementsInfo = elementsToDelete.ToList(); foreach (ReportingElementInfo eInfo in elementsInfo) { reportingElements.Remove(eInfo); } } foreach (CategoryTrigger trigger in pUpdater.CategoryTriggers) { if (trigger.isEnabled) { ElementCategoryFilter catFilter = new ElementCategoryFilter(catDictionary[trigger.categoryName]); UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeAny()); UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeElementAddition()); UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeElementDeletion()); if (trigger.categoryName == "Grids") { GridUtils.CollectGridExtents(doc, centralPath); if (GridUtils.gridParameters.ContainsKey(centralPath)) { foreach (ElementId paramId in GridUtils.gridParameters[centralPath]) { UpdaterRegistry.AddTrigger(updaterId, catFilter, Element.GetChangeTypeParameter(paramId)); } } FilteredElementCollector collector = new FilteredElementCollector(doc); List <Element> elements = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().ToList(); foreach (Element element in elements) { ReportingElementInfo reportingInfo = new ReportingElementInfo(configId, updaterGuid.ToString(), centralPath, trigger.categoryName, trigger.description, element.Id, element.UniqueId); reportingElements.Add(reportingInfo); } } else if (trigger.categoryName == "Views") { FilteredElementCollector collector = new FilteredElementCollector(doc); List <View> views = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().Cast <View>().ToList(); var viewTemplates = from view in views where view.IsTemplate select view; if (viewTemplates.Count() > 0) { foreach (Element view in viewTemplates) { ReportingElementInfo reportingInfo = new ReportingElementInfo(configId, updaterGuid.ToString(), centralPath, trigger.categoryName, trigger.description, view.Id, view.UniqueId); reportingElements.Add(reportingInfo); } } } else { FilteredElementCollector collector = new FilteredElementCollector(doc); List <Element> elements = collector.WherePasses(catFilter).WhereElementIsNotElementType().ToElements().ToList(); foreach (Element element in elements) { ReportingElementInfo reportingInfo = new ReportingElementInfo(configId, updaterGuid.ToString(), centralPath, trigger.categoryName, trigger.description, element.Id, element.UniqueId); reportingElements.Add(reportingInfo); } } } } } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("DTMUpdater-RefreshTriggers:" + ex.Message); } }