Ejemplo n.º 1
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.SelectedItem.ToString() != "Toate")
     {
         using (var db = new EntityFBio())
         {
             int classId = db.Classes.Where(s => s.ClassName == comboBox1.SelectedItem.ToString()).FirstOrDefault().Id;
             populateList(classId);
         }
     }
     else
     {
         listBox1.Items.Clear();
         listBox1.Items.Add("Nume\t\tTest\t\tPunctaj");
         string Mark = "";
         string Test = "";
         string User = "";
         using (var db = new EntityFBio())
         {
             foreach (var x in db.Results)
             {
                 AccountTest accountTest = db.AccountTests.Where(s => s.Id == x.AccountTestId).Select(s => s).FirstOrDefault();
                 User = accountTest.Account.User;
                 Test = accountTest.Test.Name;
                 Mark = x.Mark.ToString();
                 listBox1.Items.Add(User + "\t\t" + Test + "\t\t" + Mark);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public OrganizationTestEditModel CreateModel(Test test, AccountTest accountTest)
 {
     return(new OrganizationTestEditModel
     {
         TestId = test.Id,
         TestName = test.Name,
         Gender = (Gender)test.Gender,
     });
 }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            UserModel user = new UserModel();

            user.UserName        = username.Text;
            user.Password        = password.Text;
            user.ConfirmPassword = confirmpassword.Text;

            AccountTest test = new AccountTest();

            test.Should_regester_an_account(user);
        }
Ejemplo n.º 4
0
        public void Save(AccountTest domainObject)
        {
            var entity = Mapper.Map <AccountTest, AccountTestEntity>(domainObject);

            if (domainObject == null)
            {
                return;
            }
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                if (!adapter.SaveEntity(entity))
                {
                    throw new PersistenceFailureException();
                }
            }
        }
Ejemplo n.º 5
0
        public void CreateOrUpdateAccountGroupAccountInvitationTest()
        {
            string      email    = GetNewEmailAddress();
            AccountTest _account = new AccountTest();

            WebAccountService.TransitAccount t_user = _account.GetTransitInstance();
            t_user.Id = _account.EndPoint.CreateAccount(string.Empty, email, t_user);
            Assert.AreNotEqual(0, t_user.Id);
            Console.WriteLine("Created account: {0}", t_user.Id);
            // only members can create invitations
            WebGroupService.TransitAccountGroupAccountInvitation t_instance = GetTransitInstance();
            t_instance.AccountId   = t_user.Id;
            t_instance.RequesterId = _user.id;
            try
            {
                // make sure the user is not a member of the group
                Assert.IsNull(EndPoint.GetAccountGroupAccountByAccountGroupId(
                                  GetAdminTicket(), _user.id, _group_id));
                // create the account group invitation
                EndPoint.CreateOrUpdateAccountGroupAccountInvitation(_user.ticket, t_instance);
                Assert.IsTrue(false, "Expected Access Denied exception.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
                Assert.AreEqual("System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> SnCore.Services.ManagedAccount+AccessDeniedException: Access denied",
                                ex.Message.Split("\n".ToCharArray(), 2)[0],
                                string.Format("Unexpected exception: {0}", ex.Message));
            }
            // the user joins the group
            WebGroupService.TransitAccountGroupAccount t_accountinstance = new WebGroupService.TransitAccountGroupAccount();
            t_accountinstance.AccountGroupId  = _group_id;
            t_accountinstance.AccountId       = _user.id;
            t_accountinstance.IsAdministrator = false;
            t_accountinstance.Id = EndPoint.CreateOrUpdateAccountGroupAccount(GetAdminTicket(), t_accountinstance);
            // make sure the invitation can be now sent
            t_instance.Id = EndPoint.CreateOrUpdateAccountGroupAccountInvitation(_user.ticket, t_instance);
            Assert.AreNotEqual(0, t_instance.Id);

            // TODO: make sure another user can't see invitation
        }
Ejemplo n.º 6
0
        private void populateList(int classId)
        {
            listBox1.Items.Clear();
            listBox1.Items.Add("Nume\t\tTest\t\tPunctaj");
            string Mark = "";
            string Test = "";
            string User = "";

            using (var db = new EntityFBio())
            {
                foreach (var x in db.Results)
                {
                    AccountTest accountTest = db.AccountTests.Where(s => s.Id == x.AccountTestId).Select(s => s).FirstOrDefault();
                    User = accountTest.Account.User;
                    Test = accountTest.Test.Name;
                    Mark = x.Mark.ToString();
                    if (accountTest.Account.ClassId == classId)
                    {
                        listBox1.Items.Add(User + "\t\t" + Test + "\t\t" + Mark);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public async Task Main()
        {
            IAccount account = new AccountUsingLock(1000);
            var      tasks   = new Task[100];

            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = Task.Run(() => AccountTest <IAccount> .Update(account));
            }
            await Task.WhenAll(tasks);

            Console.WriteLine($"Account balance using lock {account.GetBalance()}");

            account = new AccountUsingMutex(1000);
            tasks   = new Task[100];
            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = Task.Run(() => AccountTest <IAccount> .Update(account));
            }
            await Task.WhenAll(tasks);

            Console.WriteLine($"Account balance using mutex {account.GetBalance()}");
        }
Ejemplo n.º 8
0
        private void finalizareTest()
        {
            using (var db = new EntityFBio())
            {
                double  punctaj    = 90.0 / numarEnunturi;
                decimal rezultatul = (decimal)punctaj * corecte + 10;
                rezultatul = Math.Round(rezultatul, 2);
                if (!exersare)
                {
                    AccountTest accountTest = new AccountTest();
                    accountTest.UserId = User.Id;
                    accountTest.TestId = Test.Id;
                    db.AccountTests.Add(accountTest);
                    db.SaveChanges();

                    db.Results.Add(new Result {
                        Mark = rezultatul, AccountTestId = accountTest.Id
                    });
                    db.SaveChanges();
                }
                MessageBox.Show("Rezultat: " + rezultatul + " puncte");
            }
            abandon = 1;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Entry point for the Bank program.
        /// </summary>
        /// <param name="args">Arguments to the Bank program. Currently unused.</param>
        public static void Main(string[] args)
        {
            var accountTest = new AccountTest();

            accountTest.Run();
        }
 public CustomPrincipal(AccountTest accounttest)
 {
     this.AccountTest = accounttest;
     this.Identity    = new GenericIdentity(accounttest.UserName);
 }
Ejemplo n.º 11
0
    public void AccountCannotHaveNegativeOverdraftLimit()
    {
        AccountTest account = new AccountTest(-20);

        Assert.AreEqual(0, account.OverdraftLimit, epsilon);
    }
Ejemplo n.º 12
0
        public void AcceptAccountGroupAccountInvitationTest()
        {
            // login user
            string      email    = GetNewEmailAddress();
            AccountTest _account = new AccountTest();

            WebAccountService.TransitAccount t_user = _account.GetTransitInstance();
            t_user.Id = _account.EndPoint.CreateAccount(string.Empty, email, t_user);
            Assert.AreNotEqual(0, t_user.Id);
            Console.WriteLine("Created account: {0}", t_user.Id);
            string userticket = _account.Login(email, t_user.Password);

            // join user to group
            WebGroupService.TransitAccountGroupAccount t_account = new WebGroupService.TransitAccountGroupAccount();
            t_account.AccountGroupId  = _group_id;
            t_account.AccountId       = t_user.Id;
            t_account.IsAdministrator = false;
            t_account.Id = EndPoint.CreateOrUpdateAccountGroupAccount(userticket, t_account);
            Assert.AreNotEqual(0, t_account.Id);
            Console.WriteLine("Joined user: {0}", t_account.Id);
            // update the group to private
            WebGroupService.TransitAccountGroup t_group = EndPoint.GetAccountGroupById(GetAdminTicket(), _group_id);
            t_group.IsPrivate = true;
            EndPoint.CreateOrUpdateAccountGroup(GetAdminTicket(), t_group);
            Console.WriteLine("Updated group to private: {0}", _group_id);
            // create an invitatoin for user
            WebGroupService.TransitAccountGroupAccountInvitation t_instance = new WebGroupService.TransitAccountGroupAccountInvitation();
            t_instance.AccountGroupId = _group_id;
            t_instance.AccountId      = _user.id;
            t_instance.RequesterId    = t_account.AccountId;
            t_instance.Message        = GetNewString();
            t_instance.Id             = EndPoint.CreateOrUpdateAccountGroupAccountInvitation(GetAdminTicket(), t_instance);
            Console.WriteLine("Created invitation: {0}", t_instance.Id);
            // make sure the user isn't member of the group
            Assert.IsNull(EndPoint.GetAccountGroupAccountByAccountGroupId(GetAdminTicket(), _user.id, _group_id));
            // get the pending group membership requests
            WebGroupService.TransitAccountGroupAccountRequest[] requests1 = EndPoint.GetAccountGroupAccountRequests(
                GetAdminTicket(), _group_id, null);
            Console.WriteLine("Pending requests: {0}", requests1.Length);
            // accept invitation
            EndPoint.AcceptAccountGroupAccountInvitation(_user.ticket, t_instance.Id, GetNewString());
            // this has created a new request on the group, it should be +1
            WebGroupService.TransitAccountGroupAccountRequest[] requests2 = EndPoint.GetAccountGroupAccountRequests(
                GetAdminTicket(), _group_id, null);
            Console.WriteLine("Pending requests: {0}", requests2.Length);
            Assert.AreEqual(requests1.Length + 1, requests2.Length);
            // make sure there's an AccountId in the requests for the user
            WebGroupService.TransitAccountGroupAccountRequest request = null;
            Assert.IsTrue(new TransitServiceCollection <WebGroupService.TransitAccountGroupAccountRequest>(requests2).ContainsId(
                              _user.id, "AccountId", out request));
            Assert.IsNotNull(request);
            Console.WriteLine("New request: {0}", request.Id);
            // accept the request by admin
            EndPoint.AcceptAccountGroupAccountRequest(GetAdminTicket(), request.Id, GetNewString());
            // make sure the invitation was deleted
            Assert.IsNull(EndPoint.GetAccountGroupAccountInvitationById(_user.ticket, t_instance.Id));
            // make sure the request cannot be found any more
            WebGroupService.TransitAccountGroupAccountRequest[] requests3 = EndPoint.GetAccountGroupAccountRequests(
                GetAdminTicket(), _group_id, null);
            Console.WriteLine("Pending requests: {0}", requests3.Length);
            Assert.AreEqual(requests1.Length, requests3.Length);
            // make sure the user is member of the group
            WebGroupService.TransitAccountGroupAccount t_groupaccount = EndPoint.GetAccountGroupAccountByAccountGroupId(
                GetAdminTicket(), _user.id, _group_id);
            Assert.IsNotNull(t_groupaccount);
            Console.WriteLine("Account: {0}", t_groupaccount.Id);
            Assert.AreEqual(t_groupaccount.AccountId, _user.id);
            _account.Delete(GetAdminTicket(), t_user.Id);
        }
Ejemplo n.º 13
0
 public object Any(AccountTest test)
 {
     return("hello");
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Escolha uma opção");
            Console.WriteLine("1-Delegagte");
            Console.WriteLine("2-Lock");
            Console.WriteLine("3-SocketTCP");
            Console.WriteLine("4-Task");
            Console.WriteLine("5-Threads");
            Console.WriteLine("5-Collections");

            var key = Console.ReadLine();

            var opt = int.TryParse(key, out int result) ? result : 0;

            Console.WriteLine("\n");

            switch (opt)
            {
            case 1:
                // Creates one delegate for each method. For the instance method, an
                // instance (mySC) must be supplied. For the static method, use the
                // class name.
                mySampleClass    mySC = new mySampleClass();
                myMethodDelegate myD1 = new myMethodDelegate(mySC.myStringMethod);
                myMethodDelegate myD2 = new myMethodDelegate(mySampleClass.mySignMethod);

                // Invokes the delegates.
                Console.WriteLine("{0} is {1}; use the sign \"{2}\".", 5, myD1(5), myD2(5));
                Console.WriteLine("{0} is {1}; use the sign \"{2}\".", -3, myD1(-3), myD2(-3));
                Console.WriteLine("{0} is {1}; use the sign \"{2}\".", 0, myD1(0), myD2(0));
                break;

            case 2:
                Task.Run(async() => await AccountTest.MainSample()).Wait();
                break;

            case 3:
                SynchronousSocketClient.StartClient();
                break;

            case 4:
                TaskSample.MainSample();
                break;

            case 5:
                ThreadSample.Run();
                break;

            case 6:
                Console.WriteLine("Collections");
                Console.WriteLine("1-ConcurrentDictionary");

                Task.Run(async() => await TestDictionary.RunSample()).Wait();

                break;

            default:
                Console.WriteLine("Opção inválida");
                break;
            }
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            string appkey    = CommonUtils.GetDataConfig("appkey");
            string appsecret = CommonUtils.GetDataConfig("appsecret");
            string nickname  = CommonUtils.GetDataConfig("nickname");

            ChatApiTest chatApi = new ChatApiTest(appkey, appsecret, nickname);

            Console.WriteLine("------ChatTest-----");
            chatApi.testChatApiFrom("hello!!");
            chatApi.testChatApiJson("hello!!");
            chatApi.testApiChatGeoFrom("113.979399", "22.544891");
            chatApi.testApiChatGeoJson("113.979399", "22.544891");
            chatApi.testApiSpeechChatStream("../../chat-api/test.amr");
            chatApi.testApiSpeechChatData("../../chat-api/test.amr");

            Console.WriteLine("------TokenTest-----");
            string appChannel = CommonUtils.GetDataConfig("appChannel");
            string privateKey = CommonUtils.GetDataConfig("privateKey");

            TokenTest token = new TokenTest();

            Console.WriteLine(token.testGetToken(appChannel, privateKey));

            string apiRefreshToken = CommonUtils.GetDataConfig("apiRefreshToken");

            Console.WriteLine(token.testRefreshToken(apiRefreshToken));

            string apiToken = CommonUtils.GetDataConfig("apiToken");

            Console.WriteLine(token.testDeleteToken(apiToken));

            token.testGetToken(appChannel, privateKey);   //重新获取
            apiToken        = CommonUtils.GetDataConfig("apiToken");
            apiRefreshToken = CommonUtils.GetDataConfig("apiRefreshToken");

            Console.WriteLine("------AccountTest-----");
            AccountTest account = new AccountTest(apiToken);

            string testPhone = CommonUtils.GetDataConfig("testPhone");

            Console.WriteLine(account.testCaptchaSms(testPhone));

            string defaultPhone = CommonUtils.GetDataConfig("defaultPhone");
            string defaultSms   = CommonUtils.GetDataConfig("defaultSms");

            Console.WriteLine(account.testUserSignIn(defaultPhone, defaultSms));

            string userRefreshToken = CommonUtils.GetDataConfig("userRefreshToken");

            Console.WriteLine(account.testRefreshToken(userRefreshToken));

            string userToken = CommonUtils.GetDataConfig("userToken");

            Console.WriteLine(account.testUserSignOut(userToken));

            account.testUserSignIn(defaultPhone, defaultSms);   //重新登录
            userToken = CommonUtils.GetDataConfig("userToken");

            Console.WriteLine(account.testUserInfo(userToken));

            string businessId = CommonUtils.GetDataConfig("businessId");

            Console.WriteLine(account.testAddSubAccount(userToken, businessId));

            Console.WriteLine("------OrderTest-----");
            OrderTest order = new OrderTest(apiToken, userToken);

            string orderId = CommonUtils.GetDataConfig("orderId");

            Console.WriteLine(order.testGetOneOrder(orderId));

            int    state     = (int)Utils.StateType.CHUPIAOZHONG;
            string lastId    = CommonUtils.GetDataConfig("order_Id");
            int    pageSize  = 30;
            int    orderType = (int)Utils.OrderType.FLIGHT;

            Console.WriteLine(order.testGetOrderList(state.ToString(), lastId, pageSize.ToString(), orderType.ToString()));
            Console.WriteLine(order.testDeleteOneOrder(orderId));

            Console.WriteLine("------PaymentTest-----");
            PaymentTest payment     = new PaymentTest(apiToken, userToken);
            int         paymentType = (int)Utils.PaymentType.ALIPAY;

            Console.WriteLine(payment.testOrderPay(orderId, paymentType));
            Console.WriteLine(payment.testOrderPayQR(orderId, paymentType));

            Console.WriteLine("------WalletTest-----");
            WalletTest Wallet = new WalletTest(apiToken, userToken);

            Console.WriteLine(Wallet.testGetBalance());

            string amount  = "1";
            string payType = Utils.PayType.ALI_PAY.ToString();
            string mode    = Utils.PaymentMode.APP.ToString();

            Console.WriteLine(Wallet.testWalletRecharge(amount, payType, mode));
            Console.ReadKey();
        }