void Count_words(string text) { var stopwords = _da.Load_stopwords(); var result = Businesslogic.Count_words(text, stopwords); _ui.Display_results(result.CountTotal, result.CountDistinct); }
private void CheckMonthEnd(object sender, ElapsedEventArgs e) { if (DateTime.Now.Day == DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)) { Businesslogic.GenerateVoucher(); } }
public override string ToString() { string direct = directRoom == null ? "" : directRoom ? "direct:" : "room:"; string ret = ""; if (directRoom) { ret = Businesslogic.MatrixUsernameToShortUsername(roomNameHumanReadable); } else { if (roomNameHumanReadable == null) { ret = roomID; } else { ret = roomNameHumanReadable; } ret += " Room"; } return(ret); }
public ActionResult Uploadfile(string id) { bool isSavedSuccessfully = true; string fName = ""; var bl = new Businesslogic(); try { foreach (string fileName in Request.Files) { HttpPostedFileBase file = Request.Files[fileName]; string mapPath = Server.MapPath(@"\"); var fname = Guid.NewGuid().ToString().Split('-').First() + file.FileName; bl.SaveFileOnDrive(file, mapPath, id, fname); bl.SaveFileInDb(fname, id); } } catch (Exception ex) { isSavedSuccessfully = false; } if (isSavedSuccessfully) { return(Json(new { Message = fName }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Message = "Error in saving file" })); } }
protected void OnRowCancelingEdit(object sender, EventArgs e) { GridView1.EditIndex = -1; GridView1.DataSource = Businesslogic.list(); GridView1.DataBind(); }
private void SendLowStock(object sender, ElapsedEventArgs e) { List <Inventory> stockList = Businesslogic.informLowStockItems(); if (stockList.Count != 0) { StringBuilder sb = new StringBuilder(); sb.Append(" <table border='5', bordercolorlight='#b9dcff', bordercolordark='#006fdd', width='400',align='center',bordercolor='black'><tr><th>Item Name</th><th>Available Quantity</th><th>Re-Order Quantity</th></tr>"); foreach (Inventory item in stockList) { sb.Append("<tr><td>" + item.Description + " </td>" + "<td>" + item.Quantity + "</td> " + "<td>" + item.Reorder_level + "</td></tr>"); } sb.Append("</table>"); MailMessage mm = new MailMessage("*****@*****.**", "*****@*****.**"); mm.Subject = "Low Inventory Alert"; mm.Body = "The Following Items are : <hr />" + sb.ToString();; mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(); NetworkCred.UserName = "******"; NetworkCred.Password = "******"; smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); } }
public ActionResult Save() { var settings = Request["json"]; Businesslogic bl = new Businesslogic(); var res = bl.SaveSettings(settings, Server.MapPath(@"\")); return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(res))); }
protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e) { string itemnumber = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); Businesslogic.Deleteitem(itemnumber); GridView1.DataSource = Businesslogic.list(); GridView1.DataBind(); }
public ActionResult Update() { var imagejson = Request["json"]; image data = JsonConvert.DeserializeObject <image>(imagejson); Businesslogic bl = new Businesslogic(); bl.Update(data); return(null); }
public static void Main(string[] args) { var da = new Dataaccess(); var bl = new Businesslogic(da); var pre = new Presenter(); var uc = new UseCase(bl, da, pre); var controller = new Controller(uc); controller.Show(args); }
public ActionResult Login() { var passjson = Request["json"]; Logic.Message.Password data = JsonConvert.DeserializeObject <Logic.Message.Password>(passjson); Businesslogic bl = new Businesslogic(); var res = new Logic.Message.Response(); if (bl.CheckPassword(data)) { res.status = Logic.Message.Status.OK; } else { res.status = Logic.Message.Status.ERROR; } return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(res))); }
protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView1.Rows[e.RowIndex]; string itemnumber = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); string category = (row.FindControl("Label5") as Label).Text; string description = (row.FindControl("Label3") as Label).Text; decimal price = Convert.ToDecimal((row.FindControl("Label4") as Label).Text); int quantity = Convert.ToInt32((row.FindControl("TextBox1") as TextBox).Text); string unit_measure = (row.FindControl("Label5") as Label).Text; string suppiler_ID_1 = (row.FindControl("CategoryDropdown1") as DropDownList).SelectedValue; string suppiler_ID_2 = (row.FindControl("CategoryDropdown2") as DropDownList).SelectedValue; string suppiler_ID_3 = (row.FindControl("CategoryDropdown3") as DropDownList).SelectedValue; Businesslogic.Edititem(itemnumber, quantity, suppiler_ID_1, suppiler_ID_2, suppiler_ID_3); GridView1.EditIndex = -1; BindGridData(); Response.Redirect("MaintainInventory.aspx"); }
public void Indexer_AfterReIndex(object sender, Businesslogic.ReIndexEventArgs e) { Businesslogic.Indexer i = (Businesslogic.Indexer)sender; Lucene.Net.Index.IndexWriter iw = i.ContentIndex(false); try { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Re-indexing Video"); string url = "http://umbraco.org/FullVideoXmlFeed.aspx"; XPathNodeIterator xni = umbraco.library.GetXmlDocumentByUrl(url, 3600).Current.Select("//item"); while (xni.MoveNext()) { string content = umbraco.library.StripHtml( xni.Current.SelectSingleNode("./content").Value); string name = xni.Current.SelectSingleNode("./title").Value; string image = xni.Current.SelectSingleNode("./image").Value; string id = xni.Current.SelectSingleNode("./id").Value; string link = xni.Current.SelectSingleNode("./link").Value; Hashtable fields = new Hashtable(); fields.Add("name", name); fields.Add("content", content); fields.Add("image", image ); fields.Add("id", id); fields.Add("url", link); i.AddToIndex("video_" + id.ToString(), "videos", fields, iw); umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "adding " + name + " video"); } } catch (Exception ex) { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Re-indexing videos - DONE"); iw.Optimize(); iw.Close(); }
private void UserPresenceReceivedCallback(Dictionary <string, string> changed) { if (presenceLoaded) { foreach (KeyValuePair <string, string> c in changed) { Console.WriteLine("user came " + c.Value + ": " + c.Key); string message = ""; switch (c.Value) { case "online": message = "user came online"; break; case "offline": message = "user went offline"; break; default: message = "presence changed but dunno how. neither online nor offline. from server: " + c.Value; break; } Notification n = new Notification(3000, message, Businesslogic.MatrixUsernameToShortUsername(c.Key)); n.NotificationClickedEvent += NotificationClickedCallback; n.Tag = c.Key; //todo: keep users in list of e.g. class MatrixUsers and lookup user. pass as instance n.Audiofile = Properties.Resources.icq_knock; n.Show(); //notifyIcon1.ShowBalloonTip(1000, message, c.Key, ToolTipIcon.Info); } } presenceLoaded = true; lstUsers.Items.Clear(); foreach (KeyValuePair <string, string> presence in Businesslogic.Instance.presence) { lstUsers.Items.Add(presence.Key + ": " + presence.Value); } }
private void AvatarURLReceivedCallback(MatrixAvatarResult matrixAvatarResult) { Uri uri = Businesslogic.MXC2HTTP(matrixAvatarResult.avatar_url); if (uri == null) { Bitmap b = new Bitmap(100, 100); Graphics g = Graphics.FromImage(b); Brush brush = Brushes.White; g.FillEllipse(Brushes.Blue, new Rectangle(0, 0, 100, 100)); string firstcharusername = (Businesslogic.MatrixUsernameToShortUsername(Businesslogic.Instance.loggedInUserID)).Substring(0, 1).ToUpper(); g.DrawString(firstcharusername, new Font(FontFamily.GenericSansSerif, 70), brush, new Point(5, 0)); pbAvatar.Image = b; // Properties.Resources.User_Avatar; pbAvatar.SizeMode = PictureBoxSizeMode.Zoom; } else { Businesslogic.Instance.downloadAvatar(uri, null); } }
private void RoomsDirectResolvedCallback() { foreach (MatrixRoom matrixRoom in matrixRooms) { foreach (KeyValuePair <string, List <string> > d in Businesslogic.Instance.direct) { foreach (string roomID in d.Value) { if (roomID == matrixRoom.roomID) { Console.WriteLine("resolved room (direct contact): " + d.Key); matrixRoom.roomNameHumanReadable = d.Key; matrixRoom.directRoom = true; //Businesslogic.Instance.downloadAvatar(uri) //Businesslogic.Instance.avatar .downloadAvatar(uri); } } } } for (int i = 0; i < lvRooms.Items.Count; i++) { foreach (KeyValuePair <string, List <string> > d in Businesslogic.Instance.direct) { foreach (string roomID in d.Value) { if (roomID == lvRooms.Items[i].ImageKey) { Console.WriteLine("resolved room (direct contact): " + d.Key); lvRooms.Items[i].Text = Businesslogic.MatrixUsernameToShortUsername(d.Key); // resolved name, e.g. "armin" } } } } refreshlstRoomsUpdate(); }
public ActionResult CheckOut(FormCollection form) { int count = 0; int count1 = 0; int count2 = 0; string email = Session["email"].ToString(); int shippingid = int.Parse(form["shipping"]); string creditcardnumber = form["creditcard"]; decimal shippingcharges = dao.CheckShippingCharges(shippingid); dao.AddShippingToCart(shippingid, email); List <Product> list = dao.ShowAllProductsInCart(email); if (list.Count > 0) { foreach (var product in list) { product.TotalPrice = product.Quantity * product.Price; totalPrice = totalPrice + product.TotalPrice; } } totalPrice = totalPrice + shippingcharges; decimal.Round(totalPrice, 2); ViewBag.Price = totalPrice; dao.UpdateCartCost(email, totalPrice); if (Businesslogic.Mod10Check(creditcardnumber) == true) { count = dao.AddTransaction(Session.SessionID + count, email, DateTime.Now, totalPrice); if (count > 0) //if the transaction is successfully placed, then the cart status is changed and a new cart is created for this customer { count1 = dao.UpdateCartAfterSuccessfulTransaction(email, DateTime.Now); if (count1 > 0) { count2 = dao.CreateCartAfterSuccessfulTransaction(email); if (count2 > 0) { ViewBag.Status = "Order succesfully placed, we'll be in touch!"; } else { ViewBag.Status = "Error!" + dao.message; } } else { ViewBag.Status = "Error!" + dao.message; } } } else { ViewBag.Status = "You have not entered a valid credit card number"; } return(View("Status")); }
protected void BindGridData() { GridView1.DataSource = Businesslogic.list(); GridView1.DataBind(); }
internal void MessageReceived(ReceiptEvent receiptEvent) { tsStatusLabel.Text = "Received " + receiptEvent.user_id + " " + Businesslogic.UnixTimeStampToDateTime(receiptEvent.ts).ToString(); }
public ActionResult Index(string id) { Businesslogic bl = new Businesslogic(); if (id == null) { ViewBag.guid = bl.GetGuid(); var x = bl.GetGalleryType(); ViewBag.gallery = bl.GetGalleryType(); return(View()); } else { var guid = id; var password = Request["password"]; Logic.Message.Settings settings; string viewName = ""; if (password != null) { settings = bl.GetSettings(guid); if (settings == null) { return(Content("<h1>page does not exist</h1>")); } ViewBag.guid = guid; if (settings.password == password) { viewName = bl.GetGalleryViewName(guid); ViewBag.images = bl.GetImages(guid); ViewBag.settings = settings; return(View("../Home/Gallery/" + viewName)); } else { return(View("Login")); } } else { ViewBag.guid = guid; settings = bl.GetSettings(id); if (settings == null) { return(Content("<h1>page does not exist</h1>")); } if (settings.isPassword == true) { return(View("Login")); } else { viewName = bl.GetGalleryViewName(guid); ViewBag.images = bl.GetImages(guid); ViewBag.settings = settings; return(View("../Home/Gallery/" + viewName)); } } } }
private void SyncCompletedCallback(MatrixSyncResult matrixSyncResult, bool initSync) { if (matrixSyncResult != null) { if (!initSync) { // raise notifications for messages closed room-windows foreach (KeyValuePair <string, MatrixSyncResultTimelineWrapper> messagesForRoomID in matrixSyncResult.rooms.join) { Console.WriteLine("syncCompletedCallback()"); string roomID = messagesForRoomID.Key; bool skip = false; foreach (Form form in Application.OpenForms) { if (form is Chat) { Chat chat = (Chat)form; if (chat.MatrixRoom.roomID == messagesForRoomID.Key) { // skip notifcation because window is open skip = true; break; } } } if (skip) { continue; } MatrixSyncResultTimelineWrapper wrapper = messagesForRoomID.Value; foreach (MatrixSyncResultEvents events in wrapper.timeline.events) { string sender = String.Format("{0}", Businesslogic.MatrixUsernameToShortUsername(events.sender)); int timeout = 3000; string message = ""; if (events.content.msgtype == "m.text") { if (events.content.format == "org.matrix.custom.html") { } else { timeout = calcTimeoutFromWords(events.content.body); message = events.content.body; } } if (events.content.msgtype == "m.image") { message = "new image received"; } Notification n = new Notification(timeout, sender, message); // todo: loop through matrixrooms in businesslogic and resolve there. note: Businesslogic.Instance.roomCache does not contain MatrixRooms foreach (MatrixRoom m in matrixRooms) { if (m.roomID == roomID) { //found n.Tag = m; break; } } n.NotificationClickedEvent += NotificationClickedCallback; // todo: howto/when unsubscribe? n.Show(); } } } // show messages (in chat history) in openend room-windows foreach (Form form in Application.OpenForms) { if (form is Chat) { Chat chat = (Chat)form; Console.WriteLine(chat.MatrixRoom.roomID); foreach (ChatMessage chatMessage in Businesslogic.Instance.chatMessages) { if (chat.MatrixRoom.roomID == chatMessage.RoomID && !chatMessage.Displayed) { chatMessage.Displayed = true; Console.WriteLine(String.Format("displaying message from {0} for room {1}: {2}", chatMessage.Sender, chat.MatrixRoom.roomID, chatMessage.Message)); //unencrypted chat.processIncomingChatMessage(chatMessage.Sender, chatMessage.Message); } } } } } Businesslogic.Instance.sync(); }
protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataSource = Businesslogic.list(); GridView1.DataBind(); }