Пример #1
0
        public AppViewModel()
        {
            var contactDataService = new JsonDataService();

            BookVm      = new BookViewModel(contactDataService);
            CurrentView = BookVm;
        }
Пример #2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userAccount"></param>
        /// <param name="password"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public virtual bool B2BLogin(string userAccount, string password, ref string strError)
        {
            System.Net.WebClient client = new System.Net.WebClient();
            client.Headers["Content-Type"] = "application/json";
            client.Encoding = Encoding.UTF8;
            string url                      = ComixSDK.EDI.Utils.ConfigHelper.GetConfigString("B2BLOGINURL") + "ACTION=UserLogin&account=" + userAccount + "&password="******"";
            string callingJson              = "";
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("ACTION", "UserLogin");
            dic.Add("account", userAccount);
            dic.Add("password", password);
            callingJson = JsonDataService.ObjectToJSON(dic);
            try
            {
                responseJson = client.UploadString(url, callingJson);
                responseJson = responseJson.Trim("\0".ToCharArray());
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
            ResponseLoginInfoModel responseDomain = new ResponseLoginInfoModel();

            if (responseDomain.code == "0")
            {
                return(true);
            }
            else if (responseDomain.code == "-1")
            {
                strError = "系统故障,请联系管理员";
            }
            else if (responseDomain.code == "8" || responseDomain.code == "4")
            {
                strError = "您输入的账户名/密码不匹配,请核对后重新输入!";
            }
            else if (responseDomain.code == "2")
            {
                strError = "对不起,该帐号已被冻结或未激活,请联系管理员!";
            }
            else if (responseDomain.code == "3")
            {
                strError = "对不起,管理员不能登录前台!";
            }
            else if (responseDomain.code == "5")
            {
                strError = "用户尚未激活,必须激活后才能登录!";
            }
            else if (responseDomain.code == "7")
            {
                strError = "账号异常,请联系管理员!";
            }
            else
            {
                strError = "系统账号异常,请联系管理员!";
            }
            return(false);
        }
Пример #3
0
        public void JsonStringToEntity(string jsonValue)
        {
            JsonData jsdata  = JsonDataService.GetJsonData(jsonValue);
            string   tpValue = "";

            foreach (ColumnInfo column in OringTableSchema.AllColumnInfo)
            {
                tpValue = jsdata[0][column.ColumnName].ToString();
                if (column.DataType == typeof(string))
                {
                    _data.Add(column.ColumnName, tpValue);
                }
                else if (column.DataType == typeof(int))
                {
                    _data.Add(column.ColumnName, tpValue == "" ? 0 : int.Parse(tpValue));
                }
                else if (column.DataType == typeof(decimal))
                {
                    _data.Add(column.ColumnName, tpValue == "" ? 0 : decimal.Parse(tpValue));
                }
                else if (column.DataType == typeof(bool))
                {
                    _data.Add(column.ColumnName, tpValue == "" ? false : bool.Parse(tpValue));
                }
                else if (column.DataType == typeof(DateTime))
                {
                    _data.Add(column.ColumnName, tpValue == "" ? DateTime.MaxValue : DateTime.Parse(tpValue));
                }
                else
                {
                    _data.Add(column.ColumnName, tpValue);
                }
            }
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();

            // Initialize the publications observable
            _publications = new ObservableCollection <MediumPublication>();

            // Get URL for GET request
            string apiGetPath = AppConfig.apiGetUserPath;

            // Initialize DAL
            JsonDataService jsonDataService = new JsonDataService(apiGetPath);

            // Initialize BLL
            PublicationBLL publicationBLL = new PublicationBLL(jsonDataService);

            // Get a collection of publications
            ObservableCollection <MediumPublication> publications = publicationBLL.GetPublications();

            // Shorthand for adding publications from BLL method to _publications var???
            publications.ToList().ForEach(_publications.Add);

            // Add the collection
            //foreach (var publication in publications)
            //{
            //    _publications.Add(publication);
            //}

            _list.ItemsSource = _publications;
        }
Пример #5
0
        public void createDynamicJObjectTest1()
        {
            var factoryMock = Substitute.For <Func <string> >();
            var optionsMock = Substitute.For <IOptions <MemoryCacheOptions> >();

            optionsMock.Value.Returns(callInfo => new MemoryCacheOptions());
            var              memoryCache    = new MemoryCache(optionsMock);
            ICacheService    cacheService   = new CacheService(memoryCache);
            IConfiguration   _configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            IFileRead        read           = new FileRead(_configuration, cacheService);
            IJsonDataService jsonService    = new JsonDataService(_configuration, cacheService, read);

            var countries = jsonService.GetCountries();

            string        codesJson  = read.ReadJsonFile("Json,codes2.json");
            List <Code>   codes      = JsonConvert.DeserializeObject <List <Code> >(codesJson);
            List <string> missingCN2 = new List <string>();
            List <string> missingCN3 = new List <string>();

            foreach (var c in codes)
            {
                var found = countries.FirstOrDefault(a => a.CountryName == c.CountryName);
                if (found == null)
                {
                    missingCN2.Add(c.CountryName);
                }
                else
                {
                    missingCN3.Add(c.CountryName);
                }
            }
            Action act = () => missingCN2.Count.Should().BeGreaterThan(0);

            act.Should().NotThrow();
        }
Пример #6
0
 static void Main(string[] args)
 {
     //IDataService dataService = new CsvDataService();
     //IDataService dataService = new XmlDataService();
     IDataService dataService  = new JsonDataService();
     CharacterBLL characterBLL = new CharacterBLL(dataService);
     Presenter    presenter    = new Presenter(characterBLL);
 }
Пример #7
0
        public AppViewModel()
        {
            var dataService   = new JsonDataService();
            var dialogService = new WindowDialogService();
            var mediaService  = new MusicService();

            _musicPlayerVM = new MusicPlayerViewModel(dataService, dialogService, mediaService);
        }
Пример #8
0
 static void Main(string[] args)
 {
     //IDataService dataService = new XmlDataService();
     //IDataService dataService = new XmlDataService(DataSettings.dataFilePath);
     IDataService dataService  = new JsonDataService(DataSettings.dataFilePath);
     CharacterBLL characterBll = new CharacterBLL(dataService);
     Presenter    presenter    = new Presenter(characterBll);
 }
Пример #9
0
        public static void Initailze( HttpConfiguration configuration )
        {
            var configPath = ConfigurationManager.AppSettings["DataPath"] ?? "Data";
              var dataRoot = Path.Combine( HostingEnvironment.ApplicationPhysicalPath, configPath );

              UserService = new JsonUserService( dataRoot );
              DataService = new JsonDataService( dataRoot );

              configuration.Services.Replace( typeof( IContentNegotiator ), new JsonContentNegotiator() );
        }
Пример #10
0
        public void GetLookUp_Test()
        {
            var factoryMock = Substitute.For <Func <string> >();
            var optionsMock = Substitute.For <IOptions <MemoryCacheOptions> >();

            optionsMock.Value.Returns(callInfo => new MemoryCacheOptions());
            var           memoryCache  = new MemoryCache(optionsMock);
            ICacheService cacheService = new CacheService(memoryCache);

            IConfiguration _configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            IFileRead      read           = new FileRead(_configuration, cacheService);

            IJsonDataService jsonService = new JsonDataService(_configuration, cacheService, read);
            var    list = jsonService.GetCategories();
            Action act  = () => list.Count.Should().BeGreaterThan(0);

            act.Should().NotThrow();

            list = jsonService.GetCategories();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();

            list = jsonService.GetCategories();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();

            list = jsonService.GetCategories();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();

            list = jsonService.GetConditions();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();

            list = jsonService.GetMileOptionsBy();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();

            list = jsonService.GetSortOptionsBy();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();

            list = jsonService.GetConditions();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();

            list = jsonService.GetMileOptionsBy();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();

            list = jsonService.GetSortOptionsBy();
            act  = () => list.Count.Should().BeGreaterThan(0);
            act.Should().NotThrow();
        }
Пример #11
0
        public BookViewModel(JsonDataService service)
        {
            _contactVM = new ContactViewModel(service);
            AlphaBetVM = new AlphabetViewModel();

            _service = service;
            //ContactVM.LoadContacts((await _service.GetContacts()));

            LoadContactsCommand = new RelayCommand(LoadDataContact);
            LoadBirthDayCommand = new RelayCommand(LoadBirthDayContact);
        }
Пример #12
0
        public void SetUp()
        {
            JsonSerializerSettings settings = new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.All
            };

            var company = JsonConvert.DeserializeObject <Company>(jsonString, settings);

            Service = new JsonDataService(company);
        }
