예제 #1
0
        public void AddUserToGroupExecutorTest()
        {
            SCGroup group = SCObjectGenerator.PrepareGroupObject();

            SCObjectOperations.Instance.AddGroup(group, SCOrganization.GetRoot());

            SCUser user1 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot());

            SCMemberRelation mr = SCObjectOperations.Instance.AddUserToGroup(user1, group);

            Assert.AreEqual(group.SchemaType, mr.ContainerSchemaType);
            Assert.AreEqual(user1.SchemaType, mr.MemberSchemaType);

            SCUser user2 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user2, SCOrganization.GetRoot());

            SCObjectOperations.Instance.AddUserToGroup(user2, group);

            Assert.AreEqual(2, group.CurrentUsers.Count);
            Assert.IsTrue(group.CurrentUsers.ContainsKey(user1.ID));
            Assert.IsTrue(group.CurrentUsers.ContainsKey(user2.ID));

            Assert.IsTrue(user1.CurrentGroups.ContainsKey(group.ID));
            Assert.IsTrue(user2.CurrentGroups.ContainsKey(group.ID));

            SameContainerUserAndContainerSnapshotCollection ugSnapshot = UserAndContainerSnapshotAdapter.Instance.LoadByContainerID(group.ID);

            Assert.IsTrue(ugSnapshot.ContainsKey(user1.ID));
            Assert.IsTrue(ugSnapshot.ContainsKey(user2.ID));
        }
예제 #2
0
        public SchemaObjectBase DeleteGroup(SCGroup group, SCOrganization parent, bool deletedByContainer)
        {
            group.Status = deletedByContainer ? SchemaObjectStatus.DeletedByContainer : SchemaObjectStatus.Deleted;

            SCExecutorBase executor = new SCObjectExecutor(SCOperationType.DeleteGroup, group)
            {
                NeedDeleteRelations = true, NeedValidation = false, NeedDeleteMemberRelations = true, NeedDeleteConditions = true, NeedStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (parent == null)
            {
                parent = (SCOrganization)SchemaRelationObjectAdapter.Instance.LoadByObjectID(new string[] { group.ID }).Find(m => m.Status == SchemaObjectStatus.Normal).Parent;
            }

            if (this._NeedCheckPermissions)
            {
                CheckPermissions(SCOperationType.DeleteGroup, parent.Schema, "DeleteChildren", parent.ID);
            }

            SchemaObjectBase result = null;

            ExecuteWithActions(SCOperationType.DeleteGroup, () => SCActionContext.Current.DoActions(() => result = (SchemaObjectBase)executor.Execute()));

            return(result);
        }
예제 #3
0
        public void TestSerializeSchemaPropertyValueCollection()
        {
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            System.IO.MemoryStream        ms   = new System.IO.MemoryStream();
            SchemaPropertyValueCollection obj1 = new SchemaPropertyValueCollection();

            SCGroup group = SCObjectGenerator.PrepareGroupObject();

            foreach (string key in group.Properties.GetAllKeys())
            {
                obj1.Add(group.Properties[key]);
            }

            bf.Serialize(ms, obj1);
            ms.Seek(0, System.IO.SeekOrigin.Begin);

            var obj2 = (SchemaPropertyValueCollection)bf.Deserialize(ms);

            Assert.AreEqual(obj1.Count, obj2.Count);

            var keys1 = obj1.GetAllKeys();

            foreach (var key in keys1)
            {
                Assert.IsTrue(obj2.ContainsKey(key));
                Assert.AreEqual(obj1[key].StringValue, obj2[key].StringValue);
            }
        }
예제 #4
0
        public void AddOrRemoveUserToGroupExecutorTest()
        {
            SCGroup group = SCObjectGenerator.PrepareGroupObject();

            SCObjectOperations.Instance.AddGroup(group, SCOrganization.GetRoot());

            SCUser user1 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot());

            Console.WriteLine("UserID: {0}, GroupID: {1}", user1.ID, group.ID);

            SCMemberRelation mr = SCObjectOperations.Instance.AddUserToGroup(user1, group);

            SCObjectOperations.Instance.RemoveUserFromGroup(user1, group);

            // 确认删除
            Assert.IsFalse(group.CurrentMembersRelations.ContainsKey(user1.ID));
            Assert.IsFalse(user1.CurrentMemberOfRelations.ContainsKey(group.ID));

            SCObjectOperations.Instance.AddUserToGroup(user1, group);

            // 重置数据
            group.ClearRelativeData();
            user1.ClearRelativeData();

            // 确认又加回来了
            Assert.IsTrue(group.CurrentUsers.ContainsKey(user1.ID));
            Assert.IsTrue(user1.CurrentGroups.ContainsKey(group.ID));

            Console.WriteLine("UserID: {0}, GroupID: {1}", user1.ID, group.ID);
        }
예제 #5
0
        public void MergeUserInGroupExecutorTest()
        {
            // 准备4位用户。User1位状态不变,User2待删除,User3新增加,User4复活
            SCGroup group = SCObjectGenerator.PrepareGroupObject();

            SCObjectOperations.Instance.AddGroup(group, SCOrganization.GetRoot());

            SCUser user1 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot());

            SCMemberRelation mr = SCObjectOperations.Instance.AddUserToGroup(user1, group);

            Assert.AreEqual(group.SchemaType, mr.ContainerSchemaType);
            Assert.AreEqual(user1.SchemaType, mr.MemberSchemaType);

            SCUser user2 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user2, SCOrganization.GetRoot());

            SCObjectOperations.Instance.AddUserToGroup(user2, group);

            SCUser user3 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user3, SCOrganization.GetRoot());

            SCUser user4 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user4, SCOrganization.GetRoot());
            SCObjectOperations.Instance.AddUserToGroup(user4, group);
            SCObjectOperations.Instance.RemoveUserFromGroup(user4, group);

            user4.Status = SchemaObjectStatus.Normal;

            SchemaObjectCollection needMergeUsers = new SchemaObjectCollection()
            {
                user1, user3, user4
            };

            UserAndContainerSnapshotAdapter.Instance.Merge(group.ID, group.SchemaType, needMergeUsers);

            Console.WriteLine("Group ID: {0}", group.ID);

            SameContainerUserAndContainerSnapshotCollection ugSnapshot = UserAndContainerSnapshotAdapter.Instance.LoadByContainerID(group.ID);

            Assert.IsTrue(ugSnapshot.ContainsKey(user1.ID));
            Assert.AreEqual(SchemaObjectStatus.Normal, ugSnapshot[user1.ID].Status);

            Assert.IsTrue(ugSnapshot.ContainsKey(user2.ID));
            Assert.AreEqual(SchemaObjectStatus.Deleted, ugSnapshot[user2.ID].Status);

            Assert.IsTrue(ugSnapshot.ContainsKey(user3.ID));
            Assert.AreEqual(SchemaObjectStatus.Normal, ugSnapshot[user3.ID].Status);

            Assert.IsTrue(ugSnapshot.ContainsKey(user4.ID));
            Assert.AreEqual(SchemaObjectStatus.Normal, ugSnapshot[user4.ID].Status);
        }
예제 #6
0
        public static SCGroup PrepareGroupObject()
        {
            SCGroup group = new SCGroup();

            group.ID       = UuidHelper.NewUuidString();
            group.Name     = "Great Group";
            group.CodeName = group.ID;

            return(group);
        }
예제 #7
0
        public void TestSerializeGroup()
        {
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            SCGroup obj1 = SCObjectGenerator.PrepareGroupObject();

            obj1.CreateDate     = DateTime.Now;
            obj1.VersionEndTime = new DateTime(567890);
            obj1.VersionEndTime = DateTime.MaxValue;
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            bf.Serialize(ms, obj1);
            ms.Seek(0, System.IO.SeekOrigin.Begin);
            SCGroup obj2 = (SCGroup)bf.Deserialize(ms);

            CommonAssert(obj1, obj2);
        }
