public static void Update(FormDataModel form) { MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]); MySqlDataAdapter adapter = new MySqlDataAdapter("Core_UpdateForm", connection); adapter.SelectCommand.CommandType = CommandType.StoredProcedure; MySqlParameter paramID = new MySqlParameter("pID", form.ID); paramID.Direction = ParameterDirection.Input; adapter.SelectCommand.Parameters.Add(paramID); MySqlParameter paramName = new MySqlParameter("pName", form.Name); paramName.Direction = ParameterDirection.Input; adapter.SelectCommand.Parameters.Add(paramName); MySqlParameter paramWorkflowID = new MySqlParameter("pWorkflowID", form.WorkflowID); paramWorkflowID.Direction = ParameterDirection.Input; adapter.SelectCommand.Parameters.Add(paramWorkflowID); DataTable results = new DataTable(); adapter.Fill(results); }
public static List <FormDataModel> GetFormsToAssign() { List <FormDataModel> formsToAssign = new List <FormDataModel>(); string dataString = null; string connString = ConfigurationManager.ConnectionStrings["DFMDBConnectionString"].ConnectionString; //read from config try { using (SqlConnection conn = new SqlConnection(connString)) { String spGetFormsToAssign = @"[dbo].[Proc_Form_GetFormsToAssign]"; SqlCommand cmd = new SqlCommand(spGetFormsToAssign, conn); conn.Open(); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(); while (dr.HasRows && dr.Read()) { dataString = Convert.ToString(dr["FormData"]); FormDataModel data = JsonConvert.DeserializeObject <FormDataModel>(dataString); formsToAssign.Add(data); } dr.Close(); conn.Close(); } } catch (Exception ex) { Console.WriteLine("Exception:" + ex.Message); } return(formsToAssign); }
public FormDataModel Process(string id) { var result = new FormDataModel() { success = true, data = new List <Dictionary <string, string> >() }; if (string.IsNullOrEmpty(id)) { return(result); } var idArr = id.Split('_'); var companyId = Convert.ToInt32(idArr[1]); var dic = new Dictionary <string, string>(); var company = _companyBll.GetCompanyByKey(companyId); dic.Add("CompanyId", company.CompanyId.ToString()); dic.Add("AreaId", company.AreaId.ToString()); dic.Add("CompanyName", company.CompanyName?.ToString()); dic.Add("ArtificialPerson", company.ArtificialPerson?.ToString()); dic.Add("SetUpTime", company.SetUpTime.GetFormatStr()); dic.Add("CompanyPhone", company.CompanyPhone?.ToString()); dic.Add("Address", company.Address?.ToString()); result.data.Add(dic); return(result); }
public async Task <IActionResult> FormData_Delete(int Id) { var model = new FormDataModel(); try { model.Error = await f.FormData_Del(Id); if (model.Error.MessageStatus == "success") { model.Error = null; return(await Task.Run(() => Json(new { isValid = true }))); } else { return(await Task.Run(() => Json(new { isValid = false, message = model.Error.MessageContent, title = model.Error.MessageTitle }))); } } catch (Exception ex) { var r = new ErrorViewModel(); r.MessageContent = ex.ToString(); r.MessageTitle = "Error "; r.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle }))); } }
public static List <FormDataModel> GetAll() { List <FormDataModel> forms = new List <FormDataModel>(); MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]); MySqlDataAdapter adapter = new MySqlDataAdapter("Core_GetForms", connection); DataTable results = new DataTable(); adapter.Fill(results); foreach (DataRow item in results.Rows) { FormDataModel form = new FormDataModel(); if (item["ID"].GetType() != typeof(DBNull)) { form.ID = Convert.ToInt32(item["ID"]); } if (item["Name"].GetType() != typeof(DBNull)) { form.Name = Convert.ToString(item["Name"]); } if (item["WorkflowID"].GetType() != typeof(DBNull)) { form.WorkflowID = Convert.ToInt32(item["WorkflowID"]); } forms.Add(form); } return(forms); }
public async Task <IActionResult> FormData_Search([Bind("idLog,NamaForm,Type,Id,TextLabel,Action,Controller,ValueInput,ListModel,Urutan,ShowHide,ReadOnly,Enable,Mandatory,IsNumber,FilterBy")] FormData data) { var model = new FormDataModel(); var r = new ErrorViewModel(); if (ModelState.IsValid) { try { model.ListData = await f.FormData_GetSearch(data); return(await Task.Run(() => Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "FormData_Table", model) }))); } catch (Exception ex) { r.MessageContent = ex.ToString(); r.MessageTitle = "Error "; r.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; model.Error = r; model.ListData = await f.FormData_Get(); return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle, html = Helper.RenderRazorViewToString(this, "FormData_Table", data) }))); } } else { r.MessageContent = "State Model tidak valid"; r.MessageTitle = "Error "; r.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; model.Error = r; model.ListData = await f.FormData_Get(); return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle, html = Helper.RenderRazorViewToString(this, "FormData_Table", model) }))); } }
public ActionResult <string> Put([FromForm] FormDataModel formData) { ResponseModel response = new ResponseModel(); response.status = "error"; response.content = "Unknown error!"; var slideShowPath = Path.Combine(uploadDirectory, formData.locator); if (formData.locator == "" || formData.locator == null) { response.status = "error"; response.content = "No locator specified!"; } else if (!Directory.Exists(slideShowPath)) { response.status = "error"; response.content = "'" + formData.locator + "' doesn't exist."; } else { response = CreateOrUpdateSlideShow(formData, response, "update"); } var responseJson = JsonConvert.SerializeObject(response); return(responseJson); }
public static List <FormDataModel> GetUserFormDataList(int userId, string formTypename) { List <FormDataModel> formDatas = new List <FormDataModel>(); string dataString = null; string connString = ConfigurationManager.ConnectionStrings["DFMDBConnectionString"].ConnectionString; //read from config try { using (SqlConnection conn = new SqlConnection(connString)) { String spGetUserFormDatas = @"[dbo].[Proc_Form_GetUserFormDatas]"; SqlCommand cmd = new SqlCommand(spGetUserFormDatas, conn); conn.Open(); cmd.CommandType = CommandType.StoredProcedure; SqlParameter param1 = cmd.Parameters.Add("@UserId", SqlDbType.Int); param1.Value = userId; SqlParameter param2 = cmd.Parameters.Add("@FormTypeName", SqlDbType.VarChar); param2.Value = formTypename; SqlDataReader dr = cmd.ExecuteReader(); while (dr.HasRows && dr.Read()) { dataString = Convert.ToString(dr["FormData"]); FormDataModel data = JsonConvert.DeserializeObject <FormDataModel>(dataString); formDatas.Add(data); } dr.Close(); conn.Close(); } } catch (Exception ex) { Console.WriteLine("Exception:" + ex.Message); } return(formDatas); }
public ActionResult Register() { FormDataModel model = new FormDataModel(); model.Cities = db.City.ToList(); return(View(model)); }
public async Task <bool> AppendFormAsync(FormDataModel formData) { string formDataObject = JsonConvert.SerializeObject(formData); SubmissionDataJson dataJson = JsonConvert.DeserializeObject <SubmissionDataJson>(formDataObject); int submitDataId = await _dbService.AddToStagingDBAsync(dataJson); return(true); }
public override void Create(FormDataModel form) { if (HttpContext.Current.Session["ParentID"] != null) { form.WorkflowID = Convert.ToInt32(HttpContext.Current.Session["ParentID"]); } base.Create(form); }
private ResponseModel CreateOrUpdateSlideShow(FormDataModel formData, ResponseModel response, string action) { if (formData.file != null && formData.file.Length > 0) { var locator = ""; if (action == "create") { locator = GetUniqueID16(); } else { locator = formData.locator; } var uniqueFileName = locator + Path.GetExtension(formData.file.FileName); var tempZipFilePath = Path.Combine(uploadDirectory, GetUniqueID16() + ".zip"); var slideShowPath = Path.Combine(uploadDirectory, locator); try { if (Directory.Exists(slideShowPath)) { Directory.Delete(slideShowPath, true); } using (var fileStream = new FileStream(tempZipFilePath, FileMode.Create)) { /*await file.CopyToAsync(fileStream);*/ formData.file.CopyTo(fileStream); } try { ZipFile.ExtractToDirectory(tempZipFilePath, slideShowPath); } catch (Exception e) { response.status = "error"; response.content = "Error extracting zip file in server!"; } if (System.IO.File.Exists(tempZipFilePath)) { System.IO.File.Delete(tempZipFilePath); } response.status = "success"; response.content = locator; } catch (Exception e) { response.status = "error"; response.content = "Error saving or updating! (Cannot find path)"; } } else { response.status = "error"; response.content = "No file provided in request!"; } return(response); }
public static void AddFormData(FormDataModel formData, int userId) { int formId = new int(); int isSelfAssigned = new int(); string formTypeName = formData.FormType; string connString = ConfigurationManager.ConnectionStrings["DFMDBConnectionString"].ConnectionString; try { using (SqlConnection conn = new SqlConnection(connString)) { String spAddFormData1 = @"dbo.[Proc_Form_AddForm]"; String spAddFormData2 = @"dbo.[Proc_Form_AddFormDataWithId]"; SqlCommand cmd1 = new SqlCommand(spAddFormData1, conn); SqlCommand cmd2 = new SqlCommand(spAddFormData2, conn); cmd1.CommandType = CommandType.StoredProcedure; cmd2.CommandType = CommandType.StoredProcedure; conn.Open(); SqlParameter formDataParam1 = cmd1.Parameters.AddWithValue("@FormTypeName", formTypeName); SqlParameter formDataParam2 = cmd1.Parameters.AddWithValue("@CreatedBy", userId); var reader1 = cmd1.ExecuteReader(); while (reader1.Read()) { formId = Convert.ToInt32(reader1["FormID"]); } reader1.NextResult(); while (reader1.Read()) { isSelfAssigned = Convert.ToInt32(reader1["IsSelfAssigned"]); } reader1.Close(); formData.FormId = formId; string jsonFormData = JsonConvert.SerializeObject(formData); SqlParameter formDataParam3 = cmd2.Parameters.AddWithValue("@FormData", jsonFormData); SqlParameter formDataParam4 = cmd2.Parameters.AddWithValue("@FormId", formId); var reader2 = cmd2.ExecuteNonQuery(); conn.Close(); if (isSelfAssigned == 1) { UserFormObjectModel userFormsData = new UserFormObjectModel() { FormId = formId, UserId = userId }; List <UserFormObjectModel> userFormsDatas = new List <UserFormObjectModel>(); userFormsDatas.Add(userFormsData); UserFormsHelper.AddUserFormsData(userFormsDatas); } } } catch (Exception ex) { Console.WriteLine("Exception:" + ex.Message); } }
public ActionResult <string> Post([FromForm] FormDataModel formData) { ResponseModel response = new ResponseModel(); response.status = "error"; response.content = "Unknown error!"; response = CreateOrUpdateSlideShow(formData, response, "create"); var responseJson = JsonConvert.SerializeObject(response); return(responseJson); }
public ActionResult View(int id) { FormDataModel form = FormBO.GetInstance().Get(id); FormUIModel model = new FormUIModel(); model.Name = form.Name; model.Fields = FormdetailBO.GetInstance().GetByForm(id); return(View(model)); }
public virtual void Update(FormDataModel form) { if (form.ID > 0) { FormDAL.Update(form); } else { throw new Exception("Page not found"); } }
public ActionResult Create(FormDataModel form) { FormBO.GetInstance().Create(form); if (Session["ParentID"] != null) { return(RedirectToAction("Index", new { id = Convert.ToInt32(Session["ParentID"]) })); } else { return(RedirectToAction("Index")); } }
public HttpResponseMessage UpdateFormDataApi(FormDataModel formData) { string accessToken = Request.Headers.Authorization.Parameter; if (PermissionHelper.IsUserHasPermission(accessToken, formData.FormType, "Write")) { FormHelper.UpdateFormData(formData); var message = Request.CreateResponse(HttpStatusCode.OK, "Updated"); return(message); } else { throw new Exception("Permission Denied"); } }
public HttpResponseMessage AddFormDataApi(FormDataModel formData) { string accessToken = Request.Headers.Authorization.Parameter; if (PermissionHelper.IsUserHasPermission(accessToken, formData.FormType, "FullAccess")) { UserObjectModel userObj = TokenHelper.getUserByAccessToken(accessToken); FormHelper.AddFormData(formData, userObj.UserId); var message = Request.CreateResponse(HttpStatusCode.Created, "Created"); return(message); } else { throw new Exception("Permission Denied"); } }
public static List <FormDataModel> GetByWorkflow(int id) { List <FormDataModel> forms = new List <FormDataModel>(); MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]); MySqlDataAdapter adapter = new MySqlDataAdapter("Core_GetFormsByWorkflow", connection); MySqlParameter paramID = new MySqlParameter("pID", id); paramID.Direction = ParameterDirection.Input; adapter.SelectCommand.Parameters.Add(paramID); adapter.SelectCommand.CommandType = CommandType.StoredProcedure; DataTable results = new DataTable(); adapter.Fill(results); foreach (DataRow item in results.Rows) { FormDataModel form = new FormDataModel(); if (item["ID"].GetType() != typeof(DBNull)) { form.ID = Convert.ToInt32(item["ID"]); } if (item["Name"].GetType() != typeof(DBNull)) { form.Name = Convert.ToString(item["Name"]); } if (item["WorkflowID"].GetType() != typeof(DBNull)) { form.WorkflowID = Convert.ToInt32(item["WorkflowID"]); } forms.Add(form); } return(forms); }
public ActionResult Register(FormUserData data) { FormDataModel model = new FormDataModel(); if (string.IsNullOrWhiteSpace(data.password1) || data.password1 != data.password2) { model.Cities = db.City.ToList(); if (!string.IsNullOrWhiteSpace(data.city)) { model.villages = db.Village.Where(x => x.CityId == data.city).ToList(); } model.userData = data; ViewBag.Msg = "密碼輸入錯誤"; return(View(model)); } else { try { UserData user = new UserData(); user.account = data.account; user.password = data.password1; user.city = data.city; user.village = data.village; user.address = data.address; db.UserData.Add(user); db.SaveChanges(); Response.Redirect("~/Main/Login"); return(new EmptyResult()); } catch (Exception e) { ViewBag.Msg = e; return(View(model)); } } }
public async Task <IActionResult> FormData() { Config.ConStr = _configuration.GetConnectionString("Db"); var model = new FormDataModel(); try { DeviceDetector.SetVersionTruncation(VersionTruncation.VERSION_TRUNCATION_NONE); BotParser botParser = new BotParser(); var userAgent = Request.Headers["User-Agent"]; var result = DeviceDetector.GetInfoFromUserAgent(userAgent); if (string.IsNullOrEmpty(HttpContext.Session.GetString("_UserId"))) { var model2 = new alertLogin(); return(await Task.Run(() => RedirectToAction("SignIn", "Home", model2))); } else { ViewBag.UserId = HttpContext.Session.GetString("_UserId"); ViewBag.Device = result.Match.DeviceType.ToString(); Console.WriteLine(ViewBag.Device); model.ListData = await f.FormData_Get(); return(await Task.Run(() => View(model))); } } catch (Exception ex) { var Error = new ErrorViewModel(); Error.MessageContent = ex.ToString(); Error.MessageTitle = "Error "; Error.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; model.Error = Error; return(await Task.Run(() => View(model))); } }
public static void UpdateFormData(FormDataModel formData) { string jsonFormData = JsonConvert.SerializeObject(formData); string connString = ConfigurationManager.ConnectionStrings["DFMDBConnectionString"].ConnectionString; try { using (SqlConnection conn = new SqlConnection(connString)) { String spAddFormData1 = @"dbo.[Proc_Form_UpdateFormData]"; SqlCommand cmd1 = new SqlCommand(spAddFormData1, conn); cmd1.CommandType = CommandType.StoredProcedure; conn.Open(); SqlParameter formDataParam1 = cmd1.Parameters.AddWithValue("@FormData", jsonFormData); SqlParameter formDataParam2 = cmd1.Parameters.AddWithValue("@FormId", formData.FormId); var reader1 = cmd1.ExecuteNonQuery(); conn.Close(); } } catch (Exception ex) { Console.WriteLine("Exception:" + ex.Message); } }
public ActionResult <string> Delete([FromForm] FormDataModel formData) { ResponseModel response = new ResponseModel(); response.status = "error"; response.content = "Unknown error!"; var slideShowPath = Path.Combine(uploadDirectory, formData.locator); if (formData.locator == "" || formData.locator == null) { response.status = "error"; response.content = "No locator specified!"; } else if (!Directory.Exists(slideShowPath)) { response.status = "error"; response.content = "'" + formData.locator + "' doesn't exist."; } else { try { Directory.Delete(slideShowPath, true); response.status = "success"; response.content = formData.locator + " removed successfully."; } catch (Exception e) { response.status = "error"; response.content = "Can't delete '" + formData.locator + "': permission denied!."; } } var responseJson = JsonConvert.SerializeObject(response); return(responseJson); }
public virtual void Create(FormDataModel form) { FormDAL.Create(form); }
public IActionResult Index(FormDataModel formDataModel) { Repository.AddFormDataObject(formDataModel); return(View("FormResults", Repository.FormDataObjects)); }
public ActionResult SaveData([FromBody] FormDataModel model) { bool result = true; using (var trans = _ctx.Database.BeginTransaction()) { try { string createdBy = _ctx.AspNetUsers.Where(x => x.DeletedFlag == false && x.CompanyCode == 1).Select(x => x.Id).FirstOrDefault(); int processTypeId = _ctx.CrmProcesse.Select(x => x.Id).FirstOrDefault(); int actionId = _ctx.CrmActions.Where(x => x.ProcessCode == processTypeId && x.LeadStartFlag == true).Select(x => x.Id).FirstOrDefault(); List <CrmLeads> leadsList = new List <CrmLeads>(); int LeadId = _ctx.CrmLeads.Select(x => x.Id).ToList().Max() + 1; int FollowupsId = _ctx.CrmProcessFollowUps.Select(x => x.Id).ToList().Max() + 1; foreach (var item in model.FormData) { if (string.IsNullOrEmpty(item.LeadSubject)) { continue; } // var findLead=_ctx.CrmLeads.Where(x=>x.Subject.ToLowerInvariant()==item.LeadSubject.ToLowerInvariant() &&x.CustomerId) var cus = _ctx.CrmCustomers.FirstOrDefault(x => x.Email == item.CustomerEmail && x.MobileNo == item.CustomerPhone && x.DeletedFlag == false); var findLead = _ctx.CrmLeads.Where(x => x.Subject.ToLowerInvariant() == item.LeadSubject.ToLowerInvariant() && x.CustomerId.ToString() == cus.CustomerId).FirstOrDefault(); if (findLead != null) { continue; } if (cus == null) { cus = new CrmCustomers(); cus.CreatedBy = createdBy; cus.FirstName = item.CustomerName; cus.MobileNo = item.CustomerPhone; cus.Email = item.CustomerEmail; cus.DeletedFlag = false; cus.CreatedDate = DateTime.Now; cus.TagFlag = false; cus.CompanyCode = 1; cus.LastKnownMartialStatus = true; InsertCustomer(cus); } var leads = new CrmLeads(); leads.Id = LeadId; leads.CreatedBy = createdBy; leads.CreatedDate = DateTime.Now; leads.DeletedFlag = false; leads.CustomerId = cus.Id; leads.CompanyCode = 1; leads.ProcessTypeId = processTypeId; leads.LeadValue = "0"; leads.AgentId = Convert.ToInt32(model.AgentId); leads.Rating = Convert.ToInt32(model.RatingId); leads.ProductId = Convert.ToInt32(model.ProductId); leads.Description = item.LeadDescription; leads.CompletionDate = DateTime.Now; leads.LeadDate = DateTime.Now; leads.Subject = item.LeadSubject; leads.CrmProcessFollowUps = new List <CrmProcessFollowUps>() { new CrmProcessFollowUps() { Id = FollowupsId, CreatedBy = createdBy, CreatedDate = DateTime.Now, DeletedFlag = false, ProcessNo = 1, LeadNo = LeadId, ProcessTypeId = processTypeId, AgentId = Convert.ToInt32(model.AgentId), StartDate = DateTime.Now, EstdValue = 0, CompanyCode = 1, ActionId = actionId } }; leadsList.Add(leads); LeadId++; FollowupsId++; } _ctx.CrmLeads.AddRange(leadsList); _ctx.SaveChanges(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } return(Json(result)); }
public async Task <IActionResult> AppendForm([FromBody] FormDataModel formData) { bool result = await _arrService.AppendFormAsync(formData); return(Ok(result)); }
public ActionResult ExcelUpload(StockAuditModel stock1, FormDataModel model) { var file = model.file; var BranchId = model.BranchId; string filePath = string.Empty; var StockBranchModel = Services.StockBranchInventoryService.GetAll(); if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) { string path = Server.MapPath("~/File/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } filePath = path + Path.GetFileName(file.FileName); string extension = Path.GetExtension(file.FileName); file.SaveAs(filePath); string csvData = System.IO.File.ReadAllText(filePath); var stockAuditList = new List <StockAuditModel>(); Dictionary <string, StockAuditModel> dict = new Dictionary <string, StockAuditModel>(); foreach (string row in csvData.Split('\n')) { if (!string.IsNullOrEmpty(row)) { var barcodeString = row.Split(',')[0].Replace("\r", ""); var productBarcode = barcodeString.Substring(0, 10); //stock.Barcode = productBarcode; var size = barcodeString.Substring((barcodeString.Length - 2), 2); var listBarcode = stockAuditList.Any(x => x.Barcode == productBarcode); StockAuditModel temp; dict.TryGetValue(productBarcode, out temp); if (temp != null) { if (size == "01") { temp.Quantity01 += 1; } if (size == "02") { temp.Quantity02 += 1; } if (size == "03") { temp.Quantity03 += 1; } if (size == "04") { temp.Quantity04 += 1; } if (size == "05") { temp.Quantity05 += 1; } if (size == "06") { temp.Quantity06 += 1; } if (size == "07") { temp.Quantity07 += 1; } if (size == "08") { temp.Quantity08 += 1; } if (size == "09") { temp.Quantity09 += 1; } if (size == "10") { temp.Quantity10 += 1; } if (size == "11") { temp.Quantity11 += 1; } if (size == "12") { temp.Quantity12 += 1; } if (size == "13") { temp.Quantity13 += 1; } if (size == "14") { temp.Quantity14 += 1; } if (size == "15") { temp.Quantity15 += 1; } if (size == "16") { temp.Quantity16 += 1; } if (size == "17") { temp.Quantity17 += 1; } if (size == "18") { temp.Quantity18 += 1; } if (size == "19") { temp.Quantity19 += 1; } if (size == "20") { temp.Quantity20 += 1; } if (size == "21") { temp.Quantity21 += 1; } if (size == "22") { temp.Quantity22 += 1; } if (size == "23") { temp.Quantity23 += 1; } if (size == "24") { temp.Quantity24 += 1; } if (size == "25") { temp.Quantity25 += 1; } if (size == "26") { temp.Quantity26 += 1; } if (size == "27") { temp.Quantity27 += 1; } if (size == "28") { temp.Quantity28 += 1; } if (size == "29") { temp.Quantity29 += 1; } if (size == "30") { temp.Quantity30 += 1; } } else { temp = new StockAuditModel(); temp.Quantity01 = 0; temp.Quantity02 = 0; temp.Quantity03 = 0; temp.Quantity04 = 0; temp.Quantity05 = 0; temp.Quantity06 = 0; temp.Quantity07 = 0; temp.Quantity08 = 0; temp.Quantity09 = 0; temp.Quantity10 = 0; temp.Quantity11 = 0; temp.Quantity12 = 0; temp.Quantity13 = 0; temp.Quantity14 = 0; temp.Quantity15 = 0; temp.Quantity16 = 0; temp.Quantity17 = 0; temp.Quantity18 = 0; temp.Quantity19 = 0; temp.Quantity20 = 0; temp.Quantity21 = 0; temp.Quantity22 = 0; temp.Quantity23 = 0; temp.Quantity24 = 0; temp.Quantity25 = 0; temp.Quantity26 = 0; temp.Quantity27 = 0; temp.Quantity28 = 0; temp.Quantity29 = 0; temp.Quantity30 = 0; temp.Barcode = productBarcode; temp.BranchId = BranchId; temp.Date = DateTime.Now; temp.LogId = 1; temp.IsActive = true; temp.ProductId = StockBranchModel.Where(x => x.Barcode == productBarcode).Select(x => x.ProductId).FirstOrDefault(); if (size == "01") { temp.Quantity01 += 1; } if (size == "02") { temp.Quantity02 += 1; } if (size == "03") { temp.Quantity03 += 1; } if (size == "04") { temp.Quantity04 += 1; } if (size == "05") { temp.Quantity05 += 1; } if (size == "06") { temp.Quantity06 += 1; } if (size == "07") { temp.Quantity07 += 1; } if (size == "08") { temp.Quantity08 += 1; } if (size == "09") { temp.Quantity09 += 1; } if (size == "10") { temp.Quantity10 += 1; } if (size == "11") { temp.Quantity11 += 1; } if (size == "12") { temp.Quantity12 += 1; } if (size == "13") { temp.Quantity13 += 1; } if (size == "14") { temp.Quantity14 += 1; } if (size == "15") { temp.Quantity15 += 1; } if (size == "16") { temp.Quantity16 += 1; } if (size == "17") { temp.Quantity17 += 1; } if (size == "18") { temp.Quantity18 += 1; } if (size == "19") { temp.Quantity19 += 1; } if (size == "20") { temp.Quantity20 += 1; } if (size == "21") { temp.Quantity21 += 1; } if (size == "22") { temp.Quantity22 += 1; } if (size == "23") { temp.Quantity23 += 1; } if (size == "24") { temp.Quantity24 += 1; } if (size == "25") { temp.Quantity25 += 1; } if (size == "26") { temp.Quantity26 += 1; } if (size == "27") { temp.Quantity27 += 1; } if (size == "28") { temp.Quantity28 += 1; } if (size == "29") { temp.Quantity29 += 1; } if (size == "30") { temp.Quantity30 += 1; } dict.Add(productBarcode, temp); } } var stockList = dict.Select(x => x.Value).ToList(); foreach (var l in stockList) { var stockAudit = Services.StockAuditService.Create(l); } } TempData["Success"] = "File Uploaded Successfully!"; return(RedirectToAction("Index", "StockAudit")); } return(View(stock1)); }
public async Task StartSimulation(FormDataModel formData) { _logger.LogInformation(formData.SimInterval.ToString()); var generatedData = _generator.GenerateOEEValues( formData.ShiftLength, formData.TotalBreakTime, formData.DownTime, formData.ActualCycleTimeMin, formData.ActualCycleTimeMax, formData.ActualRunRateMin, formData.ActualRunRateMax, formData.RadioRunRate, formData.RejectCountMin, formData.RejectCountMax ); var ackProductionMinute = 0; var ackTotalCount = 0.0; var ackTotalReject = 0.0; var ackPlannedStop = 0.0; var ackDownTime = 0.0; double availability = 0.0; double performance = 0.0; double quality = 0.0; double oeeCalculated = 0.0; List <ProductionDataModel> data = new List <ProductionDataModel>(); foreach (var point in generatedData) { if (stop) { return; } ackProductionMinute = ackProductionMinute + 1; if (point.PlannedStop) { point.TimeStamp = $"Planned Stop ({point.TimeStamp})"; ackPlannedStop = ackPlannedStop + 1.0; } else if (point.Downtime) { point.TimeStamp = $"Downtime ({point.TimeStamp})"; ackDownTime = ackDownTime + 1.0; } ackTotalCount = ackTotalCount + point.TotalCount; point.AckTotalCount = ackTotalCount; ackTotalReject = ackTotalReject + point.RejectCount; point.AckTotalReject = ackTotalReject; // OEE Calculation OEECalculator _oee = new OEECalculator { ShiftLength = ackProductionMinute, TotalBreakTime = ackPlannedStop, Downtime = ackDownTime, // Contains Unplanned Stops (e.g., Breakdowns) or Planned Stops (e.g., Changeovers) TotalCount = ackTotalCount, // 19271 RejectCount = ackTotalReject, // 423 IdealCycleTime = formData.IdealCycleTime, // Defined in seconds EnableIdealRunRate = formData.RadioRunRate, // Enable to calculate performance according to run rate instead of cycle time IdealRunRate = formData.IdealRunRate // Parts per minute }; availability = _oee.CalculateAvailability(); performance = _oee.CalculatePerformance(); quality = _oee.CalculateQuality(); oeeCalculated = availability * performance * quality; point.Availability = availability; point.Performance = performance; point.Quality = quality; point.OEE = oeeCalculated; data.Add(point); await Clients.All.SendAsync("StartSimulation", data); System.Threading.Thread.Sleep(formData.SimInterval); } ackTotalCount = 0.0; ackTotalReject = 0.0; }