public System.IO.Stream GetStream(object args)
        {
            AdvancedShipNoticeProviderParameters _args = new AdvancedShipNoticeProviderParameters();
            _args = args as AdvancedShipNoticeProviderParameters;
            _args.tagnamespace = "http://kaifa.b2b.schemas/AdvancedShipNotice";
            IEnumerable<string> keys = GetReceiptKeys(_args);
            if (keys.Count() > 0)
            {


                MemoryStream ms = new MemoryStream();
                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Indent = true;

                using (XmlWriter xw = XmlWriter.Create(ms, xws))
                {
                    AdvancedShipNoticeGenerator report = new AdvancedShipNoticeGenerator(keys.ToArray(), _args.configPath, _args.fromRole, _args.tostxRole, _args.toe2openRole, _args.warehous, _args.connectionstring, _args.tagnamespace);
                    XDocument doc = report.Generator();
                    doc.WriteTo(xw);
                }
                ms.Seek(0, SeekOrigin.Begin);
                System.Diagnostics.Trace.WriteLine("");
               

                UpdateFlag(_args, keys);
                System.Diagnostics.Trace.WriteLine(string.Format("Create AdvancedShipNotice {0}", string.Join(",", keys.Select(t => "" + t + "").ToArray())), "AdvancedShipNoticeProvider");
                return ms;
            }
            else
            {
                System.Diagnostics.Trace.WriteLine(" Null ", "AdvancedShipNoticeProvider");
                MailClient.SendNoHubReceiptNotificationMail(_args.toAddresses);
                return null;
            }

             
        }
        public System.IO.Stream GetStream(object args)
        {
            AdvancedShipNoticeProviderParameters _args = new AdvancedShipNoticeProviderParameters();

            _args = args as AdvancedShipNoticeProviderParameters;
            _args.tagnamespace = "http://kaifa.b2b.schemas/AdvancedShipNotice";
            IEnumerable <string> keys = GetReceiptKeys(_args);

            if (keys.Count() > 0)
            {
                MemoryStream      ms  = new MemoryStream();
                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Indent             = true;

                using (XmlWriter xw = XmlWriter.Create(ms, xws))
                {
                    AdvancedShipNoticeGenerator report = new AdvancedShipNoticeGenerator(keys.ToArray(), _args.configPath, _args.fromRole, _args.tostxRole, _args.toe2openRole, _args.warehous, _args.connectionstring, _args.tagnamespace);
                    XDocument doc = report.Generator();
                    doc.WriteTo(xw);
                }
                ms.Seek(0, SeekOrigin.Begin);
                System.Diagnostics.Trace.WriteLine("");


                UpdateFlag(_args, keys);
                System.Diagnostics.Trace.WriteLine(string.Format("Create AdvancedShipNotice {0}", string.Join(",", keys.Select(t => "" + t + "").ToArray())), "AdvancedShipNoticeProvider");
                return(ms);
            }
            else
            {
                System.Diagnostics.Trace.WriteLine(" Null ", "AdvancedShipNoticeProvider");
                MailClient.SendNoHubReceiptNotificationMail(_args.toAddresses);
                return(null);
            }
        }