private void ExportToVCF()
        {
            List<ContactDB> exportList = GetCheckedContactList();
            if (exportList.Count() == 0)
            {
                MessageBox.Show(CMLibrary.Properties.Resources.choose_contact_to_export);
                return;
            }
            if (openFolderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string path = openFolderDialog.SelectedPath;
                FileImExportController fileImEx = new FileImExportController();
                int res = fileImEx.ExportToVCFFile(exportList, path);

                if (res > 0)
                {
                    MessageBox.Show(CMLibrary.Properties.Resources.export_success);
                }
                else
                {
                    MessageBox.Show(CMLibrary.Properties.Resources.export_error);
                }
            }
        }
示例#2
0
        public async void ExportToVCF(List<int> exportList)
        {
            //List<ContactD> exportList = GetCheckedContactList();
            if (exportList.Count() == 0)
            {
                var msg = UC_AddressBook.ResourcesStringLoader.GetString("choose_contact_to_export");
                Modals.UIConfirmPopup.ShowAsyncInfoPopup(msg);
                return;
            }
            try
            {
                int res = -999;
                FolderPicker picker = new FolderPicker();
                picker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
                picker.FileTypeFilter.Add(".vcf");
                StorageFolder folder;
                FileImExportController fileImEx = new FileImExportController();
                string path = "";
                do
                {
                    if (res == FileImExportController.CODE_FOLDER_CAN_NOT_AUTHORIZED)
                    {
                        picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;

                        do
                        {
                            string msg = UC_AddressBook.ResourcesStringLoader.GetString("DIALOG-Message-export_folder_not_authorized");
                            msg = string.Format(msg, path);
                            var isReTask = await Modals.UIConfirmPopup.ShowAsyncConfirmPopup(msg);
                            if (isReTask == PopupResult.No)
                            {
                                var msgNo = UC_AddressBook.ResourcesStringLoader.GetString("DIALOG-Message-Export-NoContactExported");
                                Modals.UIConfirmPopup.ShowAsyncInfoPopup(msgNo);
                                res = FileImExportController.CODE_CAN_NOT_EXPORT;
                                return;
                            }
                            else
                            {
                                folder = await picker.PickSingleFolderAsync();
                            }
                        }
                        while (folder.Path.Equals(path));
                    }
                    else
                    {
                        folder = await picker.PickSingleFolderAsync();
                    }

                    if (folder != null)
                    {
                        path = folder.Path;
                        res = await fileImEx.ExportToVCFFile(exportList, folder);
                        if(res == FileImExportController.CODE_FOLDER_CAN_NOT_AUTHORIZED)
                            continue;
                        if (res == FileImExportController.CODE_EXPORT_SUCCESS)
                        {
                            string msg = UC_AddressBook.ResourcesStringLoader.GetString("DIALOG-Message-export_success");
                            Modals.UIConfirmPopup.ShowAsyncInfoPopup(msg);
                        }
                        else
                        {
                            string msg = UC_AddressBook.ResourcesStringLoader.GetString("DIALOG-Message-ExportError");
                            Modals.UIConfirmPopup.ShowAsyncInfoPopup(msg);
                        }
                    }
                }
                while (res == FileImExportController.CODE_FOLDER_CAN_NOT_AUTHORIZED);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                string msg = UC_AddressBook.ResourcesStringLoader.GetString("DIALOG-Message-ExportError");
                Modals.UIConfirmPopup.ShowAsyncInfoPopup(msg);
            }
        }
示例#3
0
        public void ExportToVCF(List<Object> listContact)
        {
            var exportList = ObjConvertToContactDB(listContact);
            if (exportList.Count() == 0)
            {
                MessageBox.Show(CMLibrary.Properties.Resources.choose_contact_to_export);
                return;
            }
            var dialog = new CommonOpenFileDialog();
            dialog.IsFolderPicker = true;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                string path = dialog.FileName;
                try
                {
                    if (path.Length >= 200)
                    {
                        MessageBox.Show(CMLibrary.Properties.Resources.invalid_file_name_path, CMLibrary.Properties.Resources.Destination_path_to_long, MessageBoxButton.OK);
                        return;
                    }
                }
                catch(System.IO.PathTooLongException)
                {
                    MessageBox.Show(CMLibrary.Properties.Resources.invalid_file_name_path, CMLibrary.Properties.Resources.Destination_path_to_long, MessageBoxButton.OK);
                    return;
                }

                FileImExportController fileImEx = new FileImExportController();
                int res = fileImEx.ExportToVCFFile(exportList, path);

                if (res > 0)
                {
                    MessageBox.Show(CMLibrary.Properties.Resources.export_success);
                }
                else if (res == -7)
                {
                    MessageBox.Show(CMLibrary.Properties.Resources.access_denied, CMLibrary.Properties.Resources.access_denied_title, MessageBoxButton.OK);
                }
                else
                {
                    MessageBox.Show(CMLibrary.Properties.Resources.export_error);
                }
            }
        }
示例#4
0
        public void ExportToVCF(List<Object> listContact)
        {
            var exportList = ObjConvertToContactDB(listContact);
            if (exportList.Count() == 0)
            {
                MessageBox.Show(CMLibrary.Properties.Resources.choose_contact_to_export);
                return;
            }
            if (openFolderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string path = openFolderDialog.SelectedPath;

                if (path.Length > 240)
                {
                    MessageBox.Show("Invalid file name/path");
                    return;
                    //saveFileDialog.FileName = fileName;
                    //this.ExportToCSV();
                }
                FileImExportController fileImEx = new FileImExportController();
                int res = fileImEx.ExportToVCFFile(exportList, path);

                if (res > 0)
                {
                    MessageBox.Show(CMLibrary.Properties.Resources.export_success);
                }
                else
                {
                    MessageBox.Show(CMLibrary.Properties.Resources.export_error);
                }
            }
        }