public JsonResult GetAllPO(string status) { dnbmssqlEntities db = new dnbmssqlEntities(); UserManager <User> userManager = new UserManager <User>(new UserStore <User>(new ApplicationDbContext())); var currentUser = User.Identity.Name.Substring(0, 6); var currentRegion = User.Identity.Name.Substring(6, 3); if (status == "Available") { var QQList = db.poes.Where(s => s.sid.Equals(currentUser) && s.region.Equals(currentRegion)) .Where(s => s.filestatus.Equals("Available") || s.filestatus.Equals("Updated")) .OrderBy(s => s.released); return(Json(QQList, JsonRequestBehavior.AllowGet)); } else if (status == "Downloaded") { var QQList = db.poes.Where(s => s.sid.Equals(currentUser) && s.region.Equals(currentRegion) && s.filestatus.Equals("Downloaded")) .OrderBy(s => s.released); return(Json(QQList, JsonRequestBehavior.AllowGet)); } else if (status == "Expired") { var QQList = db.ar_po.Where(s => s.sid.Equals(currentUser) && s.region.Equals(currentRegion)); return(Json(QQList, JsonRequestBehavior.AllowGet)); } else { return(Json(null, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetAllRanking(string status) { dnbmssqlEntities db = new dnbmssqlEntities(); var currentUser = User.Identity.Name; if (status == "Requested") { var QQList = db.reqlists.Where(s => s.sid.Equals(currentUser)) .Where(s => s.sts.Equals("process") || s.sts.Equals("processing") || s.sts.Equals("processed")) .OrderByDescending(s => s.dreq); return(Json(QQList, JsonRequestBehavior.AllowGet)); } else if (status == "Downloaded") { var QQList = db.reqlists.Where(s => s.sid.Equals(currentUser) && s.sts.Equals("downloaded")).OrderByDescending(s => s.dreq); return(Json(QQList, JsonRequestBehavior.AllowGet)); } else if (status == "Expired") { var QQList = db.ar_reqlist.Where(s => s.sid.Equals(currentUser)).OrderByDescending(s => s.dreq); return(Json(QQList, JsonRequestBehavior.AllowGet)); } else { return(Json(null, JsonRequestBehavior.AllowGet)); } }
private void deleteOldPDF(string date) { dnbmssqlEntities db = new dnbmssqlEntities(); var expdate = Convert.ToDateTime(date).AddDays(-7); var yeExp = expdate.ToString("yyyyMMdd"); var result = db.ar_po.Where(s => s.expiration.Equals(date)).ToList <ar_po>(); var xftp = new ftp(@"ftp://188.121.43.20/services.danubeco.com/supplier/", ""); foreach (var item in result) { try { xftp.delete(Path.GetFileName(item.link)); _sysLog("FTP File " + item + " : deleted..", Color.Green, StatusType.Sys); } catch (Exception) { _sysLog("FTP File " + item + " : error..", Color.Red, StatusType.Err); } } }
public JsonResult GetSupplierCombiAll() { var db = new dnbmssqlEntities(); var QQList = db.supplierregions.ToList(); return(Json(QQList, JsonRequestBehavior.AllowGet)); }
public int _getAllDept() { var db = new dnbmssqlEntities(); var DeptRequests = db.ViewRankingDeptRequests.ToList(); return(DeptRequests.Count()); }
public int _getAllSku() { var db = new dnbmssqlEntities(); var SkuRequests = db.ViewRankingSKURequests.ToList(); return(SkuRequests.Count()); }
public int _getAllBrand() { var db = new dnbmssqlEntities(); var brandList = db.ViewRankingBrandRequests.ToList(); return(brandList.Count()); }
public async Task <bool> AddSupplier(rX supplier) { var db = new dnbmssqlEntities(); NullFiller.FillNullFields <rX>(supplier); Capitalize.UppercaseClassFields <rX>(supplier); // Supplier Login var username = supplier.idd + supplier.region; var sup_user = db.C_User.FirstOrDefault(s => s.UserName.Equals(username)); if (sup_user == null) { var user = new User { UserName = username, Email = username + "@danubeco.com", Region = supplier.region }; try { var result = await UserManager.CreateAsync(user, supplier.password); if (!result.Succeeded) { return(false); } else { SupplierInfo(supplier); return(true); } } catch (Exception) { return(false); } } else { var user = await UserManager.FindByIdAsync(sup_user.UserId); user.PasswordHash = UserManager.PasswordHasher.HashPassword(supplier.password); await UserManager.UpdateAsync(user); SupplierInfo(supplier); return(true); } }
private void Bg_DoWork() { dnbmssqlEntities db = new dnbmssqlEntities(); var result = Convert.ToBoolean(db.sppoarchive(label1.Text)); if (!result) { _sysLog("No archive..", Color.Green, StatusType.Sys); } else { deleteOldPDF(label1.Text); } }
public string _GenerateId(string table) { try { using (var ctx = new dnbmssqlEntities()) { var result = ctx.Database.SqlQuery <int>("select Id from " + table + " order by Id desc").FirstOrDefault(); return(Convert.ToString(result + 1)); } } catch { return("1"); } }
public static void Log(string msg, string action, string user) { dnbmssqlEntities db = new dnbmssqlEntities(); var newObj = new syssuplog { userid = user, sysaction = msg, sysdate = DateTime.Now.ToString(), status = action }; db.syssuplogs.Add(newObj); db.SaveChanges(); }
private void sysLog(string msg, string action) { dnbmssqlEntities db = new dnbmssqlEntities(); var newObj = new syssuplog { userid = User.Identity.GetUserId(), sysaction = msg, sysdate = DateTime.Now.ToString(), status = action }; db.syssuplogs.Add(newObj); db.SaveChanges(); }
public OperationResult _getReqSList(string rStatus) { OperationResult op = new OperationResult(); try { var db = new dnbmssqlEntities(); var reqQQ = db.reqlists.Where(s => s.sts.Equals(rStatus) && s.rtype.Equals("sku")); var reqCnt = reqQQ.Count(); if (reqCnt.Equals(0)) { op.Success = false; return(op); } foreach (var item in reqQQ) { var objreq = db.ViewRankingSKURequests.FirstOrDefault(s => s.reqid.Equals(item.reqid)); new CSV().CreateCSV(new string[] { "002", objreq.sid.Substring(6, 3), "SKU", objreq.sid.Substring(0, 6), objreq.ffrom.Replace("-", ""), objreq.tto.Replace("-", ""), objreq.reqid, item.reqid.Substring(19, Convert.ToInt32(objreq.reqid.Length - 19)), objreq.dreq.Replace("-", ""), DateTime.Now.ToString("HH:mm:ss").Replace(":", ""), "0", "0", "0", "0", "0", objreq.sku1 }); item.sts = "processing"; } db.SaveChanges(); db.Dispose(); op.Success = true; op.AddMessage(reqCnt + " sku has been created"); return(op); } catch (Exception ex) { op.Success = false; op.AddMessage(ex.Message.ToString()); return(op); } }
public bool SubmitPO(string pono) { dnbmssqlEntities db = new dnbmssqlEntities(); UserManager <User> userManager = new UserManager <User>(new UserStore <User>(new ApplicationDbContext())); var currentUser = User.Identity.Name.Substring(0, 6); var objPO = db.poes.Where(e => e.sid.Equals(currentUser) && e.pono.Contains(pono)).FirstOrDefault(); objPO.filestatus = "Downloaded"; db.SaveChanges(); sysLog("Download PO : " + pono, "Purchasing Order"); return(true); }
public async Task <bool> Login(nLoginViewModel model) { try { var result = await SignInManager.PasswordSignInAsync(model.Username, model.Password, false, false); switch (result) { case SignInStatus.Success: var user = await UserManager.FindByNameAsync(model.Username); var getL = user.UserName.Length - 3; if (user.UserName.Substring(getL, 3) == model.Region) { var db = new dnbmssqlEntities(); var getSTatus = db.userapps.FirstOrDefault(s => s.userid.Equals(model.Username)).status; if (getSTatus.Equals("deactivated")) { return(false); } else { return(true); } } else { ModelState.AddModelError("", "Invalid region."); return(false); } default: ModelState.AddModelError("", "Invalid login attempt."); return(false); } } catch (Exception) { return(false); } }
public ActionResult PO() { dnbmssqlEntities db = new dnbmssqlEntities(); var reg = User.Identity.GetUserName().Substring(6, 3); var id = User.Identity.GetUserName().Substring(0, 6); var getall = db.poes.Where(s => s.sid.Equals(id) && s.region.Equals(reg)); ViewBag.POA = getall.Where(s => s.filestatus.Equals("Available")).Count(); ViewBag.POD = getall.Where(s => s.filestatus.Equals("Downloaded")).Count(); var getallar = db.ar_po.Where(s => s.sid.Equals(id) && s.region.Equals(reg)); ViewBag.POE = getallar.Count(); return(View()); }
private void Bg_DoWork() { dnbmssqlEntities db = new dnbmssqlEntities(); var smslist = db.sms.Distinct().ToList <sm>(); foreach (var item in smslist) { var supp = item.sid + "-" + item.region; try { var msg = supp + " : you have approved P.O. dated : " + DateTime.Now.ToString("yyyy-MM-dd") + " Visit http://services.danubeco.com for more info. Thank you!"; var result = new SMS().SendSMS(msg, item.icurrent); _sysLog(supp + result.MessageList[0].ToString(), Color.Violet, StatusType.Sys); } catch { _sysLog(supp + " error in sending SMS", Color.Red, StatusType.Err); } item.status = "Sent"; smsList.Add(item); } db.SaveChanges(); var smsArch = Convert.ToBoolean(db.spsmsarchive()); if (smsArch) { _sysLog("SMS archived..", Color.Green, StatusType.Sys); } else { _sysLog("SMS error..", Color.Red, StatusType.Sys); } }
public async Task <bool> SwitchRegionProcess(userX userX) { SignInManager.AuthenticationManager.SignOut(); var result = await SignInManager.PasswordSignInAsync(userX.username, userX.password, false, false); switch (result) { case SignInStatus.Success: var user = await UserManager.FindByNameAsync(userX.username); var getL = user.UserName.Length - 3; if (user.UserName.Substring(getL, 3) == userX.region) { var db = new dnbmssqlEntities(); var getSTatus = db.userapps.FirstOrDefault(s => s.userid.Equals(userX.username)).status; if (getSTatus.Equals("deactivated")) { return(false); } else { return(true); } } else { ModelState.AddModelError("", "Invalid region."); return(false); } default: ModelState.AddModelError("", "Invalid login attempt."); return(false); } }
private void processValidation() { dnbmssqlEntities db = new dnbmssqlEntities(); var smslist = db.suppliermobileactivtions.Distinct().ToList(); foreach (var item in smslist.Where(s => s.status.Equals("pending"))) { try { var sms = new xSms().GetCode(6); item.codesms = sms; item.datetimesent = string.Format("{0:dd-MM-yyyy hh:mm:ss}", DateTime.Now); var msg = "Requested an activation code " + sms + " for mobile registration."; var result = new SMS().SendSMS(msg, item.mobile); if (result.Success) { RichTxt(rtBox, item.mobile + " : " + sms + " : success.", Color.Green); item.status = "request"; } else { RichTxt(rtBox, item.mobile + " : " + sms + " : error csms.", Color.Red); item.status = "error"; } } catch { RichTxt(rtBox, item.mobile + " : error.", Color.Red); } } db.SaveChanges(); }
public void ProcessParallelThread() { // Get all PDF -> _mdr var Files = FolderPO.GetAllFile(FolderPO.tmpFolder, "pdf"); dnbmssqlEntities db = new dnbmssqlEntities(); foreach (var xFile in Files) { try { #region Convert FileInfo to PDF Object // Split PDF Filename into Object var pdf = SplitPdf(xFile); #endregion #region FTP Processes // Set ftp values var ftp = new ftp(@"ftp://188.121.43.20/services.danubeco.com/", "supplier"); // Upload PDF using FTP to Server Folder -> supplierx var result = ftp.Upload(Path.Combine("supplier", xFile.Name), Path.Combine(FolderPO.tmpFolder, xFile.Name)); if (result.Success) { #region Set PO Object // ----------------------------------------------- PO --------------------------------------------------------- var newPO = new po { sid = pdf.sid, pono = pdf.pono, region = pdf.region, location = pdf.location, division = pdf.division, link = xFile.Name, filestatus = "Available", released = DateTime.Now.ToString("yyyy-MM-dd"), expiration = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd"), isexpired = "no" }; #endregion #region Store PO Object in Database var isExist = db.poes.FirstOrDefault(p => p.pono.Equals(newPO.pono)); if (isExist != null) { isExist.filestatus = "Updated"; isExist.link = newPO.link; } else { db.poes.Add(newPO); } #endregion #region Set SMS // ----------------------------------------------- SMS --------------------------------------------------------- var isExists = db.sms.FirstOrDefault(x => x.sid.Equals(newPO.sid) && x.region.Equals(newPO.region)); if (isExists == null) { var user = db.supplierregions.FirstOrDefault(s => s.sid.Equals(newPO.sid) && s.region.Equals(newPO.region)); if (user != null) { if (user.sms.Equals("y")) { db.sms.Add(new sm { sid = newPO.sid, region = newPO.region, icurrent = user.mobile, timesent = DateTime.Now.ToString(), status = "waiting" }); } } } #endregion #region Store & Backup File + Log // save changes to Database db.SaveChanges(); // move files to backup folder FolderPO.moveToBckFolder(xFile); // write log ni rtbox updateLog(xFile, "Success", Color.Green); #endregion } else { #region Backup File + Log // move to error folder FolderPO.moveToErrFolder(xFile); updateLog(xFile, "ErrorFTP", Color.Red); #endregion } #endregion } catch (Exception ex) { // move to error folder FolderPO.moveToErrFolder(xFile); updateLog(xFile, "ErrorFile" + ex.Message, Color.Red); } } }