コード例 #1
0
        protected override void PreDeleteInsideTransaction(BusinessContext context)
        {
            base.PreDeleteInsideTransaction(context);

            // Remove SecureRole From Principal
            DirectoryManager.DeletePrincipal(context.GetTargetPrimaryKeyId().Value);
        }
コード例 #2
0
        protected override void PostCreateInsideTransaction(BusinessContext context)
        {
            // Call Base method
            base.PostCreateInsideTransaction(context);

            #region Create a new Document Card
            PrimaryKeyId pkDocumentType = ((CreateResponse)context.Response).PrimaryKeyId;

            // Create a new Document Card
            using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit())
            {
                // TODO: Check Card Name
                string cardName = context.Request.Target["Name"].ToString();
                string cardFriendlyName = context.Request.Target["FriendlyName"].ToString();
                string cardPluralName = cardFriendlyName;
                string tableName = "cls_Document_" + context.Request.Target["Name"].ToString();

                MetaClass newCard = DataContext.Current.MetaModel.CreateCardMetaClass(DataContext.Current.GetMetaClass(DocumentEntity.GetAssignedMetaClassName()),
                    cardName, cardFriendlyName,
                    cardPluralName, tableName);

                scope.SaveChanges();
            }
            #endregion
        }
コード例 #3
0
        /// <summary>
        /// Initializes the mapping document.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void InitializeMappingDocument(BusinessContext context)
        {
            InitializeMappingDocumentRequest request = ((InitializeMappingDocumentRequest)context.Request);

            MetaClass metaClass = DataContext.Current.GetMetaClass(context.GetTargetMetaClassName());
            List<PrimaryKeyId> primaryKeyIds = new List<PrimaryKeyId>();

            // Create Default Mapping
            MappingDocument retVal = new MappingDocument();

            DataTable dataTable = request.Data.Tables[request.TableIndex];

            MappingElement mapping = new MappingElement(dataTable.TableName, metaClass.Name);
            retVal.Add(mapping);

            MappingElementBuilder builder = new MappingElementBuilder(retVal);

            //Call creation mapping document by saved patterns
            DefaultMappingHelper.CreateMapingByPatternComparision(dataTable, metaClass, builder);

            // Write Response
            InitializeMappingDocumentResponse response = new InitializeMappingDocumentResponse();
            response.MappingDocument = retVal;

            context.SetResponse(response);
        }
コード例 #4
0
        /// <summary>
        /// Closes the assignment.
        /// </summary>
        /// <param name="context">The context.</param>
        protected virtual void CloseAssignment(BusinessContext context)
        {
            CloseAssignmentRequest request = (CloseAssignmentRequest)context.Request;

            // Load Assignment
            MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);

            if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Active)
                throw new InvalidOperationException();

            DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);

            // Update Meta Object Fields
            metaObject[AssignmentEntity.FieldClosedBy] = (int)DataContext.Current.CurrentUserId;
            metaObject[AssignmentEntity.FieldState] = (int)AssignmentState.Closed;
            metaObject[AssignmentEntity.FieldExecutionResult] = request.ExecutionResult;
            metaObject[AssignmentEntity.FieldComment] = request.Comment;
            metaObject[AssignmentEntity.FieldActualFinishDate] = dateTimeNow;

            // Save Meta Object
            metaObject.Save();

            if (metaObject[AssignmentEntity.FieldWorkflowInstanceId]!=null)
            {
                // Run Workflow
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
                RunWorkflow(entity);
            }

            context.SetResponse(new Response());
        }
コード例 #5
0
        public void DeleteKeywordIsPersisted()
        {
            using (var businessContext = new BusinessContext())
            {
                var language = new Language
                {
                    Name = "LanguageName"
                };

                businessContext.AddNewLanguage(language);

                var keyword = new Keyword
                {
                    Name = "KeywordName",
                    LanguageId = 1,
                };

                businessContext.AddNewKeyword(keyword);

                //businessContext.DeleteKeyword(keyword);

                bool notDeleted = businessContext.DataContext.Keywords.Any(k => k.Id == keyword.Id);

                //Assert.IsFalse(notDeleted);
            }
        }
コード例 #6
0
        protected override void List(BusinessContext context)
        {
            base.List(context);

            ListRequest request = (ListRequest)context.Request;
            ListResponse response = (ListResponse)context.Response;

            // Check if sorting contains OutlineNumber
            bool bSortByName = request.Sorting.Length == 1 &&
                request.Sorting[0].Source == DirectoryOrganizationalUnitEntity.FieldOutlineNumber;

            List<EntityObject> items = new List<EntityObject>(response.EntityObjects);

            // Load Name From GlobalResource
            foreach (DirectoryOrganizationalUnitEntity entity in items)
            {
                entity.Name = GlobalResource.GetString(entity.Name);
            }

            if (bSortByName)
            {
                SortEntityObjectTreeByName(items);
            }

            response.EntityObjects = items.ToArray();
        }
コード例 #7
0
        public void UpdateKeywordIsPersisted()
        {
            using (var businessContext = new BusinessContext())
            {
                var language = new Language
                {
                    Name = "LanguageName"
                };

                businessContext.AddNewLanguage(language);

                var keyword = new Keyword
                {
                    Name = "KeywordName",
                    LanguageId = 1,
                };

                businessContext.AddNewKeyword(keyword);

                keyword.Name = "New KeywordName";

                businessContext.UpdateKeyword(keyword);

                bool updated = businessContext.DataContext.Keywords.Any(k => k.Id == keyword.Id && k.Name == keyword.Name);

                Assert.IsTrue(updated);
            }
        }
