Example #1
0
        public override void LoadDucValue(BaseDto subjectInstance)
        {
            object  value       = base.LoadDucOriginalValue(subjectInstance);
            decimal?numberValue = null;

            if (value != null)
            {
                numberValue = Convert.ToDecimal(value);
            }

            switch (LoadMode)
            {
            case SubjectLoadMode.DetailMode:
                lblNumber.Visible = true;
                if (numberValue.HasValue)
                {
                    lblNumber.Text = numberValue.ToString();
                }
                break;

            case SubjectLoadMode.EditMode:
                tdInput.Visible = true;
                if (numberValue.HasValue)
                {
                    txtNumber.Text = numberValue.ToString();
                }
                txtNumber.Enabled = !SubjectField.IsReadonly;
                lblMark.Visible   = SubjectField.IsRequired;
                break;

            default:
                break;
            }
        }
 private static void BuildContentEntity(ContentEntitySlim entity, BaseDto dto)
 {
     BuildEntity(entity, dto);
     entity.ContentTypeAlias     = dto.Alias;
     entity.ContentTypeIcon      = dto.Icon;
     entity.ContentTypeThumbnail = dto.Thumbnail;
 }
Example #3
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <returns></returns>
 public async Task DeleteProxy(BaseDto input)
 {
     if (input.Id.HasValue)
     {
         await _proxyRepository.DeleteAsync(input.Id.Value);
     }
 }
Example #4
0
        public override void LoadDucValue(BaseDto subjectInstance)
        {
            object value = base.LoadDucOriginalValue(subjectInstance);

            switch (LoadMode)
            {
            case SubjectLoadMode.DetailMode:
                lblDate.Visible = true;
                if (value != null)
                {
                    DateTime dateValue = Convert.ToDateTime(value);
                    lblDate.Text = dateValue.ToString(UIConst.DateFormat);
                }
                break;

            case SubjectLoadMode.EditMode:
                tdInput.Visible = true;
                if (value != null)
                {
                    DateTime dateValue = Convert.ToDateTime(value);
                    deDate.SelectedDate = dateValue;
                }
                deDate.Enabled  = !SubjectField.IsReadonly;
                lblMark.Visible = SubjectField.IsRequired;
                break;

            default:
                break;
            }
        }
Example #5
0
 protected void UpdateAuditInformation(BaseDto model)
 {
     model.CreatedDate    = model.CreatedDate == DateTime.MinValue ? DateTime.Now : model.CreatedDate;
     model.CreatedBy      = string.IsNullOrEmpty(model.CreatedBy) ? CurrentUserName : model.CreatedBy;
     model.LastModifiedBy = CurrentUserEmail;
     model.LastModifiedOn = DateTime.Now;
 }
Example #6
0
 public void DispatchToMainThread(ParamDtoDelegate call, BaseDto dto)
 {
     MainThreadEvent evt = new MainThreadEvent();
     evt.dtoCallFuncEvents += call;
     evt.dto = dto;
     this.DispatchToMainThread(evt);
 }
        public override void LoadDucValue(BaseDto subjectInstance)
        {
            LoadDDL();

            object value = base.LoadDucOriginalValue(subjectInstance);

            if (value != null && value is int)
            {
                ddlPickup.SelectedValue = value.ToString();
            }

            switch (LoadMode)
            {
            case SubjectLoadMode.DetailMode:
                lblPickup.Visible = true;
                if (ddlPickup.SelectedItem != null)
                {
                    lblPickup.Text = ddlPickup.SelectedItem.Text;
                }
                break;

            case SubjectLoadMode.EditMode:
                tdInput.Visible   = true;
                ddlPickup.Enabled = !SubjectField.IsReadonly;
                lblMark.Visible   = SubjectField.IsRequired;
                break;

            default:
                break;
            }
        }
        WallPost GetSingleNewsfeedInternal(int id)
        {
            NewsfeedRequest request = new NewsfeedRequest()
            {
                RequestType = RequestType.GetSingle,
                Id          = id
            };

            BaseDto bDto = new BaseDto {
                Type       = DtoType.Newsfeed,
                JsonObject = JsonConvert.SerializeObject(request)
            };
            string result = _remoteConnection.Request(bDto);

            if (String.IsNullOrEmpty(result))
            {
                Log.Error(Tag, "GetSingleWallpost error result is null");
                return(null);
            }

            NewsfeedDto dto = JsonConvert.DeserializeObject <NewsfeedDto>(result);

            if (dto == null)
            {
                Log.Error(Tag, String.Format("Could not parse newsfeeddto {0}", result));
                return(null);
            }

            WallPost post = Mapper.Map <NewsfeedDto, WallPost>(dto);

            return(post);
        }
        public void PostSingleNewsfeed(WallPost post)
        {
            new Thread(() => {
                NewsfeedDto dto = Mapper.Map <WallPost, NewsfeedDto>(post);

                NewsfeedRequest request = new NewsfeedRequest()
                {
                    RequestType = RequestType.PostSingle,
                    SingleDto   = dto,
                    Token       = "123498"
                                  //Token = _privateRepo.GetLocalUser().Token
                };

                BaseDto bDto = new BaseDto {
                    Type       = DtoType.Newsfeed,
                    JsonObject = JsonConvert.SerializeObject(request)
                };
                string result = _remoteConnection.Request(bDto);
                if (String.IsNullOrEmpty(result))
                {
                    Log.Error(Tag, "GetSingleWallpost error result is null");
                    return;
                }

                var resultObject = JsonConvert.DeserializeObject <NewsfeedDto>(result);

                if (resultObject.Error != null)
                {
                    Log.Error(Tag, resultObject.Error.Message);
                }
            }).Start();
        }
Example #10
0
        public void UpdateRelativityObject <T>(BaseDto theObjectToUpdate)
            where T : BaseDto, new()
        {
            RDO rdo = theObjectToUpdate.ToRdo();

            UpdateRdo(rdo);
            InsertUpdateFileField(theObjectToUpdate, theObjectToUpdate.ArtifactId);

            Dictionary <PropertyInfo, RelativityObjectChildrenListAttribute> childObjectsInfo = BaseDto.GetRelativityObjectChildrenListInfos <T>();

            if (childObjectsInfo.Count != 0)
            {
                foreach (var childPropertyInfo in childObjectsInfo)
                {
                    var propertyInfo      = childPropertyInfo.Key;
                    var theChildAttribute = childPropertyInfo.Value;

                    Type childType = childPropertyInfo.Value.ChildType;

                    var childObjectsList = childPropertyInfo.Key.GetValue(theObjectToUpdate, null) as IList;

                    if (childObjectsList != null && childObjectsList.Count != 0)
                    {
                        MethodInfo method = GetType().GetMethod("UpdateChildListObjects", BindingFlags.NonPublic | BindingFlags.Instance).MakeGenericMethod(new Type[] { childType });

                        method.Invoke(this, new object[] { childObjectsList, theObjectToUpdate.ArtifactId });
                    }
                }
            }
        }
        public void GetAllNewsfeeds()
        {
            new Thread(() => {
                NewsfeedRequest request = new NewsfeedRequest()
                {
                    RequestType = RequestType.GetAll
                };

                BaseDto bDto = new BaseDto {
                    Type       = DtoType.Newsfeed,
                    JsonObject = JsonConvert.SerializeObject(request)
                };

                string result = _remoteConnection.Request(bDto);

                if (String.IsNullOrEmpty(result))
                {
                    Log.Error(Tag, "GetAllWallposts error result is null");
                    return;
                }

                var arrayMessage = JsonConvert.DeserializeObject <ArrayMessage>(result);
                var tempItemList = new List <WallPost>();
                foreach (var id in arrayMessage.Ids)
                {
                    var convertedWallPost = GetSingleNewsfeedInternal(id);
                    if (convertedWallPost != null)
                    {
                        tempItemList.Add(convertedWallPost);
                    }
                }
                _newsfeedRepo.AddWallPosts(tempItemList);
                OnUpdate(this, null);
            }).Start();
        }
Example #12
0
        public async Task <UserDto> getUserInitial(BaseDto BaseDto)
        {
            var oUserDto = new UserDto();

            oUserDto.isItemAdmin = false;
            oUserDto.isDataAdmin = false;
            oUserDto.isActive    = true;


            var oAccessgroups = await _Accessgroups
                                .Where(x => x.ownerCompanyId == BaseDto.companyId)
                                .OrderBy(x => x.groupName).ToListAsync();

            foreach (var oAccessgroup in oAccessgroups)
            {
                var oAccessgroupDto = new AccessgroupDto
                {
                    groupName    = oAccessgroup.groupName,
                    id           = oAccessgroup.id,
                    isChecked    = false,
                    menuItemsDto = null,
                };

                oUserDto.accessgroupsDto.Add(oAccessgroupDto);
            }

            return(oUserDto);
        }
        public async Task <GetNegotiationplanrouteDto> getNegotiationplanroute(BaseDto baseDto)
        {
            GetNegotiationplanrouteDto oNegotiationplanrouteDto = Mapper.Map <Negotiationplanroute, GetNegotiationplanrouteDto>(
                await _Negotiationplanroutes.AsNoTracking().SingleOrDefaultAsync(i => i.id == baseDto.id));

            return(await fillDdl(oNegotiationplanrouteDto));
        }
Example #14
0
        private async Task <List <AccessgroupDto> > getAccessgroups(BaseDto baseDto)
        {
            var oAccessgroups = await _Accessgroups
                                .AsNoTracking()
                                .Where(x => x.ownerCompanyId == baseDto.companyId)
                                .OrderBy(x => x.groupName)
                                .ToListAsync();

            var oAccessgroupsDto = new List <AccessgroupDto>();


            foreach (var oAccessgroup in oAccessgroups)
            {
                var oAccessgroupDto = new AccessgroupDto();
                oAccessgroupDto.id        = oAccessgroup.id;
                oAccessgroupDto.groupName = oAccessgroup.groupName;


                var oAccessgroupUser = await _AccessgroupUsers
                                       .SingleOrDefaultAsync(x =>
                                                             x.userId == baseDto.userId &&
                                                             x.accessgroupId == oAccessgroup.id);

                if (oAccessgroupUser != null)
                {
                    oAccessgroupDto.isChecked = true;
                }



                oAccessgroupsDto.Add(oAccessgroupDto);
            }

            return(oAccessgroupsDto);
        }
        public void GetSingleNewsfeed(int id)
        {
            new Thread(() => {
                NewsfeedRequest request = new NewsfeedRequest()
                {
                    RequestType = RequestType.GetSingle,
                    Id          = id
                };

                BaseDto bDto = new BaseDto {
                    Type       = DtoType.Newsfeed,
                    JsonObject = JsonConvert.SerializeObject(request)
                };
                string result = _remoteConnection.Request(bDto);
                if (String.IsNullOrEmpty(result))
                {
                    Log.Error(Tag, "GetSingleWallpost error result is null");
                    return;
                }

                NewsfeedDto dto = JsonConvert.DeserializeObject <NewsfeedDto>(result);

                if (dto == null)
                {
                    Log.Error(Tag, String.Format("Could not parse newsfeeddto {0}", result));
                    return;
                }

                WallPost post = Mapper.Map <NewsfeedDto, WallPost>(dto);

                _newsfeedRepo.AddWallPosts(new List <WallPost>(new [] { post }));
                OnUpdate(this, null);
            }).Start();
        }
Example #16
0
 public virtual void DoNative(BaseDto dto)
 {
     DebugTool.Log("[AbstractBaseAction.DoNative]\n" +
                      "Send: " + dto.resposeJSON.SendDataJosn + "\n" +
                      "Receive: " + dto.resposeJSON.RecdDataJosn);
     //dto.resposeJSON.AddRecv(BaseConst.RET_VAL, BaseConst.RET_VAL_NONE);
 }
Example #17
0
        public override void LoadDucValue(BaseDto subjectInstance)
        {
            object value     = base.LoadDucOriginalValue(subjectInstance);
            string textValue = string.Empty;

            if (value != null)
            {
                textValue = value.ToString();
            }

            switch (LoadMode)
            {
            case SubjectLoadMode.DetailMode:
                lblPhone.Visible = true;
                lblPhone.Text    = textValue;
                break;

            case SubjectLoadMode.EditMode:
                tdInput.Visible  = true;
                txtPhone.Text    = textValue;
                txtPhone.Enabled = !SubjectField.IsReadonly;
                lblMark.Visible  = SubjectField.IsRequired;
                break;

            default:
                break;
            }
        }
Example #18
0
 /// <summary>
 ///     .ctor
 /// </summary>
 /// <param name="dto"></param>
 public BaseViewModel(BaseDto dto)
 {
     EntityId         = dto.EntityId;
     CreatedDate      = dto.CreatedDate;
     LastModifiedDate = dto.LastModifiedDate;
     IsDeleted        = dto.IsDeleted;
 }
Example #19
0
        protected TEntity ToEntity <TEntity>(BaseDto dto)
        {
            var entity = Activator.CreateInstance <TEntity>();

            AutoMapper.CopyPropertyValues(dto, entity);
            return(entity);
        }
Example #20
0
        protected void ToEntityAndAddToList <TEntity, TListItem, TDto>(BaseDto dto, ObservableCollection <TListItem> list, Func <TDto, BaseDto> dtoSelector = null, bool addToEnd = true)
            where TDto : BaseDto
            where TEntity : TListItem
        {
            if (!(dto is TDto))
            {
                return;
            }

            if (dtoSelector == null)
            {
                dtoSelector = d => d;
            }

            var entity = ToEntity <TEntity>(dtoSelector((TDto)dto));

            if (addToEnd)
            {
                list.Add(entity);
            }
            else
            {
                list.Insert(0, entity);
            }
        }
Example #21
0
        protected List <RDO> GetRdos <T>(Condition queryCondition = null)
            where T : BaseDto
        {
            Query <RDO> query = new Query <RDO>()
            {
                ArtifactTypeGuid = BaseDto.GetObjectTypeGuid <T>(),
                Condition        = queryCondition
            };

            query.Fields = FieldValue.AllFields;

            QueryResultSet <RDO> results;

            using (IRSAPIClient proxyToWorkspace = CreateProxy())
            {
                try
                {
                    results = invokeWithRetryService.InvokeWithRetry(() => proxyToWorkspace.Repositories.RDO.Query(query));
                }
                catch (Exception ex)
                {
                    throw new ProxyOperationFailedException("Failed in method: " + System.Reflection.MethodInfo.GetCurrentMethod(), ex);
                }
            }

            if (results.Success == false)
            {
                throw new ArgumentException(results.Message);
            }

            return(results.Results.Select <Result <RDO>, RDO>(result => result.Artifact as RDO).ToList());
        }
        private IReferenceEditor CreateReferenceEditor(BaseDto dto, PropertyInfo propertyInfo)
        {
            ReferenceEdirorAttribute editorAttribute = (ReferenceEdirorAttribute)propertyInfo.GetCustomAttribute(typeof(ReferenceEdirorAttribute));
            Type baseReferenceType = typeof(BaseReferenceEditor <>).MakeGenericType(dto.GetType());

            return((IReferenceEditor)Activator.CreateInstance(Type.GetType(editorAttribute.CompleteAssembly), new object[] { dto }));
        }
Example #23
0
        public override void LoadDucValue(BaseDto subjectInstance)
        {
            switch (LoadMode)
            {
            case SubjectLoadMode.DetailMode:
                hlAttachment.Visible = true;
                object value = ReflectionHelper.GetValue(subjectInstance, UIConst.FLD_LinkText);
                if (value != null)
                {
                    hlAttachment.Text = value.ToString();
                }
                if (!string.IsNullOrEmpty(SubjectField.NavigateUrlFormatString))
                {
                    hlAttachment.NavigateUrl = ServerPath + string.Format(SubjectField.NavigateUrlFormatString, subjectInstance.Id);
                }
                break;

            case SubjectLoadMode.EditMode:
                tdInput.Visible          = true;
                uploadAttachment.Enabled = !SubjectField.IsReadonly;
                lblMark.Visible          = SubjectField.IsRequired;
                break;

            default:
                break;
            }
        }
Example #24
0
        internal void InsertChildListObjects <T>(IList <T> objectsToInserted, int parentArtifactId)
            where T : BaseDto
        {
            var childObjectsInfo = BaseDto.GetRelativityObjectChildrenListProperties <T>();

            bool isFilePropertyPresent = typeof(T).GetProperties().ToList().Any(c => c.DeclaringType.IsAssignableFrom(typeof(RelativityFile)));

            if (childObjectsInfo.Any() || isFilePropertyPresent)
            {
                foreach (var objectToBeInserted in objectsToInserted)
                {
                    SetParentArtifactID(objectToBeInserted, parentArtifactId);
                    int insertedRdoArtifactID = InsertRdo(objectToBeInserted.ToRdo());
                    InsertUpdateFileFields(objectToBeInserted, insertedRdoArtifactID);

                    foreach (var childPropertyInfo in childObjectsInfo)
                    {
                        InsertChildListObjectsWithDynamicType(objectToBeInserted, insertedRdoArtifactID, childPropertyInfo);
                    }
                }
            }
            else
            {
                foreach (var objectToBeInserted in objectsToInserted)
                {
                    SetParentArtifactID(objectToBeInserted, parentArtifactId);
                }

                var rdosToBeInserted = objectsToInserted.Select(x => x.ToRdo()).ToArray();

                rsapiProvider.Create(rdosToBeInserted);
            }
        }
        public void Initialise(BaseDto configuration, DictionaryParameters parameters)
        {
            Contract.Assert(configuration is ScheduledJobsWorkerConfiguration);
            
            parameters = parameters ?? new DictionaryParameters();

            var cfg = configuration as ScheduledJobsWorkerConfiguration;

            // get communication update and retry variables
            cfg.UpdateIntervalInMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["UpdateIntervalMinutes"]);
            cfg.UpdateIntervalInMinutes = 
                (0 != cfg.UpdateIntervalInMinutes) ? 
                cfg.UpdateIntervalInMinutes : 
                ScheduledJobsWorkerConfiguration.UPDATE_INTERVAL_IN_MINUTES_DEFAULT;

            cfg.ServerNotReachableRetries = Convert.ToInt32(ConfigurationManager.AppSettings["ServerNotReachableRetries"]);
            cfg.ServerNotReachableRetries = 
                cfg.UpdateIntervalInMinutes * (0 != cfg.ServerNotReachableRetries ?
                cfg.ServerNotReachableRetries : 
                ScheduledJobsWorkerConfiguration.SERVER_NOT_REACHABLE_RETRIES_DEFAULT);

            // apply parameters if overridden on command line
            var uri = ConfigurationManager.AppSettings["Uri"];
            if(parameters.ContainsKey("args0"))
            {
                uri = parameters["args0"] as string;
            }
            Contract.Assert(!string.IsNullOrWhiteSpace(uri));
            cfg.Uri = new Uri(uri);

            cfg.ManagementUriName = ConfigurationManager.AppSettings["ManagementUri"];
            if(parameters.ContainsKey("args1"))
            {
                cfg.ManagementUriName = parameters["args1"] as string;
            }
            Contract.Assert(!string.IsNullOrWhiteSpace(cfg.ManagementUriName));

            // load plugins
            var configurationLoader = new PluginLoaderConfigurationFromAppSettingsLoader();
            var pluginLoader = new PluginLoader(configurationLoader, cfg.Logger);
            cfg.Plugins = pluginLoader.InitialiseAndLoad();
            Contract.Assert(0 < cfg.Plugins.Count, "No plugins loaded. Cannot continue.");

            // get credentials to connect to Appclusive HOST server
            var credentialSection = ConfigurationManager.GetSection(AppclusiveCredentialSection.SECTION_NAME) as AppclusiveCredentialSection;
            if(null == credentialSection)
            {
                Trace.WriteLine("No credential in app.config section '{0}' defined. Using 'DefaultNetworkCredentials'.", AppclusiveCredentialSection.SECTION_NAME, "");
                
                cfg.Credential = CredentialCache.DefaultNetworkCredentials;
            }
            else
            {
                Trace.WriteLine("Credential in app.config section '{0}' found. Using '{1}\\{2}'.", AppclusiveCredentialSection.SECTION_NAME, credentialSection.Domain, credentialSection.Username);

                var networkCredential = new NetworkCredential(credentialSection.Username, credentialSection.Password, credentialSection.Domain);
                Contract.Assert(null != networkCredential);
                cfg.Credential = networkCredential;
            }
        }
        public override void Parse(BaseResult result, BaseDto dto)
        {
            if (result != null)
            {
                var adRegisterDTO = (AdRegisterDTO)dto;

                var addressResult = (AdResult)result;

                adRegisterDTO.id             = addressResult.id;
                adRegisterDTO.Name.Value     = addressResult.Name;
                adRegisterDTO.Brand.Value    = addressResult.Brand;
                adRegisterDTO.Option.Value   = addressResult.Option;
                adRegisterDTO.Price.Value    = addressResult.Price;
                adRegisterDTO.Quantity.Value = addressResult.Quantity;
                adRegisterDTO.idAddress      = addressResult.idAddress;
                adRegisterDTO.Guid           = addressResult.Guid;

                adRegisterDTO.Status     = (AD_STATUS)addressResult.idStatus;
                adRegisterDTO.StatusName = addressResult.StatusName;

                adRegisterDTO.Type = (AD_TYPE)addressResult.idType;

                adRegisterDTO.idOwner     = addressResult.idOwner;
                adRegisterDTO.ViewContact = addressResult.ViewContact;

                adRegisterDTO.Created = addressResult.Created;
            }
        }
Example #27
0
        private bool InsertMultipleObjectFields(BaseDto objectToInsert)
        {
            foreach (var propertyInfo in objectToInsert.GetType().GetProperties().Where(c =>
                                                                                        c.GetCustomAttribute <RelativityObjectFieldAttribute>()?.FieldType == RdoFieldType.MultipleObject))
            {
                var fieldGuid = propertyInfo.GetCustomAttribute <RelativityObjectFieldAttribute>()?.FieldGuid;
                if (fieldGuid == null)
                {
                    continue;
                }

                IEnumerable <object> fieldValue = (IEnumerable <object>)objectToInsert.GetPropertyValue(propertyInfo.Name);
                if (fieldValue == null)
                {
                    continue;
                }

                foreach (var childObject in fieldValue)
                {
                    //TODO: better test to see if contains value...if all fields are null, not need
                    if (((childObject as BaseDto).ArtifactId == 0))
                    {
                        Type objType       = childObject.GetType();
                        var  newArtifactId = this.InvokeGenericMethod(objType, nameof(Insert), childObject);
                        (childObject as BaseDto).ArtifactId = (int)newArtifactId;
                    }
                    else
                    {
                        //TODO: Consider update if fields have changed
                    }
                }
            }
            return(true);
        }
        /// <summary>
        /// 动态查询
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public override PageResponse GetList(BaseDto basedto)
        {
            PageResponse response = new PageResponse();
            var          dto      = (NavigationRoleDto)basedto;
            var          query    = base.Table.AsQueryable();

            //条件查询
            if (!string.IsNullOrEmpty(dto.NId))
            {
                query = query.Where(p => p.NId == dto.NId);
            }
            if (dto.Status.HasValue)
            {
                query = query.Where(p => p.Status == dto.Status);
            }
            response.total = query.Count();
            if (query.Count() > 0)
            {
                if (dto.pageIndex.HasValue && dto.pageSize.HasValue)
                {
                    query = query.Skip((dto.pageIndex.Value - 1) * dto.pageSize.Value).Take(dto.pageSize.Value);
                }
                //根据参数进行排序
                //query = query.OrderBy(p => p.Sort);
            }
            response.status = 0;
            response.code   = StatusCodeDefine.Success;
            response.data   = query.ToList();
            return(response);
        }
Example #29
0
 public static void ResetProperty(BaseDto dto)
 {
     foreach (var prop in dto.Properties)
     {
         prop.Reset();
     }
 }
Example #30
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <returns></returns>
 public async Task DeleteSpiderTask(BaseDto input)
 {
     if (input.Id.HasValue)
     {
         await _spiderRepository.DeleteAsync(input.Id.Value);
     }
 }
Example #31
0
        /// <summary>
        /// 动态查询
        /// </summary>
        /// <param name="basedto"></param>
        /// <returns></returns>
        public override PageResponse GetList(BaseDto basedto)
        {
            PageResponse response = new PageResponse();
            var          dto      = (ManagerDto)basedto;
            var          query    = base.Table.AsQueryable();

            //条件查询
            if (!string.IsNullOrEmpty(dto.Email))
            {
                query = query.Where(p => p.Email.Contains(dto.Email));
            }
            if (!string.IsNullOrEmpty(dto.UserName))
            {
                query = query.Where(p => p.UserName.Contains(dto.UserName));
            }
            if (!string.IsNullOrEmpty(dto.Mobile))
            {
                query = query.Where(p => p.Mobile.Contains(dto.Mobile));
            }
            response.total = query.Count();
            if (query.Count() > 0)
            {
                if (dto.pageIndex.HasValue && dto.pageSize.HasValue)
                {
                    query = query.Skip((dto.pageIndex.Value - 1) * dto.pageSize.Value).Take(dto.pageSize.Value);
                }
                //根据参数进行排序
                //query = query.OrderBy(p => p.Sort);
            }
            response.status = 0;
            response.code   = StatusCodeDefine.Success;
            response.data   = query.ToList();
            return(response);
        }
Example #32
0
        public IActionResult CheckItem([FromBody] BaseDto user, int itemId)
        {
            string unprotectedId;

            try
            {
                unprotectedId = _protector.Unprotect(user.Credential);
            }
            catch (CryptographicException)
            {
                return(Unauthorized());
            }

            var userId        = int.Parse(unprotectedId);
            var projectsUsers = _projectUsersRepository
                                .GetAll(p => p.UserId == userId && p.IsAccepted)
                                .AsNoTracking();
            var checkingItem = _repository.GetAll(i => i.Id == itemId).First();

            // User is modifying the item, which is not owned by him.
            if (!ToDoItemsHelper.IsItemOwnedByUser(_repository, checkingItem, userId, projectsUsers))
            {
                return(NotFound());
            }

            checkingItem.CompleteDate = DateTime.UtcNow;

            _repository.Edit(checkingItem);

            return(Ok());
        }
Example #33
0
        /// <summary>
        ///  ExecuteInsertAsync
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sender"></param>
        /// <returns></returns>
        public async Task ExecuteInsertAsync <T>(object sender) where T : class
        {
            IEnumerable <DtoType> dtoValues = sender as IEnumerable <DtoType>;
            var retValue = false;

            try
            {
                if (dtoValues != null)
                {
                    var newItems = dtoValues.Where(x =>
                    {
                        BaseDto baseDto = x as BaseDto;
                        return(baseDto.IsNew == true);
                    }
                                                   );
                    if (newItems.Count() > 0)
                    {
                        retValue = await _helperDataServices.ExecuteBulkInsertAsync <DtoType, T>(newItems).ConfigureAwait(false);
                    }
                }
            } catch (Exception ex)
            {
                throw new DataLayerException(ex.Message, ex);
            }
        }
        protected override void OnUnknownDtoReceived(BaseDto dto)
        {
            var playerProfileChanges = dto as UserPropertiesChangedInfo;
            if (playerProfileChanges != null)
            {
                UpdatePropertiesForList(Friends, p => p.Id == playerProfileChanges.UserId, playerProfileChanges.Properties);
            }

            base.OnUnknownDtoReceived(dto);
        }
Example #35
0
        protected override void OnUnknownDtoReceived(BaseDto dto)
        {
            var userPropertiesChangedInfo = dto as UserPropertiesChangedInfo;
            if (userPropertiesChangedInfo != null)
            {
                UpdatePropertiesForList(_blacklistSubject, p => p.Id == userPropertiesChangedInfo.UserId, userPropertiesChangedInfo.Properties);
            }

            base.OnUnknownDtoReceived(dto);
        }
Example #36
0
        /// <summary>
        /// ���շ�������Ϣ
        /// </summary>
        /// <param name="respData"></param>
        public virtual void DoProcess(BaseDto dto)
        {
            JSONObject json = dto.resposeJSON;
            if (json.RecdHasKey(BaseConst.NOW_SERVER_TIME))
            {
                BaseData.preServerDateTime = BaseData.nowServerDateTime;
                DateTime preClientDateTime = BaseData.nowClientDateTime;
                BaseData.nowServerTime = json.GetRecd<string>(BaseConst.NOW_SERVER_TIME);
                BaseData.nowServerDateTime = CommonUtils.DateParse(BaseData.nowServerTime);
                BaseData.nowClientDateTime = DateTime.Now;
                double serverTotalSeconds = BaseData.nowServerDateTime.Subtract(BaseData.preServerDateTime).TotalSeconds;
                double clientTotalSeconds = BaseData.nowClientDateTime.Subtract(preClientDateTime).TotalSeconds;
                if (BaseData.initDateTime)
                {
                    double diffSeconds = Math.Abs(serverTotalSeconds - clientTotalSeconds);
                    if (diffSeconds > 3000)
                    {
                        // this.actionMgr.client.timeWrong = true;
                        // TODO �ͻ���������ʾ�رճ���
                        // this.actionMgr.client.DispatchEvent(YxEventType.TIME_WRONG, null);
                    }
                }
                else
                {
                    BaseData.startServerDateTime = BaseData.nowServerDateTime;
                    BaseData.preChkDayServerDateTime = BaseData.nowServerDateTime;
                }
                BaseData.initDateTime = true;
            }
            string retMsg = json.GetRecd<string>(BaseConst.RET_VAL);
            dto.retType = json.GetRecd<int>(BaseConst.RET_TYPE);
            switch (retMsg)
            {
                case BaseConst.RET_VAL_SUCC:
                    this.DoSuccess(dto);
                    break;
                case BaseConst.RET_VAL_FAIL:
                    this.DoFail(dto);
                    break;
                case BaseConst.RET_VAL_NATIVE:
                    this.DoNative(dto);
                    break;
                default:
                    break;
            }
            dto.ExecuteNetResponseCallback();
            dto.ExecuteUICallback();

            if (this.doProcessEnd != null)
            {
                this.client.DispatchToMainThread(this.doProcessEnd, dto);
            }
        }
        public void Initialise(BaseDto configuration, DictionaryParameters parameters)
        {
            Contract.Assert(configuration is PluginLoaderConfiguration);

            var cfg = configuration as PluginLoaderConfiguration;

            // 1. Get folder from where to load extensions
            var extensionsFolder = ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.EXTENSIONS_FOLDER];
            if (!Path.IsPathRooted(extensionsFolder))
            {
                extensionsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, extensionsFolder);
            }
            Contract.Assert(Directory.Exists(extensionsFolder), extensionsFolder);

            cfg.ExtensionsFolder = extensionsFolder;

            // 2. Load plugin names to be loaded
            var pluginTypes = ConfigurationManager.AppSettings[SchedulerAppSettings.Keys.PLUGIN_TYPES];
            
            if(string.IsNullOrWhiteSpace(pluginTypes))
            {
                pluginTypes = biz.dfch.CS.Appclusive.Scheduler.Public.Constants.PLUGIN_TYPE_DEFAULT;
            }

            var pluginTypesToBeLoaded = pluginTypes
                .ToLower()
                .Split(',')
                .Distinct()
                .OrderBy(p => p)
                .ToList();
            Contract.Assert(0 < pluginTypesToBeLoaded.Count());
            
            if(pluginTypesToBeLoaded.Contains(PluginLoader.LOAD_ALL_PATTERN))
            {
                pluginTypesToBeLoaded.Clear();
                pluginTypesToBeLoaded.Add(PluginLoader.LOAD_ALL_PATTERN);
            }
            cfg.PluginTypes = pluginTypesToBeLoaded;

            Trace.WriteLine("SchedulerPluginLoader. ExtensionsFolder: '{0}' (validated). PluginTypes '{1}' (normalised).", cfg.ExtensionsFolder, string.Join(", ", cfg.PluginTypes));
        }
Example #38
0
 public virtual void DoSuccess(BaseDto dto)
 {
 }
Example #39
0
 public void RemoveEventListener(BaseDto dto)
 {
     if (dto != null && this.dtoEventDict.ContainsKey(dto.requestId))
     {
         this.dtoEventDict.Remove(dto.requestId);
     }
 }
Example #40
0
 public void AddEventListener(long evtId, BaseDto dto)
 {
     this.dtoEventDict[evtId] = dto;
 }
Example #41
0
 public void AddEventListener(BaseDto dto)
 {
     this.dtoEventDict[dto.requestId] = dto;
 }
Example #42
0
        protected override void OnUnknownDtoReceived(BaseDto dto)
        {
            //TODO: REPLACE WITH REACTIVE EXTENSIONS!

            //messages:
            ToEntityAndAddToList<BanNotificationEvent, Event, BanNotification>(dto, _messagesSubject);
            ToEntityAndAddToList<TextMessage, Event, PublicMessageDto>(dto, _messagesSubject);
            ToEntityAndAddToList<DevoiceNotificationEvent, Event, DevoiceNotification>(dto, _messagesSubject);
            ToEntityAndAddToList<GrantedModershipNotificationEvent, Event, ModershipGrantedInfo>(dto, _messagesSubject);
            ToEntityAndAddToList<RemovedModershipNotificationEvent, Event, ModershipRemovedInfo>(dto, _messagesSubject);

            //users
            ToEntityAndAddToList<User, UserDto>(dto, _onlinePlayersSubject);
            ToEntityAndAddToList<User, JoinedUserInfo>(dto, _onlinePlayersSubject, d => d.User);

            //special case (remove User):
            var leftUserInfo = dto as LeftUserInfo;
            if (leftUserInfo != null)
                RemoveEntityFromList(_onlinePlayersSubject, i => i.Id == leftUserInfo.UserId);

            var playerProfileChanges = dto as UserPropertiesChangedInfo;
            if (playerProfileChanges != null)
            {
                UpdatePropertiesForList(_onlinePlayersSubject, p => p.Id == playerProfileChanges.UserId, playerProfileChanges.Properties);
            }

            //update property IsDevoiced for players
            var devoiceNotification = dto as DevoiceNotification;
            if (devoiceNotification != null)
            {
                using (OnlineUsers.EnterSafetyRead())
                {
                    var user = OnlineUsers.FirstOrDefault(i => i.Id == devoiceNotification.TargetId);
                    if (user != null)
                        user.IsDevoiced = devoiceNotification.Devoice;
                }
            }

            var youAreDevoicedNotification = dto as YouAreDevoicedNotification;
            if (youAreDevoicedNotification != null)
            {
                _notificationService.ShowYouAreDevoicedMessage();
            }
        }
Example #43
0
 public virtual void DoFail(BaseDto dto)
 {
     DebugTool.LogWarning("[AbstractBaseAction.DoFail]\n" +
                      "Send: " + dto.resposeJSON.SendDataJosn + "\n" +
                      "Receive: " + dto.resposeJSON.RecdDataJosn);
 }
Example #44
0
        protected override void OnUnknownDtoReceived(BaseDto dto)
        {
            //messages:
            ToEntityAndAddToList<BanNotificationEvent, Event, BanNotification>(dto, Messages, null, false);
            ToEntityAndAddToList<TextMessage, Event, PublicMessageDto>(dto, Messages, null, false);
            ToEntityAndAddToList<DevoiceNotificationEvent, Event, DevoiceNotification>(dto, Messages, null, false);
            ToEntityAndAddToList<GrantedModershipNotificationEvent, Event, ModershipGrantedInfo>(dto, Messages, null, false);
            ToEntityAndAddToList<RemovedModershipNotificationEvent, Event, ModershipRemovedInfo>(dto, Messages, null, false);

            var userDto = dto as UserDto;
            if (userDto != null)
                OnlineUsers.Add(userDto);

            var joinedUserDto = dto as JoinedUserInfo;
            if (joinedUserDto != null)
                OnlineUsers.Add(joinedUserDto.User);

            var leftUserInfo = dto as LeftUserInfo;
            if (leftUserInfo != null)
                RemoveEntityFromList(OnlineUsers, i => i.Id == leftUserInfo.UserId);

            var playerProfileChanges = dto as UserPropertiesChangedInfo;
            if (playerProfileChanges != null)
            {
                UpdatePropertiesForList(OnlineUsers, p => p.Id == playerProfileChanges.UserId, playerProfileChanges.Properties);
            }

            //update property IsDevoiced for players
            var devoiceNotification = dto as DevoiceNotification;
            if (devoiceNotification != null)
            {
                var player = OnlineUsers.FirstOrDefault(i => i.Id == devoiceNotification.TargetId);
                if (player != null)
                    player.IsDevoiced = devoiceNotification.Devoice;
            }

            var youAreDevoicedNotification = dto as YouAreDevoicedNotification;
            if (youAreDevoicedNotification != null)
            {
                //TODO: Notify current user
            }
        }