Пример #1
0
        public void Merge_Reports_Only_Own_Properties()
        {
            var a   = new { W = 1, X = 2 };
            var cla = new Cla {
                X = 5
            };

            DynamicAssert.AreEqual(R.Merge(cla, a), new { W = 1, X = 2 });
            DynamicAssert.AreEqual(R.Merge(a, cla), new { W = 1, X = 2 });
        }
Пример #2
0
        public void MergeWithKey_Reports_Only_Own_Properties()
        {
            var a   = new { W = 1, X = 2 };
            var cla = new Cla {
                X = 5
            };

            DynamicAssert.AreEqual(R.MergeWithKey(last, new Cla(), a), new { W = 1, X = 2 });
            DynamicAssert.AreEqual(R.MergeWithKey(last, a, cla), new { W = 1, X = 2 });
            DynamicAssert.AreEqual(R.MergeWithKey(last, cla, new { W = 1 }), new { W = 1 });
        }
Пример #3
0
        public ActionResult ClaSubmit(Cla claModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    SmtpClient    smtp = new SmtpClient();
                    MailAddress   from = new MailAddress(claModel.Email);
                    MailAddress   to   = new MailAddress("*****@*****.**");
                    StringBuilder sb   = new StringBuilder();
                    MailMessage   msg  = new MailMessage(from, to);

                    msg.Subject    = "New CLA Submission from " + claModel.FullName;
                    msg.IsBodyHtml = false;
                    smtp.Host      = "whoaverse.com";
                    smtp.Port      = 25;

                    //format CLA email
                    sb.Append("Full name: " + claModel.FullName);
                    sb.Append(Environment.NewLine);
                    sb.Append("Email: " + claModel.Email);
                    sb.Append(Environment.NewLine);
                    sb.Append("Mailing address: " + claModel.MailingAddress);
                    sb.Append(Environment.NewLine);
                    sb.Append("City: " + claModel.City);
                    sb.Append(Environment.NewLine);
                    sb.Append("Country: " + claModel.Country);
                    sb.Append(Environment.NewLine);
                    sb.Append("Phone number: " + claModel.PhoneNumber);
                    sb.Append(Environment.NewLine);
                    sb.Append("Corporate contributor information: " + claModel.CorpContrInfo);
                    sb.Append(Environment.NewLine);
                    sb.Append("Electronic signature: " + claModel.ElectronicSignature);
                    sb.Append(Environment.NewLine);

                    msg.Body = sb.ToString();

                    //send the email with CLA data
                    smtp.Send(msg);
                    msg.Dispose();
                    ViewBag.SelectedSubverse = string.Empty;
                    return(View("~/Views/Legal/ClaSent.cshtml"));
                }
                catch (Exception)
                {
                    ViewBag.SelectedSubverse = string.Empty;
                    return(View("~/Views/Legal/ClaFailed.cshtml"));
                }
            }
            else
            {
                return(View());
            }
        }
Пример #4
0
    void Start()
    {
        int a1, int a2, int b1, int b2, ref int c1, ref int c2
        Cla a = new Cla();
        Cla b = new Cla();
        Cla c = new Cla();//怎么给结构体创造新的空间啊

        a1      = a2 = 30 / 2;
        b1 - b2 = 42;
        b1 + b2 = 36;
        c1 + c2 = 42;
        return(c1, c2);
    }