Пример #13
0
        public void Inherit_IUnitOfWork()
        {
            // Arrange
            var mockDbContext       = new Mock <DbContext>(MockBehavior.Strict);
            var mockHostEnvironment = new Mock <IHostEnvironment>(MockBehavior.Strict);
            var mockLogger          = new Mock <ILogger>(MockBehavior.Strict);

            // Act
            var jsonDataService = new JsonDataService <FakeEntity, int>("", mockDbContext.Object, mockHostEnvironment.Object, mockLogger.Object);

            // Assert
            Assert.IsAssignableFrom <IDataService>(jsonDataService);
        }
Пример #14
0
        public static void Initailze( HttpConfiguration configuration )
        {
            var configPath = ConfigurationManager.AppSettings["DataPath"] ?? "Data";
              var dataRoot = Path.Combine( HostingEnvironment.ApplicationPhysicalPath, configPath );

              UserService = new JsonUserService( dataRoot );
              DataService = new JsonDataService( dataRoot );
              MessageService = new TextFileMessageService( dataRoot );

              var typeResolver = new HttpRuntimeTypeResolver( configuration.Services.GetAssembliesResolver() );

              var rules = StarveGameRules.CreateInstance( typeResolver );
              GameHost.Initialize( rules, DataService, MessageService );

              configuration.Services.Replace( typeof( IContentNegotiator ), new JsonContentNegotiator() );
              configuration.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
        }
