It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
In my web application users need to chose folder with special file. But they don't see paths on server. How can I open server folders for viewing?
On local machine i look all directories fine:
On server like this:
call the TreeADirectory with a valid server path and you will have you tree rendered :)
private void TreeADirectory(TreeView treeView, string pathToList)
{
treeView.Nodes.Clear();
var rootInfo = new DirectoryInfo(pathToList);
var node = CreateDirNodes(rootInfo);
treeView.Nodes.Add(node);
}
private static TreeNode CreateDirNodes(DirectoryInfo directoryInfo)
{
var directoryNode = new TreeNode(directoryInfo.Name);
var dirs = directoryInfo.GetDirectories()
foreach (var directory in dirs)
{
directoryNode.Nodes.Add(CreateDirectoryNode(directory));
}
//only if you need to show files
var files = directoryInfo.GetFiles()
foreach (var file in files )
{
directoryNode.Nodes.Add(new TreeNode(file.Name));
}
return directoryNode;
}
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I want to migrate all alfresco repository contents from one repository to other. but i don't want the existing folder structure.
while migrating i have to validate the content according to some business requirement, and based on content type i have to create different folder structure in new repository.
Does any one did this previously.
Please help.
Thanks in Advance...
Ok, the solution that i give is not the best one, but i think it will work, we will start with a simple document and see if it's working (we will modifie the answer)
Getting the inputStram of a document
I think it's the most important part
public InputStream getTheInputStream () {
Document newDocument = (Document) getSession(serverURL, userName, password).getObject(path);
ContentStream cs = newDocument.getContentStream(null);
return cs.getStream();
}
Moving the inputStram from Server A to Server B
public void transfert() throws FileNotFoundException, IOException {
Session sessionB = getSession(serverUrlB, usernameB, passwordB);
//////////////////////////// GET THE FOLDER THAT YOU WILL WORK WITH
Folder root = sessionB.getRootFolder();
//////////////////////////// GET THE FOLDER THAT YOU WILL WORK WITH
File newfile = new File(fileName);
String nom = fileName;
Map<String, Object> properties = new HashMap<>();
properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
properties.put(PropertyIds.NAME, nom);
List<Ace> addAces = new LinkedList<>();
List<Ace> removeAces = new LinkedList<>();
List<Policy> policies = new LinkedList<>();
String extension = FilenameUtils.getExtension(nom);
ContentStream contentStream = new ContentStreamImpl("content." + extension, BigInteger.valueOf(nom).length()),
new MimetypesFileTypeMap().getContentType(newfile), (theInputStream);
Document dc = root.createDocument(properties, contentStream, VersioningState.MAJOR, policies, addAces, removeAces, sessionB.getDefaultContext());
}
Try this method and tell me if it's working, if you don't have the getSession method just look to this post get session method.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to set a label with something out a database.
This is my query:
string strQuery = "Select * FROM Contacts Where User='" + strSelectedUser + "'";
SqlCommand command = new SqlCommand(strQuery, Global.myConn);
SqlDataAdapter da = new SqlDataAdapter(command);
da.Fill(Global.ds, "Tabel");
Now I want to set a label
lblContact.Text=......[column database = name]....?
How do I do that?
Please use blow code to set label value from database.
First check that your query is retuning value then assign the value to label text
if(Global.ds.Tables["Tabel"].Row.Count>0)
{
lblContact.Text=Global.ds.Tables["Tabel"].Rows[0]["Colomn_Name"].toString();
}
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Is it possible to publish a Page by using Tom.net API in SDL Tridion 2011?
As Nuno mentioned, use PublishEngine.Publish and refer the syntax and example
Syntax:
PublishEngine.Publish(
new IdentifiableObject[] { linkedComponent },
engine.PublishingContext.PublishInstruction,
new List() { engine.PublishingContext.PublicationTarget });
Do something like this:-
private void Publish(IdentifiableObject item, PublicationTarget publicationTarget, bool rollBackOnFailure, bool includeComponentLinks)
{
IEnumerable<IdentifiableObject> items = new List<IdentifiableObject>() { item };
IEnumerable<PublicationTarget> targets = new List<PublicationTarget>() { publicationTarget };
PublishInstruction instruction = new PublishInstruction(item.Session)
{
DeployAt = DateTime.Now,
RenderInstruction = new RenderInstruction(item.Session)
{
RenderMode = RenderMode.Publish
},
ResolveInstruction = new ResolveInstruction(item.Session)
{
IncludeComponentLinks = includeComponentLinks
},
RollbackOnFailure = rollBackOnFailure,
StartAt = DateTime.MinValue
};
PublishEngine.Publish(items, instruction, targets);
}
**Contents is copied from How to Publish Stuff Programmatically blog
Use PublishEngine.Publish, follow Intellisense from there. You'll need to provide Render and Resolve instructions, as well as the usual details like Target, start date/time, etc.
The documentation has samples, various blogs have samples, and Visual Studio should help you find what you need.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
i m writing the code:
string query = "Select * from AdminLogin where username='" + name +
"' and password='" + password + "'";
DataSet ds = BusinessLogic.returnDataSet(query);
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr[0].ToString() == name && dr[1].ToString() == password)
{
Response.Redirect("~/Home.aspx");
}
else
{
//Here I want to write the code that will open a message box
//that will tell to user that username and password does not match.
}
}
By message box I'm assuming you mean a javascript alert. I'm not a big fan of posting back with javascript functions. I think its messy, and that javascript should only be used when dealing with client-side actions.
I would actually recommend to use a placeholder and a literal control for this. You could have the following in your webform:
<asp:placeholder id="phLoginFailed" runat="server" visible="false">
<div class="loginfailed">
Login failed
</div>
</asp:placeholder>
This placeholder could be styled like a popup, or displayed within your page using CSS.
Then change your C# to:
else
{
phLoginFailed.Visible = true;
}
Also, its worth mentioning, your SQL query is prone to SQL Injection. You should use parameterised queries.
And you should encrypt passwords when storing them in the database for security purposes.
This is not as easy as it sounds. Basically, you have two options:
Send some JavaScript to the client (for example, using RegisterClientScriptBlock) which calls the JavaScript alert(...); method.
Alternatively, use an ASP.NET component that "looks like" a popup. One example is the ModalPopup component in the ASP.NET Ajax Control Toolkit.
ClientScript.RegisterClientScriptBlock(Page.GetType(),"key", "alert('Wrong username or password')", true);
or if it is used outside page scope
then
Page page = (HttpContext.Current.Handler as Page);
if (page!=null)
{
page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "key", "alert('Wrong username or password')", true);
}
just write this line where you want o show message
this.Page.RegisterClientScriptBlock(Page.GetType(),"key", "alert('Wrong username or password')",true);
Edited code
if (dr[0].ToString() == name && dr[1].ToString() == password)
{
Response.Redirect("~/Home.aspx");
}
else
{
this.Page.RegisterClientScriptBlock(Page.GetType(),"key", "alert('Wrong username or password')",true);
//Here I want to write the code that will open a message box
//that will tell to user that username and password does not match.
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
ASP.NET : is there a way to use rdp in my web application?I need to create asp.net application and open remote desktop from my pc to another one though my web page
You can also check Myrtille, which is similar to Guacamole, but for Windows.
PS: Myrtille is the open source incarnation of Steemind cited above. I just saw the comment as I write these lines. #lopsided: please apologize my high latency reply.
Here, We have created new rdp file with dynamic IP address to mentioned path and the same will be downloaded by using HttpResponseMessage
API Controller
using System.Text;
using System.Web.Mvc;
namespace SafeIntranet.Controllers
{
public class RemoteDesktopController : Controller
{
public HttpResponseMessage GetRDPFileDownload(string ipAddress)
{
string filePath = #"C:\Test\AzureVMFile.rdp";
if (File.Exists(filePath))
{
File.Delete(filePath);
}
using (FileStream fs = File.Create(filePath))
{
Byte[] title = new UTF8Encoding(true).GetBytes("full address:s:" + ipAddress + ":3389 \nprompt for credentials:i:1 \nadministrative session:i:1");
fs.Write(title, 0, title.Length);
}
MemoryStream dataStream = null;
var fileBytes = File.ReadAllBytes(filePath);
dataStream = new MemoryStream(fileBytes);
HttpResponseMessage HttpResponseMessage = Request.CreateResponse(HttpStatusCode.OK);
HttpResponseMessage.Content = new StreamContent(dataStream);
HttpResponseMessage.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
HttpResponseMessage.Content.Headers.ContentDisposition.FileName = "AzureVM.rdp";
HttpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
return HttpResponseMessage;
}
}
}
Client Side Code:
window.location.href = "https:\\api.test.com\v1\azure\GetRDPFileDownload?ipAddress=10.10.10.10";
I don't believe there is any way you can launch RDP from asp.net and relay it through the browser, there are other remoting solution that are web based, you can check out:
GoTo My PC: http://www.gotomypc.com/
and
LogMeIn: http://www.logmein.com/
If you don't need a GUI but need your ASP.NET to execute remote code on the other server you can probably use PowerShell's remoting features:
http://technet.microsoft.com/en-us/library/dd819505.aspx
I do believe Window server already supports this you just need to install the RDP remote application watch this youtube to find out how to install http://www.youtube.com/watch?v=S6CIAGfcTU8&feature=related
info http://www.youtube.com/watch?v=7KKtTw5RTCc
Pass this code to an HTML File and if you want you can divide it later no an ASP.net aspx file separating the HTML and Code Behind.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa380809%28v=vs.85%29.aspx
Check out the minimal requirements to client machine.
Good Programming ! fellow "blue color workers" of the digital world ! :)
You can create a link which will download an automatically generated .rdp file in ASP.Net MVC using a simple controller.
Create a controller:
using System.Text;
using System.Web.Mvc;
namespace SafeIntranet.Controllers
{
public class RemoteDesktopController : Controller
{
public ActionResult Index(string link)
{
Response.AddHeader("content-disposition", "attachment; filename= " + link + ".rdp");
return new FileContentResult(
Encoding.UTF8.GetBytes($"full address:s: {link}"),
"application/rdp");
}
}
}
Create a link to call this in you view:
#Html.ActionLink("RemoteMachineName", "Index", "RemoteDesktop", new { link = "RemoteMachineName" }, null)
Or:
RemoteMachineName