コード例 #8
0
        /// <summary>
        /// Resets the delivery attempts.
        /// </summary>
        /// <param name="context">The context.</param>
        protected virtual void ResetDeliveryAttempts(BusinessContext context)
        {
            MetaObject metaObject = MetaObjectActivator.CreateInstance(context.GetTargetMetaClassName(), context.GetTargetPrimaryKeyId().Value);

            metaObject[OutgoingMessageQueueEntity.FieldDeliveryAttempts] = 0;

            metaObject.Save();
        }
 public void Execute(BusinessContext context)
 {
     _log.Debug("Execute (IPlugin) for {0}. Metaclass: {1}. PrimaryKey: {2}. Plugin Stage: {3}",
         context.GetMethod(),
         context.GetTargetMetaClassName(),
         context.GetTargetPrimaryKeyId().HasValue ? context.GetTargetPrimaryKeyId().Value.ToString() : "null",
         context.PluginStage);
 }
コード例 #10
0
 protected override void Load(BusinessContext context)
 {
     // solve problem if item was load in LocalDiskEntityObjectPlugin
     if (context.Response == null)
     {
         base.Load(context);
     }
 }
コード例 #11
0
ファイル: ListRequestHandler.cs プロジェクト: 0anion0/IBN
        /// <summary>
        /// Deletes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Delete(BusinessContext context)
        {
            // OZ: Comment base logic and call custom business logic ListManager.DeleteList
            //base.Delete(context);

            ListManager.DeleteList((int)context.GetTargetPrimaryKeyId().Value);

            context.SetResponse(new Response());
        }
コード例 #12
0
        protected override void PostCreateInsideTransaction(BusinessContext context)
        {
            base.PostCreateInsideTransaction(context);

            // Add User To Principal
            DirectoryManager.CreatePrincipal(DirectoryPrincipalType.User,
                ((CreateResponse)context.Response).PrimaryKeyId,
                ((DirectoryUserEntity)context.Request.Target).FullName);
        }
コード例 #13
0
        protected override void PostCreateInsideTransaction(BusinessContext context)
        {
            base.PostCreateInsideTransaction(context);

            // Add SecureRole To Principal
            DirectoryManager.CreatePrincipal(DirectoryPrincipalType.WorkGroup,
                ((CreateResponse)context.Response).PrimaryKeyId,
                ((DirectoryWorkGroupEntity)context.Request.Target).Name);
        }
コード例 #14
0
        /// <summary>
        /// Pres the delete inside transaction.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PreDeleteInsideTransaction(BusinessContext context)
        {
            base.PreDeleteInsideTransaction(context);

            #region Remove references from IBN 4.7 objects
            SqlHelper.ExecuteNonQuery(SqlContext.Current, System.Data.CommandType.StoredProcedure,
                "bus_cls_ListObject_Delete",
                SqlHelper.SqlParameter("@ClassName", SqlDbType.NVarChar, 250, context.GetTargetMetaClassName()),
                SqlHelper.SqlParameter("@ObjectId", SqlDbType.VarChar, 36, context.GetTargetPrimaryKeyId().Value.ToString()));
            #endregion
        }
コード例 #15
0
        protected override void PostUpdateInsideTransaction(BusinessContext context)
        {
            base.PostUpdateInsideTransaction(context);

            // Update Principal
            if(context.Request.Target.Properties.Contains(DirectoryWorkGroupEntity.FieldName))
            {
                DirectoryManager.UpdatePrincipal(context.GetTargetPrimaryKeyId().Value,
                    (string)context.Request.Target[DirectoryWorkGroupEntity.FieldName]);
            }
        }
コード例 #16
0
ファイル: AddressRequestHandler.cs プロジェクト: 0anion0/IBN
        /// <summary>
        /// Customs the method.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void CustomMethod(BusinessContext context)
        {
            base.CustomMethod(context);

            switch (context.GetMethod())
            {
                case AddressRequestMethod.SetDefaultAddress:
                    SetDefaultAddress(context);
                    break;
            }
        }
コード例 #17
0
        /// <summary>
        /// Customs the method.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void CustomMethod(BusinessContext context)
        {
            base.CustomMethod(context);

            switch (context.GetMethod())
            {
                case OutgoingMessageQueueMethod.ResetDeliveryAttempts:
                    ResetDeliveryAttempts(context);
                    break;
            }
        }
コード例 #18
0
 /// <summary>
 /// Creates the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 protected override void Create(BusinessContext context)
 {
     CustomizationProfileUserEntity newEntity = (CustomizationProfileUserEntity)context.Request.Target;
     if (newEntity.ProfileId > 0)
     {
         base.Create(context);
     }
     else  // for default profile we don't need to create a new record
     {
         context.SetResponse(new CreateResponse(PrimaryKeyId.Empty));
     }
 }
コード例 #19
0
 /// <summary>
 /// Customs the method.
 /// </summary>
 /// <param name="context">The context.</param>
 protected override void CustomMethod(BusinessContext context)
 {
     switch (context.GetMethod())
     {
         case DirectoryOrganizationalUnitMethod.Move:
             Move(context);
             break;
         default:
             base.CustomMethod(context);
             break;
     }
 }
コード例 #20
0
ファイル: ReportRequestHandler.cs プロジェクト: 0anion0/IBN
 protected override void CustomMethod(BusinessContext context)
 {
     switch (context.Request.Method)
     {
         case ReportRequestMethod.GetReportData:
             context.SetResponse(GetReportData(context.Request));
             break;
         default:
             base.CustomMethod(context);
             break;
     }
 }
コード例 #21
0
        public void AddNewLanguage_ThrowsException_WhenNameIsEmpty()
        {
            using (var businessContext = new BusinessContext())
            {
                var language = new Language
                {
                    Name = ""
                };

                businessContext.AddNewLanguage(language);
            }
        }
コード例 #22
0
 protected override void CustomMethod(BusinessContext context)
 {
     switch (context.Request.Method)
     {
         case ChangeTrackingMethod.METHOD_NAME:
             context.SetResponse(ChangeTrackingMethod.ChangeTracking(context.Request as ChangeTrackingRequest));
             break;
         default:
             base.CustomMethod(context);
             break;
     }
     base.CustomMethod(context);
 }