예제 #8
0
        public void DeleteConditionsContainerTest()
        {
            SCUser userInGroup;
            SCUser userNotInGroup;

            SCGroup group = SCObjectGenerator.PrepareGroupWithConditions(out userInGroup, out userNotInGroup);

            Console.WriteLine("Group ID: {0}", group.ID);

            SCObjectOperations.Instance.DeleteGroup(group, null, false);

            SCConditionOwner owner = SCConditionAdapter.Instance.Load(group.ID);

            owner.Conditions.ForEach(c => Assert.AreEqual(SchemaObjectStatus.Deleted, c.Status));
        }
예제 #9
0
        public void AddGroupExecutorTest()
        {
            Trace.CorrelationManager.ActivityId = UuidHelper.NewUuid();

            SCGroup group = SCObjectGenerator.PrepareGroupObject();

            SCObjectOperations.Instance.AddGroup(group, SCOrganization.GetRoot());

            SCGroup groupLoaded = (SCGroup)SchemaObjectAdapter.Instance.Load(group.ID);

            Assert.AreEqual(group.ID, groupLoaded.ID);

            SCOperationLog log = SCOperationLogAdapter.Instance.LoadByResourceID(group.ID).FirstOrDefault();

            Assert.IsNotNull(log);
            Assert.AreEqual(Trace.CorrelationManager.ActivityId.ToString(), log.CorrelationID);
        }
예제 #10
0
        public SCMemberRelation AddUserToGroup(SCUser user, SCGroup group)
        {
            SCMemberRelativeExecutor executor = new SCMemberRelativeExecutor(SCOperationType.AddUserToGroup, group, user)
            {
                NeedStatusCheck = this.NeedValidationAndStatusCheck, NeedContainerStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                CheckOrganizationChildrenPermissions(SCOperationType.AddUserToGroup, "EditMembersOfGroups", group);
            }

            SCMemberRelation result = null;

            ExecuteWithActions(SCOperationType.AddUserToGroup, () => SCActionContext.Current.DoActions(() => result = (SCMemberRelation)executor.Execute()));

            return(result);
        }
예제 #11
0
        public SchemaObjectBase UpdateGroup(SCGroup group)
        {
            SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdateGroup, group)
            {
                NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                CheckOrganizationChildrenPermissions(SCOperationType.UpdateGroup, "UpdateChildren", group);
            }

            SchemaObjectBase result = null;

            ExecuteWithActions(SCOperationType.UpdateGroup, () => SCActionContext.Current.DoActions(() => result = (SchemaObjectBase)executor.Execute()));

            return(result);
        }
예제 #12
0
        public SchemaObjectBase AddGroup(SCGroup group, SCOrganization parent)
        {
            SCOrganizationRelativeExecutor executor =
                new SCOrganizationRelativeExecutor(SCOperationType.AddGroup, parent, group)
            {
                SaveTargetData = true, NeedValidation = this.NeedValidationAndStatusCheck, NeedParentStatusCheck = this.NeedValidationAndStatusCheck, NeedDuplicateRelationCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                CheckPermissions(SCOperationType.AddGroup, parent.Schema, "AddChildren", parent.ID);
            }

            SCRelationObject result = null;

            ExecuteWithActions(SCOperationType.AddGroup, () => SCActionContext.Current.DoActions(() => result = (SCRelationObject)executor.Execute()));

            return(result);
        }
예제 #13
0
        public void RemoveUserFromGroupExecutorTest()
        {
            SCGroup group = SCObjectGenerator.PrepareGroupObject();

            SCObjectOperations.Instance.AddGroup(group, SCOrganization.GetRoot());

            SCUser user1 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot());

            SCObjectOperations.Instance.AddUserToGroup(user1, group);

            SCObjectOperations.Instance.RemoveUserFromGroup(user1, group);

            Assert.IsTrue(group.AllMembersRelations.ContainsKey(user1.ID));
            Assert.IsFalse(group.CurrentMembersRelations.ContainsKey(user1.ID));

            Assert.IsTrue(user1.AllMemberOfRelations.ContainsKey(group.ID));
            Assert.IsFalse(user1.CurrentMemberOfRelations.ContainsKey(group.ID));
        }
예제 #14
0
        public SCMemberRelation RemoveUserFromGroup(SCUser user, SCGroup group)
        {
            SCMemberRelativeExecutor executor = new SCMemberRelativeExecutor(SCOperationType.RemoveUserFromGroup, group, user)
            {
                OverrideExistedRelation = true, NeedStatusCheck = this.NeedValidationAndStatusCheck, NeedContainerStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                CheckOrganizationChildrenPermissions(SCOperationType.RemoveUserFromGroup, "EditMembersOfGroups", group);
            }

            executor.Relation.Status = SchemaObjectStatus.Deleted;

            SCMemberRelation result = null;

            ExecuteWithActions(SCOperationType.RemoveUserFromGroup, () => SCActionContext.Current.DoActions(() => result = (SCMemberRelation)executor.Execute()));

            return(result);
        }
예제 #15
0
        public void SimpleGroupConditionsTest()
        {
            SCUser userInGroup;
            SCUser userNotInGroup;

            SCGroup group = SCObjectGenerator.PrepareGroupWithConditions(out userInGroup, out userNotInGroup);

            SCConditionCalculator calculator = new SCConditionCalculator();

            SCConditionOwner owner = SCConditionAdapter.Instance.Load(group.ID, string.Empty);

            SchemaObjectCollection calculateResult = calculator.Calculate(owner);

            ConditionCalculateResultAdapter.Instance.Update(group.ID, calculateResult);

            SchemaObjectCollection loadedResult = ConditionCalculateResultAdapter.Instance.LoadCurrentUsers(group.ID);

            Assert.IsTrue(loadedResult.ContainsKey(userInGroup.ID));
            Assert.IsFalse(loadedResult.ContainsKey(userNotInGroup.ID));
        }
예제 #16
0
        public static SCGroup PrepareGroupWithConditions(out SCUser userInGroup, out SCUser userNotInGroup)
        {
            userInGroup = PrepareUserObject();
            SCObjectOperations.Instance.AddUser(userInGroup, SCOrganization.GetRoot());

            userNotInGroup = PrepareUserObject();
            SCObjectOperations.Instance.AddUser(userNotInGroup, SCOrganization.GetRoot());

            SCGroup group = PrepareGroupObject();

            SCObjectOperations.Instance.AddGroup(group, SCOrganization.GetRoot());

            SCConditionOwner owner = new SCConditionOwner();

            owner.OwnerID = group.ID;
            owner.Conditions.Add(new SCCondition(string.Format("Users.CodeName == \"{0}\"", userInGroup.CodeName)));

            SCConditionAdapter.Instance.UpdateConditions(owner);

            return(group);
        }
예제 #17
0
        public Group Convert(SCGroup @group)
        {
            if (@group == null)
            {
                return(null);
            }

            return(new Group
            {
                Id = @group.Id,
                ArtworkUrl = @group.Artwork.Url(),
                CreatedAt = dateTimeConverter.Convert(@group.CreatedAt),
                Uri = @group.Uri,
                Description = @group.Description,
                Permalink = @group.Permalink,
                PermalinkUrl = @group.PermalinkUrl,
                Creator = userConverter.Convert(@group.Creator),
                Name = @group.Name,
                ShortDescription = @group.Description
            });
        }
예제 #18
0
        public void MoveGroupTest()
        {
            SCOrganization root = SCOrganization.GetRoot();

            SCGroup group = SCObjectGenerator.PrepareGroupObject();

            SCObjectOperations.Instance.AddGroup(group, root);

            SCOrganization newOrg = SCObjectGenerator.PrepareOrganizationObject();

            SCObjectOperations.Instance.AddOrganization(newOrg, root);

            SCObjectOperations.Instance.MoveObjectToOrganization(null, group, newOrg);

            group.ClearRelativeData();
            newOrg.ClearRelativeData();
            root.ClearRelativeData();

            Assert.IsTrue(group.CurrentParents.ContainsKey(newOrg.ID));
            Assert.IsTrue(newOrg.CurrentChildren.ContainsKey(group.ID));
            Assert.IsFalse(root.CurrentChildren.ContainsKey(group.ID));
        }
