I tried to checkout a file using sharpsvn from remote repository,but i found sharpsvn can not to checkout single file only checkout folder,please help me to know how to checkout a file?Thx.
My code
SvnUpdateResult result;
SvnCheckOutArgs checkoutArgs = new SvnCheckOutArgs();
string target = txtRepository.Text.Trim();
SvnUriTarget url = new SvnUriTarget(target);
string fileName = url.FileName;
string path = folder + "\\" + fileName;
using (SvnClient client = new SvnClient())
{
try
{
client.CheckOut(url,txtLocalFilePath.Text.Trim(),out result);//.Update(path,updateArgs,out result);
if (result != null)
{
WriteCheckOutTime(txtRepository.Text.Trim(), result.Revision);
MessageBox.Show("Check out success!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch (SvnException svnException)
{
MessageBox.Show(svnException.Message + "Check out error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
catch (UriFormatException uriException)
{
MessageBox.Show(uriException.Message + "Check out error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
The smallest element you can check out with Subversion is a directory. It is not possible to check out a single file.
You can check out a directory, but leave it empty, via the Sparse Directories feature. Then update only the file you're interested in. But you must start with a directory.
FYI if you want to checkout empty use following syntax
//first define args
SvnCheckOutArgs args = new SvnCheckOutArgs();
// then for checkout only forlder empty
args.Depth = SvnDepth.Empty;
//checkout folder
client.CheckOut(url,txtLocalFilePath.Text.Trim(),args,out result)
Related
I'm working on zip files (android-studio-java)
and I tried below solutions:
android.permission.READ_EXTERNAL_STORAGE ---> failed (no read access for zip file)
Access documents and other files ---> failed (no read access for zip file)
android.permission.MANAGE_EXTERNAL_STORAGE ---> passed
My question is: Is there any lower level of permission for zip files or I have to use MANAGE_EXTERNAL_STORAGE?
Thank you,
Actually you can use ACTION_OPEN_DOCUMENT, no need for MANAGE_EXTERNAL_STORAGE
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
// you can set here the type you need setType(application/zip)
intent.setType("*/*");
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, ZIP_READ_CODE);
OnActivityResult
if (resultCode == RESULT_OK) {
case ZIP_READ_CODE: {
Uri uri = data.getData();
File file = null;
try {
file = read_uri_to_file(uri);
} catch (IOException e) {
//handle error
}
}
}
Read the File:
private File read_uri_to_file(Uri uri) throws IOException {
String displayName = "";
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
if(cursor != null && cursor.moveToFirst()){
try {
displayName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
}finally {
cursor.close();
}
}
//create temp file to copy and handle selected file
File file = File.createTempFile(
FilenameUtils.getBaseName(displayName),
"."+FilenameUtils.getExtension(displayName)
);
//copy selected file, to a temp file
InputStream inputStream = getContentResolver().openInputStream(uri);
FileUtils.copyInputStreamToFile(inputStream, file);
return file;
}
i intend to use SharpSvn methods such as 'add' and 'lock' for file or folder under SVN repository.
if the file is not mapped i receive an error indication - 'the node ... is not found'.
prior to SvnClient.Info() or SvnClient.Status(), how can i know the status of the file - is it or is it not added to SVN repository?
You can use the 'GetStatus' method:
static bool IsInRepository(string filename)
{
bool isVersioned = false;
using (SvnClient client = new SvnClient())
{
SvnStatusArgs sa = new SvnStatusArgs();
sa.Depth = SvnDepth.Empty;
sa.RetrieveAllEntries = true;
Collection<SvnStatusEventArgs> statuses;
client.GetStatus(filename, sa, out statuses);
isVersioned = !statuses[0].LocalContentStatus.Equals(SvnStatus.NotVersioned);
}
return isVersioned;
}
I have created some Crystal Reports for my Windows Project. They function fine when I run them on Visual Studio. (I am using VS 2010). But they wont work after I created the setup project and install the software on the Client PC. I get the following errors:
http://tistus.srilanka-erickson.com/errors.html
Following displayed is the button click event code that I have used to Load the crystal Report: First try clause has been used to register custom inputs to the Report, meanwhile the second try clause has been used to manually create the database connection to the report. third try clause has been used just to load the report.
private void buttonGenerateSecExportRpt_Click(object sender, EventArgs e)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (comboBoxSecPlateType.Text != "" && comboBoxSecExPlateBrand.Text != "")
{
try
{
dtFrom.Format = DateTimePickerFormat.Custom;
string periodfrom = dtFrom.Value.ToString("yyyy/MM/dd");
dtTo.Format = DateTimePickerFormat.Custom;
string periodto = dtTo.Value.ToString("yyyy/MM/dd");
//cryRpt.VerifyDatabase();
string fullPath = "..\\..\\SecondaryPlateExportReport.rpt";
cryRpt.Load(fullPath);
cryRpt.SetParameterValue("dateFromChecked", dtFrom.Checked);
cryRpt.SetParameterValue("dateToChecked", dtTo.Checked);
cryRpt.SetParameterValue("dtPeriodFrom", periodfrom);
cryRpt.SetParameterValue("dtPeriodTo", periodto);
cryRpt.SetParameterValue("PlateType", comboBoxSecPlateType.Text.Trim());
cryRpt.SetParameterValue("PlateBrand", comboBoxSecExPlateBrand.Text.Trim());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
DbConnectionInfo.SetConnectionString(ConfigurationManager.ConnectionStrings["con"].ToString());
TableLogOnInfo logOnInfo;
ConnectionInfo connectionInfo;
foreach (Table table in cryRpt.Database.Tables)
{
logOnInfo = table.LogOnInfo;
connectionInfo = logOnInfo.ConnectionInfo;
// Set the Connection parameters.
connectionInfo.DatabaseName = DbConnectionInfo.InitialCatalog;
connectionInfo.ServerName = DbConnectionInfo.ServerName;
if (!DbConnectionInfo.UseIntegratedSecurity)
{
connectionInfo.Password = DbConnectionInfo.Password;
connectionInfo.UserID = DbConnectionInfo.UserName;
}
else
{
connectionInfo.IntegratedSecurity = true;
}
table.ApplyLogOnInfo(logOnInfo);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
crystalReportViewerSecEx.ReportSource = cryRpt;
crystalReportViewerSecEx.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Please select both Plate Type and the Brand to Generate the Report!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
I want to make the crystal reports work after deploying the software on the client PCs. Any suggestions would be greatly appreciated!
crystalReport.Load(#"C:\WINDOWS\Temp\samridhi.rpt");
when u creating setup put ur crystal report path like this
and
go to "C:\WINDOWS\Temp"
and copy ur rpt and .cs file go to "C:\WINDOWS\Temp" by mycomputer not by run prompt
for not setup just to check crystal report path in project application here is
the path is
crystalReport.Load(System.Windows.Forms.Application.StartupPath + "\\samridhi.rpt");
Shehan,
It is best not to use hard-codeed paths in any .NET project. It is best if you use the Server.MapPath variable and build your string dynamically.
As an example add the using System.IO to your project. You can then use the Path.Combine method to build your string.
string mappath = HttpContext.Current.Server.MapPath("~/");
Path.Combine(mappath, "Report Folder Path", "FileName.rpt");
You can even place "Report Folder Path" into static string so that it can be called multiple times without fear of change.
as far as I know we can not call the javascript method in controller's action method. but how to consider that a particular code line get executed ? As i asked earlier here
we must have to get acknowledgment that line number so and so get executed. see this action in my controller
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult uploadfile(FormCollection fc)
{
UserMaster objUMaster = objAM.GetUser(new Guid(fc["userIdForFile"].ToString()));
try
{
string imagename = "";
//Check for files uploaded here.
foreach (string inputTagName in Request.Files)
{
HttpPostedFileBase file = Request.Files[inputTagName];
imagename = objUMaster.UserId.ToString() + file.FileName;
if (file.ContentLength > 0)
{
string filePath = Path.Combine(HttpContext.Server.MapPath("../Content/UserUploads"), objUMaster.UserId.ToString() + Path.GetFileName(file.FileName));
file.SaveAs(filePath);
string filePathThumb = Path.Combine(HttpContext.Server.MapPath("../Content/UserUploads/Thumbnails"), objUMaster.UserId.ToString() + Path.GetFileName(file.FileName));
var fl = Request.Files.Get(inputTagName);
Stream strm = fl.InputStream;
Image img = Image.FromStream(strm);
ResizeAndSaveHighQualityImage(img, 120, 120, filePathThumb, 100);
}
}
objUMaster.ProfilePhoto = imagename;
objAM.Save();
return RedirectToAction("EditProfile", new { id = objUMaster.UserId });
}
catch (Exception ex)
{
//SendEmail(ex.Message);
string strPath = HttpContext.Server.MapPath("../Content/UserUploads");
StreamWriter SW;
SW = System.IO.File.CreateText(strPath+"/log.txt");
SW.WriteLine(ex.Message.ToString());
SW.Close();
return RedirectToAction("EditProfile", new { id = objUMaster.UserId });
}
}
Here I am trying to upload the image in my domains file system (dir). but I want get alert so that I can confirm , this lie get executed successfully. because nothing happening as expected from this action. so can we call Javascript's "alert", or something else remedy?
Some pointers to help you:
See if Network service/account under which your application is running has permission on the location where you are saving your file.
Besides this to make sure that your file is saved, after save call you can make another call File.IsExist. If it exists then you can log the success/failure in some log file. Wouldn't that work for you?
I'm trying to populate a directory from the contents of a bundle built into my plug-in. The following code works when the bundle is a file-system, but fails when the bundle is a JAR.
What is the best way to test if a URL is a directory? Or is there a completely different, better approach for creating a file structure from a resource bundle?
static private void bundleCopy(String dir, String destination) throws IOException {
Bundle bundle = com.mds.apg.Activator.getDefault().getBundle();
for (#SuppressWarnings("unchecked")
Enumeration<URL> en = (Enumeration<URL>) bundle.findEntries(dir, "*", true);
en.hasMoreElements();) {
URL url = en.nextElement();
String toFileName = destination + url.getPath().substring(dir.length());
File toFile = new File(toFileName);
InputStream in;
try {
in = url.openStream();
} catch (FileNotFoundException e) {
// this exception get thrown for file system directories but not for jar file ones
if (!toFile.mkdir()) {
throw new IOException("bundleCopy: " + "directory Creation Failed: "
+ toFileName);
}
continue;
}
FileCopy.coreStreamCopy(in, toFile);
}
}
I found an answer:
The key point is that the Enumeration entries for directories end in a '/'.
The following correctly distinguishes between directories and files for both JARs and file systems:
static private void bundleCopy(String dir, String destination)
throws IOException, URISyntaxException {
Bundle bundle = com.mds.apg.Activator.getDefault().getBundle();
Enumeration<URL> en = bundle.findEntries(dir, "*", true);
while (en.hasMoreElements()) {
URL url = en.nextElement();
String pathFromBase = url.getPath().substring(dir.length()+1);
String toFileName = destination + pathFromBase;
File toFile = new File(toFileName);
if (pathFromBase.lastIndexOf('/') == pathFromBase.length() - 1) {
// This is a directory - create it and recurse
if (!toFile.mkdir()) {
throw new IOException("bundleCopy: " + "directory Creation Failed: " + toFileName);
}
} else {
// This is a file - copy it
FileCopy.coreStreamCopy(url.openStream(), toFile);
}
}
}
You could try something like new File(FileLocator.resolve(url).toUri()) to convert from the Eclipse-specific URL to one using a native Java protocol.