public void GenerateIncidence(long valId, DateTime date, string desc) { Validation val = _repo.GetPendingValidations(valId); Incidence incidence = new Incidence { IssueDate = date, Description = desc, Service = val.Service, ServiceID = val.ServiceID, Solved = false, Comments = new List <Comment>() }; val.Incidences.Add(incidence); _repo.InsertOrUpdate(incidence); _repo.InsertOrUpdate(val); }
private static void sortIncidences(List <Incidence> incidences, int j) { if (incidences != null) { int max = incidences[j].importance; for (int i = j + 1; i < incidences.Count && max < IMPORTANCE_CRITICAL; i++) { if (incidences[i].importance > max) { max = incidences[i].importance; Incidence temp = incidences[j]; incidences.RemoveAt(j); incidences.Insert(j, incidences[i]); incidences.Insert(i, temp); } } } }
public Incidence UpdateIncidence(Incidence incidence) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("incidenceId", incidence.Id); parameters.Add("date", incidence.Date); parameters.Add("latitude", incidence.Latitude); parameters.Add("longitude", incidence.Longitude); parameters.Add("message", incidence.Message); parameters.Add("orderId", incidence.OrderId); var result = connection.Execute("sp_update_incidence", param: parameters, commandType: CommandType.StoredProcedure); return(result > 0 ? incidence : new Incidence()); } }
internal async void InsertOrUpdate(Incidence incidence) { await using var db = new TimeBankContext(); var query = (from i in db.Incidences where i.ID == incidence.ID select i).FirstOrDefault(); if (query == null) { db.Incidences.Add(incidence); } else { query.Service = incidence.Service; query.ServiceID = incidence.ServiceID; query.Solved = incidence.Solved; query.Description = incidence.Description; query.Comments = incidence.Comments ?? new List <Comment>(); } await db.SaveChangesAsync(); }
public async Task <ActionResult> Create([Bind(Include = "Id,name,description")] Incidence incidence, string dnis) { if (ModelState.IsValid) { Client client = await db.Clients.Where(b => b.DNI == dnis).FirstOrDefaultAsync(); if (client != null) { db.Entry(client).State = EntityState.Modified; Incidence i = new Incidence(incidence.Id, incidence.name, incidence.description, client); db.Incidences.Add(i); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } } return(View(incidence)); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as MedicinalProductInteraction; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Subject != null) { dest.Subject = new List <Hl7.Fhir.Model.ResourceReference>(Subject.DeepCopy()); } if (DescriptionElement != null) { dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy(); } if (Interactant != null) { dest.Interactant = new List <Hl7.Fhir.Model.MedicinalProductInteraction.InteractantComponent>(Interactant.DeepCopy()); } if (Type != null) { dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy(); } if (Effect != null) { dest.Effect = (Hl7.Fhir.Model.CodeableConcept)Effect.DeepCopy(); } if (Incidence != null) { dest.Incidence = (Hl7.Fhir.Model.CodeableConcept)Incidence.DeepCopy(); } if (Management != null) { dest.Management = (Hl7.Fhir.Model.CodeableConcept)Management.DeepCopy(); } return(dest); }
public bool Equals(Incidence graph) { if (graph._nodes.Count != _nodes.Count || graph._arcs.Count != _arcs.Count) { return(false); } foreach (INode node in _nodes) { if (!graph._nodes.Contains(node)) { return(false); } } foreach (IArc arc in _arcs) { if (!graph._arcs.Contains(arc)) { return(false); } } return(true); }
public Incidence SaveIncidence(Incidence incidence) { using (IDbConnection connection = new SqlConnection(ConnectionRepository.GetConnectionString())) { connection.Open(); var parameters = new DynamicParameters(); parameters.Add("date", incidence.Date); parameters.Add("latitude", incidence.Latitude); parameters.Add("longitude", incidence.Longitude); parameters.Add("message", incidence.Message); parameters.Add("orderId", incidence.OrderId); parameters.Add("incidenceId", 0); connection.ExecuteScalar("sp_add_incidence", param: parameters, commandType: CommandType.StoredProcedure); var incidenceId = parameters.Get <Int32>("incidenceId"); incidence.Id = incidenceId; return(incidence); } }
//private int n; // Use this for initialization void Start() { //Enabled = true; /*switch (type) { * case ObjectType.Banana: * throwObj = Resources.Load("Prefabs/fruit_banana") as GameObject; * break; * case ObjectType.Strawberry: * throwObj = Resources.Load("Prefabs/fruit_strawberry") as GameObject; * break; * case ObjectType.Money: * throwObj = Resources.Load("Prefabs/money_koban") as GameObject; * break; * case ObjectType.Rock: * throwObj = Resources.Load("Prefabs/rock") as GameObject; * break; * case ObjectType.Table: * throwObj = Resources.Load("Prefabs/table_chabudai") as GameObject; * break; * }*/ throwObjects = new List <GameObject>(); throwObjects.Add(Resources.Load("Prefabs/drink_taru") as GameObject); throwObjects.Add(Resources.Load("Prefabs/fruit_banana") as GameObject); throwObjects.Add(Resources.Load("Prefabs/rock") as GameObject); throwObjects.Add(Resources.Load("Prefabs/table_chabudai") as GameObject); throwObjects.Add(Resources.Load("Prefabs/fruit_strawberry") as GameObject); throwObjects.Add(Resources.Load("Prefabs/money_koban") as GameObject); incidenceList = Incidence.GetIncidenceDistributionList(incidence); //Debug.Log(incidenceList); timeElapsed = 0.0f; wait_real = wait; shake_width = 1.0f; //n = 0; //StartCoroutine(GenerateObject()); }
public Incidence UpdateIncidence(Incidence incidence) { IIncidenceRepository repository = new IncidenceRepository(); return(repository.UpdateIncidence(incidence)); }
public Incidence SaveIncidence(Incidence incidence) { IIncidenceRepository repository = new IncidenceRepository(); return(repository.SaveIncidence(incidence)); }
public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { if (qName.Equals("game-descriptor")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("versionNumber")) { adventureData.setVersionNumber(entry.Value.ToString()); } } } if (qName.Equals("configuration")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("keepShowing")) { adventureData.setKeepShowing(entry.Value.ToString().Equals("yes")); } if (entry.Key.Equals("keyboard-navigation")) { adventureData.setKeyboardNavigation(entry.Value.ToString().Equals("enabled")); } if (entry.Key.Equals("defaultClickAction")) { if (entry.Value.ToString().Equals("showDetails")) { adventureData.setDeafultClickAction(DescriptorData.DefaultClickAction.SHOW_DETAILS); } if (entry.Value.ToString().Equals("showActions")) { adventureData.setDeafultClickAction(DescriptorData.DefaultClickAction.SHOW_ACTIONS); } } if (entry.Key.Equals("perspective")) { if (entry.Value.ToString().Equals("regular")) { adventureData.setPerspective(DescriptorData.Perspective.REGULAR); } if (entry.Value.ToString().Equals("isometric")) { adventureData.setPerspective(DescriptorData.Perspective.ISOMETRIC); } } if (entry.Key.Equals("dragBehaviour")) { if (entry.Value.ToString().Equals("considerNonTargets")) { adventureData.setDragBehaviour(DescriptorData.DragBehaviour.CONSIDER_NON_TARGETS); } if (entry.Value.ToString().Equals("ignoreNonTargets")) { adventureData.setDragBehaviour(DescriptorData.DragBehaviour.IGNORE_NON_TARGETS); } } } } // If reading a title, empty the current string if (qName.Equals("title") || qName.Equals("description")) { currentstring = string.Empty; } if (qName.EndsWith("automatic-commentaries")) { adventureData.setCommentaries(true); } // If reading the GUI tag, store the settings if (qName.Equals("gui")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { if (entry.Value.ToString().Equals("traditional")) { adventureData.setGUIType(DescriptorData.GUI_TRADITIONAL); } else if (attrs["type"].Equals("contextual")) { adventureData.setGUIType(DescriptorData.GUI_CONTEXTUAL); } } if (entry.Key.Equals("customized")) { if (entry.Value.ToString().Equals("yes")) { adventureData.setGUI(adventureData.getGUIType(), true); } else { adventureData.setGUI(adventureData.getGUIType(), false); } } if (entry.Key.Equals("inventoryPosition")) { if (entry.Value.ToString().Equals("none")) { adventureData.setInventoryPosition(DescriptorData.INVENTORY_NONE); } else if (entry.Value.ToString().Equals("top_bottom")) { adventureData.setInventoryPosition(DescriptorData.INVENTORY_TOP_BOTTOM); } else if (entry.Value.ToString().Equals("top")) { adventureData.setInventoryPosition(DescriptorData.INVENTORY_TOP); } else if (entry.Value.ToString().Equals("bottom")) { adventureData.setInventoryPosition(DescriptorData.INVENTORY_BOTTOM); } else if (entry.Value.ToString().Equals("fixed_top")) { adventureData.setInventoryPosition(DescriptorData.INVENTORY_FIXED_TOP); } else if (entry.Value.ToString().Equals("fixed_bottom")) { adventureData.setInventoryPosition(DescriptorData.INVENTORY_FIXED_BOTTOM); } } } } //Cursor if (qName.Equals("cursor")) { string type = ""; string uri = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } else if (entry.Key.Equals("uri")) { uri = entry.Value.ToString(); } } adventureData.addCursor(type, uri); } //Button if (qName.Equals("button")) { string type = ""; string uri = ""; string action = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } else if (entry.Key.Equals("uri")) { uri = entry.Value.ToString(); } else if (entry.Key.Equals("action")) { action = entry.Value.ToString(); } } adventureData.addButton(action, type, uri); } if (qName.Equals("arrow")) { string type = ""; string uri = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } else if (entry.Key.Equals("uri")) { uri = entry.Value.ToString(); } } adventureData.addArrow(type, uri); } // If reading the mode tag: if (qName.Equals("mode")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("playerTransparent")) { if (entry.Value.ToString().Equals("yes")) { adventureData.setPlayerMode(DescriptorData.MODE_PLAYER_1STPERSON); } else if (entry.Value.ToString().Equals("no")) { adventureData.setPlayerMode(DescriptorData.MODE_PLAYER_3RDPERSON); } } } } if (qName.Equals("graphics")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("mode")) { if (entry.Value.ToString().Equals("windowed")) { adventureData.setGraphicConfig(DescriptorData.GRAPHICS_WINDOWED); } else if (entry.Value.ToString().Equals("fullscreen")) { adventureData.setGraphicConfig(DescriptorData.GRAPHICS_FULLSCREEN); } else if (entry.Value.ToString().Equals("blackbkg")) { adventureData.setGraphicConfig(DescriptorData.GRAPHICS_BLACKBKG); } } } } // If reading the contents tag, switch to the chapters mode else if (qName.Equals("contents")) { reading = READING_CHAPTER; } // If reading the contents of a chapter, create a new one to store the data else if (qName.Equals("chapter")) { // Create the chapter currentChapter = new Chapter(); // Search and store the path of the file string chapterPath = null; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("path")) { chapterPath = entry.Value.ToString(); } } if (chapterPath != null) { currentChapter.setChapterPath(chapterPath); } else { currentChapter.setChapterPath(""); } // Open the file and load the data try { // Set the chapter handler // ChapterHandler chapterParser = new ChapterHandler(isCreator, currentChapter); ChapterHandler_ chapterParser = new ChapterHandler_(currentChapter); Debug.Log(currentChapter.getBooks().Count); //// Create a new factory //SAXParserFactory factory = SAXParserFactory.newInstance(); ////factory.setValidating( validate ); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); //// Set the input stream with the file //InputStream chapterIS = isCreator.buildInputStream(chapterPath); //// Parse the data and close the data //saxParser.parse(chapterIS, chapterParser); //chapterIS.close(); string chapterIS = isCreator.buildInputStream(chapterPath); chapterParser.Parse(chapterIS); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), chapterPath, e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.SAX"), chapterPath, e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createChapterIncidence(Language.GetText("Error.LoadData.IO"), chapterPath, e)); //} } // If reading the adaptation configuration, store it // With last profile modifications, only old games includes that information in its descriptor file. // For that reason, the next "path" info is the name of the profile, and it is necessary to eliminate the path's characteristic // such as / and .xml else if (qName.Equals("adaptation-configuration")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("path")) { string adaptationName = entry.Value.ToString(); // delete the path's characteristics adaptationName = adaptationName.Substring(adaptationName.IndexOf("/") + 1); adaptationName = adaptationName.Substring(0, adaptationName.IndexOf(".")); currentChapter.setAdaptationName(adaptationName); // Search in incidences. If an adaptation incidence was related to this profile, the error is more relevant for (int j = 0; j < incidences.Count; j++) { Incidence current = incidences[j]; if (current.getAffectedArea() == Incidence.ADAPTATION_INCIDENCE && current.getAffectedResource().Equals(adaptationName)) { string message = current.getMessage(); incidences.RemoveAt(j); incidences.Insert(j, Incidence.createAdaptationIncidence(true, message + "Error.LoadAdaptation.Referenced", adaptationName, null)); } } } } } // If reading the assessment configuration, store it // With last profile modifications, only old games includes that information in its descriptor file. // For that reason, the next "path" info is the name of the profile, and it is necessary to eliminate the path's characteristic // such as / and .xml else if (qName.Equals("assessment-configuration")) { foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("path")) { string assessmentName = entry.Value.ToString(); // delete the path's characteristics assessmentName = assessmentName.Substring(assessmentName.IndexOf("/") + 1); assessmentName = assessmentName.Substring(0, assessmentName.IndexOf(".")); currentChapter.setAssessmentName(assessmentName); // Search in incidences. If an adaptation incidence was related to this profile, the error is more relevant for (int j = 0; j < incidences.Count; j++) { Incidence current = incidences[j]; if (current.getAffectedArea() == Incidence.ASSESSMENT_INCIDENCE && current.getAffectedResource().Equals(assessmentName)) { string message = current.getMessage(); incidences.RemoveAt(j); incidences.Insert(j, Incidence.createAssessmentIncidence(true, message + "Error.LoadAssessment.Referenced", assessmentName, null)); } } } } } }
//// /** //// * Checks the given asset to see if it fits the category. If the asset has //// * some problem, a message is displayed to the user. If the asset already //// * exists in the ZIP file, the user is prompted to overwrite it. //// * //// * @param assetPath //// * Absolute path to the asset //// * @param assetCategory //// * Category for the asset //// * @return True if the asset can be added to the set, false otherwise //// */ //// private static bool checkAsset(string assetPath, int assetCategory) //// { //// bool assetValid = true; //// // For images, only those who have restricted dimension are checked //// if (isImageWithRestrictedDimension(assetCategory)) //// { //// // Take the instance of the controller, and the filename of the asset //// Controller controller = Controller.getInstance(); //// string assetFilename = getFilename(assetPath); //// // Take the data from the file //// // Image image = new ImageIcon( assetPath ).getImage( ); //// Image image = getImage(assetPath); //// int width = image.getWidth(null); //// int height = image.getHeight(null); //// // Prepare the string array for the error message //// string[] fileInformation = new string[] { assetFilename, string.valueOf(width), string.valueOf(height) }; //// // Restrict dimensions for the asset category //// Dimension d = getRestrictedDimension(assetCategory); //// int res_width = (int)d.getWidth(); //// int res_height = (int)d.getHeight(); //// // Icon must be exactly restricted dimensions //// if (assetCategory == CATEGORY_ICON) //// { //// if (width != res_width || height != res_height) //// { //// controller.showErrorDialog( TC.get("IconAssets.Title"), TC.get("IconAssets.ErrorIconSize", fileInformation)); //// assetValid = false; //// } //// } //// // Backgrond must be bigger than restricted dimensions //// else if (assetCategory == AssetsConstants.CATEGORY_BACKGROUND) //// { //// if (width < res_width || height < res_height) //// { //// // controller.showErrorDialog( TC.get("BackgroundAssets.Title"), TC.get("BackgroundAssets.ErrorBackgroundSize", fileInformation)); //// assetValid = false; //// } //// } //// // Arrow book must be smaller than restricted dimensions //// else if (assetCategory == AssetsConstants.CATEGORY_ARROW_BOOK) //// { //// if (width > res_width || height > res_height) //// { //// //controller.showErrorDialog( TC.get("ArrowAssets.Title"), TC.get("ArrowAssets.ErrorArrowSize", fileInformation)); //// assetValid = false; //// } //// } //// } //// return assetValid; //// } public static void checkAssetFilesConsistency(List <Incidence> incidences) { List <string> assetPaths = new List <string>(); List <int> assetTypes = new List <int>(); Controller controller = Controller.Instance; controller.getAssetReferences(assetPaths, assetTypes); for (int i = 0; i < assetPaths.Count; i++) { bool assetValid = true; string assetPath = assetPaths[i]; int assetCategory = assetTypes[i]; string message = ""; bool notPresent = true; // Take the instance of the controller, and the filename of the asset FileInfo file = new FileInfo(Path.Combine(controller.ProjectFolder, assetPath)); if (assetCategory == AssetsConstants.CATEGORY_ANIMATION) { file = new FileInfo(Path.Combine(controller.ProjectFolder, assetPath + "_01.png")); if (!file.Exists) { file = new FileInfo(Path.Combine(controller.ProjectFolder, assetPath + "_01.jpg")); } if (!file.Exists) { file = new FileInfo(Path.Combine(controller.ProjectFolder, assetPath)); } } assetValid = file.Exists && file.Length > 0; if (!assetValid) { message = TC.get("Error.AssetNotFound" + assetCategory, assetPath); } // For images, only background and icon are checked if (assetValid && (assetCategory == AssetsConstants.CATEGORY_BACKGROUND || assetCategory == AssetsConstants.CATEGORY_ICON)) { // Take the data from the file Sprite image = Controller.ResourceManager.getSprite(assetPath); int width = (int)image.rect.width; int height = (int)image.rect.height; // Prepare the string array for the error message string[] fileInformation = new string[] { assetPath, width.ToString(), height.ToString() }; // The background files must have a size of at least 800x600 if (assetCategory == AssetsConstants.CATEGORY_BACKGROUND && (width < AssetsImageDimensions.BACKGROUND_MAX_WIDTH || height < AssetsImageDimensions.BACKGROUND_MAX_HEIGHT)) { message = TC.get("BackgroundAssets.ErrorBackgroundSize", fileInformation); assetValid = false; notPresent = false; } // The icon files must have a size of 80x48 else if (assetCategory == AssetsConstants.CATEGORY_ICON && (width != AssetsImageDimensions.ICON_MAX_WIDTH || height != AssetsImageDimensions.ICON_MAX_HEIGHT)) { message = TC.get("IconAssets.ErrorIconSize", fileInformation); assetValid = false; notPresent = false; } } if (!assetValid) { incidences.Add(Incidence.createAssetIncidence(notPresent, assetCategory, message, assetPath, null)); } } }
public void Remove(Incidence incidence) { context.Incidences.Remove(incidence); }
public void Add(Incidence incidence) { context.Incidences.Add(incidence); }
/// <summary> /// Serialize to a JSON object /// </summary> public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } if (!string.IsNullOrEmpty(ResourceType)) { writer.WriteString("resourceType", (string)ResourceType !); } ((fhirCsR4.Models.DomainResource) this).SerializeJson(writer, options, false); if ((Subject != null) && (Subject.Count != 0)) { writer.WritePropertyName("subject"); writer.WriteStartArray(); foreach (Reference valSubject in Subject) { valSubject.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (!string.IsNullOrEmpty(Description)) { writer.WriteString("description", (string)Description !); } if (_Description != null) { writer.WritePropertyName("_description"); _Description.SerializeJson(writer, options); } if ((Interactant != null) && (Interactant.Count != 0)) { writer.WritePropertyName("interactant"); writer.WriteStartArray(); foreach (MedicinalProductInteractionInteractant valInteractant in Interactant) { valInteractant.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (Type != null) { writer.WritePropertyName("type"); Type.SerializeJson(writer, options); } if (Effect != null) { writer.WritePropertyName("effect"); Effect.SerializeJson(writer, options); } if (Incidence != null) { writer.WritePropertyName("incidence"); Incidence.SerializeJson(writer, options); } if (Management != null) { writer.WritePropertyName("management"); Management.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }