Пример #1
0
 public static async void HttpPost(string id, string touser, string phone, string image, string name)
 {
     try
     {
         HttpClient                httpClient = new HttpClient();
         string                    posturi    = Config.apiDreamingPraise;
         HttpRequestMessage        request    = new HttpRequestMessage(HttpMethod.Post, new Uri(posturi));
         HttpFormUrlEncodedContent postData   = new HttpFormUrlEncodedContent(
             new List <KeyValuePair <string, string> >
         {
             new KeyValuePair <string, string>("id", id),
             new KeyValuePair <string, string>("to", touser),
             new KeyValuePair <string, string>("phone", phone),
             new KeyValuePair <string, string>("image", image),
             new KeyValuePair <string, string>("name", name),
         }
             );
         request.Content = postData;
         HttpResponseMessage response = await httpClient.SendRequestAsync(request);
     }
     catch (Exception ex)
     {
         HelpMethods.Msg(ex.Message.ToString());
     }
 }
Пример #2
0
        async void Load()
        {
            string uri      = Config.apiCommentUserGet + Config.UserPhone;
            string response = await HttpGet.HttpGets(uri);

            if (response != null)
            {
                try
                {
                    JsonArray jsonList = JsonArray.Parse(response);
                    foreach (var item in jsonList)
                    {
                        JsonObject user      = item.GetObject();
                        UserModel  userModel = new UserModel();
                        userModel.uid   = user.GetNamedString("user_phone");
                        userModel.name  = user.GetNamedString("user_name");
                        userModel.image = user.GetNamedString("user_image");
                        userModel.day   = user.GetNamedString("post_id"); //文章ID

                        UserList.Add(userModel);
                    }
                }
                catch (Exception ex)
                {
                    HelpMethods.Msg(ex.Message.ToString());
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Tries to find the method that should be called.
        /// </summary>
        /// <param name="methodCall">The methodCall can be wrapped</param>
        /// <returns></returns>
        protected MethodInfo FindMethodInDomain(IMethodCall methodCall)
        {
            foreach (MethodInfo methodInfo in domainService.GetType().GetMethods())
            {
                if (methodCall.MethodName.ToLower() != methodInfo.Name.ToLower())
                {
                    continue;
                }

                List <ParameterInfo> parameterResult = methodInfo.GetParameters().ToList <ParameterInfo>();
                if ((parameterResult.Count != methodCall.Args.Count) &&
                    (HelpMethods.AddTrueForSpecified(parameterResult, methodInfo) != methodCall.Args.Count))
                {
                    continue;
                }

                if (!HelpMethods.TypesAreEqual(methodCall.Classes, parameterResult.ToArray <ParameterInfo>()))
                {
                    continue;
                }

                return(methodInfo);
            }

            return(null);
        }
    static JsonMoves.Day.Segment SegmentMove(XmlTimeline.Activity item)
    {
        JsonMoves.Day.Segment output = new JsonMoves.Day.Segment(JsonMoves.SegmentType.move, item.startTime, item.endTime);

        // TrackPoints
        List <JsonMoves.Day.Segment.Activity.TrackPoint> trackpoints = new List <JsonMoves.Day.Segment.Activity.TrackPoint>();

        foreach (var waypoint in item.waypoints)
        {
            trackpoints.Add(new JsonMoves.Day.Segment.Activity.TrackPoint(waypoint.lat, waypoint.lon, waypoint.time.Value));
        }

        // Setup
        List <JsonMoves.Day.Segment.Activity> activity = new List <JsonMoves.Day.Segment.Activity>();

        activity.Add(new JsonMoves.Day.Segment.Activity(item.activity,
                                                        HelpMethods.ReturnGroup(item.activity),
                                                        item.startTime,
                                                        item.endTime,
                                                        item.Duration,
                                                        item.Distance,
                                                        item.Calories,
                                                        trackpoints));
        output.activities = activity.ToArray();
        return(output);
    }
 public Segment(SegmentType type, DateTime startTime, DateTime endTime)
 {
     this.type      = type;
     this.startTime = HelpMethods.ConvertToIso1601(startTime);
     this.endTime   = HelpMethods.ConvertToIso1601(endTime);
     lastUpdate     = HelpMethods.ConvertToIso1601(DateTime.Now);
 }
Пример #6
0
        public void TestExtendingTypeAtRunrimeAndAddOpenEngSBModelEntries()
        {
            Type   type        = HelpMethods.ImplementTypeDynamicly(typeof(Entry1), typeof(IOpenEngSBModel));
            Object entryObject = Activator.CreateInstance(type);
            Entry1 entry       = (Entry1)entryObject;

            entry.key   = "test";
            entry.value = 1;
            List <openEngSBModelEntry> elements = new List <openEngSBModelEntry>();
            openEngSBModelEntry        osbEntry = new openEngSBModelEntry();

            osbEntry.key   = "key";
            osbEntry.type  = "type";
            osbEntry.value = "value";
            elements.Add(osbEntry);

            IOpenEngSBModel entryOpenEngSB = (IOpenEngSBModel)entry;

            entryOpenEngSB.OpenEngSBModelTail = elements;

            String          objString         = marshaller.MarshallObject(entry);
            IOpenEngSBModel objUnmarshalled   = (IOpenEngSBModel)marshaller.UnmarshallObject(objString, type);
            Entry1          entryUnmarshalled = (Entry1)objUnmarshalled;

            Assert.IsTrue(objString.ToUpper().Contains("OPENENGSBMODELTAIL"));
            Assert.IsTrue(entryObject is Entry1);
            Assert.IsTrue(entryObject is IOpenEngSBModel);
            Assert.AreEqual(elements.Count, objUnmarshalled.OpenEngSBModelTail.Count);
            Assert.AreEqual(objUnmarshalled.OpenEngSBModelTail[0].key, osbEntry.key);
            Assert.AreEqual(objUnmarshalled.OpenEngSBModelTail[0].type, osbEntry.type);
            Assert.AreEqual(objUnmarshalled.OpenEngSBModelTail[0].value, osbEntry.value);
            Assert.AreEqual(entryUnmarshalled.key, entry.key);
            Assert.AreEqual(entryUnmarshalled.value, entry.value);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            serializer.NullValueHandling = NullValueHandling.Ignore;
            if (IsMapType(objectType))
            {
                IDictionary list = new Dictionary <Object, Object>();
                serializer.Populate(reader, list);
                return(list.ConvertMap(objectType));
            }
            else if (IsException(objectType))
            {
                Object exceptionObject = Activator.CreateInstance(HelpMethods.ImplementTypeDynamicly(objectType, typeof(IJavaException)));
                serializer.Populate(reader, exceptionObject);
                return(exceptionObject);
            }

            Type typeWithIOpenEngSBModel;

            if (alreadyExtendedTypes.ContainsKey(objectType.Name))
            {
                typeWithIOpenEngSBModel = alreadyExtendedTypes[objectType.Name];
            }
            else
            {
                typeWithIOpenEngSBModel = HelpMethods.ImplementTypeDynamicly(objectType, typeof(IOpenEngSBModel));
                alreadyExtendedTypes.Add(objectType.Name, typeWithIOpenEngSBModel);
            }

            Object modelWithOpenEngsbModelTail = Activator.CreateInstance(typeWithIOpenEngSBModel);

            serializer.Populate(reader, modelWithOpenEngsbModelTail);
            return(modelWithOpenEngsbModelTail);
        }
Пример #8
0
 public void TestIfUrlsAreCorrectlyReverted()
 {
     Assert.AreEqual(HelpMethods.ReverseURL("http://example.domain.openengsb.org"), "org.openengsb.domain.example");
     Assert.AreEqual(HelpMethods.ReverseURL("http://example.domain.openengsb.org/"), "org.openengsb.domain.example");
     Assert.AreEqual(HelpMethods.ReverseURL("example.domain.openengsb.org"), "org.openengsb.domain.example");
     Assert.AreEqual(HelpMethods.ReverseURL("example.domain.openengsb.org/"), "org.openengsb.domain.example");
 }
Пример #9
0
 private void TextBox_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter && chatText.Text != null)
     {
         MessageModel message = new MessageModel();
         message.myImage = Config.UserImage;
         message.myPhone = Config.UserPhone;
         message.myName  = Config.UserName;
         message.myDream = Config.UserDream;
         message.type    = 0;
         message.msg     = chatText.Text;
         message.toPhone = User.uid;
         message.toImage = User.image;
         message.time    = HelpMethods.GetTimeNow();
         messageList.Add(message);
         if (myChat.Items.Count > 0)
         {
             myChat.ScrollIntoView(myChat.Items.Last(), ScrollIntoViewAlignment.Leading);
         }
         DbService.Current.Add(message);
         string messageJSON = JsonConvert.SerializeObject(message);
         SocKetHelp.socket.Emit("chat", messageJSON);
         chatText.Text = string.Empty;
         this.Focus(FocusState.Keyboard);
     }
 }
Пример #10
0
        public void TestIniti()
        {
            this.TestInitialize();
            this.applicationMainPage   = new ApplicationMainPage(this.Driver);
            this.loginPage             = new LoginPage(this.Driver);
            this.loanParamPage         = new LoanParametersPage(this.Driver);
            this.personalDataPage      = new PersonalDataPage(this.Driver);
            this.addressPage           = new AddressPage(this.Driver);
            this.contactsPage          = new ContactsPage(this.Driver);
            this.additionalInfoPage    = new AdditionalInfoPage(this.Driver);
            this.creditsPage           = new OtherCreditsPage(this.Driver);
            this.incomePage            = new IncomePage(this.Driver);
            this.otherIncomePage       = new OtherIncomePage(this.Driver);
            this.homePage              = new HomePage(this.Driver);
            this.loanPaymentPage       = new LoanPaymentPage(this.Driver);
            this.printingDocumentsPage = new PrintingDocumentsPage(this.Driver);
            this.uploadDocumentsPage   = new UploadDocumentsPage(this.Driver);
            this.clientOpinionPage     = new ClientOpinionPage(this.Driver);
            this.fraudSuspicionsPage   = new FraudSuspicionPage(this.Driver);

            var user = AccessExcelData.GetTestData <User>("TestName", "TestUser", "Users", BaseConstants.UsersXlsxFilename);

            this.loginPage.AnotherUserLogin(user, BaseConstants.TestCRMUrl);
            pid = HelpMethods.GeneratePID(18, 0);
            Thread.Sleep(1500);
            addressPage.FillPreviousData(homePage, applicationMainPage, loanParamPage, personalDataPage, pid);
        }
Пример #11
0
        public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
        {
            if ((args.ContinuationData["Operation"] as string) == "ImageChat" && args.Files != null && args.Files.Count > 0)
            {
                StorageFile inFile = args.Files[0];



                MessageModel message1  = new MessageModel();
                string       imagePath = await HttpPostSignleImage.HttpPost(inFile);

                message1.type    = 2;
                message1.msg     = imagePath;
                message1.toPhone = User.uid;
                message1.myImage = Config.UserImage;
                message1.myPhone = Config.UserPhone;
                message1.myName  = Config.UserName;
                message1.myDream = Config.UserDream;
                message1.toImage = User.image;
                message1.time    = HelpMethods.GetTimeNow();
                messageList.Add(message1);

                if (myChat.Items.Count > 0)
                {
                    myChat.ScrollIntoView(myChat.Items.Last(), ScrollIntoViewAlignment.Leading);
                }

                string messageJSON = JsonConvert.SerializeObject(message1);
                SocKetHelp.socket.Emit("chat", messageJSON);
                DbService.Current.Add(message1);
            }
        }
Пример #12
0
        public void PersonalData_InvalidName_ShowError()
        {
            var personalData = AccessExcelData.GetTestData <PersonalData>("TestName", "Sanity", "PersonalData", CRMConstants.ApplicationXlsxFilename);

            personalData.Pid       = pid;
            personalData.BirthDate = HelpMethods.GetBirthDayByPid(pid);
            var origFirstName  = personalData.FirstName;
            var origSecondName = personalData.SecondName;
            var origLastName   = personalData.LastName;

            var wrongNames = BaseConstants.wrongNames;

            foreach (var name in wrongNames)
            {
                personalData.FirstName = name;
                this.personalDataPage.FillPersonalData(personalData);
                personalDataPage.AssertCirilik();
                personalDataPage.Refreshe();

                personalData.FirstName  = origFirstName;
                personalData.SecondName = name;
                this.personalDataPage.FillPersonalData(personalData);
                personalDataPage.AssertCirilik();
                personalDataPage.Refreshe();

                personalData.SecondName = origSecondName;
                personalData.LastName   = name;
                this.personalDataPage.FillPersonalData(personalData);
                personalDataPage.AssertCirilik();
                personalDataPage.Refreshe();

                personalData.LastName = origLastName;
            }
        }
Пример #13
0
        async void Find()
        {
            string uri      = Config.apiUserFind + Word;
            string response = await HttpGet.HttpGets(uri);

            if (response != null)
            {
                try
                {
                    JsonArray jsonList = JsonArray.Parse(response);
                    foreach (var item in jsonList)
                    {
                        JsonObject user      = item.GetObject();
                        UserModel  userModel = new UserModel();
                        userModel.uid   = user.GetNamedString("phone");
                        userModel.name  = user.GetNamedString("name");
                        userModel.image = Config.apiFile + user.GetNamedString("image");
                        userModel.dream = user.GetNamedString("dream");
                        UserList.Add(userModel);
                    }
                }
                catch (Exception ex)
                {
                    HelpMethods.Msg(ex.Message.ToString());
                }
            }
        }
Пример #14
0
        public void LoadPulseLimits(DatabaseContext context)
        {
            HelpMethods helpm = new HelpMethods();

            /* Hranice_Tep tep_limit = new Hranice_Tep
             * {
             *   Hranica_Slabe_Min = 50,
             *   Hranica_Slabe_Max = 90,
             *   Hranica_Stredne = 100,
             *   Hranica_Vysoke = 120,
             *   TimeStamp = DateTime.Now.ToShortTimeString()
             *
             * };*/
            Hranice_Tep tep_limit = new Hranice_Tep
            {
                Hranica_Slabe_Min = 60,
                Hranica_Slabe_Max = 106,
                Hranica_Stredne   = 117,
                Hranica_Vysoke    = 127,
                TimeStamp         = DateTime.Now.ToShortTimeString()
            };

            context.PulseLimit.Add(tep_limit);

            try
            {
                context.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #15
0
    //Generate the mesh from the half-edge data structure, which is called when we have flipped an edge
    public void GenerateMesh(HalfEdgeData2 triangleData_normalized)
    {
        //From half-edge to triangle while unnormalizing
        HashSet <Triangle2> triangles_2d = new HashSet <Triangle2>();

        foreach (HalfEdgeFace2 f in triangleData_normalized.faces)
        {
            //Each face has in this case three edges
            MyVector2 p1 = f.edge.v.position;
            MyVector2 p2 = f.edge.nextEdge.v.position;
            MyVector2 p3 = f.edge.nextEdge.nextEdge.v.position;

            //Unnormalize the point
            p1 = HelpMethods.UnNormalize(p1, normalizingBox, dMax);
            p2 = HelpMethods.UnNormalize(p2, normalizingBox, dMax);
            p3 = HelpMethods.UnNormalize(p3, normalizingBox, dMax);

            Triangle2 t = new Triangle2(p1, p2, p3);

            triangles_2d.Add(t);
        }


        //Make sure the triangles have the correct orientation
        //triangles_2d = HelpMethods.OrientTrianglesClockwise(triangles_2d);


        //From 2d to mesh in one step
        //Mesh displayMesh = _TransformBetweenDataStructures.Triangles2ToMesh(triangles_2d, useCompressedMesh: false);


        //Generate the triangle meshes
        GenerateTriangleMeshes(triangles_2d);
    }
Пример #16
0
        public void TestImplementOpenEngSBModelAtRuntimeIsCorrect()
        {
            Type type = HelpMethods.ImplementTypeDynamicly(typeof(Object), typeof(IOpenEngSBModel));

            Object entryObject = Activator.CreateInstance(type);

            Assert.IsFalse(entryObject is IOpenEngSBModel);
        }
Пример #17
0
 public Main()
 {
     this.InitializeComponent();
     HelpMethods.HideStatusBar();
     PushService.CreateChannel();
     this.NavigationCacheMode = NavigationCacheMode.Required;
     SocketInit();
 }
Пример #18
0
 private void InitializeProgressType()
 {
     LayoutRoot.Width             = HelpMethods.GetWindowsWidth();
     textBlockStatus.Visibility   = Visibility.Visible;
     textBlockStatus.FontSize     = 18;
     textBlockStatus.Text         = Text;
     textBlockStatus.TextWrapping = TextWrapping.Wrap;
 }
Пример #19
0
        public void TestTypesAreEqual2()
        {
            IList <string> parameters = new List <String>();

            parameters.Add("String");
            TestClass testClass = new TestClass();

            HelpMethods.TypesAreEqual(parameters, testClass.GetType().GetMethod("hasSpecified").GetParameters());
        }
Пример #20
0
        public void ClientPersonalData_ValidData_Created()
        {
            var personalData = AccessExcelData.GetTestData <PersonalData>("TestName", "Sanity", "PersonalData", CRMConstants.ApplicationXlsxFilename);

            personalData.Pid       = pid;
            personalData.BirthDate = HelpMethods.GetBirthDayByPid(pid);
            this.personalDataPage.FillPersonalData(personalData);
            this.applicationMainPage.SaveAndContiunueGoBackSaveAndContiunue();
        }
Пример #21
0
        public void CreditParameters_ValidData_Create()
        {
            var loanParameters = AccessExcelData.GetTestData <LoanParameters>("TestName", "valid", "LoanParameters", CRMConstants.ApplicationXlsxFilename);
            var pid            = HelpMethods.GeneratePID(18, 0);

            loanParameters.Pid = pid;
            this.loanParamPage.FillLoanParameters(loanParameters);
            this.applicationMainPage.SaveAndContiunueGoBackSaveAndContiunue();
        }
Пример #22
0
        public void TestAddTrueForSpecifiedFieldsWithAnObjectListWhereTheMethodParamertsAndTheListAreTheSame()
        {
            IList <string> parameters = new List <String>();

            parameters.Add("Integer");
            parameters.Add("Boolean");
            TestClass testClass = new TestClass();

            Assert.IsTrue(HelpMethods.TypesAreEqual(parameters, testClass.GetType().GetMethod("hasObjectSpecified").GetParameters()));
        }
Пример #23
0
        public void TestAddTrueForSpecifiedFieldsWithParameterInfoAsParametersWhereNoSpecifiedIsDefined()
        {
            TestClass testClass = new TestClass();

            ParameterInfo[]      tmp      = testClass.GetType().GetMethod("hasNoSpecified").GetParameters();
            List <ParameterInfo> elements = new List <ParameterInfo>(tmp);

            HelpMethods.AddTrueForSpecified(elements, testClass.GetType().GetMethod("hasNoSpecified"));
            Assert.AreEqual <int>(elements.Count, 2);
        }
Пример #24
0
        public void TestTypesAreNotEqual()
        {
            IList <string> parameters = new List <String>();

            parameters.Add("Integer");
            parameters.Add("Bo olean");
            TestClass testClass = new TestClass();

            Assert.IsFalse(HelpMethods.TypesAreEqual(parameters, testClass.GetType().GetMethod("hasSpecified").GetParameters()));
        }
Пример #25
0
        public void CreditParameters_InvalidPID_ShowError()
        {
            var loanParameters = AccessExcelData.GetTestData <LoanParameters>("TestName", "valid", "LoanParameters", CRMConstants.ApplicationXlsxFilename);
            var pid            = HelpMethods.GeneratePID(18, -1);

            loanParameters.Pid = pid;
            this.loanParamPage.FillLoanParameters(loanParameters);
            this.applicationMainPage.SaveAndContiunueTab();
            loanParamPage.AssertWrongPid();
        }
Пример #26
0
 public Summary(ActivityType activity, float duration, double distance, float calories)
 {
     this.activity = activity;
     group         = HelpMethods.ReturnGroup(activity);
     this.duration = duration;
     this.distance = Math.Round(distance * 1000);
     if (calories > 0)
     {
         this.calories = calories;
     }
 }
 static bool CheckIfSamePlace(Place place, JsonMoves.Day.Segment.Place jsonPlace)
 {
     if (place.name == jsonPlace.name)
     {
         if (HelpMethods.DistanceTo(place.location, jsonPlace.location) <= distanceTolerance)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #28
0
        public void Login()

        {
            if (phone == null || Password == null)
            {
                HelpMethods.Msg("请您输入完整手机号和密码!");
            }
            else
            {
                HttpPostLogin.HttpPost(Phone, Password);
            }
        }
Пример #29
0
        public void TestAddTrueForSpecifiedFieldsWithParameterInfoAsParameters()
        {
            TestClass testClass = new TestClass();

            ParameterInfo[]      tmp      = testClass.GetType().GetMethod("hasSpecified").GetParameters();
            List <ParameterInfo> elements = new List <ParameterInfo>(tmp);

            HelpMethods.AddTrueForSpecified(elements, testClass.GetType().GetMethod("hasSpecified"));

            Assert.AreEqual <int>(elements.Count, 1);
            Assert.IsTrue(elements[0] is object);
        }
Пример #30
0
        public void TestAddTrueForSpecifiedFieldsWithAnObjectListWhereTheMethodHasOnlyOneParameterAsParameters()
        {
            IList <Object> elements = new List <Object>();

            elements.Add("test");
            TestClass testClass = new TestClass();

            HelpMethods.AddTrueForSpecified(elements, testClass.GetType().GetMethod("hasOnlyOneField"));

            Assert.AreEqual <int>(elements.Count, 1);
            Assert.AreEqual <String>(elements[0].ToString(), "test");
        }