コード例 #23
0
        public void AddNewKeyword_ThrowsException_WhenLanguageIdDoesNotExist()
        {
            using (var businessContext = new BusinessContext())
            {
                var keyword = new Keyword
                {
                    Name = "KeywordName",
                    LanguageId = 0
                };

                businessContext.AddNewKeyword(keyword);
            }
        }
コード例 #24
0
        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public virtual void Execute(BusinessContext context)
        {
            WorkflowInstanceEntity entityObject = (WorkflowInstanceEntity)BusinessManager.Load(context.GetTargetMetaClassName(), context.GetTargetPrimaryKeyId().Value);

            if (entityObject.OwnerDocumentId.HasValue)
            {
                Document.SetReadOnly(
                    entityObject.OwnerDocumentId.Value,
                    false);
            }

            // TODO: Add New Owner Here
        }
コード例 #25
0
 protected override void Create(BusinessContext context)
 {
     CreateRequest createRequest = context.Request as CreateRequest;
     bool forceBase = createRequest.Parameters.GetValue<bool>(EventHelper.FORCE_BASE_PARAM, false);
     if (!forceBase)
     {
          CreateResponse response = Mediachase.Ibn.Events.CustomMethods.EventHelper.CreateResourceRequestHandle(createRequest);
          context.SetResponse(response);
     }
     else
     {
         base.Create(context);
     }
 }
コード例 #26
0
 protected override void Delete(BusinessContext context)
 {
     CalendarEventResourceEntity resourceEntity = context.Request.Target as CalendarEventResourceEntity;
     DeleteRequest deleteRequest = context.Request as DeleteRequest;
     bool forceBase = deleteRequest.Parameters.GetValue<bool>(EventHelper.FORCE_BASE_PARAM, false);
     if (!forceBase)
     {
         Mediachase.Ibn.Events.CustomMethods.EventHelper.DeleteResourceRequestHandle(deleteRequest);
     }
     else
     {
         base.Delete(context);
     }
 }
コード例 #27
0
        protected override void Create(BusinessContext context)
        {
            base.Create(context);

            // Append to tree
            DirectoryOrganizationalUnitEntity target = ((DirectoryOrganizationalUnitEntity)context.Request.Target);

            BusinessObject newElement = (BusinessObject)context.Items[MetaObjectRequestHandler.SourceMetaObjectKey];
            BusinessObject parent = (BusinessObject)MetaObjectActivator.CreateInstance(DirectoryOrganizationalUnitEntity.ClassName,
                target.ParentId.Value);

            TreeNode node = parent.GetService<TreeService>().AppendChild(newElement);
            parent.Save();
        }
コード例 #28
0
        /// <summary>
        /// Pres the create.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PreCreate(BusinessContext context)
        {
            base.PreCreate(context);

            #region Fill Contact FullName = LastName FirstName MiddleName
            DirectoryUserEntity user = (DirectoryUserEntity)context.Request.Target;

            if (string.IsNullOrEmpty(user.FullName))
            {
                user.FullName = user.Properties.GetValue<string>(DirectoryUserEntity.FieldLastName, string.Empty) + " " +
                    user.Properties.GetValue<string>(DirectoryUserEntity.FieldFirstName, string.Empty) + " " +
                    user.Properties.GetValue<string>(DirectoryUserEntity.FieldMiddleName, string.Empty);
            }
            #endregion
        }
コード例 #29
0
        public void AddNewLanguageIsPersisted()
        {
            using (var businessContext = new BusinessContext())
            {
                var language = new Language
                {
                    Name = "LanguageName"
                };

                businessContext.AddNewLanguage(language);

                bool exists = businessContext.DataContext.Languages.Any(l => l.Id == language.Id);

                Assert.IsTrue(exists);
            }
        }
コード例 #30
0
ファイル: SecurityPlugin.cs プロジェクト: 0anion0/IBN
        /// <summary>
        /// Reads the right check.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ReadRightCheck(BusinessContext context)
        {
            //Если есть флаг отключить проверку авторизации то ничего не фильтруем
            if (!SkipSecurityCheckScope.IsActive)
            {
                string securityViewQuery = @"SELECT ObjectId FROM [dbo].[CalendarEvent_Security_Read]";
                //Добавляем в sql context текущего пользователя
                SetContextInfo(Security.CurrentUserId);
                //Для метода List необходимо отфильтровать список согласно security view
                if (context.GetMethod() == RequestMethod.List)
                {
                    ListRequest listRequest = context.Request as ListRequest;
                    FilterElementCollection filterColl = new FilterElementCollection();
                    foreach (FilterElement origFilterEl in listRequest.Filters)
                    {
                        filterColl.Add(origFilterEl);
                    }

                    FilterElement filterEl = new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery);
                    filterColl.Add(filterEl);
                    //перезаписываем старую коллекцию фильтров, новой
                    listRequest.Filters = filterColl.ToArray();

                }//Для метода Load необходмио предотвратить загрузку объета не имеющего соотв прав
                else if (context.GetMethod() == RequestMethod.Load)
                {

                    LoadRequest loadRequest = context.Request as LoadRequest;
                    PrimaryKeyId eventId = loadRequest.Target.PrimaryKeyId.Value;
                    VirtualEventId vEventId = (VirtualEventId)eventId;
                    if (vEventId.IsRecurrence)
                    {
                        eventId = vEventId.RealEventId;
                    }

                    if (BusinessObject.GetTotalCount(DataContext.Current.GetMetaClass(CalendarEventEntity.ClassName),
                                                      new FilterElement[] {
                                                                            new FilterElement("PrimaryKeyId", FilterElementType.Equal, eventId),
                                                                            new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery)
                                                                           }) == 0)
                    {
                        throw new Exception("Read access denied");
                    }
                }

            }
        }
