protected void Page_Load(object sender, EventArgs e) { int ID = int.Parse(Request["hid"].ToString().Replace('H', ' ')); Historial _Historial = Historial.GetHistorialById(ID); string filename = Guid.NewGuid().ToString() + ".pdf"; if (_Historial == null) { Response.Write("Error en consulta historial inexistente..."); } else { Paciente _Paciente = Paciente.Select_Paciente_By_Id(_Historial.IDPACIENTE); ReportParameter RPOS; if (_Paciente.IDOBRASOCIAL == 0) { RPOS = new ReportParameter("pobrasocial", "No"); } else { ObraSocial OS = ObraSocial.GetObraSocial(_Paciente.IDOBRASOCIAL); RPOS = new ReportParameter("pobrasocial", OS.NOMBRE); } if (_Paciente != null) { string date = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year; RV.LocalReport.ReportPath = MapPath("/DesktopModules/HistoriaClinica/Reports/InformeDeGuardia.rdlc"); RV.LocalReport.SetParameters(new ReportParameter[] { new ReportParameter("pfecha", date), new ReportParameter("ppaciente", _Paciente.APELLIDO + ", " + _Paciente.NOMBRE), new ReportParameter("pdni", _Paciente.NRODOCUMENTO), RPOS, new ReportParameter("pdiagnostico", Request["Diag"].ToString()), new ReportParameter("pobservacionenguardia", Request["obs"].ToString()), new ReportParameter("pprovisiondemedicamento", Request["med"].ToString()), new ReportParameter("pampliaciondediagnostico", _Historial.RAWDIAGNOSTICO) }); RV.LocalReport.Refresh(); byte[] b = RV.LocalReport.Render("PDF"); DotNetNuke.Entities.Portals.PortalController PC = new DotNetNuke.Entities.Portals.PortalController(); string path = Server.MapPath("/" + PC.GetPortal(0).HomeDirectory); Response.Write(path); File.WriteAllBytes(path + "\\" + filename, b); Response.Redirect("/Portals/0/" + filename); } } }
public static System.Collections.Generic.List <MLCategoryInfo> GetAllCategoriesAsListe(string Locale, bool FromCache) { DotNetNuke.Entities.Portals.PortalController pCont = new DotNetNuke.Entities.Portals.PortalController(); ArrayList portals = pCont.GetPortals(); System.Collections.Generic.List <MLCategoryInfo> liste = new System.Collections.Generic.List <MLCategoryInfo>(); foreach (DotNetNuke.Entities.Portals.PortalInfo portal in portals) { liste.AddRange(GetCategoriesAsListe(portal.PortalID, Locale, FromCache)); } return(liste); }
public void ProcessUploadFile(object sender, UploadEventArgs <HttpContext> e) { lock (_locker) { var db = new AlbumImageController(); var flAlbum = new FileAlbumController(); int albumid = int.Parse(e.HttpContextUpload.Request.QueryString["albumid"].ToString()); //tim va thiet lap thong tin con thieu cho lop V_Base int portalid = int.Parse(e.HttpContextUpload.Request.QueryString["portalid"].ToString()); var portalInfo = new DotNetNuke.Entities.Portals.PortalController().GetPortal(portalid); string pathImgThumb = "/" + portalInfo.HomeDirectory + "/" + GB.Album.CommonBase.Constants.FolderImageThum + "/"; e.HttpContextUpload.Response.ContentType = "text/plain";//"application/json"; var r = new System.Collections.Generic.List <ViewDataUploadFilesResult>(); foreach (string file in e.HttpContextUpload.Request.Files) { HttpPostedFile hpf = e.HttpContextUpload.Request.Files[file] as HttpPostedFile; string FileName = string.Empty; if (HttpContext.Request.Browser.Browser.ToUpper() == "IE") { string[] files = hpf.FileName.Split(new char[] { '\\' }); FileName = files[files.Length - 1]; } else { FileName = hpf.FileName; } if (hpf.ContentLength == 0) { continue; } //save file to album flAlbum.StoreImagesInAlbum(hpf.InputStream, FileName, portalid, 44); //add Image to DB db.AddNewImage(albumid, FileName); r.Add(new ViewDataUploadFilesResult() { Thumbnail_url = pathImgThumb + FileName, Name = FileName, Length = hpf.ContentLength, Type = hpf.ContentType }); } e.Results = r; } }
protected void btnAddAttachment_Click(object sender, EventArgs e) { string url = UserInfo.IsInRole(PortalSettings.AdministratorRoleName) ? ctlAttachment.Url : ctlUserAttachment.Url; if (url == "")//当前没有选择任何文件,直接返回 { return; } FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); AttachmentInfo ai = new AttachmentInfo(); if (url.StartsWith("FileID=")) { fi = GetFileInfoById(url); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { ai.FilePath = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; } } List <AttachmentInfo> list = AttachmentList; if (list == null) { list = new List <AttachmentInfo>(); } ai.Id = list.Count;//累加Id list.Add(ai); AttachmentList = list; gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); }
private string BuildRSS(int PortalId, int TabId, int ModuleId, int intPosts, int ForumID, bool IngnoreSecurity, bool IncludeBody) { DotNetNuke.Entities.Portals.PortalController pc = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalSettings ps = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings(); DotNetNuke.Entities.Users.UserInfo ou = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); UserController uc = new UserController(); User u = uc.GetUser(PortalId, ModuleId); DataSet ds = DataProvider.Instance().UI_TopicsView(PortalId, ModuleId, ForumID, ou.UserID, 0, 20, ou.IsSuperUser, SortColumns.ReplyCreated); if (ds.Tables.Count > 0) { offSet = ps.TimeZoneOffset; if (ds.Tables[0].Rows.Count == 0) { return string.Empty; } drForum = ds.Tables[0].Rows[0]; drSecurity = ds.Tables[1].Rows[0]; dtTopics = ds.Tables[3]; if (dtTopics.Rows.Count == 0) { return string.Empty; } bView = Permissions.HasPerm(drSecurity["CanView"].ToString(), u.UserRoles); bRead = Permissions.HasPerm(drSecurity["CanRead"].ToString(), u.UserRoles); StringBuilder sb = new StringBuilder(1024); if (bRead) { ForumName = drForum["ForumName"].ToString(); GroupName = drForum["GroupName"].ToString(); ForumDescription = drForum["ForumDesc"].ToString(); //TopicsTemplateId = CInt(drForum("TopicsTemplateId")) bAllowRSS = Convert.ToBoolean(drForum["AllowRSS"]); if (bAllowRSS) { sb.Append("<?xml version=\"1.0\" ?>" + System.Environment.NewLine); sb.Append("<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:cf=\"http://www.microsoft.com/schemas/rss/core/2005\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">" + System.Environment.NewLine); string[] Params = { ParamKeys.ForumId + "=" + ForumID, ParamKeys.ViewType + "=" + Views.Topics }; string URL = string.Empty; if (Request.QueryString["asg"] == null) { URL = DotNetNuke.Common.Globals.NavigateURL(TabId, "", Params); } else if (SimulateIsNumeric.IsNumeric(Request.QueryString["asg"])) { Params = new string[] { "asg=" + Request.QueryString["asg"], ParamKeys.ForumId + "=" + ForumID, ParamKeys.ViewType + "=" + Views.Topics }; URL = DotNetNuke.Common.Globals.NavigateURL(TabId, "", Params); } if (URL.IndexOf(Request.Url.Host) == -1) { URL = DotNetNuke.Common.Globals.AddHTTP(Request.Url.Host) + URL; } // build channel sb.Append(WriteElement("channel", 1)); sb.Append(WriteElement("title", HttpUtility.HtmlEncode(ps.PortalName) + " " + ForumName, 2)); sb.Append(WriteElement("link", URL, 2)); sb.Append(WriteElement("description", ForumDescription, 2)); sb.Append(WriteElement("language", PortalSettings.DefaultLanguage, 2)); sb.Append(WriteElement("generator", "ActiveForums 5.0", 2)); sb.Append(WriteElement("copyright", PortalSettings.FooterText, 2)); sb.Append(WriteElement("lastBuildDate", "[LASTBUILDDATE]", 2)); if (!(ps.LogoFile == string.Empty)) { string sLogo = "<image><url>http://" + Request.Url.Host + ps.HomeDirectory + ps.LogoFile + "</url>"; sLogo += "<title>" + ps.PortalName + " " + ForumName + "</title>"; sLogo += "<link>" + URL + "</link></image>"; sb.Append(sLogo); } foreach (DataRow dr in dtTopics.Rows) { if (DotNetNuke.Security.PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AuthorizedRoles)) { //objModule = objModules.GetModule(ModuleId, TabId) //If DotNetNuke.Security.PortalSecurity.IsInRoles(objModule.AuthorizedViewRoles) = True Then // sb.Append(BuildItem(dr, TabId, 2, IncludeBody, PortalId)) //End If sb.Append(BuildItem(dr, TabId, 2, IncludeBody, PortalId)); } } sb.Append("<atom:link href=\"http://" + Request.Url.Host + HttpUtility.HtmlEncode(Request.RawUrl) + "\" rel=\"self\" type=\"application/rss+xml\" />"); sb.Append(WriteElement("/channel", 1)); sb.Replace("[LASTBUILDDATE]", LastBuildDate.ToString("r")); sb.Append("</rss>"); //Cache.Insert("RSS" & ModuleId & ForumID, sb.ToString, Nothing, DateTime.Now.AddMinutes(dblCacheTimeOut), TimeSpan.Zero) return sb.ToString(); } } } return string.Empty; }
private void ConfigTurnero() { carouselTurnosMedicos.ClientIDMode = System.Web.UI.ClientIDMode.Static; carouselTurnosEnfermeros.ClientIDMode = System.Web.UI.ClientIDMode.Static; if (Session["KeyPaciente"] != null) { DotNetNuke.Entities.Portals.PortalController PC = new DotNetNuke.Entities.Portals.PortalController(); System.Collections.ArrayList AL = DotNetNuke.Entities.Users.UserController.GetUsers(PortalId); for (int a = 0; a < AL.Count; a++) { DotNetNuke.Entities.Users.UserInfo UI = (DotNetNuke.Entities.Users.UserInfo)AL[a]; System.Web.UI.HtmlControls.HtmlGenericControl HTML = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); HTML.Attributes.Add("Class", "TurnoContainer"); if (UI.IsInRole("Medico") == true || UI.IsInRole("Enfermero")) { List <ProfileUser> PU = ConnectionDispensario.Modelos.ProfileUser.getProfileUser(PortalId, UI.UserID); HtmlGenericControl DivFoto = new HtmlGenericControl("div"); HtmlGenericControl DivDatos = new HtmlGenericControl("div"); HtmlGenericControl ButtonTurno = new HtmlGenericControl("Input"); HtmlGenericControl ButtonTurnero = new HtmlGenericControl("Input"); HtmlGenericControl DivTurnero = new HtmlGenericControl("div"); DivTurnero.ID = "ContainerTurno" + UI.UserID.ToString(); DivTurnero.ClientIDMode = System.Web.UI.ClientIDMode.Static; ButtonTurno.Attributes.Add("class", "BotonAsignaTurno"); ButtonTurno.Attributes.Add("Type", "Button"); ButtonTurno.Attributes.Add("Value", "Sacar Turno"); ButtonTurno.Attributes.Add("UserID", UI.UserID.ToString()); ButtonTurno.Attributes.Add("OnClick", "AsignarTurno(this)"); ButtonTurnero.Attributes.Add("class", "BotonAsignaTurno"); ButtonTurnero.Attributes.Add("Type", "Button"); ButtonTurnero.Attributes.Add("Value", "Turnero"); ButtonTurnero.Attributes.Add("UserID", UI.UserID.ToString()); ButtonTurnero.Attributes.Add("OnClick", "AbrirTurneroMedico(this)"); string ProfileData = ""; string ROL = ""; if (PU != null && PU.Count > 0) { for (int b = 0; b < PU.Count; b++) { if (PU[b].KEY != "Medico" && PU[b].KEY != "Enfermero") { ProfileData += "<b>" + PU[b].KEY + ":</b>" + PU[b].VALUE + "</br>"; } if (PU[b].KEY == "Medico") { HTML.Attributes["class"] = "TurnoContainerMedico"; } if (PU[b].KEY == "Enfermero") { HTML.Attributes["class"] = "TurnoContainerEnfermero"; } } DivDatos.InnerHtml = ProfileData; } String imagestyle = "background-image:url([token])"; imagestyle = imagestyle.Replace("[token]", "" + UI.Profile.PhotoURL + ""); DivFoto.Attributes.Add("Style", imagestyle); DivFoto.Attributes.Add("Class", "fotoTurnero"); HTML.Controls.Add(DivFoto); HTML.Controls.Add(DivDatos); HTML.Controls.Add(ButtonTurno); HTML.Controls.Add(ButtonTurnero); HTML.Controls.Add(DivTurnero); if (UI.IsInRole("Medico")) { carouselTurnosMedicos.Controls.Add(HTML); } if (UI.IsInRole("Enfermero")) { carouselTurnosEnfermeros.Controls.Add(HTML); } } } } }
protected void btnAddAttachment_Click(object sender, EventArgs e) { string url = UserInfo.IsInRole(PortalSettings.AdministratorRoleName) ? ctlAttachment.Url : ctlUserAttachment.Url; if (url == "")//当前没有选择任何文件,直接返回 { return; } FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); AttachmentInfo ai = new AttachmentInfo(); if (url.StartsWith("FileID=")) { fi = GetFileInfoById(url); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { ai.FilePath = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; } } List<AttachmentInfo> list = AttachmentList; if (list == null) { list = new List<AttachmentInfo>(); } ai.Id = list.Count;//累加Id list.Add(ai); AttachmentList = list; gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); }
private string BuildRSS(int PortalId, int TabId, int ModuleId, int intPosts, int ForumID, bool IngnoreSecurity, bool IncludeBody) { DotNetNuke.Entities.Portals.PortalController pc = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalSettings ps = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings(); DotNetNuke.Entities.Users.UserInfo ou = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); UserController uc = new UserController(); User u = uc.GetUser(PortalId, ModuleId); DataSet ds = DataProvider.Instance().UI_TopicsView(PortalId, ModuleId, ForumID, ou.UserID, 0, 20, ou.IsSuperUser, SortColumns.ReplyCreated); if (ds.Tables.Count > 0) { offSet = Convert.ToInt32(ps.TimeZone.BaseUtcOffset.TotalMinutes); if (ds.Tables[0].Rows.Count == 0) { return(string.Empty); } drForum = ds.Tables[0].Rows[0]; drSecurity = ds.Tables[1].Rows[0]; dtTopics = ds.Tables[3]; if (dtTopics.Rows.Count == 0) { return(string.Empty); } bView = Permissions.HasPerm(drSecurity["CanView"].ToString(), u.UserRoles); bRead = Permissions.HasPerm(drSecurity["CanRead"].ToString(), u.UserRoles); StringBuilder sb = new StringBuilder(1024); if (bRead) { ForumName = drForum["ForumName"].ToString(); GroupName = drForum["GroupName"].ToString(); ForumDescription = drForum["ForumDesc"].ToString(); //TopicsTemplateId = CInt(drForum("TopicsTemplateId")) bAllowRSS = Convert.ToBoolean(drForum["AllowRSS"]); if (bAllowRSS) { sb.Append("<?xml version=\"1.0\" ?>" + System.Environment.NewLine); sb.Append("<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:cf=\"http://www.microsoft.com/schemas/rss/core/2005\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">" + System.Environment.NewLine); string[] Params = { ParamKeys.ForumId + "=" + ForumID, ParamKeys.ViewType + "=" + Views.Topics }; string URL = string.Empty; if (Request.QueryString["asg"] == null) { URL = DotNetNuke.Common.Globals.NavigateURL(TabId, "", Params); } else if (SimulateIsNumeric.IsNumeric(Request.QueryString["asg"])) { Params = new string[] { "asg=" + Request.QueryString["asg"], ParamKeys.ForumId + "=" + ForumID, ParamKeys.ViewType + "=" + Views.Topics }; URL = DotNetNuke.Common.Globals.NavigateURL(TabId, "", Params); } if (URL.IndexOf(Request.Url.Host) == -1) { URL = DotNetNuke.Common.Globals.AddHTTP(Request.Url.Host) + URL; } // build channel sb.Append(WriteElement("channel", 1)); sb.Append(WriteElement("title", HttpUtility.HtmlEncode(ps.PortalName) + " " + ForumName, 2)); sb.Append(WriteElement("link", URL, 2)); sb.Append(WriteElement("description", ForumDescription, 2)); sb.Append(WriteElement("language", PortalSettings.DefaultLanguage, 2)); sb.Append(WriteElement("generator", "ActiveForums 5.0", 2)); sb.Append(WriteElement("copyright", PortalSettings.FooterText, 2)); sb.Append(WriteElement("lastBuildDate", "[LASTBUILDDATE]", 2)); if (!(ps.LogoFile == string.Empty)) { string sLogo = "<image><url>http://" + Request.Url.Host + ps.HomeDirectory + ps.LogoFile + "</url>"; sLogo += "<title>" + ps.PortalName + " " + ForumName + "</title>"; sLogo += "<link>" + URL + "</link></image>"; sb.Append(sLogo); } foreach (DataRow dr in dtTopics.Rows) { if (DotNetNuke.Security.PortalSecurity.IsInRoles(PortalSettings.ActiveTab.TabPermissions.ToString("VIEW"))) { //objModule = objModules.GetModule(ModuleId, TabId) //If DotNetNuke.Security.PortalSecurity.IsInRoles(objModule.AuthorizedViewRoles) = True Then // sb.Append(BuildItem(dr, TabId, 2, IncludeBody, PortalId)) //End If sb.Append(BuildItem(dr, TabId, 2, IncludeBody, PortalId)); } } sb.Append("<atom:link href=\"http://" + Request.Url.Host + HttpUtility.HtmlEncode(Request.RawUrl) + "\" rel=\"self\" type=\"application/rss+xml\" />"); sb.Append(WriteElement("/channel", 1)); sb.Replace("[LASTBUILDDATE]", LastBuildDate.ToString("r")); sb.Append("</rss>"); //Cache.Insert("RSS" & ModuleId & ForumID, sb.ToString, Nothing, DateTime.Now.AddMinutes(dblCacheTimeOut), TimeSpan.Zero) return(sb.ToString()); } } } return(string.Empty); }
public int UserPermissionValue(int userID, int userPortalID, int adminRoleID, bool boolUseCache) { //check if hydrated if (_permissionValue != -1 && boolUseCache == true) { return _permissionValue; } _permissionValue = 0; RoleController roleCtrl = new RoleController(); UserController userCtrl = new UserController(); UserInfo user = userCtrl.GetUser(userPortalID, userID); DotNetNuke.Entities.Portals.PortalController portalCtrl = new DotNetNuke.Entities.Portals.PortalController(); if (user != null) { if (user.IsSuperUser || user.IsInRole(roleCtrl.GetRole(adminRoleID, userPortalID).RoleName)) { _permissionValue = 63; return _permissionValue; } } PermissionController permCtrl = new PermissionController(); List<Permission> listPermissions = permCtrl.GetItems(ID) as List<Permission>; foreach (Permission perm in listPermissions) { int permValue = 0; //check group permission if (perm.RoleID > 0) { RoleInfo role = roleCtrl.GetRole(perm.RoleID, PortalID); //TODO check for all users, unauthenticated if (role == null) { //check for all users if (perm.RoleName == "All Users") { permValue = GetPermissionValue(perm); if (permValue > _permissionValue) { _permissionValue = permValue; } } //check for unauthenticated and null user if (perm.RoleName == "Unauthenticated Users" && user == null) { permValue = GetPermissionValue(perm); if (permValue > _permissionValue) { _permissionValue = permValue; } } continue; } if (user != null) { if (user.IsInRole(role.RoleName)) { permValue = GetPermissionValue(perm); if (permValue > _permissionValue) { _permissionValue = permValue; } } } //continue looking for permissions, highest perm wins continue; } //check user permission, user perm overrides role perm if (perm.UserID > 0) { if (perm.UserID == userID) { permValue = GetPermissionValue(perm); _permissionValue = permValue; break; } } } //hydrate permission value return _permissionValue; }
private void UpdateVideo() { VideoInfo objVideo = new VideoInfo(); if (VideoId!=-1) { objVideo = VideoController.Get(VideoId); } objVideo.Id = VideoId; objVideo.PortalId = PortalId; objVideo.TypeId = TypeId; //Normal objVideo.Title = txtTitle.Text; objVideo.VideoFile = ctlVideoFile.Url; objVideo.VideoPath = ctlVideoFile.FullUrl; objVideo.UrlMode = ctlVideoFile.UrlMode; objVideo.Duration = txtVideoDuration.Text.Trim(); if (ctlVideoFile.Url.StartsWith("FileID="))// 当前选择为文件,因此试图获取其duration { int fileId = Convert.ToInt32(ctlVideoFile.Url.Replace("FileID=", "")); if (txtVideoDuration.Text.Trim() == "") { objVideo.Duration = GetVideoDuration(fileId); } } //if (CurrentType.MediaType==Convert.ToInt32(MediaType.Video)) //{ objVideo.HttpType = ddlHttpType.SelectedValue; //} //else //{ // objVideo.HttpType = "Audio"; //} objVideo.Author = txtAuthor.Text; objVideo.Source = txtSource.Text; objVideo.Quote = chkQuote.Checked; // objVideo.Private = chkPrivate.Checked; // objVideo.Protected=chkProtected.Checked; objVideo.ShareType=Convert.ToInt16(ddlShareType.SelectedValue); objVideo.Private = ddlShareType.SelectedValue == "1"; objVideo.Protected = ddlShareType.SelectedValue == "2"; objVideo.ProtectPassword = txtProtectPassword.Text; objVideo.Friends = chkFriends.Checked; objVideo.Followers = chkFollowers.Checked; if (cblGroups.Items.Count>0) { objVideo.Groups = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblGroups); } else { objVideo.Groups = string.Empty; } objVideo.LinkUrl = ctlLinkUrl.Url; if (HasManagePermission) { objVideo.DisplayOrder = Convert.ToInt32(txtDisplayOrder.Text); //other if (Settings_Portal.General.VideoRequireApproval == true) { objVideo.Authed = chkAuthed.Checked; } else { objVideo.Authed = true; } objVideo.Featured = chkFeatured.Checked; } else { objVideo.DisplayOrder = 100; objVideo.Authed = !Settings_Portal.General.VideoRequireApproval; objVideo.Featured = false; } objVideo.Active = chkActive.Checked; if (CurrentType.FieldEnable_Image) { //Image and thumbnail objVideo.Image = ctlImage.Url; objVideo.Thumbnail = ""; } else { objVideo.Image = string.Empty; objVideo.Thumbnail = string.Empty; } //File if (objVideo.Image.StartsWith("FileID=")) { //local file if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); fi = GetFileInfoById(objVideo.Image); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; System.IO.FileInfo physicalFile = new System.IO.FileInfo(fi.PhysicalPath); if (!fi.FileName.ToLower().StartsWith("thumb_"))//文件没有以"thumb_"开头,则先查找是否存在以thumb_ 开头的同名图片 { if (System.IO.File.Exists(physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name))//存在该文件,则自动指向 { objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } else//不存在,则生成该文件,然后指向 { if (Settings_Portal.General.GenerateThumb) { Cross.DNN.Common.Utility.Utils.ResizeImage(fi.PhysicalPath, Settings_Portal.General.ThumbnailSize, physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name); objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } } } } } //a3 if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { int a3FileId = Convert.ToInt32(objVideo.Image.Replace("FileID=", "")); A3FileInfo objA3File = A3FileController.Get(a3FileId); if (objA3File != null && A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName) != null) { objVideo.Thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName).A3Url; } } } //External images if (objVideo.Image.ToLower().StartsWith("http")) { objVideo.Thumbnail = objVideo.Image; } if (string.IsNullOrEmpty(objVideo.Image))//没有设置任何图片,因此试图自动获取 { if (ctlVideoFile.Url.StartsWith("FileID="))// 当前选择为文件,因此试图获取其duration,thunmnail { int fileId = Convert.ToInt32(ctlVideoFile.Url.Replace("FileID=", "")); objVideo.Image = GetVideoThumbnail(fileId); objVideo.Thumbnail = objVideo.Image; } //自动获取youtube video 的image if (ctlVideoFile.Url.ToLower().IndexOf("youtu")>0) { if (!string.IsNullOrEmpty(LocalUtils.GetYouTubeVideoId(ctlVideoFile.Url))) { objVideo.Image = LocalUtils.GetYouTubeVideoImage_FullSize(ctlVideoFile.Url, System.Web.HttpContext.Current.Request.IsSecureConnection); objVideo.Thumbnail = LocalUtils.GetYouTubeVideoImage_Thumbnail(ctlVideoFile.Url, System.Web.HttpContext.Current.Request.IsSecureConnection); } } } //Add Categories objVideo.Categories = RecursiveHelper.GetAspNetTreeCheckList(tvCategory); objVideo.Field1 = GetHtmlEditorText(txtField1.Text); objVideo.Field2 = GetHtmlEditorText(txtField2.Text); objVideo.Field3 = GetHtmlEditorText(txtField3.Text); objVideo.Field4 = GetHtmlEditorText(txtField4.Text); objVideo.Field5 = GetHtmlEditorText(txtField5.Text); objVideo.Latitude=txtLatitude.Text.Trim(); objVideo.Longitude = txtLongitude.Text.Trim(); objVideo.MapTitle = txtMapTitle.Text.Trim(); //Add Tags objVideo.Tags = ""; TagInfo objTag = new TagInfo(); List<int> tagList = new List<int>(); if (txtTag1.Text.Trim() != "") { objTag = TagController.GetByTag(txtTag1.Text.Trim(),TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag1.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag2.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 1) { objTag = TagController.GetByTag(txtTag2.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag2.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag3.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 2) { objTag = TagController.GetByTag(txtTag3.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag3.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag4.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 3) { objTag = TagController.GetByTag(txtTag4.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag4.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag5.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 4) { objTag = TagController.GetByTag(txtTag5.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag5.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag6.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 5) { objTag = TagController.GetByTag(txtTag6.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag6.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag7.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 6) { objTag = TagController.GetByTag(txtTag7.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag7.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag8.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 7) { objTag = TagController.GetByTag(txtTag8.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag8.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag9.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 8) { objTag = TagController.GetByTag(txtTag9.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag9.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag10.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 9) { objTag = TagController.GetByTag(txtTag10.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag10.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } var newTaglist = (from p in tagList select p).Distinct();//remove the repeated tag item. foreach (int item in newTaglist) { objVideo.Tags += item.ToString() + ","; } objVideo.Tags = Cross.DNN.Common.Utility.Utils.RemoveSeperator(objVideo.Tags, ","); //Tags end //date if ((txtPublishDate.Text != null) && (txtPublishDate.Text != "")) { objVideo.PublishDate = Convert.ToDateTime(txtPublishDate.Text); } else { objVideo.PublishDate = DateTime.Now; } if (txtExpireDate.Text != "") { objVideo.ExpireDate = Convert.ToDateTime(txtExpireDate.Text); } if (HasManagePermission) { objVideo.ViewRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblViewRoles, PortalSettings.AdministratorRoleId); //Rating objVideo.AllowRating = chkAllowRating.Checked; objVideo.RatingRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblRatingRoles, PortalSettings.AdministratorRoleId); //Recommend objVideo.AllowRecommend = chkAllowRecommend.Checked; objVideo.RecommendRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblRecommendRoles, PortalSettings.AdministratorRoleId); //Comment objVideo.AllowComment = chkAllowComment.Checked; objVideo.CommentRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblCommentRoles, PortalSettings.AdministratorRoleId); objVideo.AutoAuthComment = chkAutoAuthComment.Checked; //Download roles objVideo.DownloadRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblDownloadRoles, PortalSettings.AdministratorRoleId); } else { objVideo.ViewRoles = Settings_Portal.General.VideoViewRoles; objVideo.AllowRating = Settings_Portal.Rating.AllowRating; objVideo.RatingRoles = Settings_Portal.Rating.RatingRoles; objVideo.AllowRecommend = Settings_Portal.Recommend.AllowRecommend; objVideo.RecommendRoles = Settings_Portal.Recommend.RecommendRoles; objVideo.AllowComment = Settings_Portal.Comment.AllowComment; objVideo.CommentRoles = Settings_Portal.Comment.CommentRoles; objVideo.AutoAuthComment = Settings_Portal.Comment.AutoAuthComment; objVideo.DownloadRoles = Settings_Portal.Download.DownloadRoles; } objVideo.Summary = Cross.DNN.Common.Utility.Utils.RemoveAllHtmlTags(txtSummary.Text); objVideo.Description = GetHtmlEditorText(txtDetail.Text); objVideo.UserId = UserId; objVideo.UserName = UserInfo.DisplayName; objVideo.MediaType = CurrentType.MediaType; objVideo.VideoType = Convert.ToInt32(VideoType.Single);//Single video objVideo.HasVideo = true; //Now processing attachment int newVideoId = -1; if (VideoId == -1) { newVideoId = VideoController.Add(objVideo); } else { VideoController.Update(objVideo,true); newVideoId = VideoId; } UpdateUserDefinedData(newVideoId); //Reset all VideoId = -1; }
private string GetImageThumbnail(int fileId) { string thumbnail = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (File.Exists(objPhysical.DirectoryName + "\\" + "thumb_" + objPhysical.Name))//Find if exist thumbnail image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + "thumb_" + objFile.FileName; } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName).A3Url; } } } return thumbnail; }
private string GetVideoThumbnail(int fileId) { string thumbnail = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (File.Exists(objPhysical.DirectoryName + "\\" + "thumb_" + objPhysical.Name.Replace(objPhysical.Extension, ".jpg")))//Find if exist thumbnail image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + "thumb_" + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } if (File.Exists(objPhysical.DirectoryName + "\\" + objPhysical.Name.Replace(objPhysical.Extension, ".jpg")))//Find if exist same name image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } if (Settings_Portal.Video.VideoConvert && Settings_Portal.Video.PassPermissionCheck)// 如果同名的jpg文件不存在,则试图生成一个 { Cross.DNN.Common.VideoManage.VideoManageOption option = new Cross.DNN.Common.VideoManage.VideoManageOption(); option.General.FFMPEGPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\ffmpeg.exe"; option.General.FLVToolPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\flvtool2.exe"; option.General.MencoderPath = VideoConvert_ExecuteFolder + "\\mencoder\\mencoder.exe"; option.General.MencoderDirectory = VideoConvert_ExecuteFolder + "\\mencoder"; option.General.InputPath = objPhysical.Directory.FullName; option.General.OutputPath = objPhysical.Directory.FullName; option.Video.ExitProcess = Settings_Portal.Video.ProcessExitTime; option.General.FileName = objPhysical.Name; Cross.DNN.Common.VideoManage.VideoController ctlVideo = new Cross.DNN.Common.VideoManage.VideoController(option); if (File.Exists(option.General.FFMPEGPath))//First we need check if execute package available { ctlVideo.CaptureSingleImage(); thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName.Replace(objA3File.Extension, ".jpg")) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName.Replace(objA3File.Extension, ".jpg")).A3Url; } else { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + objA3File.FileName.Replace(objA3File.Extension, ".jpg")) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + objA3File.FileName.Replace(objA3File.Extension, ".jpg")).A3Url; } } } } return thumbnail; }
private string GetVideoDuration(int fileId) { string duration = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && System.IO.File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (Settings_Portal.Video.VideoConvert && Settings_Portal.Video.PassPermissionCheck) { Cross.DNN.Common.VideoManage.VideoManageOption option = new Cross.DNN.Common.VideoManage.VideoManageOption(); option.General.FFMPEGPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\ffmpeg.exe"; option.General.FLVToolPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\flvtool2.exe"; option.General.MencoderPath = VideoConvert_ExecuteFolder + "\\mencoder\\mencoder.exe"; option.General.MencoderDirectory = VideoConvert_ExecuteFolder + "\\mencoder"; option.General.InputPath = objPhysical.Directory.FullName; option.General.OutputPath = objPhysical.Directory.FullName; option.Video.ExitProcess = Settings_Portal.Video.ProcessExitTime; option.General.FileName = objPhysical.Name; Cross.DNN.Common.VideoManage.VideoController ctlVideo = new Cross.DNN.Common.VideoManage.VideoController(option); duration = ctlVideo.Get_Info().Duration; } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { duration = objA3File.Duration; } } return duration.Trim(); }
private string GetFileFullUrl(int fileId) { string url = ""; if (Settings_Portal.General.FileStorage.ToLower() == "local") { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalSettings.PortalId); objFile = ctlFile.GetFileById(fileId, PortalSettings.PortalId); if (objFile != null) { url = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName; } } if (Settings_Portal.General.FileStorage.ToLower() == "a3") { if (A3FileController.Get(fileId) != null) { url = A3FileController.Get(fileId).A3Url; } } return url; }
private void UpdateVideo() { VideoInfo objVideo = new VideoInfo(); if (VideoId != -1) { objVideo = VideoController.Get(VideoId); } objVideo.Id = VideoId; objVideo.PortalId = PortalId; objVideo.TypeId = TypeId; //Normal objVideo.Title = txtVideoTitle.Text; objVideo.VideoFile = ctlVideoFile.Url; objVideo.VideoPath = ctlVideoFile.FullUrl; objVideo.UrlMode = ctlVideoFile.UrlMode; objVideo.Duration = txtVideoDuration.Text.Trim(); if (ctlVideoFile.Url.StartsWith("FileID="))// 当前选择为文件,因此试图获取其duration { int fileId = Convert.ToInt32(ctlVideoFile.Url.Replace("FileID=", "")); if (txtVideoDuration.Text.Trim() == "") { objVideo.Duration = GetVideoDuration(fileId); } } //if (CurrentType.MediaType == Convert.ToInt32(MediaType.Video)) //{ objVideo.HttpType = ddlHttpType.SelectedValue; //} //else //{ // objVideo.HttpType = "Audio"; //} if (CurrentType.FieldEnable_Image) { //Image and thumbnail objVideo.Image = ctlVideoImage.Url; objVideo.Thumbnail = ""; } else { objVideo.Image = string.Empty; objVideo.Thumbnail = string.Empty; } //File if (objVideo.Image.StartsWith("FileID=")) { //local file if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); fi = GetFileInfoById(objVideo.Image); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; System.IO.FileInfo physicalFile = new System.IO.FileInfo(fi.PhysicalPath); if (!fi.FileName.ToLower().StartsWith("thumb_"))//文件没有以"thumb_"开头,则先查找是否存在以thumb_ 开头的同名图片 { if (System.IO.File.Exists(physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name))//存在该文件,则自动指向 { objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } else//不存在,则生成该文件,然后指向 { if (Settings_Portal.General.GenerateThumb) { Cross.DNN.Common.Utility.Utils.ResizeImage(fi.PhysicalPath, Settings_Portal.General.ThumbnailSize, physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name); objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } } } } } //a3 if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { int a3FileId = Convert.ToInt32(objVideo.Image.Replace("FileID=", "")); A3FileInfo objA3File = A3FileController.Get(a3FileId); if (objA3File != null && A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName) != null) { objVideo.Thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName).A3Url; } } } //External images if (objVideo.Image.ToLower().StartsWith("http")) { objVideo.Thumbnail = objVideo.Image; } if (string.IsNullOrEmpty(objVideo.Image))//没有设置任何图片,因此试图自动获取 { if (ctlVideoFile.Url.StartsWith("FileID="))// 当前选择为文件,因此试图获取其duration,thunmnail { int fileId = Convert.ToInt32(ctlVideoFile.Url.Replace("FileID=", "")); objVideo.Image = GetVideoThumbnail(fileId); objVideo.Thumbnail = objVideo.Image; } //自动获取youtube video 的image if (ctlVideoFile.Url.ToLower().IndexOf("youtu") > 0) { if (!string.IsNullOrEmpty(LocalUtils.GetYouTubeVideoId(ctlVideoFile.Url))) { objVideo.Image = LocalUtils.GetYouTubeVideoImage_FullSize(ctlVideoFile.Url, System.Web.HttpContext.Current.Request.IsSecureConnection); objVideo.Thumbnail = LocalUtils.GetYouTubeVideoImage_Thumbnail(ctlVideoFile.Url, System.Web.HttpContext.Current.Request.IsSecureConnection); } } } objVideo.UserId = UserId; objVideo.UserName = UserInfo.DisplayName; objVideo.MediaType = CurrentType.MediaType; objVideo.VideoType = Convert.ToInt32(VideoType.SerialSlave);//Single video objVideo.SerialOrder = Convert.ToInt32(txtSerialOrder.Text); objVideo.MasterVideoId = SerialId; //Now processing attachment int newVideoId = -1; if (VideoId == -1) { newVideoId = VideoController.Add(objVideo); VideoInfo objSerial = VideoController.Get(SerialId); if (objSerial.HasVideo==false)//如果是第一次增加,则需要修改其 master video 的has video 属性 { objSerial.HasVideo = true; VideoController.Update(objSerial,false); } } else { VideoController.Update(objVideo,false); newVideoId = VideoId; } //Reset all VideoId = -1; }
private void UpdateArticle() { ArticleInfo objArticle = new ArticleInfo(); objArticle.Id = ArticleId; objArticle.PortalId = PortalId; //Normal objArticle.Title = txtTitle.Text; objArticle.Author = txtAuthor.Text; objArticle.Source = txtSource.Text; objArticle.Quote = chkQuote.Checked; objArticle.Draft = chkDraft.Checked; objArticle.LinkUrl = ctlLinkUrl.Url; objArticle.PinOrder = Convert.ToInt32(txtPinOrder.Text); //other if (ArticlePortalSettings.General.Portal_ArticleRequireApproval == true) { objArticle.Authed = chkAuthed.Checked; } else { objArticle.Authed = true; } objArticle.Featured = chkFeatured.Checked; objArticle.Active = chkActive.Checked; objArticle.Thumbnail = ""; objArticle.Image = UserInfo.IsInRole(PortalSettings.AdministratorRoleName)?ctlImage.Url : ctlUserImage.Url; objArticle.ImageDescription = txtImageDescription.Text; if (objArticle.Image.StartsWith("FileID=")) { FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); fi = GetFileInfoById(objArticle.Image); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; System.IO.FileInfo physicalFile = new System.IO.FileInfo(fi.PhysicalPath); if (!fi.FileName.ToLower().StartsWith("thumb_")) //文件没有以"thumb_"开头,则先查找是否存在以thumb_ 开头的同名图片 { if (System.IO.File.Exists(physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name)) //存在该文件,则自动指向 { objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } else//不存在,则生成该文件,然后指向 { if (ArticlePortalSettings.General.Portal_ArticleGenerateThumb) { Utils.ResizeImage(fi.PhysicalPath, ArticlePortalSettings.General.Portal_ArticleThumbnailSize, physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name); objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } } } } } //Add Categories objArticle.Categories = RecursiveHelper.GetAspNetTreeCheckList(tvCategory); //Add Tags objArticle.Tags = ""; TagInfo objTag = new TagInfo(); List <int> tagList = new List <int>(); if (txtTag1.Text.Trim() != "") { objTag = TagController.GetByTag(txtTag1.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag1.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag2.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 1) { objTag = TagController.GetByTag(txtTag2.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag2.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag3.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 2) { objTag = TagController.GetByTag(txtTag3.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag3.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag4.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 3) { objTag = TagController.GetByTag(txtTag4.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag4.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag5.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 4) { objTag = TagController.GetByTag(txtTag5.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag5.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag6.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 5) { objTag = TagController.GetByTag(txtTag6.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag6.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag7.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 6) { objTag = TagController.GetByTag(txtTag7.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag7.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag8.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 7) { objTag = TagController.GetByTag(txtTag8.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag8.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag9.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 8) { objTag = TagController.GetByTag(txtTag9.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag9.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag10.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 9) { objTag = TagController.GetByTag(txtTag10.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag10.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } var newTaglist = (from p in tagList select p).Distinct();//remove the repeated tag item. foreach (int item in newTaglist) { objArticle.Tags += item.ToString() + ","; } objArticle.Tags = Utils.RemoveSeperator(objArticle.Tags, ","); //Tags end //date if ((txtPublishDate.Text != null) && (txtPublishDate.Text != "")) { objArticle.PublishDate = Convert.ToDateTime(txtPublishDate.Text); } else { objArticle.PublishDate = DateTime.Now; } if (txtExpireDate.Text != "") { objArticle.ExpireDate = Convert.ToDateTime(txtExpireDate.Text); } objArticle.ViewRoles = Utils.GetCheckedItems(cblViewRoles, PortalSettings.AdministratorRoleId); //Rating objArticle.AllowRating = chkAllowRating.Checked; objArticle.RatingRoles = Utils.GetCheckedItems(cblRatingRoles, PortalSettings.AdministratorRoleId); //Recommend objArticle.AllowRecommend = chkAllowRecommend.Checked; objArticle.RecommendRoles = Utils.GetCheckedItems(cblRecommendRoles, PortalSettings.AdministratorRoleId); //Comment objArticle.AllowComment = chkAllowComment.Checked; objArticle.CommentRoles = Utils.GetCheckedItems(cblCommentRoles, PortalSettings.AdministratorRoleId); objArticle.AutoAuthComment = chkAutoAuthComment.Checked; //Download roles objArticle.DownloadRoles = Utils.GetCheckedItems(cblDownloadRoles, PortalSettings.AdministratorRoleId); objArticle.Summary = LocalUtils.RemoveAllHtmlTags(txtSummary.Text); objArticle.Article = txtDetail.Text; objArticle.UserId = UserId; //Now processing attachment int newArticleId = -1; if (ArticleId == -1) { newArticleId = ArticleController.Add(objArticle); } else { ArticleController.Update(objArticle); newArticleId = ArticleId; AttachmentController.DeleteByArticle(ArticleId); //delete attachment first. } AttachmentInfo ai = new AttachmentInfo(); foreach (AttachmentInfo item in AttachmentList) { ai.ArticleId = newArticleId; ai.FilePath = item.FilePath; AttachmentController.Add(ai); } //Reset all ArticleId = -1; AttachmentList = new List <AttachmentInfo>(); gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); }