Example #1
0
 /// <summary>
 /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
 /// </summary>
 /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
 protected override void OnInit(EventArgs e)
 {
     btnExport.Click += new EventHandler(BtnExport_Click);
     ProgressControl1.ProgressCompleted += new Mediachase.Commerce.Manager.Apps.Core.Controls.ProgressCompletedHandler(ProgressControl1_ProgressCompleted);
     FilesControl.Folder = ManagementHelper.GetImportExportFolderPath(_CatalogExportFolder);
     base.OnInit(e);
 }
Example #2
0
        /// <summary>
        /// Handles the Click event of the lbSaveFiles control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void lbSaveFiles_Click(object sender, EventArgs e)
        {
            FileStreamInfo[] fsi = FileUpCtrl.Files;
            if (fsi != null && fsi.Length > 0)
            {
                try
                {
                    StringBuilder filePath = new StringBuilder(Server.MapPath(ManagementHelper.GetImportExportFolderPath(_MetaDataImportFolder)));
                    filePath.Append(fsi[0].FileName);

                    if (File.Exists(filePath.ToString()))
                    {
                        File.Delete(filePath.ToString());
                    }

                    FileUpCtrl.SaveAs(fsi[0], filePath.ToString());
                    FileUpCtrl.ReleaseAll();

                    // update upload status
                    lblUploadResult.Text = String.Empty;                     //"File saved successfully.";
                    UploadResultPanel.Update();
                }
                catch (Exception ex)
                {
                    lblUploadResult.Text = ex.Message;
                    UploadResultPanel.Update();
                }
                finally
                {
                    FilesControl.DataBind();
                    FilesPanel.Update();
                }
            }
        }
Example #3
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            System.Web.UI.Control c = this.FindControl("trUploadedFiles");
            trUploadedFiles.Attributes.Add("onMCFListRefresh",
                                           String.Format("javascript:StateChanged('{0}', '{1}', '{2}');", fvControl.ClientID, fuActions.ClientID, trUploadedFiles.ClientID));

            FilesControl.Folder = ManagementHelper.GetImportExportFolderPath("tax");
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            FilesControl.Folder        = ManagementHelper.GetImportExportFolderPath("csv/data");
            MappingFilesControl.Folder = ManagementHelper.GetImportExportFolderPath("csv/rule");

            btnImport.Click += new EventHandler(btnImport_Click);
            ProgressControl1.ProgressCompleted += new Mediachase.Commerce.Manager.Apps.Core.Controls.ProgressCompletedHandler(ProgressControl1_ProgressCompleted);
            lbSaveFiles.Click += new EventHandler(lbSaveFiles_Click);
            base.OnInit(e);
        }
Example #5
0
        /// <summary>
        /// Does the export.
        /// </summary>
        private void DoExport(Guid appId)
        {
            AppContext.Current.ApplicationId = appId;

            try
            {
                string result = String.Empty;

                if (SiteId != Guid.Empty)
                {
                    // export site

                    StringBuilder filePath = new StringBuilder(Server.MapPath(ManagementHelper.GetImportExportFolderPath("site")));
                    filePath.AppendFormat("\\SiteExport_{0}_{1}_{2}.xml", SiteName.Replace(' ', '-'), DateTime.Now.ToString("yyyyMMdd_HHmmss"), System.Environment.MachineName);
                    FileStream fs = new FileStream(filePath.ToString(), FileMode.Create, FileAccess.ReadWrite);

                    try
                    {
                        PageDocument.Init(new SqlPageDocumentStorageProvider(), new SqlTemporaryStorageProvider());
                        _ImportExport = new Mediachase.Cms.ImportExport.ImportExportHelper();
                        _ImportExport.ImportExportProgressMessage += new SiteImportExportProgressMessageHandler(ImportExport_ImportExportProgressMessage);
                        _ImportExport.ExportSite(SiteId, fs);
                    }
                    catch (SiteImportExportException ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (fs != null)
                        {
                            fs.Close();
                        }

                        // refresh files grid
                        //FilesControl.DataBind();
                        //FilesPanel.Update();
                    }
                }
                else
                {
                    throw new Exception("SiteId is empty!");
                }
            }
            catch (Exception ex)
            {
                ProgressControl1.AddProgressMessageText(ex.Message, true, -1);
            }
            finally
            {
            }
        }