コード例 #31
0
        public BusinessResult GetEmployeeByOrg(BusinessContext context)
        {
            var legalId  = context.Credential.LegalGuid();
            var tenantId = context.Credential.TenantGuid();

            var name    = context.Request["name"];
            var userno  = context.Request["userno"];
            var orgId   = context.Request.Contains("orgId") && !string.IsNullOrWhiteSpace(context.Request["orgId"]) ? Guid.Parse(context.Request["orgId"]) : Guid.Empty;
            var options = context.Request["options"];

            var notLimitLegal     = "1".Equals(context.Request["notLimitLegal"]);
            var includeOnBoarding = "1".Equals(context.Request["includeOnBoarding"]);

            var showChild    = "true".Equals(context.Request["showChild"], StringComparison.CurrentCultureIgnoreCase);
            var showSideline = "true".Equals(context.Request["showSideline"], StringComparison.CurrentCultureIgnoreCase);

            using (var dbContect = new HRDbContext())
            {
                #region "Query"
                var lstEmpStatus = new List <string>()
                {
                    "0|HR_EMP_EmpStatus",
                    "2|HR_EMP_EmpStatus",
                };

                if (includeOnBoarding)
                {
                    lstEmpStatus.Add("1|HR_EMP_EmpStatus");
                }

                var lstChildOrgId = new HR_OrganizationHelper().GetChildOrgId(notLimitLegal ? Guid.Empty : legalId, orgId, true);
                var query         = from emp in dbContect.HR_EMP_Employee
                                    join emppos in dbContect.HR_EMP_PostInformation on emp.EmployeeID equals emppos.EmployeeID
                                    join pos in dbContect.HR_ORG_Position on emppos.PositionID equals pos.PositionID
                                    //join posl in dbContect.HR_ORG_PositionLevels on pos.PositionLevelID equals posl.PositionLevelID into tmpPOSL
                                    //from posl in tmpPOSL.DefaultIfEmpty()
                                    join sl in dbContect.HR_EMP_SalaryLevel.Where(p => !p.IsDeleted) on emp.SalaryLevelID equals sl.SalaryLevelID into tmpSL
                                    from sl in tmpSL.DefaultIfEmpty()
                                    join area in dbContect.HR_EMP_OfficeArea on emp.OfficeAreaID equals area.AreaID into tmpArea
                                    from area in tmpArea.DefaultIfEmpty()
                                    join org in dbContect.HR_ORG_Organization on emppos.OrganizationID equals org.OrganizationID
                                    join leg in dbContect.HR_ORG_LegalEntity on org.LegalEntityID equals leg.LegalEntityID
                                    where !emp.IsDeleted && !emppos.IsDeleted && lstEmpStatus.Contains(emp.EmpStatus) && emp.TenantID == tenantId
                                    select new EmployeeInfo
                {
                    EmployeeID        = emp.EmployeeID,
                    EmployeeNameCN    = emp.EmployeeNameCN,
                    EmployeeNameEN    = emp.EmployeeNameEN,
                    EmployeeNumber    = emp.EmployeeNumber,
                    TeleCode          = emp.TeleCode,
                    ExtCode           = emp.ExtCode,
                    OfficeAreaID      = emp.OfficeAreaID,
                    OfficeAreaName    = area == null ? string.Empty : area.AreaName,
                    IDType            = emp.IDType,
                    IDNumber          = emp.IDNumber,
                    PersonalTelNumber = emp.PersonalCellPhone,

                    MainJobPostionID   = emp.MainJobPositionID,
                    MainJobPostionName = emp.MainJobPostionName,

                    CurrentJobLevelID    = Guid.Empty,
                    CurrentJobLevelName  = string.Empty,
                    CurrentJobLevelValue = decimal.Zero,

                    SalaryLevelID   = sl != null ? sl.SalaryLevelID : (Guid?)null,
                    SalaryLevelName = sl != null ? sl.SalaryLevelName : string.Empty,
                    SalaryLevelType = sl != null ? sl.SalaryLevelType : string.Empty,

                    FirstWorkedDate      = emp.FirstWorkedDate,
                    OnboardDate          = emp.OnboardDate,
                    PositionID           = pos.PositionID,
                    PositionCode         = pos.PositionCode,
                    PositionName         = pos.PositionName,
                    OrganizationID       = org.OrganizationID,
                    OrganizationCode     = org.OrganizationCode,
                    OrganizationName     = org.OrganizationName,
                    LegalEntityID        = org.LegalEntityID,
                    LegalEntityCode      = leg.LegalEntityCode,
                    LegalEntityName      = leg.LegalEntityName,
                    LegalEntityTelNumber = leg.TelNumber,
                    IsMain         = emppos.IsMain,
                    CreateTime     = emp.CreateTime,
                    EmployeeStatus = emp.EmployeeStatus,
                    TrialBeginDate = emp.TrialBeginDate,
                    TrialEndDate   = emp.TrialEndDate,
                    EmployeeEMail  = emp.EmployeeEMail,
                    Gender         = emp.Gender,
                    Birthday       = emp.Birthday,
                    MaritalStatus  = emp.MaritalStatus
                };

                if (!notLimitLegal)
                {
                    query = query.Where(t => t.LegalEntityID == legalId);
                }

                if (!string.IsNullOrEmpty(name))
                {
                    query = query.Where(u => u.EmployeeNameCN.Contains(name));
                }

                if (!string.IsNullOrEmpty(userno))
                {
                    query = query.Where(u => u.EmployeeNumber.Contains(userno));
                }

                #region "Options"
                var mainPosOnly      = false;
                var probationEmpOnly = false;

                if (!string.IsNullOrWhiteSpace(options))
                {
                    var opts = Newtonsoft.Json.JsonConvert.DeserializeObject(options) as dynamic;

                    try
                    {
                        mainPosOnly      = Convert.ToBoolean(opts.mainPosOnly);
                        probationEmpOnly = Convert.ToBoolean(opts.probationEmpOnly);
                    }
                    catch { }
                }

                if (mainPosOnly)
                {
                    query = query.Where(u => u.IsMain);
                }

                if (probationEmpOnly)
                {
                    query = query.Where(u => u.EmployeeStatus == "6|" + DictConstants.HR_EMP_EmployeeStatus);
                }
                #endregion

                if (!showSideline)
                {
                    query = query.Where(u => u.IsMain);
                }

                if (showChild)
                {
                    query = query.Where(t => lstChildOrgId.Contains(t.OrganizationID.Value));
                }
                else
                {
                    query = query.Where(t => t.OrganizationID == orgId);
                }
                #endregion

                var total   = 0;
                var results = new EmployeeInfo[0];

                query = BizHelper.GetPageQuery(context, query.OrderBy(g => g.CreateTime), out total);

                if (total > 0)
                {
                    results = query.ToArray();

                    foreach (var item in results)
                    {
                        item.Gender          = CommonDictService.GetDictItemName(item.Gender);
                        item.MaritalStatus   = CommonDictService.GetDictItemName(item.MaritalStatus);
                        item.IDType          = CommonDictService.GetDictItemName(item.IDType);
                        item.SalaryLevelName = string.Format("{0} ({1})", item.SalaryLevelName, CommonDictService.GetDictItemName(item.SalaryLevelType));
                    }

                    #region "Options: Address"
                    var empIDs    = query.Select(p => p.EmployeeID).ToList();
                    var addrDatum = from c in dbContect.HR_EMP_Address.Where(p => !p.IsDeleted && empIDs.Contains(p.EmployeeID))
                                    group c by c.EmployeeID into g
                                    select new
                    {
                        EmployeeID  = g.Key,
                        HomeAddress = g.Where(p => p.AddressType == "0").OrderByDescending(p => p.CreateTime).Select(p => new EmployeeAddress
                        {
                            Country      = p.Country,
                            Province     = p.Province,
                            City         = p.City,
                            District     = p.District,
                            Address      = p.Address,
                            AddressPhone = p.AddressPhone,
                            ZipCode      = p.ZipCode
                        }).FirstOrDefault(),
                        HukouAddress = g.Where(p => p.AddressType == "1").OrderByDescending(p => p.CreateTime).Select(p => new EmployeeAddress
                        {
                            Country      = p.Country,
                            Province     = p.Province,
                            City         = p.City,
                            District     = p.District,
                            Address      = p.Address,
                            AddressPhone = p.AddressPhone,
                            ZipCode      = p.ZipCode
                        }).FirstOrDefault()
                    };

                    foreach (var addr in addrDatum)
                    {
                        var item = results.FirstOrDefault(p => p.EmployeeID == addr.EmployeeID);

                        if (item != null)
                        {
                            item.HomeAddress  = addr.HomeAddress;
                            item.HukouAddress = addr.HukouAddress;
                        }
                    }
                    #endregion
                }

                return(this.OK(new { total = total, rows = results }));
            }
        }
