public async Task AfterCreate(BranchGroup group, string latestBranchName, string branchName, Func <IReactiveProcess, RepositoryActionReactiveProcessEntry> appendProcess)
 {
     if (latestBranchName != null && latestBranchName != branchName)
     {
         await gitServiceApi.MigrateOrClosePullRequests(fromBranch : latestBranchName, toBranch : branchName);
     }
 }
Пример #2
0
        public async Task <ApiResult <OrderDto> > GetOrderAsync(string orderId)
        {
            var hasPaid      = _context.ReceiptVouchers.Where(x => x.OrderId == orderId).Sum(x => x.Received);
            var orderDetails = await(from o in _context.Orders
                                     join customer in _context.Customers on o.CustomerId equals customer.Id
                                     into CustomerGroup
                                     from c in CustomerGroup.DefaultIfEmpty()
                                     join ts in _context.TransactionStatuses on o.TransactionStatusId equals ts.Id
                                     join ps in _context.PaymentStatuses on o.PaymentStatusId equals ps.Id
                                     join branch in _context.Branches on o.BranchId equals branch.Id
                                     into BranchGroup
                                     from b in BranchGroup.DefaultIfEmpty()
                                     join employee in _context.Employees on o.EmployeeId equals employee.Id
                                     into EmployeesGroup
                                     from e in EmployeesGroup.DefaultIfEmpty()
                                     where o.Id == orderId
                                     select new OrderDto()
            {
                Id                    = o.Id,
                BranchName            = b.Name,
                CustomerName          = string.IsNullOrEmpty(c.Name)?o.CustomerName:c.Name,
                DateCreated           = o.DateCreated,
                Description           = o.Description,
                DiscountDescription   = o.DiscountDescription,
                DiscountType          = o.DiscountType,
                DiscountValue         = o.DiscountValue,
                EmployeeName          = e.Name,
                CustomerAddress       = o.CustomerAddress,
                CustomerPhone         = o.CustomerPhone,
                PaymentStatusName     = ps.Name,
                TransactionStatusName = ts.Name,
                OrderDetailsDtos      = (from od in _context.OrderDetails
                                         join product in _context.Products on od.ProductId equals product.Id
                                         into ProductsGroup
                                         from p in ProductsGroup.DefaultIfEmpty()
                                         where od.OrderId == o.Id
                                         select new OrderDetailsDto()
                {
                    Id = od.Id,
                    ProductId = od.ProductId,
                    Quantity = od.Quantity,
                    ServiceName = od.ServiceName,
                    UnitPrice = od.UnitPrice,
                    ProductName = p.Name
                }).ToList(),
                TotalAmount = o.TotalAmount,
                RestAmount  = o.TotalAmount - hasPaid,
                CustomerId  = c.Id
            }).SingleOrDefaultAsync();

            if (orderDetails == null)
            {
                return(new ApiResult <OrderDto>(HttpStatusCode.NotFound, $"Không tìm thấy đơn hàng có mã: {orderId}"));
            }
            return(new ApiResult <OrderDto>(HttpStatusCode.OK, orderDetails));
        }
Пример #3
0
 public IObservable <string> LatestBranchName(BranchGroup details)
 {
     return(
         from remoteBranches in this.repositoryState.RemoteBranches()
         select branchIteration.GetLatestBranchNameIteration(
             details.GroupName,
             from remoteBranch in remoteBranches
             where this.branchIteration.IsBranchIteration(details.GroupName, remoteBranch.Name)
             select remoteBranch.Name
             )
         );
 }
Пример #4
0
        public override Task <BooleanObject> DeleteBranchGroup(KeyObject request, Grpc.Core.ServerCallContext context)
        {
            var branchGroup = new BranchGroup()
            {
                Id = Convert.ToInt32(request.Body)
            };
            var success = _branchGroupDao.Delete(branchGroup);

            return(Task.FromResult(new BooleanObject()
            {
                Body = success
            }));
        }
        public async Task AfterCreate(BranchGroup group, string latestBranchName, string createdBranchName, Func <IReactiveProcess, RepositoryActionReactiveProcessEntry> appendProcess)
        {
            var allRefs = await repository.GetAllBranchRefs().FirstOrDefaultAsync();

            var targetUpdateBranchName = createdBranchName == group.GroupName
                ? await repository.GetNextCandidateBranch(group).FirstOrDefaultAsync()
                : group.GroupName;

            await appendProcess(cli.Push(createdBranchName, targetUpdateBranchName, force: true));

            var createdRef = await repository.GetBranchRef(createdBranchName).FirstOrDefaultAsync();

            await repository.BranchUpdated(targetUpdateBranchName, createdRef, await repository.GetBranchRef(targetUpdateBranchName).FirstOrDefaultAsync());
        }
