示例#1
0
        public async Task <ResultBean <IList <NewsListBean> > > GetNewsList(long time, string type)
        {
            string key    = "ff3460eb96b32f8dca051ae1248a2e8a";
            string result = await HttpHelp.getInstance().Get("http://v.juhe.cn/toutiao/index?type=" + type + "&key=" + key);

            NewsResultBean resultBean = JsonHelp.FromJson <NewsResultBean>(result);

            logger.info("GetNewsList - " + time + ", " + resultBean.error_code + ", " + resultBean.reason);
            ResultBean <IList <NewsListBean> > rb = new ResultBean <IList <NewsListBean> >();

            if (resultBean != null && resultBean.result != null && resultBean.result.data != null)
            {
                rb.Success = true;
                rb.Message = "请求成功";
                rb.Data    = resultBean.result.data;
                foreach (NewsListBean b in rb.Data)
                {
                    b.image = b.thumbnail_pic_s;
                }
            }
            else
            {
                rb.Success = false;
                rb.Message = "请求失败";
            }
            return(rb);
        }
示例#2
0
        public ResultBean DriveItem(int id)
        {
            Console.WriteLine(id);
            DriveConfig driveConfig = systemManager.GetDriveConfigById(id);

            return(ResultBean.Success(driveConfig));
        }
示例#3
0
 private void Btn_OnDaoRuClick()                          // 点击导入
 {
     if (chooseGOK_BgV.Count > 1)                         // 选择了 多张
     {
         List <GameObject> sortList    = GetSortChoose(); // 1. 先排好序
         ResultBean[]      resultBeans = new ResultBean[sortList.Count];
         for (int i = 0; i < sortList.Count; i++)
         {
             resultBeans[i] = allGoK_ResultBeanV[sortList[i]];
         }
         MyEventCenter.SendEvent(E_GameEvent.ShowDuoTuInfo, resultBeans, EDuoTuInfoType.DaoRu);
     }
     else if (chooseGOK_BgV.Count == 1)       // 选择了 1 张
     {
         foreach (GameObject go in chooseGOK_BgV.Keys)
         {
             MyEventCenter.SendEvent(E_GameEvent.ShowSingleTuInfo, allGoK_ResultBeanV[go]);
             break;
         }
     }
     else
     {
         MyLog.Red("不可能吧");
     }
 }
示例#4
0
 public ResultBean DeleteFile(int driveId, string pathToDrive)
 {
     if (LocalFileManager.DelFile(SystemManager.BasePath + "/" + driveId.ToString() + "/" + pathToDrive))
     {
         return(ResultBean.Success());
     }
     return(ResultBean.Error("删除失败"));
 }
示例#5
0
 public ResultBean UpdatePwd([FromForm] LoginForm loginForm)
 {
     if (systemManager.UpdatePassword(loginForm.username, loginForm.password, loginForm.newPassword))
     {
         return(ResultBean.Success("密码修改成功"));
     }
     return(ResultBean.Error("原密码错误"));
 }
示例#6
0
 public ResultBean DeleteDir(int driveId, string pathToDrive)
 {
     if (LocalFileManager.DelDir(combineDrivePath(driveId, pathToDrive)))
     {
         return(ResultBean.Success());
     }
     return(ResultBean.Error("删除失败"));
 }
示例#7
0
 private void E_ShowNormalTuInfo(EGameType type, ResultBean bean)        // 显示单图信息
 {
     if (type == EGameType.JiHeTu)
     {
         go_Top.SetActive(false);
         go_Bottom.SetActive(false);
     }
 }
示例#8
0
 public ResultBean DeleteDrive(int id)
 {
     if (systemManager.DeleteDriveById(id))
     {
         return(ResultBean.Success());
     }
     return(ResultBean.Error("删除失败"));
 }
