Ejemplo n.º 1
0
        public ClientUploadResult UserInfoUploadForAndroid(MobileParam mobileParams, ClientData clientData)
        {
            Random random = new Random();
            var result = new ClientUploadResult
            {
                NextUserUploadTime = DateTime.Now.AddSeconds((double)ConfigKeys.DEFAULT_NEXT_USER_UPLOAD_TIMESPAN.ConfigValue().ToInt32()).AddMilliseconds(random.Next(86300000))
            };

            if (string.IsNullOrWhiteSpace(mobileParams.IMSI) || clientData == null)
            {
                return result;
            }

            var userUploadInfo = GetUserUploadInfo(clientData, mobileParams.IMSI);

            SaveUserUploadInfos(mobileParams, userUploadInfo);

            return result;
        }
Ejemplo n.º 2
0
        public ActionResult AndroidUserInfoUpload(string imsi)
        {
            var mobileParams = GetMobileParam();

            ClientData clientData = new ClientData();

            try
            {
                clientData = JsonConvert.DeserializeObject<ClientData>(mobileParams.RequestBody);
            }
            catch
            {
                clientData = null;
            }

            Func<bool> checkParameter = () => this.CheckRequiredParams(imsi)() && !string.IsNullOrEmpty(mobileParams.RequestBody) && clientData != null;

            Func<ClientUploadResult> userInfoUploadForAndroid = () => UserInteractService.UserInfoUploadForAndroid(mobileParams, clientData);

            var actionResult = BuildResult(checkParameter, userInfoUploadForAndroid);

            return Content(actionResult.ToString());
        }
Ejemplo n.º 3
0
        public ActionResult UploadExample()
        {
            var clientData = new ClientData
            {
                From = DateTime.Now.Date.AddDays(-2),
                To = DateTime.Now.Date,
                Apps = new List<ClientApplication>
                {
                    new ClientApplication{PackageName="com.tyd.weather", VersionName="1.2.1", VersionCode = "21", MD5="5454212125454asfda3", Action=0},
                    new ClientApplication{PackageName="com.tyd.music", VersionName="2.2.1", VersionCode = "21", MD5="jdlfjalj459895894", Action=0}
                },
                Traffics = new List<ClientTraffic>
                {
                    new ClientTraffic{PackageName="com.tyd.weather", Traffic=10024},
                    new ClientTraffic{PackageName="com.tyd.music", Traffic=23232},
                },
                Activities = new List<ClientActivity> {
                    new ClientActivity{ PackageName="com.tyd.weather", TimesPerHour="0|0|0|0|0|0|0|0|0|0|22|3|3|0|2|2|2|2|2|2|2|0|0|0"},
                    new ClientActivity{ PackageName="com.tyd.music", TimesPerHour="0|0|0|0|0|0|0|0|0|0|22|3|3|0|2|2|2|2|2|2|2|0|0|0"},
                }
            };

            //var commonResult = BuildResult<ClientData>(() => true, () => clientData);
            return Content(JsonConvert.SerializeObject(clientData));
        }
Ejemplo n.º 4
0
        internal UserUploadInfo GetUserUploadInfo(ClientData clientData, string imsi)
        {
            UserUploadInfo ret = new UserUploadInfo();

            #region Activity
            if (clientData.Activities != null)
            {
                ret.ActivityInfos = new List<AndroidUserAppActivityInfo>();
                foreach (var a in clientData.Activities)
                {
                    if (!string.IsNullOrEmpty(a.TimesPerHour))
                    {
                        var timesPerHour = a.TimesPerHour.Split(ASCII.VERTICAL_BAR_CHAR);
                        if (timesPerHour.Length >= 24)
                        {
                            ret.ActivityInfos.Add(new AndroidUserAppActivityInfo
                            {
                                IMSI = imsi,
                                PackageName = a.PackageName,
                                One = timesPerHour[0].ToInt32(),
                                Two = timesPerHour[1].ToInt32(),
                                Three = timesPerHour[2].ToInt32(),
                                Four = timesPerHour[3].ToInt32(),
                                Five = timesPerHour[4].ToInt32(),
                                Six = timesPerHour[5].ToInt32(),
                                Seven = timesPerHour[6].ToInt32(),
                                Eight = timesPerHour[7].ToInt32(),
                                Nine = timesPerHour[8].ToInt32(),
                                Ten = timesPerHour[9].ToInt32(),
                                Eleven = timesPerHour[10].ToInt32(),
                                Twelve = timesPerHour[11].ToInt32(),
                                Thirteen = timesPerHour[12].ToInt32(),
                                Fourteen = timesPerHour[13].ToInt32(),
                                Fifteen = timesPerHour[14].ToInt32(),
                                Sixteen = timesPerHour[15].ToInt32(),
                                SevenTeen = timesPerHour[16].ToInt32(),
                                Eighteen = timesPerHour[17].ToInt32(),
                                Nineteen = timesPerHour[18].ToInt32(),
                                Twenty = timesPerHour[19].ToInt32(),
                                TwentyOne = timesPerHour[20].ToInt32(),
                                TwentyTwo = timesPerHour[21].ToInt32(),
                                TwentyThree = timesPerHour[22].ToInt32(),
                                TwentyFour = timesPerHour[23].ToInt32(),
                                FromDate = clientData.From,
                                ToDate = clientData.To
                            });
                        }
                    }
                }
            }
            #endregion

            #region App Info
            if (clientData.Apps != null)
            {
                ret.AppInfos = new List<AndroidUserAppInfoOp>();
                foreach (var a in clientData.Apps)
                {
                    ret.AppInfos.Add(new AndroidUserAppInfoOp
                    {
                        IsAdd = a.Action == 0,
                        AndroidUserAppInfo = new AndroidUserAppInfo {
                            IMSI = imsi,
                            PackageName = a.PackageName,
                            VersionCode = a.VersionCode,
                            VersionName = a.VersionName,
                            MD5 = a.MD5,
                        }
                    });
                }
            }
            #endregion

            #region Traffic
            if (clientData.Traffics != null)
            {
                ret.AppTrafficInfos = new List<AndroidUserAppTrafficInfo>();
                foreach (var a in clientData.Traffics)
                {
                    ret.AppTrafficInfos.Add(new AndroidUserAppTrafficInfo {
                        IMSI = imsi,
                        PackageName = a.PackageName,
                        Traffic = a.Traffic,
                        FromDate = clientData.From,
                        ToDate = clientData.To
                    });
                }
            }
            #endregion

            return ret;
        }