示例#1
0
        public bool UpdateAppInformation(AppInformation appInfo)
        {
            bool UpdateFlag = false;
            List <SqlParameter> commandParameters = new List <SqlParameter>();

            commandParameters.Add(new SqlParameter("@DeviceID", appInfo.DeviceID));
            commandParameters.Add(new SqlParameter("@Version", appInfo.Version));
            commandParameters.Add(new SqlParameter("@Rating", appInfo.Rating));
            commandParameters.Add(new SqlParameter("@ReviewCount", appInfo.ReviewCount));
            commandParameters.Add(new SqlParameter("@ReleaseDate", appInfo.ReleaseDate));
            commandParameters.Add(new SqlParameter("@DevelopedBy", appInfo.DevelopedBy));
            commandParameters.Add(new SqlParameter("@Email", appInfo.Email));
            commandParameters.Add(new SqlParameter("@OneStarCount", appInfo.OneStarCount));
            commandParameters.Add(new SqlParameter("@TwoStarCount", appInfo.TwoStarCount));
            commandParameters.Add(new SqlParameter("@ThreeStarCount", appInfo.ThreeStarCount));
            commandParameters.Add(new SqlParameter("@FourStarCount", appInfo.FourStarCount));
            commandParameters.Add(new SqlParameter("@FiveStarCount", appInfo.FiveStarCount));
            try
            {
                int i = SqlHelper.ExecuteNonQuery(this.connectionString, CommandType.StoredProcedure, "SP_UpdateAppInformation", commandParameters.ToArray());
            }
            catch (Exception Ex)
            {
            }
            return(UpdateFlag);
        }
示例#2
0
        public AppInformation GetAppInformation(string JSONString)
        {
            JToken         token   = JObject.Parse(JSONString);
            AppInformation appInfo = new AppInformation();

            appInfo.DeviceID = (string)token.SelectToken("content.application_id");
            var VersionArray = token.SelectToken("content.store_info.versions") as JArray;

            appInfo.Version = VersionArray.Select(v => (string)v["version"]).First();
            string _releaseDate = VersionArray.Select(v => (string)v["release_date"]).First();
            string _date        = _releaseDate.Trim().Split(new char[0])[0].ToString();

            appInfo.ReleaseDate = DateTime.Parse(_date).ToShortDateString();
            appInfo.DevelopedBy = (string)token.SelectToken("content.developer.name");
            appInfo.Email       = (string)token.SelectToken("content.developer.email");
            decimal _Rating = (decimal)token.SelectToken("content.ratings.average");

            appInfo.Rating         = Math.Round(_Rating, 3);
            appInfo.ReviewCount    = (int)token.SelectToken("content.ratings.count");
            appInfo.OneStarCount   = (int)token.SelectToken("content.ratings.star_count.1");
            appInfo.TwoStarCount   = (int)token.SelectToken("content.ratings.star_count.2");
            appInfo.ThreeStarCount = (int)token.SelectToken("content.ratings.star_count.3");
            appInfo.FourStarCount  = (int)token.SelectToken("content.ratings.star_count.4");
            appInfo.FiveStarCount  = (int)token.SelectToken("content.ratings.star_count.5");
            return(appInfo);
        }
示例#3
0
        public bool syncData()
        {
            // 1. Check Activity Log for last sync
            // 2. If Last update is not today, Call the API function to fetch latest data
            // 3. Update the tables viz., AppInformation, MasterAppData and Activity Log

            DBManager dbManager = new DBManager();

            List <string> AppleDeviceIDList = ConfigurationManager.AppSettings["AppleDeviceIDList"].Split(new char[] { ',' }).ToList();
            Apple         apple             = new Apple();

            Parallel.ForEach(AppleDeviceIDList, AppleDeviceID =>
            {
                if (dbManager.isSyncRequired(AppleDeviceID))
                {
                    string JSONString            = apple.GetAPIResponse(AppleDeviceID);
                    string AppID                 = dbManager.GetAppleAppID(AppleDeviceID);
                    DataTable masterAppDataTable = apple.GetMasterAppData(JSONString, AppID);
                    dbManager.UpdateMasterAppData(masterAppDataTable, AppleDeviceID);
                    AppInformation appInfo = apple.GetAppInformation(JSONString);
                    dbManager.UpdateAppInformation(appInfo);
                }
            });

            List <string> AndroidDeviceIDList = ConfigurationManager.AppSettings["AndroidDeviceIDList"].Split(new char[] { ',' }).ToList();
            Android       android             = new Android();

            Parallel.ForEach(AndroidDeviceIDList, AndroidDeviceID =>
            {
                if (dbManager.isSyncRequired(AndroidDeviceID))
                {
                    string JSONString            = android.GetAPIResponse(AndroidDeviceID);
                    string AppID                 = dbManager.GetAndroidAppID(AndroidDeviceID);
                    DataTable masterAppDataTable = android.GetMasterAppData(JSONString, AppID);
                    dbManager.UpdateMasterAppData(masterAppDataTable, AndroidDeviceID);
                    AppInformation appInfo = android.GetAppInformation(JSONString);
                    dbManager.UpdateAppInformation(appInfo);
                }
            });

            return(true);
        }