Esempio n. 1
0
    private void ParseJson(string path)
    {
        string        jsonData       = File.ReadAllText(path);
        JsonDataModel parsedJsonData = JsonConvert.DeserializeObject <JsonDataModel>(jsonData);

        _table.SetData(parsedJsonData);
    }
Esempio n. 2
0
        public JsonResult Post(int?id, string name, string description)
        {
            var json = new JsonDataModel();

            if (string.IsNullOrEmpty(name))
            {
                json.result  = ResultType.UnSuccess;
                json.message = "Lütfen gerekli alanları doldurunuz";
            }
            else
            {
                if (id > 0)
                {
                    var postItem = _db.Group.GetById(id);
                    postItem.Description = description;
                    postItem.Name        = name;
                    _db.Group.Edit(postItem);
                }
                else
                {
                    var postItem = new Group();
                    postItem.Description = description;
                    postItem.Name        = name;
                    _db.Group.Add(postItem);
                }
                json.result = ResultType.Success;
            }
            return(Json(new { json }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public JsonResult Post(int?id, string name, string emailTitle, string emailBody)
        {
            var json = new JsonDataModel();

            if (string.IsNullOrEmpty(name))
            {
                json.result  = ResultType.UnSuccess;
                json.message = "Lütfen gerekli alanları doldurunuz";
            }
            else
            {
                if (id > 0)
                {
                    var postItem = _db.Pattern.GetById(id);
                    postItem.EmailBody  = emailBody;
                    postItem.EmailTitle = emailTitle;
                    postItem.Name       = name;
                    _db.Pattern.Edit(postItem);
                }
                else
                {
                    var postItem = new Pattern();
                    postItem.EmailBody  = emailBody;
                    postItem.EmailTitle = emailTitle;
                    postItem.Name       = name;
                    _db.Pattern.Add(postItem);
                }
                json.result = ResultType.Success;
            }
            return(Json(new { json }, JsonRequestBehavior.AllowGet));
        }
        private async Task <(channel, bool)> isOnline(channel channel)
        {
            var client  = new RestClient();
            var request = new RestRequest($"https://api.twitch.tv/kraken/users?login={channel.username}");

            request.AddHeader("Accept", "application/vnd.twitchtv.v5+json");
            request.AddHeader("Client-ID", "***CLIENT-ID***");
            var response = await client.ExecuteAsync(request);

            JsonDataModel jsonresponse = JsonConvert.DeserializeObject <JsonDataModel>(response.Content);

            if (jsonresponse._total == 0)
            {
                return(channel, false);
            }
            string _id = jsonresponse.users[0]["_id"];

            var request2 = new RestRequest($"https://api.twitch.tv/kraken/streams/{_id}");

            request2.AddHeader("Accept", "application/vnd.twitchtv.v5+json");
            request2.AddHeader("Client-ID", "***CLIENT-ID***");
            var response2 = await client.ExecuteAsync(request2);

            JsonDataModel2 jsonresponse2 = JsonConvert.DeserializeObject <JsonDataModel2>(response2.Content);

            if (jsonresponse2.stream == null)
            {
                return(channel, false);
            }
            else
            {
                return(channel, true);
            }
        }
Esempio n. 5
0
        // POST: api/RAM
        public IEnumerable <IEnumerable <string> > Post(JsonDataModel value)
        {
            var v = from entity in db.Entities
                    from device in db.Devices
                    from characteristic in db.Characteristic
                    where entity.Id == device.IdEntity &&
                    entity.NameOfEntity == "Память оперативная" &&
                    characteristic.IdCharacteristic == device.IdCharacteristic
                    select new
            {
                device.IdDevice,
                device.BrandName,
                device.Model,
                characteristic.Value1,
                characteristic.Value2,
                characteristic.Value3,
                characteristic.Value4
            };

            List <List <string> > t = new List <List <string> >();

            string[] s = null;
            if (value.motherboard != -1)
            {
                s = (from dtt in db.DeviceToType
                     from tp in db.Types
                     where dtt.IdDevice == value.motherboard && dtt.IdType == tp.IdType
                     select tp.Name).ToArray();
            }

            foreach (var i in v)
            {
                if (value.motherboard != -1)
                {
                    string tmp = (from dtt in db.DeviceToType
                                  from tp in db.Types
                                  where dtt.IdDevice == i.IdDevice && dtt.IdType == tp.IdType
                                  select tp.Name).Single();

                    if (Array.IndexOf(s, tmp) == -1)
                    {
                        continue;
                    }
                }

                List <string> d = new List <string>();
                d.Add(i.IdDevice.ToString());
                d.Add(i.BrandName);
                d.Add(i.Model);
                d.Add(i.Value1);
                d.Add(i.Value2);
                d.Add(i.Value3);
                d.Add(i.Value4);

                t.Add(d);
            }

            return(t);
        }
Esempio n. 6
0
        public ActionResult Index()
        {
            // Read JSON file and deserialize it to object
            string        fileName       = "json.json";
            string        filePath       = Server.MapPath("JSONFile");
            JsonDataModel videoDataModel = new JsonDataModel();

            try
            {
                // read json and build object
                if (System.IO.File.Exists(Path.Combine(filePath, fileName)))
                {
                    // read JSON directly from a file
                    using (StreamReader file = System.IO.File.OpenText(Path.Combine(filePath, fileName)))
                    {
                        string fileContent = file.ReadToEnd();
                        videoDataModel = JsonConvert.DeserializeObject <JsonDataModel>(fileContent);
                    }
                }

                // write to csv file using csvhelper

                // 1. Extract all images with id and imageURL
                using (var writer = new StreamWriter(System.IO.Path.Combine(filePath, "ImageContent.csv")))
                {
                    using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                    {
                        var imagerecords = videoDataModel.data.Select(x => new ImageDataModel()
                        {
                            Id = x.id, imageUrl = x.contentImageUrl
                        }).ToList();
                        csv.WriteRecords <ImageDataModel>(imagerecords);
                    }
                }
                // 2. Extract Video details like ID, Title, Link, Highest video link

                using (var writer = new StreamWriter(System.IO.Path.Combine(filePath, "VideoContent.csv")))
                {
                    using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                    {
                        var videorecords = videoDataModel.data.Select(x => new VideoDetailDataModel()
                        {
                            VideoId = x.id, Title = x.contentTitle, Link = x.url, HighestResolutionVideoUrl = x.ampPreviewUrl
                        }).ToList();
                        csv.WriteRecords <VideoDetailDataModel>(videorecords);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(View());
        }
Esempio n. 7
0
        public static void SaveLocalData(JsonDataModel userLocalAppData)
        {
            //organising data in container was not working in production need some rnd will do later
            //_localSettings.Containers[_containerName.ToString()].Values["UserData"] = JsonConvert.SerializeObject(userLocalAppData);

            //as per microsoft doc there is no limitation of data size in local setting
            //remove setting
            _localSettings.Values.Remove(_userName);
            //push setting
            _localSettings.Values[_userName] = JsonConvert.SerializeObject(userLocalAppData);
        }
Esempio n. 8
0
        public static Boolean SaveJson(string Path, JsonDataModel dataModel)
        {
            if (!File.Exists(Path))  // 判断是否已有相同文件
            {
                FileStream fs1 = new FileStream(Path, FileMode.Create, FileAccess.ReadWrite);
                fs1.Close();
            }
            string json = JsonConvert.SerializeObject(dataModel);

            File.WriteAllText(Path, json);
            return(true);
        }
Esempio n. 9
0
        public async Task LogJsonData()
        {
            if (await Request.AuthenticationCheck())
            {
                JsonDataModel jmodel = await Request.DeserializeBody <JsonDataModel>();

                if (!jmodel.JsonString.StartsWith("{\"CaptureDateTime"))
                {
                    await sql.InsertRecord(jmodel, "JsonData");
                }
            }
        }
Esempio n. 10
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            Object model = Activator.CreateInstance(_clazz);

            if (context.ActionArguments.Any(x => x.Key.Equals("data")))
            {
                JsonDataModel g = (JsonDataModel)context.ActionArguments.Where(x => x.Key.Equals("data")).Select(o => o.Value).FirstOrDefault();
                context.ActionArguments["data"] = new JsonDataModel()
                {
                    model = g.model.ToObject(_clazz)
                };
            }
        }
Esempio n. 11
0
        public static JsonDataModel ReadJson(string Path)
        {
            if (!File.Exists(Path))  // 判断是否已有文件
            {
                //FileStream fs1 = new FileStream(Path, FileMode.Create, FileAccess.ReadWrite);
                //fs1.Close();
                SaveJson(Path, new JsonDataModel()
                {
                    Sequence = 0
                });
            }
            JsonDataModel dataModel = JsonConvert.DeserializeObject <JsonDataModel>(File.ReadAllText(Path));

            return(dataModel);
        }
Esempio n. 12
0
        public JsonResult Post(long?id, int groupId, string email, string firstname, string lastname)
        {
            var json = new JsonDataModel();

            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(lastname))
            {
                json.result  = ResultType.UnSuccess;
                json.message = "Lütfen tüm alanları doldurunuz";
            }
            else
            {
                if (id > 0)
                {
                    var postItem = _db.Contact.GetById(id);
                    postItem.GroupId   = groupId;
                    postItem.Email     = email;
                    postItem.FirstName = firstname;
                    postItem.LastName  = lastname;
                    _db.Contact.Edit(postItem);
                }
                else
                {
                    var isExistContact = _db.Contact.All.Any(x => x.Email == email.ToLower() && x.GroupId == groupId);
                    if (isExistContact == false && email.Length > 0 && UtilManager.EmailIsValid(email))
                    {
                        var postItem = new Contact();
                        postItem.Email      = email.ToLower();
                        postItem.GroupId    = groupId;
                        postItem.FirstName  = firstname;
                        postItem.LastName   = lastname;
                        postItem.CreateDate = DateTime.Now;
                        _db.Contact.Add(postItem);
                        json.result = ResultType.Success;
                    }
                    else
                    {
                        json.result  = ResultType.UnSuccess;
                        json.message = "Bu mail adresi grupta bulunuyor";
                    }
                }
            }
            return(Json(new { json }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 13
0
    public void SetData(JsonDataModel jsonData)
    {
        _titleField.text = jsonData.Title;
        _columnKeys      = jsonData.ColumnHeaders;
        _rowDataMap      = jsonData.Data;

        int lastColumnIndex = _columnViewList.Count - 1;

        for (int i = 0; i < _columnKeys.Length; i++)
        {
            string key = _columnKeys[i];

            ColumnView column;

            if (lastColumnIndex < i)
            {
                column = Instantiate(_columnTemplate, _columnTemplate.transform.parent);
                _columnViewList.Add(column);
            }
            else
            {
                column = _columnViewList[i];
            }

            column.Initialize(key);

            for (int j = 0; j < _rowDataMap.Count; j++)
            {
                column.SetItemData(_rowDataMap[j][key]);
            }

            column.SetColumn();
            column.gameObject.SetActive(true);
        }

        for (int i = _columnKeys.Length; i < _columnViewList.Count; i++)
        {
            _columnViewList[i].gameObject.SetActive(false);
        }
    }
Esempio n. 14
0
        private void dowloandJSONOpenDataComplete(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                StreamReader stm = new StreamReader(e.Result);
                try
                {
                    String str = stm.ReadToEnd();

                    JsonDataModel jDataParser = new JsonDataModel();
                    jDataParser = DeserializeJSON <JsonDataModel>(str);
                    //Binding data
                    this.gridOpenData.DataContext = jDataParser.EntryItem;
                    //Binding data to the Popup
                    gridPopup.DataContext = jDataParser.EntryItem;
                    stm.Close();
                }
                catch (Exception)
                {
                }
            }
        }
Esempio n. 15
0
        // POST: api/Power
        public IEnumerable <IEnumerable <string> > Post(JsonDataModel value)
        {
            var v = from entity in db.Entities
                    from device in db.Devices
                    from characteristic in db.Characteristic
                    where entity.Id == device.IdEntity &&
                    entity.NameOfEntity == "Блок питания" &&
                    characteristic.IdCharacteristic == device.IdCharacteristic
                    select new
            {
                device.IdDevice,
                device.BrandName,
                device.Model,
                characteristic.Value1,
                characteristic.Value2,
                characteristic.Value3,
                characteristic.Value4,
                characteristic.Value5
            };

            List <List <string> > t = new List <List <string> >();

            foreach (var i in v)
            {
                List <string> d = new List <string>();
                d.Add(i.IdDevice.ToString());
                d.Add(i.BrandName);
                d.Add(i.Model);
                d.Add(i.Value1);
                d.Add(i.Value2);
                d.Add(i.Value3);
                d.Add(i.Value4);
                d.Add(i.Value5);

                t.Add(d);
            }

            return(t);
        }
Esempio n. 16
0
        public async static Task <Result> UpdateJsonFile(JsonDataModel jsonDataModel)
        {
            string FileName = _userName + "_data.json";
            Result result   = new Result();

            result.IsDbCreated     = false;
            result.CreatedFileName = FileName;
            _logger.Information(FileName + "is already there updating new content");
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            await localFolder.CreateFileAsync(FileName, CreationCollisionOption.ReplaceExisting);

            _logger.Information("Updating  DB of user " + FileName);

            StorageFile myFile = await localFolder.GetFileAsync(FileName);

            string initialJsonString = JsonConvert.SerializeObject(jsonDataModel);
            //_logger.Information("data after serilization"+initialJsonString);
            await FileIO.WriteTextAsync(myFile, initialJsonString);

            result.IsDbCreated = true;
            _logger.Information("DB Updated!!!!!!!!");
            return(result);
        }
Esempio n. 17
0
        public JsonResult Post(FileUpload fileUpload)
        {
            var json = new JsonDataModel();

            json.result  = ResultType.UnSuccess;
            json.message = "Dosya yüklenemedi";
            if (!(new Regex(@"(.*?)\.(jpg|jpeg|png|gif|bmp|tiff|tif)$", RegexOptions.IgnoreCase)).IsMatch(fileUpload.FileName))
            {
                json.message = "Geçersiz dosya tipi";
            }
            else if (fileUpload.InputStream.Length == 0)
            {
                json.message = "Dosya Seçilmedi";
            }
            else if (fileUpload.InputStream.Length > 0)
            {
                var maxsizeLarge   = SettingManager.GetValue("ImageLargeMaxsize").ToString().Split('x');
                var maxsizeMedium  = SettingManager.GetValue("ImageMediumMaxsize").ToString().Split('x');
                var maxsizeSmall   = SettingManager.GetValue("ImageSmallMaxsize").ToString().Split('x');
                var imageFilePath  = "/Uploads/images/" + fileUpload.FileName + "";
                var imageFilePathL = "/Uploads/images/(L) " + fileUpload.FileName + "";
                var imageFilePathM = "/Uploads/images/(M) " + fileUpload.FileName + "";
                var imageFilePathS = "/Uploads/images/(S) " + fileUpload.FileName + "";
                var result         = FileUpload.GenerateImageThumbnail(Image.FromStream(fileUpload.InputStream), imageFilePath);
                result = FileUpload.GenerateImageThumbnail(Image.FromStream(fileUpload.InputStream), imageFilePathL, Convert.ToInt32(maxsizeLarge[0]), Convert.ToInt32(maxsizeLarge[1]));
                result = FileUpload.GenerateImageThumbnail(Image.FromStream(fileUpload.InputStream), imageFilePathM, Convert.ToInt32(maxsizeMedium[0]), Convert.ToInt32(maxsizeMedium[1]));
                result = FileUpload.GenerateImageThumbnail(Image.FromStream(fileUpload.InputStream), imageFilePathS, Convert.ToInt32(maxsizeSmall[0]), Convert.ToInt32(maxsizeSmall[1]));
                fileUpload.InputStream.Close();
                fileUpload.InputStream.Dispose();
                if (result)
                {
                    json.result  = ResultType.Success;
                    json.message = fileUpload.FileName;
                }
            }
            return(Json(new { json }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 18
0
        public HttpResponseMessage PostData(JsonDataModel word)
        {
            int number;

            if (word.Equals(null))
            {
                JsonDataResponseModel internalserver = new JsonDataResponseModel
                {
                    code        = "00",
                    description = "500",
                    data        = ""
                };
                return(Request.CreateResponse <JsonDataResponseModel>(HttpStatusCode.InternalServerError, internalserver));
            }

            bool isNumber = int.TryParse(word.data.ToString(), out number);

            if (isNumber)
            {
                JsonDataResponseModel badresponse = new JsonDataResponseModel
                {
                    code        = "00",
                    description = "400",
                    data        = ""
                };
                return(Request.CreateResponse <JsonDataResponseModel>(HttpStatusCode.BadRequest, badresponse));
            }

            JsonDataResponseModel value = new JsonDataResponseModel
            {
                code        = "00",
                description = "OK",
                data        = word.data.ToUpper()
            };

            return(Request.CreateResponse <JsonDataResponseModel>(System.Net.HttpStatusCode.Created, value));
        }
Esempio n. 19
0
        private DataModel GetJsonDataModel(JObject json)
        {
            DataModel dynamicDataModel = new JsonDataModel();

            return(JObjectToDataModel(json, dynamicDataModel));
        }
Esempio n. 20
0
 public void Initialize(JsonDataModel jsonDataModel)
 {
     _jsonDataModel = jsonDataModel;
     _savedJsonDynamicDataSetting = _pluginSettings.GetSetting("SavedJsonDynamicDataSetting", new Dictionary <string, string>());
 }
Esempio n. 21
0
        // POST: api/body
        public IEnumerable <IEnumerable <string> > Post(JsonDataModel value)
        {
            var v = from entity in db.Entities
                    from device in db.Devices
                    from characteristic in db.Characteristic
                    where entity.Id == device.IdEntity &&
                    entity.NameOfEntity == "Корпус" &&
                    characteristic.IdCharacteristic == device.IdCharacteristic
                    select new
            {
                device.IdDevice,
                device.BrandName,
                device.Model,
                characteristic.Value1,
                characteristic.Value2,
                characteristic.Value3,
                characteristic.Value4,
                characteristic.Value5
            };

            List <List <string> > t = new List <List <string> >();

            string s = null;

            if (value.motherboard != -1)
            {
                s = (from d in db.Devices
                     from c in db.Characteristic
                     where d.IdDevice == value.motherboard && d.IdCharacteristic == c.IdCharacteristic
                     select c.Value6).Single();
            }

            foreach (var i in v)
            {
                if (value.motherboard != -1)
                {
                    string tmp = (from dr in db.Devices
                                  from c in db.Characteristic
                                  where dr.IdDevice == i.IdDevice && dr.IdCharacteristic == c.IdCharacteristic
                                  select c.Value5).Single();

                    if (!s.Equals(tmp))
                    {
                        continue;
                    }
                }

                List <string> d = new List <string>();
                d.Add(i.IdDevice.ToString());
                d.Add(i.BrandName);
                d.Add(i.Model);
                d.Add(i.Value1);
                d.Add(i.Value2);
                d.Add(i.Value3);
                d.Add(i.Value4);
                d.Add(i.Value5);

                t.Add(d);
            }

            return(t);
        }
        // POST: api/coolingSystem
        public IEnumerable <IEnumerable <string> > Post(JsonDataModel value)
        {
            var v = from entity in db.Entities
                    from device in db.Devices
                    from characteristic in db.Characteristic
                    where entity.Id == device.IdEntity &&
                    entity.NameOfEntity == "Устройство охлаждения" &&
                    characteristic.IdCharacteristic == device.IdCharacteristic
                    select new
            {
                device.IdDevice,
                device.BrandName,
                device.Model,
                characteristic.Value1,
                characteristic.Value2,
                characteristic.Value3,
                characteristic.Value4
            };

            List <List <string> > t = new List <List <string> >();

            string[] s  = null;
            string   st = null;

            if (value.motherboard != -1 || value.CPU != -1)
            {
                s = (from dtt in db.DeviceToType
                     from tp in db.Types
                     where dtt.IdDevice == (value.motherboard != -1 ? value.motherboard : value.CPU) && dtt.IdType == tp.IdType
                     select tp.Name).ToArray();

                for (int i = 0; i < s.Length; i++)
                {
                    if (Regex.IsMatch(s[i], @"Socket-\w+"))
                    {
                        st = s[i];
                        break;
                    }
                }
            }

            foreach (var i in v)
            {
                if (value.motherboard != -1 || value.CPU != -1)
                {
                    string[] tmp = (from dtt in db.DeviceToType
                                    from tp in db.Types
                                    where dtt.IdDevice == i.IdDevice && dtt.IdType == tp.IdType
                                    select tp.Name).ToArray();

                    if (Array.IndexOf(tmp, st) == -1)
                    {
                        continue;
                    }
                }

                List <string> d = new List <string>();
                d.Add(i.IdDevice.ToString());
                d.Add(i.BrandName);
                d.Add(i.Model);
                d.Add(i.Value1);
                d.Add(i.Value2);
                d.Add(i.Value3);
                d.Add(i.Value4);

                t.Add(d);
            }

            return(t);
        }
        public ConsumirApi()
        {
            var json = cliente.DownloadString(url);

            data = JsonConvert.DeserializeObject <JsonDataModel>(json);
        }
        // POST: api/motherboard
        public IEnumerable <IEnumerable <string> > Post(JsonDataModel value)
        {
            var v = from entity in db.Entities
                    from device in db.Devices
                    from characteristic in db.Characteristic
                    where entity.Id == device.IdEntity &&
                    entity.NameOfEntity == "Материнская плата" &&
                    characteristic.IdCharacteristic == device.IdCharacteristic
                    select new
            {
                device.IdDevice,
                device.BrandName,
                device.Model,
                characteristic.Value1,
                characteristic.Value2,
                characteristic.Value3,
                characteristic.Value4,
                characteristic.Value5,
                characteristic.Value6
            };

            List <List <string> > t = new List <List <string> >();

            string[] s1 = null;

            if (value.CPU != -1 || value.coolingSystem != -1)
            {
                s1 = (from dtt in db.DeviceToType
                      from tp in db.Types
                      where dtt.IdDevice == (value.CPU != -1 ? value.CPU : value.coolingSystem) && dtt.IdType == tp.IdType
                      select tp.Name).ToArray();
            }

            string s2 = null;

            if (value.body != -1)
            {
                s2 = (from d in db.Devices
                      from c in db.Characteristic
                      where d.IdDevice == value.body && d.IdCharacteristic == c.IdCharacteristic
                      select c.Value5).Single();
            }

            string[] s3 = null;
            if (value.RAM != -1)
            {
                s3 = (from dtt in db.DeviceToType
                      from tp in db.Types
                      where dtt.IdDevice == value.RAM && dtt.IdType == tp.IdType
                      select tp.Name).ToArray();
            }

            foreach (var i in v)
            {
                if (value.CPU != -1 || value.coolingSystem != -1)
                {
                    string[] tmp = (from dtt in db.DeviceToType
                                    from tp in db.Types
                                    where dtt.IdDevice == i.IdDevice && dtt.IdType == tp.IdType
                                    select tp.Name).ToArray();
                    string st = null;

                    for (int j = 0; j < tmp.Length; j++)
                    {
                        if (Regex.IsMatch(s1[j], @"Socket-\w+"))
                        {
                            st = tmp[j];
                            break;
                        }
                    }

                    if (Array.IndexOf(s1, st) == -1)
                    {
                        continue;
                    }
                }

                if (value.body != -1)
                {
                    string tmp = (from dr in db.Devices
                                  from c in db.Characteristic
                                  where dr.IdDevice == i.IdDevice && dr.IdCharacteristic == c.IdCharacteristic
                                  select c.Value6).Single();

                    if (!s2.Equals(tmp))
                    {
                        continue;
                    }
                }

                if (value.RAM != -1)
                {
                    string tmp = (from dtt in db.DeviceToType
                                  from tp in db.Types
                                  where dtt.IdDevice == i.IdDevice && dtt.IdType == tp.IdType
                                  select tp.Name).Single();

                    if (Array.IndexOf(s3, tmp) == -1)
                    {
                        continue;
                    }
                }

                List <string> d = new List <string>();
                d.Add(i.IdDevice.ToString());
                d.Add(i.BrandName);
                d.Add(i.Model);
                d.Add(i.Value1);
                d.Add(i.Value2);
                d.Add(i.Value3);
                d.Add(i.Value4);
                d.Add(i.Value5);
                d.Add(i.Value6);

                t.Add(d);
            }

            return(t);
        }
Esempio n. 25
0
        //[ValidateAntiForgeryToken]
        public IActionResult UserLogin([FromBody] JsonDataModel data)
        {
            JsonResultHelper result      = new JsonResultHelper();
            UserLoginView    model       = data.model;
            User             currentUser = _userRepository.CheckLogin(model.Email, model.Password);
            UserViewModel    _UserModel  = null;// _mapper.Map<User, UserViewModel>(currentUser);

            if (currentUser != null)
            {
                if (currentUser.Activation == true)
                {
                    UserViewModel userrole = _mapper.Map <User, UserViewModel>(currentUser);
                    if (userrole.UserRoleName.FirstOrDefault() == UserRoleName.Admin || userrole.UserRoleName.FirstOrDefault() == UserRoleName.Producers)
                    {
                        var claims = new List <Claim>
                        {
                            new Claim("UserId", currentUser.Id.ToString()),
                            new Claim("CustomCache", "0")
                        };
                        ClaimsIdentity  userIdentity = new ClaimsIdentity(claims, "login");
                        ClaimsPrincipal principal    = new ClaimsPrincipal(userIdentity);
                        HttpContext.SignInAsync(principal);
                        HttpContext.User = principal;
                        result.success   = true;
                        result.Msg.Add(_stringLocalizer.GetString("Admin.Login Success"));
                        _UserModel = _mapper.Map <User, UserViewModel>(currentUser);
                    }
                    else
                    {
                        result.success = false;
                        result.Msg.Add(_stringLocalizer.GetString("Admin.YouAreNotAdmin"));
                        return(Json(result));
                    }
                }
                else
                {
                    result.success = false;
                    result.Msg.Add(_stringLocalizer.GetString("Admin.InactiveAccount"));
                    return(Json(result));
                }
            }
            else
            {
                result.success = false;
                result.Msg.Add(_stringLocalizer.GetString("Admin.LoginFailed.Pleaseentercorrectcredentials"));
                return(Json(result));
            }

            if (_UserModel != null)
            {
                if (_UserModel.Id > 0)
                {
                    if (_UserModel.UserRoleName.FirstOrDefault() == "Admin" || _UserModel.UserRoleName.FirstOrDefault() == "Producers")
                    {
                        result.url = Url.Action("Index", "Dashboard");
                        return(Json(result));
                    }
                }
            }

            if (!string.IsNullOrEmpty(model.returnUrl))
            {
                if (Url.IsLocalUrl(model.returnUrl))
                {
                    result.url = model.returnUrl;
                    return(Json(result));
                }
            }

            //Defualt Rout
            //result.url = Url.Action("Index", "Dashboard", new { Area = "Admin" });
            //return Json(result);
            return(View(model));
        }
Esempio n. 26
0
        public ActionResult Index()
        {
            // Read JSON file and deserialize it to object

            string        fileName       = "json.json";
            string        filePath       = Server.MapPath("JSONFile");
            JsonDataModel videoDataModel = new JsonDataModel();
            Contentvideo  contvd         = new Contentvideo();


            // read json and build object
            if (System.IO.File.Exists(Path.Combine(filePath, fileName)))
            {
                string fileContent;

                // read JSON directly from a file
                using (StreamReader file = System.IO.File.OpenText(Path.Combine(filePath, fileName)))
                {
                    fileContent = file.ReadToEnd();
                }
                videoDataModel = JsonConvert.DeserializeObject <JsonDataModel>(fileContent);
            }
            // write to csv file using csvhelper


            // 1. Extract all images with id and imageURL
            using (var writer = new StreamWriter(System.IO.Path.Combine(filePath, "ImageContent.csv")))
            {
                using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                {
                    var imagerecords = videoDataModel.data.Select(x => new ImageDataModel()
                    {
                        Id = x.id,
                        contentimgUrl_Val = x.contentImageUrl,
                    }).ToList();

                    csv.WriteRecords <ImageDataModel>(imagerecords);
                }
            }
            // 2. Extract Video details like ID, Title, Link, Highest video link

            using (var writer = new StreamWriter(System.IO.Path.Combine(filePath, "VideoContent.csv")))
            {
                using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                {
                    var videorecords = videoDataModel.data.Select(x => new VideoDetailDataModel()
                    {
                        VideoId = x.id,
                        Title   = x.contentTitle,
                        Link    = x.url,
                        HighestResolutionVideoUrl = x.ampPreviewUrl
                    }).ToList();
                    csv.WriteRecords <VideoDetailDataModel>(videorecords);
                }
            }

            // jw Player Platefrom API's
            var jwplatformApi = new Api("aeKR6BF5", "E7Tz1ntUABVFvjPJg0oohVNx");
            var requestParams = new Dictionary <string, string>();

            requestParams.Add("video_key", "video_key");
            requestParams.Add("MEDIA_ID", "0mjomTb5");

            // Asynchronously
            //var response = await jwplatformApi.GetRequestAsync("/videos/show", requestParams);

            // Synchronously
            var response = jwplatformApi.GetRequest("/videos/show", requestParams);

            return(View());
        }
Esempio n. 27
0
 public static async Task LogJsonData(this JsonDataModel m)
 {
     await client.PostAsync("Log/LogJsonData", m.SERIALIZE_CONTENT());
 }