コード例 #32
0
        public BusinessResult GetEmployeeByIDs(BusinessContext context)
        {
            var content = context.Content as JObject;
            var data    = content["formdata"];

            var jsonObj = JsonConvert.DeserializeAnonymousType(
                context.Content.ToJsonString(),
                new
            {
                ids               = string.Empty,
                orgId             = string.Empty,
                name              = string.Empty,
                userno            = string.Empty,
                options           = string.Empty,
                notLimitLegal     = string.Empty,
                includeOnBoarding = string.Empty,
                showChild         = string.Empty,
                showSideline      = string.Empty
                                    //formdata = new
                                    //{
                                    //    ids = string.Empty
                                    //}
            });

            if (string.IsNullOrEmpty(jsonObj.ids))
            {
                this.ThrowException("请选择员工!");
            }
            var idPosList       = jsonObj.ids.Split(';').ToList();
            var selectedEmpList = idPosList.Select(a => new { EmployeeID = Guid.Parse(a.Split(',')[0].ToString()), PosID = Guid.Parse(a.Split(',')[1].ToString()) }).ToList();
            //List<Guid> idList = new List<Guid>();
            //if (!string.IsNullOrEmpty(jsonObj.ids))
            //{
            //    idList = jsonObj.ids.Split(';').Select(a => Guid.Parse(a.Trim().ToString())).ToList();
            //}
            List <Guid> idList   = selectedEmpList.Select(a => a.EmployeeID).ToList();
            var         legalId  = context.Credential.LegalGuid();
            var         tenantId = context.Credential.TenantGuid();

            //var orgId = context.Request["orgId"];
            //Guid orgGuid = Guid.Parse(orgId);
            //var name = context.Request["name"];
            //var userno = context.Request["userno"];
            //var options = context.Request["options"];

            //var notLimitLegal = "1".Equals(context.Request["notLimitLegal"]);

            //var includeOnBoarding = "1".Equals(context.Request["includeOnBoarding"]);

            //var showChild = "true".Equals(context.Request["showChild"], StringComparison.CurrentCultureIgnoreCase);
            //var showSideline = "true".Equals(context.Request["showSideline"], StringComparison.CurrentCultureIgnoreCase);

            var  orgId   = jsonObj.orgId;
            Guid orgGuid = Guid.Parse(orgId);
            var  name    = jsonObj.name;
            var  userno  = jsonObj.userno;
            var  options = jsonObj.options;

            var notLimitLegal = "1".Equals(jsonObj.notLimitLegal);

            var includeOnBoarding = "1".Equals(jsonObj.includeOnBoarding);

            var showChild    = "true".Equals(jsonObj.showChild, StringComparison.CurrentCultureIgnoreCase);
            var showSideline = "true".Equals(jsonObj.showSideline, StringComparison.CurrentCultureIgnoreCase);

            using (var dbContect = new HRDbContext())
            {
                var lstEmpStatus = new List <string>()
                {
                    "0|HR_EMP_EmpStatus",
                    "2|HR_EMP_EmpStatus",
                };
                if (includeOnBoarding)
                {
                    lstEmpStatus.Add("1|HR_EMP_EmpStatus");
                }

                var lstChildOrgId = new HR_OrganizationHelper().GetChildOrgId(notLimitLegal ? Guid.Empty : legalId, orgGuid, true);
                ////HR_EMP_Employee,HR_ORG_Position,HR_ORG_Organization
                var query = (from emp in dbContect.HR_EMP_Employee
                             join emppos in dbContect.HR_EMP_PostInformation on emp.EmployeeID equals emppos.EmployeeID
                             join pos in dbContect.HR_ORG_Position on emppos.PositionID equals pos.PositionID
                             join org in dbContect.HR_ORG_Organization on emppos.OrganizationID equals org.OrganizationID
                             join leg in dbContect.HR_ORG_LegalEntity on org.LegalEntityID equals leg.LegalEntityID
                             join salary in dbContect.HR_EMP_SalaryLevel.Where(s => !s.IsDeleted && !s.IsDisabled) on emp.SalaryLevelID equals salary.SalaryLevelID into salaryClosure
                             from s in salaryClosure.DefaultIfEmpty()
                             join area in dbContect.HR_EMP_OfficeArea on emp.OfficeAreaID equals area.AreaID into tmpArea
                             from area in tmpArea.DefaultIfEmpty()
                             where !emp.IsDeleted && !emppos.IsDeleted && !leg.IsDeleted && !pos.IsDeleted && !org.IsDeleted && emp.TenantID == tenantId && idList.Contains(emp.EmployeeID)
                             select new EmployeeInfo
                {
                    EmployeeID = emp.EmployeeID,
                    EmployeeNameCN = emp.EmployeeNameCN,
                    EmployeeNameEN = emp.EmployeeNameEN,
                    EmployeeNumber = emp.EmployeeNumber,
                    TeleCode = emp.TeleCode,
                    ExtCode = emp.ExtCode,
                    OfficeAreaID = emp.OfficeAreaID,
                    OfficeAreaName = area == null ? string.Empty : area.AreaName,
                    IDType = emp.IDType,
                    IDNumber = emp.IDNumber,
                    PersonalTelNumber = emp.PersonalCellPhone,
                    MainJobPostionID = emp.MainJobPositionID,
                    MainJobPostionName = emp.MainJobPostionName,
                    CurrentJobLevelName = emp.CurrentJobLevelName,
                    FirstWorkedDate = emp.FirstWorkedDate,
                    OnboardDate = emp.OnboardDate,
                    PositionID = pos.PositionID,
                    PositionCode = pos.PositionCode,
                    PositionName = pos.PositionName,
                    OrganizationID = org.OrganizationID,
                    OrganizationCode = org.OrganizationCode,
                    OrganizationName = org.OrganizationName,
                    LegalEntityID = org.LegalEntityID,
                    LegalEntityCode = leg.LegalEntityCode,
                    LegalEntityName = leg.LegalEntityName,
                    LegalEntityTelNumber = leg.TelNumber,
                    IsMain = emppos.IsMain,
                    CreateTime = emp.CreateTime,
                    EmployeeStatus = emp.EmployeeStatus,
                    TrialBeginDate = emp.TrialBeginDate,
                    TrialEndDate = emp.TrialEndDate,
                    EmployeeEMail = emp.EmployeeEMail,
                    Gender = emp.Gender,
                    Birthday = emp.Birthday,
                    MaritalStatus = emp.MaritalStatus,
                    SalaryLevelID = emp.SalaryLevelID,
                    SalaryLevelName = s == null ? String.Empty : s.SalaryLevelName,
                    SalaryLevelType = s.SalaryLevelType
                }).Distinct().ToList();


                if (!notLimitLegal)
                {
                    query = query.Where(t => t.LegalEntityID == legalId).ToList();
                }

                if (!string.IsNullOrEmpty(name))
                {
                    query = query.Where(u => u.EmployeeNameCN.Contains(name)).ToList();
                }

                if (!string.IsNullOrEmpty(userno))
                {
                    query = query.Where(u => u.EmployeeNumber.Contains(userno)).ToList();
                }

                #region "Options"
                var mainPosOnly = false;

                var probationEmpOnly = false;


                if (!string.IsNullOrWhiteSpace(options))
                {
                    var opts = Newtonsoft.Json.JsonConvert.DeserializeObject(options) as dynamic;

                    try
                    {
                        mainPosOnly      = Convert.ToBoolean(opts.mainPosOnly);
                        probationEmpOnly = Convert.ToBoolean(opts.probationEmpOnly);
                    }
                    catch { }
                }

                if (mainPosOnly)
                {
                    query = query.Where(u => u.IsMain).ToList();
                }

                if (probationEmpOnly)
                {
                    query = query.Where(u => u.EmployeeStatus == "6|" + DictConstants.HR_EMP_EmployeeStatus).ToList();
                }

                #endregion

                if (!showSideline)
                {
                    query = query.Where(u => u.IsMain).ToList();
                }
                else
                {
                    query = (from q in query
                             join emp in selectedEmpList on new { empID = q.EmployeeID, posID = q.PositionID } equals new { empID = emp.EmployeeID, posID = (Guid?)emp.PosID }
                             select q).ToList();
                }

                if (showChild)
                {
                    query = query.Where(t => lstChildOrgId.Contains(t.OrganizationID.Value)).ToList();
                }
                else
                {
                    query = query.Where(t => t.OrganizationID == orgGuid).ToList();
                }

                var total   = 0;
                var results = new EmployeeInfo[0];

                query = BizHelper.GetPageQuery(context, query.OrderBy(g => g.CreateTime).AsQueryable(), out total).ToList();

                if (total > 0)
                {
                    results = query.ToArray();

                    foreach (var item in results)
                    {
                        item.Gender        = CommonDictService.GetDictItemName(item.Gender);
                        item.MaritalStatus = CommonDictService.GetDictItemName(item.MaritalStatus);
                        item.IDType        = CommonDictService.GetDictItemName(item.IDType);
                    }

                    #region "Options: Address"
                    var empIDs    = query.Select(p => p.EmployeeID).ToList();
                    var addrDatum = from c in dbContect.HR_EMP_Address.Where(p => !p.IsDeleted && empIDs.Contains(p.EmployeeID))
                                    group c by c.EmployeeID into g
                                    select new
                    {
                        EmployeeID  = g.Key,
                        HomeAddress = g.Where(p => p.AddressType == "0").OrderByDescending(p => p.CreateTime).Select(p => new EmployeeAddress
                        {
                            Country      = p.Country,
                            Province     = p.Province,
                            City         = p.City,
                            District     = p.District,
                            Address      = p.Address,
                            AddressPhone = p.AddressPhone,
                            ZipCode      = p.ZipCode
                        }).FirstOrDefault(),
                        HukouAddress = g.Where(p => p.AddressType == "1").OrderByDescending(p => p.CreateTime).Select(p => new EmployeeAddress
                        {
                            Country      = p.Country,
                            Province     = p.Province,
                            City         = p.City,
                            District     = p.District,
                            Address      = p.Address,
                            AddressPhone = p.AddressPhone,
                            ZipCode      = p.ZipCode
                        }).FirstOrDefault()
                    };

                    foreach (var addr in addrDatum)
                    {
                        var item = results.FirstOrDefault(p => p.EmployeeID == addr.EmployeeID);

                        if (item != null)
                        {
                            item.HomeAddress  = addr.HomeAddress;
                            item.HukouAddress = addr.HukouAddress;
                        }
                    }
                    #endregion
                }

                return(this.Success(results));
                //return this.OK(new { total = total, rows = new List<dynamic> { new {
                //    EmployeeID = "B31E66F4-2E66-4C55-8957-1A50280F9696",
                //    EmployeeNameCN = "赵六",
                //    EmployeeNumber = "123",
                //    IsMain = false
                //} } });
            }
        }
