public static bool CheckFileExists(string FileName, string FolderID, string ContLanguage,string TaxonomyID)
 {
     ContentAPI cApi = new ContentAPI();
         cApi.ContentLanguage = Convert.ToInt32(ContLanguage);
         Ektron.ASM.AssetConfig.AssetData assetDat = new Ektron.ASM.AssetConfig.AssetData();
         Int64 taxID = -1;
         Int64.TryParse(TaxonomyID, out taxID);
         assetDat = cApi.EkContentRef.GetAssetDataBasedOnFileName(Path.GetFileName(FileName), Convert.ToInt64(FolderID), taxID);
         if ((assetDat != null)&& assetDat.ID != "" && assetDat.Name != "")
         {
             return true;
         }
         else
         {
             return false;
         }
 }
예제 #2
0
    public static string CheckFileExists(string FileName, string FolderID, string ContLanguage, string taxonomyID)
    {
        ContentAPI cApi = new ContentAPI();
        string cStatus = string.Empty;
        cApi.ContentLanguage = Convert.ToInt32(ContLanguage);
        Ektron.ASM.AssetConfig.AssetData assetDat = new Ektron.ASM.AssetConfig.AssetData();

        assetDat = cApi.EkContentRef.GetAssetDataBasedOnFileName(Path.GetFileName(FileName.Replace("'", "_")), Convert.ToInt64(FolderID), Convert.ToInt64(taxonomyID));
        if (assetDat != null && assetDat.ID != "" && assetDat.Name != "")
        {
            ContentStateData myContentStateData = new ContentStateData();
            myContentStateData = cApi.GetContentState(Convert.ToInt64(assetDat.ID));
            cStatus = myContentStateData.Status;
            if (cStatus == "O")
            {
                //Set Property variable that identify the user by whom the content is checked out
                if (myContentStateData.CurrentUserId == cApi.UserId)
                    cStatus = "A";
            }
            return cStatus;
        }
        else
            return "";
    }
    protected void uploadFile_Click(object sender, EventArgs e)
    {
        string fileName = string.Empty;
            HttpPostedFile fileUpld = ekFileUpload.PostedFile;
            string hasValidExtension = "";
            List<string> AllowedFileTypes = new List<string>();

            AllowedFileTypes.AddRange(DocumentManagerData.Instance.FileTypes.ToString().Split(','.ToString().ToCharArray()));
            if (fileUpld.ContentLength > 0)
            {
                Ektron.Cms.UserAPI uAPI = new UserAPI();

                _fileExtension = Path.GetExtension(fileUpld.FileName);
                //hasValidExtension = (string) (AllowedFileTypes.Find(new Predicate<string>(new System.EventHandler(CheckExtension))));
                hasValidExtension = AllowedFileTypes.Find(new Predicate<string>(CheckExtension));

                if ((hasValidExtension != null)&& hasValidExtension != "")
                {

                    //If Image Gallery, Should check if the file type is an image file type
                    if ((Request.QueryString["prop"] != null)&& Request.QueryString["prop"].ToLower() == "image")
                    {
                        if (! Ektron.Cms.Common.EkFunctions.IsImage(_fileExtension))
                        {
                            ltrStatus.Text = m_refMsg.GetMessage("msg invalid file upload images only");
                            setInvalid();
                            return;
                        }
                    }

                    fileName = Path.GetFileName(fileUpld.FileName);
                    int fileLength = fileUpld.ContentLength;
                    byte[] fileData = new byte[fileLength - 1+ 1];
                    string file = Convert.ToString(fileUpld.InputStream.Read(fileData, 0, fileLength));

                    if (fileData.Length > 0)
                    {
                        System.IO.MemoryStream stream = new System.IO.MemoryStream(fileData);
                        m_refContApi.RequestInformationRef.UserId = uAPI.UserId;
                        m_refContApi.ContentLanguage = _contentLanguage;

                        Ektron.ASM.AssetConfig.AssetData asstData = new Ektron.ASM.AssetConfig.AssetData();
                        Ektron.Cms.API.Content.Content cContent = new Ektron.Cms.API.Content.Content();
                        asstData = m_refContApi.EkContentRef.GetAssetDataBasedOnFileName(fileName, _folderID, _taxonomyID);
                        if ((asstData != null)&& asstData.ID != "" && asstData.Name != "")
                        {
                            Ektron.Cms.AssetUpdateData astData = new AssetUpdateData();
                            TaxonomyBaseData[] taxonomyCatArray = null;
                            _contentID = Convert.ToInt64(asstData.ID);
                            ContentData cData = cContent.GetContent(_contentID, Ektron.Cms.ContentAPI.ContentResultType.Published);

                            astData.FileName = fileName;
                            astData.FolderId = _folderID;
                            astData.ContentId = cData.Id;
                            astData.Teaser = cData.Teaser;
                            astData.Comment = cData.Comment;
                            astData.Title = cData.Title;
                            astData.GoLive = cData.GoLive;
                            astData.TaxonomyTreeIds = this._taxonomyID.ToString();

                            //Assigning the categories
                            taxonomyCatArray = m_refContApi.ReadAllAssignedCategory(_contentID);
                            if ((taxonomyCatArray != null)&& taxonomyCatArray.Length > 0)
                            {
                                foreach (TaxonomyBaseData tBaseData in taxonomyCatArray)
                                {
                                    if (astData.TaxonomyTreeIds == "")
                                    {
                                        astData.TaxonomyTreeIds = tBaseData.TaxonomyId.ToString();
                                    }
                                    else
                                    {
                                        astData.TaxonomyTreeIds += (string) ("," + tBaseData.TaxonomyId.ToString());
                                    }
                                }
                            }

                            //Assigning the metadatas
                            if ((cData.MetaData != null)&& cData.MetaData.Length > 0)
                            {
                                astData.MetaData = new Ektron.Cms.AssetUpdateMetaData[cData.MetaData.Length - 1 + 1];
                                for (int i = 0; i <= cData.MetaData.Length - 1; i++)
                                {
                                    astData.MetaData[i] = new AssetUpdateMetaData();
                                    astData.MetaData[i].TypeId = cData.MetaData[i].TypeId;
                                    astData.MetaData[i].ContentId = cData.Id;
                                    astData.MetaData[i].Text = cData.MetaData[i].Text;
                                }
                            }
                            astData.EndDate = cData.EndDate;
                            astData.EndDateAction = (Ektron.Cms.Common.EkEnumeration.CMSEndDateAction) (Enum.Parse(typeof(Ektron.Cms.Common.EkEnumeration.CMSEndDateAction), cData.EndDateAction.ToString(), true));

                            //Updating the Content
                            bool isUpdated = m_refContApi.EditAsset(stream, astData);
                        }
                        else
                        {
                            Ektron.Cms.AssetUpdateData astData = new AssetUpdateData();
                            astData.FileName = fileName;
                            astData.FolderId = _folderID;
                            astData.Title = Path.GetFileNameWithoutExtension(fileName);
                            astData.LanguageId = _contentLanguage;
                            astData.TaxonomyTreeIds = this._taxonomyID.ToString();
                            _contentID = m_refContApi.AddAsset(stream, astData);
                        }

                        jsMetaUrl.Text = "";
                        if (m_refContApi.EkContentRef.DoesFolderRequireMetadataOrTaxonomy(_folderID, _contentLanguage))
                        {
                            var _taxString = string.Empty;
                            if (this._taxonomyID != -1)
                            {
                                _taxString = (string) ("&taxonomyId=" + this._taxonomyID);
                            }
                            jsMetaUrl.Text = m_refContApi.AppPath + "DMSMetadata.aspx?contentId=" + _contentID + "&idString=" + _contentID + "&folderId=" + _folderID + _taxString + "&close=true&EkTB_iframe=true&height=550&width=650&modal=true&refreshCaller=true";
                        }

                        isFileUploadComplete.Value = "true";
                        ClientScript.RegisterStartupScript(this.GetType(), "closeThickBox", "uploadClick();", true);
                    }
                }
                else
                {
                    ltrStatus.Text = m_refMsg.GetMessage("msg invalid file upload");
                    setInvalid();
                }
            }
            else
            {
                ltrStatus.Text = m_refMsg.GetMessage("lbl upload file");
                setInvalid();
            }
    }
예제 #4
0
    protected void uploadFile_Click(object sender, EventArgs e)
    {
        string fileName = string.Empty;
        HttpPostedFile fileUpld = ekFileUpload.PostedFile;
        string hasValidExtension = "";
        List<string> AllowedFileTypes = new List<string>();
        bool createOverwriteThumbnail = false;
        bool isImageAsset = false;
        ContentData cData;

        long _checkTaxID = -1;
        AllowedFileTypes.AddRange(DocumentManagerData.Instance.FileTypes.ToString().Split(','));
        if (fileUpld.ContentLength > 0)
        {
            Ektron.Cms.UserAPI uAPI = new UserAPI();

            _fileExtension = Path.GetExtension(fileUpld.FileName);

            //If its an image asset then create/overwrite the thumbnail
            isImageAsset = Ektron.Cms.Common.EkFunctions.IsImage(_fileExtension);
            if (isImageAsset && !isMetadataOrTaxonomyRequired)
                createOverwriteThumbnail = true;

            hasValidExtension = AllowedFileTypes.Find(new Predicate<string>(delegate(string t) { return t.ToLower().Replace(" ", "") == ("*" + _fileExtension.ToLower()); }));
            if (hasValidExtension != null && hasValidExtension != "")
            {
                //If Image Gallery, Should check if the file type is an image file type
                if (Request.QueryString["isimage"] != null && Request.QueryString["isimage"] != "" && Convert.ToInt32(Request.QueryString["isimage"]) == 1)
                {
                    if (!isImageAsset)
                    {
                        _bTrue = false;
                        ltrStatus.Text = _messageHelper.GetMessage("msg invalid file upload images only");
                        setInvalid();
                    }

                }

                fileName = Path.GetFileName(fileUpld.FileName);
                if (fileName.IndexOf("&") > -1 || fileName.IndexOf("+") > -1 || fileName.IndexOf("%") > -1)
                {
                    _bTrue = false;
                    ltrStatus.Text = _messageHelper.GetMessage("msg cannot add file with add and plus");
                    setInvalid();
                }

                if (_bTrue)
                {
                    int fileLength = fileUpld.ContentLength;
                    byte[] fileData = new byte[fileLength];
                    string file = Convert.ToString(fileUpld.InputStream.Read(fileData, 0, fileLength));

                    if (fileData.Length > 0)
                    {
                        System.IO.Stream stream = new System.IO.MemoryStream(fileData);

                        if (isImageAsset)
                        {
                            if (!EkFunctions.isImageStreamValid(stream))
                            {
                                stream.Flush();
                                stream.Close();
                                setInvalid();
                                ltrStatus.Text = "The image is corrupted or not in correct format.";
                                return;
                            }
                            stream.Position = 0;
                        }

                        contentAPI.RequestInformationRef.UserId = uAPI.UserId;
                        contentAPI.ContentLanguage = _contentLanguage;

                        Ektron.ASM.AssetConfig.AssetData asstData = new Ektron.ASM.AssetConfig.AssetData();
                        Ektron.Cms.API.Content.Content cContent = new Ektron.Cms.API.Content.Content();
                        if (_isImageGallery)
                            _checkTaxID = Convert.ToInt64(_taxonomyIdList);
                        asstData = contentAPI.EkContentRef.GetAssetDataBasedOnFileName(fileName.Replace("'", "_"), _folderID, _checkTaxID);
                        if ((asstData != null && asstData.ID != "" && asstData.Name != "") || !String.IsNullOrEmpty(Request.QueryString["AssetID"]))
                        {
                            Ektron.Cms.AssetUpdateData astData = new AssetUpdateData();
                            TaxonomyBaseData[] taxonomyCatArray = null;
                            if (!String.IsNullOrEmpty(Request.QueryString["AssetID"]))
                                _contentID = Convert.ToInt64(Request.QueryString["AssetID"]);
                            else
                                _contentID = Convert.ToInt64(asstData.ID);
                            cData = cContent.GetContent(_contentID, Ektron.Cms.ContentAPI.ContentResultType.Published);

                            astData.FileName = fileName;
                            astData.FolderId = _folderID;
                            astData.ContentId = cData.Id;
                            astData.Teaser = cData.Teaser;
                            astData.Comment = cData.Comment;
                            astData.Title = cData.Title;
                            astData.GoLive = cData.GoLive;

                            //Assigning the categories
                            taxonomyCatArray = contentAPI.ReadAllAssignedCategory(_contentID);
                            if (taxonomyCatArray != null && taxonomyCatArray.Length > 0)
                            {
                                foreach (TaxonomyBaseData tBaseData in taxonomyCatArray)
                                {
                                    if (astData.TaxonomyTreeIds == "")
                                        astData.TaxonomyTreeIds = tBaseData.TaxonomyId.ToString();
                                    else
                                        astData.TaxonomyTreeIds += "," + tBaseData.TaxonomyId.ToString();
                                }
                            }

                            //Assigning the metadata
                            if (cData.MetaData != null && cData.MetaData.Length > 0)
                            {
                                astData.MetaData = new AssetUpdateMetaData[cData.MetaData.Length - 1];
                                for (int i = 0; i < cData.MetaData.Length - 1; i++)
                                {
                                    astData.MetaData[i] = new AssetUpdateMetaData();
                                    astData.MetaData[i].TypeId = cData.MetaData[i].TypeId;
                                    astData.MetaData[i].ContentId = cData.Id;
                                    astData.MetaData[i].Text = cData.MetaData[i].Text;
                                }
                            }
                            astData.EndDate = cData.EndDate;
                            astData.EndDateAction = (Ektron.Cms.Common.EkEnumeration.CMSEndDateAction)cData.EndDateAction;

                            //Updating the Content
                            bool isUpdated = contentAPI.EditAsset(stream, astData);

                            //Creating the thumbnail, as service takes a while to generate and we see a broken Image in that time.
                            if (!isUpdated && createOverwriteThumbnail)
                            {
                                cData = contentAPI.ShowContentById(cData.Id, contentAPI.CmsPreview, !contentAPI.CmsPreview);
                                if (cData.Status.ToLower() == "a")
                                    CreateThumbNailIfOneDoesntExist(GetPath(cData), 125, true);
                            }
                        }
                        else
                        {
                            Ektron.Cms.AssetUpdateData astData = new AssetUpdateData();
                            astData.FileName = fileName;
                            astData.FolderId = _folderID;
                            astData.TaxonomyTreeIds = _taxonomyIdList;
                            astData.Teaser = FillImageGalleryDescription();
                            astData.Title = Path.GetFileNameWithoutExtension(fileName);
                            astData.LanguageId = _contentLanguage;
                            _contentID = contentAPI.AddAsset(stream, astData);
                            //----------------searchable---------------------
                            IsContentSearchableSection(_contentID);
                            //----------------searchableEnd------------------
                            //Creating the thumbnail, as service takes a while to generate and we see a broken Image in that time.
                            if (_contentID > 0 && createOverwriteThumbnail)
                            {
                                cData = contentAPI.ShowContentById(_contentID, contentAPI.CmsPreview, !contentAPI.CmsPreview);
                                if (cData.Status.ToLower() == "a")
                                    CreateThumbNailIfOneDoesntExist(GetPath(cData), 125, false);
                            }
                        }
                        jsMetaUrl.Text = "";

                        if (isMetadataOrTaxonomyRequired || (isUrlAliasRequired && !EkFunctions.IsImage(Path.GetExtension(fileName))))
                        {
                            //put item into check-in state:
                            contentAPI.EkContentRef.CheckContentOutv2_0(_contentID);
                            contentAPI.EkContentRef.CheckIn(_contentID, "");

                            string _taxString = string.Empty;
                            if (_taxonomyIdList != "")
                                _taxString = "&taxonomyId=" + _taxonomyIdList;
                            jsMetaUrl.Text = contentAPI.AppPath + "DMSMetadata.aspx?contentId=" + _contentID + "&idString=" + _contentID + "&folderId=" + _folderID + _taxString + "&close=true&EkTB_iframe=true&height=550&width=650&modal=true&refreshCaller=true"; ;
                        }

                        isFileUploadComplete.Value = "true";
                        ClientScript.RegisterStartupScript(this.GetType(), "closeThickBox", "uploadClick();", true);
                    }
                }
            }
            else
            {
                setInvalid();
                ltrStatus.Text = _messageHelper.GetMessage("msg invalid file upload");
            }
        }
        else
        {
            setInvalid();
            ltrStatus.Text = _messageHelper.GetMessage("lbl upload file");
        }
    }
