public IHttpActionResult UpdateScaleStatus([FromBody] StoreScales sc) { try { // sc.Status = newStatus; // sc.StatusText = newStatusText; _storeScaleService.Update(sc); return(base.Ok()); } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, ex.ToString())); } }
private bool UpdateScaleStatus(bool newStatus, string newStatusText, StoreScales sc) { refreshToken(); var client = new RestClient(_restClientAddress); var request = new RestRequest(baseApiRef + "UpdateScaleStatus", Method.POST); addHeaders(request); sc.Status = newStatus; sc.StatusText = newStatusText; sc.CreatePriceFileFlag = false; request.AddJsonBody(sc); IRestResponse response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { return(true); } else { _logger.Error($"Failed with content= '{response.Content}', and message= '{response.ErrorMessage}'", response.ErrorException); return(false); } }
private void tryAgainDensiScale(StoreScales sc, IEnumerable <CurrentPrices> cp) { int iRtn = -1; try { string RefLFZKFileName = ""; string RefCFGFileName = ""; iRtn = rtsdrv.rtscaleConnectEx(RefLFZKFileName, RefCFGFileName, sc.IpAdress); if (iRtn < 0) { UpdateScaleStatus(false, $"Connection Error : {iRtn} {DateTime.Now.ToString("MM - dd HH: mm")}", sc); return; } ; rtsdrv.rtscaleClearPLUData(); PLU[] plu = new PLU[4]; int i = 0; bool processResult = true; foreach (var line in cp) { int k = i % 4; string productname = line.ProductName.ToUpper(); if (productname.Length > 20) { productname = productname.Substring(0, 20); } productname = String.Join("", productname.Normalize(NormalizationForm.FormD).Where(c => char.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)).Replace("ı", "i"); int price = Convert.ToInt32(Math.Round(((decimal)line.SalePrice * 100), 0)); int barcode = int.Parse(line.Barcode.Replace("290", "000")); plu[k].Name = productname; plu[k].LFCode = barcode; plu[k].Code = barcode.ToString(); plu[k].BarCode = 40; plu[k].UnitPrice = price; plu[k].WeightUnit = 4; plu[k].Deptment = 29; plu[k].ShlefTime = 30; i++; if (i % 4 == 0) { int result = rtsdrv.rtscaleTransferPLUCluster(plu); if (result != 0) { UpdateScaleStatus(false, $"Process Error : {result} {DateTime.Now.ToString("MM - dd HH: mm")}", sc); processResult = false; } plu = new PLU[4]; } } if (i > 0 && i % 4 != 0) { int result = rtsdrv.rtscaleTransferPLUCluster(plu); if (result != 0) { UpdateScaleStatus(false, $"Process Error : {result} {DateTime.Now.ToString("MM - dd HH: mm")}", sc); processResult = false; } } if (i > 0 && processResult) { UpdateScaleStatus(true, $"OK : {DateTime.Now.ToString("MM - dd HH: mm")}", sc); } rtsdrv.rtscaleDisConnectEx(sc.IpAdress); } catch (Exception ex) { _logger.Error($"tryAgainDensiScale error : {ex.Message}"); if (iRtn >= 0) // connection exist { rtsdrv.rtscaleDisConnectEx(sc.IpAdress); } } }
private void sendtoDensiScale(StoreScales sc) { int iRtn = -1; try { string RefLFZKFileName = ""; string RefCFGFileName = ""; iRtn = rtsdrv.rtscaleConnectEx(RefLFZKFileName, RefCFGFileName, sc.IpAdress); if (iRtn < 0) { UpdateScaleStatus(false, $"Connection Error : {iRtn} {DateTime.Now.ToString("MM - dd HH: mm")}", sc); return; } ; rtsdrv.rtscaleClearPLUData(); PLU[] plu = new PLU[4]; int i = 0; bool processResult = true; foreach (var line in _scalePrices) { // if (line.Plu1 == "2902011") continue; int k = i % 4; string productname = line.ProductName.ToUpper(); if (productname.Length > 20) { productname = productname.Substring(0, 20); } productname = String.Join("", productname.Normalize(NormalizationForm.FormD).Where(c => char.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)).Replace("ı", "i"); int price = Convert.ToInt32(Math.Round(((decimal)line.PriceAmount * 100), 0)); int barcode = int.Parse(line.Plu1.Replace("290", "000")); plu[k].Name = productname; plu[k].LFCode = barcode; plu[k].Code = barcode.ToString(); plu[k].BarCode = 40; plu[k].UnitPrice = price; plu[k].WeightUnit = 4; plu[k].Deptment = 29; plu[k].ShlefTime = 30; i++; if (i % 4 == 0) { int result = rtsdrv.rtscaleTransferPLUCluster(plu); if (result != 0) { UpdateScaleStatus(false, $"Process Error : {result} {DateTime.Now.ToString("MM - dd HH: mm")}", sc); processResult = false; } plu = new PLU[4]; } } if (i > 0 && i % 4 != 0) { int result = rtsdrv.rtscaleTransferPLUCluster(plu); if (result != 0) { UpdateScaleStatus(false, $"Process Error : {result} {DateTime.Now.ToString("MM - dd HH: mm")}", sc); processResult = false; } } if (i > 0 && processResult) { UpdateScaleStatus(true, $"OK : {DateTime.Now.ToString("MM - dd HH: mm")}", sc); } // send hotkeys _logger.Debug($"hotkeys sent started"); int[] pHotKeys = new int[84]; int index = 0; int tableIndex = 0; foreach (HotKey h in _hotkeys) { pHotKeys[index++] = h.Code; if (index == 84) { rtsdrv.rtscaleTransferHotkey(pHotKeys, tableIndex++); _logger.Debug($"hotkeys sent : { Newtonsoft.Json.JsonConvert.SerializeObject(pHotKeys)}"); index = 0; pHotKeys = new int[84]; } } if (pHotKeys.Length > 0) { rtsdrv.rtscaleTransferHotkey(pHotKeys, tableIndex++); _logger.Debug($"hotkeys sent : { Newtonsoft.Json.JsonConvert.SerializeObject(pHotKeys)}"); } rtsdrv.rtscaleDisConnectEx(sc.IpAdress); } catch (Exception ex) { _logger.Error($"sendtoDensiScale error : {ex.Message}"); if (iRtn >= 0) // connection exist { rtsdrv.rtscaleDisConnectEx(sc.IpAdress); } } }
/*Section="CustomCodeRegion"*/ #region Customized private void startHelpDeskProcess(DataModels.Helpdesk.HelpdeskRequest dataModel, IDAL dal) { bool yardimciMalzeme = (dataModel.ProcessName == "YardimMasasiYardimciMalzeme"); bool bilgislem = (dataModel.ProcessName == "YardimMasasiAriza"); int processDefinitionId = _parameterReader.ReadPublicParameter <int>(dataModel.ProcessName, dataModel.Process); var store = dal.Read <Store>(dataModel.Store); var branch = dal.Read <Branch>(store.OrganizationBranch); GroupOperations gop = new GroupOperations(dal); IProcessInstance processInstance = new ProcessInstance(processDefinitionId, OTApplication.Context.User.Id); //Set Process Variables processInstance.AddProcessVariable("user", OTApplication.Context.User.Id); processInstance.AddProcessVariable("screenReference", "Helpdesk#HelpdeskRequestListComponent#" + dataModel.HelpdeskRequestId); processInstance.AddProcessVariable("branch", store.OrganizationBranch); processInstance.AddProcessVariable("region", branch.Parent); processInstance.AddProcessVariable("requestId", dataModel.HelpdeskRequestId); if (yardimciMalzeme) { Overtech.DataModels.Security.Group g = gop.FindGroup("Satın Alma"); processInstance.AddProcessVariable("purchasingGroup", g.GroupId); g = gop.FindGroup("Depo Sorumlusu"); processInstance.AddProcessVariable("warehouseGroup", g.GroupId); g = gop.FindGroup("İdari İşler"); processInstance.AddProcessVariable("executiveStaffGroup", g.GroupId); } else if (bilgislem) { Overtech.DataModels.Security.Group g = gop.FindGroup("Momende"); processInstance.AddProcessVariable("momendeGroup", g.GroupId); g = gop.FindGroup("Bilgi Sistemleri Kullanıcıları"); processInstance.AddProcessVariable("bilgiIslemGroup", g.GroupId); } processInstance.AddProcessVariable("description", dataModel.RequestDescription); string storeName = dal.List <Store>("STR_LST_STORE_SP").Where(s => s.StoreId == dataModel.Store) .Select(s => s.Name) .FirstOrDefault(); processInstance.AddProcessVariable("storeName", storeName); string definitionName = dal.List <RequestDefinition>("HDK_LST_REQUESTDEF_SP").Where(rd => rd.RequestDefinitionId == dataModel.RequestDefinition) .Select(rd => rd.RequestDefinitionName) .FirstOrDefault(); processInstance.AddProcessVariable("definition", definitionName); string deviceNo = "-"; IEnumerable <DataModels.Helpdesk.RequestAttribute> deviceAttributeList = dal.List <DataModels.Helpdesk.RequestAttribute>("HDK_LST_ATTRIBUTE_SP") .Where(a => a.AttributeType > 4 && a.RequestDefinition == dataModel.RequestDefinition); dataModel.RequestDetailList.ForEach(rd => { if (deviceNo == "-") { for (int i = 0; i < deviceAttributeList.Count(); i++) { DataModels.Helpdesk.RequestAttribute da = deviceAttributeList.ElementAt(i); if (da.RequestAttributeId == rd.Attribute) { string deviceName; string serialNo; switch (da.AttributeType) { case 5: // TERAZI StoreScales scale = dal.Read <StoreScales>(Int32.Parse(rd.AttributeValue)); deviceName = scale.BrandName ?? ""; serialNo = scale.SerialNumber ?? ""; i = deviceAttributeList.Count(); break; case 6: // YAZARKASA StoreCashRegister cashRegister = dal.Read <StoreCashRegister>(Int32.Parse(rd.AttributeValue)); deviceName = cashRegister.BrandName ?? ""; serialNo = cashRegister.SerialNo ?? ""; i = deviceAttributeList.Count(); break; case 7: // DEMIRBAS StoreFixture fixture = dal.Read <StoreFixture>(Int32.Parse(rd.AttributeValue)); deviceName = fixture.FixtureName ?? ""; serialNo = fixture.SerialNo ?? ""; i = deviceAttributeList.Count(); break; default: deviceName = ""; serialNo = ""; i = deviceAttributeList.Count(); break; } deviceNo = deviceName + (serialNo.Length > 0 ? "-" + serialNo : ""); } } ; } }); processInstance.AddProcessVariable("deviceNo", deviceNo); //Set Action Varibles processInstance.AddActionVariable("user", OTApplication.Context.User.Id); //processInstance.AddActionVariable("description", $"{store.Name} - {product.Name}"); //Start Process var processId = processInstance.Start(dataModel.HelpdeskRequestId.ToString()); dataModel.ProcessInstance = processId; dataModel.StatusCode = 1; dal.Update(dataModel); }