/// <summary> /// 当前节点的ID或Class中是否包含关键词 /// </summary> /// <param name="Node">要检查的Node</param> /// <param name="Keywords">全部小写哦</param> /// <returns></returns> public static bool IDClassContain(HtmlNode Node, IEnumerable <string> Keywords) { if (Node == null || Keywords == null) { return(false); } List <string> Str2Check = new List <string>(); if (!string.IsNullOrEmpty(Node.Id)) { Str2Check.Add(Node.Id.ToLower()); } if (Node.Attributes.Contains("class") && !string.IsNullOrWhiteSpace(Node.Attributes["class"].Value)) { foreach (string ClassName in Node.Attributes["class"].Value.Split()) { Str2Check.Add(ClassName.ToLower()); } } foreach (string Str in Str2Check) { foreach (string Keyword in Keywords) { if (Str.Contains(Keyword)) { return(true); } } } return(false); }
public static void TestUSBFun(object sender, EventArgs e)//定时检查是否有设备在线 { bool flag = false; string deviceStr = "abc"; foreach (string Str in myUSB.GetDeviceList()) { if (Str.Contains("#vid_9527&pid_1002")) { flag = true; deviceStr = Str; break; } } if (flag == false) //没检测到全能王设备 { return; } if (myUSB.OpenUSBHid(deviceStr))//打开 USB 连接 { StaticUSB.flagUSBOPEN = true; testUSB.Stop(); //打开后就关闭定时检查 recvThread = new Thread(USBRecvProcess); recvThread.Start(); //创建发送线程 sendThread = new Thread(USBSendProcess); sendThread.Start(); MainWindow.sPage.ShowStatus("设备已连接");//todo: MainWindow.sPage.isUSBOK = true; } }
private void ShowMessage(string message) { if (!Str.Contains(message, "\n") && message.Length > LINE_LENGTH) { String[] words = message.Split(' '); String tmp = words[0]; for (int i = 1; i < words.Length; i++) { if (tmp.Length + words[i].Length + 1 > LINE_LENGTH) { tmp = tmp + "\n" + words[i]; } else { tmp = tmp + " " + words[i]; } } message = tmp; } if (!Str.Contains(message, "\n")) { message = message + "\n"; } String[] lines = message.Split('\n'); if (lines[0] != "") { labelFirstLine.Text = AdjustMessageLine(lines[0]); } labelSecondLine.Text = AdjustMessageLine(lines[1]); }
/// <summary> /// 当前节点的ID或Class中是否包含关键词 /// </summary> /// <param name="Node">要检查的Node</param> /// <param name="Keywords">全部小写哦</param> /// <returns></returns> public static double ContainIDorClass(HtmlNode Node, Dictionary <string, double> Keywords) { double Score = 0; if (Node == null || Keywords == null) { return(Score); } List <string> Str2Check = new List <string>(); if (!string.IsNullOrEmpty(Node.Id)) { Str2Check.Add(Node.Id.ToLower()); } if (Node.Attributes.Contains("class") && !string.IsNullOrWhiteSpace(Node.Attributes["class"].Value)) { foreach (string ClassName in Node.Attributes["class"].Value.Split()) { Str2Check.Add(ClassName.ToLower()); } } foreach (string Str in Str2Check) { foreach (string Key in Keywords.Keys) { if (Str.Contains(Key)) { Score += Keywords[Key]; } } } return(Score); }
internal void Show(String msg) { byte[] cursorHome = { CursorHome }; Write(cursorHome, 0, 1); StringBuilder printMsg = new StringBuilder(); if (!Str.Contains(msg, "\n")) { msg += "\n"; } foreach (String line in msg.Split('\n')) { if (Str.Contains(line, "\t")) { printMsg.Append(PadCenter(line)); } else { printMsg.Append(AlignCenter(line)); } } Write(printMsg.ToString(), 0, 42); }
internal static List <ICustomer> SearchCustomers(String info) { List <ICustomer> customerList = new List <ICustomer>(); foreach (ICustomer customer in customers) { if (Str.Contains(customer.Name, info))//search in name { ((Customer)customer).RefreshPoint(); customerList.Add(customer); } else if (Str.Contains(customer.Number, info))//search in customer number { ((Customer)customer).RefreshPoint(); customerList.Add(customer); } else if (Str.Contains(customer.Code, info))//search in customer code { ((Customer)customer).RefreshPoint(); customerList.Add(customer); } } return(customerList); }
public static bool IDClassContain(HtmlNode Node, string Keyword) { //被十级郁气了,为何找不到方法把一个单一的string放到IEnumerable<string>里面去!算了我自己重新写一遍 if (Node == null || string.IsNullOrEmpty(Keyword)) { return(false); } List <string> Str2Check = new List <string>(); if (!string.IsNullOrEmpty(Node.Id)) { Str2Check.Add(Node.Id.ToLower()); } if (Node.Attributes.Contains("class") && !string.IsNullOrWhiteSpace(Node.Attributes["class"].Value)) { foreach (string ClassName in Node.Attributes["class"].Value.Split()) { Str2Check.Add(ClassName.ToLower()); } } foreach (string Str in Str2Check) { if (Str.Contains(Keyword)) { return(true); } } return(false); }
public static String FormatQTitle(String msg) { if (Str.Contains(msg, PosMessage.TOTAL)) { return(FormatTitle(PosMessage.DOCUMENT_QUNTITY)); } return(FormatTitle(msg + PosMessage.OF_QUNTITY)); }
public bool isQuestion() { if (Str.Contains('?')) { return(true); } return(false); }
public void TestContains() { var result = Str.Contains("helloworld", "ppp", "wor"); Assert.AreEqual(true, result); result = Str.Contains("helloworld", "ppp", "Wor"); Assert.AreEqual(false, result); }
public bool AddSeperator() { bool hasDecimal = Str.Contains(sb.ToString(), decimalSeperator); if (!hasDecimal) { sb.Append(decimalSeperator); } return(!hasDecimal); }
private string AdjustMessageLine(string line) { if (Str.Contains(line, "\t")) { line = line.Replace("\t", " ".PadRight(20 - line.Length + 1)); } int adj = 20 - line.Length; int left = adj / 2; int right = adj - left; return("".PadLeft(left) + line + "".PadRight(right)); }
internal static List <IProduct> SearchProductByName(String nameData) { List <IProduct> productList = new List <IProduct>(); foreach (String name in productsByName.Keys) { if (Str.Contains(name, nameData)) { productList.Add(productsByName[name]); } } return(productList); }
public void Show(String message, Target target) { if (target == Target.Customer) { return; } if (!Str.Contains(message, "\n")) { message = message + "\n"; } String[] lines = message.Split('\n'); SetFirstMessage(AdjustMessageLine(lines[0])); SetSecondMessage(AdjustMessageLine(lines[1])); }
public DB_Architect.Table Query(string QueryScript, string DatabaseName) { Exception ImproperQueryException = new Exception("Query Inconsistant with Database Contents"); buffer = null; DB_Architect.Table T = new DB_Architect.Table(); buffer = Encoding.Default.GetBytes("PassiveQuery" + "~" + QueryScript + "~" + DatabaseName); S.Send(buffer, SocketFlags.None); buffer = new byte[8192]; S.Receive(buffer, SocketFlags.None); if (Encoding.Default.GetString(buffer).Replace("\0", "") == "Error") { throw ImproperQueryException; } int Len = BitConverter.ToInt32(buffer, 0); buffer = new byte[Len]; S.Receive(buffer); string Response = Encoding.Default.GetString(buffer); string[] ParseResponse = Response.Split('~'); DB_Architect.Key CurrentKey = new DB_Architect.Key(); foreach (string Str in ParseResponse) { if (Str.Contains("%K%")) { CurrentKey.Name = Str.Replace("%K%", "").Replace("%20%", " "); } else if (Str.Contains("%R%")) { CurrentKey.Records.Add(Str.Replace("%R%", "").Replace("%20%", " ")); } else if (Str == "%EOK%") { T.Keys.Add(CurrentKey); CurrentKey = new DB_Architect.Key(); } else if (Str == "%EOT%") { break; } } return(T); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { Room Room = Session.GetHabbo().CurrentRoom; if (Room == null || !Room.CheckRights(Session, true)) { return; } int ItemId = Packet.PopInt(); Item Item = Session.GetHabbo().CurrentRoom.GetRoomItemHandler().GetItem(ItemId); if (Item == null) { return; } string Gender = Session.GetHabbo().Gender.ToLower(); string Figure = ""; foreach (string Str in Session.GetHabbo().Look.Split('.')) { if (Str.Contains("hr") || Str.Contains("hd") || Str.Contains("he") || Str.Contains("ea") || Str.Contains("ha")) { continue; } Figure += Str + "."; } Figure = Figure.TrimEnd('.'); if (Item.ExtraData.Contains(Convert.ToChar(5))) { string[] Flags = Item.ExtraData.Split(Convert.ToChar(5)); Item.ExtraData = Gender + Convert.ToChar(5) + Figure + Convert.ToChar(5) + Flags[2]; } else { Item.ExtraData = Gender + Convert.ToChar(5) + Figure + Convert.ToChar(5) + "Default"; } Item.UpdateState(true, true); QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_ExploreMannequin", 1); }
public String FormatRemark(String remark) { int currentLine = GetCurrentLine(InvoicePage.REMARKCOUNT); if (Str.Contains(remark, '\t')) { String[] pairs = Str.Split(remark, '\t'); FormatLine(new Location(productNameLocation.X, CurrentPage.PageLines.Count + 1), "## " + pairs[0]); FormatLine(new Location(productAmountLocation.X - maxAmountWidth, CurrentPage.PageLines.Count), pairs[1].PadLeft(maxAmountWidth, ' ')); } else { FormatLine(new Location(productNameLocation.X, CurrentPage.PageLines.Count + 1), "## " + remark); } InvoicePage.REMARKCOUNT -= 1; return(CurrentPage.PageLines[currentLine]); }
public void Show(String msg) { if (IsPaused) { return; } if (currentTarget != Target.Customer) { cashierMessage = msg; CursorOff(); } else { customerMessage = msg; } byte[] cursorHome = { CursorHome }; Write(cursorHome, 0, 1); //MoveCursorUpperLeftMostPosition(); StringBuilder printMsg = new StringBuilder(); if (!Str.Contains(msg, "\n")) { msg += "\n"; } foreach (String line in msg.Split('\n')) { if (Str.Contains(line, "\t")) { printMsg.Append(PadCenter(line)); } else { printMsg.Append(AlignCenter(line)); } } Write(printMsg.ToString(), 0, 42); }
public string AnalysisString(string StrIndex, string StrAuxAttribles) { try { string[] StrArray = StrAuxAttribles.ToUpper().Split(';'); foreach (string Str in StrArray) { if (Str.Contains(StrIndex.ToUpper())) { string[] Array1 = Str.Split('='); return(Array1[1]); } } MessageBox.Show("We Can't find " + StrIndex + " in StrAuxAttribles"); return(null); } catch { return(null); } }
private string AdjustMessageLine(string line) { if (Str.Contains(line, "\t")) { if (line.IndexOf("\t") == 0) { line = line.Replace("\t", " ".PadRight(LINE_LENGTH - line.Length)); } else { line = line.Replace("\t", " ".PadRight(LINE_LENGTH - line.Length + 1)); } } else { line = line.PadLeft(line.Length + ((LINE_LENGTH - line.Length) / 2), ' '); } if (Str.Contains(line, "&")) { line = line.Replace("&", " "); } return(String.Format("{0,-" + LINE_LENGTH.ToString() + "}", line)); }
internal String[] CreatePromotionList() { if (documentTotalAmount == 0) { return new String[] { } } ; List <String> promoRemarks = new List <string>(); long pointsEarned = 0; ICustomer customer = null; if (SecurityConnector.CurrentCustomer != null && customerCode == SecurityConnector.CurrentCustomer.Code) { customer = SecurityConnector.CurrentCustomer; } if (customer != null) { remarks.Add("M", customer.Name); } foreach (IPromotion pr in Settings.SalePromotions) { if (!pr.PromotionCoverAll(this.promotionRange)) { continue; } if (this.promotionRange == PromotionRange.CUSTOMER) { if (customer == null || !((BasePromotion)pr).CheckCustomerGroup(customer)) { continue; } } BasePromotion basePRM = (BasePromotion)pr; IProduct giftProduct = null; if (basePRM.GiftProductLabelNo > 0) { giftProduct = FindProductByLabel(basePRM.GiftProductLabelNo); } if (basePRM.LimitType == LimitType.NoLimit && giftProduct == null && basePRM.Points == 0) { continue; } //compare promotions with requirement totals if (CheckLimit(basePRM)) { soldItems.SetPromotion(basePRM, false); if (giftProduct != null && soldItems.LineTotal(basePRM.GiftProductLabelNo) > 0m) { if (basePRM.LimitType == LimitType.Amount) { soldItems.GiveAsPromotion(basePRM); } else if (soldItems.LineTotal(basePRM) >= basePRM.RequiredQuantity) { //calculates how many times promotion will applied int giftRatio = (int)(soldItems.LineTotal(basePRM) / basePRM.RequiredQuantity); for (int i = 0; i < giftRatio; i++) { soldItems.GiveAsPromotion(basePRM); } } } } } //Apply product and category promotion to document BasePromotion[] tempPromotions = soldItems.Promotions; foreach (BasePromotion prm in tempPromotions) { ((IPromotion)prm).ApplyPromotion(); pointsEarned += ((IPromotion)prm).PointEarned; } //Gets total discount amount totalDiscount = soldItems.TotalDiscount(); List <String> promoLines = soldItems.PromotedLines; String promocodeApplied = ""; List <TotalPromotion> giftPromotions = new List <TotalPromotion>(); //define best total promotion TotalPromotion bestTotalPromotion = null; //Decimal promotedTotal = paymentAmount - totalDiscount; Decimal promotedTotal = documentTotalAmount - totalDiscount; foreach (IPromotion pr in Settings.TotalPromotions) { if (!pr.PromotionCoverAll(this.promotionRange)) { continue; } if (!pr.CheckPaymentType(paymentType)) { continue; } if ((this.promotionRange == PromotionRange.CUSTOMER) && (customer == null || !((TotalPromotion)pr).CheckCustomerGroup(customer))) { continue; } TotalPromotion totalPromo = (TotalPromotion)pr; if (totalPromo.GiftProductLabelNo > 0) { giftPromotions.Add((TotalPromotion)pr); #if ISKULTUR IProduct product = FindProductByLabel(totalPromo.GiftProductLabelNo); Decimal quantity = soldItems.LineTotal(totalPromo.GiftProductLabelNo); Decimal amountWithoutProduct = promotedTotal - product.UnitPrice * quantity; if (amountWithoutProduct >= totalPromo.RequiredAmount) { promotedTotal = amountWithoutProduct; } #endif } else { Decimal requiredAmount = totalPromo.HavePayment ? promotedTotal : (documentTotalAmount - totalDiscount); //select best total promotion as discount amount if (totalPromo.RequiredAmount <= requiredAmount) { bestTotalPromotion = bestTotalPromotion == null ? totalPromo : ComparePromotions(bestTotalPromotion, totalPromo, documentTotalAmount); } } } Decimal discountTotalPromotion = 0, discountCustomerPromotion = 0; if (bestTotalPromotion != null) { // Promosyonun ödeme tipine baðlý deðilse promosyon ödeme parçalý olsa da aratoplama uygulanýyor. //if (!bestTotalPromotion.HavePayment) //{ // paymentAmount = documentTotalAmount; // promotedTotal = paymentAmount - totalDiscount; //} } //Qunatity to be promotion applied int ratio = 0; if (bestTotalPromotion != null) { ratio = (int)((promotedTotal) / bestTotalPromotion.RequiredAmount); discountTotalPromotion = Math.Max(bestTotalPromotion.Discount, promotedTotal * bestTotalPromotion.PercentDiscount / 100m); if (bestTotalPromotion.RequiredAmount <= promotedTotal) { discountTotalPromotion = Math.Max(bestTotalPromotion.Discount * ratio, promotedTotal * bestTotalPromotion.PercentDiscount / 100m); } else { discountTotalPromotion = discountTotalPromotion > totalDiscount ? discountTotalPromotion : 0; } //pointsEarned += (bestTotalPromotion.Points + bestTotalPromotion.ExtraPoints) * ratio; } //Apply gift product promotions Decimal promoReqAmount = promotedTotal; #if ISKULTUR promoReqAmount -= discountTotalPromotion; #endif while (true) { TotalPromotion tp = BestGiftPromotion(giftPromotions, promoReqAmount); if (tp == null) { break; } ratio = (int)((promoReqAmount) / tp.RequiredAmount); IProduct giftProduct = FindProductByLabel(tp.GiftProductLabelNo); Decimal lineQuantity = soldItems.LineTotal(tp.GiftProductLabelNo); for (int i = 0; i < ratio && lineQuantity > 0; i++) { promoReqAmount -= tp.RequiredAmount; decimal lineDiscount = Math.Max(tp.Discount, giftProduct.UnitPrice * tp.PercentDiscount / 100m); long linePoint = (tp.Points + tp.ExtraPoints); if (lineQuantity < 1) { lineDiscount = lineDiscount * lineQuantity; linePoint = (long)(linePoint * lineQuantity); } #if ISKULTUR promoLines.Add( String.Format("06,IND,SAT {0:D4} %{1:D2}, {2:D10}", soldItems.GetSalesID((BasePromotion)tp)[i], (int)0, (int)Math.Round(lineDiscount * 100, 0))); if (promoLines.Count > 0) { promoLines.Add(String.Format("00,KOD,{0}", Settings.PromoKey)); } for (int cntr = 0; cntr < promoLines.Count; cntr++) { promoLines[cntr] = String.Format("1,{0:D5},{1}", cntr + 1, promoLines[cntr]); } pointsEarned += linePoint; lineQuantity = soldItems.LineTotal(tp.GiftProductLabelNo); #else discountTotalPromotion += lineDiscount; pointsEarned += linePoint; soldItems.GiveAsPromotion(tp); lineQuantity = soldItems.LineTotal(tp.GiftProductLabelNo); #endif } } #if ISKULTUR promotedTotal = documentTotalAmount; #endif promotedTotal -= discountTotalPromotion; String[] appliedCodes = soldItems.AppliedCodes; foreach (String appliedCode in appliedCodes) { if (appliedCode.Length > 0 && !Str.Contains(promocodeApplied, (appliedCode.Trim() + ","))) { promocodeApplied = promocodeApplied + appliedCode.Trim(); } } TotalPromotion bestPointPromo = null; if (customer != null) { discountCustomerPromotion = documentTotalAmount * customer.PromotionLimit / 100m; } promotedTotal -= discountCustomerPromotion; if (discountCustomerPromotion > 0) { promocodeApplied += "M"; } if (bestTotalPromotion != null) { promocodeApplied += bestTotalPromotion.PromotionCode; } //decimal ttlDiscount = paymentAmount - promotedTotal - totalDiscount; decimal ttlDiscount = 0; if (isFirstPayment) { ttlDiscount = documentTotalAmount - promotedTotal - totalDiscount; } if (paymentAmount > promotedTotal && isFirstPayment) { paymentAmount = promotedTotal; } bestPointPromo = BestPointPromotion(paymentAmount); if (bestPointPromo != null) { int pointMultiple = (int)((paymentAmount) / bestPointPromo.RequiredAmount); pointsEarned += (bestPointPromo.Points + bestPointPromo.ExtraPoints) * pointMultiple; if (!bestPointPromo.Equals(bestTotalPromotion)) { promocodeApplied += bestPointPromo.PromotionCode; } } #if ISKULTUR int startIndex = promoLines.Count; #else int startIndex = 0; #endif if (ttlDiscount > 0) { promoLines.Add(String.Format("06,IND,TOP {0:D4} %, {1:D10}", 0, (Int64)(ttlDiscount * 100)));//%00 } if (promocodeApplied.Length > 0) { promoLines.Add(String.Format("22,MSG,{0} {1}", PosMessage.PROMOTION_CODE, promocodeApplied)); } if (promoRemarks.Count > 0) { foreach (string pr in promoRemarks) { promoLines.Add("29,NOT," + pr); } } if (pointsEarned > 0 && customer != null && !(Str.Contains(customer.Code, "*"))) { promoLines.Add(String.Format("22,PRM,{0:D9}", pointsEarned)); } if (customer != null && int.Parse(customer.Number) > 0) { promoLines.Add(String.Format("23,PNT,{0:D9}", customer.Number)); } if (promoLines.Count > 0) { promoLines.Add(String.Format("00,KOD,{0}", Settings.PromoKey)); } for (int cntr = startIndex; cntr < promoLines.Count; cntr++) { promoLines[cntr] = String.Format("1,{0:D5},{1}", cntr + 1, promoLines[cntr]); } return(promoLines.ToArray()); }
public override void Adjust(AdjustmentType method) { if (input.ToString().Length < input.Length || Str.Contains(input.ToString(), ',')) { if (method == AdjustmentType.PercentDiscount) { method = AdjustmentType.Discount; } else if (method == AdjustmentType.PercentFee) { method = AdjustmentType.Fee; } } if (cr.Document.IsEmpty) { cr.State = States.AlertCashier.Instance(new Confirm(PosMessage.NO_SALE_INVALID_ACTION)); return; } /* * //Check whether cashier has authorization or not. * if (input.ToDecimal() == 100) * { * if (method == AdjustmentType.PercentDiscount) * { * input = new Number(cr.Document.State is DocumentOpen ? cr.Document.LastItem.TotalAmount : cr.Document.BalanceDue); * method = AdjustmentType.Discount; * } * if (method == AdjustmentType.PercentFee) * { * input = new Number(cr.Document.State is DocumentOpen ? cr.Document.LastItem.TotalAmount : cr.Document.BalanceDue); * method = AdjustmentType.Fee; * } * } */ if (method == AdjustmentType.PercentDiscount || method == AdjustmentType.Discount) { //check whether cashier has percentDiscount or discount. if (!cr.IsAuthorisedFor(Authorizations.Discount)) { cr.State = States.AlertCashier.Instance(new Confirm(PosMessage.INSUFFICIENT_ACCESS_LEVEL)); return; } } else if (method == AdjustmentType.PercentFee || method == AdjustmentType.Fee) { //check whether cashier has percentFee or fee. if (!cr.IsAuthorisedFor(Authorizations.Fee)) { cr.State = States.AlertCashier.Instance(new Confirm(PosMessage.INSUFFICIENT_ACCESS_LEVEL)); return; } } //Deny if percentFee or percentDiscount is not integer. if (method == AdjustmentType.PercentDiscount || method == AdjustmentType.PercentFee) { if (input.Decimals > 0) { cr.State = AlertCashier.Instance(new Confirm(PosMessage.DNEY_PERCENTDISCOUNT)); return; } if (input.Length > 2) { cr.State = AlertCashier.Instance(new Confirm(PosMessage.DNEY_PERCENT_OVER_AMOUNT)); return; } } Adjustment adjustment = null; try { if (cr.Document.State is DocumentOpen) { if (cr.Document.LastItem.Adjustments.Count > 0 && !cr.Document.LastItem.Adjustments[cr.Document.LastItem.Adjustments.Count - 1].IsCorrection) { cr.State = States.AlertCashier.Instance(new Confirm("DAHA ÖNCE ÜRÜNE\nÝND/ART YAPILMIÞ")); return; } if (cr.Document.LastItem is VoidItem) { cr.State = States.AlertCashier.Instance(new Confirm("ÜRÜN ÝPTALÝNE\nÝND/ART YAPILAMAZ")); return; } if (input.ToDecimal() < 0.01m) { cr.State = States.AlertCashier.Instance(new Confirm("MÝN ÝND/ART TUTARI\n0,01")); return; } adjustment = new Adjustment(cr.Document.LastItem, method, input.ToDecimal()); if (!(cr.CurrentCashier.IsAuthorisedFor(adjustment) && cr.Document.CanAdjust(adjustment))) { cr.State = States.AlertCashier.Instance(new Confirm(String.Format("{0} {1}", adjustment.Label, PosMessage.INSUFFICIENT_LIMIT))); return; } if (method == AdjustmentType.PercentFee && input.ToDecimal() > 99) { adjustment = new Adjustment(cr.Document.LastItem, AdjustmentType.Fee, adjustment.NetAmount); } cr.Printer.Print(adjustment); cr.Document.LastItem.Adjust(adjustment); //TODO - if printerresponse is OK DisplayAdapter.Both.Show(adjustment); cr.State = Selling.Instance(); } else if (cr.Document.State is DocumentSubTotal) { adjustment = new Adjustment(cr.Document, method, input.ToDecimal()); if (!(cr.CurrentCashier.IsAuthorisedFor(adjustment) && cr.Document.CanAdjust(adjustment))) { cr.State = States.AlertCashier.Instance(new Confirm(String.Format("{0} {1}", adjustment.Label, PosMessage.INSUFFICIENT_LIMIT))); return; } cr.Printer.Print(adjustment); cr.Document.Adjust(adjustment); DisplayAdapter.Both.Show(adjustment); cr.State = States.PaymentAfterTotalAdjustment.Instance(adjustment); cr.Document.State = DocumentPaying.Instance(); } } catch (CmdSequenceException) { String adj = (method == AdjustmentType.Discount || method == AdjustmentType.PercentDiscount) ? PosMessage.DISCOUNT : PosMessage.FEE; cr.State = AlertCashier.Instance(new Confirm(String.Format("ARATOPLAM ONCESINE\n{0} GECERSIZ", adj))); } catch (ReceiptLimitExceededException) { //Sales document is a receipt which needs to be //converted to an invoice Invoice invoice = new Invoice(cr.Document); if (adjustment.Target is SalesItem) { invoice.LastItem.Adjust(adjustment); } if (!cr.Printer.CanPrint(invoice)) { throw new ReceiptLimitExceededException(); } MenuList docTypes = new MenuList(); docTypes.Add(new MenuLabel(PosMessage.TRANSFER_DOCUMENT + "\n" + PosMessage.INVOICE, invoice)); cr.State = States.ListDocument.Instance(docTypes, new ProcessSelectedItem <SalesDocument>(cr.ChangeDocumentType)); DisplayAdapter.Cashier.Show(PosMessage.RECEIPT_LIMIT_EXCEEDED_TRANSFER_DOCUMENT); } finally { input.Clear(); } }
internal static int ProcessRequest(String request) { try { String success = String.Empty; switch (request.Substring(1, 2)) { case "00": String zipName = "Data.zip"; String targetPath = PosConfiguration.DataPath; if (request.Length > 3 && request[3] == '1') { zipName = "Image.zip"; targetPath = PosConfiguration.ImagePath; } String zipfile = PosConfiguration.ServerDownloadPath + zipName; if (!Directory.Exists(targetPath)) { SendMessage(false, targetPath + "' YOLU BULUNAMADI..."); return(-1); } if (!File.Exists(zipfile)) { SendMessage(false, zipfile + "' DOSYASI BULUNAMADI..."); return(-1); } GetDataZip(zipfile, targetPath); if (request.Length > 3 && request[3] == '1') { success = String.Format("IMAGE KLASÖRÜ GÜNCELLEMESÝ: {0:D6} BAÞARILI, {1:D6} BAÞARISIZ", SuccessCount, FailCount); } else { Connector.Instance().LoadAll(); success = String.Format("ZÝP ÝLE DATA YÜKLEME : KAS {0:D3}, MUST {1:D6}, DVZ {2:D3}, CRD {3:D3}, URUN {4:D6}", Connector.Instance().GetLastSuccess(DataTypes.Cashier), Connector.Instance().GetLastSuccess(DataTypes.Customer), Connector.Instance().GetLastSuccess(DataTypes.Currency), Connector.Instance().GetLastSuccess(DataTypes.Credit), Connector.Instance().GetLastSuccess(DataTypes.Product)); } SendMessage(true, success); return(1); //successful case "07": //Urun Dosyasi if (request.Length > 3 && request[3] == '2') { Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.ProductFile, PosConfiguration.DataPath + "Update" + Settings.ProductFile); try { Connector.Instance().UpdateProducts(); success = String.Format("ÜRÜN GÜNCELLEMESÝ: {0:D6} BAÞARILI, {1:D6} BAÞARISIZ", Connector.Instance().GetLastSuccess(DataTypes.Product), Connector.Instance().GetLastFail(DataTypes.Product)); SendMessage(true, success); return(1); } catch (IOException io) { //after update_product file is processed, product file is updated, if (Connector.Instance().GetLastSuccess(DataTypes.Product) > 0) { SendMessage(false, "ÜRÜNLER ÞUAN ÝÇÝN GÜNCELLENDÝ AMA GÜNCELLENEN ÜRÜNLER ÜRÜN DOSYASINA EKLENEMEDÝ"); } else { SendMessage(false, io.Message); } return(-1); //report fail result to the exe using data.dll } } else { Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.ProductFile, PosConfiguration.DataPath + Settings.ProductFile); if (Connector.Instance().CurrentSettings.GetProgramOption(Setting.DepartmentNameOnly) == PosConfiguration.ON) { Product.departmentNameOnly = true; } try { Connector.Instance().LoadProducts(); } finally { Product.departmentNameOnly = false; } success = String.Format("ÜRÜN YÜKLEMESÝ: {0:D6} BAÞARILI, {1:D6} BAÞARISIZ", Connector.Instance().GetLastSuccess(DataTypes.Product), Connector.Instance().GetLastFail(DataTypes.Product)); SendMessage(true, success); return(1); } case "08": //Musteri (Cari) Dosyalari if (request.Length > 3 && request[3] == '2') { Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.CustomerFile, PosConfiguration.DataPath + "Update" + Settings.CustomerFile); try { Connector.Instance().UpdateCustomers(); success = String.Format("MÜÞTERÝ GÜNCELLEMESÝ: {0:D6} BAÞARILI, {1:D6} BAÞARISIZ", Connector.Instance().GetLastSuccess(DataTypes.Customer), Connector.Instance().GetLastFail(DataTypes.Customer)); SendMessage(true, success); return(1); } catch (IOException io) { //after update_customer file is processed, customer file is updated, if (Connector.Instance().GetLastSuccess(DataTypes.Customer) > 0) { SendMessage(false, "MÜÞTERÝLER ÞUAN ÝÇÝN GÜNCELLENDÝ AMA GÜNCELLENEN MÜÞTERÝLER MÜÞTERÝ DOSYASINA EKLENEMEDÝ"); } else { SendMessage(false, io.Message); } return(-1); //report fail result to the exe using data.dll } } else { Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.CustomerFile, PosConfiguration.DataPath + Settings.CustomerFile); Connector.Instance().LoadCustomers(); success = String.Format("MÜÞTERÝ YÜKLEMESÝ: {0:D6} BAÞARILI, {1:D6} BAÞARISIZ", Connector.Instance().GetLastSuccess(DataTypes.Customer), Connector.Instance().GetLastFail(DataTypes.Customer)); SendMessage(true, success); return(1); } case "09": //Kasiyer Dosyasi Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.CashierFile, PosConfiguration.DataPath + Settings.CashierFile); Connector.Instance().LoadCashiers(); success = String.Format("KASÝYER YÜKLEMESÝ: {0:D6} BAÞARILI, {1:D6} BAÞARISIZ", Connector.Instance().GetLastSuccess(DataTypes.Cashier), Connector.Instance().GetLastFail(DataTypes.Cashier)); SendMessage(true, success); return(1); case "10": //Doviz Dosyasi Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.ExchangeRateFile, PosConfiguration.DataPath + Settings.ExchangeRateFile); Data.Connector.Instance().LoadCurrencies(); success = String.Format("DÖVÝZ YÜKLEMESÝ: {0:D6} BAÞARILI, {1:D6} BAÞARISIZ", Connector.Instance().GetLastSuccess(DataTypes.Currency), Connector.Instance().GetLastFail(DataTypes.Currency)); SendMessage(true, success); return(1); case "11": //Kasa hareketleri List <String> requestedFileNames = new List <string>(); String suffix = "." + PosConfiguration.Get("RegisterId"); String destinationPath = PosConfiguration.ServerArchivePath; switch (request.Substring(3, 1)) { case "0": //Tum hareketler if (!Str.Contains(request, "00000000000")) { goto case "daterange"; } requestedFileNames.AddRange(Dir.GetFiles(PosConfiguration.ArchivePath, "*" + suffix)); goto case "copy"; case "1": //Online hareketler if (!Str.Contains(request, "00000000000")) { goto case "daterange"; } requestedFileNames.AddRange(Dir.GetFiles(PosConfiguration.ArchivePath, String.Format("*{0:ddMMyy}{1}", DateTime.Today, suffix))); goto case "copy"; case "2": //Gunluk hareketler if (!Str.Contains(request, "00000000000")) { goto case "daterange"; } requestedFileNames.AddRange(Dir.GetFiles(PosConfiguration.ArchivePath, String.Format("HR{0:ddMMyy}{1}", DateTime.Today, suffix))); goto case "copy"; case "3": if (!Str.Contains(request, "00000000000")) { goto case "daterange"; } //Gunluk iade ve iptaller requestedFileNames.AddRange(Dir.GetFiles(PosConfiguration.ArchivePath, String.Format("HI{0:ddMMyy}{1}", DateTime.Today, suffix))); requestedFileNames.AddRange(Dir.GetFiles(PosConfiguration.ArchivePath, String.Format("HD{0:ddMMyy}{1}", DateTime.Today, suffix))); goto case "copy"; case "4": //Sistem hareketleri requestedFileNames.AddRange(Dir.GetFiles(PosConfiguration.LogPath, String.Format("HRERROR{1}", DateTime.Today, suffix))); destinationPath = PosConfiguration.ServerUploadPath; goto case "copy"; case "daterange": //Tarihe gore hareketler String firstDay = request.Substring(7, 2) + request.Substring(5, 2) + request.Substring(3, 2); String lastDay = request.Substring(13, 2) + request.Substring(11, 2) + request.Substring(9, 2); String shortName; requestedFileNames.AddRange(Dir.GetFiles(PosConfiguration.ArchivePath, "*" + suffix)); List <String> cloneFileNames = new List <string>(requestedFileNames); foreach (string fileName in cloneFileNames) { shortName = new FileInfo(fileName).Name.Substring(2, 6); shortName = shortName.Substring(4, 2) + shortName.Substring(2, 2) + shortName.Substring(0, 2); if (shortName.CompareTo(firstDay) < 0 || shortName.CompareTo(lastDay) > 0) { requestedFileNames.Remove(fileName); } } goto case "copy"; case "copy": int i = 0; FileInfo fileInfo; foreach (String fileName in requestedFileNames) { fileInfo = new FileInfo(fileName); Connector.FxClient.UploadFile(destinationPath + fileInfo.Name, fileName); i++; } SendMessage(true, i + "ADET DOSYA KOPYALANDI"); return(1); default: SendMessage(false, "TANIMSIZ FONKSÝYON: " + request.Substring(1, 3)); return(-1); } //break; case "13": //Promosyon dosyalarýný guncelle Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.SubtotalPromotionFile, PosConfiguration.DataPath + Settings.SubtotalPromotionFile); Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.ProductPromotionFile, PosConfiguration.DataPath + Settings.ProductPromotionFile); Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.CategoryPromotionFile, PosConfiguration.DataPath + Settings.CategoryPromotionFile); SendMessage(true, "PROMOSYON DOSYALARI KOPYALANDI."); return(1); case "14": //Ürün Seri Numaralarý (Serial.dat) Dosyasý Connector.FxClient.DownloadFile(PosConfiguration.ServerDataPath + Settings.SerialNumberFile, PosConfiguration.DataPath + Settings.SerialNumberFile); Connector.Instance().LoadSerialNumbers(); success = String.Format("SERÝ NUMARA YÜKLEMESÝ: {0:D6} BAÞARILI, {1:D6} BAÞARISIZ", Connector.Instance().GetLastSuccess(DataTypes.Customer), Connector.Instance().GetLastFail(DataTypes.Customer)); SendMessage(true, success); return(1); default: return(0); //Operation could not be processed by Data.dll } } catch (Exception e) { EZLogger.Log.Error("Exception occured. {0}", e); try { SendMessage(false, e.Message.Replace('\n', '·')); } catch { } return(-1); } //return 0; }
public void TestContains() { Assert.AreEqual(true, Str.Contains("foobar", "baz", "foo")); Assert.AreEqual(false, Str.Contains("foobar", "baz", "aux")); }
public string ToString(string format, IFormatProvider formatProvider) { if (format == null) { format = "G"; } if (format.Equals("C")) { return(String.Format(nfi, "{0:C}", ToDecimal()).TrimEnd()); } else if (format.Equals("N")) { return(String.Format(nfi, "{0:N}", ToDecimal())); } else if (format.Equals("D")) { return(String.Format(nfi, "{0:N}", ToDecimal())); } else if (format.Equals("P")) { String str = String.Format(nfi, "{0:P}", ToDecimal()); if (ToDecimal() < 0.1m) { return(str.Insert(1, "0")); } else { return(str); } } else if (format.Equals("B")) //This is used for barcodes { return(sb.ToString()); } else if (format.StartsWith("Q")) { String s = ToDecimal().ToString(); if (Str.Contains(s, decimalSeperator)) { char seperator = decimalSeperator.ToCharArray()[0]; String[] str = s.Split(seperator); int decimals = (str[1].Length > 3) ? 3 : str[1].Length; Decimal d = Decimal.Parse(str[1].ToString()); if (d == 0) { s = str[0]; } else { s = str[0] + decimalSeperator + str[1].Substring(0, decimals); } } if (format.Equals("Q")) { return(s); } else { int i = int.Parse(format.Substring(1, format.Length - 1)); if (s.Length < i) { return(s.PadLeft(i, '0')); } else { return(s.Substring(s.Length - i, i)); } } } else { String s = ToDecimal().ToString(format); if (!Str.Contains(s, decimalSeperator)) { return(s); } else { char seperator = decimalSeperator.ToCharArray()[0]; String[] str = s.Split(seperator); int decimals = (str[1].Length > 3) ? 3 : str[1].Length; return(str[0] + decimalSeperator + str[1].Substring(0, decimals)); } } }