private void dataGridViewServers_CurrentCellDirtyStateChanged(object sender, EventArgs e) { DataGridView d = sender as DataGridView; if (d != null) { DataGridViewCheckBoxCell cb = d.CurrentCell as DataGridViewCheckBoxCell; if (cb != null) { if (cb.Value is bool) { bool bValue = (bool)cb.Value; if (bValue) { DicomOpenSslVersion version = DicomNet.GetOpenSslVersion(); if (Utils.VerifyOpensslVersion(this) == false) { cb.Value = false; dataGridViewServers.RefreshEdit(); } } } d.CommitEdit(DataGridViewDataErrorContexts.CurrentCellChange); EnableDialogItems(); } } }
private void SendCopy(AutoCopyItem item) { AeInfoExtended[] aes = _aeManagementAgent.GetRelatedAeTitles(item.SourceAE, Module.AUTOCOPY_RELATION); StoreScu store = new StoreScu(); Module.InitializeDicomSecurity(false); StoreScu storeSecure = null; DicomOpenSslVersion dicomOpenSslVersion = DicomNet.GetOpenSslVersion(); if (dicomOpenSslVersion.IsAvailable) { storeSecure = new StoreScu(Module._Server.TemporaryDirectory, DicomNetSecurityMode.Tls, Module._openSslOptions); Module.SetCiphers(storeSecure); } DicomScp scp = null; string[] sopInstances = item.Datasets.ToArray(); if (aes == null || aes.Length == 0) { return; } string clientAe = Module.Options.UseCustomAE ? Module.Options.AutoCopyAE : item.ClientAE; AddEventHandlers(store, clientAe); AddEventHandlers(storeSecure, clientAe); foreach (AeInfoExtended ae in aes) { #if LEADTOOLS_V20_OR_LATER // Update dbo.AeInfo.LastAccessDate to Date.Now ae.LastAccessDate = DateTime.Now; _aeManagementAgent.Update(ae.AETitle, ae); #endif bool useTls = ae.ClientPortUsage == ClientPortUsageType.Secure || ((ae.ClientPortUsage == ClientPortUsageType.SameAsServer) && (Module._Server.Secure)); useTls = (useTls && dicomOpenSslVersion.IsAvailable); foreach (string sopInstance in sopInstances) { MatchingParameterCollection mpc = new MatchingParameterCollection(); MatchingParameterList mpl = new MatchingParameterList(); ICatalogEntity instanceEntity = RegisteredEntities.GetInstanceEntity(sopInstance); mpl.Add(instanceEntity); mpc.Add(mpl); DataSet instanceData = _StorageAgent.QueryCompositeInstances(mpc); // if (instanceData.Instance.Rows.Count == 1) if (instanceData.Tables[DataTableHelper.InstanceTableName].Rows.Count == 1) { // string file = instanceData.Instance[0].ReferencedFile; DataRow instanceRow = instanceData.Tables[DataTableHelper.InstanceTableName].Rows[0]; string file = RegisteredDataRows.InstanceInfo.ReferencedFile(instanceRow); scp = new DicomScp(IPAddress.Parse(ae.Address), ae.AETitle, ae.Port); try { if (useTls) { storeSecure.Store(scp, file); } else { store.Store(scp, file); } } catch (ClientAssociationException ce) { string message = string.Format("[Auto Copy] Failed to establish association with server: {0}.", ce.Reason); LogEvent(LogType.Error, MessageDirection.None, message, DicomCommandType.Undefined, null, store, null); } catch (DicomException de) { string message = string.Format("[Auto Copy] Error: {0}.", de.Message); LogEvent(LogType.Error, MessageDirection.Input, message, DicomCommandType.Undefined, null, store, null); } catch (Exception e) { string message = "[Auto Copy] " + e.Message; Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now, LogType.Error, MessageDirection.None, message, null, null); } } } } RemoveEventHandlers(store); RemoveEventHandlers(storeSecure); foreach (string sopInstance in sopInstances) { item.Datasets.Remove(sopInstance); } }