|
Dear
I'm newbie and i'm developing a Windows Service which should make same tasks according some REGISTRY KEY i will populate during Setup Setup (based on VS c# Setup Project).
I need to rollback installation before complete installation if during Setup a web request i run give me back some errors or some special return value.
How can I do using custom action ?
thx
nemo14
|
|
|
|
|
Don't use the registry unless you have no other option: access to it is now restricted, and likely to become more so, not less.
Instead, consider using an XML file (or similar) stored in a more accessible location. Windows provides several: Where should I store my data?[^] and it's a lot easier to just dump a folder on rollback than play with the registry.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Apart from the fact that OriginalGriff is right telling you not to use the registry, your main issue was not solved by his answer: where to do a rollback. Since you talk about a Windows Service, you should have a ServiceInstaller in your project. Then you'll do some overrides, e.g. Rollback , OnBeforeRollback , OnAfterRollback . Which ever you select, do not forget to call base.YourSelectedFunction .
|
|
|
|
|
here i am giving a small my code snippet just to show what i am trying to achieve.
private void frmMain_Load(object sender, EventArgs e)
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
sched = schedFact.GetScheduler();
sched.Start();
IJobDetail job = JobBuilder.Create<frmMain>()
.WithIdentity("Job", "group")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInHours(24)
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(01, 55))
)
.Build();
sched.ScheduleJob(job, trigger);
}
public void Execute(IJobExecutionContext context)
{
generate();
}
public void generate()
{
if (this.FetchStart != null)
this.FetchStart(this, new EventArgs());
System.Threading.Thread.Sleep(5000);
if (this.FetchDone != null)
this.FetchDone(this, new EventArgs());
}
i have done my project with VS2013 community edition. my objective is to call slide show routine every day at specific time. when i am calling my slide show routine without quartz.net scheduler then it is working fine but when i invoke my routine by quartz.net scheduler then routine is getting called but no slide show image is showing.
what [problem occur is not clear to me. as per my objective i have to use quartz.net scheduler because i need to invoke my routine at a specific time of day every day.
here i am sharing my project code because it is in onedrive. so my request please some one download my project and run at your end to see the problem and tell me the reason which causes not to show images on picture box.
if possible please rectify my code with quartz.net scheduler code. one drive project link is https://1drv.ms/f/s!AmIfMNV-CodPa81zFiNH6Ur7qro
i upload my project folder.
thanks
----------------------------------------------------------------------------------------------------------
UPDATE
when i use background worker along with quartz.net to call my generate routine then also no improvement i found. same problem that slide show image is not appearing on picture box.
here is the code for quartz.net with background worker
public partial class frmMain : Form, IJob
{
ucSlide oSlide = new ucSlide();
IScheduler sched = null;
BackgroundWorker m_oWorker = null;
public event EventHandler FetchStart;
public event EventHandler FetchDone;
public event EventHandler NoDataFound;
public frmMain()
{
InitializeComponent();
m_oWorker = new BackgroundWorker();
m_oWorker.DoWork += new DoWorkEventHandler(m_oWorker_DoWork);
m_oWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_oWorker_RunWorkerCompleted);
oSlide.MainForm = this;
oSlide.SlideSource = Utility.SlidePath;
this.Controls.Add(oSlide);
oSlide.Dock = DockStyle.Fill;
}
private void frmMain_Load(object sender, EventArgs e)
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
sched = schedFact.GetScheduler();
sched.Start();
IJobDetail job = JobBuilder.Create<frmMain>()
.WithIdentity("Job", "group")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInHours(24)
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(02,23))
)
.Build();
sched.ScheduleJob(job, trigger);
}
public void Execute(IJobExecutionContext context)
{
m_oWorker.RunWorkerAsync();
}
public void generate()
{
if (this.FetchStart != null)
this.FetchStart(this, new EventArgs());
System.Threading.Thread.Sleep(5000);
if (this.FetchDone != null)
this.FetchDone(this, new EventArgs());
}
void m_oWorker_DoWork(object sender, DoWorkEventArgs e)
{
generate();
}
void m_oWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
}
}
thanks
tbhattacharjee
|
|
|
|
|
No one is going to download a project to fix it for you. If there is an issue with Quartz.Net, the github for it can be found here[^].
This space for rent
|
|
|
|
|
Functional programming mayhem. Reap now what you sow.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Is there any third party spell checker extension like javascript spell checker to implement in my web api c# project?
I tried javascript spell checker it is working in local perfect. Once publish in online it is showing some message like register and purchase.
Please post is there any free extension because it is urgent for me due client doesn't want to purchase.
|
|
|
|
|
|
Did you even bother to search for free javascript spell checker? It took me seconds to find this[^] and this[^].
This space for rent
|
|
|
|
|
Drag and drop RichTextBox into form in the Form_Load and his running assign content for events RichTextBox_TextChanged RichTextBox but not running although I have to add this line of code:
this.RichTextBox.TextChanged + = new System.EventHandler (this.RichTextBox_TextChanged);
before Form_Load
[CODE]
public Form1()
{
InitializeComponent();
this.RichTextBox.TextChanged + = new System.EventHandler (this.RichTextBox_TextChanged);
this.Load += new System.EventHandler(this.Form1_Load);
}
private void RichTextBox_TextChanged (object sender, System.EventArgs e)
{
do something ...
}
[/ CODE]
as an example of his small examples on running normally, but in the main program will not run, I do not know what is not right ? What advice can you help me fix this.
|
|
|
|
|
You will have to be more specific than "the main program will not run". What do you mean by this? Are you seeing exceptions? If so, which ones are you seeing?
This space for rent
|
|
|
|
|
Hi,
I am trying to print Arabic receipt from Epson TM-T88V from VB.ET and C# application.
I have tried changing font, Epson settings for Arabic and all but it is not printing proper Arabic. It is printing as separation of Arabic alphabets not as a word.
Can someone please help me with this thing?
|
|
|
|
|
As fas as I understand you are using the printer's built-in font which is of poor quality.
Then the only solution to have a better font is to let Windows render a print image and send that to the printer in graphics mode (using the printer driver like with other printers). But this will usually take much more time to print.
|
|
|
|
|
|
Hello to everybody,
I have been struggling now for days on a part of the code i'am working on. And can not find the problem. Explain; If i make a new user on my admin panel everything goes well (It insert in the database), but wenn it comes to the 'verification email' it does not send it to the new user. I can verify manual the database (set 0 to 1), but that is not the way it should be. Strange is that if a user 'forgot' his password yes it is sending the new password with a verification link. I hope someone can help me out. Thanks in advance,
Here is a part off the code;
public ActionResult AddUser()
{
return View();
}
public ActionResult AddUserToDB(string name, string email, string pass, string level, string mode)
{
var lvl = (UserManager.Level)Enum.Parse(typeof(UserManager.Level), level);
var md = (UserManager.Mode)Enum.Parse(typeof(UserManager.Mode), mode);
UserManager.User user = new UserManager.User();
user.Name = name;
user.Email = email;
user.Password = PasswordHash.CreateHash(pass);
user.Level = lvl;
user.Mode = md;
user.ResetCode = "test";
user.ResetCodeUsed = false;
user.CreatedOn = DateTime.Now;
user.SignIP = "";
user.LastIP = "";
user.Status = UserManager.Status.Active;
if (user.Level == UserManager.Level.Agency)
{
user.Level = UserManager.Level.Elite;
user.Mode = UserManager.Mode.Agency;
}
UserManager.AddUser(user);
return RedirectToAction("Users");
}
[HttpPost]
public PartialViewResult UserSorting(string keyword, string icon, int page = 1)
{
ViewData["users"] = UserManager.GetUsers(page, ADMIN_LIMIT, keyword, icon);
int count = UserManager.GetUsersCount();
ViewBag.TotalItems = count;
ViewBag.PageLimit = ADMIN_LIMIT;
ViewBag.CurrentPage = page;
ViewBag.urlExpression = "/admin/users?keyword={0}&icon={1}&page={2}";
ViewBag.Sort = icon;
ViewBag.SortBy = keyword;
return PartialView("~/Views/Partials/_users.cshtml");
}
public ActionResult SignUp()
{
int u = Convert.ToInt32(TempData["user"]);
TempData.Keep();
if (u > 0)
{
return View("SignUp");
}
else
{
return PartialView("login");
}
}
[HttpPost]
public ActionResult SignUp(string name, string email, string password, string confirmpass, string level)
{
List<string> errors = new List<string>();
TempData["Name"] = name;
TempData["Email"] = email;
bool exist = UserManager.IsUserExisting(email.ToLower());
if (exist)
{
ViewBag.Errors = new List<string>() {
"This email exists in our records, please click <a href='/user/signin'>here</a> to login with this credentials."
};
return View();
}
ClickModels.UserManager.User user = new ClickModels.UserManager.User();
user.Name = name;
user.Email = email;
user.Password = PasswordHash.CreateHash(password);
user.Level = (UserManager.Level)Enum.Parse(typeof(UserManager.Level), level);
user.LastIP = Request.UserHostAddress;
user.LastLogin = DateTime.Now;
user.SignIP = Request.UserHostAddress;
user.Status = ClickModels.UserManager.Status.Active;
user.Verified = true;
user.ResetCode = Globals.RandomString(6);
user.CreatedOn = System.DateTime.Now;
user.ID = UserManager.AddUserByAdmin(user);
SendVerificationMail(user);
ViewBag.Done = true;
return View();
}
private void SendVerificationMail(UserManager.User user)
{
Task task = new Task(() =>
{
string eml = System.IO.File.ReadAllText(Server.MapPath("~/app_data/verifymail.txt"));
eml = eml.Replace("[username]", user.Name);
eml = eml.Replace("[appname]", Globals.APPNAME);
eml = eml.Replace("[vericode]", user.ResetCode);
eml = eml.Replace("[appurl]", Globals.APPURL);
eml = eml.Replace("[userid]", user.ID.ToString());
Globals.SendMail(user.Email, "Verify your " + Globals.APPNAME + " membership.", eml);
});
task.Start();
}
[HttpPost]
public ActionResult ChangeStatus(int id, string status)
{
UserManager.UpdateStatus(id, status);
return View();
}
[HttpPost]
public ActionResult ChangeLevel(int userID, string level)
{
UserManager.UpdateLevel(userID, level);
return View();
}
[HttpPost]
public ActionResult UpdateAd(string AdName, string Title, string subtitle, int userid)
{
AdManager.Ad ad = new AdManager.Ad();
ad.ID = userid;
ad.AdName = AdName;
ad.Title = Title;
ad.Subtitle = subtitle;
AdManager.UpdateParticularAd(ad);
return RedirectToAction("Userads", new { userid = userid });
}
}
}
|
|
|
|
|
It is really very hard to understand why,
Globals.SendMail(user.Email, "Verify your " + Globals.APPNAME + " membership.", eml);
fails in your application. But in any case, we are not able to help you out by just reading the code out. We need more information, such as the email address or the service being used.
In case of the email, what is the reason for it not being sent, or any error message? Did you try using the following code? In your own code, what happens is that the code creates a new task in the pool, and then returns a task object for that. However, as soon as the last line gets hit your reference is lost and (maybe, maybe...) your code is unable to proceed to send an email. That is why, I am going to write the code that actually waits for a task to finish.
Task task = Task.Run(() =>
{
string eml = System.IO.File.ReadAllText(Server.MapPath("~/app_data/verifymail.txt"));
eml = eml.Replace("[username]", user.Name);
eml = eml.Replace("[appname]", Globals.APPNAME);
eml = eml.Replace("[vericode]", user.ResetCode);
eml = eml.Replace("[appurl]", Globals.APPURL);
eml = eml.Replace("[userid]", user.ID.ToString());
Globals.SendMail(user.Email, "Verify your " + Globals.APPNAME + " membership.", eml);
});
task.Wait();
Read this as well, Task.Run Method (Action) (System.Threading.Tasks)
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hello Afzaal Ahmad Zeeshan, first of all thank you for take the time&effort! I have implant your code and no error message,
I did not have received any 'error email' it just not send. I will show you a part of my web.config file, I use mailjet.com;
<appSettings>
<add key="admin:mail" value="******@gmail.com" />
<add key="admin:pass" value="*******" />
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="encryptkey" value="*****" />
<add key="encryptkeysuper" value="******" />
<add key="logpermdura" value="3" />
<add key="logtempdura" value="50" />
<add key="nomailwebsite" value="*****m@gmail.com" />
<add key="emailwebsite" value="*****@gmail.com" />
<add key="appurl" value="http://mar*******.club" />
<add key="app_name" value="GaxHopMSG" />
<add key="mailsmtp" value="in-v3.mailjet.com" />
<add key="maillogin" value="******************************" />
<add key="mailpass" value="******************************" />
<add key="mailport" value="25" />
<add key="permusercookie" value="clkperm" />
<add key="tempusercookie" value="clkmem" />
</appSettings>
Thank you,
|
|
|
|
|
Can you look in the control panel of MailJet services? I think the problem is somewhere on that side. Check if the email request received or not.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hi Afzaal Ahmad Zeeshan Thanks for your respond!, I have looked up on the control panel in Mailjet services, There were no 'email requests' exept for changing the password (That work like a charm)I have try with diferent emails, but no positive results. I do not know anymore what to do,
|
|
|
|
|
Then you need to debug why the email requests were not being sent at all. You will need to debug it, set breakpoints and see why code doesn't execute the statement.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thank you Afzaal Ahmad Zeeshan, I need to learn how to set breakpoints (working on visual studio 2015)and then see why the code is execute the statement. It is realy hard to understand why it is not working, as i mentioned in previous post's the 'resett/forgottenpass is working well......
|
|
|
|
|
Hello. I have this backgroundTask whose output type is Windows Runtime Component .
I have absolutely no idea how to use this backgoundTask in my winform application. Basically this backgroundTask gets geolocation and retrieves long/lat. Here is the skeleton for reference
public sealed class LocationBackgroundTask : IBackgroundTask
{
async void IBackgroundTask.Run(IBackgroundTaskInstance taskInstance)
{
BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
try
{
}
catch(Exception ex) { }
finally
{
deferral.Complete();
}
}
}
Again, I have no idea how do I use this runtime component from my winform application (a button will invoke this). This code is in one project and my winform application is second project.
Thanks for any input
|
|
|
|
|
Where did you find that code, or API? That requires you to involve Windows Runtime with Windows Forms? Although I am not saying that WinRT and .NET do not go well, they do and that is the beauty of C# itself.
But, what I wanted to know was, why would you need to do that, when there are many easy cases? Secondly, if an API does expose these types, then it would also expose some wrapper types, too. Are you a bit confused about the term, "component"?
Finally, as I can see, your IBackgroundTask.Run function has a void return type — void can be captured in .NET itself, no need for any Windows Runtime component. That looks like the default Windows Runtime background task interface, you should read a bit more about it here, Background Tasks in Windows Store Apps -- Visual Studio Magazine, it shows a good example of handling these background tasks. That will help you understand how it works.
Anyways, please do read this by Scott Hanselman as well, How to call WinRT APIs in Windows 8 from C# Desktop Applications - WinRT Diagram - Scott Hanselman
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Afzaal Ahmad Zeeshan wrote: Where did you find that code, or API? It is a sample I downloaded somewhere on the web.
Afzaal Ahmad Zeeshan wrote: why would you need to do that, when there are many easy cases? Can you tell me those easy cases? I do not know.
|
|
|
|
|
Django_Untaken wrote: Can you tell me those easy cases? I do not know. One of them would be, to not expose the native typing in either of the cases. Use the types that can be used in both the runtimes.
Since you are writing a background task handler, there is no need to use Windows Runtime background task handler, you can do that in Windows Forms itself using .NET framework's Task API. Which is much more simpler and easier to use.
Task Class (System.Threading.Tasks)
Secondly, if you really do require to have a WinRT component, then make sure it exposes the type that .NET can consume natively; such as returning the string values, integer results etc. Since you only provide an interface implementation, it is very hard to tell what you want to do with that code.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|