public static List <ShortCode> GetShortCodes(string input, string regexMatchString, bool removeParagraphs) { List <ShortCode> shortCodes = new List <ShortCode>(); // get the main tag [tag attr="value"] string find = @"\[(?<tag>" + regexMatchString + @")(?<attrs>[^\]]+)\]"; if (removeParagraphs) { find = @"(<p>[\s\n]?)+" + find + @"([\s\n]?</p>)+"; } MatchCollection matches = Regex.Matches(input, find); foreach (Match match in matches) { string tagName = match.Groups["tag"].Value; string attributes = match.Groups["attrs"].Value; ShortCode sc = new ShortCode(tagName, match.Value); // parse the attributes // attr="value" MatchCollection attrMatches = Regex.Matches(attributes, @"(?<attr>\w+)=""(?<val>[^""]+)"""); foreach (Match attrMatch in attrMatches) { sc.Attributes.Add(attrMatch.Groups["attr"].Value, attrMatch.Groups["val"].Value); sc.Attributes.Add("key", attrMatch.Groups["attr"].Value); } shortCodes.Add(sc); } return(shortCodes); }
private void UnitName_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { ShortCode.Focus(); } }
public FileInfo GetFile(string name) { var fileRef = ShortCode.TryParse(name, out var c) ? _index.GetFile(c) : _index.GetFileByName(c); return(new FileInfo(Path.Combine(_uploadService.RootPath.FullName, fileRef.Location))); }
public static ShortCode ToShortCode(this SavedDataDTO savedDataDTO) { var shortCode = new ShortCode { RelatedGuid = savedDataDTO.Guid }; return(shortCode); }
public void TestCode() { // arrange int max = ShortCode.MAX; int min = ShortCode.MIN; int generatedCode = ShortCode.Next(); // act bool isInRange = generatedCode <= max && generatedCode >= min; // assert Assert.True(isInRange); }
public ImageReference Handle(ImageRequest message) { var imageRef = ShortCode.TryParse(message.Id, out var c) ? Index.GetImage(c) : Index.GetImageByName(message.Id); imageRef.SetLocation(ImageRoot); if (message.DetectContentType) { imageRef.ContentType = MimeGuesser.GuessMimeType(imageRef.FileLocation); } return(imageRef); }
public override int GetHashCode() { int hash = 1; if (Protocol != global::PKIo.PassProtocol.DoNotUse) { hash ^= Protocol.GetHashCode(); } if (ClassId.Length != 0) { hash ^= ClassId.GetHashCode(); } if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (ShortCode.Length != 0) { hash ^= ShortCode.GetHashCode(); } if (created_ != null) { hash ^= Created.GetHashCode(); } if (Secret.Length != 0) { hash ^= Secret.GetHashCode(); } if (Key.Length != 0) { hash ^= Key.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public async Task <Guid> Shorten(Url url) { var shortCode = new ShortCode(); shortCode.ReqDate = DateTime.Now; shortCode.Code = await GenerateCode(); if (Context.Url.Any(e => e.ReqUrl == url.ReqUrl)) { url = Context.Url.Where(e => e.ReqUrl == url.ReqUrl).First(); shortCode.UrlId = url.Id; await Context.ShortCode.AddAsync(shortCode); } else { url.ShortCodes.Add(shortCode); await Context.Url.AddAsync(url); } await Context.SaveChangesAsync(); return(shortCode.Code); }
public static List<ShortCode> GetShortCodes(string input, string regexMatchString, bool removeParagraphs) { List<ShortCode> shortCodes = new List<ShortCode>(); // get the main tag [tag attr="value"] string find = @"\[(?<tag>" + regexMatchString + @")(?<attrs>[^\]]+)\]"; if (removeParagraphs) { find = @"(<p>[\s\n]?)+" + find + @"([\s\n]?</p>)+"; } MatchCollection matches = Regex.Matches(input, find); foreach (Match match in matches) { string tagName = match.Groups["tag"].Value; string attributes = match.Groups["attrs"].Value; ShortCode sc = new ShortCode(tagName, match.Value); // parse the attributes // attr="value" MatchCollection attrMatches = Regex.Matches(attributes, @"(?<attr>\w+)=""(?<val>[^""]+)"""); foreach (Match attrMatch in attrMatches) { sc.Attributes.Add(attrMatch.Groups["attr"].Value, attrMatch.Groups["val"].Value); } shortCodes.Add(sc); } return shortCodes; }
public ApproveEmailTemplate() : this(ShortCode.Next(), EmailLink.Next()) { }
public IHttpActionResult ReceiveDeliveryNotification() { XNamespace ns1 = ShortCode.SOAPRequestNamespaces["ns1"]; XNamespace ns2 = ShortCode.SOAPRequestNamespaces["ns2"]; XNamespace loc = ShortCode.SOAPRequestNamespaces["loc"]; XNamespace v2 = ShortCode.SOAPRequestNamespaces["v2"]; string notificationSoapString = Request.Content.ReadAsStringAsync().Result; XElement soapEnvelope = XElement.Parse(notificationSoapString); string destination = (string) (from el in soapEnvelope.Descendants("address") select el).First(); destination = destination.Substring(4); string deliveryStatus = (string) (from el in soapEnvelope.Descendants("deliveryStatus") select el).First(); string serviceId = (string) (from el in soapEnvelope.Descendants(ns1 + "serviceId") select el).First(); string correlatorString = (string) (from el in soapEnvelope.Descendants(ns2 + "correlator") select el).First(); int correlator; Int32.TryParse(correlatorString.Substring(1), out correlator); string traceUniqueId = (string) (from el in soapEnvelope.Descendants(ns1 + "traceUniqueID") select el).First(); using (var db = new ApplicationDbContext()) { var deliveryNotification = new Delivery() { Destination = destination, DeliveryStatus = deliveryStatus, ServiceId = serviceId, Correlator = correlator, TimeStamp = DateTime.Now, TraceUniqueId = traceUniqueId, Type = correlatorString.First() == 'G' ? "General" : "Match" }; if (deliveryStatus.ToLower().Equals("deliveredtoterminal")) { var subscribers = db.Subscribers.Where(s => s.PhoneNumber.Equals(destination)); if (subscribers.Any() && subscribers.First().isActive) { // Move subscriber to the next tip depending on the type of tip delivered if (deliveryNotification.Type == "General") { subscribers.First().NextTip += 1; } else { subscribers.First().NextMatchTip += 1; } } } db.Deliveries.Add(deliveryNotification); db.SaveChanges(); //return CreatedAtRoute("DefaultApi", new { id = deliveryNotification.Id }, deliveryNotification); return(Ok(ShortCode.GetNotifySmsResponse())); } }
public SendSmsCommand(ShortCode code) { ShortCode = code; }