Ejemplo n.º 1
0
    private bool statChannelByInterval(ChannelInfo info)
    {
        //beginStat("渠道[{0}]开始统计", info.m_channelName);

        ParamStat param = new ParamStat();

        param.m_channel = info;

        StatResult result = new StatResult();

        foreach (var stat in m_statModule)
        {
            if (stat.Key == StatFlag.STAT_FLAG_REMAIN)
            {
                continue;
            }
            if (stat.Key == StatFlag.STAT_LTV)
            {
                continue;
            }

            stat.Value.doStat(param, result);
        }

        IMongoQuery imq = null;
        Dictionary <string, object> newData = getData(result, info, ref imq);

        string str = MongodbAccount.Instance.ExecuteStoreByQuery(TableName.CHANNEL_TD, imq, newData);

        //endStat("渠道[{0}]结束统计", info.m_channelName);
        return(str == string.Empty);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 文件存在
 /// </summary>
 /// <param name="status"></param>
 /// <returns></returns>
 public static bool HasFile(this StatResult status)
 {
     return(status.IsOk() &&
            status.Result != null &&
            status.Result.Fsize > 0 &&
            ValidateHelper.IsPlumpString(status.Result.Hash));
 }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(
            //    "f:\\mmf.dat", FileMode.Create, "mmf", ((long)10000 * (long)10000)))
            //{
            //    MemoryMappedViewAccessor acc = mmf.CreateViewAccessor();
            //}
            string      filename = @"G:\1.xlsx";
            IStatResult result   = new StatResult("统计时间:", new string[] { "时间", "待验证数据", "验证数据" }, new string[][] { new string[] { "2013/3/1", "5.4", "4.9" }, new string[] { "2013/3/2", "3.9", "2.8" }, new string[] { "2013/3/3", "8.9", "8.8" }, new string[] { "2013/3/4", "7.8", "7.4" } });

            try
            {
                using (StatResultToChartInExcelFile excelControl = new StatResultToChartInExcelFile())
                {
                    excelControl.Init(masExcelDrawStatType.xlXYScatter);
                    excelControl.Add("气溶胶产品数据对比", result, true, 1, false, result.Columns[1], result.Columns[2
                                     ]);
                    if (!filename.ToUpper().EndsWith(".XLSX"))
                    {
                        filename += ".XLSX";
                    }
                    excelControl.SaveFile(filename);
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 4
0
    public override void doStat(object param, StatResult result)
    {
        ParamStat p = (ParamStat)param;

        ChannelInfo cinfo = p.m_channel;

        DateTime    mint = cinfo.m_statDay.Date.AddDays(-1), maxt = cinfo.m_statDay.Date;
        IMongoQuery imq1 = Query.LT("time", BsonValue.Create(maxt));
        IMongoQuery imq2 = Query.GTE("time", BsonValue.Create(mint));
        IMongoQuery imq3 = Query.EQ("channel", BsonValue.Create(cinfo.m_channelNum));

        IMongoQuery imq = Query.And(imq1, imq2, imq3);

        MapReduceResult mapResult = MongodbPayment.Instance.executeMapReduce(cinfo.m_paymentTable,
                                                                             imq,
                                                                             MapReduceTable.getMap("recharge"),
                                                                             MapReduceTable.getReduce("recharge"));

        if (mapResult != null)
        {
            IEnumerable <BsonDocument> bson = mapResult.GetResults();
            foreach (BsonDocument d in bson)
            {
                BsonValue resValue = d["value"];
                result.m_totalIncome += resValue["total"].ToInt32();
                result.m_rechargePersonNum++;
                result.m_rechargeCount += resValue["rechargeCount"].ToInt32();
            }
        }

        statPaytype(imq, cinfo);
    }
Ejemplo n.º 5
0
        public static object GetFileStats(string path)
        {
            StatResult sr = new StatResult();

            try {
                sr.atime = (long)Directory.GetLastAccessTime(path).Subtract(DateTime.MinValue).TotalSeconds;
                sr.ctime = (long)Directory.GetCreationTime(path).Subtract(DateTime.MinValue).TotalSeconds;
                sr.mtime = (long)Directory.GetLastWriteTime(path).Subtract(DateTime.MinValue).TotalSeconds;

                if (Directory.Exists(path))
                {
                    sr.mode = 0x4000;
                }
                else if (File.Exists(path))
                {
                    FileInfo fi = new FileInfo(path);
                    sr.size = fi.Length;
                    sr.mode = 0x8000; //@TODO - Set other valid mode types (S_IFCHR, S_IFBLK, S_IFIFO, S_IFLNK, S_IFSOCK) (to the degree that they apply)
                }
                else
                {
                    throw new IOException("file does not exist");
                }
            } catch (Exception e) {
                throw ExceptionConverter.CreateThrowable(error, e.Message);
            }

            return(sr);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取文件信息
        /// </summary>
        /// <param name="key">文件key</param>
        /// <returns></returns>
        public FileInfoDto Get(string key)
        {
            StatResult statRet = GetBucketManager().Stat(QiNiuConfig.Bucket, key);

            if (statRet.Code != (int)HttpCode.OK)
            {
                return(new FileInfoDto()
                {
                    Success = false,
                    Msg = statRet.ToString()
                });
            }

            return(new FileInfoDto()
            {
                Size = statRet.Result.Fsize,
                Hash = statRet.Result.Hash,
                MimeType = statRet.Result.MimeType,
                PutTime = statRet.Result.PutTime,
                FileType = statRet.Result.FileType,
                Success = true,
                Host = QiNiuConfig.Host,
                Path = key,
                Msg = "成功"
            });
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 文件存在
 /// </summary>
 /// <param name="status"></param>
 /// <returns></returns>
 public static bool HasFile(this StatResult status)
 {
     return(status.IsOk() &&
            status.Result != null &&
            status.Result.Fsize > 0 &&
            status.Result.Hash?.Length > 0);
 }
Ejemplo n.º 8
0
 // 统计30日留存
 private void stat30DayRemain(ParamStat param, StatResult result)
 {
     queryAccList(param, 30);
     statXDayRemain(param, m_regeditAccList, ref result.m_30DayRemainCountTmp);
     statXDayRemain(param, m_regeditWithRecharge, ref result.m_30DayRemainCountRechargeTmp);
     statXDayDevRemain(param, 30, ref result.m_30DayDevRemainCountTmp);
 }
Ejemplo n.º 9
0
        private IExtractResult StateUHPI(int NormalLevel, string[] files, Dictionary <string, StatInfo> result)
        {
            float           sum        = 0;
            List <string[]> valueItems = new List <string[]>();
            string          DateStr    = GetStringArgument("DateStr");

            foreach (string key in result.Keys)
            {
                foreach (UInt16 level in result[key].UHPI.Keys)
                {
                    sum += level * ((float)result[key].UHPI[level] / result[key].totalCount);
                }
                valueItems.Add(new string[] { DataIdentifyMatcher.GetOrbitDateTime(key).AddHours(8).ToString(DateStr),
                                              Math.Round((1f / NormalLevel) * sum, 2).ToString() });
                sum = 0;
            }
            string title = "统计日期:" + DateTime.Now.ToShortDateString();

            string[]          columns    = new string[] { "日期", "比例指数" };
            IStatResult       statResult = new StatResult(title, columns, valueItems.ToArray());
            string            filename   = StatResultToFile(files, statResult, "UHE", "UHPI", "比例指数", string.Empty, 1, false);
            FileExtractResult fileResult = new FileExtractResult("UHPI", filename);

            fileResult.Add2Workspace = true;
            fileResult.SetDispaly(false);
            return(fileResult);
        }
Ejemplo n.º 10
0
    // 更新往日LTV价值
    private void updateTotalRecharge(ChannelInfo info, int days, StatResult result)
    {
        IMongoQuery imq1 = Query.EQ("genTime", StatBase.getRemainRegTime(info, days));
        IMongoQuery imq2 = Query.EQ("channel", BsonValue.Create(info.m_channelNum));
        IMongoQuery imq  = Query.And(imq1, imq2);

        bool res = MongodbAccount.Instance.KeyExistsByQuery(TableName.CHANNEL_TD, imq);

        if (res)
        {
            Dictionary <string, object> data = new Dictionary <string, object>();
            switch (days)
            {
            case 1:
            {
                data.Add("Day1TotalRecharge", result.m_1DayTotalRechargeTmp);
            }
            break;

            case 3:
            {
                data.Add("Day3TotalRecharge", result.m_3DayTotalRechargeTmp);
            }
            break;

            case 7:
            {
                data.Add("Day7TotalRecharge", result.m_7DayTotalRechargeTmp);
            }
            break;

            case 14:
            {
                data.Add("Day14TotalRecharge", result.m_14DayTotalRechargeTmp);
            }
            break;

            case 30:
            {
                data.Add("Day30TotalRecharge", result.m_30DayTotalRechargeTmp);
            }
            break;

            case 60:
            {
                data.Add("Day60TotalRecharge", result.m_60DayTotalRechargeTmp);
            }
            break;

            case 90:
            {
                data.Add("Day90TotalRecharge", result.m_90DayTotalRechargeTmp);
            }
            break;
            }

            MongodbAccount.Instance.ExecuteUpdateByQuery(TableName.CHANNEL_TD, imq, data);
        }
    }
        private IExtractResult StaticAreaByDegree(List <string> rangeList, string fileName, string outputIdentify)
        {
            IRasterDataProvider dataProvider  = null;
            IRasterDataProvider cloudProvider = null;
            List <string[]>     resultList    = new List <string[]>();

            try
            {
                dataProvider = GeoDataDriver.Open(fileName) as IRasterDataProvider;
                //获取分区AOI
                Dictionary <string, int[]> aois = GetAOIForRaster(dataProvider);
                if (aois != null && aois.Count > 0)
                {
                    foreach (string region in aois.Keys)
                    {
                        List <string[]> result = StaticAreaByRegions(rangeList, cloudProvider, dataProvider, aois[region], region);
                        if (result != null)
                        {
                            resultList.AddRange(result);
                        }
                    }
                }
                //整个区域
                List <string[]> statresult = StaticAreaByRegions(rangeList, resultList, aois.Count, "整个湖区");
                if (statresult != null)
                {
                    resultList.AddRange(statresult);
                }

                if (resultList != null && resultList.Count != 0)
                {
                    float          resolution = dataProvider.ResolutionX;
                    string         title      = "统计日期:" + DateTime.Now.ToShortDateString();
                    RasterIdentify id         = new RasterIdentify(fileName);
                    if (id.OrbitDateTime != null)
                    {
                        title += "    轨道日期:" + id.OrbitDateTime.ToShortDateString();
                    }
                    string[]    columns  = new string[] { "区域名称", "覆盖度范围", "总覆盖面积(平方公里)", "实际覆盖面积(平方公里)" };
                    IStatResult result   = new StatResult(title, columns, resultList.ToArray());
                    string      filename = StatResultToFile(new string[] { fileName }, result, "BAG", outputIdentify, "蓝藻按强度统计面积", null, 1, false, 0);
                    return(new FileExtractResult("BCDA", filename));
                }
            }
            finally
            {
                if (cloudProvider != null)
                {
                    cloudProvider.Dispose();
                }
                if (dataProvider != null)
                {
                    dataProvider.Dispose();
                }
            }
            return(null);
        }
    private void statDeviceActivation(ChannelInfo cinfo, StatResult result, DateTime mint, DateTime maxt)
    {
        IMongoQuery imq1 = Query.LT("active_time", BsonValue.Create(maxt));
        IMongoQuery imq2 = Query.GTE("active_time", BsonValue.Create(mint));
        IMongoQuery imq3 = Query.EQ("channel", BsonValue.Create(cinfo.m_channelNum));
        IMongoQuery imq  = Query.And(imq1, imq2, imq3);

        result.m_deviceActivationCount = (int)MongodbAccount.Instance.ExecuteGetCount(cinfo.m_deviceActivationTable, imq);
    }
    public override void doStat(object param, StatResult result)
    {
        ParamStat   p = (ParamStat)param;
        ChannelInfo cinfo = p.m_channel;
        DateTime    mint = cinfo.m_statDay.Date.AddDays(-1), maxt = cinfo.m_statDay.Date;

        statRegeditCount(cinfo, result, mint, maxt);
        statDeviceActivation(cinfo, result, mint, maxt);
    }
Ejemplo n.º 14
0
    public override void doStat(object param, StatResult result)
    {
        ParamStat p = (ParamStat)param;

        stat2DayRemain(p, result);
        stat3DayRemain(p, result);
        stat7DayRemain(p, result);
        stat30DayRemain(p, result);
    }
Ejemplo n.º 15
0
    private bool statChannel(ChannelInfo info)
    {
        if (!StatBase.canStat(info))
        {
            return(false);
        }

        ParamStat param = new ParamStat();

        param.m_channel = info;

        StatResult result = new StatResult();

        foreach (var stat in m_statModule.Values)
        {
            stat.doStat(param, result);
        }

        Dictionary <string, object> newData = new Dictionary <string, object>();

        newData.Add("genTime", info.m_statDay.Date.AddDays(-1));
        newData.Add("channel", info.m_channelNum);

        newData.Add("regeditCount", result.m_regeditCount);
        newData.Add("deviceActivationCount", result.m_deviceActivationCount);
        newData.Add("activeCount", result.m_activeCount);

        newData.Add("totalIncome", result.m_totalIncome);
        newData.Add("rechargePersonNum", result.m_rechargePersonNum);
        newData.Add("rechargeCount", result.m_rechargeCount);

        // newData.Add("2DayRegeditCount", result.m_2DayRegeditCount);
        newData.Add("2DayRemainCount", result.m_2DayRemainCount);

        // newData.Add("3DayRegeditCount", result.m_3DayRegeditCount);
        newData.Add("3DayRemainCount", result.m_3DayRemainCount);

        // newData.Add("7DayRegeditCount", result.m_7DayRegeditCount);
        newData.Add("7DayRemainCount", result.m_7DayRemainCount);

        //newData.Add("30DayRegeditCount", result.m_30DayRegeditCount);
        newData.Add("30DayRemainCount", result.m_30DayRemainCount);

        IMongoQuery imq1 = Query.EQ("genTime", BsonValue.Create(info.m_statDay.Date.AddDays(-1)));
        IMongoQuery imq2 = Query.EQ("channel", BsonValue.Create(info.m_channelNum));
        IMongoQuery imq  = Query.And(imq1, imq2);

        updateRemain(info, 1, result);
        updateRemain(info, 3, result);
        updateRemain(info, 7, result);
        updateRemain(info, 30, result);

        string str = MongodbAccount.Instance.ExecuteStoreByQuery(TableName.CHANNEL_TD, imq, newData);

        return(str == string.Empty);
    }
Ejemplo n.º 16
0
        /// <summary>
        /// 空间文件的stat(获取文件基本信息)操作
        /// </summary>
        public static void stat()
        {
            Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);

            string bucket = "BUCKET";
            string key    = "KEY";

            BucketManager bm     = new BucketManager(mac);
            StatResult    result = bm.stat(bucket, key);
        }
Ejemplo n.º 17
0
        public HttpResult GetInfo(string fileName)
        {
            Mac           mac    = new Mac(AccessKey, SecretKey);
            string        bucket = SpaceName;
            string        key    = fileName;
            BucketManager bm     = new BucketManager(mac);
            StatResult    result = bm.Stat(bucket, key);

            return(result);
        }
Ejemplo n.º 18
0
        public void StatTest()
        {
            Mac           mac    = new Mac(AccessKey, SecretKey);
            BucketManager target = new BucketManager(mac);
            StatResult    result = target.Stat(Bucket1, FileKey1);

            bool cond = (result.Code == (int)HttpCode.OK ||
                         result.Code == (int)HttpCode.BUCKET_NOT_EXIST ||
                         result.Code == (int)HttpCode.FILE_NOT_EXIST);

            Assert.IsTrue(cond);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 使用stat模拟操作来检查Account是否正确
        /// </summary>
        /// <returns></returns>
        private bool ValidateAccount(Account account)
        {
            Dispatcher.Invoke(new Action(delegate
            {
                this.SettingsErrorTextBlock.Text = "";
            }));

            //check ak & sk validity
            Mac           mac           = new Mac(account.AccessKey, account.SecretKey);
            BucketManager bucketManager = new BucketManager(mac);

            StatResult statResult = bucketManager.stat("NONE_EXIST_BUCKET", "NONE_EXIST_KEY");

            if (statResult.ResponseInfo.isNetworkBroken())
            {
                Log.Error("stat file network error, " + statResult.ResponseInfo.ToString());
                Dispatcher.Invoke(new Action(delegate
                {
                    this.SettingsErrorTextBlock.Text = "网络故障";
                }));
            }
            else
            {
                if (statResult.ResponseInfo.StatusCode == 401)
                {
                    Log.Error("ak & sk wrong");
                    Dispatcher.Invoke(new Action(delegate
                    {
                        this.SettingsErrorTextBlock.Text = "AK 或 SK 设置不正确";
                    }));
                }
                else if (statResult.ResponseInfo.StatusCode == 612 || statResult.ResponseInfo.StatusCode == 631)
                {
                    Log.Info("ak & sk is valid");
                    Dispatcher.Invoke(new Action(delegate
                    {
                        this.SettingsErrorTextBlock.Text = "";
                        this.mainWindow.GotoHomePage();
                    }));
                }
                else
                {
                    Log.Error(string.Format("valid ak&sk unknown error, {0}:{1}:{2}:{3}", statResult.ResponseInfo.StatusCode,
                                            statResult.ResponseInfo.Error, statResult.ResponseInfo.ReqId, statResult.Response));
                    Dispatcher.Invoke(new Action(delegate
                    {
                        this.SettingsErrorTextBlock.Text = "未知错误,请联系七牛";
                    }));
                }
            }

            return(true);
        }
Ejemplo n.º 20
0
    public override void doStat(object param, StatResult result)
    {
        ParamStat p = (ParamStat)param;

        statXDayTotalRecharge(p, 0, ref result.m_newAccIncome, result);
        statXDayTotalRecharge(p, 1, ref result.m_1DayTotalRechargeTmp);
        statXDayTotalRecharge(p, 3, ref result.m_3DayTotalRechargeTmp);
        statXDayTotalRecharge(p, 7, ref result.m_7DayTotalRechargeTmp);
        statXDayTotalRecharge(p, 14, ref result.m_14DayTotalRechargeTmp);
        statXDayTotalRecharge(p, 30, ref result.m_30DayTotalRechargeTmp);
        statXDayTotalRecharge(p, 60, ref result.m_60DayTotalRechargeTmp);
        statXDayTotalRecharge(p, 90, ref result.m_90DayTotalRechargeTmp);
    }
Ejemplo n.º 21
0
        /// <summary>
        /// 空间文件的stat(获取文件基本信息)操作
        /// </summary>
        public static void stat()
        {
            Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);

            string bucket = "test";
            string key    = "L-1.avi";

            BucketManager bm = new BucketManager(mac);

            StatResult result = bm.Stat(bucket, key);

            Console.WriteLine(result);
        }
Ejemplo n.º 22
0
        public StatResult <Stat> AddStat(TeamGame teamGame, Player player, GameTime gameTime, StatType statType)
        {
            Stat stat = CreateGameEvent <Stat>(teamGame, gameTime);

            // Create the stat
            stat.StatTypeId = statType.Id;
            stat.StatName   = statType.StatName;
            // Id for Team and Game were already set by CreateGameEvent
            stat.Team = teamGame.Team;
            stat.Game = teamGame.Game;
            // Lineup has to exist
            stat.Lineup   = teamGame.Lineups.Last();
            stat.LineupId = stat.Lineup.Id;
            // Player could be null for Team stats
            stat.Player = player;
            if (stat.Player != null)
            {
                stat.PlayerId = stat.Player.Id;
            }
            // Possession could be null if it happens before a team estiblishes possession
            stat.Possession = teamGame.Game.Possessions.LastOrDefault();
            if (stat.Possession != null)
            {
                stat.PossessionId = stat.Possession.Id;
            }

            AddStatSummary(teamGame, stat);

            PlayerGame playerGame = teamGame.Players.FirstOrDefault(teamPlayer => teamPlayer.Player == player);

            if (playerGame == null)
            {
                throw new PlayerGameNotFoundException();
            }
            AddStatSummary(playerGame, stat);

            if (statType.WillEndPossession)
            {
                ChangePossession(teamGame.Game, gameTime);
            }

            StatResult <Stat> result = new StatResult <Stat>()
            {
                DependentStats = statType.DependentStats,
                Stat           = stat,
            };

            return(result);
        }
        public ActionResult Tjt()
        {
            StatManager statManager = new StatManager();

            StatResult model = statManager.GetStatResult();

            if (model != null)
            {
                return(View(model));
            }
            else
            {
                return(Redirect("/"));
            }
        }
Ejemplo n.º 24
0
    Dictionary <string, object> getData(StatResult result, ChannelInfo info, ref IMongoQuery imq)
    {
        Dictionary <string, object> newData = new Dictionary <string, object>();

        newData.Add("genTime", info.m_statDay.Date.AddDays(-1));
        newData.Add("channel", info.m_channelNum);

        newData.Add("regeditCount", result.m_regeditCount);
        newData.Add("deviceActivationCount", result.m_deviceActivationCount);
        newData.Add("activeCount", result.m_activeCount);

        newData.Add("totalIncome", result.m_totalIncome);
        newData.Add("rechargePersonNum", result.m_rechargePersonNum);
        newData.Add("rechargeCount", result.m_rechargeCount);

        newData.Add("newAccIncome", result.m_newAccIncome);
        newData.Add("newAccRechargePersonNum", result.m_newAccRechargePersonNum);

        newData.Add("2DayRemainCount", result.m_2DayRemainCount);

        newData.Add("3DayRemainCount", result.m_3DayRemainCount);

        newData.Add("7DayRemainCount", result.m_7DayRemainCount);

        newData.Add("30DayRemainCount", result.m_30DayRemainCount);

        //////////////////////////////////////////////////////////////////////////
        newData.Add("Day2DevRemainCount", result.m_2DayDevRemainCount);
        newData.Add("Day3DevRemainCount", result.m_3DayDevRemainCount);
        newData.Add("Day7DevRemainCount", result.m_7DayDevRemainCount);
        newData.Add("Day30DevRemainCount", result.m_30DayDevRemainCount);

        newData.Add("Day1TotalRecharge", result.m_1DayTotalRecharge);
        newData.Add("Day3TotalRecharge", result.m_3DayTotalRecharge);
        newData.Add("Day7TotalRecharge", result.m_7DayTotalRecharge);
        newData.Add("Day14TotalRecharge", result.m_14DayTotalRecharge);
        newData.Add("Day30TotalRecharge", result.m_30DayTotalRecharge);
        newData.Add("Day60TotalRecharge", result.m_60DayTotalRecharge);
        newData.Add("Day90TotalRecharge", result.m_90DayTotalRecharge);

        IMongoQuery imq1 = Query.EQ("genTime", BsonValue.Create(info.m_statDay.Date.AddDays(-1)));
        IMongoQuery imq2 = Query.EQ("channel", BsonValue.Create(info.m_channelNum));

        imq = Query.And(imq1, imq2);

        return(newData);
    }
Ejemplo n.º 25
0
 public void AddStats(StatResult res, string extension, string searchedfile, string reason = null)
 {
     lock (_object)
     {
         if (res == StatResult.Success)
         {
             Succedbytype[extension]++;
             CatalogedFiles.Add(searchedfile);
         }
         else
         {
             Failedbytype[extension]++;
             SkippedFile sk = new SkippedFile(searchedfile, reason);
             FilesSkipped.Add(sk);
         }
     }
 }
Ejemplo n.º 26
0
        private IExtractResult StateAreaCol(int NormalLevel, string[] files, Dictionary <string, StatInfo> result, int HILevel)
        {
            string[]        normalDesc = GetStringArray("NormalDesc");
            List <string[]> valueItems = new List <string[]>();
            List <string>   temp       = null;
            List <string>   columnList = new List <string>();

            columnList.Add("日期");
            string DateStr = GetStringArgument("DateStr");

            for (UInt16 col = 0; col < HILevel; col++)
            {
                columnList.Add(normalDesc == null || col >= normalDesc.Length ? (NormalLevel - col).ToString() : normalDesc[col]);
            }
            IRasterDataProvider rdp = GeoDataDriver.Open(files[0]) as IRasterDataProvider;
            double areaBase         = 0f;

            areaBase = GetAreaBase(rdp, areaBase);
            foreach (string key in result.Keys)
            {
                temp = new List <string>();
                temp.Add(DataIdentifyMatcher.GetOrbitDateTime(key).AddHours(8).ToString(DateStr));
                for (UInt16 level = 0; level < HILevel; level++)
                {
                    if (!result[key].UHPI.ContainsKey((UInt16)(NormalLevel - level)))
                    {
                        temp.Add("0");
                    }
                    else
                    {
                        temp.Add(Math.Round(result[key].UHPI[(UInt16)(NormalLevel - level)] * areaBase / Math.Pow(10, 6), 2).ToString());
                    }
                }
                valueItems.Add(temp.ToArray());
            }
            string title = "统计日期:" + DateTime.Now.ToShortDateString() + " 面积单位:平方公里";

            string[]          columns    = columnList.ToArray();
            IStatResult       statResult = new StatResult(title, columns, valueItems.ToArray());
            string            filename   = StatResultToFile(files, statResult, "UHE", "UHAR", "热岛面积", string.Empty, 1, false, 1);
            FileExtractResult fileResult = new FileExtractResult("UHAR", filename);

            fileResult.Add2Workspace = true;
            fileResult.SetDispaly(false);
            return(fileResult);
        }
Ejemplo n.º 27
0
        private IExtractResult StatFirePoint(string rasterFileName)
        {
            IRasterDataProvider inRaster = RasterDataDriver.Open(rasterFileName) as IRasterDataProvider;

            if (inRaster == null)
            {
                PrintInfo("读取栅格文件失败:" + inRaster);
                return(null);
            }
            SortedDictionary <string, StatAreaItem> result;
            RasterStatByVector <Int16> stat = new RasterStatByVector <Int16>(null);

            result = stat.CountByVector(inRaster, "大洲.shp", "CONTINENT",
                                        (cur, cursum) =>
            {
                return(cursum += cur);
            });
            if (result.Count == 0)
            {
                return(null);
            }
            List <string[]> resultList = new List <string[]>();

            foreach (string key in result.Keys)
            {
                resultList.Add(new string[] { key, result[key].GrandTotal.ToString() });
            }
            string         sentitle = "统计日期:" + DateTime.Now.ToShortDateString();
            RasterIdentify id       = new RasterIdentify(rasterFileName);

            id.ProductIdentify    = "FIR";
            id.SubProductIdentify = "GFCF";
            if (id.OrbitDateTime != null)
            {
                sentitle += "    轨道日期:" + id.OrbitDateTime.ToShortDateString();
            }
            string[]    columns        = new string[] { "大洲", "累计火点数" };
            IStatResult fresult        = new StatResult(sentitle, columns, resultList.ToArray());
            string      outputIdentify = _argumentProvider.GetArg("OutFileIdentify").ToString();
            string      title          = "全球火点大洲统计";
            string      filename       = StatResultToFile(new string[] { rasterFileName }, fresult, "FIR", outputIdentify, title, null, 1, true, 1);

            return(new FileExtractResult(outputIdentify, filename));
        }
Ejemplo n.º 28
0
        internal IFileExtractResult GeneratorKB(IArgumentProvider argProvider, Dictionary <int, FireAreaFeature> features)
        {
            DateTime        orbitDateTime = DateTime.MinValue;
            string          saveFilename  = GetFALTFilenameKB(argProvider, out orbitDateTime);
            List <string[]> excelInfos    = new List <string[]>();

            string[]      columns  = new string[] { "火区号", "中心经度", "中心纬度", "火点像元个数", "像元覆盖面积(平方公里)", "明火面积(公顷)", "省地县", "林地", "草地", "农田", "其他" };
            List <string> listTemp = new List <string>();

            for (int i = 0; i < features.Count; i++)
            {
                listTemp.Add((features[i].FireReaIndex + 1).ToString());
                listTemp.Add(features[i].Longitude.ToString());
                listTemp.Add(features[i].Latitude.ToString());
                listTemp.Add(features[i].FireCount.ToString("#"));
                listTemp.Add(features[i].FireArea.ToString("#0.000"));
                listTemp.Add(features[i].SecondryFireArea.ToString("#0.000"));
                listTemp.Add(string.IsNullOrEmpty(features[i].XJName) ? @"\" : features[i].XJName);
                listTemp.Add(features[i].WoodlandPercent == 0 ? @"\" : (features[i].WoodlandPercent * 100 + "%"));
                listTemp.Add(features[i].GrasslandPercent == 0 ? @"\" : (features[i].GrasslandPercent * 100 + "%"));
                listTemp.Add(features[i].FarmlandPercent == 0 ? @"\" : (features[i].FarmlandPercent * 100 + "%"));
                listTemp.Add(features[i].OtherPercent == 0 ? @"\" : (features[i].OtherPercent * 100 + "%"));
                excelInfos.Add(listTemp.ToArray());
                listTemp.Clear();
            }
            IStatResult result = new StatResult("火区信息统计结果", columns, excelInfos.ToArray());

            using (StatResultToExcelFile excelControl = new StatResultToExcelFile())
            {
                excelControl.Init();
                excelControl.Add(true, "火区信息数据统计", result, false, 0);
                excelControl.WinExcelControl.SetCellValue(2, 2, 2, 12, 0, masExcelAlignType.Center, "火情信息快报", null);
                string timestring = string.Format("时间:{0}(北京时)", orbitDateTime.AddHours(8).ToString("yyyy年MM月dd日 HH:mm"));
                excelControl.WinExcelControl.SetCellValue(3, 2, 3, 6, 0, masExcelAlignType.Left, timestring, null);
                excelControl.WinExcelControl.SetCellValue(3, 7, 3, 12, 0, masExcelAlignType.Right, "国家卫星气象中心", null);
                excelControl.WinExcelControl.SetCellValue(4, 2, 4, 12, 1, masExcelAlignType.Center, "火区信息数据统计", null);
                excelControl.SaveFile(saveFilename);
            }
            IFileExtractResult resultFile = new FileExtractResult("FRIK", saveFilename);

            resultFile.SetDispaly(false);
            return(resultFile);
        }
Ejemplo n.º 29
0
        private IExtractResult StatArea(string[] plstFiles)
        {
            Dictionary <string, FireAreaInfo> statArea = null;
            object aoiObj = _argumentProvider.GetArg("AOI");
            string title  = string.Empty;

            if (aoiObj == null)
            {
                title    = "火情按当前区域面积统计";
                statArea = AreaStatByType(plstFiles, "当前区域");
            }
            else
            {
                if (aoiObj as Dictionary <string, int[]> != null)
                {
                    Dictionary <string, int[]> aoi = aoiObj as Dictionary <string, int[]>;
                    statArea = StatCustomArea(plstFiles, ref title, aoi);
                }
                else
                {
                    title    = "火情按" + aoiObj.ToString() + "面积统计";
                    statArea = AreaStatByType(plstFiles, aoiObj.ToString());
                }
            }
            if (statArea != null && statArea.Count != 0)
            {
                //生成结果文件参数string[][] rows
                string[]    columns;
                string[][]  resultRows      = GetResultRows(statArea, out columns);
                string      statInfo        = "统计日期:" + DateTime.Now.ToShortDateString();
                IStatResult result          = new StatResult(statInfo, columns, resultRows);
                string[]    files           = GetStringArray("SelectedPrimaryFiles");
                string      outFileIdentify = GetStringArgument("OutFileIdentify");
                string      extInfos        = GetStringArgument("extinfo");
                string      filename        = StatResultToFile(files, result, "FIR", outFileIdentify, title, extInfos, 1, false, (byte)0);
                return(new FileExtractResult(outFileIdentify, filename));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 检查图片是否已存在
        /// </summary>
        /// <param name="LV_NUM"></param>
        /// <returns></returns>
        public static bool Stat(string LV_NUM)
        {
            // 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey
            // 实际应用中,请自行设置您的AccessKey和SecretKey
            Mac           mac    = new Mac(_AccessKey, _SecretKey);
            string        bucket = _bucket;
            string        key    = LV_NUM;
            BucketManager bm     = new BucketManager(mac);
            StatResult    result = bm.Stat(bucket, key);

            if (result.Code.ToString().Trim() == "200")
            {
                //200 状态码代表 已存在该图片
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 31
0
        public static object GetFileStats(string path)
        {
            StatResult sr = new StatResult();

            try {
                sr.atime = (long)Directory.GetLastAccessTime(path).Subtract(DateTime.MinValue).TotalSeconds;
                sr.ctime = (long)Directory.GetCreationTime(path).Subtract(DateTime.MinValue).TotalSeconds;
                sr.mtime = (long)Directory.GetLastWriteTime(path).Subtract(DateTime.MinValue).TotalSeconds;

                if (Directory.Exists(path)) {
                    sr.mode = 0x4000;
                } else if (File.Exists(path)) {
                    FileInfo fi = new FileInfo(path);
                    sr.size = fi.Length;
                    sr.mode = 0x8000; //@TODO - Set other valid mode types (S_IFCHR, S_IFBLK, S_IFIFO, S_IFLNK, S_IFSOCK) (to the degree that they apply)
                } else {
                    throw new IOException("file does not exist");
                }
            } catch (Exception e) {
                throw ToPythonException(e);
            }

            return sr;
        }