Exemplo n.º 1
0
 private void deleteContacPics(int contactId)
 {
     string[] contactPicsList = Directory.GetFiles(ServerMapPath(SitePaths.contactsPics(memberInfo.id)), Encoding.sha1(contactId.ToString()) + "*");
     foreach (string contactExistingPic in contactPicsList)
     {
         File.Delete(contactExistingPic);
     }
 }
Exemplo n.º 2
0
        private void loadContact(int conctactId)
        {
            try
            {
                ContactsService contactsService = new ContactsService(SessionManager.sessionMemberInfo);
                Contact         existingContact = contactsService.getContact(conctactId);

                txtFirstName.Text      = existingContact.firstName;
                txtLastName.Text       = existingContact.lastName;
                ddlGenre.SelectedValue = existingContact.genre;
                txtEmail.Text          = existingContact.email;
                txtMobileNumber.Text   = existingContact.mobileNumber;
                txtLandlineNumber.Text = existingContact.landlineNumber;
                txtComments.Text       = existingContact.comments;

                // If the contact has an extension, means that has a pic
                if (existingContact.picExtension != string.Empty)
                {
                    imgContactPic.ImageUrl = SitePaths.contactsPics(SessionManager.sessionMemberInfo.id) + Encoding.sha1(existingContact.id.ToString()) + existingContact.picExtension;
                    chkDeletePic.Visible   = true;
                }

                // If contact is not active, the user can not edit it
                if (!existingContact.isActive)
                {
                    txtFirstName.Enabled      = false;
                    txtLastName.Enabled       = false;
                    ddlGenre.Enabled          = false;
                    txtEmail.Enabled          = false;
                    txtMobileNumber.Enabled   = false;
                    txtLandlineNumber.Enabled = false;
                    txtComments.Enabled       = false;
                    cmdEditContact.Visible    = false;
                    uplContactPic.Visible     = false;
                    chkDeletePic.Visible      = false;
                }
            }
            catch (Exception)
            {
                showError(HttpContext.GetGlobalResourceObject("Resource", "ErrorGeneral").ToString());
            }
        }
Exemplo n.º 3
0
        public static string GetTargetFileName(this MetaContent content, SitePaths paths)
        {
            var isPage = content.Page != null;

            string targetDirectory;

            if (isPage)
            {
                targetDirectory = Path.GetDirectoryName(content.FileName.Replace(paths.PagesPath, paths.OutputPath));
            }
            else
            {
                targetDirectory =
                    Path.GetDirectoryName(content.FileName.Replace(paths.PostsPath,
                        Path.Combine(paths.OutputPath, SitePaths.PostsDirectoryName)));
            }
            var targetFileName = Path.GetFileNameWithoutExtension(content.FileName) + ".html";

            var targetPath = Path.Combine(targetDirectory, targetFileName);
            return targetPath;
        }
Exemplo n.º 4
0
        public static string GetTargetFileName(this MetaContent content, SitePaths paths)
        {
            var isPage = content.Page != null;

            string targetDirectory;

            if (isPage)
            {
                targetDirectory = Path.GetDirectoryName(content.FileName.Replace(paths.PagesPath, paths.OutputPath));
            }
            else
            {
                targetDirectory =
                    Path.GetDirectoryName(content.FileName.Replace(paths.PostsPath,
                                                                   Path.Combine(paths.OutputPath, SitePaths.PostsDirectoryName)));
            }
            var targetFileName = Path.GetFileNameWithoutExtension(content.FileName) + ".html";

            var targetPath = Path.Combine(targetDirectory, targetFileName);

            return(targetPath);
        }
Exemplo n.º 5
0
        private void createContact()
        {
            try
            {
                ContactsService      contactsService = new ContactsService(SessionManager.sessionMemberInfo);
                Contact              newContact      = new Contact();
                TransactionResultDTO result;

                // Variables to manage the contact pic file
                string fileExtension   = "";
                int    fileSizeInBytes = 0;

                if (uplContactPic.HasFile)
                {
                    fileExtension   = System.IO.Path.GetExtension(uplContactPic.FileName);
                    fileSizeInBytes = uplContactPic.PostedFile.ContentLength;

                    if (!Validations.isValidContactPic(fileExtension, fileSizeInBytes))
                    {
                        showError(HttpContext.GetGlobalResourceObject("Resource", "ErrorFotoContactoInvalida").ToString());
                        return;
                    }
                }

                newContact.firstName      = txtFirstName.Text;
                newContact.lastName       = txtLastName.Text;
                newContact.genre          = ddlGenre.SelectedValue;
                newContact.email          = txtEmail.Text;
                newContact.mobileNumber   = txtMobileNumber.Text;
                newContact.landlineNumber = txtLandlineNumber.Text;
                newContact.picExtension   = fileExtension;
                newContact.comments       = txtComments.Text;

                result = contactsService.createContact(newContact);
                if (result.code == TransactionResultDTO.transactionResultCode.Success)
                {
                    int createdContactId = result.affectedId;

                    try
                    {
                        if (uplContactPic.HasFile)
                        {
                            uplContactPic.SaveAs(Server.MapPath(SitePaths.contactsPics(SessionManager.sessionMemberInfo.id) + Encoding.sha1(createdContactId.ToString()) + fileExtension));
                        }

                        Response.Redirect(Pages.getContactsDefault(), false);
                    }
                    catch (Exception)
                    {
                        contactsService.deleteContact(createdContactId);
                        showError(HttpContext.GetGlobalResourceObject("Resource", "ErrorGeneral").ToString());
                    }
                }
                else
                {
                    showError(result.failureReason);
                }
            }
            catch (Exception)
            {
                showError(HttpContext.GetGlobalResourceObject("Resource", "ErrorGeneral").ToString());
            }
        }
Exemplo n.º 6
0
 public WorkspaceInfo(SitePaths paths)
 {
     Paths = paths;
 }
Exemplo n.º 7
0
 public WorkspaceInfo(SitePaths paths)
 {
     Paths = paths;
 }