Example #1
0
        static void _CreateXMLDocument(IObjectDataManager obj, IDocumentManager mngr, OID documentID, string tempDirForXML, OID emailID, string toOrgID, string toDepartmentID)
        {
            var info  = mngr.CreateXMLDocument(documentID, toOrgID, toDepartmentID);
            var msgID = info.XMLMsgID;

            string tempFolderToRemoveOnServer = info.TempFolderOnServer;            //тут буде папка, яку потрібно передати серверу на видалення після закінчення роботи

            string xmlFile     = string.Format("nbu.document.{0}.xml", msgID);
            string fullXMLFile = Path.Combine(tempDirForXML, xmlFile);

            using (var stream = Foss.FossDoc.ApplicationServer.IO.StreamAccessOptimizer.WrapStream(info.XMLStream))
            {
                if (stream == null)
                {
                    throw new ApplicationException("stream == null");
                }

                using (FileStream fs = new FileStream(fullXMLFile, FileMode.Create))
                {
                    stream.Position = 0;
                    Foss.TemplateLibrary.StreamCopy.Copy(stream, fs);
                }
            }

            //створення файлу-вкладення
            var att = new Foss.FossDoc.ExternalModules.BusinessLogic.Utils.Attach(fullXMLFile);

            att.CreateAttach(obj, emailID, true);

            try
            {
                mngr.CleanupTemporaryData(tempFolderToRemoveOnServer);
            }
            catch (Exception)
            {
            }

            try
            {
                File.Delete(fullXMLFile);
            }
            catch
            {
            }
        }        //_CreateXMLDocument