コード例 #33
0
 public override Task Run(BusinessContext <Organisation> context, List <ValidationResult> errors)
 {
     Console.WriteLine("rule run: OrgValidtionDemo2Rule");
     return(Task.CompletedTask);
 }
コード例 #34
0
 protected override void PreCreateInsideTransaction(BusinessContext context)
 {
     base.PreCreateInsideTransaction(context);
 }
コード例 #35
0
 public YoutubeBusiness(BusinessContext context) : base(context)
 {
     _client = new YoutubeClient();
 }
コード例 #36
0
        public static dynamic Search(List <SearchParamModel> searchParams, int pp, int page)
        {
            try
            {
                var dic = new Dictionary <string, string>
                {
                    { "NAME", "C.CONTACT_NAME" },
                    { "ADDRESS", "C.CONTACT_ADDRESS" },
                    { "EMAIL", "C.CONTACT_EMAIL" },
                    { "PHONE", "C.CONTACT_PHONE1" },
                    { "MOBILE", "C.CONTACT_PHONE2" },
                    { "COMPANY", "C.COMPANY_ID" }
                };

                using (var context = new BusinessContext())
                {
                    var           condition = new StringBuilder();
                    StringBuilder condStr;
                    condition.AppendLine("WHERE 1 = 1");
                    searchParams.ForEach(s =>
                    {
                        condStr    = new StringBuilder();
                        var column = dic[s.Key.ToUpper()];
                        switch (s.Key.ToUpper())
                        {
                        case "NAME":
                        case "ADDRESS":
                        case "EMAIL":
                        case "PHONE":
                        case "MOBILE":
                            var valueSet = s.Value.Split(',');
                            foreach (var value in valueSet)
                            {
                                condStr.Append(condStr.Length > 0 ? " OR " : "(");

                                condStr.Append($"{column} LIKE '%{value}%'");
                            }
                            condStr.Append(")");
                            break;

                        case "COMPANY":
                            condStr.Append($"{column} IN ({s.Value})");
                            break;
                        }

                        condition.AppendLine($"AND {condStr}");
                    });
                    var sql =
                        $"SELECT C.*, CO.COMPANY_NAME FROM UR_CONTACT C LEFT JOIN UR_COMPANY CO ON C.COMPANY_ID = CO.COMPANY_ID {condition}";
                    var count       = context.ContactView.FromSql(sql).Count();
                    var contactList = context.ContactView.FromSql(sql).Skip(pp * (page - 1)).Take(pp).ToList();
                    return(new { count, result = contactList });
                }
            }
            catch (Exception e)
            {
                Logger.Info("Contact - Search");
                Logger.Error(e);
                return(null);
            }
        }
