|
Please don't post the same thing in multiple places: it duplicates work and annoys people.
You already have this posted in QA, leave it there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
ok, sorry. Wasnmy first question
|
|
|
|
|
I'm making an application that produce barcode labels. I'm using Sato LM408e thermal printer. In order to print i'm using sbpl command. I got no error but the printer doesnt print anything. Is there anyone who has experience printing with sato barcode printer? lm 408e to be more specific
My Code:
PrintDialog printDia = new PrintDialog();
printDia.PrinterSettings = new PrinterSettings();
DialogResult result = printDia.ShowDialog();
StringBuilder sb = new StringBuilder();
sb.AppendLine("<STX><ESC>A");
sb.AppendLine("<ESC>H0001<ESC>V0001<ESC>XM45676567");
sb.AppendLine("<ESC>Q1");
sb.AppendLine("<ESC>Z<ETX>")
String output = sb.ToString().Replace("<ESC>", ((char)27).ToString());
output.Replace("<STX>",((char)2).ToString());
output.Replace("<ETX>", ((char)3).ToString());
if (result == DialogResult.OK)
{
RawPrinterHelper.SendStringToPrinter(printDia.PrinterSettings.PrinterName, output);
}
and my output value :
http://imgur.com/hVCk2ic[^]
|
|
|
|
|
You should talk to the people who created the printer - they should provide technical support and will know more about their product than we will. If they don't, then find another supplier and demand your money back!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hello guys,
I'm having a problem and, although I understand the problem, I can't find a solution to the problem.
I'm using NamedPipes and I have created this method to Serialise on object T to a byte[].
private byte[] Serialize(T obj)
{
using (var memoryStream = new MemoryStream())
{
oBinaryFormatter.Serialize(memoryStream, obj);
return memoryStream.ToArray();
}
}
I have a test that sends a object with 300Mb and the Serialization fails with a OutOfmemory.
oBinaryFormatter.Serialize(memoryStream, 300MbObject);
I understand that the problem is related to memory. Can you guys suggest another solution for this problem?
Thanks Guys
|
|
|
|
|
Don't use the BinaryFormatter for anything that size. I would recommend either using protobuf.net[^] or manual serializing: BinaryFormatter vs. Manual Serializing[^]. Both will be faster and more compact.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Since Google Code is shutting down, you may want to direct people to the correct homepage of protobuf.net[^] on Github.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Right - forgot about that. Thank you for the heads-up.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
A typical object is not 300Mb; that already counts as a rather large transfer of data. Do you need to have it completely in memory? If it represents "data", would it not be more logical to stream the data straight to file, as opposed to creating a very large object in memory?
The memory manager really does not like large objects. I'd recommend to cut your block into ten chuncks. If you have to stream it to a memorystream, then at least allocate it once and with the correct size - otherwise it may need be reallocated and cause fragmentation.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thx guys for your replys.
I went with the solution of cutting the objects into chuncks
|
|
|
|
|
You're welcome
|
|
|
|
|
I used SMTP class for sending mail but I have problem regarding sending a mail.
when we start anti-virus then i got a error Failure sending mail but when we disable the anti-virus then SMTP work properly.
Please help what we do when anti- virus still enable.
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Please, edit your question and provide better information.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Check your anti-virus settings.
|
|
|
|
|
It looks like your anti-virus's firewall is blocking the SMTP communications. Try to allow (inbound/outbound) connections by configuring the anti-virus's firewall on port 25 (default SMTP port) or any other port number that you are using. Also, you can check the default port numbers that you can enable for SMTP in the link below:
http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol[^]
See your antivirus documentation. It will tell you where to find the settings to achieve this.
modified 11-Jun-15 12:41pm.
|
|
|
|
|
In controller i wrote like this
------------------------------------------
public dynamic multipleimageupload(string image)
{
var aa = image.Split('\\');
var finalPath = aa[2];
var img = WebImage.GetImageFromRequest();
if (finalPath != null)
{
var fileName = finalPath.Replace(" ", "");
var fname = Path.GetFileNameWithoutExtension(fileName);
Regex regex = new Regex("[^a-zA-Z0-9]");
fname = regex.Replace(fname, "");
var fileExtension = Path.GetExtension(fileName);
string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
var filenamewithtime = fname + "_" + timestamp + fileExtension;
var path = Path.Combine(Server.MapPath("~/Images/Imageupload"), filenamewithtime);
img.Save(path);
var finel = String.Format("/Images/Imageupload/{0}", filenamewithtime);
var userClient = new RestClient(string.Format("{0}/api/UserAccount/POSTImageUpload", MatchedInConfig.MatchedInApiUrl));
var request = new RestRequest(Method.POST);
var sessionResult = Session["UserID"];
request.AddParameter("UserID", sessionResult);
request.AddParameter("Avatar", finel);
var response = userClient.Execute(request);
return null;
}
return null;
}
-------------------------------------
in Api i wrote like this
----------------------------
public MI_PhotoAlbum POSTImageUpload(FacebookRegistrationModel model)
{
var userTable = new MI_PhotoAlbum();
().Query().Get().Where(a => a.UserId == model.UserID).SingleOrDefault();
userTable.UserId = model.UserID;
userTable.ImageUrl = model.Avatar;
_unitOfWork.Repository<MI_PhotoAlbum>().Insert(userTable);
_unitOfWork.Save();
return userTable;
}
--------------------------
in partialview
---------------------
<div class="photo-upload-bar">
<i class="fa fa-image"></i>Photos<div class="btn btn-primary btn-xs pull-right btn-upload" >Upload <i class="fa fa-plus"></i>
<input id="choose" type='file' name="fileUpload" onchange="readfile(this);" accept="image/x-png, image/gif, image/jpeg" /></div>
@* <label class="control-label col-md-2">Image</label>*@
<div class="col-md-10">
<img id="image_preview" src="~/Areas/Admin/Images/NoImage/NO_IMAGE.jpg" alt="your image" width="100" height="100" />
<input id="RemoveBtnID" style="display: none" type="button" value="Remove" onclick="Removefun()" />
@*<input id="choose" type='file' name="fileUpload" onchange="readfile(this);" accept="image/x-png, image/gif, image/jpeg" />*@
<span id="para" style="color: red"></span>
<span id="SpanImageId" style="color: red;"></span>
<br />
<span id="SpanimageId" style="color: red;"></span>
</div>
<script type="text/javascript">
jQuery(document).ready(function () {
ComponentsEditors.init();
});
var url = window.URL || window.webkitURL;
$('#choose').change(function () {
alert("hii");
var newInterests = $("#choose").val();
if (newInterests != "") {
$.ajax({
url: "../account/multipleimageupload/?image=" + newInterests,
type: "Post",
contentType: 'application/json; charset=utf-8',
success: function (data) {
if (data != 0) {
}
else {
}
},
error: function () { }
});
}
else {
}
var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp'];
if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {
document.getElementById('para').innerHTML = "<span>Choose Only Image Files</span>";
Removefun();
document.getElementById('Upload').innerHTML = "<span></span>";
$('#choose').val('');
$('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE_Thumb.jpg");
return false;
}
else {
$("#SpanimageId").text("");
document.getElementById('para').innerHTML = "<span></span>";
document.getElementById('Upload').innerHTML = "<span></span>";
}
});
function readfile(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#image_preview').attr('src', e.target.result);
var imagesize = input.files[0].size / 2048;
var ImageSize = imagesize / 2048;
if (ImageSize > 2) {
alert("Image size should be less than 2MB");
$('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE_Thumb.jpg");
$('#RemoveBtnID').hide();
$('#choose').show();
return false;
}
else {
$('#RemoveBtnID').show();
$("#SpanimageId").text("");
}
}
reader.readAsDataURL(input.files[0]);
}
}
function Removefun() {
$('#image_preview').attr('src', "/Areas/Admin/Images/NoImage/NO_IMAGE.jpg");
$('#RemoveBtnID').hide();
$('#choose').show();
}
</script>
|
|
|
|
|
Given that you want some javascript then the javascript forum[^] might be a more appropriate location for this question!
|
|
|
|
|
SOLUTION
make sure to refresh the folder your checking to see if the files have actually deleted or not.
In this case they were (the code works fine), just i wasn't refreshing desktop etc haha, oh well.
STUPID QUESTION CONTINUES-------------
http://s000.tinyupload.com/index.php?file_id=06162948769787766673[^]
The link above is a localized example of my problem.
I cannot for the life of me figure out why file.exists or any kind of permission checks don't work!
Its like .NET just says oh.. I might delete this, might not, might say i did but actually didn't, or didn't but actually.. didn't, maybe i will if you give me time... but i still wont tell you even if i did or didn't...
so... please save the last few strands of hair on my head!
Thanks!
(For ease of viewing: pastebin)
or right here:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using IWshRuntimeLibrary;
namespace test
{
public partial class TestFileDelete : Form
{
Boolean flag = true;
public TestFileDelete()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.button1.Enabled = false;
if (this.button1.Enabled == false) return;
int switchnum = (flag) ? 1 : 0;
int newnum = (flag) ? 0 : 1;
if (flag == true)
{
flag = false;
}
else
{
flag = true;
}
String StartMenuProgName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu), "Programs", "skbt config", "config " + newnum);
Dictionary<UInt32, String> Shortcuts = new Dictionary<uint, string>() {
{0,Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Start Keepalive (" + "config " + newnum + ").lnk")},
{1,Path.Combine(StartMenuProgName, "Start Keepalive.lnk")},
{2,Path.Combine(StartMenuProgName, "Auto Restart Test.lnk")},
{3,Path.Combine(StartMenuProgName, "Manual Restart.lnk")},
{4,Path.Combine(StartMenuProgName, "Manual Start.lnk")},
{5,Path.Combine(StartMenuProgName, "Manual Stop.lnk")},
{6,Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "README.txt")}
};
foreach (KeyValuePair<UInt32, String> shortcut in Shortcuts)
{
while (System.IO.File.Exists(Path.GetFullPath(shortcut.Value.ToString())))
{
if (this.checkBox1.Checked == true)
{
Thread.Sleep(300);
}
System.IO.File.Delete(Path.GetFullPath(shortcut.Value.ToString()));
}
}
if (Directory.Exists(StartMenuProgName)) { Directory.Delete(StartMenuProgName, true); }
StartMenuProgName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu), "Programs", "skbt config", "config " + switchnum);
String BatchLibPath = @"c:\test";
if (!addShortcut(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Start Keepalive (" + "config " + switchnum + ").lnk"),
Path.Combine(BatchLibPath, "start_keepalive.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (0).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Start Keepalive.lnk"),
Path.Combine(BatchLibPath, "start_keepalive.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (1).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Auto Restart Test.lnk"),
Path.Combine(BatchLibPath, "control", "auto_restart.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (2).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Manual Restart.lnk"),
Path.Combine(BatchLibPath, "control", "manual_restart.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (3).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Manual Start.lnk"),
Path.Combine(BatchLibPath, "control", "manual_start.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (4).");
}
if (!addShortcut(
Path.Combine(StartMenuProgName, "Manual Stop.lnk"),
Path.Combine(BatchLibPath, "control", "manual_stop.bat")))
{
MessageBox.Show("There was an error creating a shortcut in the Start Menu (5).");
}
this.button1.Enabled = true;
}
private static Boolean addShortcut(String ShortcutPath, String TargetPath)
{
try
{
WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(ShortcutPath);
link.TargetPath = TargetPath;
if (!Directory.Exists(Path.GetDirectoryName(ShortcutPath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(ShortcutPath));
}
link.Save();
return true;
}
catch
{
return false;
}
}
protected virtual bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException)
{
return true;
}
finally
{
if (stream != null)
stream.Close();
}
return false;
}
}
}
modified 9-Jun-15 23:59pm.
|
|
|
|
|
public partial class Form3 : Form
{
private OleDbConnection connection = new OleDbConnection();
public Form3()
{
InitializeComponent();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Certificates-track\certificates-track.accdb;Persist Security Info=False;";
private void button1_Click(object sender, EventArgs e)
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query="Select * from StudentData where Regdno='" + Regdno_txt.Text + "';";
command.CommandText = query;
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Name_txt.Text = reader["Name"].ToString();
Program_txt.Text = reader["Program"].ToString();
Branch_txt.Text = reader["Branch"].ToString();
}
connection.Close();
}
|
|
|
|
|
Your code is vulnerable to SQL Injection[^].
NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
using (OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Certificates-track\certificates-track.accdb;Persist Security Info=False;"))
using (OleDbCommand command = new OleDbCommand("Select Name, Program, Branch from StudentData where Regdno = ?", connection))
{
command.Parameters.AddWithValue("Regdno", Regdno_txt.Text);
connection.Open();
using (OleDbDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
{
while (reader.Read())
{
Name_txt.Text = Convert.ToString(reader["Name"]);
Program_txt.Text = Convert.ToString(reader["Program"]);
Branch_txt.Text = Convert.ToString(reader["Branch"]);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
I'm trying to use the DynamicExpression class to parse a string and get an expression tree.
This works fine for simple cases, but when the input string contains a Select() command, this gives me the error "No applicable aggregate method 'Select' exists".
For example, let's say I want to build the expression tree below:
x => x.MyCollection.Select(y => y.SomeInt)
If I pass the string "x.MyCollection.Select(SomeInt)" to the ParseLambda method, I get the error mentioned above.
Does anyone know to get around this or give me an alternative to transform a string to a lamba expression?
Thanks in advance.
|
|
|
|
|
HUONG Minh-Luong wrote:
x => x.MyCollection.Select(y => y.SomeInt)
...
"x.MyCollection.Select(SomeInt)"
Why are you passing a string which doesn't match your lambda expression?
Did you try using the string "x => x.MyCollection.Select(y => y.SomeInt)" instead?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 9-Jun-15 13:47pm.
|
|
|
|
|
It doesn't work either. It says that y is not a property of MyCollection type.
This string works "x.MyCollection.Any(SomeInt==1)", so I figured that Select should work the same way.
|
|
|
|
|
I have a DataGrid that displays information about trailers. I decided to change the location column to a DropDownList so the location can be easily changed. But I am not sure how to populate the DropDownList.
<asp:DataGrid runat="server" CssClass="tblResults" OnItemDataBound="dgList_ItemCreated" OnRowDataBound="OnRowDataBound" AllowSorting="true" OnSortCommand="dgTrailer_Sort" ID="dgTrailers" DataKeyField="ID" AutoGenerateColumns="false">
<Columns>
<asp:BoundColumn DataField="TrailerOwner" HeaderText="Owner" SortExpression="TrailerOwner"></asp:BoundColumn>
<asp:BoundColumn DataField="TrailerMake" HeaderText="Trailer Make" SortExpression="TrailerMake"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Trailer Location">
<itemtemplate>
<asp:DropDownList ID="ddlLocation" runat="server">
</asp:DropDownList>
</itemtemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
I have a DropDownList for location already (called ddlTrailerLocation) so the user can select the location for the trailer and then the DataGrid displays all that information. Here's how I populated ddlTrailerLocation:
protected void PopulateDDLs()
{
DataSet dsTrailerLocation = DataUtils.GetAllGenSmall(Company.Current.CompanyID, "Description", "", 1, false, "Description", false, "TrailerLocationNOCODE", 0);
if (dsTrailerLocation.Tables[0].Rows.Count > 0)
{
ddlTrailerLocation.DataSource = dsTrailerLocation;
ddlTrailerLocation.DataValueField = "Description";
ddlTrailerLocation.DataTextField = "Description";
ddlTrailerLocation.DataBind();
ddlTrailerLocation.Items.Insert(0, new ListItem("Select One", "0"));
}
else
{
ddlTrailerLocation.Items.Insert(0, new ListItem("No Locations Entered", "0"));
}
}
Is there something I can add to this method to display the correct location of each trailer in the DataGrid? The location column was displaying the location but is now just showing an empty DropDownList
|
|
|
|
|
If you have DropDownList control nested in your DataGridView, the best place to populate contents is RowDataBound event. It will populate dropdownlist control based on current row data.
Try something like below to find dropdownlist control in your current row and then bind the data.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var dropDownList = e.Row.FindControl("ddlLocation") as DropDownList;
}
}
modified 20-Sep-20 21:01pm.
|
|
|
|
|