Пример #6
0
        public void Update(MasterBranchGroupView model)
        {
            using (var ctx = new ConXContext())
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    BranchGroup updateObj = ctx.BranchGroups.Where(z => z.branchGroupId == model.branchGroupId).SingleOrDefault();

                    updateObj.branchGroupCode = model.branchGroupCode;
                    updateObj.branchGroupName = model.branchGroupName;
                    updateObj.updateUser      = model.updateUser;
                    updateObj.updateDatetime  = DateTime.Now;
                    ctx.SaveChanges();
                    scope.Complete();
                }
            }
        }
Пример #7
0
        public IMergeStrategy GetMergeStrategy(BranchGroup branchGroup)
        {
            switch (branchGroup.UpstreamMergePolicy)
            {
            case UpstreamMergePolicy.None:
                return(normal);

            case UpstreamMergePolicy.MergeNextIteration:
                return(mergeNextIteration);

            case UpstreamMergePolicy.ForceFresh:
                return(forceFresh);

            default:
                throw new NotImplementedException();
            }
        }
Пример #8
0
        public bool CheckDupplicate(string code, long id)
        {
            using (var ctx = new ConXContext())
            {
                BranchGroup model = ctx.BranchGroups
                                    .Where(x => (x.branchGroupCode == code))
                                    .SingleOrDefault();

                bool isDup = model != null;
                if (id > 0 && model != null)
                {
                    BranchGroup oldModel = ctx.BranchGroups.Where(z => z.branchGroupId == id).SingleOrDefault();
                    isDup = code != oldModel.branchGroupCode;
                }

                return(isDup);
            }
        }
Пример #9
0
 private void FillPropNames(BranchGroup T)
 {
     if (T != null)
     {
         PropertyInfo[] properties1 = T.GetType().GetProperties();
         foreach (var p in properties1)
         {
             string s = p.PropertyType.ToString();
             if (!p.PropertyType.IsClass || p.PropertyType.ToString().Contains("String"))
             {
                 if (!p.PropertyType.ToString().Contains("ICollection"))
                 {
                     HeaderList.Add(p.Name);
                 }
             }
         }
     }
 }
Пример #10
0
    Branch CreateBranch(Branch parent, BranchGroup group, float p, float rot)
    {
        float      r           = radius;
        float      l           = height;
        Vector3    pos         = Vector3.zero;
        Quaternion orientation = Quaternion.Euler(-90f, 0f, 0f);

        if (parent != null)
        {
            r = parent.radius * group.radiusScale;
            l = parent.length * group.lengthScale;

            float jf    = p * (parent.points.Length - 1);
            int   ji    = (int)jf;
            float jt    = jf - ji;
            int   ji2   = Mathf.Min(parent.points.Length - 1, ji + 1);
            float taper = Mathf.Pow(1f - p, group.taperBias);

            r *= taper;
            l *= Mathf.Max(taper, .5f) * Random.Range(.8f, 1.2f);

            pos          = Vector3.Lerp(parent.points[ji], parent.points[ji2], jt);
            orientation  = Quaternion.Lerp(parent.orientations[ji], parent.orientations[ji2], jt);
            orientation *= Quaternion.Euler(0, 0, rot) * Quaternion.Euler(-90f * (1f - group.forward), 0, 0);
        }

        Branch branch = new Branch()
        {
            radius = r,
            length = l,
            leaves = group.leaves,
            group  = group,
        };

        BuildBranch(branch, pos, Quaternion.LookRotation(orientation * Vector3.forward));

        if (parent != null)
        {
            parent.children.Add(branch);
        }

        return(branch);
    }
Пример #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pcSaleId"></param>
        /// <returns></returns>
        public MasterBranchGroupView GetInfo(long id)
        {
            using (var ctx = new ConXContext())
            {
                BranchGroup model = ctx.BranchGroups
                                    .Where(z => z.branchGroupId == id).SingleOrDefault();

                return(new MasterBranchGroupView
                {
                    branchGroupId = model.branchGroupId,
                    branchGroupCode = model.branchGroupCode,
                    branchGroupName = model.branchGroupName,
                    createUser = model.createUser,
                    createDatetime = model.createDatetime,
                    updateUser = model.updateUser,
                    updateDatetime = model.updateDatetime ?? DateTime.Now
                });
            }
        }
