コード例 #1
0
ファイル: movefolderitem.ascx.cs プロジェクト: jaytem/minGit
    private void Process_MoveMultiContent()
    {
        long intMoveFolderId = 0;
            string strContentIds = "";
            string[] arrArray;
            int i = 0;
            string strContentLanguages = "";
            string[] arrLanguages;
            Ektron.Cms.Content.EkContent m_refContent;
            string FolderPath;
            int contCount = 0;
            SiteAPI m_refsite = new SiteAPI();

            try
            {
                m_refContent = m_refContentApi.EkContentRef;
                m_intFolderId = Convert.ToInt64(Request.Form[folder_id.UniqueID]);
                intMoveFolderId = m_refContent.GetFolderID(Request.Form["move_folder_id"]);
                arrArray = Strings.Split(Request.Form[contentids.UniqueID], ",", -1, 0);
                for (i = 0; i <= (arrArray.Length - 1); i++)
                {
                    if ((Request.Form["id_" + arrArray[i]]).ToString().IndexOf("on") + 1 > 0)
                    {
                        strContentIds = strContentIds + arrArray[i] + ",";
                    }
                }
                if (strContentIds != "")
                {
                    strContentIds = strContentIds.Substring(0, strContentIds.Length - 1);
                }
                arrLanguages = Strings.Split(Request.Form[contentlanguages.UniqueID], ",", -1, 0);
                for (i = 0; i <= (arrArray.Length - 1); i++)
                {
                    if ((Request.Form["id_" + arrArray[i]]).ToString().IndexOf("on") + 1 > 0)
                    {
                        strContentLanguages = strContentLanguages + arrLanguages[i] + ",";
                    }
                }
                if (strContentLanguages != "")
                {
                    strContentLanguages = strContentLanguages.Substring(0, strContentLanguages.Length - 1);
                }
                if (Request.Form[hdnCopyAll.UniqueID] == "true")
                {
                    bool publishContent = false;
                    if (! (Request.Form["btn_PublishCopiedContent"] == null) && Request.Form["btn_PublishCopiedContent"].ToString() == "on")
                    {
                        publishContent = true;
                    }
                    var countContentIds = strContentIds.Split(",".ToCharArray());
                    for (contCount = 0; contCount <= countContentIds.Length - 1; contCount++)
                    {
                        m_refContent.CopyAllLanguageContent(System.Convert.ToInt32(countContentIds[contCount]), intMoveFolderId, publishContent);
                    }
                }
                else
                {
                    if (! (Request.Form[RadBtnMoveCopyValue.UniqueID] == null) && Request.Form[RadBtnMoveCopyValue.UniqueID].ToString() == "copy")
                    {
                        bool bPublish = false;
                        if (! (Request.Form["btn_PublishCopiedContent"] == null) && Request.Form["btn_PublishCopiedContent"].ToString() == "on")
                        {
                            bPublish = true;
                        }
                        m_refContent.CopyContentByID(strContentIds, strContentLanguages, intMoveFolderId, bPublish);
                    }
                    else
                    {
                        m_refContent.MoveContent(strContentIds, strContentLanguages, intMoveFolderId);
                    }
                }

                FolderPath = m_refContent.GetFolderPath(intMoveFolderId);
                if ((FolderPath.Substring(FolderPath.Length - 1, 1) == "\\"))
                {
                    FolderPath = FolderPath.Substring(FolderPath.Length - FolderPath.Length - 1, FolderPath.Length - 1);
                }
                FolderPath = FolderPath.Replace("\\", "\\\\");
                Response.Redirect((string) ("content.aspx?LangType=" + ContentLanguage + "&action=ViewContentByCategory&id=" + intMoveFolderId + "&reloadtrees=Forms,Content,Library&TreeNav=" + FolderPath), false);

            }
            catch (Exception ex)
            {
                int intError;
                string strError;
                strError = "because a record with the same title exists in the destination folder";
                intError = ex.Message.IndexOf(strError);
                if (intError > -1)
                {
                    strError = ex.Message.Substring(0, intError + strError.Length);
                    Response.Redirect((string) ("reterror.aspx?info=" + EkFunctions.UrlEncode(strError + ".")), false);
                }
                else
                {
                    Response.Redirect((string) ("reterror.aspx?info=" + EkFunctions.UrlEncode(ex.Message)), false);
                }
            }
    }