protected void ibtnEdit_Click(object sender, EventArgs e) { if (IsChallengeFiles) { LinkButton ee = (LinkButton)sender; string documentId = (string)ee.CommandArgument; DocumentId = new Guid(documentId); challengeFileComponent = new ChallengeFileComponent(new Guid(documentId)); WizardFile.ActiveStepIndex = 1; txtFileName.Text = challengeFileComponent.ChallengeFile.ObjectName; lblExtension.Text = challengeFileComponent.ChallengeFile.ObjectExtension; var list = ListComponent.GetListPerCategory("ChallengeFile", Thread.CurrentThread.CurrentCulture.Name).FirstOrDefault(a => a.Label == challengeFileComponent.ChallengeFile.ObjectType); ddCategory.SelectedValue = list.Key; } else { LinkButton ee = (LinkButton)sender; string documentId = (string)ee.CommandArgument; DocumentId = new Guid(documentId); documentComponent = new DocumentComponent(new Guid(documentId)); WizardFile.ActiveStepIndex = 1; ddCategory.SelectedValue = documentComponent.Document.Category; txtTitle.Text = documentComponent.Document.Title; txtFileName.Text = documentComponent.Document.Name; lblExtension.Text = documentComponent.Document.FileType; txtDescription.Text = documentComponent.Document.Description; rdbScope.SelectedValue = documentComponent.Document.Scope; } UpdateFile.Visible = true; CreateFile.Visible = false; }
/// <summary> /// Update information of the file in the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { try { if (IsChallengeFiles) { challengeFileComponent = new ChallengeFileComponent(DocumentId); challengeFileComponent.ChallengeFile.Updated = DateTime.Now; challengeFileComponent.ChallengeFile.ObjectName = ValidateSecurity.ValidateString(txtTitle.Text, false); challengeFileComponent.ChallengeFile.ObjectType = ddCategory.SelectedItem.Text; try { string pathServer = Server.MapPath(ddCategory.SelectedValue); string sourceFile = System.IO.Path.Combine(Server.MapPath(challengeFileComponent.ChallengeFile.ObjectLocation)); string destFile = System.IO.Path.Combine(pathServer, ValidateSecurity.ValidateString(txtFileName.Text, false) + ValidateSecurity.ValidateString(lblExtension.Text, false)); if (!Directory.Exists(pathServer)) { Directory.CreateDirectory(pathServer); } if (System.IO.File.Exists(sourceFile)) { if (!System.IO.File.Exists(destFile)) { System.IO.File.Move(sourceFile, destFile); } else { System.IO.File.Delete(destFile); System.IO.File.Move(sourceFile, destFile); } } challengeFileComponent.ChallengeFile.ObjectLocation = ddCategory.SelectedValue + ValidateSecurity.ValidateString(txtFileName.Text, false) + ValidateSecurity.ValidateString(lblExtension.Text, false); challengeFileComponent.Save(); } catch { } } else { documentComponent = new DocumentComponent(DocumentId); documentComponent.Document.Updated = DateTime.Now; documentComponent.Document.UploadedBy = UserId; documentComponent.Document.Version++; documentComponent.Document.Title = ValidateSecurity.ValidateString(txtTitle.Text, false); documentComponent.Document.Name = ValidateSecurity.ValidateString(txtFileName.Text, false); documentComponent.Document.Description = ValidateSecurity.ValidateString(txtDescription.Text, false); documentComponent.Document.Scope = rdbScope.SelectedValue; documentComponent.Document.Category = ddCategory.SelectedValue; documentComponent.Save(); } FillDataRepeater(); Count = 0; WizardFile.ActiveStepIndex = 0; } catch (Exception exc) { Exceptions. ProcessModuleLoadException( this, exc); } }
/// <summary> /// Download the file and accumulates the number of downloads /// </summary> public void DownloadFile() { byte[] objectFile; DocumentComponent documentComponent = new DocumentComponent(fileId); if (documentComponent.Document.DocumentId != Guid.Empty) { string filename = string.Empty; if (!string.IsNullOrEmpty(documentComponent.Document.Name)) { filename = documentComponent.Document.Name + documentComponent.Document.FileType; } else { if (!string.IsNullOrEmpty(documentComponent.Document.Title)) { filename = documentComponent.Document.Title + documentComponent.Document.FileType; } else { filename = "File" + documentComponent.Document.FileType; } } if (documentComponent.Document.Scope == "1") { documentComponent.Document.Views = documentComponent.Document.Views + 1; documentComponent.Document.Read = DateTime.Now; documentComponent.Save(); objectFile = documentComponent.Document.DocumentObject; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.Buffer = true; Response.AppendHeader("content-disposition", "attachment; filename=\"" + filename + "\""); Response.BinaryWrite(objectFile); Response.Flush(); Response.End(); } if (documentComponent.Document.Scope == "2")//issue seg { documentComponent.Document.Views = documentComponent.Document.Views + 1; documentComponent.Document.Read = DateTime.Now; documentComponent.Save(); objectFile = documentComponent.Document.DocumentObject; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.Buffer = true; Response.AppendHeader("content-disposition", "attachment; filename=\"" + filename + "\""); Response.BinaryWrite(objectFile); Response.Flush(); Response.End(); } lblMessage.Text = Localization.GetString("Rights", LocalResourceFile); } lblMessage.Text = Localization.GetString("Error", LocalResourceFile); }
/// <summary> /// Загрузить документ/комплект. /// </summary> /// <returns>Документ/комплект.</returns> public IDocumentComponent Load() { IdGenerator generator = IdGenerator.Instance; var doc1 = new DocumentComponent("Документ 1", generator.GetId()); var doc2 = new DocumentComponent("Документ 2", generator.GetId()); var comp1 = new DocumentComposite("Комплект 1", generator.GetId()); comp1.Add(doc1); comp1.Add(doc2); var doc3 = new DocumentComponent("Документ 3", generator.GetId()); var comp2 = new DocumentComposite("Комплект 2", generator.GetId()); comp2.Add(doc3); comp2.Add(comp1); return(comp2); }
public void run() { var document = new DocumentComponent("ComposableDocument"); var headerDocumentSection = new HeaderDocumentComponent(); var body = new DocumentComponent("Body"); document.AddComponent(headerDocumentSection); document.AddComponent(body); var customerDocumentSection = new CustomerDocumentComponent(41); var orders = new DocumentComponent("Orders"); var order0 = new OrderDocumentComponent(0); var order1 = new OrderDocumentComponent(1); orders.AddComponent(order0); orders.AddComponent(order1); body.AddComponent(customerDocumentSection); body.AddComponent(orders); string gatheredData = document.GatherData(); Console.WriteLine(gatheredData); }
/// <summary> /// Delete document row of the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDeleteUpdate_Click(object sender, EventArgs e) { if (IsChallengeFiles) { //Logical delete challengeFileComponent = new ChallengeFileComponent(DocumentId); challengeFileComponent.ChallengeFile.Updated = DateTime.Now; challengeFileComponent.ChallengeFile.Delete = true; challengeFileComponent.Save(); } else { //physical delete documentComponent = new DocumentComponent(DocumentId); documentComponent.Delete(); } FillDataRepeater(); WizardFile.ActiveStepIndex = 0; }
/// <summary> /// Save document in the server /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { string pathServerTemp = Server.MapPath("Portals/0/Images/Temp/"); string pathServerThumbImages = Server.MapPath("Portals/0/ModIma/ThumbImages/"); if (IsChallengeFiles) { if (string.IsNullOrEmpty(ValidateSecurity.ValidateString(txtTitle.Text, false))) { rgvtxtTitle.IsValid = false; return; } //Information of the document challengeFileComponent = new ChallengeFileComponent(Guid.NewGuid()); challengeFileComponent.ChallengeFile.Created = DateTime.Now; challengeFileComponent.ChallengeFile.Updated = challengeFileComponent.ChallengeFile.Created; challengeFileComponent.ChallengeFile.ObjectName = txtFileName.Text; challengeFileComponent.ChallengeFile.ObjectType = ddCategory.SelectedItem.Text; challengeFileComponent.ChallengeFile.Size = FileSize; challengeFileComponent.ChallengeFile.ObjectExtension = ExtensionName; challengeFileComponent.ChallengeFile.Language = Language; challengeFileComponent.ChallengeFile.ChallengeReferenceId = ChallengeReference; try { string pathServer = Server.MapPath(ddCategory.SelectedValue); string sourceFile = System.IO.Path.Combine(pathServerTemp, FileName + ExtensionName); string destFile = System.IO.Path.Combine(pathServer, ValidateSecurity.ValidateString(txtFileName.Text, false) + ValidateSecurity.ValidateString(lblExtension.Text, false)); if (!Directory.Exists(pathServer)) { Directory.CreateDirectory(pathServer); } if (System.IO.File.Exists(sourceFile)) { if (!System.IO.File.Exists(destFile)) { System.IO.File.Move(sourceFile, destFile); } else { System.IO.File.Delete(destFile); System.IO.File.Move(sourceFile, destFile); } } //Save document information in the database challengeFileComponent.ChallengeFile.ObjectLocation = ddCategory.SelectedValue + ValidateSecurity.ValidateString(txtFileName.Text, false) + ValidateSecurity.ValidateString(lblExtension.Text, false); challengeFileComponent.Save(); } catch { } } else { documentComponent = new DocumentComponent(Guid.NewGuid()); UserPropertyComponent user = new UserPropertyComponent(UserId); documentComponent.Document.Created = DateTime.Now; documentComponent.Document.CreatedBy = UserId; documentComponent.Document.Updated = documentComponent.Document.Created; documentComponent.Document.Views = 0; documentComponent.Document.Version = 1; documentComponent.Document.UploadedBy = user.UserProperty.UserId; documentComponent.Document.Author = string.Empty;// user.UserProperty.FirstName + " " + user.UserProperty.LastName; documentComponent.Document.Name = ValidateSecurity.ValidateString(txtFileName.Text, false); documentComponent.Document.Title = ValidateSecurity.ValidateString(txtTitle.Text, false); documentComponent.Document.FileType = ExtensionName; documentComponent.Document.Deleted = false; documentComponent.Document.Description = ValidateSecurity.ValidateString(txtDescription.Text, false); documentComponent.Document.Size = FileSize; documentComponent.Document.Permission = "0"; documentComponent.Document.Scope = rdbScope.SelectedValue; documentComponent.Document.Status = "published"; documentComponent.Document.Category = ddCategory.SelectedValue; documentComponent.Document.DocumentObject = Bytes; documentComponent.Document.ExternalReference = SolutionId; documentComponent.Document.Folder = Folder; //Save information of the document if (documentComponent.Save() < 0) { throw new Exception(); } if (ExtensionName.ToUpper() == ".PDF") { GhostscriptWrapper.GeneratePageThumb(pathServerTemp + FileName + ExtensionName, pathServerThumbImages + "pdf-" + documentComponent.Document.DocumentId.ToString() + ".jpg", 1, 150, 150, 300, 300); } } FillDataRepeater(); WizardFile.ActiveStepIndex = 0; } catch (Exception exc) { Exceptions. ProcessModuleLoadException( this, exc); } }
/// <summary> /// Load categories to the dropdownlist /// </summary> public void FillDataRepeater() { if (IsChallengeFiles) { List <NestedFile> nestedFiles = new List <NestedFile>(); List <List> list = ListComponent.GetListPerCategory("ChallengeFile", Thread.CurrentThread.CurrentCulture.Name).ToList(); List <ChallengeFile> fileList = null; DocumentsLoaded = 0; foreach (var item in list) { fileList = ChallengeFileComponent.GetFilesForChallenge(ChallengeReference, item.Label).ToList().Where(a => a.Delete == false || a.Delete == null).ToList(); if (fileList.Count > 0) { nestedFiles.Add(new NestedFile() { files = fileList, list = item }); DocumentsLoaded = DocumentsLoaded + fileList.Count; } } if (nestedFiles.Count > 0) { lblEmptyMessage.Visible = false; } else { lblEmptyMessage.Visible = true; } rCategory.DataSource = nestedFiles; rCategory.DataBind(); } else { List <NestedDocument> nestedDocuments = new List <NestedDocument>(); List <List> list = ListComponent.GetListPerCategory("FileCategory", Thread.CurrentThread.CurrentCulture.Name).ToList(); List <Document> documentList = null; DocumentsLoaded = 0; foreach (var item in list) { if (Folders != null) { foreach (var item2 in Folders) { documentList = DocumentComponent.GetDocuments(SolutionId, item.Key, item2); if (documentList.Count > 0) { nestedDocuments.Add(new NestedDocument() { documents = documentList, list = item }); DocumentsLoaded = DocumentsLoaded + documentList.Count; } } } else { documentList = DocumentComponent.GetDocuments(SolutionId, item.Key, Folder); if (documentList.Count > 0) { nestedDocuments.Add(new NestedDocument() { documents = documentList, list = item }); DocumentsLoaded = DocumentsLoaded + documentList.Count; } } } if (nestedDocuments.Count > 0) { lblEmptyMessage.Visible = false; } else { lblEmptyMessage.Visible = true; } rCategory.DataSource = nestedDocuments; rCategory.DataBind(); } }
public List <OrganizationsModel> GetOrganization(Guid organization, int?userId = -1, string language = "en-US") { try { var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); //lists List <OrganizationsModel> ListOrganization = new List <OrganizationsModel>(); List <string> ListLogo = new List <string>(); List <ReferencesModel> ListReference = new List <ReferencesModel>(); List <AccreditationsModel> ListAccreditation = new List <AccreditationsModel>(); List <AttributesModel> ListAttributes = new List <AttributesModel>(); List <UserProfileModel> ListuserInfo = new List <UserProfileModel>(); //get attributes var attributes = AttributesComponent.GetAttributesList(organization).ToList(); foreach (var item in attributes) { ListAttributes.Add(new AttributesModel() { AttributeID = item.AttributeID, OrganizationID = item.OrganizationID, Type = item.Type, Value = item.Value, ValueType = item.ValueType, Description = item.Description, Label = item.Label }); } //get number of solution var solutionsNumber = SolutionComponent.GetSolutionPerOrganization(organization).ToList().Count(); //get partners var partnersLogo = PartnershipsComponent.GetPartnershipListLogo(organization).ToList(); //get organizations by Id var List = OrganizationComponent.GetOrganizationPerId(organization).ToList(); //get organization references by Id var resultReferences = ReferencesComponent.GetReferences(organization).ToList(); //get user info var users = List.First().UserOrganizations.Where(a => a.Role == 1); //know if current user is owner bool owner = false; if (currentUser.UserID == users.First().UserID || currentUser.IsInRole("Administrators") || currentUser.IsSuperUser) { owner = true; } var userProfile = new UserPropertyComponent(users.First().UserID); // UserProfileModel userProfile = user.GetProfile(Convert.ToInt32(List.First().CreatedBy)); string finalExt = ""; if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".png"))) { finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".png"; } else if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".jpg"))) { finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".jpg"; } else { finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\defaultImage.png"; } if (resultReferences.Count() > 0) { foreach (var item in resultReferences) { var userProfileReferences = new UserPropertyComponent(item.UserId); ListReference.Add(new ReferencesModel() { ReferenceId = (Guid)item.ReferenceId, OrganizationId = (Guid)item.OrganizationId, UserId = item.UserId, Type = item.Type, Comment = item.Comment, Created = item.Created.ToString(), Updated = item.Updated.ToString(), Deleted = item.Deleted, fullName = userProfileReferences.UserProperty.FirstName + " " + userProfileReferences.UserProperty.LastName }); } } //Get organization accreditations var resultAccreditations = AccreditationsComponent.GetAccreditationId(organization).ToList(); if (resultAccreditations.Count() > 0) { foreach (var item in resultAccreditations) { DocumentComponent doc = new DocumentComponent((Guid)item.DocumentId); ListAccreditation.Add(new AccreditationsModel() { AccreditationId = (Guid)item.AccreditationId, OrganizationId = (Guid)item.OrganizationId, Content = item.Content, Description = item.Description, DocumentId = (Guid)item.DocumentId, Name = item.Name, Type = item.Type, yearAccreditation = item.Year, docName = doc.Document.Name, docUrl = "" }); } } foreach (var item in List) { ListOrganization.Add(new OrganizationsModel() { OrganizationID = (Guid)item.OrganizationID, Code = item.Code, Name = item.Name, //Address = currentUser.IsInRole("NexsoUser") ? item.Address : "", Address = item.Address, //Phone = currentUser.IsInRole("NexsoUser") ? item.Phone : "", Phone = item.Phone, //Email = currentUser.IsInRole("NexsoUser") ? item.Email : "", Email = item.Email, //ContactEmail = currentUser.IsInRole("NexsoUser") ? item.ContactEmail : "", ContactEmail = item.ContactEmail, Website = item.Website, Twitter = item.Twitter, //Skype = currentUser.IsInRole("NexsoUser") ? item.Skype : "", Skype = item.Skype, //Facebook = currentUser.IsInRole("NexsoUser") ? item.Facebook : "", Facebook = item.Facebook, GooglePlus = item.GooglePlus, LinkedIn = item.LinkedIn, Description = item.Description, Logo = item.Logo, Country = item.Country, Region = item.Region, City = item.City, ZipCode = item.ZipCode, Created = Convert.ToDateTime(item.Created), Updated = Convert.ToDateTime(item.Updated), Latitude = Convert.ToDecimal(item.Latitude), Longitude = Convert.ToDecimal(item.Longitude), GoogleLocation = item.GoogleLocation, Language = item.Language, Year = Convert.ToInt32(item.Year), Staff = Convert.ToInt32(item.Staff), Budget = Convert.ToDecimal(item.Budget), CheckedBy = item.CheckedBy, CreatedOn = Convert.ToDateTime(item.Created), UpdatedOn = Convert.ToDateTime(item.Updated), CreatedBy = Convert.ToInt32(item.CreatedBy), Deleted = Convert.ToBoolean(item.Deleted), accreditations = ListAccreditation, references = ListReference, solutionNumber = Convert.ToInt32(solutionsNumber), partnershipsLogo = partnersLogo, attributes = ListAttributes, userFirstName = userProfile.UserProperty.FirstName, userLastName = userProfile.UserProperty.LastName, userEmail = userProfile.UserProperty.email, userLinkedIn = userProfile.UserProperty.LinkedIn, userFacebook = userProfile.UserProperty.FaceBook, userTwitter = userProfile.UserProperty.Twitter, userAddress = userProfile.UserProperty.Address, userCity = userProfile.UserProperty.City, userCountry = userProfile.UserProperty.Country, userProfilePicture = finalExt, userID = currentUser.UserID.ToString(), ownerSolution = owner }); } return(ListOrganization); } catch (HttpResponseException e) { throw e; } catch (Exception ee) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ee); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
protected Decorator(DocumentComponent documentComponent) { DocumentComponent = documentComponent; }
public void AddSection(DocumentComponent section) { _sections.Add(section); }