Beispiel #1
0
        public int processAttachement(Attachement att, LicenseMailBodyData data, IMailMessage mail)
        {
            int        iCount  = 0;
            LicenseXML xmlData = LicenseXML.Deserialize(att.data);

            foreach (license ldata in xmlData.licenses)
            {
                utils.helpers.addLog("processAttachement: new LicenseData...\r\n");
                LicenseData licenseData = new LicenseData(ldata.id, ldata.user, ldata.key, data.OrderNumber, data.OrderDate, data.yourPOnumber, data.EndCustomer, data.Product, data.Quantity, mail.User, mail.timestamp);
                //if (_licenseDataBase.addQueued(licenseData))
                utils.helpers.addLog("firing license_mail event\r\n");
                OnStateChanged(new StatusEventArgs(StatusType.license_mail, licenseData));
                iCount++;
                //if (_licenseDataBase.add(ldata.id, ldata.user, ldata.key, data.OrderNumber, data.OrderDate, data.yourPOnumber, data.EndCustomer, data.Product, data.Quantity, mail.User, mail.timestamp))
                //    iCount++;
                //utils.helpers.addLog("start _licenseDataBase.add() done\r\n");
            }
            #region alternative_code

            /*
             * // Request all the attachments on the email message. This results in a GetItem operation call to EWS.
             * m.Load(new Microsoft.Exchange.WebServices.Data.PropertySet(Microsoft.Exchange.WebServices.Data.EmailMessageSchema.Attachments));
             * foreach (Microsoft.Exchange.WebServices.Data.Attachment att in m.Attachments)
             * {
             *  if (att is Microsoft.Exchange.WebServices.Data.FileAttachment)
             *  {
             *      Microsoft.Exchange.WebServices.Data.FileAttachment fileAttachment = att as Microsoft.Exchange.WebServices.Data.FileAttachment;
             *
             *      //get a temp file name
             *      string fname = System.IO.Path.GetTempFileName(); //utils.helpers.getAppPath() + fileAttachment.Id.ToString() + "_" + fileAttachment.Name
             *
             *      // Load the file attachment into memory. This gives you access to the attachment content, which
             *      // is a byte array that you can use to attach this file to another item. This results in a GetAttachment operation
             *      // call to EWS.
             *      fileAttachment.Load();
             *
             *      // Load attachment contents into a file. This results in a GetAttachment operation call to EWS.
             *      fileAttachment.Load(fname);
             *      addLog("Attachement file saved to: " + fname);
             *
             *      // Put attachment contents into a stream.
             *      using (System.IO.FileStream theStream =
             *          new System.IO.FileStream(utils.helpers.getAppPath() + fileAttachment.Id.ToString() + "_" + fileAttachment.Name, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
             *      {
             *          //This results in a GetAttachment operation call to EWS.
             *          fileAttachment.Load(theStream);
             *      }
             *
             *      //load into memory stream, seems the only stream supported
             *      using (System.IO.MemoryStream ms = new System.IO.MemoryStream(att.Size))
             *      {
             *          fileAttachment.Load(ms);
             *          using (System.IO.FileStream fs = new System.IO.FileStream(fname, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
             *          {
             *              ms.CopyTo(fs);
             *              fs.Flush();
             *          }
             *      }
             *      addLog("saved attachement: " + fname);
             *      iRet++;
             *  }
             * }
             */
            #endregion
            return(iCount);
        }
Beispiel #2
0
 public void addAttachement(Attachement att)
 {
     attList.Add(att);
 }
Beispiel #3
0
 public MailMessage(string user, string body, string subject, Attachement[] atts, DateTime dt)
 {
     this.User = user;
     this.Body = body;
     this.Subject = subject;
     this.Attachements = atts;
     attList.AddRange(atts);
     timestamp = dt;
 }
