private Color GetOrganismColor(OrganismType o) { var r = 0; var g = 0; var b = 0; if (o == OrganismType.GRASS) { r = Rando.Next(50) + 10; g = Rando.Next(100) + 150; b = Rando.Next(50) + 10; } if (o == OrganismType.DEER) { r = Rando.Next(150) + 50; g = Rando.Next(75) + 20; b = Rando.Next(30) + 5; } if (o == OrganismType.WOLF) { r = Rando.Next(10) + 240; g = Rando.Next(10) + 240; b = Rando.Next(10) + 240; } return new Color(r,g,b); }
public void DeleteOrganismType(OrganismType organismTypeToBeDeleted) { //Validate Input if (organismTypeToBeDeleted == null) { throw (new ArgumentNullException("organismTypeToBeDeleted")); } // Validate Primary key value if (organismTypeToBeDeleted.OrganismTypeID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("OrganismTypeID"); } OnOrganismTypeSaving(organismTypeToBeDeleted); OnOrganismTypeDeleting(organismTypeToBeDeleted); if (organismTypeToBeDeleted.EntityState == EntityState.Detached) { _DatabaseContext.OrganismTypes.Attach(organismTypeToBeDeleted); } _DatabaseContext.OrganismTypes.DeleteObject(organismTypeToBeDeleted); int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No OrganismType deleted!"); } OnOrganismTypeDeleted(organismTypeToBeDeleted); OnOrganismTypeSaved(organismTypeToBeDeleted); }
public void DeleteOrganismTypes(List <int> organismTypeIDsToDelete) { //Validate Input foreach (int organismTypeID in organismTypeIDsToDelete) { if (organismTypeID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("OrganismTypeID"); } } List <OrganismType> organismTypesToBeDeleted = new List <OrganismType>(); foreach (int organismTypeID in organismTypeIDsToDelete) { OrganismType organismType = new OrganismType { OrganismTypeID = organismTypeID }; _DatabaseContext.OrganismTypes.Attach(organismType); _DatabaseContext.OrganismTypes.DeleteObject(organismType); organismTypesToBeDeleted.Add(organismType); OnOrganismTypeDeleting(organismType); } int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows != organismTypeIDsToDelete.Count) { throw new DataNotUpdatedException("One or more organismType records have not been deleted."); } foreach (OrganismType organismTypeToBeDeleted in organismTypesToBeDeleted) { OnOrganismTypeDeleted(organismTypeToBeDeleted); } }
public virtual int CreateNewOrganismType(OrganismType newOrganismType) { // Validate Parameters if (newOrganismType == null) { throw (new ArgumentNullException("newOrganismType")); } // Apply business rules OnOrganismTypeSaving(newOrganismType); OnOrganismTypeCreating(newOrganismType); _DatabaseContext.OrganismTypes.AddObject(newOrganismType); int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No organismType created!"); } // Apply business workflow OnOrganismTypeCreated(newOrganismType); OnOrganismTypeSaved(newOrganismType); return(newOrganismType.OrganismTypeID); }
public void UpdateOrganismType(OrganismType updatedOrganismType) { // Validate Parameters if (updatedOrganismType == null) { throw (new ArgumentNullException("updatedOrganismType")); } // Validate Primary key value if (updatedOrganismType.OrganismTypeID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("OrganismTypeID"); } // Apply business rules OnOrganismTypeSaving(updatedOrganismType); OnOrganismTypeUpdating(updatedOrganismType); //attaching and making ready for parsistance if (updatedOrganismType.EntityState == EntityState.Detached) { _DatabaseContext.OrganismTypes.Attach(updatedOrganismType); } _DatabaseContext.ObjectStateManager.ChangeObjectState(updatedOrganismType, System.Data.EntityState.Modified); //this line makes the code un-testable! int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No organismType updated!"); } //Apply business workflow OnOrganismTypeUpdated(updatedOrganismType); OnOrganismTypeSaved(updatedOrganismType); }
protected void FormViewOrganismType_ItemUpdating(object sender, FormViewUpdateEventArgs e) { TextBox txtOrganismType = (TextBox)formViewOrganismType.FindControl("txtOrganismType"); OrganismTypeActionStatus status = Validate(txtOrganismType.Text, actionType.update); if (status == OrganismTypeActionStatus.Success) { Type myType = (typeof(OrganismType)); PropertyInfo[] props = myType.GetProperties(); string[] arrNewValues = new string[e.NewValues.Keys.Count]; e.NewValues.Keys.CopyTo(arrNewValues, 0); OrganismTypeBLL organismTypeBLL = new OrganismTypeBLL(); OrganismType organismType = organismTypeBLL.GetOrganismTyeByOrganismTypeId2((int)e.Keys["OrganismTypeId"]); foreach (var prop in props) { if (("System.String,System.Int,System.DateTime,System.Guid").IndexOf((prop.PropertyType).FullName) >= 0) // Si la propiedad es de tipo Guid, String, Int o DateTime { if (!arrNewValues.Contains(prop.Name)) { e.NewValues[prop.Name] = prop.GetValue(organismType, null); } } } } else { ltlMessage.Text = MessageFormatter.GetFormattedErrorMessage(GetErrorMessage(status)); e.Cancel = true; } }
public Organism(OrganismType type, int[,] m, int error, int age) { Type = type; Error = error; Age = age; Matrix = SwarmIntSolver.DuplicateMatrix(m); }
/// <remarks/> public System.IAsyncResult BeginGetTopAnimals(string version, OrganismType tat, int num, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("GetTopAnimals", new object[] { version, tat, num}, callback, asyncState); }
public Organism(OrganismType type, int[,] m, int error, int age) { Type = type; Error = error; Age = age; Matrix = MatrixHelper.DuplicateMatrix(m); }
public string GetOrganismTypeName(int organismTypeID) { OrganismTypeBLL organismTypeBLL = new OrganismTypeBLL(); OrganismType organismType = organismTypeBLL.GetOrganismTypeByOrganismTypeID(organismTypeID); return(organismType.OrganismTypeName); }
/*Notes - * DefineChromosomeLength - Should be run first to define the length since the next method assumes that the length was already defined (DefineChromosomePositions). * */ #region Constructor /// <summary> /// The default nChr is 3 and the organism type is drosophila /// </summary> /// <param name="_nChr"></param> /// <param name="_type"></param> public DataGeneratorPresentor(int _nChr = 3, OrganismType _type = OrganismType.Drosophila) { go = new GenomeOrganization(); nChr = _nChr; type = _type; database = DatabaseProvider.GetDatabase(); database.GenomeOrganization = go; }
/// <remarks/> public System.IAsyncResult BeginGetTopAnimals(string version, OrganismType tat, int num, System.AsyncCallback callback, object asyncState) { return(this.BeginInvoke("GetTopAnimals", new object[] { version, tat, num }, callback, asyncState)); }
public DataSet GetTopAnimals(string version, OrganismType tat, int num) { if ( num == 0 ) { num = 3; } return ChartBuilder.GetTopAnimals(version, tat, num); }
public System.Data.DataSet GetTopAnimals(string version, OrganismType tat, int num) { object[] results = this.Invoke("GetTopAnimals", new object[] { version, tat, num }); return((System.Data.DataSet)(results[0])); }
public DataSet GetTopAnimals(string version, OrganismType tat, int num) { if (num == 0) { num = 3; } return(ChartBuilder.GetTopAnimals(version, tat, num)); }
public Organism(OrganismType organismType, string firstName, string secondName, string latFirstName, string latSecondName, Colour colour) { OrganismType = organismType; FirstName = firstName; SecondName = secondName; LatFirstName = latFirstName; LatSecondName = latSecondName; Colour = colour; this.Photos = new List <Photo>(); }
/// <remarks/> public void GetTopAnimalsAsync(string version, OrganismType tat, int num, object userState) { if ((this.GetTopAnimalsOperationCompleted == null)) { this.GetTopAnimalsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetTopAnimalsOperationCompleted); } this.InvokeAsync("GetTopAnimals", new object[] { version, tat, num }, this.GetTopAnimalsOperationCompleted, userState); }
public OrganismType GetOrganismTyeByOrganismTypeId2(int organismTypeID) { //Validate Input if (organismTypeID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("organismTyepID"); } OrganismType organismType = (_DatabaseContext.OrganismTypes.FirstOrDefault(instance => instance.OrganismTypeID == organismTypeID)); var ass = organismType.OrganismTypeName; return(organismType); }
public ActionResult Edit(OrganismType obj) { try { if (ModelState.IsValid) { dbActionResult resultAction = new dbActionResult(); resultAction = db.EditOrganismType(obj); int id = resultAction.intResult; if (id >= 0) { return(RedirectToAction("Index")); } if (id == -1) { db.DetachOrganismType(obj); OrganismType oldObj = db.GetOrganismType(obj.OrganismTypeID); ModelState.AddModelError("", "Ошибка параллельного доступа к данным. Если проблема повторится, обратитесь к системному администратору."); if (oldObj.Code != obj.Code) { ModelState.AddModelError("Code", "Текущее значение: " + oldObj.Code.ToString()); } if (oldObj.DescriptionEng != obj.DescriptionEng) { ModelState.AddModelError("DescriptionEng", "Текущее значение: " + oldObj.DescriptionEng.ToString()); } if (oldObj.DescriptionRus.ToString() != obj.DescriptionRus.ToString()) { ModelState.AddModelError("DescriptionRus", "Текущее значение: " + oldObj.DescriptionRus.ToString()); } obj.Timestamp = oldObj.Timestamp; } if (id == -2) { ModelState.AddModelError("", resultAction.exData.Message.ToString() + " | " + resultAction.exData.GetType().ToString() + " | " + "Невозможно сохранить изменения. Нажмите обновить страницу и повторить действия. Если проблема повторится, обратитесь к системному администратору."); } } } catch (DataException ex) { ModelState.AddModelError("", ex.Message.ToString() + " | " + ex.GetType().ToString() + " | " + "Невозможно сохранить изменения. Попробуйте повторить действия. Если проблема повторится, обратитесь к системному администратору."); } return(View(obj)); }
public ActionResult Create(OrganismType obj) { try { if (ModelState.IsValid) { int id = db.AddOrganismType(obj); return(RedirectToAction("Index")); } } catch (DataException ex) { ModelState.AddModelError("", ex.Message.ToString() + " Невозможно сохранить изменения. Попробуйте повторить действия. Если проблема повторится, обратитесь к системному администратору."); } return(RedirectToAction("Index")); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as TargetComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Target != null) { dest.Target = (Hl7.Fhir.Model.Identifier)Target.DeepCopy(); } if (Type != null) { dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy(); } if (Interaction != null) { dest.Interaction = (Hl7.Fhir.Model.CodeableConcept)Interaction.DeepCopy(); } if (Organism != null) { dest.Organism = (Hl7.Fhir.Model.CodeableConcept)Organism.DeepCopy(); } if (OrganismType != null) { dest.OrganismType = (Hl7.Fhir.Model.CodeableConcept)OrganismType.DeepCopy(); } if (Amount != null) { dest.Amount = (Hl7.Fhir.Model.DataType)Amount.DeepCopy(); } if (AmountType != null) { dest.AmountType = (Hl7.Fhir.Model.CodeableConcept)AmountType.DeepCopy(); } if (Source != null) { dest.Source = new List <Hl7.Fhir.Model.ResourceReference>(Source.DeepCopy()); } return(dest); }
private static void addTopOrganisms(OrganismType organismType, StringBuilder buffer) { DataSet dataSet = ChartBuilder.GetTopAnimals(ServerSettings.LatestVersion, organismType, 10); buffer.Append("<span class=\"SubTitle\">" + organismType + "</span>"); buffer.Append("<ol type=\"1\" class=\"CritterList\">"); if (dataSet != null) { if (dataSet.Tables.Contains("Species")) { DataTable speciesTable = dataSet.Tables["Species"]; foreach (DataRow row in speciesTable.Rows) { buffer.Append("<li>"); buffer.Append(Convert.ToString(row["Name"]) + " (" + Convert.ToString(row["Population"]) + ")"); buffer.Append("</li>"); } } } buffer.Append("</ol>"); buffer.Append("</span>"); }
private void addToDbButton_Click(object sender, EventArgs e) { // Get the values from the form, lowecase everything, create the instance of Organism OrganismType organismType = (OrganismType)organismTypeComboBox.SelectedItem; string firstName = firstNameTextBox.Text.Trim().ToLower(); string secondName = secondNameTextBox.Text.Trim().ToLower(); string latFirstName = latFirstNameTextBox.Text.Trim().ToLower(); string latSecondName = latSecondNameTextBox.Text.Trim().ToLower(); Colour colour = (Colour)colourComboBox.SelectedItem; _tryOrganism = new Organism(organismType, firstName, secondName, latFirstName, latSecondName, colour); // Add to ThreadPool task to TryAddPerson Task.Run(() => TryAddOrganismLocking(_tryOrganism)); // Reset the form firstNameTextBox.Text = ""; secondNameTextBox.Text = ""; latFirstNameTextBox.Text = ""; latSecondNameTextBox.Text = ""; }
protected void FormViewOrganism_ItemUpdating(object sender, FormViewUpdateEventArgs e) { TextBox txtCommonName = (TextBox)formViewOrganism.FindControl("txtCommonName"); TextBox txtScientificName = (TextBox)formViewOrganism.FindControl("txtScientificName"); DropDownList ddlOrganismType = (DropDownList)formViewOrganism.FindControl("ddlOrganismType"); OrganismActionStatus status = Validate(txtCommonName.Text, txtScientificName.Text, Convert.ToInt32(ddlOrganismType.SelectedValue), actionType.update); if (status == OrganismActionStatus.Success) { Type myType = (typeof(Organism)); PropertyInfo[] props = myType.GetProperties(); string[] arrNewValues = new string[e.NewValues.Keys.Count]; e.NewValues.Keys.CopyTo(arrNewValues, 0); OrganismBLL organismBLL = new OrganismBLL(); OrganismTypeBLL organismTypeBLL = new OrganismTypeBLL(); OrganismType organismType = organismTypeBLL.GetOrganismTypeByOrganismTypeID(Convert.ToInt32(ddlOrganismType.SelectedValue)); Organism organism = organismBLL.GetOrganismByOrganismId2((int)e.Keys["OrganismId"]); foreach (var prop in props) { if (("System.String,System.Int32,System.Int,System.DateTime,System.Guid").IndexOf((prop.PropertyType).FullName) >= 0) // Si la propiedad es de tipo Guid, String, Int o DateTime { if (!arrNewValues.Contains(prop.Name)) { e.NewValues[prop.Name] = prop.GetValue(organism, null); } } } e.NewValues["OrganismTypeID"] = organismType.OrganismTypeID; Page.RouteData.Values["organismtype_id"] = organismType.OrganismTypeID.ToString(); } else { ltlMessage.Text = MessageFormatter.GetFormattedErrorMessage(GetErrorMessage(status)); e.Cancel = true; } }
/* * Member: GetTopAnimals * Purpose: This class get the n top animal of a specific organism * classification from the database and returns their information as * a DataSet */ public static DataSet GetTopAnimals(string version, OrganismType organismType, int count) { version = new Version(version).ToString(3); using (SqlConnection myConnection = new SqlConnection(ServerSettings.SpeciesDsn)) { myConnection.Open(); using (SqlCommand command = new SqlCommand("TerrariumTopAnimals", myConnection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Count", count); command.Parameters.AddWithValue("@Version", version); command.Parameters.AddWithValue("@SpeciesType", organismType.ToString()); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { DataSet tempData = new DataSet(); adapter.Fill(tempData, "Species"); return(tempData); } } } }
/* Member: GetTopAnimals Purpose: This class get the n top animal of a specific organism classification from the database and returns their information as a DataSet */ public static DataSet GetTopAnimals(string version, OrganismType organismType, int count) { version = new Version(version).ToString(3); using(SqlConnection myConnection = new SqlConnection(ServerSettings.SpeciesDsn)) { myConnection.Open(); SqlCommand command = new SqlCommand( "TerrariumTopAnimals", myConnection ); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add( "@Count", count ); command.Parameters.Add( "@Version", version ); command.Parameters.Add( "@SpeciesType", organismType.ToString() ); SqlDataAdapter adapter = new SqlDataAdapter(command); DataSet tempData = new DataSet(); adapter.Fill(tempData, "Species"); myConnection.Close(); return tempData; } }
private static void addTopOrganisms(OrganismType organismType, StringBuilder buffer) { DataSet dataSet = ChartBuilder.GetTopAnimals(ServerSettings.LatestVersion, organismType, 10); buffer.Append("<span class=\"SubTitle\">" + organismType + "</span>"); buffer.Append("<ol type=\"1\" class=\"CritterList\">"); if (dataSet != null) { if (dataSet.Tables.Contains("Species")) { DataTable speciesTable = dataSet.Tables["Species"]; foreach (DataRow row in speciesTable.Rows) { buffer.Append("<li>"); buffer.Append(Convert.ToString(row["Name"]) + " (" + Convert.ToString(row["Population"]) + ")"); buffer.Append("</li>"); } } } buffer.Append("</ol>"); buffer.Append("</span>"); }
public System.Data.DataSet GetTopAnimals(string version, OrganismType tat, int num) { object[] results = this.Invoke("GetTopAnimals", new object[] { version, tat, num}); return ((System.Data.DataSet)(results[0])); }
partial void OnOrganismTypeDeleting(OrganismType organismType);
/// <remarks/> public void GetTopAnimalsAsync(string version, OrganismType tat, int num) { this.GetTopAnimalsAsync(version, tat, num, null); }
public IEnumerable<object> GetTopAnimals(string version, OrganismType tat, int num) { return null; }
partial void OnOrganismTypeUpdating(OrganismType organismType);
partial void OnOrganismTypeUpdated(OrganismType organismType);
/// <summary> /// Deprecated Method for adding a new object to the OrganismTypes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToOrganismTypes(OrganismType organismType) { base.AddObject("OrganismTypes", organismType); }
/// <remarks/> public void GetTopAnimalsAsync(string version, OrganismType tat, int num) { this.GetTopAnimalsAsync(version, tat, num, null); }
/// <remarks/> public void GetTopAnimalsAsync(string version, OrganismType tat, int num, object userState) { if ((this.GetTopAnimalsOperationCompleted == null)) { this.GetTopAnimalsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetTopAnimalsOperationCompleted); } this.InvokeAsync("GetTopAnimals", new object[] { version, tat, num}, this.GetTopAnimalsOperationCompleted, userState); }
/// <summary> /// Serialize to a JSON object /// </summary> public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } ((fhirCsR4.Models.BackboneElement) this).SerializeJson(writer, options, false); if (Target != null) { writer.WritePropertyName("target"); Target.SerializeJson(writer, options); } if (Type != null) { writer.WritePropertyName("type"); Type.SerializeJson(writer, options); } if (Interaction != null) { writer.WritePropertyName("interaction"); Interaction.SerializeJson(writer, options); } if (Organism != null) { writer.WritePropertyName("organism"); Organism.SerializeJson(writer, options); } if (OrganismType != null) { writer.WritePropertyName("organismType"); OrganismType.SerializeJson(writer, options); } if (AmountQuantity != null) { writer.WritePropertyName("amountQuantity"); AmountQuantity.SerializeJson(writer, options); } if (AmountRange != null) { writer.WritePropertyName("amountRange"); AmountRange.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(AmountString)) { writer.WriteString("amountString", (string)AmountString !); } if (_AmountString != null) { writer.WritePropertyName("_amountString"); _AmountString.SerializeJson(writer, options); } if (AmountType != null) { writer.WritePropertyName("amountType"); AmountType.SerializeJson(writer, options); } if ((Source != null) && (Source.Count != 0)) { writer.WritePropertyName("source"); writer.WriteStartArray(); foreach (Reference valSource in Source) { valSource.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
partial void OnOrganismTypeDeleted(OrganismType organismType);
partial void OnOrganismTypeSaved(OrganismType organismType);