示例#9
0
 public ResultBean List(int driveId, string path, string password, int page)
 {
     if (path == null)
     {
         path = "";
     }
     return(ResultBean.Success(new { totalPage = 1, fileList = fileManager.ListFiles(driveId, path) }));
 }
示例#10
0
 public ResultBean updateFolder(int driveId, string pathToDrive)
 {
     if (LocalFileManager.CreateDir(combineDrivePath(driveId, pathToDrive)))
     {
         return(ResultBean.Success());
     }
     return(ResultBean.Error("创建失败"));
 }
示例#11
0
        public async Task <ResultBean <IList <NewsItemBean> > > GetToutiaoList(long time, string type)
        {
            ResultBean <IList <NewsItemBean> > rb = new ResultBean <IList <NewsItemBean> >();

            //string url = "http://www.toutiao.com/api/article/feed/?category=" + type + "&utm_source=toutiao&widen=1&max_behot_time=0&max_behot_time_tmp=0&tadrequire=true&as=A1C529791677EE2&cp=599667FE4E32EE1";
            string url    = "http://www.toutiao.com/api/pc/feed/?category=" + type + "&utm_source=toutiao&max_behot_time=" + max_behot_time;
            string result = await HttpHelp.getInstance().Get(url);

            if (result == null || "".Equals(result))
            {
                rb.Success = false;
                rb.Message = "请求http失败";
            }
            else
            {
                NewsToutiaoResultEntity resultBean = JsonHelp.FromJson <NewsToutiaoResultEntity>(result);
                logger.info("GetToutiaoList - url=" + url + ", " + resultBean.next.max_behot_time + ", " + resultBean.message);
                IList <NewsItemBean> list = new List <NewsItemBean>();
                if (resultBean.message.Equals("success") && resultBean.data != null)
                {
                    max_behot_time = resultBean.next.max_behot_time;
                    foreach (NewsToutiaoItemEntity item in resultBean.data)
                    {
                        NewsItemBean bean = new NewsItemBean {
                            Title = item.title, Source = item.source, Image = "http:" + item.image_url, Url = "https://www.toutiao.com" + item.source_url
                        };
                        DateTime utcdt = DateTime.Parse(DateTime.UtcNow.ToString("1970-01-01 00:00:00")).AddSeconds(item.behot_time);
                        bean.Datetime = utcdt.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
                        if (item.image_url != null)
                        {
                            bean.IsImage = true;
                        }
                        else if (item.image_list != null)
                        {
                            bean.IsThird = true;
                            bean.Image1  = "http:" + item.image_list[0].url;
                            bean.Image2  = "http:" + item.image_list[1].url;
                            bean.Image3  = "http:" + item.image_list[2].url;
                        }
                        else
                        {
                            bean.IsText = true;
                        }

                        list.Add(bean);
                    }
                    rb.Success = true;
                    rb.Data    = list;
                    rb.Message = "请求成功,返回" + list.Count + "条";
                }
                else
                {
                    rb.Success = false;
                    rb.Message = "请求结果为空";
                }
            }
            return(rb);
        }
