Exemple #1
0
        public void testSave()
        {
            var unLocode = new UnLocode("SESTO");

            var           trackingId     = new TrackingId("XYZ");
            var           completionTime = DateTime.Parse("2008-01-01");
            HandlingEvent @event         = HandlingEventFactory.createHandlingEvent(completionTime,
                                                                                    trackingId,
                                                                                    null,
                                                                                    unLocode,
                                                                                    HandlingActivityType.CLAIM,
                                                                                    null);

            HandlingEventRepository.store(@event);

            flush();

            var result = GenericTemplate.QueryForObjectDelegate(CommandType.Text,
                                                                String.Format("select * from HandlingEvent where sequence_number = {0}", @event.SequenceNumber),
                                                                (r, i) => new { CARGO_ID = r["CARGO_ID"], COMPLETIONTIME = r["COMPLETIONTIME"] });

            Assert.AreEqual(1L, result.CARGO_ID);
            Assert.AreEqual(completionTime, result.COMPLETIONTIME);
            // TODO: the rest of the columns
        }
        private void BuildConstructor(GenericTemplate classType, System.Reflection.ConstructorInfo constructorInfo)
        {
            var args = constructorInfo.GetParameters().Select(
                x => new VarInfo(
                    x.Name,
                    x.ParameterType.FullName == null?
                    GenericType.Get(x.ParameterType.GenericParameterPosition):
                    storage.GetType(ConvertMSILNames(x.ParameterType))
                    )).ToList();

            if (args.All(x => x.Type != null))
            {
                classType.AddConstructor(args);
            }
        }
Exemple #3
0
        /// <summary>
        /// Send Generic
        /// </summary>
        /// <param name="email">Email</param>
        /// <param name="fromName">From Name</param>
        /// <param name="subject">Subject</param>
        /// <param name="title">Email Title</param>
        /// <param name="body">Email Body</param>
        public void SendGeneric(string email, string fromName, string subject, string title, string body)
        {
            var template = new GenericTemplate()
            {
                Title = title,
                Body  = body,
            };

            try
            {
                this.Send(email, fromEmail, fromName, subject, template.TransformText());
            }
            catch
            {
            }
        }
        public void Build(GenericTemplate templateType, System.Type type)
        {
            var methods = type.GetMethods().Where(x => x.IsPublic && !x.IsStatic);

            foreach (var method in methods)
            {
                BuildMethod(templateType, method);
            }

            var constrInfo = type.GetConstructors().Where(x => x.IsPublic && !x.IsStatic);

            foreach (var item in constrInfo)
            {
                BuildConstructor(templateType, item);
            }
        }
Exemple #5
0
        GenericTemplate GenericTemplateTest()
        {
            var buttons = new List <Button>();

            buttons.Add(new UrlButton()
            {
                Type        = ButtonType.web_url,
                Title       = "Support document",
                URL         = "https://support.punnel.com/collection/40-bat-au",
                FallbackUrl = "https://support.punnel.com",
            });

            //buttons.Add(new PostbackButton
            //{
            //    Title = "Support",
            //    Payload = "PL_YES",
            //    Type = ButtonType.postback
            //});

            var elements = new List <Element>();

            elements.Add(new Element()
            {
                Title         = "Ueh University",
                SubTitle      = "Do you want support",
                ImageUrl      = "https://static.becungshop.vn/images/500x500/set-ao-thun-co-tru-lv-va-quan-short-jean-cho-be-trai-p2444980a9ba22-500x500.jpg",
                Buttons       = buttons,
                DefaultAction = new ElementDefaultAction()
                {
                    Type = ButtonType.web_url,
                    URL  = "https://support.punnel.com/article/38-huong-dan-gan-facebook-messenger-chat-vao-landing-page",
                    HasMessengerExtensions = false,
                    WebviewHeightRatio     = ContentSize.tall,
                    FallbackUrl            = "https://support.punnel.com"
                },
            });

            var t = new GenericTemplate()
            {
                Elements     = elements,
                TemplateType = TemplateType.generic
            };

            return(t);
        }
