/// <summary> /// Deletes the file binary from the file system. /// </summary> /// <param name="fileId">MetaFile ID</param> /// <param name="name">Returning the metafile name</param> protected bool DeleteFromFileSystem(int fileId, ref string name) { // Delete the file in file system MetaFileInfo mi = MetaFileInfoProvider.GetMetaFileInfo(fileId); if (mi != null) { name = mi.MetaFileName; // Ensure the binary column first (check if exists) DataSet ds = MetaFileInfoProvider.GetMetaFiles("MetaFileID = " + fileId, null, "CASE WHEN MetaFileBinary IS NULL THEN 0 ELSE 1 END AS HasBinary", -1); if (!DataHelper.DataSourceIsEmpty(ds)) { bool hasBinary = ValidationHelper.GetBoolean(ds.Tables[0].Rows[0][0], false); if (!hasBinary) { // Copy the binary data to database mi.MetaFileBinary = MetaFileInfoProvider.GetFile(mi, SiteInfoProvider.GetSiteName(mi.MetaFileSiteID)); mi.Generalized.UpdateData(); } // Delete the file from the disk MetaFileInfoProvider.DeleteFile(SiteInfoProvider.GetSiteName(mi.MetaFileSiteID), mi.MetaFileGUID.ToString(), true, false); return(true); } } return(false); }
protected void hdnPostback_Click(object sender, EventArgs e) { try { int fileId = ValidationHelper.GetInteger(hdnField.Value, 0); if (fileId > 0) { // Get uploaded meta file MetaFileInfo mfi = MetaFileInfoProvider.GetMetaFileInfo(fileId); // Set currently handled meta file CurrentlyHandledMetaFile = mfi; // Fire after upload event if (OnAfterUpload != null) { OnAfterUpload(this, EventArgs.Empty); } // Reload grid data gridFiles.ReloadData(); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } }
/// <summary> /// Processes a meta file upload for an existing e-product. /// Returns the ID of the related SKU file object if it was created or updated successfully, otherwise returns 0. /// </summary> private int ProcessUploadForExistingEproduct() { if (SKUID == 0) { // SKU does not exist return(0); } MetaFileInfo metaFile = fileListElem.CurrentlyHandledMetaFile; SKUFileInfo skuFile = null; DataSet skuFiles = SKUFileInfoProvider.GetSKUFiles().WhereEquals("FileMetaFileGUID", metaFile.MetaFileGUID); if (DataHelper.DataSourceIsEmpty(skuFiles)) { // Create a new SKU file skuFile = new SKUFileInfo() { FileSKUID = SKUID, FileMetaFileGUID = metaFile.MetaFileGUID }; } else { // Get an existing SKU file skuFile = new SKUFileInfo(skuFiles.Tables[0].Rows[0]); } skuFile.FileName = metaFile.MetaFileName; skuFile.FilePath = MetaFileInfoProvider.GetMetaFileUrl(metaFile.MetaFileGUID, metaFile.MetaFileName); skuFile.FileType = MediaSourceEnum.MetaFile.ToString(); SKUFileInfoProvider.SetSKUFileInfo(skuFile); return(skuFile.FileID); }
// Deserialize and check Est Entries and add them to the list if they are non-default. private void DeserializeEstEntries(MetaFileInfo metaFileInfo, byte[]?data) { if (data == null) { return; } var num = data.Length / 6; using var reader = new BinaryReader(new MemoryStream(data)); for (var i = 0; i < num; ++i) { var gr = ( GenderRace )reader.ReadUInt16(); var id = reader.ReadUInt16(); var value = reader.ReadUInt16(); var type = (metaFileInfo.SecondaryType, metaFileInfo.EquipSlot) switch { (BodySlot.Face, _) => EstManipulation.EstType.Face, (BodySlot.Hair, _) => EstManipulation.EstType.Hair, (_, EquipSlot.Head) => EstManipulation.EstType.Head, (_, EquipSlot.Body) => EstManipulation.EstType.Body, _ => (EstManipulation.EstType) 0, }; if (!gr.IsValid() || type == 0) { continue; } var def = EstFile.GetDefault(type, gr, id); if (def != value) { MetaManipulations.Add(new EstManipulation(gr.Split().Item1, gr.Split().Item2, type, id, value)); } }
/// <summary> /// Initializes metafile. /// </summary> private void InitializeMetaFile() { MetaFileInfo metaFileInfo = null; if (InfoObject != null) { metaFileInfo = InfoObject as MetaFileInfo; } else { // Get metafile metaFileInfo = MetaFileInfoProvider.GetMetaFileInfoWithoutBinary(ObjectGuid, SiteName, true); InfoObject = metaFileInfo; } // If file is not null and current user is global administrator then set image if (metaFileInfo != null) { // Check modify permission if (CheckPermissions && !UserInfoProvider.IsAuthorizedPerObject(metaFileInfo.MetaFileObjectType, metaFileInfo.MetaFileObjectID, PermissionsEnum.Modify, CMSContext.CurrentSiteName, CMSContext.CurrentUser)) { RedirectToAccessDenied(GetString("metadata.errors.filemodify")); } // Fire event GetObjectExtension if (GetObjectExtension != null) { GetObjectExtension(metaFileInfo.MetaFileExtension); } } else { URLHelper.Redirect("~/CMSMessages/Information.aspx?message=" + HttpUtility.UrlPathEncode(GetString("editedobject.notexists"))); } }
/// <summary> /// Handles the OnBeforeSave event of the Form control. /// </summary> private void Form_OnBeforeSave(object sender, EventArgs e) { if (FormObject != null) { switch (ThumbnailType) { case ThumbnailTypeEnum.Metafile: // Clear the Icon CSS class field FormObject.SetValue(IconCssFieldName, string.Empty); fontIconSelector.Value = string.Empty; break; case ThumbnailTypeEnum.CssClass: // Delete uploaded metafile Guid metaFileguid = ValidationHelper.GetGuid(Value, Guid.Empty); if (metaFileguid != Guid.Empty) { MetaFileInfo metaFile = MetaFileInfoProvider.GetMetaFileInfo(metaFileguid, FormObject.Generalized.ObjectSiteName, true); MetaFileInfoProvider.DeleteMetaFileInfo(metaFile); } // Delete the metafile thumbnail Value = null; FormObject.SetValue(Field, null); // Update the Icon CSS class field FormObject.SetValue(IconCssFieldName, fontIconSelector.Value); break; } } }
/// <summary> /// Handles the OnBeforeSave event of the Form control. /// </summary> private void Form_OnBeforeSave(object sender, EventArgs e) { if (FormObject != null) { switch (iconType) { case IconTypeEnum.Metafile: // Remove icon css class FormObject.SetValue(IconCssFieldName, null); txtCssClass.Text = string.Empty; break; case IconTypeEnum.CssClass: // Delete uploaded metafile Guid metaFileguid = ValidationHelper.GetGuid(Value, Guid.Empty); if (metaFileguid != Guid.Empty) { MetaFileInfo metaFile = MetaFileInfoProvider.GetMetaFileInfo(metaFileguid, null, true); MetaFileInfoProvider.DeleteMetaFileInfo(metaFile); } // Delete the metafile thumbnail Value = null; FormObject.SetValue(Field, null); // Update the Icon CSS class field FormObject.SetValue(IconCssFieldName, txtCssClass.Text); break; } } }
private void LoadMetafile() { if (metafile == null) { metafile = MetaFileInfoProvider.GetMetaFileInfoWithoutBinary(metafileGuid, CurrentSiteName, true); } }
// Deserialize and check Eqdp Entries and add them to the list if they are non-default. private void DeserializeEqdpEntries(MetaFileInfo metaFileInfo, byte[]?data) { if (data == null) { return; } var num = data.Length / 5; using var reader = new BinaryReader(new MemoryStream(data)); for (var i = 0; i < num; ++i) { // Use the SE gender/race code. var gr = ( GenderRace )reader.ReadUInt32(); var byteValue = reader.ReadByte(); if (!gr.IsValid() || !metaFileInfo.EquipSlot.IsEquipment() && !metaFileInfo.EquipSlot.IsAccessory()) { continue; } var value = Eqdp.FromSlotAndBits(metaFileInfo.EquipSlot, (byteValue & 1) == 1, (byteValue & 2) == 2); var def = new EqdpManipulation(ExpandedEqdpFile.GetDefault(gr, metaFileInfo.EquipSlot.IsAccessory(), metaFileInfo.PrimaryId), metaFileInfo.EquipSlot, gr.Split().Item1, gr.Split().Item2, metaFileInfo.PrimaryId); var manip = new EqdpManipulation(value, metaFileInfo.EquipSlot, gr.Split().Item1, gr.Split().Item2, metaFileInfo.PrimaryId); if (def.Entry != manip.Entry) { MetaManipulations.Add(manip); } } }
void fileListElem_OnBeforeDelete(object sender, CancelEventArgs e) { // Get meta file that is being deleted MetaFileInfo mfi = this.fileListElem.CurrentlyHandledMetaFile; // Get SKU files with meta file's GUID DataSet skuFiles = SKUFileInfoProvider.GetSKUFiles(String.Format("FileMetaFileGUID = '{0}'", mfi.MetaFileGUID), null); if (!DataHelper.DataSourceIsEmpty(skuFiles)) { // Get SKU file SKUFileInfo skufi = new SKUFileInfo(skuFiles.Tables[0].Rows[0]); if (skufi != null) { // If SKU file has no dependencies if (!SKUFileInfoProvider.CheckDependencies(skufi)) { // Delete SKU file information SKUFileInfoProvider.DeleteSKUFileInfo(skufi); } else { // Set error message about existing dependency this.ErrorMessage = this.GetString("ecommerce.deletedisabled"); this.lblAttachmentError.Text = this.ErrorMessage; // Cancel delete e.Cancel = true; } } } }
/// <summary> /// Checks and processes the dependencies of the meta file and related SKU file that is being deleted. /// Returns true if the related SKU file object that is being deleted has no existing dependencies and it can be deleted, otherwise returns false. /// </summary> private bool ProcessDeleteForExistingEproduct() { MetaFileInfo metaFile = fileListElem.CurrentlyHandledMetaFile; DataSet skuFiles = SKUFileInfoProvider.GetSKUFiles(String.Format("FileMetaFileGUID = '{0}'", metaFile.MetaFileGUID), null); if (!DataHelper.DataSourceIsEmpty(skuFiles)) { SKUFileInfo skuFile = new SKUFileInfo(skuFiles.Tables[0].Rows[0]); if (skuFile != null) { if (!SKUFileInfoProvider.CheckDependencies(skuFile)) { SKUFileInfoProvider.DeleteSKUFileInfo(skuFile); } else { ErrorMessage = GetString("ecommerce.deletedisabled"); return(false); } } } return(true); }
/// <summary> /// Transforms inline attachment source back to metafile attachment source. /// </summary> /// <param name="match">Regex match result for inline attachment source</param> /// <returns>MetaFile attachment source</returns> private static string TransformSrc(Match match) { if (match.Groups.Count > 0) { // Get content ID (metafile GUID without '-') and make GUID of it string cidCode = match.Groups["cidCode"].Value; Guid mfGuid = (cidCode.Length == 32) ? ValidationHelper.GetGuid(cidCode.Insert(20, "-").Insert(16, "-").Insert(12, "-").Insert(8, "-"), Guid.Empty) : Guid.Empty; if (mfGuid != Guid.Empty) { // Get metafile by GUID MetaFileInfo mfi = MetaFileInfoProvider.GetMetaFileInfo(mfGuid, null, false); if (mfi != null) { SiteInfo site = SiteInfoProvider.GetSiteInfo((mfi.MetaFileSiteID > 0) ? mfi.MetaFileSiteID : CMSContext.CurrentSiteID); if (site != null) { // return metafile source return("src=\"" + URLHelper.GetAbsoluteUrl("~/CMSPages/GetMetaFile.aspx?fileguid=" + mfGuid, site.DomainName) + "\""); } } } } return(match.Value); }
/// <summary> /// Ensures the info objects. /// </summary> private void LoadInfos() { switch (baseImageEditor.ImageType) { case ImageHelper.ImageTypeEnum.Metafile: if (mf == null) { mf = MetaFileInfoProvider.GetMetaFileInfoWithoutBinary(metafileGuid, CurrentSiteName, true); } break; case ImageHelper.ImageTypeEnum.PhysicalFile: // Skip loading info for physical files break; default: if (ai == null) { baseImageEditor.Tree = new TreeProvider(MembershipContext.AuthenticatedUser); // If using workflow then get versioned attachment if (VersionHistoryID != 0) { ai = DocumentHelper.GetAttachment(attachmentGuid, VersionHistoryID); } // Else get file without binary data else { ai = AttachmentInfoProvider.GetAttachmentInfoWithoutBinary(attachmentGuid, CurrentSiteName); } } break; } }
/// <summary> /// Processes a meta file upload for a new e-product. /// Returns the ID of the related SKU file object if it was created or updated successfully, otherwise returns 0. /// </summary> private int ProcessUploadForNewEproduct() { if (SKUID == 0) { // SKU does not exist return(0); } // Upload the file fileElem.ObjectID = SKUID; fileElem.UploadFile(); MetaFileInfo metaFile = fileElem.CurrentlyHandledMetaFile; if (metaFile == null) { // The file was not uploaded return(0); } // Create a new SKU file SKUFileInfo skuFile = new SKUFileInfo() { FileSKUID = SKUID, FileMetaFileGUID = metaFile.MetaFileGUID, FileName = metaFile.MetaFileName, FilePath = MetaFileInfoProvider.GetMetaFileUrl(metaFile.MetaFileGUID, metaFile.MetaFileName), FileType = MediaSourceEnum.MetaFile.ToString() }; SKUFileInfoProvider.SetSKUFileInfo(skuFile); return(skuFile.FileID); }
protected void gridFile_OnAction(string actionName, object actionArgument) { switch (actionName.ToLower()) { case "delete": try { // Get meta file ID int metaFileId = ValidationHelper.GetInteger(actionArgument, 0); // Get meta file MetaFileInfo mfi = MetaFileInfoProvider.GetMetaFileInfo(metaFileId); // Delete meta file MetaFileInfoProvider.DeleteMetaFileInfo(metaFileId); // Execute after delete event if (OnAfterDelete != null) { OnAfterDelete(this, null); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } break; } }
/// <summary> /// Uploads the product image meta file for a new product. /// Returns the ID of the uploaded meta file if it was uploaded successfully, otherwise returns 0. /// </summary> private int UploadImageForNewProduct() { if (SKUID == 0) { // SKU does not exist return(0); } HttpPostedFile file = metaFileElem.PostedFile; if ((file == null) || (file.ContentLength == 0)) { // No file was posted return(0); } metaFileElem.ObjectID = SKUID; metaFileElem.UploadFile(); MetaFileInfo metaFile = metaFileElem.CurrentlyHandledMetaFile; if (metaFile == null) { // The file was not uploaded return(0); } return(metaFile.MetaFileID); }
public BdExplorer() { metaFile = new MetaFileInfo(Path.Combine(BdDiscovery.PazLocation, "pad00000.meta")); metaFile.FillFileBlocks(); metaFile.FillPazFiles(); metaFile.FillFileBlockNames(); BuildFileTree(); }
public void Run() { Console.WriteLine("Check Check"); StopWatchUtils.WatchStopInit(); List <MetaFileInfo> lstMetaFileInfo = new List <MetaFileInfo>(); // 读取Unity目录. string strUnityAssetData = @"C:\svnWorks\android151_cjp"; DirectoryInfo diAssetData = new DirectoryInfo(strUnityAssetData); FileInfo[] metaFiles = diAssetData.GetFiles("*.meta", SearchOption.AllDirectories); foreach (var eachMetaFile in metaFiles) { // eachMetaFile.FullName string[] fileLines = File.ReadAllLines(eachMetaFile.FullName); // 再次遍历每个文件的每一行. foreach (var eachFileLine in fileLines) { if (eachFileLine.Contains("assetBundleName:")) { string handleEachLine = eachFileLine.Trim(); // 分开: string[] parts = handleEachLine.Split(':'); string strBundleName = parts[1].Trim(); if (!string.IsNullOrEmpty(strBundleName)) { // 这里输出文件名和Bundle名. string strSaveFileName = CommonUtils.GetAssetNameFromPath(eachMetaFile.FullName, strUnityAssetData); MetaFileInfo metaFile = new MetaFileInfo(); metaFile.fileName = strSaveFileName; metaFile.bundleName = strBundleName; lstMetaFileInfo.Add(metaFile); // // Console.WriteLine(eachMetaFile.FullName); // Console.WriteLine(strBundleName); } } } } string strResult = JsonConvert.SerializeObject(lstMetaFileInfo, Formatting.Indented); CommonUtils.WriteFile(@"D:\AnalyzeABInMeta.json", strResult); StopWatchUtils.WatchStopOnceEnd("AnalyzeABInMeta"); Console.WriteLine("1"); }
/// <summary> /// Gets the new output MetaFile object. /// </summary> /// <param name="mfi">Meta file info</param> /// <param name="data">Output MetaFile data</param> public CMSOutputMetaFile NewOutputFile(MetaFileInfo mfi, byte[] data) { CMSOutputMetaFile mf = new CMSOutputMetaFile(mfi, data); mf.Watermark = Watermark; mf.WatermarkPosition = WatermarkPosition; return(mf); }
/// <summary> /// Returns the output data dependency based on the given attachment record. /// </summary> /// <param name="mi">Metafile object</param> protected CMSCacheDependency GetOutputDataDependency(MetaFileInfo mi) { if (mi == null) { return(null); } return(CacheHelper.GetCacheDependency(mi.GetDependencyCacheKeys())); }
/// <summary> /// Uploads file with new product uploader. /// </summary> public void UploadNewProductFile() { // Get SKU SKUInfo skui = SKUInfoProvider.GetSKUInfo(this.SKUID); // Get allowed extensions string allowedExtensions = null; if (skui != null) { string settingKey = (skui.IsGlobal) ? "CMSUploadExtensions" : (CMSContext.CurrentSiteName + ".CMSUploadExtensions"); allowedExtensions = SettingsKeyProvider.GetStringValue(settingKey); } // Get posted file HttpPostedFile file = this.newProductFileUploader.PostedFile; if ((file != null) && (file.ContentLength > 0) && !String.IsNullOrEmpty(allowedExtensions)) { // Get file extension string extension = Path.GetExtension(file.FileName);; // If file extension is not allowed if (!FileHelper.CheckExtension(extension, allowedExtensions)) { // Set error message and don't upload string error = ValidationHelper.GetString(SessionHelper.GetValue("NewProductError"), null); error += ";" + String.Format(this.GetString("com.eproduct.attachmentinvalid"), allowedExtensions.Replace(";", ", ")); SessionHelper.SetValue("NewProductError", error); return; } } // Upload attachment this.newProductFileUploader.ObjectID = this.SKUID; this.newProductFileUploader.UploadFile(); // Get uploaded meta file MetaFileInfo mfi = this.newProductFileUploader.CurrentlyHandledMetaFile; if (mfi != null) { // Create new SKU file SKUFileInfo skufi = new SKUFileInfo(); skufi.FileSKUID = this.SKUID; skufi.FileMetaFileGUID = mfi.MetaFileGUID; skufi.FileName = mfi.MetaFileName; skufi.FilePath = MetaFileInfoProvider.GetMetaFileUrl(mfi.MetaFileGUID, mfi.MetaFileName); skufi.FileType = MediaSourceEnum.MetaFile.ToString(); // Save SKU file SKUFileInfoProvider.SetSKUFileInfo(skufi); } }
/// <summary> /// Initializes form controls (title and description). /// </summary> private void InitializeForm() { switch (ObjectType) { // Attachment case TreeObjectType.ATTACHMENT: AttachmentInfo attachmentInfo = InfoObject as AttachmentInfo; if (attachmentInfo != null) { ObjectTitle = attachmentInfo.AttachmentTitle; ObjectDescription = attachmentInfo.AttachmentDescription; ObjectFileName = Path.GetFileNameWithoutExtension(attachmentInfo.AttachmentName); ObjectExtension = attachmentInfo.AttachmentExtension; ObjectSize = DataHelper.GetSizeString(attachmentInfo.AttachmentSize); } break; // Meta file case PredefinedObjectType.METAFILE: MetaFileInfo metaFileInfo = InfoObject as MetaFileInfo; if (metaFileInfo != null) { ObjectTitle = metaFileInfo.MetaFileTitle; ObjectDescription = metaFileInfo.MetaFileDescription; ObjectFileName = Path.GetFileNameWithoutExtension(metaFileInfo.MetaFileName); ObjectExtension = metaFileInfo.MetaFileExtension; ObjectSize = DataHelper.GetSizeString(metaFileInfo.MetaFileSize); } break; // Media file case PredefinedObjectType.MEDIAFILE: if (OnSetMetaData != null) { OnSetMetaData(this, null); } break; // Nothing default: break; } if (!this.Enabled) { // Disable controls this.txtFileName.Enabled = false; this.txtTitle.Enabled = false; this.txtDescription.Enabled = false; } }
/// <summary> /// Updates metafile image path. /// </summary> private void UpdateImagePath(MediaLibraryInfo mli) { // Update image path according to its meta file DataSet ds = MetaFileInfoProvider.GetMetaFiles(ucMetaFile.ObjectID, mli.TypeInfo.ObjectType); if (!DataHelper.DataSourceIsEmpty(ds)) { MetaFileInfo metaFile = new MetaFileInfo(ds.Tables[0].Rows[0]); mli.LibraryTeaserPath = MetaFileInfoProvider.GetMetaFileUrl(metaFile.MetaFileGUID, metaFile.MetaFileName); } else { mli.LibraryTeaserPath = ""; } }
/// <summary> /// Uploads file. /// </summary> public void UploadFile() { if ((uploader.PostedFile != null) && (uploader.PostedFile.ContentLength > 0) && (ObjectID > 0)) { try { MetaFileInfo existing = null; // Check if uploaded file already exists and delete it DataSet ds = MetaFileInfoProvider.GetMetaFiles(ObjectID, ObjectType, Category, null, null); if (!DataHelper.DataSourceIsEmpty(ds)) { // Get existing record ID and delete it existing = new MetaFileInfo(ds.Tables[0].Rows[0]); MetaFileInfoProvider.DeleteMetaFileInfo(existing); } // Create new meta file MetaFileInfo mfi = new MetaFileInfo(uploader.PostedFile, ObjectID, ObjectType, Category); if (existing != null) { // Preserve GUID mfi.MetaFileGUID = existing.MetaFileGUID; mfi.MetaFileTitle = existing.MetaFileTitle; mfi.MetaFileDescription = existing.MetaFileDescription; } mfi.MetaFileSiteID = SiteID; // Save to the database MetaFileInfoProvider.SetMetaFileInfo(mfi); // Set currently handled meta file this.CurrentlyHandledMetaFile = mfi; SetupControls(); } catch (Exception ex) { lblErrorUploader.Visible = true; lblErrorUploader.Text = ex.Message; ViewState["SavingFailed"] = true; SetupControls(); } // File was uploaded, do not delete in one postback mAlreadyUploadedDontDelete = true; } }
/// <summary> /// BtnUpload click event handler. /// </summary> protected void btnUpload_Click(object sender, EventArgs e) { if (!AllowModify || (uploader.PostedFile == null) || (uploader.PostedFile.FileName.Trim() == "")) { return; } try { // Fire before upload event CancelEventArgs beforeUploadArgs = new CancelEventArgs(); if (OnBeforeUpload != null) { OnBeforeUpload(this, beforeUploadArgs); } // If upload was not cancelled if (!beforeUploadArgs.Cancel) { // Create new meta file MetaFileInfo mfi = new MetaFileInfo(uploader.PostedFile, ObjectID, ObjectType, Category) { MetaFileSiteID = SiteID }; // Save meta file MetaFileInfoProvider.SetMetaFileInfo(mfi); // Set currently handled meta file CurrentlyHandledMetaFile = mfi; // Fire after upload event if (OnAfterUpload != null) { OnAfterUpload(this, EventArgs.Empty); } // Reload grid data gridFiles.ReloadData(); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } }
/// <summary> /// Updates metafile image path. /// </summary> private void UpdateImagePath(MediaLibraryInfo mli) { // Update image path according to its meta file DataSet ds = MetaFileInfoProvider.GetMetaFiles(ucMetaFile.ObjectID, mli.TypeInfo.ObjectType, MetaFileInfoProvider.OBJECT_CATEGORY_THUMBNAIL, null, null); if (!DataHelper.DataSourceIsEmpty(ds)) { MetaFileInfo metaFile = new MetaFileInfo(ds.Tables[0].Rows[0]); mli.LibraryTeaserGuid = metaFile.MetaFileGUID; mli.LibraryTeaserPath = MetaFileInfoProvider.GetMetaFileUrl(metaFile.MetaFileGUID, metaFile.MetaFileName); } else { mli.LibraryTeaserGuid = Guid.Empty; mli.LibraryTeaserPath = String.Empty; } }
/// <summary> /// Copies the file binary to the file system. /// </summary> /// <param name="fileId">MetaFile ID</param> /// <param name="name">Returning the metafile name</param> protected bool CopyToFileSystem(int fileId, ref string name) { // Copy the file from database to the file system MetaFileInfo mi = MetaFileInfoProvider.GetMetaFileInfo(fileId); if (mi != null) { name = mi.MetaFileName; // Ensure the physical file MetaFileInfoProvider.EnsurePhysicalFile(mi, SiteInfoProvider.GetSiteName(mi.MetaFileSiteID)); return(true); } return(false); }
/// <summary> /// Ensures the info objects. /// </summary> private void LoadInfos() { switch (baseImageEditor.ImageType) { default: case ImageHelper.ImageTypeEnum.Attachment: if (ai == null) { baseImageEditor.Tree = new TreeProvider(CMSContext.CurrentUser); // If using workflow then get versioned attachment if (VersionHistoryID != 0) { AttachmentHistoryInfo attachmentVersion = VersionManager.GetAttachmentVersion(VersionHistoryID, attachmentGuid); if (attachmentVersion == null) { ai = null; } else { ai = new AttachmentInfo(attachmentVersion.Generalized.DataClass); ai.AttachmentID = attachmentVersion.AttachmentHistoryID; } } // else get file without binary data else { ai = AttachmentManager.GetAttachmentInfoWithoutBinary(attachmentGuid, CurrentSiteName); } } break; case ImageHelper.ImageTypeEnum.Metafile: if (mf == null) { mf = MetaFileInfoProvider.GetMetaFileInfoWithoutBinary(metafileGuid, CurrentSiteName, true); } break; case ImageHelper.ImageTypeEnum.PhysicalFile: // Skip loading info for physical files break; } }
// Deserialize and check Eqp Entries and add them to the list if they are non-default. private void DeserializeEqpEntry(MetaFileInfo metaFileInfo, byte[]?data) { // Eqp can only be valid for equipment. if (data == null || !metaFileInfo.EquipSlot.IsEquipment()) { return; } var value = Eqp.FromSlotAndBytes(metaFileInfo.EquipSlot, data); var def = new EqpManipulation(ExpandedEqpFile.GetDefault(metaFileInfo.PrimaryId), metaFileInfo.EquipSlot, metaFileInfo.PrimaryId); var manip = new EqpManipulation(value, metaFileInfo.EquipSlot, metaFileInfo.PrimaryId); if (def.Entry != manip.Entry) { MetaManipulations.Add(manip); } }
/// <summary> /// Creates new widget with setting from parent webpart. /// </summary> /// <param name="parentWebpartId">ID of parent webpart</param> /// <param name="categoryId">ID of parent widget category</param> /// <returns>Created widget info</returns> private WidgetInfo NewWidget(int parentWebpartId, int categoryId) { WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(parentWebpartId); // Widget cannot be created from inherited webpart if ((wpi != null) && (wpi.WebPartParentID == 0)) { // Set widget according to parent webpart WidgetInfo wi = new WidgetInfo(); wi.WidgetName = FindUniqueWidgetName(wpi.WebPartName, 100); wi.WidgetDisplayName = wpi.WebPartDisplayName; wi.WidgetDescription = wpi.WebPartDescription; wi.WidgetDocumentation = wpi.WebPartDocumentation; wi.WidgetSkipInsertProperties = wpi.WebPartSkipInsertProperties; wi.WidgetIconClass = wpi.WebPartIconClass; wi.WidgetProperties = FormHelper.GetFormFieldsWithDefaultValue(wpi.WebPartProperties, "visible", "false"); wi.WidgetWebPartID = parentWebpartId; wi.WidgetCategoryID = categoryId; // Save new widget to DB WidgetInfoProvider.SetWidgetInfo(wi); // Get thumbnail image from webpart DataSet ds = MetaFileInfoProvider.GetMetaFiles(wpi.WebPartID, WebPartInfo.OBJECT_TYPE, null, null, null, null, 1); if (!DataHelper.DataSourceIsEmpty(ds)) { MetaFileInfo mfi = new MetaFileInfo(ds.Tables[0].Rows[0]); mfi.Generalized.EnsureBinaryData(); mfi.MetaFileID = 0; mfi.MetaFileGUID = Guid.NewGuid(); mfi.MetaFileObjectID = wi.WidgetID; mfi.MetaFileObjectType = WidgetInfo.OBJECT_TYPE; MetaFileInfoProvider.SetMetaFileInfo(mfi); } // Return ID of newly created widget return(wi); } return(null); }
/// <summary> /// Returns the output data dependency based on the given attachment record. /// </summary> /// <param name="mi">Metafile object</param> protected CMSCacheDependency GetOutputDataDependency(MetaFileInfo mi) { if (mi == null) { return null; } return CacheHelper.GetCacheDependency(mi.GetDependencyCacheKeys()); }
/// <summary> /// Generate documentation page. /// </summary> protected override void OnInit(EventArgs e) { base.OnInit(e); // Get current resolver resolver = CMSContext.CurrentResolver.CreateContextChild(); plImg = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/plus.png"); minImg = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/minus.png"); webPartId = QueryHelper.GetString("webPartId", String.Empty); if (webPartId != String.Empty) { wpi = WebPartInfoProvider.GetWebPartInfo(webPartId); } string aliasPath = QueryHelper.GetString("aliaspath", String.Empty); // Ensure correct view mode if (String.IsNullOrEmpty(aliasPath)) { // Ensure the dashboard mode for the dialog if (QueryHelper.Contains("dashboard")) { PortalContext.SetRequestViewMode(ViewModeEnum.DashboardWidgets); PortalContext.DashboardName = QueryHelper.GetString("dashboard", String.Empty); PortalContext.DashboardSiteName = QueryHelper.GetString("sitename", String.Empty); } // Ensure the design mode for the dialog else { PortalContext.SetRequestViewMode(ViewModeEnum.Design); } } // If widgetId is in query create widget documentation widgetID = QueryHelper.GetString("widgetId", String.Empty); if (widgetID != String.Empty) { // Get widget from instance string zoneId = QueryHelper.GetString("zoneid", String.Empty); Guid instanceGuid = QueryHelper.GetGuid("instanceGuid", Guid.Empty); int templateID = QueryHelper.GetInteger("templateID", 0); bool newItem = QueryHelper.GetBoolean("isNew", false); bool isInline = QueryHelper.GetBoolean("Inline", false); PageInfo pi = null; try { // Load page info from alias path and page template pi = CMSWebPartPropertiesPage.GetPageInfo(aliasPath, templateID); } catch (PageNotFoundException) { // Do not throw exception if page info not found (e.g. bad alias path) } if (pi != null) { PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi); if (templateInstance != null) { // Get the instance of widget WebPartInstance widgetInstance = templateInstance.GetWebPart(instanceGuid, widgetID); // Info for zone type WebPartZoneInstance zone = templateInstance.GetZone(zoneId); if (zone != null) { zoneType = zone.WidgetZoneType; } if (widgetInstance != null) { // Create widget from webpart instance wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType); } } } // If inline widget display columns as in editor zone if (isInline) { zoneType = WidgetZoneTypeEnum.Editor; } // If no zone set (only global admins allowed to continue) if (zoneType == WidgetZoneTypeEnum.None) { if (!CMSContext.CurrentUser.UserSiteManagerAdmin) { RedirectToAccessDenied(GetString("attach.actiondenied")); } } // If wi is still null (new item f.e.) if (wi == null) { // Try to get widget info directly by ID if (!newItem) { wi = WidgetInfoProvider.GetWidgetInfo(widgetID); } else { wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(widgetID, 0)); } } } String itemDescription = String.Empty; String itemType = String.Empty; String itemDisplayName = String.Empty; String itemDocumentation = String.Empty; int itemID = 0; // Check whether webpart was found if (wpi != null) { itemDescription = wpi.WebPartDescription; itemType = PortalObjectType.WEBPART; itemID = wpi.WebPartID; itemDisplayName = wpi.WebPartDisplayName; itemDocumentation = wpi.WebPartDocumentation; } // Or widget was found else if (wi != null) { itemDescription = wi.WidgetDescription; itemType = PortalObjectType.WIDGET; itemID = wi.WidgetID; itemDisplayName = wi.WidgetDisplayName; itemDocumentation = wi.WidgetDocumentation; } if ((wpi != null) || (wi != null)) { // Get WebPart (widget) image DataSet ds = MetaFileInfoProvider.GetMetaFiles(itemID, itemType); // Set image url of exists if (!DataHelper.DataSourceIsEmpty(ds)) { MetaFileInfo mtfi = new MetaFileInfo(ds.Tables[0].Rows[0]); if (mtfi != null) { if (mtfi.MetaFileImageWidth > 385) { imgTeaser.Width = 385; } imgTeaser.ImageUrl = ResolveUrl("~/CMSPages/GetMetaFile.aspx?fileguid=" + mtfi.MetaFileGUID.ToString()); } } else { // Set default image imgTeaser.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/imagenotavailable.png"); } // Additional image information imgTeaser.ToolTip = HTMLHelper.HTMLEncode(itemDisplayName); imgTeaser.AlternateText = HTMLHelper.HTMLEncode(itemDisplayName); // Set description of webpart ltlDescription.Text = HTMLHelper.HTMLEncode(itemDescription); // Get description from parent weboart if webpart is inherited if ((wpi != null) && ((wpi.WebPartDescription == null || wpi.WebPartDescription == "") && (wpi.WebPartParentID > 0))) { WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID); if (pwpi != null) { ltlDescription.Text = HTMLHelper.HTMLEncode(pwpi.WebPartDescription); } } FormInfo fi = null; // Generate properties if (wpi != null) { // Get form info from parent if webpart is inherited if (wpi.WebPartParentID != 0) { WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID); if (pwpi != null) { fi = GetWebPartProperties(pwpi); } } else { fi = GetWebPartProperties(wpi); } } else if (wi != null) { fi = GetWidgetProperties(wi); } // Generate properties if (fi != null) { GenerateProperties(fi); } // Generate documentation text if (itemDocumentation == null || itemDocumentation.Trim() == "") { if ((wpi != null) && (wpi.WebPartParentID != 0)) { WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID); if (pwpi != null && pwpi.WebPartDocumentation.Trim() != "") { ltlContent.Text = HTMLHelper.ResolveUrls(pwpi.WebPartDocumentation, null); } else { ltlContent.Text = "<br /><div style=\"padding-left:5px; font-weight: bold;\">" + GetString("WebPartDocumentation.DocumentationText") + "</div><br />"; } } else { ltlContent.Text = "<br /><div style=\"padding-left:5px; font-weight: bold;\">" + GetString("WebPartDocumentation.DocumentationText") + "</div><br />"; } } else { ltlContent.Text = HTMLHelper.ResolveUrls(itemDocumentation, null); } } }
/// <summary> /// Provides operations necessary to create and store new metafile. /// </summary> /// <param name="args">Upload arguments.</param> /// <param name="context">HttpContext instance.</param> private void HandleMetafileUpload(UploaderHelper args, HttpContext context) { MetaFileInfo mfi = null; try { // Check the allowed extensions args.IsExtensionAllowed(); if (args.IsInsertMode) { // Create new metafile info mfi = new MetaFileInfo(args.FilePath, args.MetaFileArgs.ObjectID, args.MetaFileArgs.ObjectType, args.MetaFileArgs.Category); mfi.MetaFileSiteID = args.MetaFileArgs.SiteID; } else { if (args.MetaFileArgs.MetaFileID > 0) { mfi = MetaFileInfoProvider.GetMetaFileInfo(args.MetaFileArgs.MetaFileID); } else { DataSet ds = MetaFileInfoProvider.GetMetaFilesWithoutBinary(args.MetaFileArgs.ObjectID, args.MetaFileArgs.ObjectType, args.MetaFileArgs.Category, null, null); if (!DataHelper.DataSourceIsEmpty(ds)) { mfi = new MetaFileInfo(ds.Tables[0].Rows[0]); } } if (mfi != null) { FileInfo fileInfo = FileInfo.New(args.FilePath); // Init the MetaFile data mfi.MetaFileName = URLHelper.GetSafeFileName(fileInfo.Name, null); mfi.MetaFileExtension = fileInfo.Extension; FileStream file = fileInfo.OpenRead(); mfi.MetaFileSize = Convert.ToInt32(fileInfo.Length); mfi.MetaFileMimeType = MimeTypeHelper.GetMimetype(mfi.MetaFileExtension); mfi.InputStream = file; // Set image properties if (ImageHelper.IsImage(mfi.MetaFileExtension)) { ImageHelper ih = new ImageHelper(mfi.MetaFileBinary); mfi.MetaFileImageHeight = ih.ImageHeight; mfi.MetaFileImageWidth = ih.ImageWidth; } } } if (mfi != null) { MetaFileInfoProvider.SetMetaFileInfo(mfi); } } catch (Exception ex) { args.Message = ex.Message; } finally { if (String.IsNullOrEmpty(args.Message)) { if (!string.IsNullOrEmpty(args.AfterSaveJavascript)) { args.AfterScript = String.Format(@" if (window.{0} != null) {{ window.{0}() }} else if ((window.parent != null) && (window.parent.{0} != null)) {{ window.parent.{0}() }}", args.AfterSaveJavascript); } else { args.AfterScript = String.Format(@" if (window.InitRefresh_{0}) {{ window.InitRefresh_{0}('{1}', false, false, {2}); }} else {{ if ('{1}' != '') {{ alert('{1}'); }} }}", args.ParentElementID, ScriptHelper.GetString(args.Message.Trim(), false), mfi.MetaFileID); } } else { args.AfterScript += ScriptHelper.GetAlertScript(args.Message, false); } args.AddEventTargetPostbackReference(); context.Response.Write(args.AfterScript); context.Response.Flush(); } }
private void UpdateSKUImagePath(SKUInfo skuObj) { if (ECommerceSettings.UseMetaFileForProductImage && !hasAttachmentImagePath) { // Update product image path according to its meta file DataSet ds = MetaFileInfoProvider.GetMetaFiles(ucMetaFile.ObjectID, skuObj.TypeInfo.ObjectType, MetaFileInfoProvider.OBJECT_CATEGORY_IMAGE, null, null); if (!DataHelper.DataSourceIsEmpty(ds)) { MetaFileInfo metaFile = new MetaFileInfo(ds.Tables[0].Rows[0]); skuObj.SKUImagePath = MetaFileInfoProvider.GetMetaFileUrl(metaFile.MetaFileGUID, metaFile.MetaFileName); } else { skuObj.SKUImagePath = ""; } } else { // Update product image path from the image selector skuObj.SKUImagePath = imgSelect.Value; } }
/// <summary> /// Creates new widget with setting from parent webpart. /// </summary> /// <param name="parentWebpartId">ID of parent webpart</param> /// <param name="categoryId">ID of parent widget category</param> /// <returns>Created widget info</returns> private WidgetInfo NewWidget(int parentWebpartId, int categoryId) { WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(parentWebpartId); // Widget cannot be created from inherited webpart if ((wpi != null) && (wpi.WebPartParentID == 0)) { // Set widget according to parent webpart WidgetInfo wi = new WidgetInfo(); wi.WidgetName = FindUniqueWidgetName(wpi.WebPartName, 100); wi.WidgetDisplayName = wpi.WebPartDisplayName; wi.WidgetDescription = wpi.WebPartDescription; wi.WidgetDocumentation = wpi.WebPartDocumentation; wi.WidgetProperties = FormHelper.GetFormFieldsWithDefaultValue(wpi.WebPartProperties, "visible", "false"); wi.WidgetWebPartID = parentWebpartId; wi.WidgetCategoryID = categoryId; // Save new widget to DB WidgetInfoProvider.SetWidgetInfo(wi); // Get thumbnail image from webpart DataSet ds = MetaFileInfoProvider.GetMetaFiles(wpi.WebPartID, PortalObjectType.WEBPART, null, null, null, null, 1); if (!DataHelper.DataSourceIsEmpty(ds)) { MetaFileInfo mfi = new MetaFileInfo(ds.Tables[0].Rows[0]); mfi.Generalized.EnsureBinaryData(); mfi.MetaFileID = 0; mfi.MetaFileGUID = Guid.NewGuid(); mfi.MetaFileObjectID = wi.WidgetID; mfi.MetaFileObjectType = PortalObjectType.WIDGET; MetaFileInfoProvider.SetMetaFileInfo(mfi); } // Return ID of newly created widget return wi; } return null; }
/// <summary> /// Returns url of item's (webpart,widget) image. /// </summary> /// <param name="itemID">ID of webpart (widget)</param> /// <param name="itemType">Type of item (webpart,widget)</param> private string GetItemImage(int itemID, string itemType) { String wimgurl = String.Empty; DataSet mds = MetaFileInfoProvider.GetMetaFiles(itemID, itemType); // Check whether image exists if (!DataHelper.DataSourceIsEmpty(mds)) { // Ge tmetafile info object MetaFileInfo mtfi = new MetaFileInfo(mds.Tables[0].Rows[0]); if (mtfi != null) { // Image found - used in development mode isImagePresent = true; // Get image url return ResolveUrl("~/CMSPages/GetMetaFile.aspx?fileguid=" + mtfi.MetaFileGUID.ToString()); } } return GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/imagenotavailable.png"); }
protected void uploader_OnDeleteFile(object sender, EventArgs e) { // Careful with upload and delete in on postback - ignore delete request if (mAlreadyUploadedDontDelete) { return; } try { using (DataSet ds = MetaFileInfoProvider.GetMetaFiles(ObjectID, ObjectType, Category, null, null)) { if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { var mfi = new MetaFileInfo(dr); if (mfi.MetaFileName.ToLowerCSafe() == uploader.CurrentFileName.ToLowerCSafe()) { MetaFileInfoProvider.DeleteMetaFileInfo(mfi.MetaFileID); } } } } RaiseOnAfterDelete(); SetupControls(); } catch (Exception ex) { ViewState["DeletingFailed"] = true; ShowError(ex.Message); SetupControls(); } }
/// <summary> /// Creates an eProduct. Called when the "Create eProduct" button is pressed. /// </summary> private bool CreateEProduct() { // Get the department DepartmentInfo department = DepartmentInfoProvider.GetDepartmentInfo("MyNewDepartment", CMSContext.CurrentSiteName); // Create a new product object SKUInfo newProduct = new SKUInfo(); // Set the properties if (department != null) { newProduct.SKUDepartmentID = department.DepartmentID; } newProduct.SKUName = "MyNewEProduct"; newProduct.SKUPrice = 169; newProduct.SKUEnabled = true; newProduct.SKUSiteID = CMSContext.CurrentSiteID; newProduct.SKUProductType = SKUProductTypeEnum.EProduct; newProduct.SKUValidity = ValidityEnum.Until; newProduct.SKUValidUntil = DateTime.Today.AddDays(10d); // Create an eProduct SKUInfoProvider.SetSKUInfo(newProduct); // Path of a file to be uploaded string eProductFile = Server.MapPath("Files/file.png"); // Create and set a metafile to the eProduct MetaFileInfo metafile = new MetaFileInfo(eProductFile, newProduct.SKUID, "ecommerce.sku", "E-product"); MetaFileInfoProvider.SetMetaFileInfo(metafile); // Create and set a SKUFile to the eProduct SKUFileInfo skuFile = new SKUFileInfo(); skuFile.FileSKUID = newProduct.SKUID; skuFile.FilePath = "~/getmetafile/" + metafile.MetaFileGUID.ToString().ToLower() + "/" + metafile.MetaFileName + ".aspx"; skuFile.FileType = "MetaFile"; skuFile.FileName = metafile.MetaFileName; skuFile.FileMetaFileGUID = metafile.MetaFileGUID; SKUFileInfoProvider.SetSKUFileInfo(skuFile); return true; }
/// <summary> /// BtnUpload click event handler. /// </summary> protected void btnUpload_Click(object sender, EventArgs e) { if (!AllowModify || (uploader.PostedFile == null) || (uploader.PostedFile.FileName.Trim() == String.Empty)) { return; } try { // Fire before upload event CancelEventArgs beforeUploadArgs = new CancelEventArgs(); if (OnBeforeUpload != null) { OnBeforeUpload(this, beforeUploadArgs); } // If upload was not cancelled if (!beforeUploadArgs.Cancel) { // Create new meta file MetaFileInfo mfi = new MetaFileInfo(uploader.PostedFile, ObjectID, ObjectType, Category) { MetaFileSiteID = SiteID }; // Save meta file MetaFileInfoProvider.SetMetaFileInfo(mfi); CurrentlyHandledMetaFile = mfi; RaiseOnAfterUpload(); gridFiles.ReloadData(); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } }
/// <summary> /// Imports default metafiles which were changed in the new version. /// </summary> /// <param name="upgradeFolder">Folder where the generated metafiles.xml file is</param> private static void ImportMetaFiles(string upgradeFolder) { try { // To get the file use Phobos - Generate files button, Metafile settings. // Choose only those object types which had metafiles in previous version and these metafiles changed to the new version. String xmlPath = Path.Combine(upgradeFolder, "metafiles.xml"); if (File.Exists(xmlPath)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(xmlPath); XmlNode metaFilesNode = xDoc.SelectSingleNode("MetaFiles"); if (metaFilesNode != null) { String filesDirectory = Path.Combine(upgradeFolder, "Metafiles"); using (new CMSActionContext { LogEvents = false }) { foreach (XmlNode metaFile in metaFilesNode) { // Load metafiles information from XML String objType = metaFile.Attributes["ObjectType"].Value; String groupName = metaFile.Attributes["GroupName"].Value; String codeName = metaFile.Attributes["CodeName"].Value; String fileName = metaFile.Attributes["FileName"].Value; String extension = metaFile.Attributes["Extension"].Value; String fileGUID = metaFile.Attributes["FileGUID"].Value; String title = (metaFile.Attributes["Title"] != null) ? metaFile.Attributes["Title"].Value : null; String description = (metaFile.Attributes["Description"] != null) ? metaFile.Attributes["Description"].Value : null; // Try to find correspondent info object BaseInfo infoObject = BaseAbstractInfoProvider.GetInfoByName(objType, codeName); if (infoObject != null) { int infoObjectId = infoObject.Generalized.ObjectID; // Check if metafile exists InfoDataSet<MetaFileInfo> metaFilesSet = MetaFileInfoProvider.GetMetaFilesWithoutBinary(infoObjectId, objType, groupName, "MetaFileGUID = '" + fileGUID + "'", null); if (DataHelper.DataSourceIsEmpty(metaFilesSet)) { // Create new metafile if does not exists String mfFileName = String.Format("{0}.{1}", fileGUID, extension.TrimStart('.')); MetaFileInfo mfInfo = new MetaFileInfo(Path.Combine(filesDirectory, mfFileName), infoObjectId, objType, groupName); mfInfo.MetaFileGUID = ValidationHelper.GetGuid(fileGUID, Guid.NewGuid()); // Set correct properties mfInfo.MetaFileName = fileName; if (title != null) { mfInfo.MetaFileTitle = title; } if (description != null) { mfInfo.MetaFileDescription = description; } // Save new meta file MetaFileInfoProvider.SetMetaFileInfo(mfInfo); } } } // Remove existing files after successful finish String[] files = Directory.GetFiles(upgradeFolder); foreach (String file in files) { File.Delete(file); } } } } } catch (Exception ex) { EventLogProvider.LogException(EventLogSource, "IMPORTMETAFILES", ex); } }
private void HandleMetaFileUpload() { string message = string.Empty; MetaFileInfo mfi = null; try { // Check the allowed extensions CheckAllowedExtensions(); if (InsertMode) { // Create new meta file mfi = new MetaFileInfo(FileUploadControl.PostedFile, ObjectID, ObjectType, Category); mfi.MetaFileSiteID = SiteID; } else { if (MetaFileID > 0) { mfi = MetaFileInfoProvider.GetMetaFileInfo(MetaFileID); } else { DataSet ds = MetaFileInfoProvider.GetMetaFilesWithoutBinary(ObjectID, ObjectType, Category, null, null); if (!DataHelper.DataSourceIsEmpty(ds)) { mfi = new MetaFileInfo(ds.Tables[0].Rows[0]); } } if (mfi != null) { string fileExt = Path.GetExtension(FileUploadControl.FileName); // Init the MetaFile data mfi.MetaFileName = URLHelper.GetSafeFileName(FileUploadControl.FileName, null); mfi.MetaFileExtension = fileExt; mfi.MetaFileSize = Convert.ToInt32(FileUploadControl.PostedFile.InputStream.Length); mfi.MetaFileMimeType = MimeTypeHelper.GetMimetype(fileExt); mfi.InputStream = StreamWrapper.New(FileUploadControl.PostedFile.InputStream); // Set image properties if (ImageHelper.IsImage(mfi.MetaFileExtension)) { // Make MetaFile binary load from InputStream mfi.MetaFileBinary = null; ImageHelper ih = new ImageHelper(mfi.MetaFileBinary); mfi.MetaFileImageHeight = ih.ImageHeight; mfi.MetaFileImageWidth = ih.ImageWidth; } } } if (mfi != null) { // Save file to the database MetaFileInfoProvider.SetMetaFileInfo(mfi); } } catch (Exception ex) { // Log the exception EventLogProvider.LogException("Uploader", "UploadMetaFile", ex); message = ex.Message; } finally { string afterSaveScript = string.Empty; if (String.IsNullOrEmpty(message)) { if (!string.IsNullOrEmpty(AfterSaveJavascript)) { afterSaveScript = String.Format( @" if (window.{0} != null) {{ window.{0}(files) }} else if ((window.parent != null) && (window.parent.{0} != null)) {{ window.parent.{0}(files) }} ", AfterSaveJavascript ); } else { afterSaveScript = String.Format(@" if ((window.parent != null) && (/parentelemid={0}/i.test(window.location.href)) && (window.parent.InitRefresh_{0})) {{ window.parent.InitRefresh_{0}('{1}', false, false, {2}); }} else {{ if ('{1}' != '') {{ alert('{1}'); }} }}", ParentElemID, ScriptHelper.GetString(message.Trim(), false), mfi.MetaFileID.ToString() + (InsertMode ? ",'insert'" : ",'update'")); } } else { afterSaveScript += ScriptHelper.GetAlertScript(message, false); } ScriptHelper.RegisterStartupScript(this, typeof(string), "afterSaveScript_" + ClientID, afterSaveScript, true); } }
/// <summary> /// Ensures the info objects. /// </summary> private void LoadInfos() { switch (baseImageEditor.ImageType) { case ImageHelper.ImageTypeEnum.Metafile: if (mf == null) { mf = MetaFileInfoProvider.GetMetaFileInfoWithoutBinary(metafileGuid, CurrentSiteName, true); } break; case ImageHelper.ImageTypeEnum.PhysicalFile: // Skip loading info for physical files break; default: if (ai == null) { baseImageEditor.Tree = new TreeProvider(MembershipContext.AuthenticatedUser); // If using workflow then get versioned attachment if (VersionHistoryID != 0) { AttachmentHistoryInfo attachmentVersion = VersionManager.GetAttachmentVersion(VersionHistoryID, attachmentGuid); if (attachmentVersion != null) { // Create new attachment object ai = new AttachmentInfo(attachmentVersion.Generalized.DataClass); if (ai != null) { AttachmentHistoryID = attachmentVersion.AttachmentHistoryID; ai.AttachmentVersionHistoryID = VersionHistoryID; } } } // Else get file without binary data else { ai = AttachmentInfoProvider.GetAttachmentInfoWithoutBinary(attachmentGuid, CurrentSiteName); } } break; } }
/// <summary> /// Initializes common properties used for processing image. /// </summary> private void baseImageEditor_InitializeProperties() { var currentUser = MembershipContext.AuthenticatedUser; // Process attachment switch (baseImageEditor.ImageType) { // Process physical file case ImageHelper.ImageTypeEnum.PhysicalFile: { if (!String.IsNullOrEmpty(filePath)) { if ((currentUser != null) && currentUser.IsGlobalAdministrator) { try { // Load the file from disk string physicalPath = Server.MapPath(filePath); byte[] data = File.ReadAllBytes(physicalPath); baseImageEditor.ImgHelper = new ImageHelper(data); } catch { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.loading")); } } else { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.rights")); } } else { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.loading")); } } break; // Process metafile case ImageHelper.ImageTypeEnum.Metafile: { // Get metafile mf = MetaFileInfoProvider.GetMetaFileInfoWithoutBinary(metafileGuid, CurrentSiteName, true); // If file is not null and current user is global administrator then set image if (mf != null) { if (UserInfoProvider.IsAuthorizedPerObject(mf.MetaFileObjectType, mf.MetaFileObjectID, PermissionsEnum.Modify, CurrentSiteName, MembershipContext.AuthenticatedUser)) { // Ensure metafile binary data mf.MetaFileBinary = MetaFileInfoProvider.GetFile(mf, CurrentSiteName); if (mf.MetaFileBinary != null) { baseImageEditor.ImgHelper = new ImageHelper(mf.MetaFileBinary); } else { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.loading")); } } else { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.rights")); } } else { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.loading")); } } break; default: { baseImageEditor.Tree = new TreeProvider(currentUser); // If using workflow then get versioned attachment if (VersionHistoryID != 0) { // Get the versioned attachment AttachmentHistoryInfo attachmentVersion = VersionManager.GetAttachmentVersion(VersionHistoryID, attachmentGuid); if (attachmentVersion != null) { // Create new attachment object ai = new AttachmentInfo(attachmentVersion.Generalized.DataClass); if (ai != null) { AttachmentHistoryID = attachmentVersion.AttachmentHistoryID; ai.AttachmentVersionHistoryID = VersionHistoryID; } } } // Else get file without binary data else { ai = AttachmentInfoProvider.GetAttachmentInfoWithoutBinary(attachmentGuid, CurrentSiteName); } // If file is not null and current user is set if (ai != null) { TreeNode node; if (ai.AttachmentDocumentID > 0) { node = baseImageEditor.Tree.SelectSingleDocument(ai.AttachmentDocumentID); } else { // Get parent node ID in case attachment is edited for document not created yet int parentNodeId = QueryHelper.GetInteger("parentId", 0); node = baseImageEditor.Tree.SelectSingleNode(parentNodeId); } // If current user has appropriate permissions then set image - check hash fro live site otherwise check node permissions if ((currentUser != null) && (node != null) && ((IsLiveSite && QueryHelper.ValidateHash("hash")) || (!IsLiveSite && (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed)))) { // Ensure attachment binary data if (VersionHistoryID == 0) { ai.AttachmentBinary = AttachmentInfoProvider.GetFile(ai, CurrentSiteName); } if (ai.AttachmentBinary != null) { baseImageEditor.ImgHelper = new ImageHelper(ai.AttachmentBinary); } else { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.loading")); } } else { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.filemodify")); } } else { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.loading")); } } break; } // Check that image is in supported formats if ((!baseImageEditor.LoadingFailed) && (baseImageEditor.ImgHelper.ImageFormatToString() == null)) { baseImageEditor.LoadingFailed = true; baseImageEditor.ShowError(GetString("img.errors.format")); } // Disable editor if loading failed if (baseImageEditor.LoadingFailed) { Enabled = false; } }
protected void uploader_OnDeleteFile(object sender, EventArgs e) { // Careful with upload and delete in on postback - ignore delete request if (mAlreadyUploadedDontDelete) { return; } try { using (DataSet ds = MetaFileInfoProvider.GetMetaFiles(ObjectID, ObjectType, Category, null, null)) { if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { MetaFileInfo mfi = new MetaFileInfo(dr); if ((mfi != null) && (mfi.MetaFileName.ToLower() == uploader.CurrentFileName.ToLower())) { MetaFileInfoProvider.DeleteMetaFileInfo(mfi.MetaFileID); } } } } // Execute after delete event if (OnAfterDelete != null) { OnAfterDelete(this, null); } SetupControls(); } catch (Exception ex) { ViewState["DeletingFailed"] = true; lblErrorUploader.Visible = true; lblErrorUploader.Text = ex.Message; SetupControls(); } }
public static void Upgrade55R2() { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("I", DateTime.Now, "Upgrade to 5.5 R2", "Upgrade - Start"); DataClassInfo dci = null; #region "CMS.UserSettings" try { dci = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if (fi != null) { FormFieldInfo ffi = new FormFieldInfo(); ffi.Name = "UserSkype"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "User Skype account"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserIM"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 100; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "User instant messenger"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserPhone"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 26; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = true; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "User phone"; ffi.DefaultValue = String.Empty; ffi.Description = "User phone number."; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); ffi = new FormFieldInfo(); ffi.Name = "UserPosition"; ffi.DataType = FormFieldDataTypeEnum.Text; ffi.Size = 200; ffi.AllowEmpty = true; ffi.PublicField = false; ffi.System = false; ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Visible = false; ffi.Caption = "Position"; ffi.DefaultValue = String.Empty; ffi.Description = String.Empty; ffi.RegularExpression = String.Empty; fi.AddFormField(ffi); dci.ClassFormDefinition = fi.GetXmlDefinition(); dci.ClassXmlSchema = TableManager.GetXmlSchema("CMS_UserSettings"); DataClassInfoProvider.SetDataClass(dci); // Generate queries SqlGenerator.GenerateDefaultQueries(dci, true, false); } } } catch (Exception ex) { evp.LogEvent("CMS.UserSettings - Upgrade", "Upgrade", ex); } #endregion #region "WebTemplate meta file" try { WebTemplateInfo wti = WebTemplateInfoProvider.GetWebTemplateInfo("IntranetPortal"); if (wti != null) { string imgPath = HttpContext.Current.Server.MapPath("~/App_Data/CMSTemp/intranetportal.gif"); if (File.Exists(imgPath)) { MetaFileInfo mfi = new MetaFileInfo(imgPath, wti.WebTemplateId, "cms.webtemplate", "Thumbnail"); if (mfi != null) { MetaFileInfoProvider.SetMetaFileInfo(mfi); } File.Delete(imgPath); } } } catch (Exception ex) { evp.LogEvent("Upgrade to 5.5 R2", "Upgrade", ex); } #endregion // Clear hashtables CMSObjectHelper.ClearHashtables(); // Set the path to the upgrade package mUpgradePackagePath = HttpContext.Current.Server.MapPath("~/CMSSiteUtils/Import/upgrade_55_55R2.zip"); mWebsitePath = HttpContext.Current.Server.MapPath("~/"); // Set data version ObjectHelper.SetSettingsKeyValue("CMSDataVersion", "5.5R2"); CMSThread thread = new CMSThread(Upgrade55R2Import); thread.Start(); }
/// <summary> /// Gets the new output MetaFile object. /// </summary> /// <param name="mfi">Meta file info</param> /// <param name="data">Output MetaFile data</param> public CMSOutputMetaFile NewOutputFile(MetaFileInfo mfi, byte[] data) { CMSOutputMetaFile mf = new CMSOutputMetaFile(mfi, data); mf.Watermark = Watermark; mf.WatermarkPosition = WatermarkPosition; return mf; }
/// <summary> /// Uploads file. /// </summary> public void UploadFile() { if ((uploader.PostedFile != null) && (ObjectID > 0)) { try { MetaFileInfo existing = null; // Check if uploaded file already exists and delete it DataSet ds = MetaFileInfoProvider.GetMetaFiles(ObjectID, ObjectType, Category, null, null); if (!DataHelper.DataSourceIsEmpty(ds)) { // Get existing record ID and delete it existing = new MetaFileInfo(ds.Tables[0].Rows[0]); MetaFileInfoProvider.DeleteMetaFileInfo(existing); } // Create new meta file MetaFileInfo mfi = new MetaFileInfo(uploader.PostedFile, ObjectID, ObjectType, Category); if (existing != null) { // Preserve GUID mfi.MetaFileGUID = existing.MetaFileGUID; mfi.MetaFileTitle = existing.MetaFileTitle; mfi.MetaFileDescription = existing.MetaFileDescription; } mfi.MetaFileSiteID = SiteID; // Save to the database MetaFileInfoProvider.SetMetaFileInfo(mfi); CurrentlyHandledMetaFile = mfi; RaiseOnAfterUpload(); SetupControls(); } catch (Exception ex) { ShowError(ex.Message); ViewState["SavingFailed"] = true; SetupControls(); } // File was uploaded, do not delete in one postback mAlreadyUploadedDontDelete = true; } }
/// <summary> /// Saves SKU data and returns created SKU object. /// </summary> public SKUInfo SaveData() { // Check permissions if (SiteID > 0) { if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyProducts")) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyProducts"); } } else { if (!ECommerceContext.IsUserAuthorizedForPermission("EcommerceGlobalModify")) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify"); } } if ((plcSKUControls.Visible) && (this.Node != null)) { // Create empty SKU object SKUInfo skuObj = new SKUInfo(); // Set SKU site id skuObj.SKUSiteID = SiteID; // Set SKU Name if (plcSKUName.Visible) { skuObj.SKUName = txtSKUName.Text.Trim(); } else { string skuNameField = GetDocumentMappedField("SKUName"); skuObj.SKUName = ValidationHelper.GetString(this.Node.GetValue(skuNameField), ""); } // Set SKU price if (plcSKUPrice.Visible) { skuObj.SKUPrice = txtSKUPrice.Value; } else { string skuPriceField = GetDocumentMappedField("SKUPrice"); skuObj.SKUPrice = ValidationHelper.GetDouble(this.Node.GetValue(skuPriceField), 0); } // Set SKU image path according to the document binding if (!plcMetaFile.Visible && !plcImagePath.Visible) { string skuImageField = GetDocumentMappedField("SKUImagePath"); skuObj.SKUImagePath = ValidationHelper.GetString(this.Node.GetValue(skuImageField), ""); } // Set SKU description if (plcSKUDescription.Visible) { skuObj.SKUDescription = htmlSKUDescription.Value; } else { string skuDescriptionField = GetDocumentMappedField("SKUDescription"); skuObj.SKUDescription = ValidationHelper.GetString(this.Node.GetValue(skuDescriptionField), ""); } // Set SKU department skuObj.SKUDepartmentID = departmentElem.DepartmentID; skuObj.SKUEnabled = true; // Create new SKU SKUInfoProvider.SetSKUInfo(skuObj); if ((plcImagePath.Visible || plcMetaFile.Visible) && (skuObj.SKUID > 0)) { if (ECommerceSettings.UseMetaFileForProductImage) { // Save meta file ucMetaFile.ObjectID = skuObj.SKUID; ucMetaFile.ObjectType = ECommerceObjectType.SKU; ucMetaFile.Category = MetaFileInfoProvider.OBJECT_CATEGORY_IMAGE; ucMetaFile.UploadFile(); // Update product image path according to its meta file DataSet ds = MetaFileInfoProvider.GetMetaFiles(ucMetaFile.ObjectID, skuObj.TypeInfo.ObjectType); if (!DataHelper.DataSourceIsEmpty(ds)) { // Set product image path MetaFileInfo metaFile = new MetaFileInfo(ds.Tables[0].Rows[0]); skuObj.SKUImagePath = MetaFileInfoProvider.GetMetaFileUrl(metaFile.MetaFileGUID, metaFile.MetaFileName); } } else { skuObj.SKUImagePath = this.imgSelect.Value; } // Update product SKUInfoProvider.SetSKUInfo(skuObj); } return skuObj; } return null; }
protected override void OnLoad(EventArgs e) { plImg = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/plus.png"); minImg = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/minus.png"); if (WebpartID != String.Empty) { wpi = WebPartInfoProvider.GetWebPartInfo(WebpartID); } // Ensure correct view mode if (String.IsNullOrEmpty(AliasPath)) { // Ensure the dashboard mode for the dialog if (!string.IsNullOrEmpty(DashboardName)) { PortalContext.SetRequestViewMode(ViewModeEnum.DashboardWidgets); PortalContext.DashboardName = DashboardName; PortalContext.DashboardSiteName = DashboardSiteName; } // Ensure the design mode for the dialog else { PortalContext.SetRequestViewMode(ViewModeEnum.Design); } } if (WidgetID != String.Empty) { PageInfo pi = null; try { // Load page info from alias path and page template pi = CMSWebPartPropertiesPage.GetPageInfo(AliasPath, PageTemplateID, CultureCode); } catch (PageNotFoundException) { // Do not throw exception if page info not found (e.g. bad alias path) } if (pi != null) { PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi); if (templateInstance != null) { // Get the instance of widget WebPartInstance widgetInstance = templateInstance.GetWebPart(InstanceGUID, WidgetID); // Info for zone type WebPartZoneInstance zone = templateInstance.GetZone(ZoneID); if (zone != null) { zoneType = zone.WidgetZoneType; } if (widgetInstance != null) { // Create widget from webpart instance wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType); } } } // If inline widget display columns as in editor zone if (IsInline) { zoneType = WidgetZoneTypeEnum.Editor; } // If no zone set (only global admins allowed to continue) if (zoneType == WidgetZoneTypeEnum.None) { if (!CMSContext.CurrentUser.UserSiteManagerAdmin) { RedirectToAccessDenied(GetString("attach.actiondenied")); } } // If wi is still null (new item f.e.) if (wi == null) { // Try to get widget info directly by ID if (!IsNew) { wi = WidgetInfoProvider.GetWidgetInfo(WidgetID); } else { wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(WidgetID, 0)); } } } String itemDescription = String.Empty; String itemType = String.Empty; String itemDisplayName = String.Empty; String itemDocumentation = String.Empty; int itemID = 0; // Check whether webpart was found if (wpi != null) { itemDescription = wpi.WebPartDescription; itemType = PortalObjectType.WEBPART; itemID = wpi.WebPartID; itemDisplayName = wpi.WebPartDisplayName; itemDocumentation = wpi.WebPartDocumentation; } // Or widget was found else if (wi != null) { itemDescription = wi.WidgetDescription; itemType = PortalObjectType.WIDGET; itemID = wi.WidgetID; itemDisplayName = wi.WidgetDisplayName; itemDocumentation = wi.WidgetDocumentation; } if ((wpi != null) || (wi != null)) { // Get WebPart (widget) image DataSet ds = MetaFileInfoProvider.GetMetaFiles(itemID, itemType); // Set image url of exists if (!DataHelper.DataSourceIsEmpty(ds)) { MetaFileInfo mtfi = new MetaFileInfo(ds.Tables[0].Rows[0]); if (mtfi != null) { if (mtfi.MetaFileImageWidth > 385) { imgTeaser.Width = 385; } imgTeaser.ImageUrl = ResolveUrl("~/CMSPages/GetMetaFile.aspx?fileguid=" + mtfi.MetaFileGUID.ToString()); } } else { // Set default image imgTeaser.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/WebpartProperties/imagenotavailable.png"); } // Additional image information imgTeaser.ToolTip = HTMLHelper.HTMLEncode(itemDisplayName); imgTeaser.AlternateText = HTMLHelper.HTMLEncode(itemDisplayName); // Set description of webpart ltlDescription.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(itemDescription)); // Get description from parent weboart if webpart is inherited if ((wpi != null) && (string.IsNullOrEmpty(wpi.WebPartDescription) && (wpi.WebPartParentID > 0))) { WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID); if (pwpi != null) { ltlDescription.Text = HTMLHelper.HTMLEncode(pwpi.WebPartDescription); } } FormInfo fi = null; // Generate properties if (wpi != null) { // Get form info from parent if webpart is inherited if (wpi.WebPartParentID != 0) { WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID); if (pwpi != null) { fi = GetWebPartProperties(pwpi); } } else { fi = GetWebPartProperties(wpi); } } else if (wi != null) { fi = GetWidgetProperties(wi); } // Generate properties if (fi != null) { GenerateProperties(fi); } // Generate documentation text if (itemDocumentation == null || itemDocumentation.Trim() == "") { if ((wpi != null) && (wpi.WebPartParentID != 0)) { WebPartInfo pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID); if (pwpi != null && pwpi.WebPartDocumentation.Trim() != "") { ltlContent.Text = HTMLHelper.ResolveUrls(pwpi.WebPartDocumentation, null); } else { ltlContent.Text = "<br /><div style=\"padding-left:5px; font-weight: bold;\">" + GetString("WebPartDocumentation.DocumentationText") + "</div><br />"; } } else { ltlContent.Text = "<br /><div style=\"padding-left:5px; font-weight: bold;\">" + GetString("WebPartDocumentation.DocumentationText") + "</div><br />"; } } else { ltlContent.Text = HTMLHelper.ResolveUrls(itemDocumentation, null); } } ScriptHelper.RegisterJQuery(Page); string script = @" $j(document.body).ready(initializeResize); function initializeResize () { resizeareainternal(); $j(window).resize(function() { resizeareainternal(); }); } function resizeareainternal () { var height = document.body.clientHeight ; var panel = document.getElementById ('" + divScrolable.ClientID + @"'); // Get parent footer to count proper height (with padding included) var footer = $j('.PageFooterLine'); panel.style.height = (height - footer.outerHeight() - panel.offsetTop) +'px'; }"; ScriptHelper.RegisterClientScriptBlock(Page, typeof(Page), "mainScript", ScriptHelper.GetScript(script)); string[,] tabs = new string[4, 4]; tabs[0, 0] = GetString("webparts.documentation"); tabs[1, 0] = GetString("general.properties"); tabControlElem.Tabs = tabs; tabControlElem.UsePostback = true; // Disable caching Response.Cache.SetNoStore(); base.OnLoad(e); }