示例#12
0
        private void clientAccept(Object socketServer)
        {
            Socket client = socketServer as Socket;
            //获取客户端的IP和端口号
            string clientIP   = (client.RemoteEndPoint as IPEndPoint).Address.ToString();//IPAddress
            int    clientPort = (client.RemoteEndPoint as IPEndPoint).Port;

            LogUtil.Log("客户端连入 " + clientIP + " : " + clientPort); //CJC应提示或列出报警器是否可用正常
            int order = 1;                                         //序号

            while (true)
            {
                byte[] clientData = new byte[1024];
                //try
                //{
                int revLen = client.Receive(clientData, SocketFlags.None);
                if (revLen <= 0)
                {
                    LogUtil.Log("客户端:" + clientIP + "数据长度为0 break");
                    break;
                }
                else if (revLen == 25)
                {
                    TreeEntity bean   = DataUtil.ParseData(clientData, revLen, clientIP);
                    ResultBean result = DataUtil.CheckEntity(bean);
                    LogUtil.Log(LogLevel.Info, "接收数据 " + (bean.SourceData));
                    if (result.Result)
                    {
                        try
                        {
                            client.Send(DataUtil.Respond(bean, order));
                            order++;
                            LogUtil.Log(LogLevel.Info, "回复数据 " + (DataUtil.ByteDataToStringSplit(DataUtil.Respond(bean, order))));
                        }
                        catch
                        {
                            LogUtil.Log(LogLevel.Error, "发送数据 " + (DataUtil.ByteDataToStringSplit(DataUtil.Respond(bean, order))) + " 失败");
                        }
                    }
                    send(bean);//保存数据库
                }
                else
                {
                    string data = DataUtil.ByteDataToStringSplit(clientData, 0, revLen);
                    LogUtil.Log(LogLevel.Error, clientIP + "|接收到长度为" + revLen + "的数据|" + data);
                }

                /*
                 * }
                 * catch (Exception e)
                 * {
                 * LogUtil.Log("远程主机关闭了一个现有的连接" + e.Message);
                 * break;
                 * }
                 */
            }
        }
示例#13
0
        public ResultBean SaveDriveItem(Drive driveConfig)
        {
            int userId;

            if (int.TryParse(SystemManager.Decrypt(HttpContext.Request.Cookies["userId"]), out userId))
            {
                systemManager.SaveNewDrive(driveConfig.name, userId);
                return(ResultBean.Success());
            }
            return(ResultBean.Error("userId error"));
        }
示例#14
0
        public ResultBean DeleteDriveItem(int id)
        {
            int userId;

            if (int.TryParse(SystemManager.Decrypt(HttpContext.Request.Cookies["userId"]), out userId))
            {
                systemManager.DeleteDriveById(id);
                return(ResultBean.Success());
            }
            return(ResultBean.Error("userId error"));
        }
示例#15
0
    static IEnumerator WaitForImage(List <FileInfo> fileInfos, Action <ResultBean[]> callBack)
    {
        System.Drawing.Image[] l_UseImages = new System.Drawing.Image[fileInfos.Count];     // 改的图
        ResultBean[]           resList     = new ResultBean[fileInfos.Count];

        // 开个线程
        new Thread(() =>
        {
            for (int i = 0; i < fileInfos.Count; i++)
            {
                System.Drawing.Image yuanImage = System.Drawing.Image.FromFile(fileInfos[i].FullName);


                int width  = yuanImage.Width;
                int height = yuanImage.Height;
                GetShouFan(ref width, ref height);
                System.Drawing.Image useImage = yuanImage.GetThumbnailImage(width, height, () => false, System.IntPtr.Zero);
                ResultBean bean = new ResultBean();
                bean.Width      = width;
                bean.Height     = height;
                resList[i]      = bean;
                l_UseImages[i]  = useImage;
            }
        }).Start();


        for (int i = 0; i < fileInfos.Count; i++)
        {
            while (null == l_UseImages[i])
            {
                yield return(0);
            }
            using (MemoryStream ms = new MemoryStream())
            {
                l_UseImages[i].Save(ms, ImageFormat.Png);
                yield return(0);

                Texture2D tex = new Texture2D(8, 8);
                tex.LoadImage(ms.ToArray());
                yield return(0);

                Sprite sp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
                sp.name = Path.GetFileNameWithoutExtension(fileInfos[i].FullName);

                resList[i].SP   = sp;
                resList[i].File = fileInfos[i];
            }
        }

        if (null != callBack)
        {
            callBack(resList);
        }
    }
示例#16
0
    //————————————————————————————————————

    public static void LoadSingleTu_Quick(FileInfo fileInfo, Action <ResultBean> callBack)    // 原图,大图可以考虑用这个(不卡,但大小不可控)
    {
        MyWebDownLoader.DownTexture("file://" + fileInfo.FullName, (tu) =>
        {
            Sprite sp       = Sprite.Create(tu, new Rect(0, 0, tu.width, tu.height), new Vector2(0.5f, 0.5f));
            ResultBean bean = new ResultBean(sp, fileInfo, tu.width, tu.height);
            if (null != callBack)
            {
                callBack(bean);
            }
        });
    }