コード例 #37
0
 public StudentBusiness(BusinessContext context) : base(context)
 {
 }
コード例 #38
0

        
コード例 #39
0
 public ProveedorViewModel(BusinessContext context)
 {
     this.context     = context;
     this.Proveedores = new ObservableCollection <proveedor>();
 }
コード例 #40
0
        public ActionResult Index()
        {
            BusinessContext businessContext = this.Request.GetOwinContext().Get <BusinessContext>();

            return(View());
        }
コード例 #41
0
ファイル: InvoiceController.cs プロジェクト: manyar98/Zhivar
        public async Task <HttpResponseMessage> StartWorkFlow(WorkFlowBusiClass entity)
        {
            SecurityManager.ThrowIfUserContextNull();
            try
            {
                using (UnitOfWork uow = new UnitOfWork())
                {
                    #region Validate


                    var invoice = BusinessContext.GetBusinessRule <Invoice>(this.BusinessRule.OperationAccess, this.BusinessRule.UnitOfWork)
                                  .Queryable().Where(dr => dr.ID == entity.ID).SingleOrDefault();


                    if (invoice.Status != NoeInsertFactor.Temporary)
                    {
                        throw new OMFValidationException("این فاکتور قبلا ارسال شده است.");
                    }

                    var workFlowQuery = uow.Repository <WorkflowInfo>()
                                        .Queryable()
                                        .Where(wf => wf.Code == entity.Code)
                                        .SingleOrDefault();
                    var workFlowID = workFlowQuery.ID;

                    var instanceQuery = uow.RepositoryAsync <WorkflowInstance>()
                                        .Queryable()
                                        .Where(ins => ins.RelatedRecordId == entity.ID &&
                                               ins.WorkflowInfoId == workFlowID);
                    #endregion

                    //if (vaziatDarkhast == Enums.VaziatDarkhast.SabteDarkhast && !await instanceQuery.Any())
                    //{

                    //   var darkhastRule = new DarkhastRule();

                    //   var validateStartWorkflow = new ValidateStartWorkflow();

                    //     var IsPaymentRequire = await darkhastRule.HasPaymentRequire(entity.NoeDarkhastID);

                    //validateStartWorkflow.Validate(new ValidateData
                    //{
                    //    darkhastID = entity.ID,
                    //    noeDarkhastID = entity.NoeDarkhastID,
                    //    IsPaymentRequire = IsPaymentRequire,
                    //    organID = entity.OrganizationID
                    //});

                    //  var validateExchangeData = new ValidateExchangeData();
                    //entity.ExchangeData = validateExchangeData.CreateExchange(new ValidateExData
                    //{
                    //    RelatedRecordID = entity.ID,
                    //    noeDarkhastID = entity.NoeDarkhastID,
                    //    ExchangeData = entity.ExchangeData,
                    //});

                    dynamic result1;
                    //if (entity.NoeDarkhastID == Enums.NoeDarkhastEnum.ENTEGHAL_SARMAIEH_ZABDARI)
                    //{
                    //    var daroukhanehID = Convert.ToInt32(entity.ExchangeData["daroukhanehShakhsIDDovom"]);
                    //    var organizationID = uow.Repository<Sherkat>().Queryable()
                    //                                  .Where(dr => dr.ID == daroukhanehID)
                    //                                  .SingleOrDefault().OrganID;
                    result1 = await WorkflowManager.StartWorkflowAsync(new WorkflowStartInfo()
                    {
                        Code                  = entity.Code,
                        ExchangeData          = entity.ExchangeData,
                        InstanceTitle         = entity.InstanceTitle,
                        RelatedRecordId       = entity.ID,
                        StarterOrganizationId = entity.OrganizationID,
                        StarterUserId         = SecurityManager.CurrentUserContext.UserId,
                        StartType             = OMF.Workflow.Enums.StartType.Request
                    });

                    if (result1.Code == 1)
                    {
                        var workflowInstance = uow.Repository <WorkflowInstance>().Queryable()
                                               .Where(ins => ins.RelatedRecordId == entity.ID &&
                                                      ins.Status == WfStateStatus.Open
                                                      ).SingleOrDefault();
                        WFExchangeData ex = (WFExchangeData)workflowInstance.InitialExchangeData;

                        ex[WfConstants.StarterOrganizationIdKey] = Convert.ToString(entity.OrganizationID);
                        workflowInstance.InitialExchangeData     = (string)ex;
                        workflowInstance.ObjectState             = ObjectState.Modified;
                        uow.RepositoryAsync <WorkflowInstance>().Update(workflowInstance);
                        await uow.SaveChangesAsync();
                    }



                    if (result1.Code == 1)
                    {
                        InvoiceRule invoiceRule = new InvoiceRule();
                        await invoiceRule.UpdateVaziatInvoice(entity.ID, NoeInsertFactor.waitingForConfirmation);

                        return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)ResultCode.Successful, data = new { records = "" } }));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.InternalServerError, new { resultCode = (int)ResultCode.Exception, data = new { records = "" } }));
                    }
                }
            }
            catch (Exception ex)
            {
                return(await this.HandleExceptionAsync(ex));
            }
        }
