public bool UpdateEmrNote(int series, NoteStatus noteStatus, ref NoteStatus noteStatusEnd, bool CommitFlag) { noteStatusEnd = noteStatus; /* Confirm the note exists. */ XmlNode emrNote = GetEmrNoteBySeries(series); if (emrNote == null) { return(Return.Failed); } /* word window to word document */ string tmpfile = Path.Combine(Globals.currentDirectory, ResourceName.Mytmp); //udt.jj.SaveWordDoc(ThisAddIn.Application.ActiveDocument, tmpfile, false); #region Update the emrDocument in dadabase /* Package the word document into a xml elelement. */ XmlNode noteDoc = emrDoc.CreateElement(ElementNames.EmrNote); noteDoc.InnerText = udt.jj.WordDocumentToString(tmpfile); string registryID = emrDoc.DocumentElement.GetAttribute(AttributeNames.RegistryID); /* Update the dadabase. */ if (!Globals.offline) { using (gjtEmrService.emrServiceXml es = new gjtEmrService.emrServiceXml()) { try { string strResult = es.IsEnabledCommit(registryID, series); if (strResult == "0") { noteStatusEnd = NoteStatus.Draft; if (CommitFlag == true) { MessageBox.Show("已经超时提交过的文档不能再次提交,请与质管部门联系!", ErrorMessage.Warning, MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } } else { emrNote.Attributes["NoteStatus"].Value = (Convert.ToInt32(noteStatusEnd)).ToString(); if ((Convert.ToInt32(noteStatusEnd)).ToString() == "1" && ThisAddIn.CanOption(ElementNames.CommitTime)) { if (emrNote.Attributes["fanxiu"] == null || emrNote.Attributes["fanxiu"].Value == "No") { emrNote.Attributes[AttributeNames.WrittenDate].Value = ThisAddIn.Today().ToString(); } } } } catch (Exception ex) { Globals.logAdapter.Record("EX741852968", ex.Message + ">>" + ex.ToString(), true); } } if (ThisAddIn.UpdateOneEmrNote(registryID, emrNote, noteDoc) == Return.Failed) { return(Return.Failed); } } else { OpDone opDone = new OpDone("离线,寄存失败!"); opDone.Show(); return(Return.Failed); } #endregion #region Update the local storage string noteID = emrNote.Attributes[AttributeNames.NoteID].Value; string wdDocName = udt.MakeWdDocumentFileName(registryID, noteID, series, Globals.workFolder); File.Copy(tmpfile, wdDocName, true); if (Globals.localDocumentEncode) { udt.jj.EncodeEmrDocument(wdDocName); } string LastWriteTime = ThisAddIn.Today().ToFileTime().ToString(); emrNote.Attributes[AttributeNames.NoteStatus].Value = noteStatus.ToString("d"); emrNote.Attributes[AttributeNames.LastWriteTime].Value = LastWriteTime; emrDoc.DocumentElement.SetAttribute(AttributeNames.LastWriteTime, LastWriteTime); emrDoc.Save(emrDocFile); udt.jj.EncodeEmrDocument(emrDocFile); #endregion return(Return.Successful); }