示例#17
0
    //—————————————————— 事件 ——————————————————


    private void E_Show(ResultBean resultBeans)      // 显示
    {
        mCurrentResultBean = resultBeans;

        mUIGameObject.SetActive(true);
        tx_Name.text    = Path.GetFileNameWithoutExtension(resultBeans.File.FullName);
        tx_HuoZhui.text = resultBeans.File.Extension;

        sp_Tu.sprite     = resultBeans.SP;
        yuanLaiWidth     = resultBeans.Width;
        yuanLaiHidth     = resultBeans.Height;
        tx_YuanSize.text = yuanLaiWidth + " x " + yuanLaiHidth;

        SetTuSize(yuanLaiWidth, yuanLaiHidth);
    }
示例#18
0
    //—————————————————— 事件 ——————————————————


    private void E_Show(ResultBean bean)                                  // 显示
    {
        mCurrentBean     = bean;
        tx_FileName.text = Path.GetFileNameWithoutExtension(bean.File.FullName);
        tx_HuoZhui.text  = bean.File.Extension.Substring(1);
        tx_TuSize.text   = "";

        mUIGameObject.SetActive(true);

        Sp_Tu.sprite   = bean.SP;
        yuanLaiWidth   = bean.Width;
        yuanLaiHidth   = bean.Height;
        tx_TuSize.text = yuanLaiWidth + " x " + yuanLaiHidth;
        SetTuSize(yuanLaiWidth, yuanLaiHidth);
    }
示例#19
0
        public ResultBean insertWeightDataToWorkBean(DZCBean bean)//电子秤读到重量
        {
            ResultBean result  = new ResultBean();
            bool       success = false;
            string     msg     = "";

            ConnBean conn      = new ConnBean();
            bool     connExist = connMap.TryGetValue(bean.Ip, out conn);//通过关联表中找到读卡器IP


            if (conn != null)
            {
                if (conn.Ip3 != null)                              //读卡器IP
                {
                    WorkBean work = tryGetWorkBeanValue(conn.Ip3); //通过读卡器IP得到已经保存的刷卡信息
                    if (work != null)
                    {
                        work = insertWeightToMap(work, bean);

                        saveWork(work);//保存信息

                        success       = true;
                        msg           = "数据保存成功";
                        result.IsLow  = (bean.Weight - conn.Weight) < 0.00000001;//低重
                        result.Value1 = bean.Weight + "";
                        result.Value2 = conn.Weight + "";
                        result.Msg2   = "低重,发送报警。报警重量:" + conn.Weight + ",当前重量:" + bean.Weight;//在IsLow为true时才正确
                        result.Bean   = conn;
                    }
                    else
                    {
                        msg = "电子称 " + conn.Ip + " 未有用户刷卡,重量数据不保存";
                    }
                }
                else
                {
                    msg = "电子称 " + conn.Ip + " 关联的读卡器 " + conn.Ip3 + " 不存在";
                }
            }
            else
            {
                msg = "关联表中不存在电子秤IP:" + bean.Ip + "的报警器及读卡器关联信息";
            }
            result.Success = success;
            result.Msg     = msg;

            return(result);
        }
