public void Setup() { BasilProject.InitializeForTests(); _FilePath = Path.GetTempFileName(); _lexEntryRepository = new LexEntryRepository(_FilePath); _outputPath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); _writingSystemIds = new List<string>(new string[] {"red", "green", "blue"}); _headwordWritingSystem = new WritingSystem(_writingSystemIds[0], new Font(FontFamily.GenericSansSerif, 10)); _viewTemplate = new ViewTemplate(); _viewTemplate.Add(new Field(LexEntry.WellKnownProperties.Citation, "LexEntry", new string[] {"blue", "red"})); _viewTemplate.Add(new Field(LexEntry.WellKnownProperties.LexicalUnit, "LexEntry", new string[] {"red", "green", "blue"})); _viewTemplate.Add(new Field(LexEntry.WellKnownProperties.BaseForm, "LexEntry", _writingSystemIds)); Field visibleCustom = new Field("VisibleCustom", "LexEntry", _writingSystemIds, Field.MultiplicityType.ZeroOr1, "MultiText"); visibleCustom.Visibility = CommonEnumerations.VisibilitySetting.Visible; visibleCustom.DisplayName = "VisibleCustom"; _viewTemplate.Add(visibleCustom); }
public PLiftExporter(string path, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate): base(path) { this._lexEntryRepository = lexEntryRepository; this._viewTemplate = viewTemplate; }
public void Setup() { _tempFolder = new TemporaryFolder(); _wordListFilePath = _tempFolder.GetTemporaryFile(); _filePath = _tempFolder.GetTemporaryFile(); //Db4oLexModelHelper.InitializeForNonDbTests(); WeSayWordsProject.InitializeForTests(); _lexEntryRepository = new LexEntryRepository(_filePath); // InMemoryRecordListManager(); _glossingLanguageWSId = BasilProject.Project.WritingSystems.TestWritingSystemAnalId; _vernacularLanguageWSId = BasilProject.Project.WritingSystems.TestWritingSystemVernId; File.WriteAllLines(_wordListFilePath, _words); _viewTemplate = new ViewTemplate(); _viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", new string[] { BasilProject.Project.WritingSystems. TestWritingSystemVernId })); _task = new GatherWordListTask( GatherWordListConfig.CreateForTests( _wordListFilePath,_glossingLanguageWSId), _lexEntryRepository, _viewTemplate); }
public PLiftExporter(StringBuilder builder, bool produceFragmentOnly, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate): base(builder, produceFragmentOnly) { this._lexEntryRepository = lexEntryRepository; this._viewTemplate = viewTemplate; }
public GatherBySemanticDomainTask(IGatherBySemanticDomainsConfig config, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : base( config, lexEntryRepository, viewTemplate) { if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrEmpty(config.semanticDomainsQuestionFileName)) { throw new ArgumentNullException("config.semanticDomainsQuestionFileName"); } if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } _currentDomainIndex = -1; _currentQuestionIndex = 0; _words = null; _semanticDomainQuestionsFileName = DetermineActualQuestionsFileName(config.semanticDomainsQuestionFileName); if (!File.Exists(_semanticDomainQuestionsFileName)) { string pathInProject = Path.Combine( WeSayWordsProject.Project.PathToWeSaySpecificFilesDirectoryInProject, _semanticDomainQuestionsFileName); if (File.Exists(pathInProject)) { _semanticDomainQuestionsFileName = pathInProject; } else { string pathInProgramDir = Path.Combine(BasilProject.ApplicationCommonDirectory, _semanticDomainQuestionsFileName); if (!File.Exists(pathInProgramDir)) { throw new ApplicationException( string.Format( "Could not find the semanticDomainQuestions file {0}. Expected to find it at: {1} or {2}. The name of the file is influenced by the first enabled writing system for the Semantic Domain Field.", _semanticDomainQuestionsFileName, pathInProject, pathInProgramDir)); } _semanticDomainQuestionsFileName = pathInProgramDir; } } _semanticDomainField = viewTemplate.GetField("SemanticDomainDdp4"); }
public DictionaryTask(DictionaryBrowseAndEditConfiguration config, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : base(config, lexEntryRepository) { if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } _viewTemplate = viewTemplate; // _userSettings = userSettings; }
public MissingInfoTask(MissingInfoConfiguration config, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : base( config, lexEntryRepository) { if (config.MissingInfoField == null) { throw new ArgumentNullException("MissingInfoField"); } if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } _missingInfoField = viewTemplate[config.MissingInfoField]; _viewTemplate = CreateViewTemplateFromListOfFields(viewTemplate, config.FieldsToShow); MarkReadOnlyFields(config.FieldsToShowReadOnly); //hack until we overhaul how Tasks are setup: _isBaseFormFillingTask = config.FieldsToShow.Contains(LexEntry.WellKnownProperties.BaseForm); if (_isBaseFormFillingTask) { Field flagField = new Field(); flagField.DisplayName = StringCatalog.Get("~This word has no Base Form", "The user will click this to say that this word has no baseform. E.g. Kindess has Kind as a baseform, but Kind has no other word as a baseform."); flagField.DataTypeName = "Flag"; flagField.ClassName = "LexEntry"; flagField.FieldName = "flag_skip_" + config.MissingInfoField; flagField.Enabled = true; _viewTemplate.Add(flagField); } _writingSystem = BasilProject.Project.WritingSystems.UnknownVernacularWritingSystem; // use the master view Template instead of the one for this task. (most likely the one for this // task doesn't have the EntryLexicalForm field specified but the Master (Default) one will Field fieldDefn = WeSayWordsProject.Project.DefaultViewTemplate.GetField( Field.FieldNames.EntryLexicalForm.ToString()); if (fieldDefn != null) { if (fieldDefn.WritingSystemIds.Count > 0) { _writingSystem = BasilProject.Project.WritingSystems[fieldDefn.WritingSystemIds[0]]; } else { throw new ConfigurationException("There are no writing systems enabled for the Field '{0}'", fieldDefn.FieldName); } } }
public void Setup() { WeSayWordsProject.Project.RemoveCache(); _tempFolder = new TemporaryFolder(); _filePath = _tempFolder.GetTemporaryFile(); _semanticDomainFilePath = _tempFolder.GetTemporaryFile(); CreateSemanticDomainFile(); _lexEntryRepository = new LexEntryRepository(_filePath); _viewTemplate = MakeViewTemplate("en"); _task = new GatherBySemanticDomainTask(_semanticDomainFilePath, _lexEntryRepository, _viewTemplate); }
public void SetUp() { WeSayWordsProject.InitializeForTests(); _tempFolder = new TemporaryFolder(); _filePath = _tempFolder.GetTemporaryFile(); _lexEntryRepository = new LexEntryRepository(_filePath); #if GlossMeaning _primaryMeaningFieldName = Field.FieldNames.SenseGloss.ToString(); #else _primaryMeaningFieldName = LexSense.WellKnownProperties.Definition; #endif string[] analysisWritingSystemIds = new string[] { BasilProject.Project.WritingSystems. TestWritingSystemAnalId }; string[] vernacularWritingSystemIds = new string[] { BasilProject.Project.WritingSystems. TestWritingSystemVernId }; RtfRenderer.HeadWordWritingSystemId = vernacularWritingSystemIds[0]; _viewTemplate = new ViewTemplate(); _viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", vernacularWritingSystemIds)); _viewTemplate.Add(new Field(_primaryMeaningFieldName, "LexSense", analysisWritingSystemIds)); _viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(), "LexExampleSentence", vernacularWritingSystemIds)); _viewTemplate.Add(new Field(Field.FieldNames.ExampleTranslation.ToString(), "LexExampleSentence", analysisWritingSystemIds)); empty = CreateTestEntry("", "", ""); apple = CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away."); banana = CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas."); car = CreateTestEntry("car", "small motorized vehicle", "Watch out for cars when you cross the street."); bike = CreateTestEntry("bike", "vehicle with two wheels", "He rides his bike to school."); }
public SampleTaskBuilder(WeSayWordsProject project, ICurrentWorkTask currentWorkTask, IRecordListManager recordListManager) { _picoContext = CreateContainer(); _picoContext.RegisterComponentInstance("Project", project); _picoContext.RegisterComponentInstance("Current Task Provider", currentWorkTask); _picoContext.RegisterComponentInstance("Record List Manager", recordListManager); string[] analysisWritingSystemIds = new string[] { project.WritingSystems.AnalysisWritingSystemDefaultId }; string[] vernacularWritingSystemIds = new string[] {project.WritingSystems.VernacularWritingSystemDefaultId}; ViewTemplate viewTemplate = new ViewTemplate(); viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), vernacularWritingSystemIds)); viewTemplate.Add(new Field(Field.FieldNames.SenseGloss .ToString(), analysisWritingSystemIds)); viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(), vernacularWritingSystemIds)); viewTemplate.Add(new Field(Field.FieldNames.ExampleTranslation.ToString(), analysisWritingSystemIds)); _picoContext.RegisterComponentInstance("Default Field Inventory", viewTemplate); }
private void Make(ViewTemplate template, string path) { PLiftExporter exporter = new PLiftExporter(path, _lexEntryRepository, template); ResultSet<LexEntry> allEntriesSortedByHeadword = this._lexEntryRepository.GetAllEntriesSortedByHeadword( this._headwordWritingSystem); foreach (RecordToken<LexEntry> token in allEntriesSortedByHeadword) { int homographNumber = 0; if ((bool) token["HasHomograph"]) { homographNumber = (int) token["HomographNumber"]; } exporter.Add(token.RealObject, homographNumber); } exporter.End(); }
private static ViewTemplate MakeViewTemplate(string nameAndQuestionWritingSystem) { Field semanticDomainField = new Field(LexSense.WellKnownProperties.SemanticDomainsDdp4, "LexSense", new string[] {nameAndQuestionWritingSystem}); semanticDomainField.OptionsListFile = "Ddp4.xml"; semanticDomainField.DataTypeName = "OptionRefCollection"; ViewTemplate v = new ViewTemplate(); Field lexicalFormField = new Field(Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", new string[] {"br"}); lexicalFormField.DataTypeName = "MultiText"; v.Add(lexicalFormField); v.Add(semanticDomainField); return v; }
public void SetUp() { WeSayWordsProject.InitializeForTests(); _tempFolder = new TemporaryFolder(); _filePath = _tempFolder.GetTemporaryFile(); _lexEntryRepository = new LexEntryRepository(_filePath); _writingSystem = new WritingSystem("pretendVernacular", new Font(FontFamily.GenericSansSerif, 24)); CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away."); CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas."); CreateTestEntry("car", "small motorized vehicle", "Watch out for cars when you cross the street."); CreateTestEntry("dog", "animal with four legs; man's best friend", "He walked his dog."); string[] analysisWritingSystemIds = new string[] {"analysis"}; string[] vernacularWritingSystemIds = new string[] {_writingSystem.Id}; RtfRenderer.HeadWordWritingSystemId = vernacularWritingSystemIds[0]; _viewTemplate = new ViewTemplate(); _viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", vernacularWritingSystemIds)); _viewTemplate.Add(new Field(LexSense.WellKnownProperties.Definition, "LexSense", analysisWritingSystemIds)); _viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(), "LexExampleSentence", vernacularWritingSystemIds)); Field exampleTranslationField = new Field( Field.FieldNames.ExampleTranslation.ToString(), "LexExampleSentence", analysisWritingSystemIds); _viewTemplate.Add(exampleTranslationField); _missingTranslationRecordList = _lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit( exampleTranslationField, _writingSystem); }
//private string MakePLiftTempFile(IEnumerable<LexEntry> entries, ViewTemplate template, IFindEntries finder) //{ // string path = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); // LiftExporter exporter = new LiftExporter(path); // exporter.SetUpForPresentationLiftExport(template, finder); // foreach (LexEntry entry in entries) // { // exporter.Add(entry); // } // exporter.End(); // return path; //} public string MakePLiftTempFile(LexEntryRepository lexEntryRepository, ViewTemplate template) { string path = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); PLiftExporter exporter = new PLiftExporter(path, lexEntryRepository, template); ResultSet<LexEntry> recordTokens = lexEntryRepository.GetAllEntriesSortedByHeadword(template.HeadwordWritingSystem); foreach (RecordToken<LexEntry> token in recordTokens) { int homographNumber = 0; if ((bool) token["HasHomograph"]) { homographNumber = (int) token["HomographNumber"]; } exporter.Add(token.RealObject, homographNumber); } exporter.End(); return path; }
public DictionaryControl(LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) { if (lexEntryRepository == null) { throw new ArgumentNullException("lexEntryRepository"); } if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } _viewTemplate = viewTemplate; _lexEntryRepository = lexEntryRepository; _cmWritingSystems = new ContextMenu(); SetupPickerControlWritingSystems(); InitializeComponent(); InitializeDisplaySettings(); _writingSystemChooser.Image = Resources.Expand.GetThumbnailImage(6, 6, ReturnFalse, IntPtr.Zero); _btnFind.Image = Resources.Find.GetThumbnailImage(18, 18, ReturnFalse, IntPtr.Zero); _btnDeleteWord.Image = Resources.DeleteWord; _btnNewWord.Image = Resources.NewWord.GetThumbnailImage(18, 18, ReturnFalse, IntPtr.Zero); Control_EntryDetailPanel.ViewTemplate = _viewTemplate; Control_EntryDetailPanel.LexEntryRepository = _lexEntryRepository; _findTextAdapter = new ResultSetToListOfStringsAdapter("Form", _records); _findText.Items = _findTextAdapter; SetListWritingSystem( _viewTemplate.GetDefaultWritingSystemForField( Field.FieldNames.EntryLexicalForm.ToString())); _findText.KeyDown += _findText_KeyDown; _recordsListBox.SelectedIndexChanged += OnRecordSelectionChanged; UpdateDisplay(); }
public void Setup() { _tempFolder = new TemporaryFolder(); _filePath = _tempFolder.GetTemporaryFile(); WeSayWordsProject.InitializeForTests(); string[] vernacularWritingSystemIds = new string[] { BasilProject.Project.WritingSystems. TestWritingSystemVernId }; _viewTemplate = new ViewTemplate(); _viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", vernacularWritingSystemIds)); _viewTemplate.Add(new Field("Note", "LexEntry", new string[] {"en"}, Field.MultiplicityType.ZeroOr1, "MultiText")); _lexEntryRepository = new LexEntryRepository(_filePath); _task = new DictionaryTask( DictionaryBrowseAndEditConfiguration.CreateForTests(), _lexEntryRepository, _viewTemplate);//, new UserSettingsForTask()); }
// private bool _suspendNotificationOfNavigation=false; public GatherWordListTask(IGatherWordListConfig config, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : base(config, lexEntryRepository, viewTemplate) { if (config.WordListFileName == null) { throw new ArgumentNullException("wordListFileName"); } if (config.WordListWritingSystemId == null) { throw new ArgumentNullException("wordListWritingSystemId"); } if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } Field lexicalFormField = viewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString()); if (lexicalFormField == null || lexicalFormField.WritingSystemIds.Count < 1) { _lexicalUnitWritingSystem = BasilProject.Project.WritingSystems.UnknownVernacularWritingSystem; } else { string firstWSid = lexicalFormField.WritingSystemIds[0]; WritingSystem firstWS = BasilProject.Project.WritingSystems[firstWSid]; _lexicalUnitWritingSystem = firstWS; } _wordListFileName = config.WordListFileName; _words = null; _writingSystemIdForWordListWords = config.WordListWritingSystemId; }
protected WordGatheringTaskBase(ITaskConfiguration config, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : base( config, lexEntryRepository) { if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } _viewTemplate = viewTemplate; Field lexicalFormField = viewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString()); WritingSystemCollection writingSystems = BasilProject.Project.WritingSystems; if (lexicalFormField == null || lexicalFormField.WritingSystemIds.Count < 1) { _lexicalFormWritingSystem = writingSystems.UnknownVernacularWritingSystem; } else { _lexicalFormWritingSystem = writingSystems[lexicalFormField.WritingSystemIds[0]]; } }
public LexExampleSentenceLayouter(DetailList builder, ViewTemplate viewTemplate) : base(builder, viewTemplate, null) {}
public FLExCompatibleXhtmlWriter(bool linkToUserCss, ViewTemplate viewTemplate) { _linkToUserCss = linkToUserCss; _viewTemplate = viewTemplate; Grouper = new MultigraphParser(new string[] {}); //property needs to be set by the client to get anything interesting }
public MissingInfoControl(ResultSet<LexEntry> records, ViewTemplate viewTemplate, Predicate<LexEntry> isNotComplete, LexEntryRepository lexEntryRepository) { if (!DesignMode) { if (records == null) { throw new ArgumentNullException("records"); } if (viewTemplate == null) { throw new ArgumentNullException("viewTemplate"); } if (isNotComplete == null) { throw new ArgumentNullException("isNotComplete"); } if (lexEntryRepository == null) { throw new ArgumentNullException("lexEntryRepository"); } } InitializeComponent(); PreviewKeyDown += OnPreviewKeyDown; _btnNextWord.ReallySetSize(50, 50); // _btnPreviousWord.ReallySetSize(30, 30); if (DesignMode) { return; } _completedRecords = new BindingList<RecordToken<LexEntry>>(); _todoRecords = (BindingList<RecordToken<LexEntry>>) records; _viewTemplate = viewTemplate; _isNotComplete = isNotComplete; InitializeDisplaySettings(); _entryViewControl.KeyDown += OnKeyDown; _entryViewControl.ViewTemplate = _viewTemplate; _entryViewControl.LexEntryRepository = lexEntryRepository; _recordsListBox.DataSource = _todoRecords; // _records.ListChanged += OnRecordsListChanged; // this needs to be after so it will get change event after the ListBox WritingSystem listWritingSystem = GetListWritingSystem(); _recordsListBox.BorderStyle = BorderStyle.None; _recordsListBox.SelectedIndexChanged += OnRecordSelectionChanged; _recordsListBox.Enter += _recordsListBox_Enter; _recordsListBox.Leave += _recordsListBox_Leave; _recordsListBox.RetrieveVirtualItem += OnRetrieveVirtualItemEvent; _recordsListBox.WritingSystem = listWritingSystem; _completedRecordsListBox.DataSource = _completedRecords; _completedRecordsListBox.BorderStyle = BorderStyle.None; _completedRecordsListBox.SelectedIndexChanged += OnCompletedRecordSelectionChanged; _completedRecordsListBox.Enter += _completedRecordsListBox_Enter; _completedRecordsListBox.Leave += _completedRecordsListBox_Leave; _completedRecordsListBox.WritingSystem = listWritingSystem; _completedRecordsListBox.RetrieveVirtualItem += OnRetrieveVirtualItemEvent; labelNextHotKey.BringToFront(); _btnNextWord.BringToFront(); _btnPreviousWord.BringToFront(); SetCurrentRecordFromRecordList(); }
private static void SortLift(string outputPath, LexEntryRepository lexEntryRepository, ViewTemplate template) { using (var exporter = new LiftWriter(outputPath, LiftWriter.ByteOrderStyle.NoBOM)) { IWritingSystemDefinition firstWs = template.HeadwordWritingSystems[0]; ResultSet <LexEntry> recordTokens = lexEntryRepository.GetAllEntriesSortedByHeadword(firstWs); int index = 0; foreach (RecordToken <LexEntry> token in recordTokens) { int homographNumber = 0; if ((bool)token["HasHomograph"]) { homographNumber = (int)token["HomographNumber"]; } LexEntry lexEntry = token.RealObject; EmbeddedXmlCollection sortedAnnotation = new EmbeddedXmlCollection(); sortedAnnotation.Values.Add("<annotation name='sorted-index' value='" + (++index) + "'/>"); lexEntry.Properties.Add(new KeyValuePair <string, IPalasoDataObjectProperty>("SortedIndex", sortedAnnotation)); exporter.Add(lexEntry, homographNumber); } exporter.End(); } }
public static void Inizialize(ISession Session) { #region Customer Inizialize Customer WallStreetDaily = new Customer { Id = 1, Name = "Wall Street Daily" }; Customer FleetStreetPublication = new Customer { Id = 2, Name = "Fleet Street Publication" }; Customer DailyEdge = new Customer { Id = 3, Name = "Daily Edge" }; Customer HeidiShubert = new Customer { Id = 6, Name = "Heidi Shubert" }; Customer WeissResearch = new Customer { Id = 4, Name = "Weiss Research" }; Customer WSD = new Customer { Id = 5, Name = "WSD Custom Strategy" }; Session.Save(DailyEdge); Session.Save(HeidiShubert); Session.Save(WallStreetDaily); Session.Save(WeissResearch); Session.Save(WSD); Session.Save(FleetStreetPublication); #endregion #region Portfolios Inizialize Portfolio portfolio1 = new Portfolio { Id = 1, Name = "Strategic Investment Open Portfolio", Notes = "A portfolio is a grouping of financial assets such as stocks,", DisplayIndex = 1, LastUpdateDate = new DateTime(2017, 4, 28), Visibility = false, Quantity = 2, PercentWins = 73.23m, BiggestWinner = 234.32m, BiggestLoser = 12.65m, AvgGain = 186.65m, MonthAvgGain = 99.436m, PortfolioValue = 1532.42m, Customer = WallStreetDaily }; Portfolio portfolio2 = new Portfolio { Id = 2, Name = "Strategic Investment Income Portfolio", Notes = "A portfolio is a grouping of financial assets such as stocks,", DisplayIndex = 2, LastUpdateDate = new DateTime(2017, 3, 12), Visibility = true, Quantity = 3, PercentWins = 93.23m, BiggestWinner = 534.32m, BiggestLoser = 123.46m, AvgGain = 316.65m, MonthAvgGain = 341.436m, PortfolioValue = 5532.42m, Customer = WallStreetDaily //Positions = new List<Position> { position3, position4, position5 } }; Portfolio portfolio3 = new Portfolio { Id = 3, Name = "HDFC Bank", DisplayIndex = 4, LastUpdateDate = new DateTime(2017, 3, 12), Visibility = true, Quantity = 3, PercentWins = 93.23m, BiggestWinner = 534.32m, BiggestLoser = 123.46m, AvgGain = 316.65m, MonthAvgGain = 341.436m, PortfolioValue = 5532.42m, Customer = WallStreetDaily }; Portfolio portfolio4 = new Portfolio { Id = 4, Name = "IndusInd Bank", DisplayIndex = 5, LastUpdateDate = new DateTime(2017, 3, 12), Visibility = true, Quantity = 3, PercentWins = 93.23m, BiggestWinner = 534.32m, BiggestLoser = 123.46m, AvgGain = 316.65m, MonthAvgGain = 341.436m, PortfolioValue = 5532.42m, Customer = FleetStreetPublication }; Portfolio portfolio5 = new Portfolio { Id = 5, Name = "UltraTechCement", DisplayIndex = 3, LastUpdateDate = new DateTime(2017, 3, 12), Visibility = true, Quantity = 3, PercentWins = 93.23m, BiggestWinner = 534.32m, BiggestLoser = 123.46m, AvgGain = 316.65m, MonthAvgGain = 341.436m, PortfolioValue = 5532.42m, Customer = FleetStreetPublication }; Session.Save(portfolio1); Session.Save(portfolio2); Session.Save(portfolio3); Session.Save(portfolio4); Session.Save(portfolio5); #endregion #region Positions Inizialize Position position1 = new Position { Id = 1, SymbolId = 3, SymbolType = Symbols.Option, SymbolName = "PLSE", Name = "Pulse Biosciences CS", OpenDate = new DateTime(2015, 7, 20), OpenPrice = 128.32m, OpenWeight = 40, TradeType = TradeTypes.Long, TradeStatus = TradeStatuses.Open, Dividends = 57.3m, CurrentPrice = 99.53m, Gain = 87.12m, AbsoluteGain = 110.34m, MaxGain = 154.34m, LastUpdateDate = new DateTime(2016, 1, 1), LastUpdatePrice = 218.32m, Portfolio = portfolio1 }; Position position2 = new Position { Id = 2, SymbolId = 2, SymbolType = Symbols.Stock, SymbolName = "WIWTY", Name = "Witwatersrand Gold Rsrcs Ltd ", OpenDate = new DateTime(2009, 2, 24), OpenPrice = 4.00m, OpenWeight = 125, TradeType = TradeTypes.Long, TradeStatus = TradeStatuses.Open, Dividends = 0.00m, CurrentPrice = 3.64m, Gain = 40.0m, AbsoluteGain = 1.60m, MaxGain = 1.60m, LastUpdateDate = new DateTime(2016, 1, 1), LastUpdatePrice = 218.32m, Portfolio = portfolio1 }; Position position3 = new Position { Id = 3, SymbolId = 1, SymbolType = Symbols.Option, SymbolName = "AAT", Name = "AAT Corporation Limited", OpenDate = new DateTime(2017, 4, 28), OpenPrice = 43.20m, OpenWeight = 113, TradeType = TradeTypes.Long, TradeStatus = TradeStatuses.Wait, Dividends = 17.34m, CloseDate = new DateTime(2017, 5, 2), ClosePrice = 54.24m, Gain = 11.56m, AbsoluteGain = 9.45m, MaxGain = 14.34m, LastUpdateDate = new DateTime(2016, 5, 1), LastUpdatePrice = 53.32m, Portfolio = portfolio2 }; Position position4 = new Position { Id = 4, SymbolId = 4, SymbolType = Symbols.Stock, SymbolName = "FXI", Name = "iShares FTSE/XINHUA 25", OpenDate = new DateTime(2009, 8, 28), OpenPrice = 39.81m, OpenWeight = 65, TradeType = TradeTypes.Long, TradeStatus = TradeStatuses.Close, Dividends = 1.54m, CloseDate = new DateTime(2012, 1, 12), ClosePrice = 36.74m, Gain = 3.84m, AbsoluteGain = 3.65m, MaxGain = 3.65m, LastUpdateDate = new DateTime(2011, 10, 11), LastUpdatePrice = 53.32m, Portfolio = portfolio2 }; Position position5 = new Position { Id = 1, SymbolId = 3, SymbolType = Symbols.Option, SymbolName = "DBA", Name = "Powershares DB Agri Index", OpenDate = new DateTime(2009, 10, 30), OpenPrice = 25.57m, OpenWeight = 72, TradeType = TradeTypes.Short, TradeStatus = TradeStatuses.Open, Dividends = 0.00m, CloseDate = new DateTime(2012, 1, 12), ClosePrice = 29.25m, CurrentPrice = 12.56m, Gain = 14.39m, AbsoluteGain = 11.34m, MaxGain = 13.34m, Portfolio = portfolio2 }; var position10 = (Position)position1.Clone(); var position11 = (Position)position1.Clone(); var position12 = (Position)position1.Clone(); var position13 = (Position)position1.Clone(); var position14 = (Position)position1.Clone(); var position15 = (Position)position1.Clone(); var position16 = (Position)position1.Clone(); var position17 = (Position)position1.Clone(); var position18 = (Position)position1.Clone(); var position19 = (Position)position1.Clone(); var position21 = (Position)position2.Clone(); var position20 = (Position)position2.Clone(); var position22 = (Position)position2.Clone(); var position23 = (Position)position2.Clone(); var position24 = (Position)position2.Clone(); var position25 = (Position)position2.Clone(); var position26 = (Position)position2.Clone(); var position27 = (Position)position2.Clone(); var position28 = (Position)position2.Clone(); var position29 = (Position)position2.Clone(); Session.Save(position1); Session.Save(position10); Session.Save(position11); Session.Save(position12); Session.Save(position13); Session.Save(position14); Session.Save(position15); Session.Save(position16); Session.Save(position17); Session.Save(position18); Session.Save(position19); Session.Save(position20); Session.Save(position21); Session.Save(position22); Session.Save(position23); Session.Save(position24); Session.Save(position25); Session.Save(position26); Session.Save(position27); Session.Save(position28); Session.Save(position29); Session.Save(position2); Session.Save(position3); Session.Save(position4); Session.Save(position5); #endregion #region ColumnFormat Inizialize ColumnFormat None = new ColumnFormat { Id = 1, Name = "None" }; ColumnFormat Money = new ColumnFormat { Id = 2, Name = "Money" }; ColumnFormat Linked = new ColumnFormat { Id = 3, Name = "Linked" }; ColumnFormat Date = new ColumnFormat { Id = 4, Name = "Date" }; ColumnFormat DateAndTime = new ColumnFormat { Id = 6, Name = "DateAndTime" }; ColumnFormat Percent = new ColumnFormat { Id = 7, Name = "Percent" }; Session.Save(None); Session.Save(Money); Session.Save(Linked); Session.Save(Date); Session.Save(DateAndTime); Session.Save(Percent); #endregion #region Formats Inizialize Format DateFormat = new Format { Id = 1, Name = "Date Format", ColumnFormats = new List <ColumnFormat> { Date, Linked, DateAndTime } }; Format MoneyFormat = new Format { Id = 2, Name = "Money Format", ColumnFormats = new List <ColumnFormat> { None, Money, Linked } }; Format PercentFormat = new Format { Id = 3, Name = "Percent Format", ColumnFormats = new List <ColumnFormat> { None, Percent } }; Format NoneFormat = new Format { Id = 4, Name = "None Format", ColumnFormats = new List <ColumnFormat> { None } }; Format LineFormat = new Format { Id = 5, Name = "Line Format", ColumnFormats = new List <ColumnFormat> { None, Linked } }; Session.Save(DateFormat); Session.Save(MoneyFormat); Session.Save(PercentFormat); Session.Save(NoneFormat); Session.Save(LineFormat); #endregion #region ViewTemplate Inizialize ViewTemplate viewTemplate1 = new ViewTemplate { Id = 1, Name = "Preview all", Positions = TemplatePositions.All, ShowPortfolioStats = true, SortOrder = Sorting.ASC, Customer = WallStreetDaily, //Columns = new List<ViewTemplateColumn> //{ // viewTemplateColumn1, viewTemplateColumn2, viewTemplateColumn3, viewTemplateColumn4, // viewTemplateColumn5, viewTemplateColumn6, viewTemplateColumn6, viewTemplateColumn7, // viewTemplateColumn8, viewTemplateColumn9, viewTemplateColumn10, viewTemplateColumn11, // viewTemplateColumn12, viewTemplateColumn13, viewTemplateColumn13, viewTemplateColumn14, // viewTemplateColumn15, viewTemplateColumn16 //} }; ViewTemplate viewTemplate2 = new ViewTemplate { Id = 2, Name = "Default", Positions = TemplatePositions.OpenOnly, ShowPortfolioStats = false, SortOrder = Sorting.DESC, Customer = WallStreetDaily, //Columns = new List<ViewTemplateColumn> //{viewTemplateColumn21} }; Session.Save(viewTemplate1); Session.Save(viewTemplate2); #endregion #region Columns Inizialize Column Name = new Column { Id = 1, Name = "Name", Format = LineFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn1, viewTemplateColumn21 } }; Column SymbolName = new Column { Id = 2, Name = "Symbol Name", Format = LineFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn2 } }; Column OpenPrice = new Column { Id = 3, Name = "Open Price", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn3 } }; Column OpenDate = new Column { Id = 4, Name = "Open Date", Format = DateFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn4 } }; Column OpenWeight = new Column { Id = 5, Name = "Open Weight", Format = NoneFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn5 } }; Column CurrentPrice = new Column { Id = 6, Name = "Current Price", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn6 } }; Column ClosePrice = new Column { Id = 7, Name = "Close Price", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn7 } }; Column CloseDate = new Column { Id = 8, Name = "Close Date", Format = DateFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn8 } }; Column TradeType = new Column { Id = 9, Name = "Trade Type", Format = NoneFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn9 } }; Column TradeStatus = new Column { Id = 10, Name = "Trade Status", Format = NoneFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn10 } }; Column Dividends = new Column { Id = 11, Name = "Dividends", Format = MoneyFormat, // ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn11 } }; Column Gain = new Column { Id = 12, Name = "Gain", Format = MoneyFormat, // ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn12 } }; Column AbsoluteGain = new Column { Id = 13, Name = "Absolute Gain", Format = PercentFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn13 } }; Column MaxGain = new Column { Id = 14, Name = "Max Gain", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn14 } }; Column LastUpdateDate = new Column { Id = 15, Name = "Last Update Date", Format = DateFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn15 } }; Column LastUpdatePrice = new Column { Id = 16, Name = "Last Update Price", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn16 } }; Session.Save(Name); Session.Save(SymbolName); Session.Save(OpenPrice); Session.Save(OpenDate); Session.Save(OpenWeight); Session.Save(CurrentPrice); Session.Save(ClosePrice); Session.Save(CloseDate); Session.Save(TradeType); Session.Save(TradeStatus); Session.Save(Dividends); Session.Save(Gain); Session.Save(AbsoluteGain); Session.Save(MaxGain); Session.Save(LastUpdateDate); Session.Save(LastUpdatePrice); #endregion #region ViewTemplateColumns Inizialize ViewTemplateColumn viewTemplateColumn1 = new ViewTemplateColumn { Id = 1, Name = "Name", ColumnEntiy = Name, ViewTemplateId = 1, DisplayIndex = 1, ColumnFormat = Linked, ColumnId = 1, ColumnFormatId = 3, ViewTemplate = viewTemplate1, //ViewTemplatesForSorting = new List<ViewTemplate> { viewTemplate1 } }; ViewTemplateColumn viewTemplateColumn2 = new ViewTemplateColumn { Id = 2, Name = "Symbol", ColumnEntiy = SymbolName, ViewTemplateId = 1, DisplayIndex = 2, ColumnFormat = None, ColumnId = 2, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn3 = new ViewTemplateColumn { Id = 4, Name = "Open Price", ColumnEntiy = OpenPrice, ViewTemplateId = 1, DisplayIndex = 4, ColumnFormat = Money, ColumnId = 3, ColumnFormatId = 2, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn4 = new ViewTemplateColumn { Id = 5, Name = "Open Date", ColumnEntiy = OpenDate, ViewTemplateId = 1, DisplayIndex = 5, ColumnFormat = Date, ColumnId = 4, ColumnFormatId = 4, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn5 = new ViewTemplateColumn { Id = 3, Name = "Weight", ColumnEntiy = OpenWeight, ViewTemplateId = 1, DisplayIndex = 3, ColumnFormat = None, ColumnId = 5, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn6 = new ViewTemplateColumn { Id = 6, Name = "Current Price", ColumnEntiy = CurrentPrice, ViewTemplateId = 1, DisplayIndex = 6, ColumnFormat = Linked, ColumnId = 6, ColumnFormatId = 3, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn7 = new ViewTemplateColumn { Id = 7, Name = "Close Price", ColumnEntiy = ClosePrice, ViewTemplateId = 1, DisplayIndex = 7, ColumnFormat = None, ColumnId = 7, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn8 = new ViewTemplateColumn { Id = 8, Name = "Close Date", ColumnEntiy = CloseDate, ViewTemplateId = 1, DisplayIndex = 8, ColumnFormat = DateAndTime, ColumnId = 8, ColumnFormatId = 6, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn9 = new ViewTemplateColumn { Id = 9, Name = "Trade Type", ColumnEntiy = TradeType, ViewTemplateId = 1, DisplayIndex = 9, ColumnFormat = None, ColumnId = 9, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn10 = new ViewTemplateColumn { Id = 10, Name = "Trade Status", ColumnEntiy = TradeStatus, ViewTemplateId = 1, DisplayIndex = 10, ColumnFormat = None, ColumnId = 10, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn11 = new ViewTemplateColumn { Id = 11, Name = "Dividends", ColumnEntiy = Dividends, ViewTemplateId = 1, DisplayIndex = 11, ColumnFormat = Money, ColumnId = 11, ColumnFormatId = 2, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn12 = new ViewTemplateColumn { Id = 12, Name = "Absolute Gain", ColumnEntiy = AbsoluteGain, ViewTemplateId = 1, DisplayIndex = 12, ColumnFormat = Percent, ColumnId = 13, ColumnFormatId = 7, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn13 = new ViewTemplateColumn { Id = 13, Name = "Max Gain", ColumnEntiy = MaxGain, ViewTemplateId = 1, DisplayIndex = 13, ColumnFormat = Money, ColumnId = 14, ColumnFormatId = 2, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn14 = new ViewTemplateColumn { Id = 14, Name = "Gain", ColumnEntiy = Gain, ViewTemplateId = 1, DisplayIndex = 14, ColumnFormat = Linked, ColumnId = 12, ColumnFormatId = 3, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn15 = new ViewTemplateColumn { Id = 15, Name = "Last Update Date", ColumnEntiy = LastUpdateDate, ViewTemplateId = 1, DisplayIndex = 15, ColumnFormat = DateAndTime, ColumnId = 15, ColumnFormatId = 6, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn16 = new ViewTemplateColumn { Id = 16, Name = "Last Update Price", ColumnEntiy = LastUpdatePrice, ViewTemplateId = 1, DisplayIndex = 16, ColumnFormat = Linked, ColumnId = 16, ColumnFormatId = 2, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn21 = new ViewTemplateColumn { Id = 17, Name = "Name", ColumnEntiy = Name, ViewTemplateId = 2, DisplayIndex = 1, ColumnFormat = None, ColumnId = 1, ColumnFormatId = 1, ViewTemplate = viewTemplate2, //ViewTemplatesForSorting = new List<ViewTemplate> { viewTemplate2 } }; Session.Save(viewTemplateColumn1); Session.Save(viewTemplateColumn2); Session.Save(viewTemplateColumn3); Session.Save(viewTemplateColumn4); Session.Save(viewTemplateColumn5); Session.Save(viewTemplateColumn6); Session.Save(viewTemplateColumn1); Session.Save(viewTemplateColumn7); Session.Save(viewTemplateColumn8); Session.Save(viewTemplateColumn9); Session.Save(viewTemplateColumn10); Session.Save(viewTemplateColumn11); Session.Save(viewTemplateColumn12); Session.Save(viewTemplateColumn13); Session.Save(viewTemplateColumn14); Session.Save(viewTemplateColumn15); Session.Save(viewTemplateColumn16); Session.Save(viewTemplateColumn21); #endregion //viewTemplate1.Columns.Add(viewTemplateColumn1); //viewTemplate1.Columns.Add(viewTemplateColumn2); //viewTemplate1.Columns.Add(viewTemplateColumn3); //viewTemplate1.Columns.Add(viewTemplateColumn4); //viewTemplate1.Columns.Add(viewTemplateColumn5); //viewTemplate1.Columns.Add(viewTemplateColumn6); //viewTemplate1.Columns.Add(viewTemplateColumn7); //viewTemplate1.Columns.Add(viewTemplateColumn8); //viewTemplate1.Columns.Add(viewTemplateColumn9); //viewTemplate1.Columns.Add(viewTemplateColumn10); //viewTemplate1.Columns.Add(viewTemplateColumn11); //viewTemplate1.Columns.Add(viewTemplateColumn12); //viewTemplate1.Columns.Add(viewTemplateColumn13); //viewTemplate1.Columns.Add(viewTemplateColumn14); //viewTemplate1.Columns.Add(viewTemplateColumn15); //viewTemplate1.Columns.Add(viewTemplateColumn16); //viewTemplate2.Columns.Add(viewTemplateColumn21); Session.Flush(); #region View Inizialize ViewForTable previewAllView = new ViewForTable { Id = 1, Name = "Preview All View", ShowName = true, DateFormat = DateFormats.MonthDayYear, MoneyPrecision = 2, PercentyPrecision = 4, ViewTemplate = viewTemplate1, Customer = WallStreetDaily }; ViewForTable defaultView = new ViewForTable { Id = 2, Name = "Default View", ShowName = false, DateFormat = DateFormats.DayMonthNameYear, MoneyPrecision = 1, PercentyPrecision = 2, ViewTemplate = viewTemplate2, Customer = WallStreetDaily }; Session.Save(previewAllView); Session.Save(defaultView); #endregion #region User Inizialize var userManager = new ApplicationUserManager(new UserStore <UserEntity>(Session)); var roleManager = new ApplicationRoleManager(new RoleStore <Role>(Session)); List <Role> identityRoles = new List <Role> { new Role() { Name = "Admin" }, new Role() { Name = "User" }, new Role() { Name = "Employee" } }; foreach (Role role in identityRoles) { roleManager.Create(role); } UserEntity admin = new UserEntity { Email = "Admin", UserName = "******" }; userManager.Create(admin, "Password"); userManager.AddToRole(admin.Id, "Admin"); userManager.AddToRole(admin.Id, "Employee"); var clientProfile = new Profile { Id = admin.Id, Login = admin.UserName, Customer = WallStreetDaily, CustomerId = WallStreetDaily.Id }; WallStreetDaily.Profiles.Add(clientProfile); #endregion #region Records Inizialize Record record1 = new Record { UserId = "1aaa023d-e950-47fc-9c3f-54fbffcc99cf", Entity = Entities.Position, Operation = Operations.Create, Successfully = true, EntityId = 1, DateTime = new DateTime(2017, 4, 1) }; Record record2 = new Record { UserId = "1aaa023d-e950-47fc-9c3f-54fbffcc99cf", Entity = Entities.Position, Operation = Operations.Delete, Successfully = false, EntityId = 1, DateTime = new DateTime(2017, 4, 3) }; Record record3 = new Record { UserId = "2da9e5e9-ee3e-473c-a131-c39050b26760", Entity = Entities.Portfolio, Operation = Operations.Update, Successfully = true, EntityId = 2, DateTime = new DateTime(2017, 4, 4) }; Session.Save(record1); Session.Save(record2); Session.Save(record3); #endregion Session.Flush(); }
private void listBoxViewTemplate_DoubleClick(object sender, EventArgs e) { int selection = listBoxViewTemplate.SelectedIndex; if (selection > 0) { SelectedItem = templates[selection]; DialogResult = DialogResult.OK; Close(); } }
public EntryViewControl() { _viewTemplate = null; InitializeComponent(); RefreshEntryDetail(); }
public TaskFlowViewModel(ViewTemplate template, ITaskRepository repository) : base(template, repository) { this.SelectFlowTaskCommand = new Command("SelectTask", "SelectTask", "", this.ExecuteSelectFlowTask); }
public static void Inizialize(ISession Session) { #region Customer Inizialize Customer WallStreetDaily = new Customer { Id = 1, Name = "Wall Street Daily" }; Customer FleetStreetPublication = new Customer { Id = 2, Name = "Fleet Street Publication" }; Customer DailyEdge = new Customer { Id = 3, Name = "Daily Edge" }; Customer HeidiShubert = new Customer { Id = 6, Name = "Heidi Shubert" }; Customer WeissResearch = new Customer { Id = 4, Name = "Weiss Research" }; Customer WSD = new Customer { Id = 5, Name = "WSD Custom Strategy" }; Session.Save(DailyEdge); Session.Save(HeidiShubert); Session.Save(WallStreetDaily); Session.Save(WeissResearch); Session.Save(WSD); Session.Save(FleetStreetPublication); #endregion #region Portfolios Inizialize Portfolio portfolio1 = new Portfolio { Id = 1, Name = "Strategic Investment Open Portfolio", Notes = "A portfolio is a grouping of financial assets such as stocks,", DisplayIndex = 1, LastUpdateDate = new DateTime(2017, 4, 28), Visibility = false, Quantity = 2, PercentWins = 73.23m, BiggestWinner = 234.32m, BiggestLoser = 12.65m, AvgGain = 186.65m, MonthAvgGain = 99.436m, PortfolioValue = 1532.42m, Customer = WallStreetDaily }; Portfolio portfolio2 = new Portfolio { Id = 2, Name = "Strategic Investment Income Portfolio", Notes = "A portfolio is a grouping of financial assets such as stocks,", DisplayIndex = 2, LastUpdateDate = new DateTime(2017, 3, 12), Visibility = true, Quantity = 3, PercentWins = 93.23m, BiggestWinner = 534.32m, BiggestLoser = 123.46m, AvgGain = 316.65m, MonthAvgGain = 341.436m, PortfolioValue = 5532.42m, Customer = WallStreetDaily //Positions = new List<Position> { position3, position4, position5 } }; Portfolio portfolio3 = new Portfolio { Id = 3, Name = "HDFC Bank", DisplayIndex = 4, LastUpdateDate = new DateTime(2017, 3, 12), Visibility = true, Quantity = 3, PercentWins = 93.23m, BiggestWinner = 534.32m, BiggestLoser = 123.46m, AvgGain = 316.65m, MonthAvgGain = 341.436m, PortfolioValue = 5532.42m, Customer = WallStreetDaily }; Portfolio portfolio4 = new Portfolio { Id = 4, Name = "IndusInd Bank", DisplayIndex = 5, LastUpdateDate = new DateTime(2017, 3, 12), Visibility = true, Quantity = 3, PercentWins = 93.23m, BiggestWinner = 534.32m, BiggestLoser = 123.46m, AvgGain = 316.65m, MonthAvgGain = 341.436m, PortfolioValue = 5532.42m, Customer = FleetStreetPublication }; Portfolio portfolio5 = new Portfolio { Id = 5, Name = "UltraTechCement", DisplayIndex = 3, LastUpdateDate = new DateTime(2017, 3, 12), Visibility = true, Quantity = 3, PercentWins = 93.23m, BiggestWinner = 534.32m, BiggestLoser = 123.46m, AvgGain = 316.65m, MonthAvgGain = 341.436m, PortfolioValue = 5532.42m, Customer = FleetStreetPublication }; Session.Save(portfolio1); Session.Save(portfolio2); Session.Save(portfolio3); Session.Save(portfolio4); Session.Save(portfolio5); #endregion #region Positions Inizialize Position position1 = new Position { Id = 1, SymbolId = 3, SymbolType = Symbols.Option, SymbolName = "PLSE", Name = "Pulse Biosciences CS", OpenDate = new DateTime(2015, 7, 20), OpenPrice = 128.32m, OpenWeight = 40, TradeType = TradeTypes.Long, TradeStatus = TradeStatuses.Open, Dividends = 57.3m, CurrentPrice = 99.53m, Gain = 87.12m, AbsoluteGain = 110.34m, MaxGain = 154.34m, LastUpdateDate = new DateTime(2016, 1, 1), LastUpdatePrice = 218.32m, Portfolio = portfolio1 }; Position position2 = new Position { Id = 2, SymbolId = 2, SymbolType = Symbols.Stock, SymbolName = "WIWTY", Name = "Witwatersrand Gold Rsrcs Ltd ", OpenDate = new DateTime(2009, 2, 24), OpenPrice = 4.00m, OpenWeight = 125, TradeType = TradeTypes.Long, TradeStatus = TradeStatuses.Open, Dividends = 0.00m, CurrentPrice = 3.64m, Gain = 40.0m, AbsoluteGain = 1.60m, MaxGain = 1.60m, LastUpdateDate = new DateTime(2016, 1, 1), LastUpdatePrice = 218.32m, Portfolio = portfolio1 }; Position position3 = new Position { Id = 3, SymbolId = 1, SymbolType = Symbols.Option, SymbolName = "AAT", Name = "AAT Corporation Limited", OpenDate = new DateTime(2017, 4, 28), OpenPrice = 43.20m, OpenWeight = 113, TradeType = TradeTypes.Long, TradeStatus = TradeStatuses.Wait, Dividends = 17.34m, CloseDate = new DateTime(2017, 5, 2), ClosePrice = 54.24m, Gain = 11.56m, AbsoluteGain = 9.45m, MaxGain = 14.34m, LastUpdateDate = new DateTime(2016, 5, 1), LastUpdatePrice = 53.32m, Portfolio = portfolio2 }; Position position4 = new Position { Id = 4, SymbolId = 4, SymbolType = Symbols.Stock, SymbolName = "FXI", Name = "iShares FTSE/XINHUA 25", OpenDate = new DateTime(2009, 8, 28), OpenPrice = 39.81m, OpenWeight = 65, TradeType = TradeTypes.Long, TradeStatus = TradeStatuses.Close, Dividends = 1.54m, CloseDate = new DateTime(2012, 1, 12), ClosePrice = 36.74m, Gain = 3.84m, AbsoluteGain = 3.65m, MaxGain = 3.65m, LastUpdateDate = new DateTime(2011, 10, 11), LastUpdatePrice = 53.32m, Portfolio = portfolio2 }; Position position5 = new Position { Id = 1, SymbolId = 3, SymbolType = Symbols.Option, SymbolName = "DBA", Name = "Powershares DB Agri Index", OpenDate = new DateTime(2009, 10, 30), OpenPrice = 25.57m, OpenWeight = 72, TradeType = TradeTypes.Short, TradeStatus = TradeStatuses.Open, Dividends = 0.00m, CloseDate = new DateTime(2012, 1, 12), ClosePrice = 29.25m, CurrentPrice = 12.56m, Gain = 14.39m, AbsoluteGain = 11.34m, MaxGain = 13.34m, Portfolio = portfolio2 }; var position10 = (Position)position1.Clone(); var position11 = (Position)position1.Clone(); var position12 = (Position)position1.Clone(); var position13 = (Position)position1.Clone(); var position14 = (Position)position1.Clone(); var position15 = (Position)position1.Clone(); var position16 = (Position)position1.Clone(); var position17 = (Position)position1.Clone(); var position18 = (Position)position1.Clone(); var position19 = (Position)position1.Clone(); var position21 = (Position)position2.Clone(); var position20 = (Position)position2.Clone(); var position22 = (Position)position2.Clone(); var position23 = (Position)position2.Clone(); var position24 = (Position)position2.Clone(); var position25 = (Position)position2.Clone(); var position26 = (Position)position2.Clone(); var position27 = (Position)position2.Clone(); var position28 = (Position)position2.Clone(); var position29 = (Position)position2.Clone(); Session.Save(position1); Session.Save(position10); Session.Save(position11); Session.Save(position12); Session.Save(position13); Session.Save(position14); Session.Save(position15); Session.Save(position16); Session.Save(position17); Session.Save(position18); Session.Save(position19); Session.Save(position20); Session.Save(position21); Session.Save(position22); Session.Save(position23); Session.Save(position24); Session.Save(position25); Session.Save(position26); Session.Save(position27); Session.Save(position28); Session.Save(position29); Session.Save(position2); Session.Save(position3); Session.Save(position4); Session.Save(position5); #endregion #region ColumnFormat Inizialize ColumnFormat None = new ColumnFormat { Id = 1, Name = "None" }; ColumnFormat Money = new ColumnFormat { Id = 2, Name = "Money" }; ColumnFormat Linked = new ColumnFormat { Id = 3, Name = "Linked" }; ColumnFormat Date = new ColumnFormat { Id = 4, Name = "Date" }; ColumnFormat DateAndTime = new ColumnFormat { Id = 6, Name = "DateAndTime" }; ColumnFormat Percent = new ColumnFormat { Id = 7, Name = "Percent" }; Session.Save(None); Session.Save(Money); Session.Save(Linked); Session.Save(Date); Session.Save(DateAndTime); Session.Save(Percent); #endregion #region Formats Inizialize Format DateFormat = new Format { Id = 1, Name = "Date Format", ColumnFormats = new List <ColumnFormat> { Date, Linked, DateAndTime } }; Format MoneyFormat = new Format { Id = 2, Name = "Money Format", ColumnFormats = new List <ColumnFormat> { None, Money, Linked } }; Format PercentFormat = new Format { Id = 3, Name = "Percent Format", ColumnFormats = new List <ColumnFormat> { None, Percent } }; Format NoneFormat = new Format { Id = 4, Name = "None Format", ColumnFormats = new List <ColumnFormat> { None } }; Format LineFormat = new Format { Id = 5, Name = "Line Format", ColumnFormats = new List <ColumnFormat> { None, Linked } }; Session.Save(DateFormat); Session.Save(MoneyFormat); Session.Save(PercentFormat); Session.Save(NoneFormat); Session.Save(LineFormat); #endregion #region ViewTemplate Inizialize ViewTemplate viewTemplate1 = new ViewTemplate { Id = 1, Name = "Preview all", Positions = TemplatePositions.All, ShowPortfolioStats = true, SortOrder = Sorting.ASC, Customer = WallStreetDaily }; ViewTemplate viewTemplate2 = new ViewTemplate { Id = 2, Name = "Default", Positions = TemplatePositions.OpenOnly, ShowPortfolioStats = false, SortOrder = Sorting.DESC, Customer = WallStreetDaily }; Session.Save(viewTemplate1); Session.Save(viewTemplate2); #endregion #region Columns Inizialize Column Name = new Column { Id = 1, Name = "Name", Format = LineFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn1, viewTemplateColumn21 } }; Column SymbolName = new Column { Id = 2, Name = "Symbol Name", Format = LineFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn2 } }; Column OpenPrice = new Column { Id = 3, Name = "Open Price", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn3 } }; Column OpenDate = new Column { Id = 4, Name = "Open Date", Format = DateFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn4 } }; Column OpenWeight = new Column { Id = 5, Name = "Open Weight", Format = NoneFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn5 } }; Column CurrentPrice = new Column { Id = 6, Name = "Current Price", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn6 } }; Column ClosePrice = new Column { Id = 7, Name = "Close Price", Format = MoneyFormat, // ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn7 } }; Column CloseDate = new Column { Id = 8, Name = "Close Date", Format = DateFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn8 } }; Column TradeType = new Column { Id = 9, Name = "Trade Type", Format = NoneFormat, // ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn9 } }; Column TradeStatus = new Column { Id = 10, Name = "Trade Status", Format = NoneFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn10 } }; Column Dividends = new Column { Id = 11, Name = "Dividends", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn11 } }; Column Gain = new Column { Id = 12, Name = "Gain", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn12 } }; Column AbsoluteGain = new Column { Id = 13, Name = "Absolute Gain", Format = PercentFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn13 } }; Column MaxGain = new Column { Id = 14, Name = "Max Gain", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn14 } }; Column LastUpdateDate = new Column { Id = 15, Name = "Last Update Date", Format = DateFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn15 } }; Column LastUpdatePrice = new Column { Id = 16, Name = "Last Update Price", Format = MoneyFormat, //ViewTemplateColumns = new List<ViewTemplateColumn> { viewTemplateColumn16 } }; Session.Save(Name); Session.Save(SymbolName); Session.Save(OpenPrice); Session.Save(OpenDate); Session.Save(OpenWeight); Session.Save(CurrentPrice); Session.Save(ClosePrice); Session.Save(CloseDate); Session.Save(TradeType); Session.Save(TradeStatus); Session.Save(Dividends); Session.Save(Gain); Session.Save(AbsoluteGain); Session.Save(MaxGain); Session.Save(LastUpdateDate); Session.Save(LastUpdatePrice); #endregion #region ViewTemplateColumns Inizialize ViewTemplateColumn viewTemplateColumn1 = new ViewTemplateColumn { Id = 1, Name = "Name", ColumnEntiy = Name, ViewTemplateId = 1, DisplayIndex = 1, ColumnFormat = Linked, ColumnId = 1, ColumnFormatId = 3, ViewTemplate = viewTemplate1, //ViewTemplatesForSorting = new List<ViewTemplate> { viewTemplate1 } }; ViewTemplateColumn viewTemplateColumn2 = new ViewTemplateColumn { Id = 2, Name = "Symbol", ColumnEntiy = SymbolName, ViewTemplateId = 1, DisplayIndex = 2, ColumnFormat = None, ColumnId = 2, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn3 = new ViewTemplateColumn { Id = 4, Name = "Open Price", ColumnEntiy = OpenPrice, ViewTemplateId = 1, DisplayIndex = 4, ColumnFormat = Money, ColumnId = 3, ColumnFormatId = 2, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn4 = new ViewTemplateColumn { Id = 5, Name = "Open Date", ColumnEntiy = OpenDate, ViewTemplateId = 1, DisplayIndex = 5, ColumnFormat = Date, ColumnId = 4, ColumnFormatId = 4, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn5 = new ViewTemplateColumn { Id = 3, Name = "Weight", ColumnEntiy = OpenWeight, ViewTemplateId = 1, DisplayIndex = 3, ColumnFormat = None, ColumnId = 5, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn6 = new ViewTemplateColumn { Id = 6, Name = "Current Price", ColumnEntiy = CurrentPrice, ViewTemplateId = 1, DisplayIndex = 6, ColumnFormat = Linked, ColumnId = 6, ColumnFormatId = 3, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn7 = new ViewTemplateColumn { Id = 7, Name = "Close Price", ColumnEntiy = ClosePrice, ViewTemplateId = 1, DisplayIndex = 7, ColumnFormat = None, ColumnId = 7, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn8 = new ViewTemplateColumn { Id = 8, Name = "Close Date", ColumnEntiy = CloseDate, ViewTemplateId = 1, DisplayIndex = 8, ColumnFormat = DateAndTime, ColumnId = 8, ColumnFormatId = 6, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn9 = new ViewTemplateColumn { Id = 9, Name = "Trade Type", ColumnEntiy = TradeType, ViewTemplateId = 1, DisplayIndex = 9, ColumnFormat = None, ColumnId = 9, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn10 = new ViewTemplateColumn { Id = 10, Name = "Trade Status", ColumnEntiy = TradeStatus, ViewTemplateId = 1, DisplayIndex = 10, ColumnFormat = None, ColumnId = 10, ColumnFormatId = 1, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn11 = new ViewTemplateColumn { Id = 11, Name = "Dividends", ColumnEntiy = Dividends, ViewTemplateId = 1, DisplayIndex = 11, ColumnFormat = Money, ColumnId = 11, ColumnFormatId = 2, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn12 = new ViewTemplateColumn { Id = 12, Name = "Absolute Gain", ColumnEntiy = AbsoluteGain, ViewTemplateId = 1, DisplayIndex = 12, ColumnFormat = Percent, ColumnId = 13, ColumnFormatId = 7, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn13 = new ViewTemplateColumn { Id = 13, Name = "Max Gain", ColumnEntiy = MaxGain, ViewTemplateId = 1, DisplayIndex = 13, ColumnFormat = Money, ColumnId = 14, ColumnFormatId = 2, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn14 = new ViewTemplateColumn { Id = 14, Name = "Gain", ColumnEntiy = Gain, ViewTemplateId = 1, DisplayIndex = 14, ColumnFormat = Linked, ColumnId = 12, ColumnFormatId = 3, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn15 = new ViewTemplateColumn { Id = 15, Name = "Last Update Date", ColumnEntiy = LastUpdateDate, ViewTemplateId = 1, DisplayIndex = 15, ColumnFormat = DateAndTime, ColumnId = 15, ColumnFormatId = 6, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn16 = new ViewTemplateColumn { Id = 16, Name = "Last Update Price", ColumnEntiy = LastUpdatePrice, ViewTemplateId = 1, DisplayIndex = 16, ColumnFormat = Linked, ColumnId = 16, ColumnFormatId = 2, ViewTemplate = viewTemplate1 }; ViewTemplateColumn viewTemplateColumn21 = new ViewTemplateColumn { Id = 17, Name = "Name", ColumnEntiy = Name, ViewTemplateId = 2, DisplayIndex = 1, ColumnFormat = None, ColumnId = 1, ColumnFormatId = 1, ViewTemplate = viewTemplate2, //ViewTemplatesForSorting = new List<ViewTemplate> { viewTemplate2 } }; Session.Save(viewTemplateColumn1); Session.Save(viewTemplateColumn2); Session.Save(viewTemplateColumn3); Session.Save(viewTemplateColumn4); Session.Save(viewTemplateColumn5); Session.Save(viewTemplateColumn6); Session.Save(viewTemplateColumn1); Session.Save(viewTemplateColumn7); Session.Save(viewTemplateColumn8); Session.Save(viewTemplateColumn9); Session.Save(viewTemplateColumn10); Session.Save(viewTemplateColumn11); Session.Save(viewTemplateColumn12); Session.Save(viewTemplateColumn13); Session.Save(viewTemplateColumn14); Session.Save(viewTemplateColumn15); Session.Save(viewTemplateColumn16); Session.Save(viewTemplateColumn21); #endregion #region View Inizialize ViewForTable previewAllView = new ViewForTable { Id = 1, Name = "Preview All View", ShowName = true, DateFormat = DateFormats.MonthDayYear, MoneyPrecision = 2, PercentyPrecision = 4, ViewTemplate = viewTemplate1, ViewTemplateId = viewTemplate1.Id, Customer = WallStreetDaily }; ViewForTable defaultView = new ViewForTable { Id = 2, Name = "Default View", ShowName = false, DateFormat = DateFormats.DayMonthNameYear, MoneyPrecision = 1, PercentyPrecision = 2, ViewTemplate = viewTemplate2, ViewTemplateId = viewTemplate2.Id, Customer = WallStreetDaily }; Session.Save(previewAllView); Session.Save(defaultView); #endregion #region User Inizialize var userManager = new ApplicationUserManager(new UserStore <UserEntity>(Session)); var roleManager = new ApplicationRoleManager(new RoleStore <Role>(Session)); List <Role> identityRoles = new List <Role> { new Role() { Name = "Admin" }, new Role() { Name = "User" }, new Role() { Name = "Employee" } }; foreach (Role role in identityRoles) { roleManager.Create(role); } UserEntity admin = new UserEntity { Email = "Admin", UserName = "******" }; userManager.Create(admin, "Password"); userManager.AddToRole(admin.Id, "Admin"); userManager.AddToRole(admin.Id, "Employee"); var clientProfile = new Profile { Id = admin.Id, Login = admin.UserName, Customer = WallStreetDaily, CustomerId = WallStreetDaily.Id }; WallStreetDaily.Profiles.Add(clientProfile); #endregion #region Records Inizialize Record record1 = new Record { UserId = "1aaa023d-e950-47fc-9c3f-54fbffcc99cf", Entity = Entities.Position, Operation = Operations.Create, Successfully = true, EntityId = 1, DateTime = new DateTime(2017, 4, 1) }; Record record2 = new Record { UserId = "1aaa023d-e950-47fc-9c3f-54fbffcc99cf", Entity = Entities.Position, Operation = Operations.Delete, Successfully = false, EntityId = 1, DateTime = new DateTime(2017, 4, 3) }; Record record3 = new Record { UserId = "2da9e5e9-ee3e-473c-a131-c39050b26760", Entity = Entities.Portfolio, Operation = Operations.Update, Successfully = true, EntityId = 2, DateTime = new DateTime(2017, 4, 4) }; Session.Save(record1); Session.Save(record2); Session.Save(record3); #endregion Session.Flush(); #region View and function inizialize ISQLQuery createSymbolView = Session.CreateSQLQuery( "CREATE VIEW SymbolView AS " + "SELECT S.SymbolID, S.Symbol, S.Name, C.Symbol AS CurrencySymbol " + "FROM HistoricalDataNew.dbo.Symbol AS S INNER JOIN " + "HistoricalDataNew.dbo.Currencies AS C ON S.CurrencyId = C.CurrencyId"); ISQLQuery createSymbolDividends = Session.CreateSQLQuery( "CREATE VIEW SymbolDividends AS " + "SELECT DividendAmount, SymbolID, TradeDate " + "FROM HistoricalDataNew.dbo.Dividend"); ISQLQuery createTradeSybolInformation = Session.CreateSQLQuery( "CREATE VIEW TradeSybolInformation AS " + "SELECT SymbolID, TradeDate, TradeIndex " + "FROM HistoricalDataNew.dbo.IndexData " + "UNION " + "SELECT SymbolID, TradeDate, CAST(TradeOpen AS money) AS TradeIndex " + "FROM HistoricalDataNew.dbo.StockData"); ISQLQuery createGetPriceInDateInterval = Session.CreateSQLQuery( "CREATE FUNCTION[dbo].[getPriceDividendForSymbolInDateInterval](@dateFrom datetime, @dateTo datetime, @symbolId int) " + "RETURNS " + "@report TABLE(TradeDate datetime, Price MONEY, Dividends MONEY) " + "AS BEGIN " + "INSERT INTO @report SELECT DISTINCT tr.TradeDate, tr.TradeIndex AS Price, ISNULL(( " + "SELECT SUM(d.DividendAmount) " + "FROM SymbolDividends d " + "WHERE d.SymbolId = tr.SymbolId AND d.SymbolID = @symbolId AND " + "d.TradeDate = tr.TradeDate),0) AS Dividends " + "FROM TradeSybolInformation tr " + "WHERE tr.SymbolID = @symbolId AND tr.TradeDate >= @dateFrom AND tr.TradeDate <= @dateTo " + "ORDER BY tr.TradeDate " + "RETURN " + "END "); ISQLQuery creategetMaxMinGain = Session.CreateSQLQuery( "CREATE FUNCTION[dbo].[getMaxMinGainForSymbolInDateInterval](@dateFrom datetime, @dateTo datetime, @symbolId int) " + "RETURNS " + "@report TABLE(TradeDate datetime, Price MONEY, Dividends MONEY) " + "AS BEGIN " + "DECLARE @tab TABLE(TradeDate datetime, Price MONEY, Dividends MONEY) " + "INSERT INTO @tab SELECT *FROM getPriceDividendForSymbolInDateInterval(@dateFrom, @dateTo, @symbolId) " + "INSERT INTO @report SELECT TOP 1 * FROM @tab " + "WHERE Price + Dividends = (SELECT MAX(Price + Dividends) FROM @tab) " + "INSERT INTO @report SELECT TOP 1 * FROM @tab " + "WHERE Price + Dividends = (SELECT MIN(Price + Dividends) FROM @tab) " + "RETURN " + "END"); createSymbolView.ExecuteUpdate(); createSymbolDividends.ExecuteUpdate(); createTradeSybolInformation.ExecuteUpdate(); createGetPriceInDateInterval.ExecuteUpdate(); creategetMaxMinGain.ExecuteUpdate(); #endregion }
public ViewTemplate CreateViewTemplate(ViewTemplate template) { return(MissingInfoViewMaker.CreateViewTemplate(this, template)); }
private static ViewTemplate MakeSampleInventory() { ViewTemplate f = new ViewTemplate(); f.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", new string[] {"xx", "yy"})); Field field = new Field(LexSense.WellKnownProperties.Gloss, "LexSense", new string[] {"zz"}); field.Enabled = false; //field.Visibility = CommonEnumerations.VisibilitySetting.Invisible; f.Add(field); return f; }
public static ViewTemplate CreateViewTemplate(MissingInfoConfiguration config, ViewTemplate baseTemplate) { var template = CreateViewTemplateFromListOfFields(baseTemplate, config.FieldsToShowCommaSeparated, config.FieldsToShowReadOnly); //see WS-1120 ([email protected]) Add option to limit "add meanings" task to the ones that have a semantic domain //for now, let's just turn off all ghosts in these fill-in tasks template.DoWantGhosts = false; MarkReadOnlyFields(template, config.FieldsToShowReadOnly); //hack until we overhaul how Tasks are setup: var isBaseFormFillingTask = config.FieldsToShowCommaSeparated.Contains(LexEntry.WellKnownProperties.BaseForm); if (isBaseFormFillingTask) { Field flagField = new Field(); flagField.DisplayName = StringCatalog.Get("~&This word has no Base Form", "The user will click this to say that this word has no baseform. E.g. Kindness has Kind as a baseform, but Kind has no other word as a baseform."); flagField.DataTypeName = "Flag"; flagField.ClassName = "LexEntry"; flagField.FieldName = "flag-skip-" + config.MissingInfoFieldName; flagField.Enabled = true; template.Add(flagField); } return(template); }
/// <summary> /// 保存系统模板 /// </summary> /// <param name="template"></param> /// <param name="models"></param> /// <returns></returns> public bool SaveTemplateInfo(ViewTemplate template, int[] models) { if (string.IsNullOrEmpty(template.Preview)) { return(this.FaildMessage("请上传预览图")); } if (string.IsNullOrEmpty(template.Name)) { return(this.FaildMessage("请输入模板名称")); } bool isNew = template.ID == 0; using (DbExecutor db = NewExecutor(IsolationLevel.ReadUncommitted)) { if (template.ID == 0) { template.AddIdentity(db); } else { template.Update(db, t => t.Name, t => t.Preview); } //# 得到当前平台下所有的视图 List <ViewSetting> views = db.ReadList <ViewSetting>(t => t.Platform == template.Platform); List <ViewModel> modelList = new List <ViewModel>(); foreach (int modelId in models) { ViewModel model = db.ReadInfo <ViewModel>(t => t.ID == modelId); if (model == null) { db.Rollback(); return(this.FaildMessage($"模型ID{modelId}不存在")); } ViewTemplateConfig config = isNew ? null : config = db.ReadInfo <ViewTemplateConfig>(t => t.TemplateID == template.ID && t.ViewID == model.ViewID); if (config != null && config.ModelID != modelId) { config.ModelID = modelId; config.Update(db, t => t.ModelID); } else if (config == null) { config = new ViewTemplateConfig() { TemplateID = template.ID, ViewID = model.ViewID, ModelID = model.ID }; config.Add(db); } modelList.Add(model); } ViewSetting view = views.FirstOrDefault(t => !modelList.Any(p => p.ViewID == t.ID)); if (view != null) { db.Rollback(); return(this.FaildMessage($"视图{view.Name}未选则模型")); } db.Commit(); } return(this.AccountInfo.Log(LogType.View, $"保存系统模板 {template.Platform}/{template.Name}")); }
private DetailList MakeDetailList(bool showNormallyHiddenFields, bool showMinorMeaningLabel, ViewTemplate template) { //TODO need tests for other data types when made optional //TODO need tests for showing non-empty optional tests in non-show-all mode LexEntry entry = GetNewEntry(); DetailList dl = new DetailList(); LexEntryLayouter layout = new LexEntryLayouter(dl, 0, template, null, Context, entry, false, () => new TestConfirmDelete(), showMinorMeaningLabel); layout.ShowNormallyHiddenFields = showNormallyHiddenFields; layout.AddWidgets(); _rowCount = dl.RowCount; return(dl); }
public override void Setup() { base.Setup(); _tempFolder = new TemporaryFolder(); _vernacularWritingSystem = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.VernacularIdForTest); RtfRenderer.HeadWordWritingSystemId = _vernacularWritingSystem.Id; _filePath = _tempFolder.GetTemporaryFile(); _lexEntryRepository = new LexEntryRepository(_filePath); _analysisWritingSystemIds = new string[] { WritingSystemsIdsForTests.AnalysisIdForTest }; string[] vernacularWritingSystemIds = new string[] { _vernacularWritingSystem.Id }; ViewTemplate viewTemplate = new ViewTemplate(); viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", vernacularWritingSystemIds)); viewTemplate.Add(new Field("focusOnMe", "LexEntry", _analysisWritingSystemIds, Field.MultiplicityType.ZeroOr1, "MultiText")); viewTemplate.Add(new Field("MyEntryCustom", "LexEntry", _analysisWritingSystemIds, Field.MultiplicityType.ZeroOr1, "MultiText")); Field readOnlySemanticDomain = new Field(LexSense.WellKnownProperties.SemanticDomainDdp4, "LexSense", _analysisWritingSystemIds); readOnlySemanticDomain.Visibility = CommonEnumerations.VisibilitySetting.ReadOnly; viewTemplate.Add(readOnlySemanticDomain); Field shy1 = new Field("MyShyEntryCustom", "LexEntry", _analysisWritingSystemIds, Field.MultiplicityType.ZeroOr1, "MultiText"); shy1.Visibility = CommonEnumerations.VisibilitySetting.NormallyHidden; shy1.DisplayName = "MyShyEntryCustom"; viewTemplate.Add(shy1); #if GlossMeaning viewTemplate.Add(new Field(Field.FieldNames.SenseGloss.ToString(), "LexSense", analysisWritingSystemIds)); #else _definitionField = new Field(LexSense.WellKnownProperties.Definition, "LexSense", _analysisWritingSystemIds); viewTemplate.Add(_definitionField); #endif viewTemplate.Add(new Field("MySenseCustom", "LexSense", _analysisWritingSystemIds, Field.MultiplicityType.ZeroOr1, "MultiText")); viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(), "LexExampleSentence", vernacularWritingSystemIds)); viewTemplate.Add(new Field(Field.FieldNames.ExampleTranslation.ToString(), "LexExampleSentence", _analysisWritingSystemIds)); Field customField = new Field("SemanticDomains", "LexSense", _analysisWritingSystemIds, Field.MultiplicityType.ZeroOr1, "OptionCollection"); customField.DisplayName = "Sem Dom"; customField.OptionsListFile = "SemanticDomains.xml"; viewTemplate.Add(customField); Field customPOSField = new Field(LexSense.WellKnownProperties.PartOfSpeech, "LexSense", _analysisWritingSystemIds, Field.MultiplicityType.ZeroOr1, "Option"); customPOSField.DisplayName = "POS"; customPOSField.OptionsListFile = "PartsOfSpeech.xml"; viewTemplate.Add(customPOSField); Field customNotesField = new Field(PalasoDataObject.WellKnownProperties.Note, "LexSense", _analysisWritingSystemIds); customNotesField.DisplayName = "s-note"; viewTemplate.Add(customNotesField); Field exampleNotesField = new Field(PalasoDataObject.WellKnownProperties.Note, "LexExampleSentence", _analysisWritingSystemIds); exampleNotesField.DisplayName = "ex-note"; viewTemplate.Add(exampleNotesField); _entryViewFactory = (() => new EntryViewControl()); DictionaryControl.Factory dictControlFactory = (memory => new DictionaryControl(_entryViewFactory, _lexEntryRepository, viewTemplate, memory, new StringLogger())); _task = new DictionaryTask(dictControlFactory, DictionaryBrowseAndEditConfiguration.CreateForTests(), _lexEntryRepository, new TaskMemoryRepository()); //, new UserSettingsForTask()); _detailTaskPage = new TabPage(); ActivateTask(); _tabControl = new TabControl(); _tabControl.Dock = DockStyle.Fill; _tabControl.TabPages.Add(_detailTaskPage); _tabControl.TabPages.Add(new TabPage("Dummy")); _window = new Form(); _window.Controls.Add(_tabControl); _window.Width = 700; _window.Height = 500; _window.Show(); }
private EntryViewControl CreateFilteredForm(LexEntry entry, string field, string className, params string[] writingSystems) { ViewTemplate viewTemplate = new ViewTemplate(); viewTemplate.Add(new Field(field, className, writingSystems)); EntryViewControl entryViewControl = new EntryViewControl(); entryViewControl.LexEntryRepository = _lexEntryRepository; entryViewControl.ViewTemplate = viewTemplate; entryViewControl.DataSource = entry; Form window = new Form(); window.Controls.Add(entryViewControl); window.Show(); return entryViewControl; }
/* private List<Parameter> GetParameters(XPathNavigator component) { List<Parameter> parameters = new List<Parameter>(); if (component.HasChildren) { XPathNodeIterator children = component.SelectChildren(string.Empty, string.Empty); foreach (XPathNavigator child in children) { if (child.GetAttribute("UseInConstructor", string.Empty) == "false") continue; parameters.Add(GetSimpleParameter(child)); } } return parameters; } private Parameter GetSimpleParameter(XPathNavigator child) { switch (child.GetAttribute("class", string.Empty)) { case "": return new NamedParameter(child.Name, child.Value); break; case "string": return new NamedParameter(child.Name, child.Value); break; case "bool": return new NamedParameter(child.Name, child.ValueAsBoolean); break; case "DateTime": return new NamedParameter(child.Name, child.ValueAsDateTime); break; case "double": return new NamedParameter(child.Name, child.ValueAsDouble); break; case "int": return new NamedParameter(child.Name, child.ValueAsInt); break; case "long": return new NamedParameter(child.Name, child.ValueAsLong); break; default: throw new ConfigurationException("Didn't understand this type of paramter in the config file: '{0}'", child.GetAttribute("class", string.Empty)); break; } } */ // review: this might belong in a nother file... public static IEnumerable<ViewTemplate> CreateViewTemplates(string xmlConfiguration) { XPathDocument doc = new XPathDocument(new StringReader(xmlConfiguration)); XPathNavigator navigator = doc.CreateNavigator(); navigator = navigator.SelectSingleNode("//components"); if (navigator != null) { bool hasviewTemplate = false; XPathNodeIterator componentList = navigator.SelectChildren(string.Empty, string.Empty); foreach (XPathNavigator component in componentList) { Debug.Assert(component.Name == "viewTemplate"); hasviewTemplate = true; ViewTemplate template = new ViewTemplate(); template.LoadFromString(component.OuterXml); yield return template; } Debug.Assert(hasviewTemplate, "Currently, there must be at least 1 viewTemplate in the WeSayConfig file"); } }
private void buttonOK_Click(object sender, EventArgs e) { // Set SelectedItem property SelectedItem = templates[listBoxViewTemplate.SelectedIndex]; DialogResult = DialogResult.OK; Close(); }
public LexSenseLayouter(DetailList builder, ViewTemplate viewTemplate, LexEntryRepository lexEntryRepository) : base(builder, viewTemplate, lexEntryRepository) {}
private void GetPredefinedTemplates() { // Get all Views and only show ones currently not available List<logicalView> views = logicalView.getAll(true); List<string> viewNames = new List<string>(); foreach(logicalView view in views) { viewNames.Add(view.Name); } // All Series if (!viewNames.Contains(DBView.cTranslateTokenAll)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenAll; template.prettyname = Translation.All; template.description = "Shows all series in database."; template.configuration = @"series<;><;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Favourite Series if (!viewNames.Contains(DBView.cTranslateTokenFavourite)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenFavourite; template.prettyname = Translation.Favourites; template.tagview = true; template.description = "Shows all series tagged as Favourite."; template.configuration = @"series<;><Series.ViewTags>;like;%|Favourites|%<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Online Favourite Series if (!viewNames.Contains(DBView.cTranslateTokenOnlineFavourite)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenOnlineFavourite; template.prettyname = Translation.OnlineFavourites; template.tagview = true; template.description = "Shows all series tagged as Favourite online at theTVDB.com. This requires the Account Indentifier to be set."; template.configuration = @"series<;><Series.ViewTags>;like;%|OnlineFavourites|%<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Unwatched Series if (!viewNames.Contains(DBView.cTranslateTokenUnwatched)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenUnwatched; template.prettyname = Translation.Unwatched; template.description = "Shows all series with un-watched episodes."; template.configuration = @"series<;><Episode.Watched>;=;0<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Channels if (!viewNames.Contains(DBView.cTranslateTokenChannels)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenChannels; template.prettyname = Translation.Channels; template.description = "Groups all Series according to Aired TV Channel (Network) e.g. ABC, BBC, The CW, Comedy Channel..."; template.configuration = @"group:<Series.Network><;><;><;><nextStep>series<;><;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Genres if (!viewNames.Contains(DBView.cTranslateTokenGenres)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenGenres; template.prettyname = Translation.Genres; template.description = "Groups all Series according to Genre (Network), e.g. Action, Drama, Comedy..."; template.configuration = @"group:<Series.Genre><;><;><;><nextStep>series<;><;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Content Rating if (!viewNames.Contains(DBView.cTranslateTokenContentRating)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenContentRating; template.prettyname = Translation.ContentRating; template.description = "Groups all Series according to Content Rating (Certification) e.g. Rating PG, Rating M..."; template.configuration = @"group:<Series.ContentRating><;><;><;><nextStep>series<;><;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // View Tags if (!viewNames.Contains(DBView.cTranslateTokenViewTags)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenViewTags; template.prettyname = Translation.ViewTags; template.description = "Groups all Series according to View Tags, view tags are views that you can assign series too."; template.configuration = @"group:<Series.ViewTags><;><;><;><nextStep>series<;><;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Actors if (!viewNames.Contains(DBView.cTranslateTokenActors)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenActors; template.prettyname = Translation.Actors; template.description = "Groups all Series according to starring Actors."; template.configuration = @"group:<Series.Actors><;><;><;><nextStep>series<;><;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Latest (30 Days Episode View) if (!viewNames.Contains(DBView.cTranslateTokenLatest)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenLatest; template.prettyname = Translation.Latest; template.description = "Filters the last 30 Days of episodes which have Aired. This view will skip Series selection and take you directly to the list of episodes. Episodes are listed in descending order."; template.configuration = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>"; templates.Add(template); } // Recently Added (Last 7 Days Episode View) if (!viewNames.Contains(DBView.cTranslateTokenRecentlyAdded)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenRecentlyAdded; template.prettyname = Translation.RecentlyAdded; template.description = "Filters the last 7 days of recently added episodes into your library. This view will skip Series selection and take you directly to the list of episodes. Episodes are listed in descending order."; template.configuration = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>"; templates.Add(template); } // Adult Shows // Only AND conditions are currently supported if (!viewNames.Contains(DBView.cTranslateTokenAdultSeries)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenAdultSeries; template.prettyname = Translation.AdultSeries; template.description = "Filters series that are suitable for Mature Audiences or recommend Parental Consent ie. series that have a Content Rating of TV-PG, TV-14 and TV-MA. This will also show unrated Series, if a series is unrated please update the online database at: http://theTVDB.com"; template.configuration = @"series<;><Series.ContentRating>;!=;TV-Y<cond><Series.ContentRating>;!=;TV-Y7<cond><Series.ContentRating>;!=;TV-G<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Kids Shows // Only AND conditions are currently supported if (!viewNames.Contains(DBView.cTranslateTokenKidsSeries)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenKidsSeries; template.prettyname = Translation.KidsSeries; template.description = "Filters series that are suitable for children ie. series that have a Content Rating of TV-Y, TV-Y7 and TV-G."; template.configuration = @"series<;><Series.ContentRating>;!=;TV-PG<cond><Series.ContentRating>;!=;TV-14<cond><Series.ContentRating>;!=;TV-MA<cond><Series.ContentRating>;!=;<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Contining Series if (!viewNames.Contains(DBView.cTranslateTokenContinuing)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenContinuing; template.prettyname = Translation.Continuing; template.description = "Filters series list with shows that are still Continuing."; template.configuration = @"series<;><Series.Status>;=;Continuing<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Ended Series if (!viewNames.Contains(DBView.cTranslateTokenEnded)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenEnded; template.prettyname = Translation.Ended; template.description = "Filters series list with shows that have Ended."; template.configuration = @"series<;><Series.Status>;=;Ended<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // HD Episodes if (!viewNames.Contains(DBView.cTranslateTokenHighDefinition)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenHighDefinition; template.prettyname = Translation.HighDefinition; template.description = "Filters all episodes that contain a Video Height Greater than or equal to 720 pixels."; template.configuration = @"series<;><Episode.videoHeight>;>=;720<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // SD Episodes if (!viewNames.Contains(DBView.cTranslateTokenStandardDefinition)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenStandardDefinition; template.prettyname = Translation.StandardDefinition; template.description = "Filters all episodes that contain a Video Height Less than 720 pixels."; template.configuration = @"series<;><Episode.videoHeight>;<;720<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Top 10 (Online) if (!viewNames.Contains(DBView.cTranslateTokenTop10Online)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenTop10Online; template.prettyname = Translation.Top10Online; template.description = "Filters theTVDB Top 10 highest ratings series, in descending order."; template.configuration = @"series<;><Series.Rating>;!=;<;><Series.Rating>;desc<;>10<nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Top 10 (User) if (!viewNames.Contains(DBView.cTranslateTokenTop10User)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenTop10User; template.prettyname = Translation.Top10User; template.description = "Filters your personal Top 10 highest rated series, in descending order."; template.configuration = @"series<;><Series.myRating>;!=;<;><Series.myRating>;desc<;>10<nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Top 25 (Online) if (!viewNames.Contains(DBView.cTranslateTokenTop25Online)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenTop25Online; template.prettyname = Translation.Top25Online; template.description = "Filters theTVDB Top 25 highest ratings series, in descending order."; template.configuration = @"series<;><Series.Rating>;!=;<;><Series.Rating>;desc<;>25<nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Top 25 (User) if (!viewNames.Contains(DBView.cTranslateTokenTop25User)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenTop25User; template.prettyname = Translation.Top25User; template.description = "Filters your personal Top 25 highest rated series, in descending order."; template.configuration = @"series<;><Series.myRating>;!=;<;><Series.myRating>;desc<;>25<nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Removable Media //if (!viewNames.Contains(DBView.cTranslateTokenRemovableMedia)) { // ViewTemplate template = new ViewTemplate(); // template.name = DBView.cTranslateTokenRemovableMedia; // template.prettyname = Translation.RemovableMedia; // template.description = "Displays all Episodes found in pathes where the 'Removable' option is enabled e.g. DVD Drive, USB Drive."; // template.configuration = @"series<;><Episode.Removable>;=;1<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; // templates.Add(template); //} // Local Media //if (!viewNames.Contains(DBView.cTranslateTokenLocalMedia)) { // ViewTemplate template = new ViewTemplate(); // template.name = DBView.cTranslateTokenLocalMedia; // template.prettyname = Translation.LocalMedia; // template.description = "Displays all Episodes found in pathes where the 'Removable' option is disabled e.g. Internal Hard Drives, Network Drive."; // template.configuration = @"series<;><Episode.Removable>;=;0<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; // templates.Add(template); //} // Available Media Only if (!viewNames.Contains(DBView.cTranslateTokenAvailableMedia)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenAvailableMedia; template.prettyname = Translation.AvailableMedia; template.description = "Filters out Episodes that are currently not available e.g. Network Share Offline, USB Hard Drive not connected."; template.configuration = @"series<;><Episode.IsAvailable>;!=;0<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Subtitles Episodes if (!viewNames.Contains(DBView.cTranslateTokenSubtitles)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenSubtitles; template.prettyname = Translation.Subtitles; template.description = "Filters series that contain episodes with one or more subtitles."; template.configuration = @"series<;><Episode.TextCount>;>=;1<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } // Multi-Audio Episodes if (!viewNames.Contains(DBView.cTranslateTokenMultiAudio)) { ViewTemplate template = new ViewTemplate(); template.name = DBView.cTranslateTokenMultiAudio; template.prettyname = Translation.MultiAudio; template.description = "Filters series that contain episodes with more than one Audio Track."; template.configuration = @"series<;><Episode.AudioTracks>;>;1<;><;><nextStep>season<;><;><Season.seasonIndex>;asc<;><nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>"; templates.Add(template); } }
private Autodesk.Revit.DB.View CreateTemplateFor3DView(Autodesk.Revit.DB.View viewTemplate) { Transaction t = new Transaction(_doc); t.Start("Create view template 'DCE Structure 3D'"); // Copy an existing view template ICollection <ElementId> copyIds = new Collection <ElementId> { viewTemplate.Id }; // Create a default CopyPasteOptions CopyPasteOptions cpOpts = new CopyPasteOptions(); ElementId tmpId = ElementTransformUtils.CopyElements( _doc, copyIds, _doc, Transform.Identity, cpOpts) .First(); viewTemplate = _doc.GetElement(tmpId) as Autodesk.Revit.DB.View; viewTemplate.Name = THREED_VIEW_TEMPLATE_NAME; t.Commit(); // Ensure that the parameters are included in "DCE Structure 3D" view template List <BuiltInParameter> bipList = new List <BuiltInParameter>() { BuiltInParameter.VIEW_SCALE_PULLDOWN_METRIC, BuiltInParameter.VIEW_DETAIL_LEVEL, // BuiltInParameter.VIEW_PARTS_VISIBILITY, BuiltInParameter.VIS_GRAPHICS_MODEL, BuiltInParameter.VIS_GRAPHICS_ANNOTATION, // BuiltInParameter.VIS_GRAPHICS_ANALYTICAL_MODEL, // BuiltInParameter.VIS_GRAPHICS_IMPORT, BuiltInParameter.VIS_GRAPHICS_FILTERS, BuiltInParameter.VIS_GRAPHICS_RVT_LINKS, BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_MODEL, //BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_SHADOWS, //BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_SKETCHY_LINES, //BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_LIGHTING, //BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_PHOTO_EXPOSURE, //BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_BACKGROUND, //BuiltInParameter.VIEW_PHASE_FILTER, BuiltInParameter.VIEW_DISCIPLINE, BuiltInParameter.VIEW_SHOW_HIDDEN_LINES, //BuiltInParameter.VIEWER3D_RENDER_SETTINGS }; ViewTemplate.IncludParamToViewTemplate(_doc, viewTemplate, bipList); List <BuiltInCategory> bicList = new List <BuiltInCategory> { BuiltInCategory.OST_Walls, BuiltInCategory.OST_StructuralColumns, BuiltInCategory.OST_StructuralFraming, BuiltInCategory.OST_Floors, BuiltInCategory.OST_StructuralFoundation }; ViewTemplate.SetOnlyCategoriesVisible(_doc, viewTemplate, bicList); t.Start("Set view display paramters"); // Set the scale value viewTemplate.Scale = 400; // Set the detail level viewTemplate.DetailLevel = ViewDetailLevel.Fine; // Set the display style viewTemplate.DisplayStyle = DisplayStyle.ShadingWithEdges; // Set the discipline viewTemplate.Discipline = ViewDiscipline.Structural; OverrideGraphicSettings ogs = new OverrideGraphicSettings(); ogs.SetSurfaceTransparency(50); ogs.SetCutFillPatternVisible(false); viewTemplate.SetCategoryOverrides( _doc.Settings.Categories.get_Item(BuiltInCategory.OST_Floors).Id, ogs); // Remove all the filter in the view template foreach (ElementId id in viewTemplate.GetFilters()) { viewTemplate.RemoveFilter(id); } t.Commit(); return(viewTemplate); }
private List <ViewPlan> CreateNewViewPlan(Document doc, List <Level> newLevels) { List <ViewPlan> viewPlans = new List <ViewPlan>(); // Prepare the ViewFamilyType for the ViewPlan creation ViewFamilyType viewFamilyType = (from elem in new FilteredElementCollector(doc) .OfClass(typeof(ViewFamilyType)) .Cast <ViewFamilyType>() where elem.ViewFamily == ViewFamily.StructuralPlan select elem) .First(); View standardTemplate = ViewTemplate.FindViewTemplateOrDefault( _doc, ViewType.CeilingPlan, Default.TEMPLATE_NAME_STANDARD_FLOOR, out bool standardTemplateIsFound); View foundationTemplate = ViewTemplate.FindViewTemplateOrDefault( _doc, ViewType.CeilingPlan, Default.TEMPLATE_NAME_FOUNDATION, out bool foundationTemplateIsFound); using (Transaction t = new Transaction(doc, "Create View Plans")) { try { t.Start(); for (int i = 0; i < newLevels.Count; i++) { Level level = newLevels[i]; ViewPlan viewPlan = ViewPlan.Create(doc, viewFamilyType.Id, level.Id); viewPlan.Name = $"0{i + 1} {level.Name}"; viewPlans.Add(viewPlan); // TODO: Deal with the case when template is not found if (!viewPlan.Name.ToLower().Contains(Default.KEYWORD_FOUNDATION) && standardTemplateIsFound) { viewPlan.ViewTemplateId = standardTemplate.Id; } if (viewPlan.Name.ToLower().Contains(Default.KEYWORD_FOUNDATION) && foundationTemplateIsFound) { viewPlan.ViewTemplateId = foundationTemplate.Id; } // Associate level to the new viewplan AssociateLevelToNewViewPlan(level, viewPlan); } t.Commit(); } catch (Exception e) { TaskDialog.Show("Revit", $"Exception when creating view plans : {e.Message}"); t.RollBack(); } } return(viewPlans); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { _uiapp = commandData.Application; _uidoc = _uiapp.ActiveUIDocument; _doc = _uidoc.Document; // Get list of all levels for structural elements IList <Level> strLevels = GetAllLevels(_doc, true, true); if (strLevels.Count == 0) { return(Result.Cancelled); } // Get a ViewFamilyType for a 3D view ViewFamilyType viewFamilyType = (from v in new FilteredElementCollector(_doc) .OfClass(typeof(ViewFamilyType)) .Cast <ViewFamilyType>() where v.ViewFamily == ViewFamily.ThreeDimensional select v).First(); Autodesk.Revit.DB.View viewTemplate = ViewTemplate.FindViewTemplateOrDefault(_doc, ViewType.ThreeD, THREED_VIEW_TEMPLATE_NAME, out bool templateIsFound); if (viewTemplate != null && !templateIsFound) // Dont find the view template named as "DCE Structure 3D" { viewTemplate = CreateTemplateFor3DView(viewTemplate); } // Get all the 3D view created by the plugin IList <View3D> threeDViewList = (from v in new FilteredElementCollector(_doc) .OfClass(typeof(View3D)) .Cast <View3D>() where v.GetEntitySchemaGuids().Count != 0 select v) .ToList(); Transaction t = new Transaction(_doc); // loop through all levels, except the first one for (int highFloorLevelInd = 1; highFloorLevelInd < strLevels.Count; highFloorLevelInd++) { Level highFloorLevel = strLevels[highFloorLevelInd]; t.Start("Create or update 3D view"); View3D view; if (threeDViewList.Any(v => GetAssociateLevelOf3DView(v).Equals(highFloorLevel.Id))) { view = (from v in threeDViewList where GetAssociateLevelOf3DView(v).Equals(highFloorLevel.Id) select v) .First(); } else { // Create the 3d view view = View3D.CreateIsometric(_doc, viewFamilyType.Id); // Asociate the high-floor level to the 3d view AssociateLevelTo3DView(highFloorLevel, view); } if (viewTemplate != null) { // Apply the "DCE Structure 3D" view template to the created view view.ViewTemplateId = viewTemplate.Id; } // Set the name of the view if (view.Name != highFloorLevel.Name) { view.Name = highFloorLevel.Name; } // Get the bounding box of space between the high-floor and low-floor BoundingBoxXYZ boundingBoxXYZ = GetBoundingBoxOfLevel(strLevels, highFloorLevelInd, view); // Apply this bounding box to the view's section box view.SetSectionBox(boundingBoxXYZ); // Save orientation and lock the view view.SaveOrientationAndLock(); t.Commit(); // Open the just-created view // There cannot be an open transaction when the active view is set _uidoc.ActiveView = view; } return(Result.Succeeded); }
/// <summary> /// for old unit tests /// </summary> /// <param name="semanticDomainsQuestionFileName"></param> /// <param name="lexEntryRepository"></param> /// <param name="viewTemplate"></param> public GatherBySemanticDomainTask(string semanticDomainsQuestionFileName, LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate) : this(GatherBySemanticDomainConfig.CreateForTests(semanticDomainsQuestionFileName), lexEntryRepository, viewTemplate) { }
public LexicalFormSorter (ViewTemplate viewTemplate) { _viewTemplate = viewTemplate; }
public LexExampleSentenceLayouter(DetailList parentDetailList, int parentRow, ViewTemplate viewTemplate, IServiceProvider serviceProvider, LexExampleSentence exampleToLayout) : base(parentDetailList, parentRow, viewTemplate, null, serviceProvider, exampleToLayout) { }
public LexSenseLayouter(DetailList parentDetailList, int parentRow, ViewTemplate viewTemplate, LexEntryRepository lexEntryRepository, IServiceProvider serviceProvider, LexSense senseToLayout) : base(parentDetailList, parentRow, viewTemplate, lexEntryRepository, serviceProvider, senseToLayout) { }