Пример #1
1
        public ActionResult Index()
        {
            PassGenerator generator = new PassGenerator();

            EventPassGeneratorRequest request = new EventPassGeneratorRequest();
            request.Identifier = "pass.tomasmcguinness.com";
            request.CertThumbnail = ConfigurationManager.AppSettings["PassBookCertificateThumbnail"];
            request.FormatVersion = 1;
            request.SerialNumber = "121212";
            request.Description = "My first pass";
            request.OrganizationName = "Tomas McGuinness";
            request.TeamIdentifier = "Team America";
            request.LogoText = "My Pass";
            request.BackgroundColor = "rgb(255, 255, 255)";

            request.IconFile = Server.MapPath(@"~/Icons/icon.png");
            request.IconRetinaFile = Server.MapPath(@"~/Icons/[email protected]");

            request.LogoFile = Server.MapPath(@"~/Icons/logo.png");
            request.LogoRetinaFile = Server.MapPath(@"~/Icons/[email protected]");

            request.EventName = "Jeff Wayne's War of the Worlds";
            request.VenueName = "The O2";

            Pass generatedPass = generator.Generate(request);

            return new FileContentResult(generatedPass.GetPackage(), "application/vnd.apple.pkpass");
        }
Пример #2
0
        private void WriteStyleSpecificKeys(JsonWriter writer, PassGeneratorRequest request)
        {
            EventPassGeneratorRequest eventRequest = request as EventPassGeneratorRequest;

            if (eventRequest != null)
            {
                WriteEventRequestKeys(writer, eventRequest);
                return;
            }

            StoreCardGeneratorRequest storeCardRequest = request as StoreCardGeneratorRequest;

            if (storeCardRequest != null)
            {
                WriteStoreCardKeys(writer, storeCardRequest);
                return;
            }
        }
Пример #3
0
        private void WriteEventRequestKeys(JsonWriter writer, EventPassGeneratorRequest eventRequest)
        {
            writer.WritePropertyName("eventTicket");
            writer.WriteStartObject();

            writer.WritePropertyName("primaryFields");
            writer.WriteStartArray();

            writer.WriteStartObject();
            writer.WritePropertyName("key");
            writer.WriteValue("event");
            writer.WritePropertyName("value");
            writer.WriteValue(eventRequest.EventName);
            writer.WriteEndObject();

            writer.WriteStartObject();
            writer.WritePropertyName("key");
            writer.WriteValue("venue");
            writer.WritePropertyName("label");
            writer.WriteValue("Venue");
            writer.WritePropertyName("value");
            writer.WriteValue(eventRequest.VenueName);
            writer.WriteEndObject();

            writer.WriteStartObject();
            writer.WritePropertyName("dateStyle");
            writer.WriteValue("PKDateStyleMedium");
            writer.WritePropertyName("timeStyle");
            writer.WriteValue("PKDateStyleMedium");
            writer.WritePropertyName("isRelative");
            writer.WriteValue(true);

            writer.WritePropertyName("label");
            writer.WriteValue("Starts in");
            writer.WritePropertyName("key");
            writer.WriteValue("start");
            writer.WritePropertyName("value");
            writer.WriteValue("2012-12-31T20:03Z");

            writer.WriteEndObject();

            writer.WriteEndArray();
            writer.WriteEndObject();
        }
Пример #4
0
        public ActionResult Index()
        {
            PassGenerator generator = new PassGenerator();

            EventPassGeneratorRequest request = new EventPassGeneratorRequest();
            request.Identifier = "pass.tomsamcguinness.events";
            request.CertThumbprint = ConfigurationManager.AppSettings["PassBookCertificateThumbprint"];
            request.CertLocation = System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser;
            request.FormatVersion = 1;
            request.SerialNumber = "121212";
            request.Description = "My first pass";
            request.OrganizationName = "Tomas McGuinness";
            request.TeamIdentifier = "Team America";
            request.LogoText = "My Pass";
            request.BackgroundColor = "#FFFFFF";
            request.ForegroundColor = "#000000";

            request.BackgroundFile = Server.MapPath(@"~/Icons/Starbucks/background.png");
            request.BackgroundRetinaFile = Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            request.IconFile = Server.MapPath(@"~/Icons/icon.png");
            request.IconRetinaFile = Server.MapPath(@"~/Icons/[email protected]");

            request.LogoFile = Server.MapPath(@"~/Icons/logo.png");
            request.LogoRetinaFile = Server.MapPath(@"~/Icons/[email protected]");

            request.EventName = "Jeff Wayne's War of the Worlds";
            request.VenueName = "The O2";

            request.AuthenticationToken = "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc";
            request.WebServiceUrl = "http://192.168.1.59:82/api";

            request.AddBarCode("01927847623423234234", BarcodeType.PKBarcodeFormatPDF417, "UTF-8", "01927847623423234234");

            Pass generatedPass = generator.Generate(request);

            return new FileContentResult(generatedPass.GetPackage(), "application/vnd.apple.pkpass");
        }
Пример #5
0
        private void WriteEventRequestKeys(JsonWriter writer, EventPassGeneratorRequest eventRequest)
        {
            writer.WritePropertyName("eventTicket");
            writer.WriteStartObject();

            writer.WritePropertyName("primaryFields");
            writer.WriteStartArray();

            writer.WriteStartObject();
            writer.WritePropertyName("key");
            writer.WriteValue("event-name");
            writer.WritePropertyName("value");
            writer.WriteValue(eventRequest.EventName);
            writer.WriteEndObject();

            writer.WriteStartObject();
            writer.WritePropertyName("key");
            writer.WriteValue("venue-name");
            writer.WritePropertyName("label");
            writer.WriteValue("Venue");
            writer.WritePropertyName("value");
            writer.WriteValue(eventRequest.VenueName);
            writer.WriteEndObject();

            writer.WriteStartObject();
            writer.WritePropertyName("dateStyle");
            writer.WriteValue("PKDateStyleMedium");
            writer.WritePropertyName("timeStyle");
            writer.WriteValue("PKDateStyleMedium");
            writer.WritePropertyName("isRelative");
            writer.WriteValue(true);

            writer.WritePropertyName("label");
            writer.WriteValue("Starts in");
            writer.WritePropertyName("key");
            writer.WriteValue("start-time");
            writer.WritePropertyName("value");
            writer.WriteValue("2012-12-31T20:03Z");

            writer.WriteEndObject();

            writer.WriteEndArray();
            writer.WriteEndObject();
        }