|
|
 below is my code.
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "ap*****",
UserName = "****",
Password = "******",
SshHostKeyFingerprint = "*******"
};
using (Session session = new Session())
{
session.ExecutablePath = @"WinSCP.exe path";
session.Open(sessionOptions);
List<RemoteFileInfo> files =
session.EnumerateRemoteFiles(
MonitorDirectory, FileSearchPattern, EnumerationOptions.None)
.ToList();
DateTime now = DateTime.Today;
ReportMonth = now.ToString("MMM").ToUpper();
foreach (RemoteFileInfo fileInfo in files)
{
------------------------------have to do renaming of the file here---------------------------
if (fileInfo.FullName.Contains(GetClientID))
{
if (fileInfo.Length > ThresholdValue)
{
FileModifiedDate = fileInfo.LastWriteTime.ToString("yyyyMM", CultureInfo.InvariantCulture);
if (GetReportDateYM == FileModifiedDate || fileInfo.FullName.Contains(ReportMonth))
{
FileName = fileInfo.FullName;
Dts.Variables["User::FileName"].Value = FileName;
Dts.Variables["User::FileDate"].Value = FileModifiedDate;
Dts.TaskResult = (int)ScriptResults.Success;
break;
}
}
}
So here I have a directory in remote server and I am accessing it through WinSCP tool. requirement is to rename the files insider this remote directory. I can read each and every file name but I am not able to find rename function here.
|
|
|
|
|
Hi,
I have no experience with WinSCP, however browsing the documentation I'm now convinced what you need is here[^].
Google is your friend, treat him well.
|
|
|
|
|
Thank you Luc Pattyn. will go through the same.
|
|
|
|
|
Dear all,
I am sorry by now, I want to use Multicombobox in datagridview,
I have access file have two table :ItemAll, Pur in acccess file.Column Items in datagridview1 is Combobox,
1- I want to create column of items as multicombobox ,when click on culumn Items , its doplist table ItemAll have two column :Items,NameItem.
2-In datagridview , when click multicombobox anh selcect Items column in combobox , In columm datagridview will receive data .
I have added Multicombobox.cs, MulticomboboxPopup in project, I use dataset ACCSDataset.
Thank you
My email:[DELETED]@gmail.com
modified 27-Apr-20 1:25am.
|
|
|
|
|
Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I am programing and application for work which requires a certain level of access rights to users. Once logged in I get the access level number 1-10 which is then put onto a splash screen in a hidden txt box.
on the closure of the splash screen i would like it to go to a menu for that access right.
This is the code I am using
private void tmr_splash_Tick(object sender, EventArgs e)
{
prb_splash.Increment(1);
if (prb_splash.Value == 100)
tmr_splash.Stop();
if (prb_splash.Value == 100)
this.Hide();
if (prb_splash.Value == 100 & (!txt_number.Text.Contains("10")))
{
frm_Artemis_admin aa = new frm_Artemis_admin();
aa.ShowDialog();
}
else
if (prb_splash.Value == 100 & (!txt_number.Text.Contains("09")))
{
frm_Employees_edit aa = new frm_Employees_edit();
aa.ShowDialog();
}
The application runs but even though I have changed the access rights to 9 to test it its still going to the admin menu?
If anyone can help that would be great.
Many Thanks :)
|
|
|
|
|
This is going to be dependent on data to a large degree - and we don't have any access to that.
So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
"9" is not the same as "09" when searching a text string.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
This is way too simplistic, you need to build up a framework for managing your security.
Your users credentials and rights (0-9) need to be stored in a class that all your forms can access.
When you instantiate a form you need to be able to check that class and apply the restrictions to the form as it is constructed (in WPF by binding the enable/visible values).
Instead of 10 levels the standard is to use Roles where a user may have multiple roles.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Hi,
I'm trying to solve 100 doors Kata from provided link "http://www.tddbuddy.com/katas/100%20Doors.pdf[^]"
I've solved Open and Closed door status but stuck with Bonus part where I have to show Holding state as well. Can someone please help me to solve that. Below is the code for Open and Close door.
List<bool> listDoorStatus= new List<bool>();
for (int i = 1; i <= 100; i++)
{
for (int j = i; j <= numberOfDoors; j += i)
{
listDoorStatus[j - 1] = !listDoorStatus[j - 1];
}
}
StringBuilder sb = new StringBuilder();
foreach (var item in listDoorStatus)
{
if (item)
{
sb.Append("@");
}
else
{
sb.Append("#");
}
} return sb.toString()
|
|
|
|
|
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I am able to solve till two status of doors which are open and close. but in next step have to Add a third state which is holding (use H). By adding this state, you must toggle between open, holding and closed when visiting the doors.
I am just trying to learn this kind of problems which we generally found on Hacker Rank just like FizzBuzz.
So Till now what I solved:
If pass=1 for 10 doors then output will be @@@@@@@@@@
If Pass=2 for 10 doors then output will be @#@#@#@#@#
If Pass=3 for 10 doors then output will be @###@@@###
Where @ represents Open, and # represents close.
till this place I have solved it. But not when I've to show holding status as well. i am bit confused. I tried to create a loop on output and place H (represent Holding State) but it didn't work for me.
Like for Pass 2 output should be @H#@H#@H#@
|
|
|
|
|
So what have you tried?
It's obvious why you're having difficulty, but your code doesn't show any attempt to implement a "third state" at all.
And that implies "I haven't tried at all" - so you need to show us that you have. We aren;t here to do it all for you!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
How do you identify whether a door is open or closed, and what do you mean by "holding status"?
|
|
|
|
|
You started with 2 "states", you now have 3: open "@", closed "#", and holding "H".
Change your logic to handle 3 states, instead of just 2 (i.e. if item is a "bool", it should be a numeric or an "enum").
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I am trying to put together an application in Visual Studio using C sharp for the first time. I have a database on my SQL server but can not seem to connect using the string provided by Visual Studio nor the one below. Can anyone please help?
SqlConnection con = new SqlConnection(@"Data Source=\=DAVIES-SERVER\SQLEXPRESS;database=Artemis Data;Integrated Security=True");
Many thanks
|
|
|
|
|
Your connectionstring seems off.
Member 14812582 wrote: @"Data Source=\=DAVIES-SERVER\SQLEXPRESS;database=Artemis Data;Integrated Security=True"
"=DAVIES-SERVER" is hardly a computer-name. Drop the equals, and it may work. Use an IP if it doesn't.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
|
Use the Server Explorer under Tools | Connect to Database / Server and test your connection. All your attempts will fail if you're not available to your server.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
the goal: use interfaces to enable creating a collection of different types of objects: and, then, at run-time cast back to the generic type without hard-coding specific types.
a. without using 'dynamic
b. without using reflection
c. without cloning/copying (using something like 'Activator.CreateInstance)
note: you might think you could:
a. use 'Convert.ChangeType : no, it is designed for conversion to a variety of primitive types, requires implementing IConvertible, and it returns an object.
b. use a 'ComponentModel.TypeConverter implementation per class: returns an object; internal method overrides cannot have return type modified
background:
A common pattern in creating heterogenous collections of different Type objects is making the various objects inherit from a generic Interface that itself inherits from a non-generic interface: by casting the instances of the generic interface to the non-generic interface, you then can create a collection you can compile.
when, at run-time, you have an instance of the non-generic interface, you can, then, "upcast" to the generic interface to expose fields, properties, methods unique to the generic type ... but ...
to upcast you need to:
1. know the Type
2. or, use a switch statement in which you use explicitly coded possible type matches
if you have a variable of type 'Type, there is no way to use its run-time value to upcast the non-generic interface instance !
public interface IBeing
{
string BName { get; set; }
Type BType { get; set; }
}
public interface IBeing<T> : IBeing where T : class
{
T Value { get; set; }
}
public class Being<T> : IBeing where T : class
{
public Being(string name, T value)
{
Value = value;
BName = name;
}
public T Value { get; set; }
public string BName { get; set; }
public Type BType { get; set; }
}
public class Human : IBeing
{
public Human(string name)
{
BName = name;
}
public Type BType { get; set; }
public string BName { get; set; }
}
public class Dog : IBeing
{
public Dog(string name)
{
BName = name;
}
public Type BType { get; set; }
public string BName { get; set; }
}
public class BeingCache
{
public BeingCache()
{
Beings = new List<IBeing>();
}
public List<IBeing> Beings { get; }
public IBeing AddBeing<T>(string name, T value) where T : class
{
Being<T> newbeing = new Being<T>(name, value);
newbeing.BType = typeof(T);
Beings.Add(newbeing);
return newbeing;
}
}
BeingCache beingCache = new BeingCache();
Human h1 = new Human("h1");
Dog d1 = new Dog("d1");
IBeing being1 = beingCache.AddBeing<Human>("Jack", h1);
IBeing being2 = beingCache.AddBeing<Dog>("Rover", d1);
IBeing being1human = beingCache.Beings[0];
IBeing being2dog = beingCache.Beings[1]; At this point, to convert the interface instance back to its generic form: IBeing<Human> backtogeneric1 = (IBeing<Human>) being1Human; will work.
And, a typical pattern is to have a 'switch statement that hard codes the conversion for each interface instancee Type.
But, consider: hard-coded conversion requires design-time "world knowledge" of each Type.
What is desired is a run-time conversion method that uses the Type stored in the interface instance to get the generic interface instance with it "payload" of other data.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
modified 24-Apr-20 10:50am.
|
|
|
|
|
If I understand the goal correctly (which maybe I don't), then it is inherently impossible, because even if you arranged to get an element casted to the right type, there is no way to represent the result. Any single type (this excludes dynamic because it is not a "single type") that you choose for a method that performs that conversion would be the wrong type - the only things that works are "useless types" (non-generic IBeing and object ). If you already knew the resulting type then you could do it, but then we're back to requiring that knowledge to be built in statically which you didn't want.
|
|
|
|
|
Hi Harold,
I embed an instance of the generic Type in the newly created interface instance. At run-time, I can pull that reference out: given I know the current interface instance type, and the destination generic type ... you'd think you could "rehydrate" (convert) without reflection, use of reflection, 'dynamic, etc.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
The problem is that you don't know at compile-time what the run-time type of the instance will be.
As Harold said, there isn't a compile-time type you can use which would give you access to the properties or methods of the run-time type.
Consider:
public abstract class Being
{
public string Name { get; set; }
}
public class Dog : Being
{
public void Bark() { ... }
}
public class Human : Being
{
public void ComposeMusic() { ... }
}
List<Being> beings = LoadBeings();
Being aBeing = beings[0];
Type beingType = aBeing.GetType();
{ What could possibly go here? } myBeing = BeingAsType(aBeing, beingType);
myBeing.{ Which method could you call here? }();
Perhaps the visitor pattern might help you?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|