Beispiel #4
0
        private void mnuProcess_Mail_Click(object sender, EventArgs e)
        {
            string sBody =
                "Hello Yolanda  Xie,\r\n" +
                "\r\n" +
                "Thank you for purchasing Naurtech software. Here are the registration keys for your software licenses. Please note that both the License ID and Registration keys are case sensitive. You can find instructions to manually register your license at:\r\n" +
                "http://www.naurtech.com/wiki/wiki.php?n=Main.TrainingVideoManualRegistration\r\n" +
                "\r\n" +
                "     Order Number:     15109\r\n" +
                "     Order Date:       4/10/2014\r\n" +
                "     Your PO Number:   PO93504\r\n" +
                "     End Customer:     Honeywell\r\n" +
                "     Product:          [NAU-1504] CETerm for Windows CE 6.0 / 5.0 / CE .NET\r\n" +
                "     Quantity:         46\r\n" +
                "\r\n" +
                "     Qty Ordered...............: 46\r\n" +
                "     Qty Shipped To Date.......: 46\r\n" +
                "\r\n" +
                "     Qty Shipped in this email.: 46\r\n" +
                "\r\n" +
                "\r\n" +
                "**** Registration Keys for Version 5.7 ***** \r\n" +
                "\r\n" +
                "\r\n" +
                "Version 5.1 and above support AUTOMATED LICENSE REGISTRATION. Please use the attached license file. This prevents you from having to type each key to register your copy of the software. Please refer to support wiki article http://www.naurtech.com/wiki/wiki.php?n=Main.AutoRegistration\r\n" +
                "";

            string testFile = utils.helpers.getAppPath() + "LicenseXMLFileSample.xml";
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            //read file into memorystream
            using (System.IO.FileStream file = new System.IO.FileStream(testFile, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                byte[] bytes = new byte[file.Length];
                file.Read(bytes, 0, (int)file.Length);
                ms.Write(bytes, 0, (int)file.Length);
                ms.Flush();
            }

            Attachement[] atts = new Attachement[] { new Attachement(ms, "test.xml") };
            MailMessage msg = new MailMessage("E841719", sBody, "License Keys - Order: 15476: [NAU-1504] CETerm for Windows CE 6.0 / 5.0 / CE .NET", atts, DateTime.Now);

            this.Cursor = Cursors.WaitCursor;
            this.Enabled = false;
            Application.DoEvents();
            int i = _licenseMail.processMail(msg);
            this.Enabled = true;
            this.Cursor = Cursors.Default;
            Application.DoEvents();

            //setLblStatus("Updated data. Use refresh";
            doRefresh();
        }
Beispiel #5
0
        public int processAttachement(Attachement att, LicenseMailBodyData data, IMailMessage mail)
        {
            int iCount=0;
            LicenseXML xmlData = LicenseXML.Deserialize(att.data);

            foreach(license ldata in xmlData.licenses){
                utils.helpers.addLog("processAttachement: new LicenseData...\r\n");
                LicenseData licenseData = new LicenseData(ldata.id, ldata.user, ldata.key, data.OrderNumber, data.OrderDate, data.yourPOnumber, data.EndCustomer, data.Product, data.Quantity, mail.User, mail.timestamp);
                //if (_licenseDataBase.addQueued(licenseData))
                utils.helpers.addLog("firing license_mail event\r\n");
                OnStateChanged(new StatusEventArgs(StatusType.license_mail, licenseData));
                iCount++;
                //if (_licenseDataBase.add(ldata.id, ldata.user, ldata.key, data.OrderNumber, data.OrderDate, data.yourPOnumber, data.EndCustomer, data.Product, data.Quantity, mail.User, mail.timestamp))
                //    iCount++;
                //utils.helpers.addLog("start _licenseDataBase.add() done\r\n");

            }
                    #region alternative_code
                    /*
                    // Request all the attachments on the email message. This results in a GetItem operation call to EWS.
                    m.Load(new Microsoft.Exchange.WebServices.Data.PropertySet(Microsoft.Exchange.WebServices.Data.EmailMessageSchema.Attachments));
                    foreach (Microsoft.Exchange.WebServices.Data.Attachment att in m.Attachments)
                    {
                        if (att is Microsoft.Exchange.WebServices.Data.FileAttachment)
                        {
                            Microsoft.Exchange.WebServices.Data.FileAttachment fileAttachment = att as Microsoft.Exchange.WebServices.Data.FileAttachment;

                            //get a temp file name
                            string fname = System.IO.Path.GetTempFileName(); //utils.helpers.getAppPath() + fileAttachment.Id.ToString() + "_" + fileAttachment.Name

                            // Load the file attachment into memory. This gives you access to the attachment content, which
                            // is a byte array that you can use to attach this file to another item. This results in a GetAttachment operation
                            // call to EWS.
                            fileAttachment.Load();

                            // Load attachment contents into a file. This results in a GetAttachment operation call to EWS.
                            fileAttachment.Load(fname);
                            addLog("Attachement file saved to: " + fname);

                            // Put attachment contents into a stream.
                            using (System.IO.FileStream theStream =
                                new System.IO.FileStream(utils.helpers.getAppPath() + fileAttachment.Id.ToString() + "_" + fileAttachment.Name, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
                            {
                                //This results in a GetAttachment operation call to EWS.
                                fileAttachment.Load(theStream);
                            }

                            //load into memory stream, seems the only stream supported
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(att.Size))
                            {
                                fileAttachment.Load(ms);
                                using (System.IO.FileStream fs = new System.IO.FileStream(fname, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
                                {
                                    ms.CopyTo(fs);
                                    fs.Flush();
                                }
                            }
                            addLog("saved attachement: " + fname);
                            iRet++;
                        }
                    }
                    */
                    #endregion
            return iCount;
        }
Beispiel #6
0
 public void addAttachement(Attachement att)
 {
     attList.Add(att);
 }