Example #1
0
        protected void btnFroogleGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                string fileName = string.Format("froogle_{0}_{1}.xml", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4));
                string filePath = string.Format("{0}files\\froogle\\{1}", HttpContext.Current.Request.PhysicalApplicationPath, fileName);
                using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
                {
                    FroogleService.GenerateFeed(fs);
                }

                string clickhereStr = string.Format("<a href=\"{0}files/froogle/{1}\" target=\"_blank\">{2}</a>", CommonHelper.GetStoreLocation(false), fileName, GetLocaleResourceString("Admin.PromotionProviders.Froogle.ClickHere"));
                string result       = string.Format(GetLocaleResourceString("Admin.PromotionProviders.Froogle.SuccessResult"), clickhereStr);
                ShowMessage(result);
            }
            catch (Exception exc)
            {
                ProcessException(exc);
            }
        }
Example #2
0
        protected void btnFroogleFTPUpload_OnClick(object sender, EventArgs e)
        {
            try
            {
                this.SettingManager.SetParam("Froogle.FTPHostname", txtFroogleFTPHostname.Text);
                this.SettingManager.SetParam("Froogle.FTPFilename", txtFroogleFTPFilename.Text);
                this.SettingManager.SetParam("Froogle.FTPUsername", txtFroogleFTPUsername.Text);
                this.SettingManager.SetParam("Froogle.FTPPassword", txtFroogleFTPPassword.Text);

                string hostname = this.SettingManager.GetSettingValue("Froogle.FTPHostname");
                string filename = this.SettingManager.GetSettingValue("Froogle.FTPFilename");
                string uri      = String.Format("{0}/{1}", hostname, filename);
                string username = this.SettingManager.GetSettingValue("Froogle.FTPUsername");
                string password = this.SettingManager.GetSettingValue("Froogle.FTPPassword");


                FtpWebRequest req = WebRequest.Create(uri) as FtpWebRequest;
                req.Credentials = new NetworkCredential(username, password);
                req.KeepAlive   = true;
                req.UseBinary   = true;
                req.Method      = WebRequestMethods.Ftp.UploadFile;

                using (Stream reqStream = req.GetRequestStream())
                {
                    FroogleService.GenerateFeed(reqStream);
                }

                FtpWebResponse rsp = req.GetResponse() as FtpWebResponse;

                ShowMessage(String.Format(GetLocaleResourceString("Admin.PromotionProviders.Froogle.FTPUploadStatus"), rsp.StatusDescription));
            }
            catch (Exception exc)
            {
                ProcessException(exc);
            }
        }