示例#20
0
 private void InitMoBan(Transform t, ResultBean resultBean) // 初始化模版
 {
     t.Find("Tu").GetComponent <Image>().sprite = resultBean.SP;
     t.GetComponent <Button>().onClick.AddListener(() =>
     {
         if (t.gameObject.Equals(go_CurrentSelect) && isSelect) // 双击
         {
             Btn_OnDoubleItemClick(resultBean);
         }
         else // 单击
         {
             go_CurrentSelect = t.gameObject;
             Ctrl_Coroutine.Instance.StartCoroutine(CheckoubleClick());
         }
     });
 }
        /// <summary>
        /// 获取新闻列表
        /// </summary>
        async private void getNewsList()
        {
            double now = DateTime.Now.Subtract(DateTime.Parse("1970-1-1")).TotalSeconds;
            ResultBean <IList <NewsListBean> > rb = await this.newsService.GetNewsList((long)now, "shishang");

            if (rb.Success)
            {
                this.dataList = rb.Data;
                this.refreshListView();
            }
            else
            {
                await DisplayAlert("提示", "请求网络失败!", "ERROR");
            }
            this.listView.EndRefresh();
        }
        /// <summary>
        /// 获取新闻列表
        /// </summary>
        async private void getNewsList()
        {
            double now = DateTime.Now.Subtract(DateTime.Parse("1970-1-1")).TotalSeconds;
            ResultBean <IList <NewsListBean> > rb = await this.newsService.GetNewsList((long)now, this.type);

            logger.info("---getNewsList----get---, type=" + this.type + ", msg=" + rb.Message);
            if (rb.Success)
            {
                this.newsList.Clear();
                foreach (NewsListBean bean in rb.Data)
                {
                    this.newsList.Add(bean);
                }
            }
            this.listView.EndRefresh();
            this.listView.IsRefreshing = false;
        }
示例#23
0
        protected void submit_Click(object sender, EventArgs e)
        {
            string     id     = Request.QueryString["id"];
            IResult    prj    = DataAccess.CreateIResult();
            ResultBean result = new ResultBean();

            result.UserId          = "1";
            result.RtProjectID     = id;
            result.RtPrjName       = Project_Name.Text;
            result.RtPeople        = Project_PersonLiable.Text;
            result.RtBookNumber    = Result_BookNumber.Text;
            result.RtClass         = Result_class.Text;
            result.RtBookNameC     = Result_BookNameC.Text;
            result.RtBookNameEn    = Result_BookNameEn.Text;
            result.RtPublishName   = Result_PublishName.Text;
            result.RtPublishLevel  = Result_PublishLevel.Text;
            result.RtPublishTime   = Result_PublishTime.Text;
            result.RtPublishNumber = Result_publishNumber.Text;
            result.RtWordCount     = Result_WordCount.Text;

            if (prj.isNull(id))
            {
                if (prj.insertResult(result))
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "confim", "<script>alert('项目成果提交成功,请等待审核!');location.href='PersonalRsSubmit.aspx?id=" + id + "';</script>", false);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "confim", "<script>alert('项目成果提交失败!');location.href='PersonalRsSubmit.aspx?id=" + id + "';</script>", false);
                }
            }
            else
            {
                if (prj.updateResult(result))
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "confim", "<script>alert('项目成果修改成功,请等待审核!');location.href='PersonalRsSubmit.aspx?id=" + id + "';</script>", false);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "confim", "<script>alert('项目成果修改失败!');location.href='PersonalRsSubmit.aspx?id=" + id + "';</script>", false);
                }
            }
        }
示例#24
0
 public async Task <ResultBean> uploadFile([FromForm] FileUploadModel fm)
 {
     if (fm.file.Length > 0)
     {
         var filePath = combineDrivePath(fm.driveId, fm.pathToDrive) + "/" + fm.file.FileName;
         using (var fileStream = new FileStream(filePath, FileMode.Create))
         {
             try
             {
                 await fm.file.CopyToAsync(fileStream);
             }
             catch (Exception e)
             {
                 return(ResultBean.Error("保存失败"));
             }
         }
     }
     return(ResultBean.Success());
 }