예제 #5
0
    private void Page_Load(System.Object sender, System.EventArgs e)
    {
        try
        {
            bool fileChanged = true;
            string assetId;
            List<AssetFileData> assetIdFileNameList = null;
            List<AssetFileData> tempAssetIdFileNameList = new List<AssetFileData>();
            m_refContent = AppUI.EkContentRef;
            if (Request.Form["type"] != null)
            {
                actionType = (string)(Request.Form["type"].Trim().ToLower());
            }

            if (Request.Form["requireMetaTaxonomy"] != null)
            {
                isCallerDmsDragDropCtl = true;
            }

            m_refContApi = new ContentAPI();
            m_refMsg = m_refContApi.EkMsgRef;
            if (!String.IsNullOrEmpty(Request.Form["content_language"]))
            {

                ContentLanguage = Convert.ToInt32(Request.Form["content_language"]);
                if (ContentLanguage == Ektron.Cms.Common.EkConstants.CONTENT_LANGUAGES_UNDEFINED || ContentLanguage == Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES)
                {
                    ContentLanguage = AppUI.DefaultContentLanguage;
                }
                AppUI.ContentLanguage = ContentLanguage;
                m_refContApi.ContentLanguage = ContentLanguage;

            }
            if (actionType.ToLower() == "add" && (Request.QueryString["SelTaxonomyId"] != null) && Request.QueryString["SelTaxonomyId"] != "")
            {
                TaxonomySelectId = Convert.ToInt64(Request.QueryString["SelTaxonomyId"]);
            }
            userId = Convert.ToInt64(Ektron.Cms.CommonApi.GetEcmCookie()["user_id"]);
            loginToken = Convert.ToInt32(Ektron.Cms.CommonApi.GetEcmCookie()["unique_id"]);

            if ((Request.Form["taxonomyselectedtree"] != null) && Request.Form["taxonomyselectedtree"].ToString().Length > 1)
            {
                jsTaxonomyIdReloadFrame.Text = Request.Form["taxonomyselectedtree"].ToString();
                if (Request.Form["taxonomyselectedtree"].ToString().Split(",".ToCharArray()) != null)
                {
                    jsTaxonomyId.Text = (Request.Form["taxonomyselectedtree"].ToString().Split(",".ToCharArray()))[0];
                }
            }

            if (Request.Form["editaction"] == "cancel")
            {
                Session.Remove(Convert.ToString(userId) + Convert.ToString(loginToken) + "Attachments");
                if ((actionType != "add") && (Request.Form["content_id"] != "" && Convert.ToInt64(Request.Form["content_id"]) > 0))
                {
                    string status = m_refContApi.GetContentStatusById(Convert.ToInt64(Request.Form["content_id"]));
                    if (status.ToLower() == "o") //28710 - if asset is a office file status = "A" on saving in word
                    {
                        m_refContent.UndoCheckOutv2_0(Convert.ToInt64(Request.Form["content_id"]));
                    }
                    if (Request.Form["FromEE"] == "true" || Request.QueryString["close"] == "true")
                    {
                        if (Request.QueryString["close"] == "true")
                        {
                            Response.Redirect("close.aspx?reload=true", false);
                            return;
                        }
                        else
                        {
                            Response.Redirect("close.aspx", false);
                            return;
                        }
                    }
                    else
                    {
                        Response.Redirect((string)("content.aspx?id=" + Request.Form["content_id"] + "&action=viewstaged&LangType=" + m_refContApi.ContentLanguage), false);
                        return;
                    }
                }
                else
                {
                    if (Request.Form["FromEE"] == "true" || Request.QueryString["close"] == "true")
                    {
                        if (Request.QueryString["close"] == "true")
                        {
                            Response.Redirect("close.aspx?reload=true", false);
                            return;
                        }
                        else
                        {
                            Response.Redirect("close.aspx", false);
                            return;
                        }
                    }
                    else
                    {
                        Response.Redirect((string)("content.aspx?id=" + Request.Form["content_folder"] + "&action=ViewContentByCategory&LangType=" + m_refContApi.ContentLanguage), false);
                        return;
                    }
                }
            }

            int i;
            for (i = 0; i <= m_AssetInfoKeys.Length - 1; i++)
            {
                asset_info.Add(m_AssetInfoKeys[i], "");
            }
            if (actionType != "multiple,add")
            {
                if ((Request.Form["asset_assetid"] != null) && (Request.Form["asset_assetid"].Length > 1))
                {
                    assetId = Request.Form["asset_assetid"];
                }
                else
                {
                    assetId = System.Guid.NewGuid().ToString();
                }
                Response.Expires = -1;
                Response.AddHeader("Pragma", "no-cache");
                Response.AddHeader("cache-control", "no-store");
                string ErrDescription = "";
                string filename;
                if (Request.Files["fileupload"] != null)
                {
                    fileChanged = true;
                    filename = Request.Files["fileupload"].FileName;

                    string[] DMSFileTypes = DocumentManagerData.Instance.FileTypes.Replace("*","").Split(',');
                    bool IsFileTypeAllowed = false;

                    if (DMSFileTypes != null && !string.IsNullOrEmpty(filename))
                    {
                        if (Array.FindIndex(DMSFileTypes, x => x.ToString().Trim().ToLower() == filename.Substring(filename.IndexOf(".")).ToLower()) >= 0)
                        {
                            IsFileTypeAllowed = true;
                        }
                    }

                    if (actionType == "add")
                    {
                        Ektron.ASM.AssetConfig.AssetData astData = new Ektron.ASM.AssetConfig.AssetData();
                        astData = m_refContent.GetAssetDataBasedOnFileName(Path.GetFileName(filename), Convert.ToInt64(Request.Form["content_folder"]), -1);
                        if (astData != null && astData.ID != "" && astData.Name != "")
                        {
                            ErrDescription = "A content with title: " + astData.Name + " and ID: " + astData.ID + " already exists with the file name: " + Path.GetFileName(filename) + ". Please use a different filename.";
                            Response.Redirect((string)("reterror.aspx?info=" + ErrDescription), false);
                            return;
                        }
                    }
                    if (filename.Trim() == "")
                    {
                        fileChanged = false;
                        filename = (string)(Request.Form["oldfilename"].ToString());
                    }
                    else
                    {
                        if (!IsFileTypeAllowed)
                        {
                            EkException.LogException(String.Format("Attempt at uploading unallowed file type occurred from user id: {0}", this.userId));
                            ErrDescription = "The file has not been uploaded. Please see administrator.";
                            Response.Redirect("reterror.aspx?info=" + ErrDescription, false);
                            return;
                        }
                        try
                        {
                            string docFilePath = DocumentManagerData.Instance.WebSharePath;
                            if (!System.IO.Path.IsPathRooted(docFilePath))
                            {
                                docFilePath = Ektron.ASM.AssetConfig.Utilities.UrlHelper.GetAppPhysicalPath() + docFilePath;
                            }
                            string destFileName = docFilePath + Path.GetFileName(filename) + assetId;
                            using (BinaryReader br = new BinaryReader(Request.Files["fileupload"].InputStream))
                            {
                                byte[] buf;
                                using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(destFileName, FileMode.Create)))
                                {
                                    buf = br.ReadBytes(bufSize);

                                    if (EkFunctions.IsImage(Path.GetExtension(filename)))
                                    {
                                        System.IO.Stream streamTmp=new System.IO.MemoryStream(buf);
                                        if (!EkFunctions.isImageStreamValid(streamTmp))
                                        {
                                            streamTmp.Flush();
                                            streamTmp.Close();
                                            throw new Exception("The image is corrupted or not in correct format.");
                                        }
                                        streamTmp.Flush();
                                        streamTmp.Close();
                                    }

                                    int index = 0;
                                    while (buf.Length > 0)
                                    {
                                        binaryWriter.Write(buf, 0, buf.Length);
                                        index += buf.Length;
                                        buf = br.ReadBytes(bufSize);
                                    }
                                    binaryWriter.Flush();
                                    binaryWriter.Close();
                                }

                                br.Close();
                            }
                        }
                        catch (Exception ex)
                        {

                            throw ex;
                        }
                    }
                }
                else
                {
                    filename = (string)(Request.Form["filename"].ToString());
                    fileChanged = false;
                }
                ProcessPage(filename, assetId, fileChanged, null);
            }
            else
            {
                bool isOfc2010 = false;
                if (Request.Cookies[DMSCookieName] != null && !string.IsNullOrEmpty(Request.Cookies[DMSCookieName].Value))
                {
                    if (Request.Cookies[DMSCookieName].Value == "2010")
                    {
                        isOfc2010 = true;
                    }
                }
                if (isOfc2010)
                {
                    ProcessUploadOffice2010();
                }
                else
                {
                    #region originalupload
                    if (Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "Attachments"] != null)
                    {
                        assetIdFileNameList = (List<AssetFileData>)Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "Attachments"];
                        Session.Remove(Convert.ToString(userId) + Convert.ToString(loginToken) + "Attachments");
                    }
                    //If coming from photo/image gallery, do not upload any files if a single invalid file is found
                    if ((Request.Form["isImage"] != null) && Request.Form["isImage"].ToString() == "1")
                    {
                        List<string> allFilesList = null;
                        if (Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "AllPostedFiles"] != null)
                        {
                            allFilesList = (List<string>)Session[userId + loginToken + "AllPostedFiles"];
                            Session.Remove(Convert.ToString(userId) + Convert.ToString(loginToken) + "AllPostedFiles");
                        }
                        string invalidFilesMsg = "";
                        if (allFilesList != null)
                        {
                            for (int index = 0; index <= allFilesList.Count - 1; index++)
                            {
                                if (!EkFunctions.IsImage(Path.GetExtension(System.Convert.ToString(allFilesList[index]))))
                                {
                                    invalidFilesMsg = System.Convert.ToString(allFilesList[index]);
                                    this.jsInvalidFiles.Text = "Only images can be uploaded here, invalid file type found: " + invalidFilesMsg.Replace("\\", "\\\\").Replace("\'", "\\\'") + "\\nNo images have been uploaded.";
                                    this.uxAlertInvalidFileType.Visible = true;
                                    this.uxCloseThickBox.Visible = true;
                                    return;
                                }
                            }
                        }
                    }
                    if (assetIdFileNameList != null && assetIdFileNameList.Count > 0)
                    {
                        for (int index = 0; index <= assetIdFileNameList.Count - 1; index++)
                        {
                            if (assetIdFileNameList[index].FileName.IndexOfAny(new char[] { '&', '%', '+' }) > -1)
                            {
                                this.jsInvalidFiles.Text = "Some files with &,+ or % could not be uploaded";
                                this.uxAlertInvalidFileType.Visible = true;
                            }
                            else
                            {
                                tempAssetIdFileNameList.Add(assetIdFileNameList[index]);
                            }
                        }
                        assetIdFileNameList = tempAssetIdFileNameList;
                    }
                    fileChanged = true;
                    if ((assetIdFileNameList != null) && assetIdFileNameList.Count > 0)
                    {
                        ProcessPage("", "", true, assetIdFileNameList);
                    }
                    else
                    {
                        //if any files were rejected
                        if (Request.Form["FromEE"] == "true" || Request.QueryString["close"] == "true")
                        {
                            if (Request.QueryString["close"] == "true")
                            {
                                Response.Redirect("close.aspx?reload=true", false);
                            }
                            else
                            {
                                Response.Redirect("close.aspx", false);
                            }
                        }
                        else
                        {
                            if (isCallerDmsDragDropCtl == true)
                            {
                                if ((Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "RejectedFiles"] != null) && Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "RejectedFiles"].ToString() != "")
                                {
                                    this.jsInvalidFiles.Text = m_refMsg.GetMessage("lbl error message for multiupload") + " " + Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "RejectedFiles"].ToString().Replace("\\", "\\\\").Replace("\'", "\\\'");
                                    this.jsInvalidFiles.Text += "\\n" + m_refMsg.GetMessage("js:cannot add file with add and plus");
                                    this.uxAlertInvalidFileType.Visible = true;
                                    Session.Remove(Convert.ToString(userId) + Convert.ToString(loginToken) + "RejectedFiles");
                                    this.uxCloseThickBox.Visible = true;
                                }
                                else
                                {
                                    Response.Redirect(Request.UrlReferrer.PathAndQuery + ((Request.UrlReferrer.PathAndQuery.IndexOf("showtab") > -1) ? "" : "&showtab=multiple"), false);
                                }

                            }
                            else
                            {
                                if ((Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "RejectedFiles"] == null) || Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "RejectedFiles"].ToString() == "")
                                {
                                    if ((Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "Attachments"] == null) || Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "Attachments"].ToString() == "")
                                    {
                                        if (Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "NoFilesToUpload"] == null)
                                        {
                                            Session.Add(Convert.ToString(userId) + Convert.ToString(loginToken) + "NoFilesToUpload", "NoFilesToUpload");
                                        }
                                        else
                                        {
                                            Session[Convert.ToString(userId) + Convert.ToString(loginToken) + "NoFilesToUpload"] = "NoFilesToUpload";
                                        }
                                    }
                                }
                                Response.Redirect((string)("content.aspx?id=" + Request.Form["content_folder"] + "&action=ViewContentByCategory&LangType=" + ContentLanguage), false);
                            }
                        }
                    }
                    #endregion
                }
            }

        }
        catch (Exception ex)
        {
            Utilities.ShowError(ex.Message.ToString());
        }
    }