public static string ConnectionString(EnvironmentType environmentType, string prefix, ConnectionStringInfos connectionStringInfos, DataSources dataSources) { var connectionStringInfo = connectionStringInfos.FirstOrDefault(c => prefix.Contains(c.Namespace) && c.EnvironmentType == environmentType); if (connectionStringInfo != null) { return(connectionStringInfo.ConnectionString); } var dataSource = dataSources.FirstOrDefault(d => d.MachineId == Environment.MachineName)?.TheDataSource ?? "./SQLEXPRESS"; switch (environmentType) { case EnvironmentType.UnitTest: return(ConnectionString(dataSource, prefix + ".UnitTest")); case EnvironmentType.Qualification: return(ConnectionString(dataSource, prefix + ".Test")); case EnvironmentType.Production: return(ConnectionString(dataSource, prefix)); default: throw new NotImplementedException("Unknown environment."); } }
private void OnEditDataSource(object sender, EventArgs e) { var dataSourceNode = DataTree.SelectedNode; if (dataSourceNode != null) { var dataSourceInfo = DataSources.FirstOrDefault(i => i.Name == dataSourceNode.Name); if (dataSourceInfo != null) { _dataSourceDialog.DataSourceInfo = dataSourceInfo; if (_dataSourceDialog.ShowDialog(this) == DialogResult.OK) { var newDataSourceInfo = _dataSourceDialog.DataSourceInfo; DataSources.Replace(dataSourceInfo, newDataSourceInfo); UpdateDataSourceNode(newDataSourceInfo, dataSourceNode); InvokeDataSourceChanged(dataSourceInfo, newDataSourceInfo); } } } }
private void LoadTFSCSV() { frmLoginSendHaxCom oLogin = new frmLoginSendHaxCom { LoginURL = TimeKeeperBaseURL }; oLogin.openMode = frmLoginSendHaxCom.OpenMode.Search; oLogin.optDays.Enabled = false; oLogin.optSel.Enabled = false; if (oLogin.ShowDialog() == DialogResult.OK) { List <WorkItemsDay> oItems = new List <WorkItemsDay>(); List <CsvReg> regs = getHaxComTFSTime(oLogin.PHPSession, dtpFrom.Value, DateTime.Today, oLogin.chkAll.Checked, (oLogin.CHKBug.Checked || oLogin.chkPBI.Checked || oLogin.chkOther.Checked), oLogin.chkMeeting.Checked, oLogin.chkPrjtLess.Checked, oLogin.chkNonBillable.Checked, oLogin.chkCapitalized.Checked); var oDataSource = oDataSources.First(x => x.Type == Datasourcetype.TFS); var outlookDataSource = oDataSources.FirstOrDefault(x => x.Type == Datasourcetype.Outlook); //gets rest of TFS data using the TFS IDS var tfsItems = WorkItemMapper.GetHistoricalWorkitemsByIDs(oDataSource.ServerUrl, oDataSource.ProjectName, oDataSource.User, regs.Select(x => x.TFSId).Distinct()); //assembles the listview foreach (DateTime dDate in regs.Select(x => x.Date).Distinct()) { var oTemp = new WorkItemsDay(dDate); foreach (CsvReg oReg in regs.Where(x => x.Date == dDate)) { if (oReg.TFSId == 0) //meetings { var oWI = new WorkItemHours(); oWI.HaxComID = oReg.EntryID; oWI.ID = "meeting"; oWI.ProjectId = 0; oWI.ClientId = 166; oWI.SubClientId = 5; oWI.Function = 41; //dev meeting oWI.Description = oReg.Title; oWI.Title = oReg.Title; oWI.FromDatasource = outlookDataSource; oWI.BillingType = BillingType.Capitalized; oWI.HaxComHours = oReg.Hours; oTemp.WorkItems.Add(oWI); } else { var oTFSI = tfsItems.FirstOrDefault(x => x.ID == oReg.TFSId.ToString()); if (oTFSI != null) { string sType = oTFSI.Type.ToUpperInvariant(); if (oLogin.chkAll.Checked || (sType == "BUG" && oLogin.CHKBug.Checked) || (sType == "USER STORY" && oLogin.chkPBI.Checked) || (sType != "BUG" && sType != "PRODUCT BACKLOG ITEM" && oLogin.chkOther.Checked)) { oTemp.WorkItems.Add(WorkItemToWIHours(oTFSI, oReg.EntryID, oDataSource, oReg.Hours)); } } } } oItems.Add(oTemp); } UpdateListview(oItems, false); } }
/// <summary> /// 删除数据源 /// </summary> /// <param name="id">数据源ID</param> public void DeleteDataSource(string id) { var deleteObj = DataSources.FirstOrDefault(i => i.Name == id); if (deleteObj != null) { DataSources.Remove(deleteObj); } this.SaveChanges(); }
private void Handle(FeedDataSourceUnsubscribedEvent evt) { if (UserId != evt.UserId) { throw new DomainException(Global.UserNotAuthorizedToUnSubscribe); } var datasource = DataSources.FirstOrDefault(d => d.DatasourceId == evt.DataSourceId); if (datasource == null) { throw new DomainException(string.Format(Global.DataSourceDoesntExist, evt.DataSourceId)); } DataSources.Remove(datasource); UpdateDateTime = evt.DeletionDateTime; Version = evt.Version; }
private void OnDeleteDataSource(object sender, EventArgs e) { var dataSourceNode = DataTree.SelectedNode; if (dataSourceNode != null) { var dataSourceInfo = DataSources.FirstOrDefault(i => i.Name == dataSourceNode.Name); if (dataSourceInfo != null) { if (Resources.DeleteDataSourceQuestion.ShowQuestion(dataSourceNode.Name)) { DataSources.Remove(dataSourceInfo); dataSourceNode.Remove(); InvokeDataSourceDeleted(dataSourceInfo); } } } }
private void OnMoveDown(object sender, EventArgs e) { var selectedNode = DataTree.SelectedNode; if (IsDataSourceNode(selectedNode)) { var dataSourceInfo = DataSources.FirstOrDefault(i => i.Name == selectedNode.Name); DataSources.MoveDown(dataSourceInfo); } else if (IsParameterNode(selectedNode)) { var parameterInfo = Parameters.FirstOrDefault(i => i.Name == selectedNode.Name); Parameters.MoveDown(parameterInfo); } else if (IsTotalNode(selectedNode)) { var totalInfo = Totals.FirstOrDefault(i => i.Name == selectedNode.Name); Totals.MoveDown(totalInfo); } selectedNode.MoveDown(); }
private void SelectDataSourceProperty(Control propertyEditor) { if (DataSources != null) { var selectedDataSourceName = DataSourceEdit.Text; if (string.IsNullOrWhiteSpace(selectedDataSourceName) == false) { var selectedDataSource = DataSources.FirstOrDefault(ds => ds.Name == selectedDataSourceName); if (selectedDataSource != null) { _propertySelectForm.View.DataSourceName = selectedDataSourceName; _propertySelectForm.View.DataSourceSchema = selectedDataSource.Schema; _propertySelectForm.View.DataSourceProperty = propertyEditor.Text; if (_propertySelectForm.ShowDialog(this) == DialogResult.OK) { propertyEditor.Text = _propertySelectForm.View.DataSourceProperty; } } } } }
/// <summary> /// 获取数据源 /// </summary> /// <param name="id">数据源ID</param> /// <returns>数据源</returns> public DataSource GetDataSource(string id) { return(DataSources.FirstOrDefault(i => i.Name == id)); }