public void Create(string content, string email) { var bug = new BugReport() { Content = content, CreatedOn = DateTime.Now, Email = email, }; this.bugsRepository.Add(bug); this.bugsRepository.Save(); }
/// <summary> /// Displays exception information. Should be called from try...catch handlers /// </summary> /// <param name="ex">Exception object to handle</param> public static void HandleException(Exception ex) { if (ex == null || HandleKnownExceptions(ex)) return; // TODO: suggest a bug report for other exceptions ErrorHandler handler = new ErrorHandler { txtError = { Text = ex.Message } }; var errorMessage = new BugReport(ex).PrintForPhabricator(); handler.txtDetails.Text = errorMessage; handler.txtSubject.Text = ex.GetType().Name + " in " + Thrower(ex); // Tools.WriteDebug("HandleException", errorMessage); handler.ShowDialog(); }
public ActionResult ReportBug(BugReportViewModel vm) { string output = ""; if (ModelState.IsValid) { try { vm.Content = vm.Content.Replace(Environment.NewLine, "<br/>"); string filename = null; if (vm.BugImage != null) { string path = uploadService.UploadImage(vm.BugImage, WebServices.enums.UploadLocationEnum.Bugs, enableSizeValidation: false); filename = Path.GetFileName(path); } var entity = new BugReport() { Content = vm.Content, CitizenID = SessionHelper.LoggedCitizen?.ID, Citizen = SessionHelper.LoggedCitizen, ImgUrl = filename == null ? null : "upload/" + filename }; bugReportRepository.Add(entity); bugReportRepository.SaveChanges(); vm.Sent = true; } catch (Exception e) { return(Content(output + "There was a problem with your bug report. Try to go back and save details about bug. Inform admin about this bug by messaging account 'admin'. Try to send bug later. <br/><br/>We are doomed if there are bug errors in bug reporting service :O." + e.ToString().Replace(Environment.NewLine, "<br/>") )); } } return(View(vm)); }
private static string BuildJsonRequest(BugReport report) { var ht = new Hashtable(); ht.Add("userEmail", report.Email); ht.Add("userDescription", report.UserDescription); ht.Add("console", CreateConsoleDump()); ht.Add("systemInformation", report.SystemInformation); if (report.ScreenshotData != null) { ht.Add("screenshot", Convert.ToBase64String(report.ScreenshotData)); } var json = Json.Serialize(ht); return(json); }
/// <summary> /// Used for handling general exceptions bound to the main thread. /// Handles the <see cref="AppDomain.UnhandledException"/> events in <see cref="System"/> namespace. /// </summary> /// <param name="sender">Exception sender object.</param> /// <param name="e">Real exception is in: ((Exception)e.ExceptionObject)</param> private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e) { try { if (Settings.HandleExceptions) { Logger.Trace("Starting to handle a System.AppDomain.UnhandledException."); var executionFlow = new BugReport().Report((Exception)e.ExceptionObject, ExceptionThread.Main); if (executionFlow == ExecutionFlow.BreakExecution) { Environment.Exit(0); } } } catch (Exception E) { // do nothing } }
public bool UpdateBugReport(BugReport br) { XDocument doc = XDocument.Load(Constant.BUG_XML_PATH); var elem = doc.Elements("BugReports") .Elements("BugReport") .First(M => Convert.ToInt32(M.Element("Number").Value) == br.Number); if (elem != null) { elem.Element("ReportedBy").Value = br.ReportedBy ?? string.Empty; elem.Element("OwnedBy").Value = br.OwnedBy ?? string.Empty; elem.Element("Keywords").Value = br.Keywords ?? string.Empty; elem.Element("Component").Value = br.Component ?? string.Empty; elem.Element("Description").Value = br.Description ?? string.Empty; } doc.Save(Constant.BUG_XML_PATH); return(true); }
public ActionResult Save(BugReport bugReport) { if (!ModelState.IsValid) { var viewModel = new ReportFormViewModel { BugReport = bugReport, Browsers = _context.Browsers.ToList(), OperatingSystems = _context.OperatingSystems.ToList() }; return(View("BugSubmission", viewModel)); } else { _context.BugReport.Add(bugReport); _context.SaveChanges(); return(RedirectToAction("SubmissionSuccess", "Home")); } }
/// <summary> /// Used for handling System.Threading.Tasks bound to a background worker thread. /// Handles the <see cref="UnobservedTaskException"/> event in <see cref="System.Threading.Tasks"/> namespace. /// </summary> /// <param name="sender">Exception sender object.</param> /// <param name="e">Real exception is in: e.Exception.</param> private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs e) { if (Settings.HandleExceptions) { Logger.Trace("Starting to handle a System.Threading.Tasks.UnobservedTaskException."); var executionFlow = new BugReport().Report(e.Exception, ExceptionThread.Task); if (executionFlow == ExecutionFlow.BreakExecution) { e.SetObserved(); if (!OnExitCallback()) { Environment.Exit(0); } } else if (executionFlow == ExecutionFlow.ContinueExecution) { e.SetObserved(); } } }
static private int inner_modSearch_byteCode(IntPtr ctx, byte[] src) { Native.uts_push_lstring_d(ctx, src, src.Length); Native.duk_to_buffer_u(ctx, -1); Native.duk_load_function(ctx); pushModSearchArgs(ctx); setModSearchArgs(ctx); if (Native.duk_pcall(ctx, 0) != 0) { BugReport.Report("Error: " + Native.duk_safe_to_string(ctx, -1)); } Native.duk_pop(ctx); // pop result or error popModSearchArgs(ctx); setModSearchArgs(ctx); return(0); }
public bool InsertBugReport(BugReport br) { br.Number = (new Random()).Next(1000, 10000); XElement elem = new XElement("BugReport" , new XElement("Number", br.Number) , new XElement("ReportedBy", br.ReportedBy ?? string.Empty) , new XElement("OwnedBy", br.OwnedBy ?? string.Empty) , new XElement("Component", br.Component ?? string.Empty) , new XElement("Keywords", br.Keywords ?? string.Empty) , new XElement("ReportedTime", DateTime.Now.ToString(Constant.DATETIME_FORMAT)) , new XElement("Description", br.Description ?? string.Empty) , new XElement("Comments", string.Empty) ); XDocument doc = XDocument.Load(Constant.BUG_XML_PATH); doc.Element("BugReports").Add(elem); doc.Save(Constant.BUG_XML_PATH); return(true); }
/// <summary> /// Used for handling WPF exceptions bound to the UI thread. /// Handles the <see cref="Application.DispatcherUnhandledException"/> events in <see cref="System.Windows"/> namespace. /// </summary> /// <param name="sender">Exception sender object</param> /// <param name="e">Real exception is in: e.Exception</param> private static void DispatcherUnhandledExceptionHandler(object sender, DispatcherUnhandledExceptionEventArgs e) { try { if (Settings.HandleExceptions) { Logger.Trace("Starting to handle a System.Windows.Application.DispatcherUnhandledException."); var executionFlow = new BugReport().Report(e.Exception, ExceptionThread.UI_WPF); e.Handled = true; if (executionFlow == ExecutionFlow.BreakExecution) { Environment.Exit(0); } } } catch (Exception E) { // do nothing } }
public void GetByID_TwoItems_ReturnsCorrectObject() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); BugReport entity1 = new BugReport { ID = id1 }; BugReport entity2 = new BugReport { ID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <BugReport>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <BugReport>(entity2)); // Assert Assert.AreNotSame(entity1, _cache.GetByID(id1)); Assert.AreNotSame(entity2, _cache.GetByID(id2)); }
// GET: BugReports/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BugReport bugReport = db.BugReports.Find(id); if (bugReport == null) { return(HttpNotFound()); } ViewBag.ProjectsId = new SelectList(db.Projects, "ProjectId", "ProjectTitle"); ViewBag.StatusId = new SelectList(db.StatusOfStoriesTasks, "Id", "Status", bugReport.StatusId); ViewBag.ReleaseId = new SelectList(db.Releases, "Id", "Version", bugReport.ReleaseId); ViewBag.SprintsId = new SelectList(db.Sprints, "Id", "Name", bugReport.SprintsId); ViewBag.UserId = new SelectList(db.Users, "Id", "Name", bugReport.UserId); ViewBag.BugTypeId = new SelectList(db.BugTypes, "Id", "TypeOfBug", bugReport.BugTypeId); return(View(bugReport)); }
/// <summary> /// Creates an error report for the given exception, suitable for sending to FogBugz. /// </summary> /// <param name="fatal">Can the program execution continue after this exception?</param> public static BugReport CreateReportForException( Exception e, bool fatal ) { // Create an error report. BugReport report = new BugReport { FogBugzUrl = "https://phillco.fogbugz.com/ScoutSubmit.asp", UserName = "******", Project = "LANdrop", Area = "Crash Reports", DefaultMessage = DEFAULT_BUGZSCOUT_MESSAGE, }; if ( fatal ) report.Description += "\n*** FATAL ERROR ***\n"; report.AddMachineDetails( "\nDiscovered by" ); report.AddExceptionDetails( e ); report.Description += "Application version: " + Util.GetProgramVersion( ) + Environment.NewLine; report.Description += "OS: " + Util.GetWindowsVersion( ) + Environment.NewLine; return report; }
public ActionResult Edit(int?id, BugReport model) { //int temp = Request.Form.Count; model.Number = id ?? 0; try { if (id == null) { brService.InsertBugReport(model); } else { brService.UpdateBugReport(model); } return(RedirectToAction("Index")); } catch//(Exception ex) { return(View(model)); } }
public ErrorForm( Exception e, BugReport report, bool fatal ) { InitializeComponent( ); this.Exception = e; this.Report = report; // Style the form differently for fatal errors. this.ErrorIsFatal = fatal; if ( ErrorIsFatal ) { pbIcon.Image = global::LANdrop.Properties.Resources.exclamation; lblTitle.Text = "We're sorry..."; lblDescription.Text = "LANdrop has encountered a fatal error and must restart."; btnRestart.Text = "Restart"; } Size = MinimumSize; UpdateState( ); BringToFront( ); runReporter( ); }
public ActionResult CreateBugReport(UIBugReport_C uim) { AjaxStatus status = new AjaxStatus(); using (var context = new DataContext()) { try { Account account = base.GetLoginAccount(); BugReport model = uim.CreateModel(); BugReportOperations.TryCreate(account, context, model); SendBugReport(account, model, status); } catch (Exception e) { base.HandleException("CreateBugReport", e); status.SetError(e.Message); } } return(Json(status)); }
/// <summary> /// Used for handling WinForms exceptions bound to the UI thread. /// Handles the <see cref="Application.ThreadException"/> events in <see cref="System.Windows.Forms"/> namespace. /// </summary> /// <param name="sender">Exception sender object.</param> /// <param name="e">Real exception is in: e.Exception</param> private static void ThreadExceptionHandler(object sender, ThreadExceptionEventArgs e) { try { if (Settings.HandleExceptions) { Logger.Trace("Starting to handle a System.Windows.Forms.Application.ThreadException."); // WinForms UI thread exceptions do not propagate to more general handlers unless: Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); var executionFlow = new BugReport().Report(e.Exception, ExceptionThread.UI_WinForms); if (executionFlow == ExecutionFlow.BreakExecution) { Environment.Exit(0); } } } catch (Exception E) { // do nothing } }
public void GetByID_RemovedItem_ReturnsCorrectObject() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); BugReport entity1 = new BugReport { ID = id1 }; BugReport entity2 = new BugReport { ID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <BugReport>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <BugReport>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <BugReport>(entity1)); // Assert Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(id1); }); Assert.AreNotSame(entity2, _cache.GetByID(id2)); }
/// <summary> /// Displays exception information. Should be called from try...catch handlers /// </summary> /// <param name="ex">Exception object to handle</param> public static void HandleException(Exception ex) { if (ex == null || HandleKnownExceptions(ex)) { return; } // TODO: suggest a bug report for other exceptions ErrorHandler handler = new ErrorHandler { txtError = { Text = ex.Message } }; var errorMessage = new BugReport(ex).PrintForPhabricator(); handler.txtDetails.Text = errorMessage; handler.txtSubject.Text = ex.GetType().Name + " in " + Thrower(ex); Tools.WriteDebug("HandleException", errorMessage); handler.ShowDialog(); }
private void btnSubmit_Click( object sender, EventArgs e ) { BugReport report = new BugReport { FogBugzUrl = "https://phillco.fogbugz.com/ScoutSubmit.asp", UserName = "******", Project = "LANdrop", Area = "Feedback", Title = "v" + Util.GetProgramVersion( ) + ( rbGreat.Checked ? " (Positive Feedback)" : " (Negative Feedback)" ), // Use version number to split feedback by version. DefaultMessage = "", }; // Uncomment to have each report add a case entry (even if no comments were added). //report.Description += ( rbGreat.Checked ? "It's great!" : "It needs work..." ) + Environment.NewLine + Environment.NewLine; if ( tbAdditionalComments.Text.Trim( ).Length > 0 ) report.Description += tbAdditionalComments.Text; ThreadPool.QueueUserWorkItem( delegate { report.Submit( ); } ); Close( ); }
/// <summary> /// 接收服务器的消息时的处理 /// </summary> /// <param name="iar"></param> void receiveCallBack(IAsyncResult iar) { try { if (receiveCounter >= FileSize) { fs.Write(receiveByte, 0, FileSize % receiveByte.Length); fs.Close(); } else { fs.Write(receiveByte, 0, receiveByte.Length); receiveCounter += receiveByte.Length; dataSocket.BeginReceive(receiveByte, 0, receiveByte.Length, 0, receiveCallBack, null); } } catch (Exception e) { BugReport.report(e); } }
public void SendBugReport(Account requester, BugReport bugreport, AjaxStatus status) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(GITAPI); request.Headers.Add("Authorization", string.Format("token {0}", TOKEN)); request.Method = "POST"; request.ContentType = "application/json"; request.Accept = "application/json"; request.UserAgent = ACCOUNT; try { using (var streamWriter = new StreamWriter(request.GetRequestStream())) { var jsonString = new JavaScriptSerializer().Serialize(new { title = bugreport.headline, body = bugreport.description + "\n\n[" + requester.Name + "]", labels = new List <String>(new string[] { LABEL }) }); streamWriter.Write(jsonString); streamWriter.Flush(); streamWriter.Close(); } var response = request.GetResponse(); using (var streamReader = new StreamReader(response.GetResponseStream())) { var deserializer = new JavaScriptSerializer(); var result = streamReader.ReadToEnd(); var dict = deserializer.Deserialize <Dictionary <string, object> >(result); status.data1 = "Ärende: " + dict["number"]; status.data2 = "Rubrik: " + dict["title"]; } } catch (Exception e) { TraceLog.Instance.LogError("SendBugReport() " + e.ToString()); throw new ServerConflictException("Kunde inte skapa felanmälan, kontakta oss via e-post"); } }
public async Task <IActionResult> SubmitBugReport([FromForm] BugReport bugReport) { Parser uaParser = Parser.GetDefault(); ClientInfo clientBrowser = uaParser.Parse(Request.Headers["User-Agent"].ToString()); bugReport.BrowserInfo = $"{clientBrowser.UA.Family} Version {clientBrowser.UA.Major}.{clientBrowser.UA.Minor}"; bugReport.SAP1EMUVersion = GetType().Assembly.GetName().Version.ToString(); StringBuilder body = new StringBuilder(); body.AppendLine("**SAP1EMU Version**"); body.AppendLine($"v{bugReport.SAP1EMUVersion}"); body.AppendLine(); body.AppendLine("**Browser Info**"); body.AppendLine(bugReport.BrowserInfo); body.AppendLine(); body.AppendLine("**Description**"); body.AppendLine(bugReport.Description); body.AppendLine(); body.AppendLine("**Steps to reproduce bug**"); body.AppendLine(bugReport.ReproductionSteps); try { Issue createdIssue = await CreateGithubIssue(bugReport.Title, body.ToString(), bugTag); return(Ok(createdIssue)); } catch (NotFoundException) { return(NotFound()); } catch (AuthorizationException) { return(Unauthorized()); } }
private void sendContactNotificationEmailAsync(BugReport bug) { string emailBody = "Contact Request\n\n"; emailBody += "Email: " + bug.Email + "\n"; emailBody += "PortalName: " + bug.PortalName + "\n"; emailBody += "PortalId: " + bug.PortalId + "\n"; emailBody += "AbsoluteUrl: " + bug.AbsoluteUrl + "\n"; emailBody += "AbsoluteUrlReferrer: " + bug.AbsoluteUrlReferrer + "\n"; emailBody += "DateTime: " + bug.DateTime.ToShortDateString() + "\n"; emailBody += "\nDescription: \n" + bug.Description + "\n\n"; emailBody += "To see the message thread, follow the link below:\n"; emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/Admin/ContactRequests.aspx") + "?b=" + bug.Id; string subject = "CONTACT: A contact request from '" + bug.PortalName + "'"; Affine.Utils.GmailUtil gmail = new Utils.GmailUtil(); aqufitEntities entities = new aqufitEntities(); gmail.Send("*****@*****.**", subject, emailBody); }
static string BuildJsonRequest(int typeValue, BugReport report) { string json = ""; switch (typeValue) { case (int)ReportType.ScreenShot: var ht = new Hashtable(); ht.Add("text", report.UserDescription); json = Json.Serialize(ht); break; case (int)ReportType.SystemInfo: json = BuildSystemInfoJsonRequest(report); break; case (int)ReportType.Console: json = BuildConsoleLogJsonRequest(report); break; } return(json); }
public ErrorForm(Exception e, BugReport report, bool fatal) { InitializeComponent( ); this.Exception = e; this.Report = report; // Style the form differently for fatal errors. this.ErrorIsFatal = fatal; if (ErrorIsFatal) { pbIcon.Image = global::SampleProgram.Properties.Resources.exclamation; lblTitle.Text = "We're sorry..."; lblDescription.Text = "SampleApp has encountered a fatal error and must restart."; btnRestart.Text = "Restart"; } Size = MinimumSize; UpdateState( ); BringToFront( ); bugReporter.RunWorkerAsync( ); }
//revise this class to be singleton public IList <BugReport> GetBugReports() { IList <BugReport> reports = new List <BugReport>(); XDocument doc = XDocument.Load(Constant.BUG_XML_PATH); var result = from bug in doc.Elements("BugReports").Elements("BugReport") select bug; foreach (var elem in result) { BugReport r = new BugReport(); r.Number = Convert.ToInt32(elem.Element("Number").Value); r.ReportedBy = elem.Element("ReportedBy").Value; r.OwnedBy = elem.Element("OwnedBy").Value; r.Keywords = elem.Element("Keywords").Value; r.Component = elem.Element("Component").Value; r.ReportedTime = Convert.ToDateTime(elem.Element("ReportedTime").Value); r.Description = elem.Element("Description").Value; reports.Add(r); } return(reports); }
private void Form_SendClicked(object sender, EventArgs e) { _BugReport.UserActions = _FormBugReport.WhatYouDid; _BugReport.Email = _FormBugReport.Email; _FormBugReport.Hide(); try // Yes I know that it's not good practice // But still it the solution. { _BugSubmitter.Submit(_BugReport); } catch (Exception internalException) { MessageBox.Show("Error in exception-handling code. Please send us screenshot of this message\r\n" + BugSubmitter.FormatErrorMessage(internalException), "FileWall", MessageBoxButtons.OK, MessageBoxIcon.Error); } _BugReport = null; }
private void TsCall() { IntPtr ctx = _context.ptr; Native.duv_push_ref(ctx, _funref); if (Native.duk_is_function(ctx, -1) != 1) { Native.duk_pop(ctx); return; } FillCallArgs(ctx); if (Native.duk_pcall(ctx, _args.Length) != 0) { BugReport.Report("Error: " + Native.duk_safe_to_string(ctx, -1)); Native.duk_pop(ctx); // pop error return; } Native.duk_pop(ctx); // pop result return; }
static void Main(string[] args) { try { Program program = new Program(); string ip = args[0]; int port = int.Parse(args[1]); string fileName = args[2]; BugReport.report(new Exception(ip + " " + port.ToString() + " " + fileName)); Console.WriteLine("server ip : " + ip); Console.WriteLine("port : " + port.ToString()); program.dataConnect(ip, port, fileName); Thread.Sleep(50); program.dataDisconnect(); } catch (Exception e) { Console.Write(e.ToString()); Console.WriteLine(); BugReport.report(e); } //Console.ReadLine(); }
private static void HandleAction(uint user, uint target, Location targetLocation, params string[] args) { string message = string.Empty; foreach (var arg in args) { message += " " + arg; } if (message.Length > 1000) { SendMessageToPC(user, "Your message was too long. Please shorten it to no longer than 1000 characters and resubmit the bug. For reference, your message was: \"" + message + "\""); return; } var isPlayer = GetIsPC(user); var area = GetArea(user); var areaResref = GetResRef(area); var position = GetPosition(user); var orientation = GetFacing(user); BugReport report = new BugReport { SenderPlayerID = isPlayer ? (Guid?)Guid.Parse(GetObjectUUID(user)) : null, CDKey = GetPCPublicCDKey(user), Text = message, AreaResref = areaResref, SenderLocationX = position.X, SenderLocationY = position.Y, SenderLocationZ = position.X, SenderLocationOrientation = orientation }; var key = Guid.NewGuid().ToString(); DB.Set(key, report); SendMessageToPC(user, "Bug report submitted! Thank you for your report."); }
public bool DeleteBugReport(int id) { BugReport br = new BugReport(); if (id <= 0) { return(false); } try { XDocument doc = XDocument.Load(Constant.BUG_XML_PATH); var elem = doc.Elements("BugReports") .Elements("BugReport") .First(M => Convert.ToInt32(M.Element("Number").Value) == id); if (elem != null) { br.Number = Convert.ToInt32(elem.Element("Number").Value); br.ReportedBy = elem.Element("ReportedBy").Value; br.OwnedBy = elem.Element("OwnedBy").Value; br.Keywords = elem.Element("Keywords").Value; br.Component = elem.Element("Component").Value; br.ReportedTime = Convert.ToDateTime(elem.Element("ReportedTime").Value); br.Description = elem.Element("Description").Value; elem.Remove(); } doc.Save(Constant.BUG_XML_PATH); } catch { return(false); } return(true); }
public void SendBugReport(BugReport report, BugReportCompleteCallback completeHandler, BugReportProgressCallback progressCallback = null) { if (report == null) { throw new ArgumentNullException("report"); } if (completeHandler == null) { throw new ArgumentNullException("completeHandler"); } if (_isBusy) { completeHandler(false, "BugReportApiService is already sending a bug report"); return; } if (Application.internetReachability == NetworkReachability.NotReachable) { completeHandler(false, "No Internet Connection"); return; } _errorMessage = ""; enabled = true; _isBusy = true; _completeCallback = completeHandler; _progressCallback = progressCallback; _reportApi = new BugReportApi(report, Settings.Instance.ApiKey); StartCoroutine(_reportApi.Submit()); }
/// <summary> /// Send e-mail /// </summary> /// <param name="Bug">Bug for send</param> public static void SendBugReport(BugReport Bug) { if (Internet) { var fromAddress = new MailAddress("*****@*****.**", Bug.Author); var toAddress = new MailAddress("*****@*****.**", "Fix"); const string fromPassword = "******"; string subject = Bug.Category; StringBuilder body = new System.Text.StringBuilder(); body.AppendLine("From: \t\t" + Bug.Author); body.AppendLine("Category: \t\t" + Bug.Category); body.AppendLine("Title: \t\t" + Bug.Title); body.AppendLine("Text: " + Bug.Text); var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body.ToString() }) { smtp.Send(message); } } else { DrawEngine.ConsoleDraw.WriteTitle("Для отправки баг репорта требуется подключение к интернету!"); } }
public static void Main(string[] args) { Storage storage = StorageFactory.Instance.CreateStorage(); storage.Open("testlinq.dbs"); QueryListener listener = new QueryListener(); storage.Listener = listener; Database db = new Database(storage); int n; Customer customer1 = new Customer(); customer1.name = "Age Soft"; customer1.address = "MT, Freen Valley, 5"; customer1.phone = "111-1111"; customer1.contactPerson = "John Smith"; customer1.vip = true; db.AddRecord(customer1); Customer customer2 = new Customer(); customer2.name = "WebAlta"; customer2.address = "Moscow, Russia, Kolomenskay nab.,2"; customer2.phone = "222-22222"; customer2.contactPerson = "Piter Volokov"; db.AddRecord(customer2); BugReport bug1 = new BugReport(); bug1.issuedBy = customer1; bug1.priority = BugReport.Priority.Low; bug1.description = "It doesn't work"; bug1.version = 1.03M; db.AddRecord(bug1); BugReport bug2 = new BugReport(); bug2.issuedBy = customer2; bug2.priority = BugReport.Priority.High; bug2.description = "Something is definitely wrong"; bug2.version = 2.01M; db.AddRecord(bug2); Console.WriteLine("Search customer by name"); n = 0; foreach (Customer c in db.Select<Customer>(c => c.name == "WebAlta")) { Console.WriteLine(c); n += 1; } Debug.Assert(n == 1); Console.WriteLine("Locate customers issued high priority bugs for version 2.0"); n = 0; var query1 = from bug in db.GetTable<BugReport>() where bug.priority >= BugReport.Priority.High && bug.version >= 2.0M orderby bug.priority select bug.issuedBy; foreach (var c in query1) { Console.WriteLine(c); n += 1; } Debug.Assert(n == 1); Console.WriteLine("Select customer by name and contact person"); n = 0; string name = "Age Soft"; string person = "John Smith"; var query2 = from c in db.GetTable<Customer>() where name == c.name && c.contactPerson == person select c; foreach (var c in query2) { Console.WriteLine(c); n += 1; } Debug.Assert(n == 1); name = "WebAlta"; person = "Piter Volokov"; n = 0; foreach (var c in query2) { Console.WriteLine(c); n += 1; } Debug.Assert(n == 1); Debug.Assert(listener.nSeqSearches == 0); Console.WriteLine("Select with index join"); n = 0; foreach (BugReport bug in db.Select<BugReport>(bug => bug.issuedBy.name == "WebAlta" || bug.issuedBy.name == "Age Soft")) { Console.WriteLine(bug); n += 1; } Debug.Assert(n == 2); Console.WriteLine("Select with index prefix search"); n = 0; foreach (Customer customer in db.Select<Customer>(customer => customer.phone == "222-22222" && customer.name.StartsWith("Web"))) { Console.WriteLine(customer); n += 1; } Debug.Assert(n == 1); Debug.Assert(listener.nSeqSearches == 0); Console.WriteLine("Select without search condition"); n = 0; var query3 = from bug in db.GetTable<BugReport>() orderby bug.priority select bug; foreach (var b in query3) { Console.WriteLine(b); n += 1; } Debug.Assert(n == 2); Console.WriteLine("Select using sequential search"); n = 0; var query4 = from bug in db.GetTable<BugReport>() where bug.version >= 2.0M select bug; foreach (var b in query4) { Console.WriteLine(b); n += 1; } Debug.Assert(n == 1); n = 0; var query5 = from bug in db.GetTable<BugReport>() where bug.issuedBy == customer1 select bug; foreach (var b in query5) { Console.WriteLine(b); n += 1; } Debug.Assert(n == 1); n = 0; List<Customer> customers = new List<Customer>(); customers.Add(customer1); customers.Add(customer2); var query6 = from bug in db.GetTable<BugReport>() where customers.Contains(bug.issuedBy) select bug; foreach (var b in query6) { Console.WriteLine(b); n += 1; } Debug.Assert(n == 2); n = 0; foreach (Customer c in db.Select<Customer>(c => c.name.CompareTo("A") >= 0)) { Console.WriteLine(c); n += 1; } Debug.Assert(n == 2); n = 0; foreach (Customer c in db.Select<Customer>(c => String.Compare(c.name, "webalta", StringComparison.CurrentCultureIgnoreCase) == 0)) { Console.WriteLine(c); n += 1; } Debug.Assert(n == 1); n = 0; foreach (Customer c in db.Select<Customer>(c => c.vip)) { Console.WriteLine(c); n += 1; } Debug.Assert(n == 1); n = 0; foreach (Customer c in db.Select<Customer>(c => !c.vip)) { Console.WriteLine(c); n += 1; } Debug.Assert(n == 1); Debug.Assert(listener.nSeqSearches == 1); storage.Close(); }
protected void bSend_Click(object sender, EventArgs e) { aqufitEntities entities = new aqufitEntities(); UserSettings settings = null; if (this.UserId > 0) { settings = entities.UserSettings.FirstOrDefault(us => us.UserKey == this.UserId && us.PortalKey == this.PortalId); } string un = settings != null ? settings.UserName : ""; string url = Request["u"] != null ? Request["u"] : Request.Url.AbsoluteUri; long tab = Request["t"] != null ? Convert.ToInt64(Request["t"]) : this.TabId; string email = string.Empty; if (this.UserId > 0) { email = entities.UserSettings.FirstOrDefault(u => u.Id == this.UserId && u.PortalKey == this.PortalId).UserEmail; } else { email = txtEmail.Text; } BugReport bug = new BugReport() { Description = txtDescription.Text, UserAgent = Request.UserAgent, UserId = this.UserId, UserName = un, PortalId = this.PortalId, PortalName = this.PortalAlias.HTTPAlias, AbsoluteUrl = Request.Url.AbsoluteUri, AbsoluteUrlReferrer = url, DateTime = DateTime.Now, Ip = Request.ServerVariables["REMOTE_ADDR"], RawUrl = Request.RawUrl, ScreenResolution = hiddenScreenRes.Value, Status = "Open", Email = email, ActiveTabId = this.TabId, IsContactRequest = panelContactHead.Visible }; entities.AddToBugReports(bug); entities.SaveChanges(); bSend.Visible = false; txtDescription.Visible = false; if (panelBugHead.Visible) // This moduel is configured to report bugs { sendBugNotificationEmailAsync(bug); litStatus.Text = "<em>Thank You</em>. Bear with us as we work out some of the kinks in our system."; } else { sendContactNotificationEmailAsync(bug); litStatus.Text = "<em>Thank You</em>. Your request has been sent. We will get back to you as soon as we possibly can."; } }
/// <summary> /// For a list of selected keyboards invoke the corresponding msi package to install the /// package on the user's computer. The selected fonts are copied to the appropraite folder /// in the windows directory. /// </summary> private void InstallSelectedItems() { try { btnNext.Enabled = false; //compile a list of selected keyboards/fonts. Dictionary<string, string> selectedKeyboards = null; Dictionary<string, string> selectedFonts = null; foreach (Control control in pnlContent.Controls) { if (control is KeyboardForm) { KeyboardForm kform = control as KeyboardForm; selectedKeyboards = kform.GetSelectedKeyboards(); } else if (control is FontForm) { FontForm fontform = control as FontForm; selectedFonts = fontform.GetSelectedFonts(); } } //for each selected keyboard, invoke its installer. if (selectedKeyboards != null) { foreach (string key in selectedKeyboards.Keys) { string path = selectedKeyboards[key]; ExecProc(string.Format("\"{0}\"", path), "", true); } } //expand the selected font files and copy them to the windows font folder. if (selectedFonts != null) { foreach (string key in selectedFonts.Keys) { string path = selectedFonts[key]; string dir = Path.GetDirectoryName(path); string pattern = Path.GetFileName(path); string[] files = null; try { files = Directory.GetFiles(dir, pattern); } catch { continue; } foreach (string file in files) { int status = Win32.AddFontResource(file); } } } } catch (Exception ex) { BugReport report = new BugReport(ex); report.ShowDialog(this); } }