public static ReturnData SendMultipleEmail(List <string> receiver, string subject, string body, string attachmentPath) { try { DataClassesDataContext db = new DataClassesDataContext(); string sender = db.TBConfigurations.Where(x => x.Name == "email_user").FirstOrDefault().Value; dynamic dd = OurClass.DecryptPassword(db.TBConfigurations.Where(x => x.Name == "email_password").FirstOrDefault().Value); string passEmail = OurClass.DecryptPassword(db.TBConfigurations.Where(x => x.Name == "email_password").FirstOrDefault().Value); string smtpHost = db.TBConfigurations.Where(x => x.Name == "email_smtp_client").FirstOrDefault().Value; int smtpPort = int.Parse(db.TBConfigurations.Where(x => x.Name == "email_smtp_port").FirstOrDefault().Value); MailMessage msg = new MailMessage(); msg.From = new MailAddress(sender, System.Configuration.ConfigurationManager.AppSettings["Title"]); foreach (var emailAddr in receiver) { msg.To.Add(new MailAddress(emailAddr)); } msg.Subject = subject; msg.Body = body; msg.IsBodyHtml = true; if (attachmentPath != "") { msg.Attachments.Add(new Attachment(attachmentPath)); } SmtpClient smtp = new SmtpClient(smtpHost, smtpPort); smtp.Credentials = new NetworkCredential(sender, passEmail); smtp.Send(msg); return(ReturnData.MessageSuccess("Email sent", null)); } catch (Exception ex) { return(ReturnData.MessageFailed(ex.Message + " - " + attachmentPath, null)); } }
public IEnumerable <dynamic> Dynamic_GetAll(DataClassesDataContext db) { try { Class_Product _product = new Class_Product(); return(Dynamic_Func_GetAll(db).AsEnumerable().Select(x => new { x.IDCategory, x.IDCategoryParent, ParentName = x.ParentName, Image = OurClass.ImageExists(x.Image, "category") ? x.Image : "noimage.jpg", x.Name, x.Description, x.Active, Child = Dynamic_GetDataBy_IDCategoryParent(db, x.IDCategory), TotalProduct = _product.AJAX_FE_GetTotalProduct_ByIDCategory(x.IDCategory) }).ToArray()); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(null); } }
public Datatable AJAX_GetTable(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search) { try { IEnumerable <dynamic> data = Dynamic_GetAll(); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.Where(x => x.Name.ToLower().Contains(search.ToLower())).ToArray(); } List <Dictionary <string, dynamic> > resultList = new List <Dictionary <string, dynamic> >(); foreach (dynamic currData in data) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("IDRole", currData.IDRole); newData.Add("Name", currData.Name); newData.Add("DateInsert", currData.DateInsert); resultList.Add(newData); } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new WITLibrary.Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public dynamic DYNAMIC_AddToCart_Renew(int idProduct, int idCustomer, int idCustomerProduct) { try { DataClassesDataContext db = new DataClassesDataContext(); Class_Order _Order = new Class_Order(); var dataOrder = db.TBProducts.Where(x => x.IDProduct == idProduct).FirstOrDefault(); //HttpCookie _cookie = HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()]; string anonID = HttpContext.Current.Request.AnonymousID; TBOrder_temp _cookie = _Order.GetEncodedDataOrder(anonID); string _token = ""; Dictionary <string, dynamic> _product = new Dictionary <string, dynamic>(); List <Dictionary <string, dynamic> > _listProduct = new List <Dictionary <string, dynamic> >(); Dictionary <string, dynamic> _tokenData = new Dictionary <string, dynamic>(); TBProduct_Combination productCombination = db.TBProduct_Combinations.Where(x => !x.Deflag && x.IDProduct_Combination == dataOrder.TBProduct_Combinations.FirstOrDefault().IDProduct_Combination).FirstOrDefault(); if (productCombination == null) { return(ReturnData.MessageFailed("Data not found", null)); } _product.Add("IDProduct", dataOrder.IDProduct); _product.Add("IDCombination", dataOrder.TBProduct_Combinations.FirstOrDefault().IDProduct_Combination); _product.Add("Price", dataOrder.Price * 1); _product.Add("CombinationName", dataOrder.TBProduct_Combinations.FirstOrDefault().Name); _product.Add("Quantity", 1); _product.Add("ProductName", dataOrder.Name); _product.Add("PricePerUnit", dataOrder.Price); _product.Add("Weight", productCombination.Weight); _product.Add("WeightPerUnit", productCombination.Weight); _listProduct.Add(_product); _tokenData.Add("Product", _listProduct); _tokenData.Add("TotalPrice", dataOrder.Price); _tokenData.Add("TotalQuantity", 1); _tokenData.Add("TotalWeight", productCombination.Weight); _tokenData.Add("Subtotal", dataOrder.Price); _tokenData.Add("IDCurrency", Class_Currency.GetActiveCurrencyID()); _tokenData.Add("OrderType", "renew"); _tokenData.Add("IDCustomerProduct", idCustomerProduct); _token = OurClass.EncryptToken(_tokenData); //HttpContext.Current.Response.Cookies.Add(new HttpCookie(System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString(), _token)); _Order.SaveEncodeDataOrder(HttpContext.Current.Request.AnonymousID, _token); //HttpContext.Current.Response.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()].Expires = DateTime.Now.AddMinutes(120); return(ReturnData.MessageSuccess("Product add to cart successfully", _tokenData)); //cek cookies nya ada ngga, kalo ada ganti token //kalo ga ada tambahin dulu _witcomcrt_ //cek kalo token nya kosong // kalo ngga kosong, decrypt dulu, ambil object nya. //trus tambahin sama cart yang baru } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public ReturnData AJAX_Delete_Photo(int idPostMedia) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { TBPostMedia _deleteData = GetDetail_Photo(db, idPostMedia); if (_deleteData == null) { return(ReturnData.MessageFailed("The requested resource does not exist.", null)); } string _nameBefore = _deleteData.MediaUrl; db.TBPostMedias.DeleteOnSubmit(_deleteData); db.SubmitChanges(); OurClass.DeleteFile(_deleteData.MediaUrl, "post"); Dictionary <string, dynamic> _result = new Dictionary <string, dynamic>(); _result.Add("Photos", Dynamic_GetData_Photo_ByIDPost(db, _deleteData.IDPost)); return(ReturnData.MessageSuccess(_nameBefore + " has been successfully deleted.", _result)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public IEnumerable <dynamic> Dynamic_GetData_Photo_ByIDPost(DataClassesDataContext db, int idPost) { try { return(Dynamic_Func_GetData_ByIDPost_Photo(db, idPost).AsEnumerable().Select(x => new { x.IDPostMedia, x.IDPost, x.Title, x.Description, Preview = OurClass.ImageExists(x.MediaUrl, "post") ? x.MediaUrl : "noimage.jpg", x.Active, x.Deflag, x.DateInsert, x.DateLastUpdate }).ToArray()); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(null); } }
public Datatable AJAX_GetTableByIDCustomerGroup(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search, int idCustomerGroup) { try { IEnumerable <dynamic> data = Dynamic_GetAll_ByIDCustomerGroup(idCustomerGroup); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.Where(x => x.FirstName.ToLower().Contains(search.ToLower()) || x.LastName.ToLower().Contains(search.ToLower()) || x.Email.ToLower().Contains(search.ToLower()) ).ToArray(); } List <Dictionary <string, dynamic> > resultList = new List <Dictionary <string, dynamic> >(); foreach (dynamic currData in data) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("IDCustomer", currData.IDCustomer); newData.Add("Name", currData.FirstName + ' ' + currData.LastName); newData.Add("Email", currData.Email); newData.Add("Active", currData.Active); newData.Add("PhoneNumber", currData.PhoneNumber); resultList.Add(newData); } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { throw; } }
private void SendEmail2() { //MailMessage msg = new MailMessage(); //msg.From = new MailAddress("*****@*****.**", System.Configuration.ConfigurationManager.AppSettings["Title"]); //msg.To.Add(new MailAddress("*****@*****.**")); //msg.Subject = "asdasdasd"; //msg.Body = "testing email"; //msg.IsBodyHtml = true; ////SmtpClient smtp = new SmtpClient("mail.wit.co.id", 25); ////smtp.Credentials = new NetworkCredential("*****@*****.**", "Rikki12345"); //SmtpClient smtp = new SmtpClient("mail.wit.co.id", 25); //smtp.Credentials = new NetworkCredential("*****@*****.**", "Rikki12345"); ////smtp.UseDefaultCredentials = false; //smtp.EnableSsl = false; //smtp.Send(msg); //SEND EMAIL Class_Configuration _config = new Class_Configuration(); var emailLogo = _config.Dynamic_Get_EmailLogo(); using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-register.html"))) { string body = ""; body = reader.ReadToEnd(); body = body.Replace("{name}", "Rikki Novar"); body = body.Replace("{email}", "*****@*****.**"); body = body.Replace("{password}", "asdasd"); body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]); body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo); body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]); Response.Write(OurClass.SendEmail("*****@*****.**", WebConfigurationManager.AppSettings["Title"] + " Account Registration", body, "").message); } }
public static int CheckCurrencyCart() { Class_Order _order = new Class_Order(); string anonID = HttpContext.Current.Request.AnonymousID; TBOrder_temp _cookie = _order.GetEncodedDataOrder(anonID); string _token = ""; if (_cookie == null) { return(0); } else { _token = _cookie.EncodedData; dynamic tmp = (OurClass.DecryptToken(_token) as IDictionary <string, dynamic>); if ((tmp as Dictionary <string, dynamic>).ContainsKey("IDCurrency")) { return(tmp["IDCurrency"]); } else { return(0); } } }
protected void Page_Load(object sender, EventArgs e) { DataClassesDataContext db = new DataClassesDataContext(); var delprods = db.TBProducts.Where(x => x.Deflag); int count = 0; foreach (var item in delprods) { var imageprods = db.TBProduct_Photos.Where(x => x.IDProduct == item.IDProduct); var checkProds = db.TBProducts.Where(x => !x.Deflag && x.Name.ToLower() == item.Name.ToLower()); if (checkProds == null) { Response.Write(item.Name + " (This Product is Still Active) <br/>"); } else { foreach (var image in imageprods) { Response.Write(image.Photo + "<br/>"); OurClass.DeleteFile(image.Photo, "product"); count++; var combFoto = db.TBProduct_Combination_Photos.Where(x => x.IDProduct_Photo == image.IDProduct_Photo); db.TBProduct_Combination_Photos.DeleteAllOnSubmit(combFoto); db.SubmitChanges(); db.TBProduct_Photos.DeleteOnSubmit(image); db.SubmitChanges(); } } } Response.Write(count + " Image Product Deleted"); }
public ReturnData AJAX_SaveShippingToCart(int idShipping) { try { //var cartCookies = HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()]; Class_Order order = new Class_Order(); var cartCookies = order.GetEncodedDataOrder(HttpContext.Current.Request.AnonymousID); if (cartCookies == null) { return(ReturnData.MessageFailed("Invalid token", null)); } DataClassesDataContext db = new DataClassesDataContext(); Class_Shipping shipping = new Class_Shipping(); var token = cartCookies.EncodedData; dynamic CartData = OurClass.DecryptToken(token); dynamic address = CartData["DeliveryAddress"]; int idDistrict = address["IDDistrict"]; dynamic shippingData = shipping.Dynamic_GetShipping_ByIDShipping(idShipping); dynamic resultShipping = new Dictionary <string, dynamic>(); decimal totalPrice = 0; decimal price = 0; totalPrice = Class_Currency.GetPriceConversionCurrency(shippingData.Price * Math.Ceiling((decimal)CartData["TotalWeight"])); price = Class_Currency.GetPriceConversionCurrency(shippingData.Price); if (CartData["TotalWeight"] < 1) { totalPrice = Class_Currency.GetPriceConversionCurrency(shippingData.Price); } resultShipping["IDCarrier"] = shippingData.IDCarrier; resultShipping["IDShipping"] = shippingData.IDShipping; resultShipping["IDDistrict"] = shippingData.IDDistrict; resultShipping["Image"] = shippingData.Image; resultShipping["Name"] = shippingData.Name; resultShipping["Price"] = price; resultShipping["Information"] = shippingData.Information; resultShipping["TotalPrice"] = totalPrice; CartData["Shipping"] = resultShipping; token = OurClass.EncryptToken(CartData); //HttpContext.Current.Response.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieCart"].ToString()].Value = token; order.SaveEncodeDataOrder(HttpContext.Current.Request.AnonymousID, token); return(ReturnData.MessageSuccess("OK", CartData)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public ReturnData AJAX_Insert_Photo(int idPage, HttpPostedFile file) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { dynamic _page = Dynamic_GetDetail_Information(db, idPage); if (_page == null) { return(ReturnData.MessageFailed("The requested resource does not exist.", null)); } List <TBPageMedia> _renameFile = GetData_Photo_ByIDPage(db, idPage).ToList(); for (int i = 0; i < _renameFile.Count; i++) { string oldPhoto = _renameFile[i].MediaUrl; _renameFile[i].MediaUrl = ((string)_page.Page_Title).ToLower().Replace(" ", "-") + "-" + (i + 1).ToString() + WITLibrary.ConvertCustom.GetExtention(oldPhoto); if (OurClass.ImageExists(oldPhoto, "page")) { System.IO.File.Move(HttpContext.Current.Server.MapPath("~/assets/images/page/" + oldPhoto), HttpContext.Current.Server.MapPath("~/assets/images/page/" + _renameFile[i].MediaUrl)); } } int fileSizeInBytes = file.ContentLength; string fileName = file.FileName; string fileExtension = System.IO.Path.GetExtension(fileName); TBPageMedia _newData = new TBPageMedia { IDPage = idPage, Cover = (_renameFile.Where(x => x.Cover).Count() == 0) ? true : false, MediaUrl = ((string)_page.Page_Title).ToLower().Replace(" ", "-") + "-" + (_renameFile.Count() + 1).ToString() + fileExtension, Active = true, DateInsert = DateTime.Now, DateLastUpdate = DateTime.Now, }; db.TBPageMedias.InsertOnSubmit(_newData); db.SubmitChanges(); if (_newData != null) { file.SaveAs(HttpContext.Current.Server.MapPath("/assets/images/page/" + _newData.MediaUrl)); return(ReturnData.MessageSuccess(fileName + " for this product has been successfully uploaded.", null)); } return(ReturnData.MessageFailed(fileName + " for this product failed to upload.", null)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public ReturnData AJAX_Insert(string baseImage, string fnImage, string name, string email, string phone, string address, string description, bool active) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { if (!ValidationInsert_Name(db, name)) { return(ReturnData.MessageFailed(name + " already exists.", null)); } TBManufacturer _newData = new TBManufacturer { Logo = WITLibrary.ConvertCustom.GetExtention(fnImage), Name = name, Email = email, Phone = phone, Address = address, ShortDescription = OurClass.ShortDescription(description, 250), Description = description, Active = active, Deflag = false, DateInsert = DateTime.Now, DateLastUpdate = DateTime.Now }; db.TBManufacturers.InsertOnSubmit(_newData); db.SubmitChanges(); if (_newData != null) { if (baseImage != "" && fnImage != "") { System.Drawing.Image _image = WITLibrary.ConvertCustom.Base64ToImage(baseImage); _image.Save(HttpContext.Current.Server.MapPath("/assets/images/manufacturer/" + _newData.IDManufacturer + _newData.Logo)); _newData.Logo = _newData.IDManufacturer + _newData.Logo; db.SubmitChanges(); } if (_newData != null) { return(ReturnData.MessageSuccess(name + " has been successfully inserted.", null)); } return(ReturnData.MessageFailed(name + " failed to insert.", null)); } return(ReturnData.MessageFailed(name + " failed to insert.", null)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public Datatable AJAX_GetTable_Log_Stock_filter(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search, DateTime startDate, DateTime endDate) { try { DataClassesDataContext db = new DataClassesDataContext(); var datamentah = db.TBLog_Stocks.Where(x => x.InsertDate >= startDate && x.InsertDate <= endDate).ToArray(); //dynamic[] data = db.SP_Report_GetCategoryDistribution(startDate, endDate).ToArray(); dynamic[] data = datamentah; int count = data.Count(); int number = 1; if (!string.IsNullOrEmpty(search)) { data = data.AsEnumerable().Where(x => x.TBEmployee.Name.ToLower().Contains(search.ToLower()) || x.ProductName.ToLower().Contains(search.ToLower()) || x.Description.ToLower().Contains(search.ToLower()) ).ToArray(); } Dictionary <string, dynamic>[] resultList = new Dictionary <string, dynamic> [data.Count()]; for (int i = 0; i < data.Count(); i++) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("Number", number); newData.Add("EmployeeName", data[i].TBEmployee == null ? "" : data[i].TBEmployee.Name); newData.Add("ProductName", data[i].ProductName); newData.Add("Type", data[i].Type); newData.Add("Description", data[i].Description); newData.Add("Quantity", data[i].Quantity); newData.Add("QuantityBefore", data[i].InitialQuantity); newData.Add("QuantityAfter", data[i].LastQuantity); newData.Add("InsertDate", data[i].InsertDate); number += 1; resultList[i] = newData; } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public ReturnData AJAX_Update(int idManufacturer, string baseImage, string fnImage, string name, string email, string phone, string address, string description, bool active) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { if (!ValidationName_Update(db, idManufacturer, name)) { return(ReturnData.MessageFailed(name + " already exists.", null)); } TBManufacturer _updateData = GetDetail(db, idManufacturer); if (_updateData == null) { return(ReturnData.MessageFailed("The requested resource does not exist.", null)); } string _nameBefore = _updateData.Name; _updateData.Logo = _updateData.IDManufacturer.ToString() + WITLibrary.ConvertCustom.GetExtention(fnImage); _updateData.Name = name; _updateData.Email = email; _updateData.Phone = phone; _updateData.Address = address; _updateData.ShortDescription = OurClass.ShortDescription(description, 250); _updateData.Description = description; _updateData.Active = active; _updateData.DateLastUpdate = DateTime.Now; if (baseImage != "" && fnImage != "") { System.Drawing.Image _image = WITLibrary.ConvertCustom.Base64ToImage(baseImage); _image.Save(HttpContext.Current.Server.MapPath("/assets/images/manufacturer/" + _updateData.Logo)); } db.SubmitChanges(); if (_updateData != null) { return(ReturnData.MessageSuccess(_nameBefore + " has been successfully updated.", null)); } return(ReturnData.MessageFailed(_nameBefore + " failed to update.", null)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public ReturnData AJAX_Forget_Password(string email) { try { DataClassesDataContext db = new DataClassesDataContext(); if (IsExistsEmail(email)) { var emp = db.TBEmployees.Where(x => !x.Deflag && x.Email == email).FirstOrDefault(); if (emp != null) { string text = email + "-" + emp.Name.Substring(0, 2); string token = this.EncryptPassword(text); int aa = token.Length; string pass = EncryptToken(email, DateTime.Now.ToString("MMddHHmmss")); aa = pass.Length; emp.Password = pass; db.SubmitChanges(); //SEND EMAIL using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-forgot-password.html"))) { Class_Configuration _config = new Class_Configuration(); var emailLogo = _config.Dynamic_Get_EmailLogo(); string body = ""; body = reader.ReadToEnd(); body = body.Replace("{name}", emp.Name); body = body.Replace("{Url}", WebConfigurationManager.AppSettings["url"].ToString() + "/adminwitcommerce/reset-password.aspx?token=" + emp.Password); body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]); body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo); body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]); OurClass.SendEmail(emp.Email, WebConfigurationManager.AppSettings["Title"] + " Reset Password", body, ""); } return(ReturnData.MessageSuccess("Reset password link has been sent to your email, please check your inbox or spam folder.", null)); } return(ReturnData.MessageSuccess("Employee Not Found", null)); } else { return(ReturnData.MessageSuccess("Your email has not registered as Employee", null)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public Datatable AJAX_GetTable_Log_Order(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search) { try { DataClassesDataContext db = new DataClassesDataContext(); DateTime startDate = db.TBOrders.FirstOrDefault().DateInsert; dynamic[] data = db.TBLog_Orders.ToArray(); int count = data.Count(); int number = 1; if (!string.IsNullOrEmpty(search)) { data = data.AsEnumerable().Where(x => x.TBEmployee.Name.ToLower().Contains(search.ToLower()) || x.Reference.ToLower().Contains(search.ToLower()) || x.Description.ToLower().Contains(search.ToLower()) ).ToArray(); } Dictionary <string, dynamic>[] resultList = new Dictionary <string, dynamic> [data.Count()]; for (int i = 0; i < data.Count(); i++) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("Number", number); newData.Add("EmployeeName", data[i].TBEmployee == null ? "" : data[i].TBEmployee.Name); newData.Add("Reference", data[i].Reference); newData.Add("Customer", data[i].CustomerName); newData.Add("Status", data[i].OrderStatus); newData.Add("Description", data[i].Description); newData.Add("InsertDate", data[i].DateInsert); number += 1; resultList[i] = newData; } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public Datatable AJAX_GetTable(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search, string idCarrier) { try { DataClassesDataContext db = new DataClassesDataContext(); IEnumerable <dynamic> data = db.TBShippings.Where(X => !X.Deflag && X.IDCarrier.ToString() == idCarrier).Select(x => new { x.IDShipping, x.IDCarrier, x.IDDistrict, x.Price, DistrictName = x.TBDistrict.Name, CityName = x.TBDistrict.TBCity.Name }).ToList(); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.Where(x => x.CityName.ToLower().Contains(search.ToLower()) || x.DistrictName.ToLower().Contains(search.ToLower())).ToArray(); } List <Dictionary <string, dynamic> > resultList = new List <Dictionary <string, dynamic> >(); foreach (dynamic currData in data) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("CityName", currData.CityName); newData.Add("DistrictName", currData.DistrictName); newData.Add("Price", currData.Price); newData.Add("IDShipping", currData.IDShipping); newData.Add("IDCarrier", currData.IDCarrier); newData.Add("IDDistrict", currData.IDDistrict); resultList.Add(newData); } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public ReturnData AJAX_Forget_Password(string email) { try { DataClassesDataContext db = new DataClassesDataContext(); if (IsExistsEmail(email)) { var cust = db.TBCustomers.Where(x => !x.Deflag && x.Email == email).FirstOrDefault(); if (cust != null) { string text = email + "-" + cust.FirstName.Substring(0, 2); string token = this.EncryptPassword(text); int aa = token.Length; string pass = EncryptToken(email, DateTime.Now.ToString("MMddHHmmss")); aa = pass.Length; cust.Password = pass; db.SubmitChanges(); //SEND EMAIL using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-forgot-password.html"))) { Class_Configuration _config = new Class_Configuration(); var emailLogo = _config.Dynamic_Get_EmailLogo(); string body = ""; body = reader.ReadToEnd(); body = body.Replace("{name}", cust.FirstName); body = body.Replace("{Url}", WebConfigurationManager.AppSettings["url"].ToString() + "/reset-password.aspx?token=" + cust.Password); body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]); body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo); body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]); OurClass.SendEmail(cust.Email, WebConfigurationManager.AppSettings["Title"] + " Reset Password", body, ""); } return(ReturnData.MessageSuccess("OK", null)); } return(ReturnData.MessageSuccess("", null)); } else { return(ReturnData.MessageSuccess("", null)); } } catch (Exception ex) { return(ReturnData.MessageFailed(ex.Message, null)); } }
public Datatable AJAX_GetTable(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search) { try { IEnumerable <dynamic> data = Dynamic_GetAll(new DataClassesDataContext()); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.Where(x => x.Name.ToLower().Contains(search.ToLower())).ToArray(); } List <Dictionary <string, dynamic> > resultList = new List <Dictionary <string, dynamic> >(); foreach (dynamic currData in data) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("IDVoucher", currData.IDVoucher); newData.Add("Name", currData.Name); newData.Add("Code", currData.Code); newData.Add("Description", currData.Description); newData.Add("VoucherType", currData.VoucherType); newData.Add("Value", currData.Value); newData.Add("TotalAvailable", currData.TotalAvailable); newData.Add("Used", currData.Used); newData.Add("MinimumAmount", currData.MinimumAmount); newData.Add("StartDate", currData.StartDate); newData.Add("EndDate", currData.EndDate); newData.Add("Active", currData.Active); resultList.Add(newData); } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new WITLibrary.Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public dynamic Dynamic_Get_ShopInformation() { try { DataClassesDataContext db = new DataClassesDataContext(); return(db.TBConfigurations.Where(x => x.Name.Contains("shop_")).Select(x => new { x.Name, Value = (x.Name.Contains("password")) ? OurClass.DecryptPassword(x.Value) : x.Value })); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(null); } }
public Datatable AJAX_GetTable(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search) { try { DataClassesDataContext db = new DataClassesDataContext(); Class_Page_Category _pageCategory = new Class_Page_Category(); IEnumerable <dynamic> data = Dynamic_GetAll(db); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.Where(x => x.Post_Title.ToLower().Contains(search.ToLower())).ToArray(); } List <Dictionary <string, dynamic> > resultList = new List <Dictionary <string, dynamic> >(); foreach (dynamic currData in data) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("IDPost", currData.IDPost); newData.Add("Post_Title", currData.Post_Title); newData.Add("Page_Title", currData.Page_Title); newData.Add("Post_ShortContent", currData.Post_ShortContent); newData.Add("Post_Content", currData.Post_Content); newData.Add("DateInsert", currData.DateInsert.ToString("dd-MM-yyyy") + " " + currData.DateInsert.ToLongTimeString()); newData.Add("DateLastUpdate", currData.DateLastUpdate.ToString("dd-MM-yyyy") + " " + currData.DateLastUpdate.ToLongTimeString()); newData.Add("Active", currData.Active); newData.Add("Categories", Dynamic_GetData_PageCategories_ByIDPost(db, currData.IDPost)); resultList.Add(newData); } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new WITLibrary.Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public Datatable AJAX_GetTable(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search, int idPage) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { IEnumerable <dynamic> data = Dynamic_GetAll(db, idPage).Where(x => !x.Deflag); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.Where(x => x.Name.ToLower().Contains(search.ToLower())).ToArray(); } List <Dictionary <string, dynamic> > resultList = new List <Dictionary <string, dynamic> >(); foreach (dynamic currData in data) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("IDPageCategory", currData.IDPageCategory); newData.Add("IDPage", currData.IDPage); newData.Add("Name", currData.Name); newData.Add("Description", currData.Description); newData.Add("DateInsert", currData.DateInsert.ToString("dd-MM-yyyy") + " " + currData.DateInsert.ToLongTimeString()); newData.Add("DateLastUpdate", currData.DateLastUpdate.ToString("dd-MM-yyyy") + " " + currData.DateLastUpdate.ToLongTimeString()); newData.Add("Deflag", currData.Deflag); resultList.Add(newData); } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new WITLibrary.Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public Datatable AJAX_GetTable_Log_Error(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search) { try { DataClassesDataContext db = new DataClassesDataContext(); dynamic[] data = db.TBLog_Errors.OrderByDescending(x => x.ID).ToArray(); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.AsEnumerable().Where(x => x.TBEmployee.Name.ToLower().Contains(search.ToLower()) || x.ProductName.ToLower().Contains(search.ToLower()) || x.Description.ToLower().Contains(search.ToLower()) ).ToArray(); } Dictionary <string, dynamic>[] resultList = new Dictionary <string, dynamic> [data.Count()]; for (int i = 0; i < data.Count(); i++) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("ID", data[i].ID); newData.Add("Message", data[i].ErrorMessage); newData.Add("StackTrace", data[i].StackTrace); newData.Add("Date", data[i].DateInsert); resultList[i] = newData; } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public Datatable AJAX_GetTable_Monitoring(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search) { try { DataClassesDataContext db = new DataClassesDataContext(); IEnumerable <dynamic> data = Dynamic_GetData_MonitoringStock(); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.Where(x => x.CombinationName.ToLower().Contains(search.ToLower()) || x.ProductName.ToLower().Contains(search.ToLower()) ).ToArray(); } List <Dictionary <string, dynamic> > resultList = new List <Dictionary <string, dynamic> >(); foreach (dynamic currData in data) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("IDProductCombination", currData.IDProduct_Combination); newData.Add("ProductName", currData.ProductName); newData.Add("CombinationName", currData.CombinationName); newData.Add("Quantity", currData.Quantity); newData.Add("ReferenceCode", currData.ReferenceCode); newData.Add("Active", currData.Active); resultList.Add(newData); } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public dynamic Dynamic_GetDetail_Photo(DataClassesDataContext db, int idPostMedia) { try { return(Dynamic_Func_GetDetail_Photo(db, idPostMedia).AsEnumerable().Select(x => new { x.IDPageMedia, x.IDPage, x.MediaUrl, Preview = OurClass.ImageExists(x.MediaUrl, "page") ? x.MediaUrl : "noimage.jpg", x.Cover }).FirstOrDefault()); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(null); } }
public ReturnData AJAX_Update_VeritransConfiguration(dynamic data) { try { //Dictionary<string,dynamic> n = new Dictionary<string,dynamic>(); //n.leng DataClassesDataContext db = new DataClassesDataContext(); //for (int i = 0; i < data.Count; i++) //{ // string name = data[0].Key; //} foreach (var item in data) { string name = item.Key; var row = db.TBConfigurations.Where(x => x.Name == name).FirstOrDefault(); if (row != null) { if (name.Contains("password")) { row.Value = OurClass.EncryptPassword(item.Value); } else { row.Value = item.Value; } row.DateLastUpdate = DateTime.Now; db.SubmitChanges(); } } return(ReturnData.MessageSuccess("OK", null)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public Datatable AJAX_GetTable(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search) { try { DataClassesDataContext db = new DataClassesDataContext(); IEnumerable <dynamic> data = db.TBPayment_Methods.Where(X => !X.Deflag).ToList(); int count = data.Count(); if (!string.IsNullOrEmpty(search)) { data = data.Where(x => x.Name.ToLower().Contains(search.ToLower())).ToArray(); } List <Dictionary <string, dynamic> > resultList = new List <Dictionary <string, dynamic> >(); foreach (dynamic currData in data) { Dictionary <string, dynamic> newData = new Dictionary <string, dynamic>(); newData.Add("IDPaymentMethod", currData.IDPaymentMethod); newData.Add("Name", currData.Name); newData.Add("Bank", currData.Bank); newData.Add("Owner", currData.Owner); newData.Add("AccountNumber", currData.AccountNumber); newData.Add("Description", currData.Description); newData.Add("Image", currData.Image); resultList.Add(newData); } return(OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir)); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(new WITLibrary.Datatable { sEcho = 0, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <Dictionary <string, dynamic> >() }); } }
public dynamic Dynamic_GetData_ByIDProductCombination(dynamic ids) { try { DataClassesDataContext db = new DataClassesDataContext(); List <dynamic> result = new List <dynamic>(); foreach (var item in ids) { int id = (int)item; dynamic data = db.TBOrder_Details.Where(x => x.IDOrder_Detail == id).Select(x => new { ProductName = x.TBProduct.Name, CombinationName = x.TBProduct_Combination.Name, Photo = OurClass.ImageExists(x.TBProduct.TBProduct_Photos.FirstOrDefault(y => y.IsCover).Photo, "product") ? x.TBProduct.TBProduct_Photos.FirstOrDefault(y => y.IsCover).Photo : "noimage.jpg", x.Discount, x.Price, x.Quantity, x.Weight, x.OriginalPrice, TotalDiscount = x.Discount * x.Quantity, TotalPrice = x.OriginalPrice * x.Quantity, Subtotal = (x.OriginalPrice * x.Quantity) - (x.Discount * x.Quantity), x.TBProduct_Combination.ReferenceCode, }).FirstOrDefault(); if (data != null) { result.Add(data); } } return(result); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(null); } }
public IEnumerable <dynamic> Dynamic_GetData_PageMedia(DataClassesDataContext db, int idPost) { try { return(db.TBPostMedias.Where(x => x.IDPost == idPost && !x.Deflag).AsEnumerable().Select(x => new { x.IDPostMedia, x.IDPost, x.Title, Preview = OurClass.ImageExists(x.MediaUrl, "post") ? x.MediaUrl : "noimage.jpg", x.Active, x.Description }).ToArray()); } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(null); } }