/// <summary> /// Updates the Patient's Name tag in the specified <see cref="DicomFile"/> /// based on the specified <see cref="StudyStorageLocation"/>. Normalization /// may occur. /// </summary> /// <param name="file"></param> /// <returns></returns> public UpdateItem Apply(DicomFile file) { Platform.CheckForNullReference(file, "file"); string orginalPatientsNameInFile = file.DataSet[DicomTags.PatientsName].ToString(); // Note: only apply the name rules if we can't update it to match the study if (!UpdateNameBasedOnTheStudy(file)) UpdateNameBasedOnRules(file); string newPatientName = file.DataSet[DicomTags.PatientsName].ToString(); UpdateItem change = null; if (!newPatientName.Equals(orginalPatientsNameInFile, StringComparison.InvariantCultureIgnoreCase)) { change = new UpdateItem(DicomTags.PatientsName, orginalPatientsNameInFile, newPatientName); StringBuilder log = new StringBuilder(); log.AppendLine(String.Format("AUTO-CORRECTION: SOP {0}", file.MediaStorageSopInstanceUid)); log.AppendLine(String.Format("\tPatient's Name: {0} ==> {1}. ", change.OriginalValue, change.NewValue)); Platform.Log(LogLevel.Info, log.ToString()); } return change; }
public bool IsBetterThan(UpdateItem update, AppUpdateLevel preferredType) { if (update == null) return true; if ((int)this.Type > (int)preferredType) return false; return this.Version > update.Version || this.Date > update.Date; }
private static void DownloadUpdate(Form form, UpdateItem updateItem) { if (form.InvokeRequired) { form.BeginInvoke(new MethodInvoker(() => DownloadUpdate(form, updateItem))); return; } new UpdaterDownloadWindow(updateItem).ShowDialog(form); }
public List<IEvent> Handle(UpdateItem cmd) { if (cmd == null) throw new ArgumentNullException("cmd"); return new List<IEvent> { new ItemUpdated( timestamp: cmd.timestamp, id: cmd.id, name: cmd.name, description: cmd.description) }; }
public static void Update(Form form, bool interactive) { if (PhUtils.IsInternetConnected) { XmlDocument xDoc = new XmlDocument(); try { xDoc.Load(Properties.Settings.Default.AppUpdateUrl); } catch (Exception ex) { if (interactive) PhUtils.ShowException("Unable to download update information", ex); else Program.HackerWindow.QueueMessage("Unable to download update information: " + ex.Message); return; } UpdateItem currentVersion = new UpdateItem(); UpdateItem bestUpdate = currentVersion; XmlNodeList nodes = xDoc.SelectNodes("//update"); foreach (XmlNode node in nodes) { try { UpdateItem update = new UpdateItem(node); if (update.IsBetterThan(bestUpdate, (AppUpdateLevel)Properties.Settings.Default.AppUpdateLevel)) bestUpdate = update; } catch (Exception ex) { Logging.Log(ex); } } PromptWithUpdate(form, bestUpdate, currentVersion, interactive); } else if (interactive) PhUtils.ShowWarning("An Internet session could not be established. Please verify connectivity."); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string uploaderCaps(byte[] data, string path, string param) { UUID inv = inventoryItemID; string res = String.Empty; UpdateItemResponse response = new UpdateItemResponse(); handlerUpdateItem = OnUpLoad; if (handlerUpdateItem != null) { response = handlerUpdateItem(inv, data); } if (response.AssetKind == AssetType.LSLText) { if (response.SaveErrors != null && response.SaveErrors.Count > 0) { LLSDScriptCompileFail compFail = new LLSDScriptCompileFail(); compFail.new_asset = response.AssetId.ToString(); compFail.new_inventory_item = inv; compFail.state = "complete"; foreach (string str in response.SaveErrors) { compFail.errors.Array.Add(str); } res = LLSDHelpers.SerializeLLSDReply(compFail); } else { LLSDScriptCompileSuccess compSuccess = new LLSDScriptCompileSuccess(); compSuccess.new_asset = response.AssetId.ToString(); compSuccess.new_inventory_item = inv; compSuccess.state = "complete"; res = LLSDHelpers.SerializeLLSDReply(compSuccess); } } else { LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = response.AssetId.ToString(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; res = LLSDHelpers.SerializeLLSDReply(uploadComplete); } httpListener.RemoveStreamHandler("POST", uploaderPath); return res; }
private static List<UpdateItem> GetUpdateList(DicomFile file, IEnumerable<BaseImageLevelUpdateCommand> commands) { List<UpdateItem> updateList = new List<UpdateItem>(); foreach (BaseImageLevelUpdateCommand cmd in commands) { if (cmd.UpdateEntry != null && cmd.UpdateEntry.TagPath != null && cmd.UpdateEntry.TagPath.Tag != null) { UpdateItem item = new UpdateItem(cmd, file); updateList.Add(item); } } return updateList; }
private static void PromptWithUpdate(Form form, UpdateItem bestUpdate, UpdateItem currentVersion, bool interactive) { if (form.InvokeRequired) { form.BeginInvoke(new MethodInvoker(() => PromptWithUpdate(form, bestUpdate, currentVersion, interactive))); return; } if (bestUpdate != currentVersion) { DialogResult dialogResult; if (OSVersion.HasTaskDialogs) { TaskDialog td = new TaskDialog(); td.PositionRelativeToWindow = true; td.Content = "Your Version: " + currentVersion.Version.ToString() + "\nServer Version: " + bestUpdate.Version.ToString() + "\n\n" + "\n" + bestUpdate.Message; td.MainInstruction = "Process Hacker update available"; td.WindowTitle = "Update available"; td.MainIcon = TaskDialogIcon.SecurityWarning; td.Buttons = new TaskDialogButton[] { new TaskDialogButton((int)DialogResult.Yes, "Download"), new TaskDialogButton((int)DialogResult.No, "Cancel"), }; dialogResult = (DialogResult)td.Show(form); } else { dialogResult = MessageBox.Show( form, "Your Version: " + currentVersion.Version.ToString() + "\nServer Version: " + bestUpdate.Version.ToString() + "\n\n" + bestUpdate.Message + "\n\nDo you want to download the update now?", "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation ); } if (dialogResult == DialogResult.Yes) { DownloadUpdate(form, bestUpdate); } } else if (interactive) { if (OSVersion.HasTaskDialogs) { TaskDialog td = new TaskDialog(); td.PositionRelativeToWindow = true; td.Content = "Your Version: " + currentVersion.Version.ToString() + "\nServer Version: " + bestUpdate.Version.ToString(); td.MainInstruction = "Process Hacker is up-to-date"; td.WindowTitle = "No updates available"; td.MainIcon = TaskDialogIcon.SecuritySuccess; td.CommonButtons = TaskDialogCommonButtons.Ok; td.Show(form); } else { MessageBox.Show( form, "Process Hacker is up-to-date.", "No updates available", MessageBoxButtons.OK, MessageBoxIcon.Information ); } } }
private static bool add(UpdateItem item, SQLiteDatabase db) { return(db.Replace(item.Table, item.FieldData)); }
private void CheckVersionUpdateEvent(CheckVersionResponse response) { if (response != null) { VersionType type = (VersionType)System.Enum.Parse(typeof(VersionType), response.type.ToString()); UpdateItem item = new UpdateItem(response.url, response.name, response.updateInfo, type); if (WindowModel.Instance.IsOpenUpdateWindow()) { UpdateWindow updateWindow = WindowModel.Instance.UpdateWindow; updateWindow.UpdateInfo(item); } else { if (type == VersionType.VERSION_UPDATE) { item.EndEvent = new EndEvent(this.UpdateVersionEnd); this.fileService.DownloadIDKinUpdatePackage(item); } } } }
private List <UpdateItem> GetChanges() { var changes = new List <UpdateItem>(); var oldPatientName = new PersonName(Study.PatientsName); var newPatientName = PatientNamePanel.PersonName; if (!oldPatientName.AreSame(newPatientName, PersonNameComparisonOptions.CaseInsensitive)) { var item = new UpdateItem(DicomTags.PatientsName, Study.PatientsName, PatientNamePanel.PersonName); changes.Add(item); } String dicomBirthDate = !(string.IsNullOrEmpty(PatientBirthDate.Text)) ? DateTime.ParseExact(PatientBirthDate.Text, InputDateParser.DateFormat, null).ToString(DicomConstants.DicomDate) : ""; if (AreDifferent(Study.PatientsBirthDate, dicomBirthDate)) { var item = new UpdateItem(DicomTags.PatientsBirthDate, Study.PatientsBirthDate, dicomBirthDate); changes.Add(item); } string newPatientAge = String.IsNullOrEmpty(PatientAge.Text)? String.Empty:String.Format("{0}{1}", PatientAge.Text.PadLeft(3, '0'), PatientAgePeriod.SelectedValue); if (AreDifferent(Study.PatientsAge, newPatientAge)) { var item = new UpdateItem(DicomTags.PatientsAge, Study.PatientsAge, newPatientAge); changes.Add(item); } // PatientGender is a required field. if (AreDifferent(Study.PatientsSex, PatientGender.Text)) { var item = new UpdateItem(DicomTags.PatientsSex, Study.PatientsSex, PatientGender.Text); changes.Add(item); } //PatientID.Text is a required field. if (AreDifferent(Study.PatientId, PatientID.Text)) { var item = new UpdateItem(DicomTags.PatientId, Study.PatientId, PatientID.Text); changes.Add(item); } if (AreDifferent(Study.StudyDescription, StudyDescription.Text)) { var item = new UpdateItem(DicomTags.StudyDescription, Study.StudyDescription, StudyDescription.Text); changes.Add(item); } if (AreDifferent(Study.StudyId, StudyID.Text)) { var item = new UpdateItem(DicomTags.StudyId, Study.StudyId, StudyID.Text); changes.Add(item); } if (AreDifferent(Study.AccessionNumber, AccessionNumber.Text)) { var item = new UpdateItem(DicomTags.AccessionNumber, Study.AccessionNumber, AccessionNumber.Text); changes.Add(item); } var oldPhysicianName = new PersonName(Study.ReferringPhysiciansName); var newPhysicianName = ReferringPhysicianNamePanel.PersonName; if (!newPhysicianName.AreSame(oldPhysicianName, PersonNameComparisonOptions.CaseInsensitive)) { var item = new UpdateItem(DicomTags.ReferringPhysiciansName, Study.ReferringPhysiciansName, ReferringPhysicianNamePanel.PersonName.ToString()); changes.Add(item); } string newDicomStudyDate = string.Empty; if (!string.IsNullOrEmpty(StudyDate.Text)) { DateTime newStudyDate; newDicomStudyDate = InputDateParser.TryParse(StudyDate.Text, out newStudyDate) ? newStudyDate.ToString(DicomConstants.DicomDate) : string.Empty; } if (AreDifferent(Study.StudyDate, newDicomStudyDate)) { var item = new UpdateItem(DicomTags.StudyDate, Study.StudyDate, newDicomStudyDate); changes.Add(item); } int hh = String.IsNullOrEmpty(StudyTimeHours.Text)? 0:int.Parse(StudyTimeHours.Text); int mm = String.IsNullOrEmpty(StudyTimeMinutes.Text) ? 0 : int.Parse(StudyTimeMinutes.Text); int ss = String.IsNullOrEmpty(StudyTimeSeconds.Text) ? 0 : int.Parse(StudyTimeSeconds.Text); String dicomStudyTime = String.Format("{0:00}{1:00}{2:00}", hh, mm, ss); // #9475 : if fraction is in the original time, it should be preserved unless the hours, minutes or seconds are modified. var originalTime = Study.StudyTime; if (!string.IsNullOrEmpty(originalTime) && originalTime.Contains(".")) { originalTime = originalTime.Substring(0, originalTime.IndexOf(".", StringComparison.InvariantCultureIgnoreCase)); } if (AreDifferent(originalTime, dicomStudyTime)) { var item = new UpdateItem(DicomTags.StudyTime, Study.StudyTime, dicomStudyTime); changes.Add(item); } return(changes); }
public static void Update(Form form, bool interactive) { XmlDocument xDoc = new XmlDocument(); try { xDoc.Load(Settings.Instance.AppUpdateUrl); } catch (Exception ex) { if (interactive) PhUtils.ShowException("Unable to download update information", ex); else Program.HackerWindow.QueueMessage("Unable to download update information: " + ex.Message); return; } UpdateItem currentVersion = new UpdateItem(); UpdateItem bestUpdate = currentVersion; XmlNodeList nodes = xDoc.SelectNodes("//update"); foreach (XmlNode node in nodes) { try { UpdateItem update = new UpdateItem(node); // Check if this update is better than the one we already have. if (update.IsBetterThan(bestUpdate, (AppUpdateLevel)Settings.Instance.AppUpdateLevel)) bestUpdate = update; } catch (Exception ex) { Logging.Log(ex); } } PromptWithUpdate(form, bestUpdate, currentVersion, interactive); }
/// <summary> /// Based on a UpdateItem, this method will update it's settings with any Bolt related data /// </summary> /// <param name="target">Target GameObject that should represent a Bolt Entity</param> /// <param name="item">Configuration data stored into a UpdateItem</param> private static void UpdateBoltEntity(GameObject target, UpdateItem item) { if (target.name.Equals(item.name) == false) { return; } BoltLog.Info("Updating {0}", target.name); foreach (var entityComponent in item.entityComponents) { var boltEntityComponent = target.AddComponent <BoltEntity>(); var entityModify = boltEntityComponent.ModifySettings(); entityModify.prefabId = entityComponent.prefabId; entityModify.sceneId = entityComponent.sceneId; entityModify.serializerId = entityComponent.serializerId; entityModify.updateRate = entityComponent.updateRate; entityModify.autoFreezeProxyFrames = entityComponent.autoFreezeProxyFrames; entityModify.clientPredicted = entityComponent.clientPredicted; entityModify.allowInstantiateOnClient = entityComponent.allowInstantiateOnClient; entityModify.persistThroughSceneLoads = entityComponent.persistThroughSceneLoads; entityModify.sceneObjectDestroyOnDetach = entityComponent.sceneObjectDestroyOnDetach; entityModify.sceneObjectAutoAttach = entityComponent.sceneObjectAutoAttach; entityModify.alwaysProxy = entityComponent.alwaysProxy; EditorUtils.MarkDirty((Component)boltEntityComponent); } if (item.hasEntityHitboxBody) { var hitboxComponent = target.AddComponent <BoltHitboxBody>(); EditorUtils.MarkDirty(hitboxComponent); } foreach (var hitBoxData in item.entityHitboxes) { var hitBoxComponent = target.AddComponent <BoltHitbox>(); hitBoxComponent.hitboxShape = hitBoxData.hitboxShape; hitBoxComponent.hitboxType = hitBoxData.hitboxType; hitBoxComponent.hitboxSphereRadius = hitBoxData.hitboxSphereRadius; hitBoxComponent.hitboxCenter = hitBoxData.hitboxCenter; hitBoxComponent.hitboxBoxSize = hitBoxData.hitboxBoxSize; EditorUtils.MarkDirty(hitBoxComponent); } foreach (var childItem in item.childItems) { for (int i = 0; i < target.transform.childCount; i++) { var childTransform = target.transform.GetChild(i); if (childTransform.name.Equals(childItem.name)) { UpdateBoltEntity(childTransform.gameObject, childItem); } } } EditorUtils.MarkDirty(target); }
public CollectionsXMLManager() { _updateItem = new UpdateItem(this); _openWebpage = new OpenWebpage(this); }
private static bool delete(UpdateItem item, SQLiteDatabase db) { return(db.Delete(item.Table, item.FieldData)); }
public void UpdateInfo(UpdateItem item) { if (item != null) { this.updateItem = item; if (item.Type == VersionType.VERSION_NONE) { this.lblMsg.Text = "已经是最新版本,不需要更新"; this.btnCheckUpdate.Visibility = Visibility.Collapsed; this.btnExit.Visibility = Visibility.Visible; } if (item.Type == VersionType.VERSION_UPDATE) { this.lblMsg.Text = "检测到最近版本,是否需要更新"; this.btnCheckUpdate.Visibility = Visibility.Collapsed; this.btnYes.Visibility = Visibility.Visible; this.btnNo.Visibility = Visibility.Visible; } if (item.Type == VersionType.VERSION_REFUSE) { this.lblMsg.Text = "服务器拒绝更新"; } } }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string uploaderCaps(byte[] data, string path, string param) { UUID inv = inventoryItemID; string res = String.Empty; handlerUpdateItem = OnUpLoad; if (handlerUpdateItem != null) { res = handlerUpdateItem(inv, data).ToString(); } httpListener.RemoveStreamHandler("POST", uploaderPath); return res; }
/// <summary> /// Exchanges update items that were previously generated via /// a call to <see cref="GetUpdateItem"/>. /// </summary> /// <param name="data">The update data to apply to the edit (modified to /// hold the values that were previously defined for the edit)</param> internal void ExchangeData(UpdateItem item) { Distance[] newDistances = (Distance[])item.Value; Distance[] oldDistances = new Distance[m_Sections.Count]; Debug.Assert(newDistances.Length == oldDistances.Length); for (int i = 0; i < newDistances.Length; i++) { LineFeature section = m_Sections[i]; oldDistances[i] = section.ObservedLength; section.ObservedLength = newDistances[i]; } m_Distances = newDistances; item.Value = oldDistances; }
/// <summary> /// Handle raw uploaded asset data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public string uploaderCaps(byte[] data, string path, string param) { UUID inv = inventoryItemID; string res = String.Empty; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); UUID assetID = UUID.Zero; handlerUpdateItem = OnUpLoad; if (handlerUpdateItem != null) { assetID = handlerUpdateItem(inv, data); } uploadComplete.new_asset = assetID.ToString(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); httpListener.RemoveStreamHandler("POST", uploaderPath); if (m_dumpAssetToFile) { SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); } return res; }
private void UpdateNewVersion(UpdateItem obj) { gridUpdate.Visibility = Visibility.Visible; tbUpdateVersion.Text = $"New version {obj.VersionNumber} hype!"; UpdateContent = obj; }