コード例 #42
0
        private readonly List <Department> _itemsList = new List <Department>(); // to test linq IEnumerable

        public RepoDepartment(BusinessContext dbContext)
        {
            _dbContext = dbContext;
            //  _itemsList = _dbContext.Departments; // to test linq IQuerable
        }
コード例 #43
0
 public ElectricityBillViewModel(BusinessContext context)
 {
     this.context = context;
 }
コード例 #44
0
ファイル: Order.cs プロジェクト: SebasWW/BusinessFramework
 internal Order(BusinessContext businessManager, DTOrder entry)
     : base(businessManager, entry)
 {
 }
コード例 #45
0
ファイル: UserManager.cs プロジェクト: Inscrutable700/test
 public UserManager(BusinessContext businessContext, RepositoryManager repositoryManager)
     : base(businessContext, repositoryManager)
 {
 }
コード例 #46
0
 /// <summary>
 /// 选择员工对话框
 /// 参数无(根据当前人所属的法人得到当前组织机构)
 /// 返回数据(userId,userName)
 /// {userId:'B31E66F4-2E66-4C55-8957-1A50280F9696',userName:'******'}
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public BusinessResult EmployeeView(BusinessContext context)
 {
     return(this.View(@"Enterprise\HR\Common\_fmSelectUser.cshtml", new { Context = context, BizId = this.ViewModel.Model.BizId }));
 }
コード例 #47
0
        protected override void InitializeEntity(BusinessContext context)
        {
            base.InitializeEntity(context);

            ((WorkflowDefinitionEntity)((InitializeEntityResponse)context.Response).EntityObject).Xaml = McWorkflowSerializer.GetString(new SequentialWorkflowActivity());
        }
コード例 #48
0

        
コード例 #49
0
 public RSDetails(BusinessContext Context)
 {
     _Context = Context;
 }
コード例 #50
0
 public WaterBillViewModel(BusinessContext context)
 {
     this.context = context;
 }
コード例 #51
0
        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        void IPlugin.Execute(BusinessContext context)
        {
            this.Context = context;

            this.Execute(context);
        }
コード例 #52
0
 protected abstract IQueryable <TEntry> OnReadSecure(BusinessContext context, IQueryable <TEntry> query);
コード例 #53
0
 public ManagerBase(RepositoryContext repositoryContext, BusinessContext businessContext)
 {
     this.repositoryContext = repositoryContext;
     this.businessContext   = businessContext;
 }
コード例 #54
0
 internal IQueryable <TEntry> ReadSecure(BusinessContext context, IQueryable <TEntry> query)
 {
     return(OnReadSecure(context, query));
 }
コード例 #55
0
 public Type3ClassifiersRepository(BusinessContext context)
 {
     _context = context;
 }