private EMKServise.MedDocument.DocumentAttachment ConvertAttachment(MedDocument.DocumentAttachment c) { if ((object)c != null) { EMKServise.MedDocument.DocumentAttachment eda = new EMKServise.MedDocument.DocumentAttachment(); if (c.Data != null) { eda.Data = c.Data; } if (c.Hash != null) { eda.Hash = c.Hash; } if (c.MimeType != "") { eda.MimeType = c.MimeType; } if (c.Url != null) { eda.Url = c.Url; } return(eda); } else { return(null); } }
public TestAttachment(MedDocument.DocumentAttachment at) { if ((at != null) && ((at.Data != null) || (at.Hash != null) || (at.MimeType != null) || (at.Url != null))) { attachment = at; } }
public TestAttachment(MedDocument.DocumentAttachment at) { if ((at != null) && ((at.Data != null) || (at.Hash != null) || (at.MimeType != null) || (at.Url != null))) { attachment = at; } }
public static MedDocument.DocumentAttachment SetAttachment(string path, string url, string mimeType) { MedDocument.DocumentAttachment a = new MedDocument.DocumentAttachment { Data = Encoding.UTF8.GetBytes(Convert.ToBase64String(File.ReadAllBytes(path))), //Url = new Uri(url), MimeType = mimeType }; a.Hash = N3.EMK.Infrastructure.Helpers.Md5Helper.GetGost3411Hash(a.Data); return(a); }
public static List<TestAttachment> BuildTestAttacmentFromDataBase(string idStep, string idMedDocumentType) { List<TestAttachment> taList = new List<TestAttachment>(); if (idStep != "") { using (SqlConnection connection = Global.GetSqlConnection()) { string findDocuments = "SELECT * FROM MedDocument WHERE IdStep = '" + idStep + "' AND IdMedDocumentType = '" + idMedDocumentType + "'"; SqlCommand participantCommand = new SqlCommand(findDocuments, connection); using (SqlDataReader docsReader = participantCommand.ExecuteReader()) { while (docsReader.Read()) { MedDocument.DocumentAttachment at = new MedDocument.DocumentAttachment(); if (docsReader["Attachment"].ToString() != "") { byte[] ata = docsReader["Attachment"] as byte[]; if (ata != null) at.Data = ata; } if (docsReader["AttachmentHash"].ToString() != "") { byte[] ath = docsReader["AttachmentHash"] as byte[]; if (ath != null) at.Hash = ath; } if (docsReader["AttachmentURL"].ToString() != "") at.Url = new Uri(Convert.ToString(docsReader["AttachmentURL"])); if (docsReader["MIMEType"].ToString() != "") at.MimeType = docsReader["MIMEType"].ToString(); TestAttachment t = new TestAttachment(at); if (docsReader["IdMedDocument"].ToString() != "") t.idMedDocument = docsReader["IdMedDocument"].ToString(); if (docsReader["DocHead"].ToString() != "") t.DocHead = docsReader["DocHead"].ToString(); if (docsReader["CreationDate"].ToString() != "") t.CreationDate = Convert.ToDateTime(docsReader["CreationDate"]); if (docsReader["IdDoctor"].ToString() != "") t.IdDoctor = docsReader["IdDoctor"].ToString(); taList.Add(t); } } } } if (taList.Count != 0) return taList; else return null; }
private static MedDocument.DocumentAttachment SetAttachment(string path, string url, string mimeType) { MedDocument.DocumentAttachment a = new MedDocument.DocumentAttachment { Data = File.ReadAllBytes(path), //Hash = Convert.FromBase64String("SGVsbG8sIFdvcmxk"), Url = new Uri(url), MimeType = mimeType }; var process = new Process(); process.StartInfo.FileName = "cpverify.exe"; process.StartInfo.Arguments = "-mk " + path; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; var sb = new StringBuilder(); process.Start(); while (!process.StandardOutput.EndOfStream) { sb.Append(process.StandardOutput.ReadLine()); } string str = sb.ToString(); var res = new byte[str.Length / 2];//проверим что их чётное количество? :) for (var i = 0; i < str.Length; i += 2) { res[i / 2] = byte.Parse(str.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);//или byte.TryParse для избежания эксепшинов } a.Hash = res; return a; }
public static MedDocument.DocumentAttachment SetAttachment(string path, string url, string mimeType) { MedDocument.DocumentAttachment a = new MedDocument.DocumentAttachment { Data = Encoding.UTF8.GetBytes(Convert.ToBase64String(File.ReadAllBytes(path))), //Url = new Uri(url), MimeType = mimeType }; a.Hash = N3.EMK.Infrastructure.Helpers.Md5Helper.GetGost3411Hash(a.Data); return a; }
static public List <TestAttachment> BuildTestAttacmentFromDataBase(string idStep, string idMedDocumentType) { List <TestAttachment> taList = new List <TestAttachment>(); if (idStep != "") { using (SqlConnection connection = Global.GetSqlConnection()) { string findDocuments = "SELECT * FROM MedDocument WHERE IdStep = '" + idStep + "' AND IdMedDocumentType = '" + idMedDocumentType + "'"; SqlCommand participantCommand = new SqlCommand(findDocuments, connection); using (SqlDataReader docsReader = participantCommand.ExecuteReader()) { while (docsReader.Read()) { MedDocument.DocumentAttachment at = new MedDocument.DocumentAttachment(); if (docsReader["Attachment"].ToString() != "") { byte[] ata = docsReader["Attachment"] as byte[]; if (ata != null) { at.Data = ata; } } if (docsReader["AttachmentHash"].ToString() != "") { byte[] ath = docsReader["AttachmentHash"] as byte[]; if (ath != null) { at.Hash = ath; } } if (docsReader["AttachmentURL"].ToString() != "") { at.Url = new Uri(Convert.ToString(docsReader["AttachmentURL"])); } if (docsReader["MIMEType"].ToString() != "") { at.MimeType = docsReader["MIMEType"].ToString(); } TestAttachment t = new TestAttachment(at); if (docsReader["IdMedDocument"].ToString() != "") { t.idMedDocument = docsReader["IdMedDocument"].ToString(); } if (docsReader["DocHead"].ToString() != "") { t.DocHead = docsReader["DocHead"].ToString(); } if (docsReader["CreationDate"].ToString() != "") { t.CreationDate = Convert.ToDateTime(docsReader["CreationDate"]); } if (docsReader["IdDoctor"].ToString() != "") { t.IdDoctor = docsReader["IdDoctor"].ToString(); } taList.Add(t); } } } } if (taList.Count != 0) { return(taList); } else { return(null); } }