Пример #15
0
        static void Main(string[] args)
        {
            IDataService DataService;
            CharacterBLL CharacterBLL;
            Presenter    presenter;

            DataService  = new CsvDataService(@"Data/Data.csv");
            CharacterBLL = new CharacterBLL(DataService);
            presenter    = new Presenter(CharacterBLL);

            DataService  = new XmlDataService(@"Data/Data.xml");
            CharacterBLL = new CharacterBLL(DataService);
            presenter    = new Presenter(CharacterBLL);

            DataService  = new JsonDataService();
            CharacterBLL = new CharacterBLL(DataService);
            presenter    = new Presenter(CharacterBLL);
        }
Пример #16
0
        static void Main(string[] args)
        {
            IDataService dataService;
            CharacterBLL characterBLL;
            Presenter    presenter;

            // Run CSV Serializer
            dataService  = new CsvDataService();
            characterBLL = new CharacterBLL(dataService);
            presenter    = new Presenter(characterBLL);

            // Run XML Serializer
            dataService  = new XmlDataService();
            characterBLL = new CharacterBLL(dataService);
            presenter    = new Presenter(characterBLL);

            // Run JSON Serializer
            dataService  = new JsonDataService();
            characterBLL = new CharacterBLL(dataService);
            presenter    = new Presenter(characterBLL);
        }
Пример #17
0
        public static void Initailze(HttpConfiguration configuration)
        {
            var configPath = ConfigurationManager.AppSettings["DataPath"] ?? "Data";
            var dataRoot   = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, configPath);

            UserService    = new JsonUserService(dataRoot);
            DataService    = new JsonDataService(dataRoot);
            MessageService = new TextFileMessageService(dataRoot);



            var typeResolver = new HttpRuntimeTypeResolver(configuration.Services.GetAssembliesResolver());


            var rules = StarveGameRules.CreateInstance(typeResolver);

            GameHost.Initialize(rules, DataService, MessageService);



            configuration.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator());
            configuration.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
        }
Пример #18
0
        public void JsonDataServiceTest()
        {
            var dataService = new JsonDataService(outputDir);

            Assert.IsNotNull(dataService);
        }