|
I have a method that creates this value:
0x0001000000FFFFFFFF01000000000000000601000000036162630B
It is stored in the DB as <Binary Data>.
I use Select value from table where id = 1234.
This is the code that writes creates the value:
public void SetSessionData(string token, object data)
{
DataService ds = null;
try
{
ds = new DataService();
using (MemoryStream stream = new MemoryStream())
{
DALArgs args = new DALArgs();
ds.SetRealmConnection(_realm);
Args.Add("sessionkey", _sessionkey);
args.Add("sessiontoken", token);
BinaryFormatter b = new BinaryFormatter();
b.Serialize(stream, data);
stream.Position = 0;
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
args.Add("sessionvalue", buffer);
ds.Execute("olb_SetSessionData", args);</pre>
I'm trying to figure out how I can assign the results of the select statement to a variable and create this response:
0
1
0
0
0
255
255
255
255
1
0
0
0
0
0
0
0
6
1
0
0
0
3
97
98
99
That array comes from this:
if (reader.Read())
{
byte[] data = (byte[])reader["SessionValue"];
I hope that is enough information, and that it can be done.
Any help is appreciated.
|
|
|
|
|
In a C# 2008 application, the code listed below ends up in the catch exception block. The error message says the file can not be
located in the specified location: "C://temp//09-24-2012//companyname_company.xlsx".
The value for the String fileName in the createCust is obtained from the value passed
to this method. The file does exist on the specified location.
The code I am referring to is listed below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common.Logging;
using System.IO;
namespace sample1
{
public class Helper1
{
private static ILog log = LogManager.GetCurrentClassLogger();
public Customer createCust(String CustId, String fileName)
{
Customer cst = new Customer();
byte[] buffer = null;
try
{
System.IO.FileStream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(fileStream);
long totalBytes = new System.IO.FileInfo(fileName).Length;
buffer = binaryReader.ReadBytes((Int32)totalBytes);
DateTime attachmentId = DateTime.Now;
cst.Id = attachmentId.ToString();
cst.MimeType = getMimeType(fileName);
cst.Value = buffer;
fileStream.Close();
binaryReader.Close();
}
catch (Exception e)
{
throw new Exception(e.Message);
}
return cust;
}
}}
I do not have any idea of why the file can not be located. The file exists in the path
that is passed to the createCust method. The location of the file path is specified as,
"C://temp//09-24-2012//companyname_company.xlsx".
Thus can you tell me what could be causing the file not to be located and how to fix the problem?
|
|
|
|
|
Maybe a permissions or a UAC issue - can you access this file directly?
|
|
|
|
|
You are using double forward slashes in C://temp//09-24-2012//companyname_company.xlsx , which is not a valid path in Windows. It should be C:\\temp\\09-24-2012\\companyname_company.xlsx .
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
True for the Windows API but not for the .NET System.IO classes which will accept either flavour of path separator. The redundant 'escaping' in the forward slashed path string is also gracefully ignored.
Alan.
|
|
|
|
|
Thanks, I was not aware of that.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
rachel_m wrote: that is passed to the createCust method
How do you know that? The code doesn't print the value.
rachel_m wrote: throw new Exception(e.Message);
You are throwing information away with that. There could be other information in the stack trace. There could be information in the type of exception.
|
|
|
|
|
I'm currently doing Automated Acceptance test driven development, and I'm wondering if I should use my real Data Access Layer in my tests, or if I should fake out the data instead and just verify that what is being passed to/from is correct.
One issue is that the DAL is being developed by another team, and i'm coding the front end/business logic. I could make it work so I could test the real thing, but i'm not sure.
|
|
|
|
|
I test my DAL because otherwise how do I know it was tested?
However given that someone else is creating yours you could treat it as ready to go external service. That depends on how much you trust it.
|
|
|
|
|
Member 8674492 wrote: I'm wondering if I should use my real Data Access Layer in my tests
Yes, you should
|
|
|
|
|
For acceptance testing? Yes. That should be as close to the actual production environment as possible – if you can do it, it should actually be on the production environment.
However, you should of course also have automated unit and isolated integration tests that use a mocked out DAL which you run as a matter of course during development.
|
|
|
|
|
Most decent mocking toolkits will allow you to simulate return values from code, so you could call your DAL code and set it up to ignore certain calls and then return you carefully crafted data to satisfy your test criteria.
|
|
|
|
|
Please help me to do a program that can download a file from a ftpserver with a progress bar that computes the percentage of the downloaded data. But it is by using the asynchronous method that was written from the codefile.cs and that will be called on th form.cs.The progress bar is in the other form.t.y
|
|
|
|
|
Perhaps you and this guy[^] could get together. I find it suspicious that you both have the same requirements.
As your account is new, it could be that you are unaware of the way the forums operate. We help you solve issues that you have with code that you've written - we don't write it for you.
|
|
|
|
|
Member 9454563 wrote: Please help me to do a program
I only do humans.
Member 9454563 wrote: that can download a file from a ftpserver with a progress bar that computes the percentage of the downloaded data. But it is by using the asynchronous method that was written from the codefile.cs and that will be called on th form.cs.The progress bar is in the other form
What do you need help with exactly? Finding the manual? Well, here[^] it is, and even contains samples. Anything else you need help with?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Guys I need your help! Please help me to make Asynchronous method of uploading and downloading FTP with progress bar in C#.
|
|
|
|
|
rikah wrote: Please help me to make Asynchronous method of uploading and downloading FTP with progress bar in C#.
Asynchrone methods calls? Take a look here[^]
I would do it as a thread[^] and use delegates [^]to update the progress bar.
------------------------------
Author of Primary ROleplaying SysTem
How do I take my coffee? Black as midnight on a moonless night.
War doesn't determine who's right. War determines who's left.
|
|
|
|
|
We'll be happy to help. First, please let us know what you've tried and where you're having problems.
/ravi
|
|
|
|
|
On the windows form, we put listbox for the list of directories. A button to get the list of directories and display it on the listbox. Another button for downloading, and another button for uploading. We just need Asynchronous method when downloading or uploading a file or getting the list of directories.
|
|
|
|
|
Hi
I have a small project that would require me to convert a ASP Classic with 5000+ lines of code to ASP .NET C# is there such a tool that can do this for me? I've already research for the whole week but all the tools that I've tried didn't work. should I do a rewrite for the whole thing?
Thanks in advance.
|
|
|
|
|
I don't believe there is any tool that can do a full conversion for you.
There are a few that can help you convert parts of the program but honestly, you will have to do a large amount of conversion on your own.
|
|
|
|
|
Since ASP and ASP.NET are so vastly different, there is no conversion tool to go between the to. You have to rewrite this by hand.
|
|
|
|
|
I think the closest model to use is the Razor Web pages. If you try to use web forms or MVC, the change will be too much. Read about Razor web pages to learn about it.
|
|
|
|
|
Hi Guys,
I have a program that reads stuff from a Searial COM port. It uses one of those USB to COM port gizmos (Prolific driver).
The environment is Win7/Server 2008R2 (all 64 bit), joined to domain, .NET4.
The program works fine when run from within context of an end user.
However, when i try to run the same program as a windows service I get 'The system cannot find the file specified'. I tried to configure the service to run both as a local system account and as a domain service account (added to the admin ug), but still the same error.
I also created a little test program (see the code at the end of the post, it is stolen from somewhere on the internet).
This runs fine when run from the console and opens the port and reports its type (CHAR), but fails with the same error (File not found) when i try to run it as a scheduled job.
Again i tried running it both under my own account and under account of a service (both added as local admins) and it is the same error.
I am pretty sure it is some sort of a security/policy issue but cannot quite figure out what.
Any pointers will be greatly appreciated,
Alexei
static void Main(string[] args)
{
var portName = @"\\.\COM3";
var handle = CreateFile(portName, 0, 0, IntPtr.Zero, 3, 0x80, IntPtr.Zero);
if (handle == (IntPtr)(-1))
{
Console.WriteLine("Could not open " + portName + ": "
+ new Win32Exception().Message);
return;
}
var type = GetFileType(handle);
Console.WriteLine("File " + portName + " reports its type as: " + type);
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall,
SetLastError = true)]
public static extern IntPtr CreateFile(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr SecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile);
[DllImport("kernel32.dll")]
static extern FileType GetFileType(IntPtr hFile);
enum FileType : uint
{
UNKNOWN = 0x0000,
DISK = 0x0001,
CHAR = 0x0002,
PIPE = 0x0003,
REMOTE = 0x8000,
}
|
|
|
|
|
Did you try configuring your service to run as a network account?
Why are you using CreateFile anyway? Can't you just open Com3 using the serial port class?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|