예제 #19
0
        public void QueryGroupMembersTest()
        {
            SCGroup group = SCObjectGenerator.PrepareGroupObject();

            SCObjectOperations.Instance.AddGroup(group, SCOrganization.GetRoot());

            SCUser user1 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot());

            SCMemberRelation mr = SCObjectOperations.Instance.AddUserToGroup(user1, group);

            SCObjectAndRelationCollection result = SCSnapshotAdapter.Instance.QueryContainerContainsUsersByIDs(new string[] { "Groups" }, new string[] { group.ID }, false, DateTime.MinValue);

            Assert.IsTrue(result.Count > 0);

            result.FillDetails();

            Console.WriteLine(result[0].Detail.Properties.GetValue("Name", string.Empty));
            Console.WriteLine(result[0].ParentID);
            Assert.AreEqual(user1.ID, result[0].Detail.ID);
        }
        public MasterAssetsAssignmentResult GetASMasterAssetsAssignmentByID(long MasterAssetsAssignmentId)
        {
            try
            {
                var _data = (from MP in _Context.ASMasterProducts
                             //join CO in _AdminContext.ADMasterCountries on MP.CountryOfOrigin equals CO.MasterCountryId into COGroup
                             //from CO in COGroup.DefaultIfEmpty()
                             //join MT in _AdminContext.ADMasterTaxes on MP.ProductTaxCode equals MT.MasterTaxId into MTGroup
                             //from MT in MTGroup.DefaultIfEmpty()
                             //join MC in _AdminContext.ADMasterCurrencies on MP.ProductCurrency equals MC.MasterCurrencyId into MCGroup
                             //from MC in MCGroup.DefaultIfEmpty()
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId
                             join MAA in _Context.ASMasterAssetsAssignments on MPC.MasterProductChildId equals MAA.MasterProductChildId
                             where MAA.MasterAssetsAssignmentId == MasterAssetsAssignmentId
                             select new
                {
                    MPC.MasterProductChildId,
                    MPC.MasterProductId,
                    MPC.ProductChildSKU,
                    MPC.ProductChildTitle,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchaseDate,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.MasterVendorId,
                    MPC.IsDeadAssets,
                    MPC.IsTimeToSaleProduct,
                    MPC.IsSaleProduct,
                    MPC.SaleDate,
                    MPC.SalePrice,
                    MPC.ProductQty,
                    MPC.ProductQtyUnit,
                    MPC.NumberOfItemIncludeInProduct,
                    MPC.ItemPackageQuantity,
                    MPC.IterationOfWarranty,
                    MPC.WarrantyStartDate,
                    MPC.WarrantyExpiryDate,
                    MPC.MasterBranchId,

                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    CA.MasterCategoryId,
                    CA.CategoryTitle,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.ProductModel,
                    MP.Manufacturer,

                    MAA.MasterAssetsAssignmentId,
                    MAA.AssetsAssignmentDate,
                    MAA.ASMasterProductChilds,
                    MAA.MasterEmployeeId,
                    MAA.IsAssetsDeAssign,
                    MAA.AssetsDeAssignmentDate,
                    MAA.DeAssignReason,
                    MAA.MasterLocationId,
                    MAA.Sequence,
                    MAA.IsActive,
                    MAA.EnterById,
                    MAA.EnterDate,
                    MAA.ModifiedById,
                    MAA.ModifiedDate,
                });


                var _Item = _data.FirstOrDefault();

                MasterAssetsAssignmentResult _MasterAssetsAssignmentResult = new MasterAssetsAssignmentResult();
                if (_data != null)
                {
                    _MasterAssetsAssignmentResult.MasterAssetsAssignmentId = _Item.MasterAssetsAssignmentId;
                    _MasterAssetsAssignmentResult.AssetsAssignmentDate     = _Item.AssetsAssignmentDate;
                    _MasterAssetsAssignmentResult.MasterEmployeeId         = _Item.MasterEmployeeId;
                    _MasterAssetsAssignmentResult.IsAssetsDeAssign         = _Item.IsAssetsDeAssign;
                    _MasterAssetsAssignmentResult.AssetsDeAssignmentDate   = _Item.AssetsDeAssignmentDate;
                    _MasterAssetsAssignmentResult.DeAssignReason           = _Item.DeAssignReason;
                    _MasterAssetsAssignmentResult.MasterLocationId         = _Item.MasterLocationId;
                    _MasterAssetsAssignmentResult.Sequence     = _Item.Sequence;
                    _MasterAssetsAssignmentResult.IsActive     = _Item.IsActive;
                    _MasterAssetsAssignmentResult.ActiveColor  = "green";
                    _MasterAssetsAssignmentResult.ActiveIcon   = "glyphicon glyphicon-ok";
                    _MasterAssetsAssignmentResult.EnterById    = _Item.EnterById;
                    _MasterAssetsAssignmentResult.EnterDate    = _Item.EnterDate;
                    _MasterAssetsAssignmentResult.ModifiedById = _Item.ModifiedById;
                    _MasterAssetsAssignmentResult.ModifiedDate = _Item.ModifiedDate;

                    if (_MasterAssetsAssignmentResult.IsActive == false)
                    {
                        _MasterAssetsAssignmentResult.ActiveColor = "red";
                        _MasterAssetsAssignmentResult.ActiveIcon  = "glyphicon glyphicon-remove";
                    }

                    _MasterAssetsAssignmentResult.MasterProductChildId = _Item.MasterProductChildId;
                    _MasterAssetsAssignmentResult.MasterProductId      = _Item.MasterProductId;
                    //_MasterAssetsAssignmentResult.ASMasterProducts = _Item.ASMasterProducts;
                    _MasterAssetsAssignmentResult.ProductChildSKU        = _Item.ProductChildSKU;
                    _MasterAssetsAssignmentResult.ProductChildTitle      = _Item.ProductChildTitle;
                    _MasterAssetsAssignmentResult.ManufacturerPartNumber = _Item.ManufacturerPartNumber;
                    //_MasterAssetsAssignmentResult.ASMasterProductSizes = _Item.ASMasterProductSizes;
                    _MasterAssetsAssignmentResult.PurchaseDate                 = _Item.PurchaseDate;
                    _MasterAssetsAssignmentResult.PurchasePrice                = _Item.PurchasePrice;
                    _MasterAssetsAssignmentResult.DepreciatePrice              = _Item.DepreciatePrice;
                    _MasterAssetsAssignmentResult.MasterVendorId               = _Item.MasterVendorId;
                    _MasterAssetsAssignmentResult.IsDeadAssets                 = _Item.IsDeadAssets;
                    _MasterAssetsAssignmentResult.IsTimeToSaleProduct          = _Item.IsTimeToSaleProduct;
                    _MasterAssetsAssignmentResult.IsSaleProduct                = _Item.IsSaleProduct;
                    _MasterAssetsAssignmentResult.SaleDate                     = _Item.SaleDate;
                    _MasterAssetsAssignmentResult.SalePrice                    = _Item.SalePrice;
                    _MasterAssetsAssignmentResult.ProductQty                   = _Item.ProductQty;
                    _MasterAssetsAssignmentResult.ProductQtyUnit               = _Item.ProductQtyUnit;
                    _MasterAssetsAssignmentResult.NumberOfItemIncludeInProduct = _Item.NumberOfItemIncludeInProduct;
                    _MasterAssetsAssignmentResult.ItemPackageQuantity          = _Item.ItemPackageQuantity;
                    _MasterAssetsAssignmentResult.IterationOfWarranty          = _Item.IterationOfWarranty;
                    _MasterAssetsAssignmentResult.WarrantyStartDate            = _Item.WarrantyStartDate;
                    _MasterAssetsAssignmentResult.WarrantyExpiryDate           = _Item.WarrantyExpiryDate;
                    _MasterAssetsAssignmentResult.MasterBranchId               = _Item.MasterBranchId;
                    _MasterAssetsAssignmentResult.MasterEmployeeId             = _Item.MasterEmployeeId;

                    _MasterAssetsAssignmentResult.ProductTitle         = _Item.ProductTitle;
                    _MasterAssetsAssignmentResult.MasterBrandId        = _Item.MasterBrandId;
                    _MasterAssetsAssignmentResult.BrandTitle           = _Item.BrandTitle;
                    _MasterAssetsAssignmentResult.MasterSubCategoryId  = _Item.MasterSubCategoryId;
                    _MasterAssetsAssignmentResult.SubCategoryTitle     = _Item.SubCategoryTitle;
                    _MasterAssetsAssignmentResult.MasterCategoryId     = _Item.MasterCategoryId;
                    _MasterAssetsAssignmentResult.CategoryTitle        = _Item.CategoryTitle;
                    _MasterAssetsAssignmentResult.ProductSKU           = _Item.ProductSKU;
                    _MasterAssetsAssignmentResult.ProductModel         = _Item.ProductModel;
                    _MasterAssetsAssignmentResult.Manufacturer         = _Item.Manufacturer;
                    _MasterAssetsAssignmentResult.DepreciatePercentage = _Item.DepreciatePercentage;
                    _MasterAssetsAssignmentResult.ReorderLevel         = _Item.ReorderLevel;
                }
                return(_MasterAssetsAssignmentResult);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #21
0
		public SCMemberRelation RemoveUserFromGroup(SCUser user, SCGroup group)
		{
			SCMemberRelativeExecutor executor = new SCMemberRelativeExecutor(SCOperationType.RemoveUserFromGroup, group, user) { OverrideExistedRelation = true, NeedStatusCheck = this.NeedValidationAndStatusCheck, NeedContainerStatusCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
				CheckOrganizationChildrenPermissions(SCOperationType.RemoveUserFromGroup, "EditMembersOfGroups", group);

			executor.Relation.Status = SchemaObjectStatus.Deleted;

			SCMemberRelation result = null;

			ExecuteWithActions(SCOperationType.RemoveUserFromGroup, () => SCActionContext.Current.DoActions(() => result = (SCMemberRelation)executor.Execute()));

			return result;
		}
예제 #22
0
		public SCMemberRelation AddUserToGroup(SCUser user, SCGroup group)
		{
			SCMemberRelativeExecutor executor = new SCMemberRelativeExecutor(SCOperationType.AddUserToGroup, group, user) { NeedStatusCheck = this.NeedValidationAndStatusCheck, NeedContainerStatusCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
				CheckOrganizationChildrenPermissions(SCOperationType.AddUserToGroup, "EditMembersOfGroups", group);

			SCMemberRelation result = null;

			ExecuteWithActions(SCOperationType.AddUserToGroup, () => SCActionContext.Current.DoActions(() => result = (SCMemberRelation)executor.Execute()));

			return result;
		}
예제 #23
0
		public SchemaObjectBase DeleteGroup(SCGroup group, SCOrganization parent, bool deletedByContainer)
		{
			group.Status = deletedByContainer ? SchemaObjectStatus.DeletedByContainer : SchemaObjectStatus.Deleted;

			SCExecutorBase executor = new SCObjectExecutor(SCOperationType.DeleteGroup, group) { NeedDeleteRelations = true, NeedValidation = false, NeedDeleteMemberRelations = true, NeedDeleteConditions = true, NeedStatusCheck = this.NeedValidationAndStatusCheck };

			if (parent == null)
				parent = (SCOrganization)SchemaRelationObjectAdapter.Instance.LoadByObjectID(new string[] { group.ID }).Find(m => m.Status == SchemaObjectStatus.Normal).Parent;

			if (this._NeedCheckPermissions)
				CheckPermissions(SCOperationType.DeleteGroup, parent.Schema, "DeleteChildren", parent.ID);

			SchemaObjectBase result = null;

			ExecuteWithActions(SCOperationType.DeleteGroup, () => SCActionContext.Current.DoActions(() => result = (SchemaObjectBase)executor.Execute()));

			return result;
		}
예제 #24
0
		public SchemaObjectBase UpdateGroup(SCGroup group)
		{
			SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdateGroup, group) { NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
				CheckOrganizationChildrenPermissions(SCOperationType.UpdateGroup, "UpdateChildren", group);

			SchemaObjectBase result = null;

			ExecuteWithActions(SCOperationType.UpdateGroup, () => SCActionContext.Current.DoActions(() => result = (SchemaObjectBase)executor.Execute()));

			return result;
		}
예제 #25
0
		public SchemaObjectBase AddGroup(SCGroup group, SCOrganization parent)
		{
			SCOrganizationRelativeExecutor executor =
				new SCOrganizationRelativeExecutor(SCOperationType.AddGroup, parent, group) { SaveTargetData = true, NeedValidation = this.NeedValidationAndStatusCheck, NeedParentStatusCheck = this.NeedValidationAndStatusCheck, NeedDuplicateRelationCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
				CheckPermissions(SCOperationType.AddGroup, parent.Schema, "AddChildren", parent.ID);

			SCRelationObject result = null;

			ExecuteWithActions(SCOperationType.AddGroup, () => SCActionContext.Current.DoActions(() => result = (SCRelationObject)executor.Execute()));

			return result;
		}
예제 #26
0
        public List <AdditionOperation> GetAditionOperations(string id)
        {
            List <AdditionOperation> list = new List <AdditionOperation>();

            if (string.IsNullOrEmpty(id) == false)
            {
                var obj = SchemaObjectAdapter.Instance.Load(id);
                if (obj.Status == SchemaObjectStatus.Normal)
                {
                    if (obj is SCUser)
                    {
                        var relation = obj.CurrentParentRelations.Find(m => m.Status == SchemaObjectStatus.Normal && m.Default && Util.IsOrganization(m.ParentSchemaType));
                        if (relation != null)
                        {
                            list.Add(new AdditionOperation("转到缺省组织", false, GetClientUrl("~/lists/OUExplorer.aspx?ou=" + relation.ParentID), "_blank"));
                        }
                        string ownerId = ((SCUser)obj).OwnerID;
                        if (string.IsNullOrEmpty(ownerId) == false)
                        {
                            list.Add(new AdditionOperation("转到所有者", false, GetClientUrl("~/lists/OUExplorer.aspx?ou=" + ownerId), "_blank"));
                        }
                    }
                    else if (obj is SCGroup)
                    {
                        SCGroup grp      = (SCGroup)obj;
                        var     parents  = grp.CurrentParentRelations;
                        var     relation = parents.Find(m => m.Status == SchemaObjectStatus.Normal && Util.IsOrganization(m.ParentSchemaType));
                        if (relation != null)
                        {
                            list.Add(new AdditionOperation("转到组织", false, GetClientUrl("~/lists/OUExplorer.aspx?ou=" + relation.ParentID), "_blank"));
                        }
                    }
                    else if (obj is SCRole)
                    {
                        SCRole role = (SCRole)obj;
                        list.Add(new AdditionOperation("打开应用", false, GetClientUrl("~/lists/AllApps.aspx?id=" + role.CurrentApplication.ID), "_blank"));
                        list.Add(new AdditionOperation("定位", true, GetClientUrl("~/lists/AppRoles.aspx?app=" + role.CurrentApplication.ID) + "&id=" + role.ID, "_blank"));
                        //if (this.GetEditRoleMembersEnabled(role.CurrentApplication.ID))
                        //{
                        //    list.Add(new AdditionOperation("角色矩阵", true, GetClientUrl("/MCSWebApp/WorkflowDesigner/MatrixModalDialog/RolePropertyExtension.aspx?AppID=" + role.CurrentApplication.ID + "&roleID=" + role.ID)));
                        //}

                        list.Add(new AdditionOperation("角色功能定义", true, GetClientUrl("~/dialogs/RoleDefinition.aspx?role=" + role.ID)));
                    }
                    else if (obj is SCPermission)
                    {
                        SCPermission permission = (SCPermission)obj;
                        list.Add(new AdditionOperation("打开应用", false, GetClientUrl("~/lists/AllApps.aspx?id=" + permission.CurrentApplication.ID), "_blank"));
                        list.Add(new AdditionOperation("定位", true, GetClientUrl("~/lists/AppFunctions.aspx?app=" + permission.CurrentApplication.ID) + "&id=" + permission.ID, "_blank"));
                    }
                    else if (obj is SCOrganization)
                    {
                        var relation = obj.CurrentParentRelations.Find(m => m.Status == SchemaObjectStatus.Normal && Util.IsOrganization(m.ParentSchemaType));
                        if (relation != null)
                        {
                            list.Add(new AdditionOperation("转到上级组织", false, GetClientUrl("~/lists/OUExplorer.aspx?ou=" + relation.ParentID), "_blank"));
                        }
                    }
                    else if (obj is SCApplication)
                    {
                        list.Add(new AdditionOperation("定位", false, GetClientUrl("~/lists/AllApps.aspx?id=" + obj.ID), "_blank"));
                    }
                }
            }

            return(list);
        }
예제 #27
0
        public IEnumerable <MasterProductResult> GetASMasterProductByID(long MasterCategoryId, long MasterSubCategoryId, long MasterBrandId)
        {
            try
            {
                //Get Parent Product data as per MasterCategoryId Or MasterSubCategoryId Or  MasterBranchId
                var _data = (from MP in _Context.ASMasterProducts
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             where (MasterCategoryId > 0 && MasterSubCategoryId == 0 && MasterBrandId == 0 && SC.MasterCategoryId == MasterCategoryId) ||
                             (MasterCategoryId == 0 && MasterSubCategoryId > 0 && MasterBrandId == 0 && MP.MasterSubCategoryId == MasterSubCategoryId) ||
                             (MasterCategoryId == 0 && MasterSubCategoryId == 0 && MasterBrandId > 0 && MP.MasterBrandId == MasterBrandId)
                             select new
                {
                    MP.MasterProductId,
                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.ProductHSNCode,
                    MP.ProductBarCode,
                    MP.ProductMainImage,
                    MP.Description,
                    MP.Specification,
                    MP.LegalDisclamer,
                    MP.SafetyWarning,
                    MP.ProductModel,
                    MP.Manufacturer,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.CountryOfOrigin,
                    //CO.CountryTitle,
                    MP.ProductTaxCode,
                    //MT.TaxTitle,
                    //MT.IsTaxPercentageAmount,
                    //MT.TaxValue,
                    MP.ProductCurrency,
                    //MC.CurrencyTitle,
                    MP.Sequence,
                    MP.IsActive,
                    MP.EnterById,
                    MP.EnterDate,
                    MP.ModifiedById,
                    MP.ModifiedDate,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    CA.CategoryTitle,
                    CA.MasterCategoryId
                });

                var _AdminCountries  = _AdminContext.ADMasterCountries.ToList();
                var _AdminTaxes      = _AdminContext.ADMasterTaxes.ToList();
                var _AdminCurrencies = _AdminContext.ADMasterCurrencies.ToList();
                var _AdminBranches   = _AdminContext.ADMasterBranches.ToList();
                var _AdminEmployees  = _AdminContext.ADMasterEmployees.ToList();
                var _AdminVendors    = _AdminContext.ADMasterVendors.ToList();

                //Get Child Product data as per MasterCategoryId Or MasterSubCategoryId Or  MasterBranchId
                var _Productdata = (from MC in _Context.ASMasterCategories
                                    join MSC in _Context.ASMasterSubCategories on MC.MasterCategoryId equals MSC.MasterCategoryId
                                    join MP in _Context.ASMasterProducts on MSC.MasterSubCategoryId equals MP.MasterSubCategoryId into MPGroup
                                    from MP in MPGroup.DefaultIfEmpty()
                                    join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId into MPCGroup
                                    from MPC in MPCGroup.DefaultIfEmpty()
                                    where (MasterCategoryId > 0 && MasterSubCategoryId == 0 && MasterBrandId == 0 && MSC.MasterCategoryId == MasterCategoryId) ||
                                    (MasterCategoryId == 0 && MasterSubCategoryId > 0 && MasterBrandId == 0 && MP.MasterSubCategoryId == MasterSubCategoryId) ||
                                    (MasterCategoryId == 0 && MasterSubCategoryId == 0 && MasterBrandId > 0 && MP.MasterBrandId == MasterBrandId)
                                    select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryTitle,
                    MSC.MasterSubCategoryId,
                    MSC.SubCategoryTitle,
                    MPC.MasterProductId,
                    MPC.ProductChildTitle,
                    MPC.ProductChildSKU,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.IsActive,
                    MPC.IsDeadAssets,
                    MPC.IsSaleProduct,
                    MPC.MasterBranchId,
                    MPC.MasterEmployeeId,
                    MPC.WarrantyExpiryDate
                });

                //insert search data in model List<MasterProductResult> object with parent and child
                List <MasterProductResult> objMasterProductResultList = new List <MasterProductResult>();

                foreach (var _Item in _data.ToList())
                {
                    MasterProductResult _MasterProductResult = new MasterProductResult();
                    _MasterProductResult.MasterProductId      = _Item.MasterProductId;
                    _MasterProductResult.ProductTitle         = _Item.ProductTitle;
                    _MasterProductResult.MasterBrandId        = _Item.MasterBrandId;
                    _MasterProductResult.BrandTitle           = _Item.BrandTitle;
                    _MasterProductResult.MasterSubCategoryId  = _Item.MasterSubCategoryId;
                    _MasterProductResult.SubCategoryTitle     = _Item.SubCategoryTitle;
                    _MasterProductResult.MasterCategoryId     = _Item.MasterCategoryId;
                    _MasterProductResult.CategoryTitle        = _Item.CategoryTitle;
                    _MasterProductResult.ProductSKU           = _Item.ProductSKU;
                    _MasterProductResult.ProductHSNCode       = _Item.ProductHSNCode;
                    _MasterProductResult.ProductBarCode       = _Item.ProductBarCode;
                    _MasterProductResult.ProductMainImage     = _Item.ProductMainImage;
                    _MasterProductResult.Description          = _Item.Description;
                    _MasterProductResult.Specification        = _Item.Specification;
                    _MasterProductResult.LegalDisclamer       = _Item.LegalDisclamer;
                    _MasterProductResult.SafetyWarning        = _Item.SafetyWarning;
                    _MasterProductResult.ProductModel         = _Item.ProductModel;
                    _MasterProductResult.Manufacturer         = _Item.Manufacturer;
                    _MasterProductResult.DepreciatePercentage = _Item.DepreciatePercentage;
                    _MasterProductResult.ReorderLevel         = _Item.ReorderLevel;
                    _MasterProductResult.CountryOfOrigin      = _Item.CountryOfOrigin;
                    _MasterProductResult.CountryOfOriginTitle = _AdminCountries.Where(a => a.MasterCountryId == _Item.CountryOfOrigin).Select(a => a.CountryTitle).FirstOrDefault();
                    _MasterProductResult.ProductTaxCode       = _Item.ProductTaxCode;
                    _MasterProductResult.ProductTaxCodeTitle  = _AdminTaxes.Where(a => a.MasterTaxId == _Item.ProductTaxCode).Select(a => a.TaxTitle).FirstOrDefault();
                    _MasterProductResult.ProductCurrency      = _Item.ProductCurrency;
                    _MasterProductResult.ProductCurrencyTitle = _AdminCurrencies.Where(a => a.MasterCurrencyId == _Item.ProductCurrency).Select(a => a.CurrencyTitle).FirstOrDefault();;

                    _MasterProductResult.TotalAssetsInStock          = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsAssign                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false && (a.MasterEmployeeId != 0)).Count());
                    _MasterProductResult.AssetsInRepair              = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.ServiceInExpire             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.WarrantyExpiryDate <= DateTime.Now && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsInSold                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == true).Count());
                    _MasterProductResult.AssetsInDead                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == true && a.IsSaleProduct == false).Count());
                    _MasterProductResult.TotalAssetsCost             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.PurchasePrice) ?? 0);
                    _MasterProductResult.TotalAssetsDepreciatedValue = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.DepreciatePrice) ?? 0);

                    _MasterProductResult.Sequence      = _Item.Sequence;
                    _MasterProductResult.IsActive      = _Item.IsActive;
                    _MasterProductResult.EnterById     = _Item.EnterById;
                    _MasterProductResult.EnterDate     = _Item.EnterDate;
                    _MasterProductResult.ModifiedById  = _Item.ModifiedById;
                    _MasterProductResult.ModifiedDate  = _Item.ModifiedDate;
                    _MasterProductResult.MaxProductSKU = _Context.ASMasterProductChilds.Where(a => a.MasterProductId == _Item.MasterProductId).Max(a => a.ProductChildSKU);

                    objMasterProductResultList.Add(_MasterProductResult);

                    var _dataChild = (from MPC in _Context.ASMasterProductChilds
                                      join MAA in _Context.ASMasterAssetsAssignments on MPC.MasterProductChildId equals MAA.MasterProductChildId into MAAGroup
                                      from MAA in MAAGroup.DefaultIfEmpty()
                                      where MPC.MasterProductId == _Item.MasterProductId
                                      select new
                    {
                        MPC.MasterProductChildId,
                        MPC.MasterProductId,
                        MPC.ProductChildSKU,
                        MPC.ManufacturerPartNumber,
                        MPC.PurchaseDate,
                        MPC.PurchasePrice,
                        MPC.DepreciatePrice,
                        MPC.WarrantyExpiryDate,
                        MPC.WarrantyStartDate,
                        MPC.IterationOfWarranty,
                        MPC.MasterBranchId,
                        MPC.MasterEmployeeId,
                        MPC.MasterVendorId,
                        MPC.IsDeadAssets,
                        MPC.IsSaleProduct,
                        MPC.IsActive,
                        MasterAssetsAssignmentId = (MAA.MasterAssetsAssignmentId != null ? MAA.MasterAssetsAssignmentId : 0),
                        MAA.AssetsAssignmentDate,
                        MAA.IsAssetsDeAssign
                    });


                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    List <MasterProductAssignChildResult> objMasterProductAssignChildResultList = new List <MasterProductAssignChildResult>();
                    foreach (var _ItemChild in _dataChild.ToList())
                    {
                        MasterProductAssignChildResult _MasterProductAssignChildResult = new MasterProductAssignChildResult();

                        _MasterProductAssignChildResult.MasterProductChildId   = _ItemChild.MasterProductChildId;
                        _MasterProductAssignChildResult.MasterProductId        = _ItemChild.MasterProductId;
                        _MasterProductAssignChildResult.ProductChildSKU        = _ItemChild.ProductChildSKU;
                        _MasterProductAssignChildResult.ManufacturerPartNumber = _ItemChild.ManufacturerPartNumber;
                        _MasterProductAssignChildResult.PurchaseDate           = _ItemChild.PurchaseDate;
                        _MasterProductAssignChildResult.PurchasePrice          = _ItemChild.PurchasePrice;
                        _MasterProductAssignChildResult.DepreciatePrice        = _ItemChild.DepreciatePrice;
                        _MasterProductAssignChildResult.WarrantyExpiryDate     = _ItemChild.WarrantyExpiryDate;
                        _MasterProductAssignChildResult.WarrantyStartDate      = _ItemChild.WarrantyStartDate;
                        _MasterProductAssignChildResult.IterationOfWarranty    = _ItemChild.IterationOfWarranty;
                        _MasterProductAssignChildResult.IsActive                 = _ItemChild.IsActive;
                        _MasterProductAssignChildResult.IsDeadAssets             = _ItemChild.IsDeadAssets;
                        _MasterProductAssignChildResult.IsSaleProduct            = _ItemChild.IsSaleProduct;
                        _MasterProductAssignChildResult.MasterBranchId           = _ItemChild.MasterBranchId;
                        _MasterProductAssignChildResult.BranchTitle              = _AdminBranches.Where(a => a.MasterBranchId == _ItemChild.MasterBranchId).Select(a => a.BranchTitle).FirstOrDefault();
                        _MasterProductAssignChildResult.MasterEmployeeId         = _ItemChild.MasterEmployeeId;
                        _MasterProductAssignChildResult.EmployeeName             = _AdminEmployees.Where(a => a.MasterEmployeeId == _ItemChild.MasterEmployeeId).Select(a => a.EmployeeName).FirstOrDefault();
                        _MasterProductAssignChildResult.MasterAssetsAssignmentId = _ItemChild.MasterAssetsAssignmentId;
                        _MasterProductAssignChildResult.AssetsAssignmentDate     = _ItemChild.AssetsAssignmentDate;
                        _MasterProductAssignChildResult.MasterVendorId           = _ItemChild.MasterVendorId;
                        _MasterProductAssignChildResult.VendorTitle              = _AdminVendors.Where(a => a.MasterVendorId == _ItemChild.MasterVendorId).Select(a => a.VendorTitle).FirstOrDefault();;
                        _MasterProductAssignChildResult.IsAssetsDeAssign         = _ItemChild.IsAssetsDeAssign;

                        objMasterProductAssignChildResultList.Add(_MasterProductAssignChildResult);
                    }
                    _MasterProductResult.ProductAssignChildList = objMasterProductAssignChildResultList;
                }

                return(objMasterProductResultList);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #28