Example #6
0
        /// <summary>
        /// Handles the Click event of the lbSaveFiles control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void lbSaveFiles_Click(object sender, EventArgs e)
        {
            FileStreamInfo[] fsi = FileUpCtrl.Files;
            if (fsi != null && fsi.Length > 0)
            {
                try
                {
                    string filePath = Path.Combine(HttpContext.Current.Server.MapPath(ManagementHelper.GetImportExportFolderPath("catalog")), fsi[0].FileName);

                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }

                    FileUpCtrl.SaveAs(fsi[0], filePath);
                    FileUpCtrl.ReleaseAll();

                    // update upload status
                    lblUploadResult.Text = String.Empty;                     //"File saved successfully.";
                    UploadResultPanel.Update();
                }
                catch (Exception ex)
                {
                    lblUploadResult.Text = ex.Message;
                    UploadResultPanel.Update();
                }
                finally
                {
                    FilesControl.DataBind();
                    FilesPanel.Update();
                }
            }
        }
Example #7
0
        /// <summary>
        /// Processes the export button event.
        /// </summary>
        protected void DoExport(Guid appId)
        {
            AppContext.Current.ApplicationId = appId;

            try
            {
                if (!String.IsNullOrEmpty(CatalogName))
                {
                    // export site

                    StringBuilder sbDirName = new StringBuilder(Path.GetTempPath());
                    sbDirName.AppendFormat("CatalogExport_{0}_{1}_{2}", AppId, CatalogName, DateTime.Now.ToString("yyyyMMdd-HHmmss"));
                    string dirName = sbDirName.ToString();
                    if (Directory.Exists(dirName))
                    {
                        Directory.Delete(dirName, true);
                    }
                    DirectoryInfo dir = Directory.CreateDirectory(dirName);

                    string zipPath = Path.Combine(_CurrentHttpContext.Server.MapPath(ManagementHelper.GetImportExportFolderPath("catalog")), dir.Name);

                    StringBuilder filePath = new StringBuilder(dir.FullName);
                    filePath.AppendFormat("\\Catalog.xml");
                    FileStream fs = new FileStream(filePath.ToString(), FileMode.Create, FileAccess.ReadWrite);

                    try
                    {
                        _ImportExport.ImportExportProgressMessage += new Mediachase.Commerce.Catalog.ImportExport.ImportExportProgressMessageHandler(ImportExport_ImportExportProgressMessage);

                        int startTime = Environment.TickCount;

                        _ImportExport.Export(CatalogName, fs, Path.Combine(_CurrentHttpContext.Server.MapPath(ManagementHelper.GetImportExportFolderPath("catalog")), dirName));//dir.FullName);

                        if (fs != null)
                        {
                            fs.Close();
                            fs = null;
                        }

                        ProgressControl1.AddProgressMessageText("Creating zip file.", 99);

                        ZipHelper.CreateZip(dir.FullName, String.Concat(zipPath, ".zip"));

                        ProgressControl1.AddProgressMessageText("Finished.", 100);
                    }
                    catch (Mediachase.Commerce.Catalog.ImportExport.ImportExportException ex)
                    {
                        throw ex;
                    }
                    catch (Exception ex1)
                    {
                        throw ex1;
                    }
                    finally
                    {
                        if (fs != null)
                        {
                            fs.Close();
                        }

                        // delete temporary folder
                        if (Directory.Exists(dir.FullName))
                        {
                            Directory.Delete(dir.FullName, true);
                        }
                    }
                }                 // if (!String.IsNullOrEmpty(CatalogName))
                else
                {
                    throw new Exception("CatalogName is empty!");
                }
            }
            catch (Exception ex)
            {
                ProgressControl1.AddProgressMessageText(ex.Message, true, -1);
            }
            finally
            {
            }
        }