Пример #12
0
 /// <summary>Add a list of players to the active branches.</summary>
 /// <param name="players">The roster indices of the players.</param>
 /// <param name="branch">The branch data to pair with.</param>
 /// <param name="merge">If the branch has been picked before, should this player join that group?</param>
 public void PickBranch(List <int> players, Branch branch, bool merge = true)
 {
     if (merge)
     {
         var key = branch.ID;
         if (activeBranches.ContainsKey(key))
         {
             activeBranches[key].Players.Merge(players);
         }
         else
         {
             activeBranches[key] = new BranchGroup(players, branch);
         }
     }
     else
     {
         var group     = new BranchGroup(players, branch);
         var randomKey = branch.ID + UnityEngine.Random.Range(0, int.MaxValue);
         activeBranches[randomKey] = group;
     }
 }
Пример #13
0
    Branch[] CreateBranchGroup(Branch parent, int groupIndex)
    {
        BranchGroup group = groups[groupIndex];

        List <float> ptmp = new List <float>();

        float[] rotations = new float[group.frequency];
        for (int i = 0; i < group.frequency; i++)
        {
            ptmp.Add(Mathf.Clamp01(group.branchHeight + (1f - group.branchHeight) * (1f - Mathf.Pow(Random.value, group.heightBias))));
            rotations[i] = (i == 0 ? 0f : rotations[i - 1]) + Random.Range(90f, 270f);
        }
        ptmp.Sort();
        float[] positions = ptmp.ToArray();

        for (int i = 0; i < group.branchSpread; i++)
        {
            float[] tmp = new float[positions.Length];
            for (int j = 0; j < positions.Length; j++)
            {
                float prev = j == 0 ? group.branchHeight : positions[j - 1];
                float next = j == positions.Length - 1 ? 1f : positions[j + 1];
                tmp[j] = (prev + next) * .5f;
            }
            positions = tmp;
        }

        Branch[] branches = new Branch[group.frequency];
        for (int i = 0; i < group.frequency; i++)
        {
            branches[i] = CreateBranch(parent, group, positions[i], rotations[i]);

            if (groupIndex + 1 < groups.Count)
            {
                CreateBranchGroup(branches[i], groupIndex + 1);
            }
        }
        return(branches);
    }
Пример #14
0
        public void Create(MasterBranchGroupView model)
        {
            using (var ctx = new ConXContext())
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    BranchGroup newObj = new BranchGroup()
                    {
                        branchGroupCode = model.branchGroupCode,
                        branchGroupName = model.branchGroupName,
                        createUser      = model.createUser,
                        createDatetime  = DateTime.Now,
                        updateUser      = model.updateUser,
                        updateDatetime  = DateTime.Now
                    };

                    ctx.BranchGroups.Add(newObj);
                    ctx.SaveChanges();
                    scope.Complete();
                }
            }
        }
Пример #15
0
        public AuthenticationData login(string username, string password)
        {
            using (var ctx = new ConXContext())
            {
                User user = ctx.Users
                            .Include("userBranchPrvlgList.branch")
                            .Include("userBranchPrvlgList.userRole")
                            .Include("department")
                            .Where(z => z.username == username)
                            .SingleOrDefault();

                if (user == null)
                {
                    throw new Exception("รหัสผู้ใช้หรือรหัสผ่านไม่ถูกต้อง");
                }
                else
                {
                    if (!user.password.Equals(password))
                    {
                        throw new Exception("รหัสผู้ใช้หรือรหัสผ่านไม่ถูกต้อง");
                    }

                    if (!user.statusId.Equals("A"))
                    {
                        throw new Exception("สถานะผู้ใช้งานนี้ถูกยกเลิก");
                    }
                }

                AuthenticationData data = new AuthenticationData()
                {
                    username            = user.username,
                    name                = user.name,
                    isPC                = user.isPC,
                    isDefaultPassword   = (user.password == DefaultPassword.value),
                    department          = user.department,
                    departmentId        = user.departmentId,
                    statusId            = user.statusId,
                    userBranchPrvlgList = user.userBranchPrvlgList.Where(x => x.branch.status == "A").ToList(),
                    userRoleId          = user.userRoleId,
                    menuGroups          = new List <ModelViews.menuFunctionGroupView>(),
                    userBranchGroupes   = new List <Dropdownlist>(),
                    userBranches        = new List <Dropdownlist>()
                };
                foreach (UserBranchPrvlg branchPrvlg in user.userBranchPrvlgList.Where(x => x.branch.status == "A"))
                {
                    Dropdownlist branch = new Dropdownlist
                    {
                        parentKey = branchPrvlg.branch.branchGroupId,
                        key       = branchPrvlg.branch.branchId,
                        value     = branchPrvlg.branch.branchCode + "-" + branchPrvlg.branch.entityCode + " " + branchPrvlg.branch.branchNameThai,
                    };
                    data.userBranches.Add(branch);

                    Dropdownlist bGroup = data.userBranchGroupes.Find(z => z.key == branch.parentKey);

                    if (bGroup == null)
                    {
                        BranchGroup  bGroupFull  = ctx.BranchGroups.Where(z => z.branchGroupId == branch.parentKey).SingleOrDefault();
                        Dropdownlist branchGroup = new Dropdownlist()
                        {
                            key   = bGroupFull.branchGroupId,
                            value = bGroupFull.branchGroupCode + "-" + bGroupFull.branchGroupName
                        };
                        data.userBranchGroupes.Add(branchGroup);
                    }
                }


                if (!user.isPC)
                {
                    data.menuGroups = getUserRole((long)user.userRoleId);
                }


                return(data);
            }
        }
