|
You cannot create a List<File> because the File Class (System.IO)[^] contains only static methods, you cannot instantiate a File object. But you could create a list of filenames that you wish to use. As to deserialising multiple XML files, there is no good reason why it would not work.
|
|
|
|
|
Thanks, but any idea of how could I create that list?
|
|
|
|
|
|
PS: Mi code is the same code of the video
|
|
|
|
|
I also have this question posted on Unity as well, but I figured that branching out for answers wouldn't be a bad thing.
Unity is primarily a Game Engine, but I am using it to make a non-game app. What I essentially need to have happen is that I take in a email, parse it- pick and choose what I need out of it, then send and display another email as well as display graphically that edited version.
As of right now, I am using EAGetMail library to try and keep track of the messages and then I am hoping I can access them while the "game" (application) is running. I know that Unity has a way of sending out emails obviously, as developers want to send out surveys and vital information, but as far as receiving those emails during game runtime, that seems like a big stretch and there is probably an easier way to do this.
If you have any information that would be helpful! Looking for ideas and concepts and maybe a little example code.
|
|
|
|
|
Things will make a lot more sense if you first create a console or windows app to "test" the "email logic".
It shouldn't be that hard to integrate "emails" into Unity; the fact that you are asking the question means:
1) You do not understand Unity "scripts"
2) You do not know how to "partition / package" code properly
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
0
down vote
favorite
I need to write a code in script component in SSIS that will move files to corresponding folders. Files that I'm getting are usually named, for example "Dem323_04265.45.23.4", "Dem65_459.452.56", "Ec2345_456.156.7894" and I need to move them to a corresponding folders. The name of my folders are "Oklahoma City (323)", "New York(65)".. I need to move those files to matching folders, so for example "Dem323_04265.45.23.4" would go to folder "Oklahoma City (323)". I need to modify my code so the number that is located between first two or three letter and underline matches number located in parenthesis. I've been working on this for several days already and I'm new with ssis and c#, so any help would be appreciated. This is the code I have so far:
public void Main()
{
string filename;
// string datepart;
bool FolderExistFlg;
filename = Dts.Variables["User::FileName"].Value.ToString();
// datepart = (filename.Substring(filename.Length - 12)).Substring(0, 8);
var folderNumber = Regex.Match(
filename,
//Dts.Variables["OutputMainFolder"].Value.ToString(),
@"\(([^)]*)\)").Groups[1].Value;
FolderExistFlg = Directory.Exists(Dts.Variables["OutputMainFolder"].Value.ToString() + "\\" + folderNumber);
if (!FolderExistFlg)
{
Directory.CreateDirectory(Dts.Variables["OutputMainFolder"].Value.ToString() + "\\" + folderNumber);
}
File.Move(Dts.Variables["SourceFolder"].Value.ToString() + "\\" + filename + "\\" + folderNumber,
Dts.Variables["OutputMainFolder"].Value.ToString() + "\\" + filename);
Dts.TaskResult = (int)ScriptResults.Success;
}
#region ScriptResults declaration
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
}
}
|
|
|
|
|
Most of us here can't read your mind: is your code not compiling, or crashing: what are the error messages, and where do they occur ?
If it's not crashing, set breakpoints, and examine the state of inputs, outputs, and variables: describe the places where "state" is not what you expect it to be.
Details, details, details.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
So what exact error you are facing on this code? You can debug and share that specific information
modified 20-Sep-20 21:01pm.
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using HtmlAgilityPack;
using System.Net;
using System.IO;
namespace DocumentosSubsidios.Infrastructure.RobotBase
{
public abstract class BaseRoboAddress
{
public enum EncodingEnum
{
Default,
UTF8,
ASCII,
ISO_8859_1,
ANSICodePage
}
public BaseRoboAddress() { }
public BaseRoboBaseRoboAddress(WebClientSession webClientSession)
{
this._webClientSession = webClientSession;
}
public delegate void MyMethodInvoker<T>(T t);
public event MyMethodInvoker<string> ResultRequest;
#region [Membros Privados]
private CredentialCache _credentialCache;
private WebClientSession _webClientSession;
private CookieCollection _cookies = null;
private HtmlNodeCollection _inputs = null;
#endregion
#region [Propriedades]
public WebClientSession WebClientSession
{
get
{
if (_webClientSession == null) _webClientSession = new WebClientSession();
return _webClientSession;
}
set
{
_webClientSession = value;
}
}
private CredentialCache mCredentialCache
{
get
{
if (_credentialCache == null) _credentialCache = new CredentialCache();
return _credentialCache;
}
set
{
_credentialCache = value;
}
}
public CookieCollection Cookies
{
get
{
if (_cookies == null)
_cookies = new CookieCollection();
return _cookies;
}
set { _cookies = value; }
}
public HtmlNodeCollection Inputs
{
get
{
if (_inputs == null)
_inputs = new HtmlNodeCollection(null);
return _inputs;
}
set { _inputs = value; }
}
#endregion
#region [Métodos Publicos]
public virtual HtmlDocument Get(string url)
{
return this.Get(url, false, EncodingEnum.UTF8);
}
public HtmlDocument Get(string url, EncodingEnum encoding)
{
return this.Get(url, false, encoding);
}
public HtmlDocument Get(string url, bool fire, EncodingEnum encoding)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
byte[] pagina = this.WebClientSession.DownloadData(url);
switch (encoding)
{
case EncodingEnum.UTF8:
htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ASCII:
htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.Default:
htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ISO_8859_1:
htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
break;
}
return htmlDocument;
}
public HtmlDocument Post(string url, NameValueCollection parametros, bool fire)
{
return this.Post(url, parametros, fire, EncodingEnum.UTF8);
}
public HtmlDocument Post(string url, NameValueCollection parametros, EncodingEnum encoding)
{
return this.Post(url, parametros, true, encoding);
}
public HtmlDocument Post(string url, NameValueCollection parametros)
{
return this.Post(url, parametros, true);
}
public HtmlDocument Post(string url, NameValueCollection parametros, bool fire, EncodingEnum encoding)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
byte[] pagina = this.WebClientSession.UploadValues(url, parametros);
switch (encoding)
{
case EncodingEnum.Default:
htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.UTF8:
htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ASCII:
htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ISO_8859_1:
htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
break;
}
return htmlDocument;
}
public byte[] PostBinario(string url, NameValueCollection parametros)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
return this.WebClientSession.UploadValues(url, parametros);
}
public HtmlDocument PostData(string url, IEnumerable<byte> IBody, bool fire)
{
lock (this)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
byte[] pagina = this.WebClientSession.UploadData(url, "POST", IBody.ToArray());
htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
return htmlDocument;
}
}
public HtmlDocument PostData(string url, IEnumerable<byte> IBody)
{
return this.PostData(url, IBody, true);
}
public HtmlDocument PostData(string url, IEnumerable<byte> IBody, EncodingEnum encoding)
{
lock (this)
{
byte[] pagina = this.WebClientSession.UploadData(url, "POST", IBody.ToArray());
HtmlDocument htmlDocument = LoadHtmlDocument(encoding, pagina);
return htmlDocument;
}
}
private HtmlDocument LoadHtmlDocument(EncodingEnum encoding, byte[] pagina)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
switch (encoding)
{
case EncodingEnum.Default:
htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.UTF8:
htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ASCII:
htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ISO_8859_1:
htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
break;
}
return htmlDocument;
}
|
|
|
|
|
Correct. It won't.
Now, what would you like us to do about it?
If you have compiler errors, tell us what they are. It makes our lives a whole load easier...
You are missing a #endregion directive, and two close curly brackets, and your parameterized constructor is misspelt:
public BaseRoboBaseRoboAddress(WebClientSession webClientSession)
{
this._webClientSession = webClientSession;
}
Just reading the error messages would have told you that - and fixing them is trivial.
public BaseRoboAddress(WebClientSession webClientSession)
{
this._webClientSession = webClientSession;
}
Sent from my Amstrad PC 1640
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks for the help. The problem was even in the constructor
|
|
|
|
|
You're welcome!
Sent from my Amstrad PC 1640
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Nice! "Getters" that update properties ...
Why didn't I think of that.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thanks for the help. The problem was even in the constructor
|
|
|
|
|
Hi all..
I am working on a project in c#.net for the customer administration in the company where I work. The administration asked me to add a feature for the project which allows for the user of the system (my C#.net project) to connect to the customers by clicking their numbers shown on a list on a window and then the Android phone of the user responses automatically for clicking and do a call to the customer who has the clicked number.. In other words, how to make my c#.net project dials customers' numbers by using android phone's SIM card (GSM or CDMA). I don't know how I start. I have already tried to search in the internet, but I found so rare and insufficient information about this topic.. So, I need to know all requirements and all details in order for this feature works. So I really need a help for this issue. Thanks in advance.
|
|
|
|
|
|
Hi, OriginalGriff
Thank you so much for helping, I will study your suggestions carefully.. thanks again
|
|
|
|
|
You're welcome!
Sent from my Amstrad PC 1640
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Let me see if I have this straight. The code will run on the phone (so I am assuming you are writing this using Xamarin) and you want to dial someone else's phone. Is this correct?
This space for rent
|
|
|
|
|
Hi, Pete O'Hanlon
Thank you so much for your reply.. The code will be run on laptops not on phones, so when a user works on a laptop, which the project will be installed on, and the customers' window will be appearing which has a list of customers' phone numbers, then just by clicking any phone number from the list, the user's android phone directly calls the number which has been clicked on the list.. I hope the idea got clearer, thank you..
|
|
|
|
|
Who is the user, and who is the customer? And how does the laptop send the dial commands to the Android phone?
|
|
|
|
|
Richard MacCutchan wrote: how does the laptop send the dial commands to the Android phone?
That's probably what he's asking!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Yes, but not actually thought about it.
|
|
|
|
|
This isn't a trivial thing to do and is going to require the Android phone being set up to act as a mobile hotspot. Once it is available as a hotspot, the PC is going to have to connect to it and establish a Peer to Peer connection as a background service (the Android samples demonstrate how to find the IP address). Once the connection is established, you're going to send messages from the PC to the phone over this service telling it to make the call (you're going to have to use an Intent here - Google it). To be honest, unless you use Xamarin on the phone, the vast majority of what you are going to do here is going to be Java and you're going to have to get very comfortable with the Android SDK.
This space for rent
|
|
|
|
|