0
        /// <summary>
        /// 构造一棵用于测试的简单组织机构树
        /// </summary>
        public static void PreareTestOrgTree()
        {
            SchemaObjectAdapter.Instance.ClearAllData();

            SCOrganization parent1 = PrepareOrganizationObject("第一组织", "第一组织");

            SCObjectOperations.Instance.AddOrganization(parent1, SCOrganization.GetRoot());

            SCObjectOperations.Instance.AddUser(PrepareUserObject("沈", "峥", "shenzheng"), parent1);
            SCObjectOperations.Instance.AddUser(PrepareUserObject("危", "仁飞", "weirf"), parent1);

            SCOrganization parent2 = PrepareOrganizationObject("第二组织", "第二组织");

            parent2.DisplayName = "第二组织(很多人)";
            SCObjectOperations.Instance.AddOrganization(parent2, SCOrganization.GetRoot());
            AddMultiUsers(parent2);

            SCOrganization parent3 = PrepareOrganizationObject("第三组织", "第三组织");

            SCObjectOperations.Instance.AddOrganization(parent3, SCOrganization.GetRoot());

            SCOrganization parent31 = PrepareOrganizationObject("第三.一组织", "第三.一组织");

            SCObjectOperations.Instance.AddOrganization(parent31, parent3);

            SCUser user1 = PrepareUserObject("金", "涛", "jintao");

            SCObjectOperations.Instance.AddUser(user1, parent31);

            SCUser user2 = PrepareUserObject("郑", "桂龙", "zhenggl");

            SCObjectOperations.Instance.AddUser(user2, parent31);

            SCOrganization parent32 = PrepareOrganizationObject("第三.二组织", "第三.二组织");

            SCObjectOperations.Instance.AddOrganization(parent32, parent3);

            SCUser user3 = PrepareUserObject("李", "琪", "liqi");

            SCObjectOperations.Instance.AddUser(user3, parent32);

            SCUser user4 = PrepareUserObject("徐", "磊", "xulei");

            SCObjectOperations.Instance.AddUser(user4, parent32);

            SCOrganization parent4 = PrepareOrganizationObject("第四组织", "第四组织");

            parent4.DisplayName = "第四组织(包含组)";
            SCObjectOperations.Instance.AddOrganization(parent4, SCOrganization.GetRoot());

            SCGroup group = PrepareSCObject <SCGroup>("包含领导的组", "包含领导的组");

            SCObjectOperations.Instance.AddGroup(group, parent4);

            SCObjectOperations.Instance.AddUserToGroup(user1, group);
            SCObjectOperations.Instance.AddUserToGroup(user2, group);

            SCGroup group2 = PrepareSCObject <SCGroup>("包含孩子们的组", "包含孩子们的组");

            SCObjectOperations.Instance.AddGroup(group2, parent4);

            //重复插入
            SCObjectOperations.Instance.AddUserToGroup(user3, group2);
            SCObjectOperations.Instance.AddUserToGroup(user3, group2);

            SCObjectOperations.Instance.AddUserToGroup(user4, group2);
            SCObjectOperations.Instance.AddUserToGroup(user4, group2);

            PrepareTestApplicationData();
        }
        public IEnumerable <MasterAssetsAssignmentResult> GetAllASMasterAssetsAssignment(long MasterEmployeeId)
        {
            try
            {
                var _data = (from MP in _Context.ASMasterProducts
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId
                             join MAA in _Context.ASMasterAssetsAssignments on MPC.MasterProductChildId equals MAA.MasterProductChildId
                             where MAA.MasterEmployeeId == MasterEmployeeId
                             select new
                {
                    MPC.MasterProductChildId,
                    MPC.MasterProductId,
                    MPC.ProductChildSKU,
                    MPC.ProductChildTitle,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchaseDate,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.MasterVendorId,
                    MPC.IsDeadAssets,
                    MPC.IsTimeToSaleProduct,
                    MPC.IsSaleProduct,
                    MPC.SaleDate,
                    MPC.SalePrice,
                    MPC.ProductQty,
                    MPC.ProductQtyUnit,
                    MPC.NumberOfItemIncludeInProduct,
                    MPC.ItemPackageQuantity,
                    MPC.IterationOfWarranty,
                    MPC.WarrantyStartDate,
                    MPC.WarrantyExpiryDate,
                    MPC.MasterBranchId,

                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    CA.MasterCategoryId,
                    CA.CategoryTitle,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.ProductModel,
                    MP.Manufacturer,


                    MAA.MasterAssetsAssignmentId,
                    MAA.AssetsAssignmentDate,
                    MAA.ASMasterProductChilds,
                    MAA.MasterEmployeeId,
                    MAA.IsAssetsDeAssign,
                    MAA.AssetsDeAssignmentDate,
                    MAA.DeAssignReason,
                    MAA.MasterLocationId,
                    MAA.Sequence,
                    MAA.IsActive,
                    MAA.EnterById,
                    MAA.EnterDate,
                    MAA.ModifiedById,
                    MAA.ModifiedDate,
                });

                List <MasterAssetsAssignmentResult> objMasterAssetsAssignmentResultList = new List <MasterAssetsAssignmentResult>();

                foreach (var _Item in _data.ToList())
                {
                    var _MasterAssetsAssignmentResult = new MasterAssetsAssignmentResult();


                    _MasterAssetsAssignmentResult.MasterAssetsAssignmentId = _Item.MasterAssetsAssignmentId;
                    _MasterAssetsAssignmentResult.AssetsAssignmentDate     = _Item.AssetsAssignmentDate;
                    _MasterAssetsAssignmentResult.MasterEmployeeId         = _Item.MasterEmployeeId;
                    _MasterAssetsAssignmentResult.IsAssetsDeAssign         = _Item.IsAssetsDeAssign;
                    _MasterAssetsAssignmentResult.AssetsDeAssignmentDate   = _Item.AssetsDeAssignmentDate;
                    _MasterAssetsAssignmentResult.DeAssignReason           = _Item.DeAssignReason;
                    _MasterAssetsAssignmentResult.MasterLocationId         = _Item.MasterLocationId;
                    _MasterAssetsAssignmentResult.Sequence     = _Item.Sequence;
                    _MasterAssetsAssignmentResult.IsActive     = _Item.IsActive;
                    _MasterAssetsAssignmentResult.ActiveColor  = "green";
                    _MasterAssetsAssignmentResult.ActiveIcon   = "glyphicon glyphicon-ok";
                    _MasterAssetsAssignmentResult.EnterById    = _Item.EnterById;
                    _MasterAssetsAssignmentResult.EnterDate    = _Item.EnterDate;
                    _MasterAssetsAssignmentResult.ModifiedById = _Item.ModifiedById;
                    _MasterAssetsAssignmentResult.ModifiedDate = _Item.ModifiedDate;

                    if (_MasterAssetsAssignmentResult.IsActive == false)
                    {
                        _MasterAssetsAssignmentResult.ActiveColor = "red";
                        _MasterAssetsAssignmentResult.ActiveIcon  = "glyphicon glyphicon-remove";
                    }

                    _MasterAssetsAssignmentResult.MasterProductChildId = _Item.MasterProductChildId;
                    _MasterAssetsAssignmentResult.MasterProductId      = _Item.MasterProductId;
                    //_MasterAssetsAssignmentResult.ASMasterProducts = _Item.ASMasterProducts;
                    _MasterAssetsAssignmentResult.ProductChildSKU        = _Item.ProductChildSKU;
                    _MasterAssetsAssignmentResult.ProductChildTitle      = _Item.ProductChildTitle;
                    _MasterAssetsAssignmentResult.ManufacturerPartNumber = _Item.ManufacturerPartNumber;
                    //_MasterAssetsAssignmentResult.ASMasterProductSizes = _Item.ASMasterProductSizes;
                    _MasterAssetsAssignmentResult.PurchaseDate                 = _Item.PurchaseDate;
                    _MasterAssetsAssignmentResult.PurchasePrice                = _Item.PurchasePrice;
                    _MasterAssetsAssignmentResult.DepreciatePrice              = _Item.DepreciatePrice;
                    _MasterAssetsAssignmentResult.MasterVendorId               = _Item.MasterVendorId;
                    _MasterAssetsAssignmentResult.IsDeadAssets                 = _Item.IsDeadAssets;
                    _MasterAssetsAssignmentResult.IsTimeToSaleProduct          = _Item.IsTimeToSaleProduct;
                    _MasterAssetsAssignmentResult.IsSaleProduct                = _Item.IsSaleProduct;
                    _MasterAssetsAssignmentResult.SaleDate                     = _Item.SaleDate;
                    _MasterAssetsAssignmentResult.SalePrice                    = _Item.SalePrice;
                    _MasterAssetsAssignmentResult.ProductQty                   = _Item.ProductQty;
                    _MasterAssetsAssignmentResult.ProductQtyUnit               = _Item.ProductQtyUnit;
                    _MasterAssetsAssignmentResult.NumberOfItemIncludeInProduct = _Item.NumberOfItemIncludeInProduct;
                    _MasterAssetsAssignmentResult.ItemPackageQuantity          = _Item.ItemPackageQuantity;
                    _MasterAssetsAssignmentResult.IterationOfWarranty          = _Item.IterationOfWarranty;
                    _MasterAssetsAssignmentResult.WarrantyStartDate            = _Item.WarrantyStartDate;
                    _MasterAssetsAssignmentResult.WarrantyExpiryDate           = _Item.WarrantyExpiryDate;
                    _MasterAssetsAssignmentResult.MasterBranchId               = _Item.MasterBranchId;
                    _MasterAssetsAssignmentResult.MasterEmployeeId             = _Item.MasterEmployeeId;
                    _MasterAssetsAssignmentResult.EmployeeName                 = "";
                    _MasterAssetsAssignmentResult.ProductTitle                 = _Item.ProductTitle;
                    _MasterAssetsAssignmentResult.MasterBrandId                = _Item.MasterBrandId;
                    _MasterAssetsAssignmentResult.BrandTitle                   = _Item.BrandTitle;
                    _MasterAssetsAssignmentResult.MasterSubCategoryId          = _Item.MasterSubCategoryId;
                    _MasterAssetsAssignmentResult.SubCategoryTitle             = _Item.SubCategoryTitle;
                    _MasterAssetsAssignmentResult.MasterCategoryId             = _Item.MasterCategoryId;
                    _MasterAssetsAssignmentResult.CategoryTitle                = _Item.CategoryTitle;
                    _MasterAssetsAssignmentResult.ProductSKU                   = _Item.ProductSKU;
                    _MasterAssetsAssignmentResult.ProductModel                 = _Item.ProductModel;
                    _MasterAssetsAssignmentResult.Manufacturer                 = _Item.Manufacturer;
                    _MasterAssetsAssignmentResult.DepreciatePercentage         = _Item.DepreciatePercentage;
                    _MasterAssetsAssignmentResult.ReorderLevel                 = _Item.ReorderLevel;

                    objMasterAssetsAssignmentResultList.Add(_MasterAssetsAssignmentResult);
                }
                return(objMasterAssetsAssignmentResultList);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #30
0
        public IEnumerable <MasterProductResult> GetAllASMasterProduct()
        {
            try
            {
                var _data = (from MP in _Context.ASMasterProducts
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             select new
                {
                    MP.MasterProductId,
                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.ProductHSNCode,
                    MP.ProductBarCode,
                    MP.ProductMainImage,
                    MP.Description,
                    MP.Specification,
                    MP.LegalDisclamer,
                    MP.SafetyWarning,
                    MP.ProductModel,
                    MP.Manufacturer,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.CountryOfOrigin,
                    //CO.CountryTitle,
                    MP.ProductTaxCode,
                    //MT.TaxTitle,
                    //MT.IsTaxPercentageAmount,
                    //MT.TaxValue,
                    MP.ProductCurrency,
                    //MC.CurrencyTitle,
                    MP.Sequence,
                    MP.IsActive,
                    MP.EnterById,
                    MP.EnterDate,
                    MP.ModifiedById,
                    MP.ModifiedDate,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    CA.CategoryTitle,
                    CA.MasterCategoryId
                    //TotalAssets = 2,
                    //AssetsAllocated = 1
                }).ToList();

                var _Productdata = (from MC in _Context.ASMasterCategories
                                    join MSC in _Context.ASMasterSubCategories on MC.MasterCategoryId equals MSC.MasterCategoryId
                                    join MP in _Context.ASMasterProducts on MSC.MasterSubCategoryId equals MP.MasterSubCategoryId into MPGroup
                                    from MP in MPGroup.DefaultIfEmpty()
                                    join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId into MPCGroup
                                    from MPC in MPCGroup.DefaultIfEmpty()
                                    select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryTitle,
                    MSC.MasterSubCategoryId,
                    MSC.SubCategoryTitle,
                    MPC.MasterProductId,
                    MPC.ProductChildTitle,
                    MPC.ProductChildSKU,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.IsActive,
                    MPC.IsDeadAssets,
                    MPC.IsSaleProduct,
                    MPC.MasterBranchId,
                    MPC.MasterEmployeeId,
                    MPC.WarrantyExpiryDate
                });

                var _AdminCountries  = _AdminContext.ADMasterCountries.ToList();
                var _AdminTaxes      = _AdminContext.ADMasterTaxes.ToList();
                var _AdminCurrencies = _AdminContext.ADMasterCurrencies.ToList();

                List <MasterProductResult> objMasterProductResultList = new List <MasterProductResult>();

                foreach (var _Item in _data.ToList())
                {
                    var _MasterProductResult = new MasterProductResult();

                    _MasterProductResult.MasterProductId      = _Item.MasterProductId;
                    _MasterProductResult.ProductTitle         = _Item.ProductTitle;
                    _MasterProductResult.MasterBrandId        = _Item.MasterBrandId;
                    _MasterProductResult.BrandTitle           = _Item.BrandTitle;
                    _MasterProductResult.MasterSubCategoryId  = _Item.MasterSubCategoryId;
                    _MasterProductResult.SubCategoryTitle     = _Item.SubCategoryTitle;
                    _MasterProductResult.MasterCategoryId     = _Item.MasterCategoryId;
                    _MasterProductResult.CategoryTitle        = _Item.CategoryTitle;
                    _MasterProductResult.ProductSKU           = _Item.ProductSKU;
                    _MasterProductResult.ProductHSNCode       = _Item.ProductHSNCode;
                    _MasterProductResult.ProductBarCode       = _Item.ProductBarCode;
                    _MasterProductResult.ProductMainImage     = _Item.ProductMainImage;
                    _MasterProductResult.Description          = _Item.Description;
                    _MasterProductResult.Specification        = _Item.Specification;
                    _MasterProductResult.LegalDisclamer       = _Item.LegalDisclamer;
                    _MasterProductResult.SafetyWarning        = _Item.SafetyWarning;
                    _MasterProductResult.ProductModel         = _Item.ProductModel;
                    _MasterProductResult.Manufacturer         = _Item.Manufacturer;
                    _MasterProductResult.DepreciatePercentage = _Item.DepreciatePercentage;
                    _MasterProductResult.ReorderLevel         = _Item.ReorderLevel;
                    _MasterProductResult.CountryOfOrigin      = _Item.CountryOfOrigin;
                    _MasterProductResult.CountryOfOriginTitle = _AdminCountries.Where(a => a.MasterCountryId == _Item.CountryOfOrigin).Select(a => a.CountryTitle).FirstOrDefault();
                    _MasterProductResult.ProductTaxCode       = _Item.ProductTaxCode;
                    _MasterProductResult.ProductTaxCodeTitle  = _AdminTaxes.Where(a => a.MasterTaxId == _Item.ProductTaxCode).Select(a => a.TaxTitle).FirstOrDefault();
                    _MasterProductResult.ProductCurrency      = _Item.ProductCurrency;
                    _MasterProductResult.ProductCurrencyTitle = _AdminCurrencies.Where(a => a.MasterCurrencyId == _Item.ProductCurrency).Select(a => a.CurrencyTitle).FirstOrDefault();;
                    _MasterProductResult.Sequence             = _Item.Sequence;

                    _MasterProductResult.TotalAssetsInStock          = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsAssign                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false && (a.MasterEmployeeId != 0)).Count());
                    _MasterProductResult.AssetsInRepair              = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.ServiceInExpire             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.WarrantyExpiryDate <= DateTime.Now && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsInSold                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == true).Count());
                    _MasterProductResult.AssetsInDead                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == true && a.IsSaleProduct == false).Count());
                    _MasterProductResult.TotalAssetsCost             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.PurchasePrice) ?? 0);
                    _MasterProductResult.TotalAssetsDepreciatedValue = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.DepreciatePrice) ?? 0);


                    _MasterProductResult.IsActive     = _Item.IsActive;
                    _MasterProductResult.EnterById    = _Item.EnterById;
                    _MasterProductResult.EnterDate    = _Item.EnterDate;
                    _MasterProductResult.ModifiedById = _Item.ModifiedById;
                    _MasterProductResult.ModifiedDate = _Item.ModifiedDate;

                    objMasterProductResultList.Add(_MasterProductResult);
                }
                return(objMasterProductResultList.ToList());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }