public List <SystemEntity> GetAllSystems()
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT * from Systems");

            List <SystemEntity> list = new List <SystemEntity>();
            Database            db   = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                    {
                        while (dataReader.Read())
                        {
                            list.Add(SystemEntity.ReaderBind(dataReader));
                        }
                    }
                }

                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                    strSql.ToString(),
                                                    base.FormatParameters(dbCommand.Parameters),
                                                    ex.Message));
                }
            }
            return(list);
        }
Esempio n. 2
0
        private IEnumerable <LuceneAction> GetTaxRateActions(SystemEntity entity)
        {
            if (!_taxSettings.TaxesEnabled || _taxSettings.PriceLoadingMethod == PriceLoadingMethod.IncludingTax)
            {
                yield break;
            }

            var rate = entity as TaxRate;

            if (rate == null)
            {
                yield break;
            }

            var variants = _session.QueryOver <ProductVariant>().Where(variant => variant.TaxRate.Id == rate.Id && variant.Product != null).List().ToList();

            if (rate.IsDefault)
            {
                variants.AddRange(
                    _session.QueryOver <ProductVariant>()
                    .Where(variant => variant.TaxRate == null && variant.Product != null)
                    .List());
            }
            foreach (var variant in variants)
            {
                yield return(GetAction(variant.Product));
            }
        }
 public Document GenerateDocument(SystemEntity entity)
 {
     var item = GenerateItem(entity);
     if (item == null)
         return null;
     return _searchConverter.Convert(item);
 }
Esempio n. 4
0
        public UpdateSystemInfoResponse Process(UpdateSystemInfoRequest request)
        {
            try
            {
                var dao = new SystemInfoDao();

                var data = new SystemEntity();

                SystemInfoMapper.UpdateSystemInfo(ref data, request.SystemInfo);

                dao.UpdateSystemData(data);

                return(new UpdateSystemInfoResponse()
                {
                    Token = request.Token, ResultType = ResultType.OK
                });
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(new UpdateSystemInfoResponse()
                {
                    Token = request.Token, ResultType = ResultType.Error
                });
            }
        }
 public Document GenerateDocument(SystemEntity entity)
 {
     UniversalSearchItem item = GenerateItem(entity);
     if (item == null)
         return null;
     return _searchConverter.Convert(item);
 }
Esempio n. 6
0
        public void GetWithUsers_GetOne()
        {
            SystemDto systemDto = this.GetNewValidDto();
            UserDto   userDto   = GetValidUserDto();

            SystemEntity entity = MapperInstance.Map <SystemEntity>(systemDto);

            entity.UserSystemLst.Add(new UserSystemEntity
            {
                SystemId = systemDto.Id,
                System   = entity,
                UserId   = userDto.Id,
                User     = MapperInstance.Map <UserEntity>(userDto)
            });

            var repositoryMock = this.GetNewEmptyMockedRepository();

            repositoryMock.Setup(r => r.SelectIncludingUsers(It.IsAny <string>()))
            .Returns(entity);
            var serviceMock = this.GetNewService(repositoryMock.Object);

            var obtainedDto = serviceMock.Service.GetWithUsers(systemDto.Id);

            serviceMock.MockUnitOfWork.Verify(mock => mock.Systems.SelectIncludingUsers(It.IsAny <string>()), Times.Once);
            obtainedDto.Should().NotBeNull();
            obtainedDto.Users.Should().NotBeNull();
            obtainedDto.Users.Should().HaveCount(1);
            obtainedDto.Id.Should().Be(systemDto.Id);
            obtainedDto.Users.First().UserId.Should().Be(userDto.Id);
        }
        public SystemEntity GetBySysName(string sysName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT s.* from Systems s ");
            strSql.Append("WHERE s.SystemName=@SystemName");

            SystemEntity systemEntity = null;
            Database     db           = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "SystemName", DbType.String, sysName);

                    using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                    {
                        if (dataReader.Read())
                        {
                            systemEntity = SystemEntity.ReaderBind(dataReader);
                        }
                    }
                }

                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                    strSql.ToString(),
                                                    base.FormatParameters(dbCommand.Parameters),
                                                    ex.Message));
                }
            }
            return(systemEntity);
        }
Esempio n. 8
0
        public static UdpConnectionService BuildService(SystemEntity entity)
        {
            var service = new UdpConnectionService();

            service.IpAddress = entity.ServerURL;
            service.Port      = int.Parse(entity.ServerPort);
            return(service);
        }
Esempio n. 9
0
 public ResponseModel Insert(SystemEntity entity)
 {
     this.dao.Insert(entity);
     return(new ResponseModel()
     {
         Status = true, Menssage = "Inserted system"
     });
 }
Esempio n. 10
0
 public static UpdatedEventInfo GetUpdatedEventInfo(this SystemEntity entity, SystemEntity original)
 {
     if (entity == null)
         return null;
     return
         Activator.CreateInstance(typeof(UpdatedEventInfo<>).MakeGenericType(entity.GetType()), entity, original)
             as UpdatedEventInfo;
 }
Esempio n. 11
0
        public static TcpConnectionService BuildService(SystemEntity entity)
        {
            var service = new TcpConnectionService();

            service.IpAddress = entity.IP;
            service.Port      = int.Parse(entity.Port);
            return(service);
        }
Esempio n. 12
0
 public static EventInfo GetEventInfo(this SystemEntity entity)
 {
     if (entity == null)
     {
         return(null);
     }
     return(Activator.CreateInstance(typeof(EventInfo <>).MakeGenericType(entity.GetType()), entity) as EventInfo);
 }
Esempio n. 13
0
        private IEnumerable <LuceneAction> GetVariantActions(SystemEntity entity)
        {
            var variant = entity as ProductVariant;

            if (variant != null && variant.Product != null)
            {
                yield return(GetAction(variant.Product));
            }
        }
Esempio n. 14
0
 public static UpdatedEventInfo GetUpdatedEventInfo(this SystemEntity entity, SystemEntity original)
 {
     if (entity == null)
     {
         return(null);
     }
     return
         (Activator.CreateInstance(typeof(UpdatedEventInfo <>).MakeGenericType(entity.GetType()), entity, original)
          as UpdatedEventInfo);
 }
Esempio n. 15
0
        public void Delete(object obj)
        {
            SystemEntity entity = obj as SystemEntity;

            if (entity != null)
            {
                AddDeletedEvent(entity);
            }
            _session.Delete(obj);
        }
Esempio n. 16
0
        public object Save(object obj)
        {
            SystemEntity systemEntity = obj as SystemEntity;

            if (systemEntity != null)
            {
                AddAddEvent(systemEntity);
            }
            return(_session.Save(obj));
        }
Esempio n. 17
0
        public void Update(object obj)
        {
            SystemEntity systemEntity = obj as SystemEntity;

            if (systemEntity != null)
            {
                AddUpdateEvent(systemEntity);
            }
            _session.Update(obj);
        }
Esempio n. 18
0
        public Document GenerateDocument(SystemEntity entity)
        {
            var item = GenerateItem(entity);

            if (item == null)
            {
                return(null);
            }
            return(_searchConverter.Convert(item));
        }
Esempio n. 19
0
 private void AddDeletedEvent(SystemEntity obj)
 {
     if (Deleted.All(info => info.ObjectBase != obj))
     {
         EventInfo eventInfo = obj.GetEventInfo();
         Deleted.Add(eventInfo);
         eventInfo.PreTransactionHandled = true;
         eventInfo.Publish(this, typeof(IOnDeleting <>),
                           (info, ses, t) => info.GetTypedInfo(t).ToDeletingArgs(ses, t));
     }
 }
Esempio n. 20
0
        private static Op <SystemEntityMono> RawToMono(SystemEntity systemEntity)
        {
            var type = systemEntity.GetType();

            if (_matchedFactories.ContainsKey(type))
            {
                return(Op <SystemEntityMono> .Correct(_matchedFactories[type].Invoke(systemEntity)));
            }

            return(Op <SystemEntityMono> .Error($"No mono factory for {type.Name}"));
        }
Esempio n. 21
0
        public static void UpdateDeviceData(ref SystemEntity entity, UdpConnectionService service)
        {
            if (!string.IsNullOrWhiteSpace(service.IpAddress))
            {
                entity.ServerURL = service.IpAddress;
            }

            if (service.Port != 0)
            {
                entity.ServerPort = service.Port.ToString();
            }
        }
Esempio n. 22
0
 private void AddUpdateEvent(SystemEntity obj)
 {
     if (Updated.All(info => info.ObjectBase != obj))
     {
         SystemEntity     originalVersion = GetOriginalVersion(obj);
         UpdatedEventInfo eventInfo       = obj.GetUpdatedEventInfo(originalVersion);
         Updated.Add(eventInfo);
         eventInfo.PreTransactionHandled = true;
         eventInfo.Publish(this, typeof(IOnUpdating <>),
                           (info, ses, t) => info.GetTypedInfo(t).ToUpdatingArgs(ses, t));
     }
 }
Esempio n. 23
0
        public void SaveOrUpdate(object obj)
        {
            SystemEntity entity = obj as SystemEntity;

            if (entity != null && entity.Id == 0)
            {
                AddAddEvent(entity);
            }
            else if (entity != null)
            {
                AddUpdateEvent(entity);
            }
            _session.SaveOrUpdate(obj);
        }
        public UniversalSearchItem GenerateItem(SystemEntity entity)
        {
            if (entity == null)
                return null;

            Type type = entity.GetType();
            if (!GetUniversalSearchItemTypes.ContainsKey(type))
                return null;

            GetUniversalSearchItemBase getUniversalSearchItem = _kernel.Get(GetUniversalSearchItemTypes[type]) as GetUniversalSearchItemBase;
            if (getUniversalSearchItem == null)
                return null;

            return getUniversalSearchItem.GetSearchItem(entity);
        }
Esempio n. 25
0
        public void Delete(SystemEntity entity)
        {
            if (!_universalSearchItemGenerator.CanGenerate(entity))
            {
                return;
            }

            var data = new UniversalSearchIndexData
            {
                Action = UniversalSearchIndexAction.Delete,
                UniversalSearchItem = _universalSearchItemGenerator.GenerateItem(entity)
            };

            if (!AnyExistInEndRequest(data))
                CurrentRequestData.OnEndRequest.Add(new AddUniversalSearchTaskInfo(data));
        }
Esempio n. 26
0
        public bool OnPreInsert(PreInsertEvent @event)
        {
            SystemEntity systemEntity = @event.Entity as SystemEntity;

            if (systemEntity != null)
            {
                DateTime now = CurrentRequestData.Now;
                SetCreatedOn(@event.Persister, @event.State, systemEntity, now);
                SetUpdatedOn(@event.Persister, @event.State, systemEntity, now);
                if (systemEntity is SiteEntity && (systemEntity as SiteEntity).Site == null)
                {
                    SetSite(@event.Persister, @event.State, systemEntity as SiteEntity, CurrentRequestData.CurrentSite);
                }
            }
            return(false);
        }
Esempio n. 27
0
        public List <LuceneAction> GetAllActions(object entity, LuceneOperation operation)
        {
            if (!(entity is SystemEntity))
            {
                return(new List <LuceneAction>());
            }
            SystemEntity systemEntity = entity as SystemEntity;
            Dictionary <Type, List <Func <SystemEntity, IEnumerable <LuceneAction> > > > actionsDictionary = GetActionsDictionary(operation);
            List <LuceneAction> luceneActions = new List <LuceneAction>();

            foreach (Func <SystemEntity, IEnumerable <LuceneAction> > action in actionsDictionary.Keys.SelectMany(key => actionsDictionary[key]))
            {
                luceneActions.AddRange(action(systemEntity));
            }
            return(luceneActions);
        }
Esempio n. 28
0
 public UserServiceSystemTest()
 {
     _user                 = this.GetNewValidDto();
     _system               = this.GetNewValidSystemDto();
     _userEntity           = MapperInstance.Map <UserEntity>(_user);
     _systemEntity         = MapperInstance.Map <SystemEntity>(_system);
     _userEntityWithSystem = MapperInstance.Map <UserEntity>(_user);
     _userEntityWithSystem.UserSystemLst.Add(new UserSystemEntity()
     {
         SystemId = _system.Id,
         UserId   = _user.Id,
         System   = _systemEntity,
         User     = _userEntity
     });
     this.SetupRepository();
 }
Esempio n. 29
0
        private IEnumerable <LuceneAction> GetValueActions(SystemEntity entity)
        {
            var line = entity as ProductSpecificationValue;

            if (line == null)
            {
                yield break;
            }

            yield return(new LuceneAction
            {
                Entity = line.Product.Unproxy(),
                Operation = LuceneOperation.Update,
                IndexDefinition = IndexingHelper.Get <ProductSearchIndex>()
            });
        }
        private static IEnumerable <LuceneAction> GetActions(SystemEntity entity)
        {
            var line = entity as ProductOptionValue;

            if (line != null && line.ProductVariant != null && line.ProductVariant.Product != null)
            {
                yield return new LuceneAction
                       {
                           Entity          = line.ProductVariant.Product.Unproxy(),
                           Operation       = LuceneOperation.Update,
                           IndexDefinition =
                               IndexingHelper.Get <ProductSearchIndex>()
                       }
            }
            ;
        }
Esempio n. 31
0
        public void Update(SystemEntity entity)
        {
            if (!_universalSearchItemGenerator.CanGenerate(entity))
            {
                return;
            }
            var data = new UniversalSearchIndexData
            {
                Action = UniversalSearchIndexAction.Update,
                UniversalSearchItem = _universalSearchItemGenerator.GenerateItem(entity)
            };

            if (!AnyExistInEndRequest(data))
            {
                CurrentRequestData.OnEndRequest.Add(new AddUniversalSearchTaskInfo(data));
            }
        }
Esempio n. 32
0
 public ResponseModel Update(SystemEntity entity)
 {
     if (this.dao.Update(entity))
     {
         return(new ResponseModel()
         {
             Status = true, Menssage = "Updated system"
         });
     }
     else
     {
         return(new ResponseModel()
         {
             Status = false, Menssage = "Not Updated system"
         });
     }
 }
Esempio n. 33
0
        //[System.Web.Services.WebMethod]
        //public static void GetComplaintItem(HttpContext context)
        //{
        //    //Get System properties from System table
        //    ISystemRepository systemRepository = ObjectFactory.GetInstance<ISystemRepository>();
        //    SystemEntity sysEntity = systemRepository.GetBySysName(cmplEntity.SystemName);

        //    //Get Item Path
        //    string serverName = sysEntity.IP + (sysEntity.Port.Length>0 ? ":" + sysEntity.Port : "");
        //    string connStr = String.Format("server={0};database={1};uid={2};pwd={3};max pool size =1024000",
        //                                    serverName, sysEntity.DBLocation, sysEntity.UserName, sysEntity.UserPwd);
        //    string type = ((ComplaintTypeEnum)cmplEntity.Type).ToString();

        //    string path = complaintApp.GetComItem(connStr, sysEntity.Procedure, type, cmplEntity.TargetID);

        //    HelpPath helpPath = new HelpPath();
        //    helpPath.Type = type;
        //    helpPath.Path = path;

        //    JavaScriptSerializer jss = new JavaScriptSerializer();
        //    context.Response.Write(jss.Serialize(helpPath));

        //    //if (type == "Photo")
        //    //{
        //    //    this.comImg.ImageUrl = path;
        //    //    this.comImg.Visible = true;
        //    //}
        //    //else if (type == "Video")
        //    //{
        //    //    //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>setPlayerVideo();</script>");
        //    //    context.Response.Write(path);
        //    //}
        //}


        public void GetComplaintItem()
        {
            //Get System properties from System table
            ISystemRepository systemRepository = ObjectFactory.GetInstance <ISystemRepository>();
            SystemEntity      sysEntity        = systemRepository.GetBySysName(cmplEntity.SystemName);

            //Get Item Path
            string serverName = sysEntity.IP + (sysEntity.Port.Length > 0 ? ":" + sysEntity.Port : "");
            string connStr    = String.Format("server={0};database={1};uid={2};pwd={3};max pool size =1024000",
                                              serverName, sysEntity.DBLocation, sysEntity.UserName, sysEntity.UserPwd);
            string type = ((ComplaintTypeEnum)cmplEntity.Type).ToString();

            string result = complaintApp.GetComItem(connStr, sysEntity.Procedure, type, cmplEntity.TargetID);

            if (string.IsNullOrEmpty(result))
            {
                comItem = new ComplaintItem();
                return;
            }

            JavaScriptSerializer jss = new JavaScriptSerializer();

            comItem = (ComplaintItem)jss.Deserialize(result, typeof(ComplaintItem));

            if (type == "Photo")
            {
                this.comImg.Style["display"] = "inline";
            }
            else if (type == "Video")
            {
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "setPlayerVideo('" + comItem.Path + "');", true);
            }
            else if (type == "User")
            {
                this.comUser.Style["display"] = "inline";
            }
            else if (type == "Group")
            {
                this.comGroup.Style["display"] = "inline";
            }
            else if (type == "Post")
            {
                this.comPost.Style["display"] = "inline";
            }
        }
Esempio n. 34
0
        private void SetUpdatedOn(IEntityPersister persister, object[] state, SystemEntity siteEntity, DateTime date)
        {
            Set(persister, state, "UpdatedOn", date);

            siteEntity.UpdatedOn = date;
        }
Esempio n. 35
0
 public bool CanGenerate(SystemEntity entity)
 {
     return entity != null && GetUniversalSearchItemTypes.ContainsKey(entity.GetType());
 }
Esempio n. 36
0
        public UniversalSearchItem GenerateItem(SystemEntity entity)
        {
            if (entity == null)
                return null;

            Type type = entity.GetType();
            if (!GetUniversalSearchItemTypes.ContainsKey(type))
                return null;

            var getUniversalSearchItem = _kernel.Get(GetUniversalSearchItemTypes[type]) as GetUniversalSearchItemBase;
            if (getUniversalSearchItem == null)
                return null;

            return getUniversalSearchItem.GetSearchItem(entity);
        }