示例#25
0
 public ResultBean EditDrive(DriveConfig driveConfig)
 {
     if (driveConfig.id == null)
     {
         int userId;
         if (int.TryParse(SystemManager.Decrypt(HttpContext.Request.Cookies["userId"]), out userId))
         {
             systemManager.SaveNewDrive(driveConfig.name, userId);
             return(ResultBean.Success());
         }
     }
     else
     {
         if (systemManager.EditDrive(driveConfig))
         {
             return(ResultBean.Success());
         }
     }
     return(ResultBean.Error("未知错误"));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            string     id     = Request.QueryString["id"];
            IResult    prj    = DataAccess.CreateIResult();
            ResultBean result = prj.getIR(id);

            Project_ID.Text = id;

            if (!IsPostBack)
            {
                if (prj.isNull(id))
                {
                    Response.Write("<script language=javascript>alert('无数据!')</script>");
                    Project_Name.Text         = result.RtPrjName;
                    Project_PersonLiable.Text = result.RtPeople;
                    Result_BookNumber.Text    = "无数据";
                    Result_class.Text         = "无数据";
                    Result_BookNameC.Text     = "无数据";
                    Result_BookNameEn.Text    = "无数据";
                    Result_PublishName.Text   = "无数据";
                    Result_PublishLevel.Text  = "无数据";
                    Result_PublishTime.Text   = "无数据";
                    Result_publishNumber.Text = "无数据";
                    Result_WordCount.Text     = "无数据";
                }
                else
                {
                    Project_Name.Text         = result.RtPrjName;
                    Project_PersonLiable.Text = result.RtPeople;
                    Result_BookNumber.Text    = result.RtBookNumber;
                    Result_class.Text         = result.RtClass;
                    Result_BookNameC.Text     = result.RtBookNameC;
                    Result_BookNameEn.Text    = result.RtBookNameEn;
                    Result_PublishName.Text   = result.RtPublishName;
                    Result_PublishLevel.Text  = result.RtPublishLevel;
                    Result_PublishTime.Text   = result.RtPublishTime;
                    Result_publishNumber.Text = result.RtPublishNumber;
                    Result_WordCount.Text     = result.RtWordCount;
                }
            }
        }
示例#27
0
    static IEnumerator WaitForImage(FileInfo fileInfo, Action <ResultBean> callBack)
    {
        System.Drawing.Image image     = null;
        System.Drawing.Image image_Gai = null;
        // 开个线程
        new Thread(() =>
        {
            image          = System.Drawing.Image.FromFile(fileInfo.FullName);
            int saveWidth  = image.Width;
            int saveHeight = image.Height;
            GetShouFan(ref saveWidth, ref saveHeight);
            image_Gai = image.GetThumbnailImage(saveWidth, saveHeight, () => false, System.IntPtr.Zero);
        }).Start();
        while (null == image)
        {
            yield return(0);
        }
        while (null == image_Gai)
        {
            yield return(0);
        }
        using (MemoryStream ms = new MemoryStream())
        {
            image_Gai.Save(ms, ImageFormat.Png);
            yield return(0);

            Texture2D tex = new Texture2D(8, 8);
            tex.LoadImage(ms.ToArray());
            yield return(0);

            Sprite sp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
            sp.name = Path.GetFileNameWithoutExtension(fileInfo.FullName);
            if (null != callBack)
            {
                ResultBean result = new ResultBean(sp, fileInfo, image.Width, image.Height);
                callBack(result);
            }
        }
    }
示例#28
0
        public void receiveData(DZCBean bean, UserBean user)
        {
            Console.WriteLine("我这这里页面接收到了数据: " + bean.Ip);
            //把数据给前台

            if (bean != null)                                               //电子秤数据
            {
                ResultBean result = model.insertWeightDataToWorkBean(bean); //结合数据,保存数据,判断低重

                LogUtil.instance.Log(result.Msg);

                if (result.Success && result.IsLow)
                {
                    LogUtil.instance.Log(result.Msg2);
                    alarmServer.send(result.Bean);
                }
            }
            else if (user != null) //用户刷卡的
            {
            }
            view.showTable(null);
        }