Exemple #6
0
        private void GetTypeInfo(System.Type stype)
        {
            if (stype.IsGenericType)
            {
                var template = new GenericTemplate(stype.Name, stype.GetGenericArguments().Length);

                storage.AddTemplate(template);
            }
            else
            {
                var type = stype.IsAbstract
                    ? new PackageType(stype.Name)
                    : new ClassType(stype.Name);

                storage.AddType(type);
            }

            nameConvertor.Register(stype.Assembly.GetName().Name, stype.Namespace, stype.Name, stype.Name);
        }
Exemple #7
0
        public void testSave()
        {
            TrackingId trackingId  = new TrackingId("AAA");
            Location   origin      = locationRepository.find(SampleLocations.STOCKHOLM.UnLocode);
            Location   destination = locationRepository.find(SampleLocations.MELBOURNE.UnLocode);

            Cargo cargo = new Cargo(trackingId, new RouteSpecification(origin, destination, DateTime.Now));

            cargoRepository.store(cargo);

            getSession().Flush();
            getSession().Clear();

            cargo = cargoRepository.find(trackingId);
            Assert.IsNull(cargo.Itinerary);

            cargo.AssignToRoute(
                new Itinerary(Leg.DeriveLeg(voyageRepository.find(new VoyageNumber("0101")),
                                            locationRepository.find(SampleLocations.STOCKHOLM.UnLocode),
                                            locationRepository.find(SampleLocations.MELBOURNE.UnLocode))));

            flush();

            var map = GenericTemplate.QueryForObjectDelegate(CommandType.Text,
                                                             String.Format("select * from Cargo where tracking_id = '{0}'", trackingId.Value),
                                                             (r, i) => new { TRACKING_ID = r["TRACKING_ID"] });

            Assert.AreEqual("AAA", map.TRACKING_ID);

            long originId = (long)getSession().GetIdentifier(cargo);
            //Assert.AreEqual(originId, map.get("SPEC_ORIGIN_ID"));

            long destinationId = (long)getSession().GetIdentifier(cargo);

            //Assert.AreEqual(destinationId, map.get("SPEC_DESTINATION_ID"));

            getSession().Clear();

            Cargo loadedCargo = cargoRepository.find(trackingId);

            Assert.AreEqual(1, loadedCargo.Itinerary.Legs.Count());
        }
Exemple #8
0
        public void testReplaceItinerary()
        {
            Cargo cargo   = cargoRepository.find(new TrackingId("FGH"));
            long  cargoId = (long)getSession().GetIdentifier(cargo);

            Assert.AreEqual(3,
                            GenericTemplate.ExecuteScalar(CommandType.Text,
                                                          String.Format("select count(*) from Leg where cargo_id = {0}", cargoId)));

            Location  legFrom      = locationRepository.find(new UnLocode("DEHAM"));
            Location  legTo        = locationRepository.find(new UnLocode("FIHEL"));
            Itinerary newItinerary = new Itinerary(Leg.DeriveLeg(SampleVoyages.atlantic2, legFrom, legTo));

            cargo.AssignToRoute(newItinerary);

            cargoRepository.store(cargo);
            flush();

            Assert.AreEqual(1,
                            GenericTemplate.ExecuteScalar(CommandType.Text,
                                                          String.Format("select count(*) from Leg where cargo_id = {0}", cargoId)));
        }
        private void BuildMethod(GenericTemplate classType, System.Reflection.MethodInfo type)
        {
            var list = new List <VarInfo>();

            foreach (var item in type.GetParameters())
            {
                if (item.ParameterType.FullName == null)
                {
                    list.Add(new VarInfo(item.Name, GenericType.Get(item.ParameterType.GenericParameterPosition)));
                }
                else
                {
                    var itemType = storage.GetType(ConvertMSILNames(item.ParameterType));
                    list.Add(new VarInfo(item.Name, itemType));
                }
            }

            var retType = type.ReturnType.FullName == null
                ? GenericType.Get(type.ReturnType.GenericParameterPosition)
                : storage.GetType(ConvertMSILNames(type.ReturnType));

            classType.AddMethod(type.Name, list, retType, false);
        }