Пример #16
0
    void CreateBranchMesh(Branch branch, List <Vector3> vertices, List <Vector3> normals, List <Vector4> uvs, List <int> indices, List <Vector3> leaves, List <Vector3> leafNormals, List <Vector4> leafuvs)
    {
        BranchGroup group = branch.group;
        int         bi;
        float       rad  = branch.radius;
        float       texy = 1f;
        Vector3     pos;
        Quaternion  q;

        for (int i = 0; i < branch.points.Length; i++)
        {
            pos = branch.points[i];
            q   = branch.orientations[i];

            texy  = textureScaleY * textureScaleX * branch.length / rad;
            texy *= i / (branch.points.Length - 1f);

            rad = branch.radius * Mathf.Pow(1f - i / (branch.points.Length - 1f), group.taperBias);
            bi  = vertices.Count;
            for (int j = 0; j <= group.sides; j++)
            {
                Vector3 n = q * Quaternion.Euler(0, 0, 360f * j / group.sides) * Vector3.up;

                vertices.Add(pos + n * rad);
                normals.Add(n);
                uvs.Add(new Vector2(textureScaleX * j / group.sides, texy));

                if (i < branch.points.Length - 1 && j < group.sides)
                {
                    indices.Add(bi + j);
                    indices.Add(bi + j + 1);
                    indices.Add(bi + j + group.sides + 1);

                    indices.Add(bi + j + 1);
                    indices.Add(bi + j + group.sides + 2);
                    indices.Add(bi + j + group.sides + 1);
                }
            }
        }

        for (int i = 0; i < branch.leaves; i++)
        {
            float t = Random.value;

            float p   = Random.value;
            float jf  = p * (branch.points.Length - 1);
            int   ji  = (int)jf;
            float jt  = jf - ji;
            int   ji2 = Mathf.Min(branch.points.Length - 1, ji + 1);
            pos = Vector3.Lerp(branch.points[ji], branch.points[ji2], jt);
            Quaternion orientation = Quaternion.Lerp(branch.orientations[ji], branch.orientations[ji2], jt);
            rad          = branch.radius * Mathf.Pow(1f - p, group.taperBias);
            orientation *= Quaternion.Euler(0, 0, Random.Range(-180f, 180f));
            Vector3 normal = orientation * Quaternion.Euler(Random.Range(-45f, 45f), Random.Range(-45f, 45f), 0f) * Vector3.up;

            leaves.Add(pos + normal * rad);
            leafNormals.Add(normal);
            // x: rotation
            // y: color
            // z: size
            // w: texture
            leafuvs.Add(new Vector4(Random.value, Random.value, Random.Range(.5f, 1f) * group.leafSize, Random.value));
        }

        foreach (Branch b in branch.children)
        {
            CreateBranchMesh(b, vertices, normals, uvs, indices, leaves, leafNormals, leafuvs);
        }
    }
Пример #17
0
 public Task AfterCreate(BranchGroup group, string latestBranchName, string branchName, Func <IReactiveProcess, RepositoryActionReactiveProcessEntry> appendProcess)
 {
     return(Task.CompletedTask);
 }