Пример #5
0
        public ActionResult ClaSubmit(Cla claModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("~/Views/Legal/Cla.cshtml"));
            }

            var from = new MailAddress(claModel.Email);
            var to   = new MailAddress("*****@*****.**");
            var sb   = new StringBuilder();
            var msg  = new MailMessage(@from, to)
            {
                Subject = "New CLA Submission from " + claModel.FullName
            };

            // format CLA email
            sb.Append("Full name: " + claModel.FullName);
            sb.Append(Environment.NewLine);
            sb.Append("Email: " + claModel.Email);
            sb.Append(Environment.NewLine);
            sb.Append("Mailing address: " + claModel.MailingAddress);
            sb.Append(Environment.NewLine);
            sb.Append("City: " + claModel.City);
            sb.Append(Environment.NewLine);
            sb.Append("Country: " + claModel.Country);
            sb.Append(Environment.NewLine);
            sb.Append("Phone number: " + claModel.PhoneNumber);
            sb.Append(Environment.NewLine);
            sb.Append("Corporate contributor information: " + claModel.CorpContrInfo);
            sb.Append(Environment.NewLine);
            sb.Append("Electronic signature: " + claModel.ElectronicSignature);
            sb.Append(Environment.NewLine);

            msg.Body = sb.ToString();

            // send the email with CLA data
            if (EmailUtility.SendEmail(msg))
            {
                msg.Dispose();
                ViewBag.SelectedSubverse = string.Empty;
                return(View("~/Views/Legal/ClaSent.cshtml"));
            }
            ViewBag.SelectedSubverse = string.Empty;
            return(View("~/Views/Legal/ClaFailed.cshtml"));
        }
        public async Task <IActionResult> CreateNew([Required][FromBody] CLADTO request)
        {
            var newCla = new Cla()
            {
                Active      = request.Active,
                RawMarkdown = request.RawMarkdown,
            };

            bool inactivated = false;

            // Other active CLAs need to become inactive if new one is added
            if (newCla.Active)
            {
                foreach (var cla in await database.Clas.Where(c => c.Active).ToListAsync())
                {
                    cla.Active  = false;
                    inactivated = true;
                    logger.LogInformation("CLA {Id} is being made inactive due to creating a new one", cla.Id);
                }
            }

            var user = HttpContext.AuthenticatedUser() !;

            await database.AdminActions.AddAsync(new AdminAction()
            {
                Message       = $"New CLA with active status: {newCla.Active} created",
                PerformedById = user.Id,
            });

            await database.Clas.AddAsync(newCla);

            await database.SaveChangesAsync();

            logger.LogInformation("New CLA {Id} with active: {Active} created by {Email}", newCla.Id,
                                  newCla.Active, user.Email);

            if (inactivated)
            {
                jobClient.Enqueue <InvalidatePullRequestsWithCLASignaturesJob>(x => x.Execute(CancellationToken.None));
            }

            return(Ok());
        }
        protected sealed override void Seed()
        {
            var cla1Signature1 = new ClaSignature()
            {
                Email = CLA1Signature1Email,
                ClaSignatureStoragePath = "cla1/signature1",
                DeveloperUsername       = "******",
                GithubAccount           = CLA1Signature1Github,
            };

            var cla1 = new Cla()
            {
                Active      = false,
                Id          = CLA1Id,
                RawMarkdown = "CLA 1",
                Signatures  = new HashSet <ClaSignature>()
                {
                    cla1Signature1,
                }
            };

            cla1Signature1.Cla = cla1;

            var cla2Signature1 = new ClaSignature()
            {
                Email = CLA2Signature1Email,
                ClaSignatureStoragePath = "cla2/signature1",
                DeveloperUsername       = CLA2Signature1DeveloperUsername,
                GithubAccount           = CLA2Signature1Github,
            };

            var cla2Signature2 = new ClaSignature()
            {
                Email = CLA2Signature2Email,
                ClaSignatureStoragePath = "cla2/signature2",
                GithubAccount           = CLA2Signature2Github,
            };

            var cla2 = new Cla()
            {
                Active      = true,
                Id          = CLA2Id,
                RawMarkdown = "CLA 2",
                Signatures  = new HashSet <ClaSignature>()
                {
                    cla2Signature1,
                    cla2Signature2,
                }
            };

            cla2Signature1.Cla = cla2;
            cla2Signature2.Cla = cla2;

            Database.Clas.Add(cla1);
            Database.ClaSignatures.Add(cla1Signature1);

            Database.Clas.Add(cla2);
            Database.ClaSignatures.Add(cla2Signature1);
            Database.ClaSignatures.Add(cla2Signature2);

            if (CLA1Signature1Github.Length <= AppInfo.PartialGithubMatchRevealAfterLenght)
            {
                throw new Exception("configured github name is too short");
            }

            if (CLA2Signature2Email.Length <= AppInfo.PartialEmailMatchRevealAfterLenght)
            {
                throw new Exception("configured email is too short");
            }

            Database.SaveChanges();
        }