|
kruegs35 wrote: that does not return any key column information
It's even telling you what the problem is. Include the primary key in your select statement.
|
|
|
|
|
I am using SqlBulkCopy to get what I need now.
|
|
|
|
|
how can add crystal report with web application with asp.net,C# with the help of procedure
|
|
|
|
|
There[^] you go. The 4th link looks particularly promising.
|
|
|
|
|
Agree with Pete. You should have searched Google before asking here.
Anyway check my past answer
Crystal report with Stored procedure[^]
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
HI,
I have a problem. I put my code which i want to do below. I have a website which is in Share point. I need to active a email alert but not using Share point. I want to create a server scheduler and this application will get information from my website about the task lists. if some tasks deadline is near then my scheduler will send email to the specific user. This console application will help me to get list items from my share point website. I also want to fetch List guids from share point web application. In short i can say i need to fetch all list items and want to store them in the form of array. Later on i will use this information and will put a flag to check if the due date is close. If the due date is coming soon then i will send an automatic email to that specific user. If you see my code which i share in my post you will find some information about this. Please let me know if you need further information.
If there is some other way to active automatic email but without using share point workflow or alert. Because share point alert are always needed to be closed manually every time if we put some schedule on them. So please anyone who has a solution please let me know..
Thanks in Advance for your help
namespace Email
{
class Program
{
static string siteUrl = "";
static void Main(string[] args)
{
try
{
using (SPSite testSite = new SPSite(siteUrl))
{
Console.WriteLine("site url: " + testSite.Url);
using (SPWeb ourWeb = testSite.OpenWeb(new Guid("e94c0a67-7408-4413-a4d2-4f26275008ac")))
{
SPList ourList = ourWeb.Lists[new Guid("DEB874E1-8BE7-4AD5-A507-EE6C8DF27FDC")];
foreach (SPListItem ourItem in ourList.Items)
{
if (checkForRemind(ourItem))
Console.WriteLine("Remind!");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("OOps: " + ex.Message);
}
}
static bool checkForRemind(SPListItem ourItem)
{
bool remindIsSet = false;
foreach (SPField ourField in ourItem.Fields)
{
Console.WriteLine("Field name: " + ourField.StaticName);
}
return remindIsSet;
}
}
}
|
|
|
|
|
Hi everyone. I'm trying to draw text of string on a panel control outside the Paint event but surprisingly, nothing is being drawn. I actually cannot figure out what is wrong with my code. I decided to create a small application to test that and again nothing is being drawn. The small code I wrote to test it is shown below:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DrawText();
}
private void DrawText()
{
Graphics grfx = panel.CreateGraphics();
grfx.DrawString("Problem drawing text on Panel", panel.Font, Brushes.Black, 50, 50);
grfx.Dispose();
}
}
}
The variable 'panel' is an object of Panel which has been placed on the form with a Dock property 'Fill'. After compiling the text is not drawn. I don't know what I am doing wrong. Please help.
|
|
|
|
|
The most obvious thing here is that your form hasn't actually finished loading yet, and you are attempting to draw the text once and once only (before the form is actually rendered). What you need to do is draw the string in the Paint event handler.
As you are drawing this in a panel, you would hook into the paint event handler on the panel like this:
private void panel_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawString("Problem drawing text on panel", panel.Font, Brushes.Black, 50, 50);
}
modified 15-Feb-12 7:21am.
|
|
|
|
|
Thanks Hanlon! Looks like I cannot avoid Paint handling for the Panel control for it to work. I will try that.
|
|
|
|
|
It's best to hang your painting code in the Paint event. Windows will tell you when to paint your form as that can be at any time, even you don't expect it in your code.
It's far better to do it that way instead of trying to figure out why it appears as though your painting code work most of the time, but not at others.
For example, in your original code, your painting code would draw the text on the panel, but when the user drags another window over the top of the panel and then removes it, your text will be gone.
Windows will tell you that your forms and controls need to be repainted via the Paint event. If you don't hang your drawing code from there, you'll end up with all kinds of painting issues you can't figure out.
|
|
|
|
|
In actual fact the text is getting drawn, but every time the panel is repainted it is going to clear it out (and this will happen as soon as the form is loaded). You say you want to do this outside the Paint event, but this is where this sort of thing should be handled. You should just call the panel's Invalidate method every time the text is updated. Something like this:-
string text;
public Form1()
{
InitializeComponent();
text = "No problem drawing in paint method!";
panel.Invalidate();
}
private void panel_Paint(object sender, PaintEventArgs e)
{
Graphics grfx = e.Graphics;
grfx.DrawString(text, panel.Font, Brushes.Black, 50, 50);
grfx.Dispose();
}
private void button1_Click(object sender, EventArgs e)
{
text = "Changed with the click of a button !";
panel.Invalidate();
}
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
As Pete says, this specific case is because you're drawing on the panel before the form finishes loading, and therefore before the panel hits the screen and repaints itself, so anything you are doing may work but you'll never see it. (Actually I'm a bit surprised CreateGraphics doesn't throw an exception at that stage.)
Why do you think you need to paint stuff outside a Paint event handler? There are a few specialist cases where that can be useful, but for 99% of all custom painting you want to do it in Paint, and I would expect that you should also be doing it there.
|
|
|
|
|
I was drawing the text outside the Paint event because the Panel is created in a different class while the function that draws the text is found in another class in the application I am writing (Not the example shown as a test). But I think I should do it in a Paint event. I want to install a Paint event for the Panel in the class within which the function that draws the text is implemented. Yet to do it but I hope that will work. Thanks.
|
|
|
|
|
One way to handle this is to create a list of items you want to paint (ordered by the order you want to paint them), and have each one use it's own paint method. Then you just iterate over this list in the paint event and call the appropriate draw. I would typically do something like this:
public abstract class PaintBase
{
public void Draw(Graphics graphics)
{
OnDraw(Graphics graphics);
}
protected abstract OnDraw(Graphics graphics);
} Then, you derive your classes from this:
public class PanelText : PaintBase
{
public Font DrawFont { get; set; }
public string Text { get; set; }
protected override OnDraw(Graphics graphics)
{
graphics.DrawString(Text, DrawFont, Brushes.Black, 50, 50);
}
} Then, in your form, create a list of type PaintBase and add what you need to it, as in:
private List<PaintBase> paintables = new List<PaintBase>();
private void AddPaintables()
{
PanelText panelText = new PanelText();
panelText.DrawFont = panel.Font;
panelText.Text = "Problem drawing text on panel";
paintables.Add(panelText);
} Finally, in your paint handler, all you would do is iterate like this:
foreach (PaintBase item in paintables)
{
item.Draw(e.Graphics);
} This is a very rough implementation - it's missing a lot of error handling, validation, etc, but on the whole, you should be able to get the idea. Note that I've just knocked this up in the message editor, so I apologise if the syntax isn't 100%; it should serve to get you started though.
|
|
|
|
|
Very cool, Pete, this to me exemplifies one of the cases of "gems submerging in the forums," where the post, imho, deserves elevation to some "archived Valhalla," without requiring the author to write a Tip/Trick or article.
As you know, I have been commenting on issues like this in the "Buggs and Suggs" forum.
best, Bill
"The first principle is that you must not fool yourself, and you are the easiest person to fool." Richard Feynman
|
|
|
|
|
Hi
Dan_K ,
To draw object under any control, you must implement the event "OnPaint".
You can use this code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
panel.Paint += new PaintEventHandler(panel_Paint);
}
private void void panel_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawString("Problem drawing text on Panel", panel.Font, Brushes.Black, 50, 50);
}
}
}
|
|
|
|
|
Hi all
Here is my conundrum: I have a helper class/function that says if a date is a working day.
It does this by reading in the holidays from the database and checking the date against weekends, and then holidays.
It holds the holidays in a dictionary keyed by date for quick lookup and caching.
It is passed an interface to a holiday repository in the ctor and everything is injected via Castle Windsor ctor injection from a root entity.
It needs to be an in-memory cache and readily accessible as it is used a lot.
So far so good.
How would you go about making this a static extension method to DateTime?
(Since you can’t inject to static classes…)
The basic problem is, can you pass stuff into an extension method using CW? Or am I stuck with injection all the way and no statics, and therefore no extension methods?
I came up with a hack that uses a collection in the static helper class, and gets set with the holiday cache beforehand, but it just seemed a bit klunky...
Thanks in advance for any ideas...
|
|
|
|
|
Uh, am I missing something obvious?
public static bool IsWorkingDay(this DateTime dt){
return false;
}
permits
bool shouldIBeWorking = DateTime.Now.IsWorkingDay();
(Is it possible to have extension properties? I don't think so, right?)
This is completely independent of dependency injection and as long as the extension method is visible in the place you're trying to use it (i.e. in the same assembly, or a referenced assembly, and you have a using statement for the class that defines it) it should work anywhere.
|
|
|
|
|
I'll try again with an example:
Here is the current naive implementation:
public static class DateExtension
{
static readonly Dictionary<DateTime, Holiday> Dict;
static DateExtension()
{
Dict = new Dictionary<DateTime, Holiday>();
}
public static void SetHoliday(Holiday holidayToAdd)
{
Dict.Add(holidayToAdd.Date, holidayToAdd);
}
public static bool IsWorkingDay(this DateTime dateToCheck)
{
if (dateToCheck.DayOfWeek == DayOfWeek.Saturday ||
dateToCheck.DayOfWeek == DayOfWeek.Sunday)
{
return false;
}
return !Dict.ContainsKey(dateToCheck);
}
}
public class Holiday
{
public virtual DateTime Date { get; set; }
public virtual string Description { get; set; }
}
To use this, you have to stuff the DateExtension with the holidays first
Holiday hol = new Holiday {Date = new DateTime(2012, 1, 2), Description = "NYD 2012"};
DateExtension.SetHoliday(hol);
So you would use it like this:
DateTime dt = new DateTime(2012, 1, 2);
Debug.Assert(!dt.IsWorkingDay());
dt = dt.AddDays(1);
Debug.Assert(dt.IsWorkingDay());
Now, the question is about, how can I nicely get CW to instantiate the holidays into the static extension, without doing something like this:
var holRep = _container.Resolve<IHolidayRepository>();
DateExtension.SetAllHolidays(holRep.All());
In other words, can anyone think of a way to do this automatically within CW by simply registering the static class DateExtension in CW and have it inject the repository for me?
Thx
|
|
|
|
|
Ah, okay, now I see the problem.
The easiest way is to register in reverse, i.e. pass a container to the extension class:
static class DateExtensions {
static IUnityContainer container;
static HolidayHandler handler;
public static void RegisterHolidayHandler(IUnityContainer container){
container.Register<HolidayHandler, HolidayHandler>();
this.container = container;
}
public static bool IsHoliday(){
if(handler == null) handler = container.Resolve<HolidayHandler>();
}
class HolidayHandler {
internal List<Holidays> holidays;
public HolidayHandler(EntityContext context){
holidays = context.GetHolidays();
}
}
}
If you want some syntactic tidyness then of course RegisterHolidayHandler can itself be an extension method.
If you don't want to have a dependency on the dependency injection framework here (and I don't think you do, really), you need to give the extension class a property (of type IHolidayHandler or something) and explicitly assign an instance of a subclass which is populated by IoC. This is essentially 'loading the holidays' but with the mechanics of it abstracted and hidden away. That is pretty much what you say you don't want to do.
I can't think of a clever way without having to do, at least,
DateExtensions.HolidayRepository = _container.Resolve<IHolidayRepository>();
|
|
|
|
|
Thanks BobJanova.
Isn't passing around a reference to the container an anti-pattern?
Anyway, I'm specifically trying to avoid directly calling resolve against any repositories, as I want all the plumbing to be automatic through ctor/field injection. Which you can't (apparently) do with statics, and CW.
Hmmm....
Rgds
|
|
|
|
|
Yes, I suspect it is, which is why I suggest doing it the other way.
I'm pretty sure you can't do property/field injection on a static because there is no point at which an instance of it is created by the container and passed to something else. Obviously you can't do constructor parameter injection.
Personally I don't like dependency injection much and consider the whole field something of an anti-pattern so perhaps I'm not the ideal person to be trying to help you
|
|
|
|
|
I want to develope a RTF editor like word.I means it must hava WYSWG and Have a page view (like a Print View).
|
|
|
|
|
|
hi my friends
i need to help for( programming code c++ or c#) mapping for noc(network on chip)
by algorithm pso(particle swarm optimization)
i cant speak or write english welly
help me pleas
|
|
|
|
|