示例#1
0
        private void DoImport(Guid siteId, Guid appId)
        {
            try
            {
                AppContext.Current.ApplicationId = appId;
                _ImportExport = new Mediachase.Cms.ImportExport.ImportExportHelper();                 //ImportExportHelper.Current;

                string filePath = SelectedFilePath;

                if (String.IsNullOrEmpty(filePath))
                {
                    throw new Exception("No selected file.");
                }

                // import site
                FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);

                try
                {
                    _ImportExport.ImportExportProgressMessage += new SiteImportExportProgressMessageHandler(ImportExport_ImportExportProgressMessage);
                    _ImportExport.ImportSite(fs, appId, siteId, false);

                    SelectedFilePath = null;
                }
                catch (SiteImportExportException ex)
                {
                    throw ex;
                }
                finally
                {
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                ProgressControl1.AddProgressMessageText(ex.Message, true, -1);
            }
            finally
            {
            }
        }
示例#2
0
        /// <summary>
        /// Handles the Click event of the btnImport 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 btnImport_Click(object sender, EventArgs e)
        {
            _ImportExport = new Mediachase.Cms.ImportExport.ImportExportHelper();             //ImportExportHelper.Current;

            Guid appId = GetCurrentApplicationId();

            string filePath = SelectedFilePath;

            if (String.IsNullOrEmpty(filePath))
            {
                throw new Exception("No selected file.");
            }

            // import site
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            Guid siteId = _ImportExport.GetSiteID(fs, appId);

            SiteDto sites = CMSContext.Current.GetSitesDto(appId);

            if (sites.Site.Count > 0)
            {
                CommandParameters           cp  = new CommandParameters("cmdShowDialogSiteImportConfirm");
                Dictionary <string, string> dic = new Dictionary <string, string>();

                if (!siteId.Equals(Guid.Empty))
                {
                    dic["SiteId"] = siteId.ToString();
                }
                cp.CommandArguments = dic;

                string cmd = CommandManager.GetCommandString("cmdShowDialogSiteImportConfirm", dic);
                cmd = cmd.Replace("\"", "&quot;");
                Mediachase.Ibn.Web.UI.WebControls.ClientScript.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString("N"), cmd, true);

                return;
            }

            // start import in a new thread
            ProgressControl1.StartOperation(new System.Threading.ThreadStart(delegate { DoImport(new Guid(), appId); }));
        }