Beispiel #1
0
        /// <summary>
        /// 上传一个文件,返回节点描述符。
        /// </summary>
        /// <param name="sPath"></param>
        /// <returns></returns>
        public static FileTreeNode UploadFile(string sPath, string strID, string strInfo, ContentKind cKind, string strApp)
        {
            TFile file = new TFile();

            file.FileContent = File.ReadAllBytes(sPath);
            FileStream fs = File.OpenRead(sPath);

            file.FileId    = strID;
            file.FileInfo  = strInfo;
            file.FileKind  = (TContentKind)cKind;
            file.FileSize  = fs.Length;
            file.FromApp   = strApp;
            file.FileOwner = GetValidator().VssID;
            ClientAdapt.Open();
            TVssService.Client client   = ClientAdapt.GetClient();
            string             strNewID = client.Put(GetValidator(), file);

            ClientAdapt.Close();

            FileTreeNode fileTreeNode = new FileTreeNode();

            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            fileTreeNode.CreateDate = (uint)(DateTime.Now - startTime).TotalSeconds;
            fileTreeNode.FileID     = strNewID;
            fileTreeNode.FileInfo   = strInfo;
            fileTreeNode.FileKind   = cKind;
            fileTreeNode.FileSize   = (ulong)fs.Length;
            fileTreeNode.FromApp    = strApp;
            fileTreeNode.SubNodes   = null;
            fileTreeNode.FileOwner  = GetValidator().VssID;
            fileTreeNode.NodeName   = fs.Name.Substring(fs.Name.LastIndexOf("\\") + 1);

            return(fileTreeNode);
        }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sName = Request.Params["sName"];
        string sPsws = Request.Params["sPsw"];

        ClientAdapt.Open();
        TVssService.Client client      = ClientAdapt.GetClient();
        TValidator         tValidator  = new TValidator(sName, sPsws, "VssBlog");
        TLoginResult       tLoginState = client.Login(tValidator);

        ClientAdapt.Close();

        HttpContext.Current.Session["UserLogin"] = tValidator;

        Response.Clear();
        if (tLoginState == TLoginResult.SUCCESS)
        {
            Response.Write("SUCCESS");
        }
        else
        {
            Response.Write("ERROR");
        }

        Response.End();
    }
Beispiel #3
0
        public static FileTreeNode UploadTextFile(string sContent, string nodeName, string strID, string strInfo, ContentKind cKind, string strApp)
        {
            TFile file = new TFile();

            file.FileContent = System.Text.Encoding.UTF8.GetBytes(sContent);
            file.FileId      = strID;
            file.FileInfo    = strInfo;
            file.FileKind    = (TContentKind)cKind;
            file.FileSize    = file.FileContent.Length;
            file.FromApp     = strApp;
            file.FileOwner   = GetValidator().VssID;
            ClientAdapt.Open();
            TVssService.Client client   = ClientAdapt.GetClient();
            string             strNewID = client.Put(GetValidator(), file);

            ClientAdapt.Close();

            FileTreeNode fileTreeNode = new FileTreeNode();

            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            fileTreeNode.CreateDate = (uint)(DateTime.Now - startTime).TotalSeconds;
            fileTreeNode.FileID     = strNewID;
            fileTreeNode.FileInfo   = strInfo;
            fileTreeNode.FileKind   = cKind;
            fileTreeNode.FileSize   = (ulong)file.FileContent.Length;
            fileTreeNode.FromApp    = strApp;
            fileTreeNode.SubNodes   = null;
            fileTreeNode.FileOwner  = GetValidator().VssID;
            fileTreeNode.NodeName   = nodeName;

            return(fileTreeNode);
        }
Beispiel #4
0
 public static void DestoryFile(string fileID)
 {
     ClientAdapt.Open();
     TVssService.Client client = ClientAdapt.GetClient();
     client.Del(GetValidator(), fileID);
     ClientAdapt.Close();
 }
Beispiel #5
0
        /// <summary>
        /// 取消公开某一个文件
        /// </summary>
        /// <param name="fileID"></param>
        public static void RecallFile(string fileID)
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            client.Recover(GetValidator(), fileID, new List <string>());

            ClientAdapt.Close();
        }
Beispiel #6
0
        public static bool SaveDirectoryInfo()
        {
            ClientAdapt.Open();
            TVssService.Client client  = ClientAdapt.GetClient();
            TCommandResult     tResult = client.SaveFileTree(BLLControl.GetValidator(), JsonConvert.SerializeObject(RootFileTree));

            ClientAdapt.Close();

            return(tResult == TCommandResult.SUCCESS);
        }
Beispiel #7
0
        /// <summary>
        /// 取消一系列朋友对某一个文件的访问授权
        /// </summary>
        /// <param name="fileID"></param>
        /// <param name="listFriends"></param>
        public static void RecoverFile(string fileID, List <string> listFriends)
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            client.Recover(GetValidator(), fileID, listFriends);

            ClientAdapt.Close();
        }
Beispiel #8
0
        /// <summary>
        /// 删除朋友列表(单向)会自动判断名字,不正确则忽略!
        /// </summary>
        /// <param name="list"></param>
        public static void DelFocus(List <string> list)
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            TCommandResult res = client.DelFocus(GetValidator(), list);

            ClientAdapt.Close();
        }
Beispiel #9
0
        /// <summary>
        /// 删除指定ID的朋友消息。
        /// </summary>
        /// <param name="strMsgID"></param>
        public static void DelFriendMessage(string strMsgID)
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            client.DelFriendMessage(GetValidator(), strMsgID);

            ClientAdapt.Close();
        }
Beispiel #10
0
        public static bool Login(string vssID, string vssPsw, string vssApp)
        {
            ClientAdapt.Open();
            TVssService.Client client = ClientAdapt.GetClient();
            SetValidator(vssID, vssPsw, vssApp);
            TLoginResult tLoginState = client.Login(GetValidator());

            ClientAdapt.Close();
            return(tLoginState != TLoginResult.SUCCESS);
        }
Beispiel #11
0
        /// <summary>
        /// 公开某一个文件
        /// </summary>
        /// <param name="fileID"></param>
        public static void PublishFile(string fileID, string provideName)
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            client.Provide(GetValidator(), fileID, new List <string>(), provideName);

            ClientAdapt.Close();
        }
Beispiel #12
0
        /// <summary>
        /// 获取用户的几个内容量集
        /// </summary>
        /// <returns></returns>
        public static TNumber GetNumber()
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            TNumber tNumber = client.GetNumber(GetValidator());

            ClientAdapt.Close();

            return(tNumber);
        }
Beispiel #13
0
        /// <summary>
        /// 获取被授权消息
        /// </summary>
        /// <param name="listID"></param>
        /// <param name="maxNum"></param>
        /// <returns></returns>
        public static List <TMessages> GetProvideMessage(int maxNum)
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            List <TMessages> retList = client.GetProvideMessage(GetValidator(), maxNum);

            ClientAdapt.Close();

            return(retList);
        }
Beispiel #14
0
        /// <summary>
        /// 根据FileID ,获得列表。
        /// </summary>
        /// <param name="fileID"></param>
        /// <returns></returns>
        public static List <string> GetFilePrivideList(string fileID)
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            List <string> retList = client.GetFileProvideList(GetValidator(), fileID);

            ClientAdapt.Close();

            return(retList);
        }
Beispiel #15
0
        /// <summary>
        /// 获取朋友列表(单向)
        /// </summary>
        /// <returns></returns>
        public static List <TFriendMessage> GetFriendMessage()
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            List <TFriendMessage> retList = client.GetFriendMessage(GetValidator(), 100);

            ClientAdapt.Close();

            return(retList);
        }
Beispiel #16
0
        /// <summary>
        /// 获得关注我的朋友的列表(单向指我)
        /// </summary>
        /// <returns></returns>
        public static List <string> GetFollowList()
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            List <string> retList = client.GetFollow(GetValidator());

            ClientAdapt.Close();

            return(retList);
        }
Beispiel #17
0
        /// <summary>
        /// 获取指定用户们的公开消息
        /// </summary>
        /// <param name="listID"></param>
        /// <param name="maxNum"></param>
        /// <returns></returns>
        public static List <TMessages> GetPublishMessage(List <string> listID, int maxNum)
        {
            ClientAdapt.Open();

            TVssService.Client client = ClientAdapt.GetClient();

            List <TMessages> retList = client.GetPublishMessage(GetValidator(), listID, maxNum);

            ClientAdapt.Close();

            return(retList);
        }
Beispiel #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["data"] == null)
        {
            Response.Write("NOPARAMS");
            Response.End();
            return;
        }

        string sData = Request.Params["data"];


        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            //这里也可以根据类型不同,返回适当的情况!
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];



        string sRet = "";

        ClientAdapt.Open();
        TVssService.Client client = ClientAdapt.GetClient();
        if (sData == "")
        {
            //判断获取对象
            if (Request.Params["vssid"] != null)
            {
                tValidator = new TValidator(Request.Params["vssid"], "", "VssBlog");
            }
            sRet = client.GetAppUserInfo(tValidator);
        }
        else
        {
            client.PutAppUserInfo(tValidator, sData);
        }
        ClientAdapt.Close();
        if (sData == "")
        {
            Response.Write(sRet);
        }
        else
        {
            Response.Write("SUCCESS");
        }
        Response.End();
    }
Beispiel #19
0
        /// <summary>
        /// 下载一个文件,返回描述符。
        /// </summary>
        /// <param name="sPath"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public static TFile DownloadFile(string sPath, FileTreeNode file)
        {
            string strFID = file.FileID;

            ClientAdapt.Open();
            TVssService.Client client = ClientAdapt.GetClient();
            TFile tFile = client.Get(GetValidator(), strFID);

            ClientAdapt.Close();
            File.WriteAllBytes(sPath, tFile.FileContent);

            return(tFile);
        }
Beispiel #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["data"] == null)
        {
            Response.Write("NOPARAMS");
            Response.End();
            return;
        }

        string sData = Request.Params["data"];


        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            //这里也可以根据类型不同,返回适当的情况!
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];


        ClientAdapt.Open();
        TVssService.Client client = ClientAdapt.GetClient();
        TFile tFile = new TFile();

        tFile.FileId      = "";
        tFile.FileContent = System.Text.Encoding.UTF8.GetBytes(sData);
        tFile.FileInfo    = DateTime.Now.ToLongDateString() + "  " + DateTime.Now.ToLongTimeString() + " Send a Blog.";
        tFile.FileKind    = TContentKind.Weibo;
        tFile.FileOwner   = tValidator.VssID;
        tFile.FileSize    = tFile.FileContent.Length;
        tFile.FromApp     = "VssBlog";
        tFile.FileOwner   = tValidator.VssID;

        string fileID = client.Put(tValidator, tFile);

        tFile.FileId      = fileID;
        tFile.FileContent = System.Text.Encoding.UTF8.GetBytes(sData.Replace("[REPLACE_STRMSGID]", fileID));

        fileID = client.Put(tValidator, tFile);

        ClientAdapt.Close();

        Response.Write(fileID);

        Response.End();
    }
Beispiel #21
0
        public static FileTreeNode InitFileTree()
        {
            //进行通信,拉取用户的数据。
            ClientAdapt.Open();
            TVssService.Client client  = ClientAdapt.GetClient();
            string             strTree = client.GetFileTree(GetValidator());

            ClientAdapt.Close();
            if (strTree == "None")
            {
                return(ExampleData.getInitUserFileTree());
            }
            else
            {
                return(JsonConvert.DeserializeObject <FileTreeNode>(strTree));
            }
        }
Beispiel #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["fileID"] == null || Request.Params["friID"] == null)
        {
            Response.Write("NOPARAMS");
            Response.End();
            return;
        }

        string sFile = Request.Params["fileID"];
        string sID   = Request.Params["friID"];

        string[]      arID;
        List <string> listID = new List <string>();

        if (sID != "")
        {
            arID = sID.Split('|');
            foreach (string id in arID)
            {
                listID.Add(id);
            }
        }


        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            //这里也可以根据类型不同,返回适当的情况!
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];

        ClientAdapt.Open();
        TVssService.Client client = ClientAdapt.GetClient();

        client.Provide(tValidator, sFile, listID, "VssBlog-" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());

        ClientAdapt.Close();

        Response.Write("SUCCESS");

        Response.End();
    }
Beispiel #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            //这里也可以根据类型不同,返回适当的情况!
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        if (Request.Files.Count == 0)
        {
            return;
        }
        HttpPostedFile file = Request.Files[0];
        Stream         s    = file.InputStream;

        s.Seek(0, SeekOrigin.Begin);
        byte[] buf = new byte[s.Length];
        s.Read(buf, 0, (int)s.Length);

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];


        ClientAdapt.Open();
        TVssService.Client client = ClientAdapt.GetClient();
        TFile tFile = new TFile();

        tFile.FileId      = "";
        tFile.FileContent = buf;
        tFile.FileInfo    = DateTime.Now.ToLongDateString() + "  " + DateTime.Now.ToLongTimeString() + "Upload a Picture";
        tFile.FileKind    = TContentKind.Picture;
        tFile.FileOwner   = tValidator.VssID;
        tFile.FileSize    = tFile.FileContent.Length;
        tFile.FromApp     = "VssBlog";
        tFile.FileOwner   = tValidator.VssID;

        string fileID = client.Put(tValidator, tFile);

        ClientAdapt.Close();

        Response.Write("<img id='mypic' width='400px' height='300px' src='GetFile.aspx?fileID=" + fileID + "' />");

        Response.End();
    }
Beispiel #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            //这里也可以根据类型不同,返回适当的情况!
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];

        ClientAdapt.Open();

        TVssService.Client client  = ClientAdapt.GetClient();
        TNumber            tNumber = client.GetNumber(tValidator);

        ClientAdapt.Close();

        Response.Write(JsonConvert.SerializeObject(tNumber));
        Response.End();
    }
Beispiel #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["opKind"] == null || Request.Params["friID"] == null)
        {
            Response.Write("NOPARAMS");
            Response.End();
            return;
        }

        int    iKind = Int32.Parse(Request.Params["opKind"]);
        string sID   = Request.Params["friID"];

        string[]      arID;
        List <string> listID = new List <string>();

        if (sID != "")
        {
            arID = sID.Split('|');
            foreach (string id in arID)
            {
                listID.Add(id);
            }
        }


        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            //这里也可以根据类型不同,返回适当的情况!
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];

        ClientAdapt.Open();
        TVssService.Client client = ClientAdapt.GetClient();

        List <string> retList = null;

        switch (iKind)
        {
        case 0:
        {
            //拉取关注列表:
            retList = client.GetFocus(tValidator);
            ClientAdapt.Close();
            Response.Write("{Data:['" + string.Join("','", retList.ToArray()) + "']}");
            Response.End();
            return;
        }

        case 1:
        {
            //拉取我的听众列表:
            retList = client.GetFollow(tValidator);
            ClientAdapt.Close();
            Response.Write("{Data:['" + string.Join("','", retList.ToArray()) + "']}");
            Response.End();
            return;
        }

        case 2:
        {
            //设置关注列表
            client.AddFocus(tValidator, listID);
            ClientAdapt.Close();
            Response.Write("SUCCESS");
            Response.End();
            return;
        }

        case 3:
        {
            //取消关注
            client.DelFocus(tValidator, listID);
            ClientAdapt.Close();
            Response.Write("SUCCESS");
            Response.End();
            return;
        }

        case 4:
        {
            //拉取关注列表:同时要求详细信息
            retList = client.GetFocus(tValidator);
            break;
        }

        case 5:
        {
            //拉取我的听众列表:同时要求详细信息
            retList = client.GetFollow(tValidator);
            break;
        }

        default:
        {
            break;
        }
        }

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

        TValidator tmpValid = new TValidator(tValidator.VssID, tValidator.VssPsw, tValidator.AppID);

        foreach (string s in retList)
        {
            tmpValid.VssID = s;
            listReal.Add(client.GetAppUserInfo(tmpValid));
        }

        ClientAdapt.Close();

        Response.Write("{Data:[" + string.Join(",", listReal.ToArray()) + "]}");
        Response.End();
    }
Beispiel #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["opKind"] == null || Request.Params["vssID"] == null)
        {
            Response.Write("NOPARAMS");
            Response.End();
            return;
        }

        int    iKind = Int32.Parse(Request.Params["opKind"]);
        string vssID = Request.Params["vssID"];

        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            //这里也可以根据类型不同,返回适当的情况!
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];

        ClientAdapt.Open();
        TVssService.Client client = ClientAdapt.GetClient();

        List <TMessages> retList = new List <TMessages>();

        switch (iKind)
        {
        case 0:
        {
            //拉取我的share
            retList = client.GetPublishMessage(tValidator, new List <string>()
                {
                    vssID
                }, 500);
            if (tValidator.VssID == vssID)
            {
                retList.AddRange(client.GetProvideItems(tValidator, 500));
            }
            ClientAdapt.Close();
            break;
        }

        case 1:
        {
            //拉取@我的:
            if (tValidator.VssID == vssID)
            {
                retList = client.GetProvideMessage(tValidator, 500);
            }
            ClientAdapt.Close();
            break;
        }

        case 2:
        {
            //我的大厅
            TValidator    tmpValid = new TValidator(vssID, tValidator.VssPsw, tValidator.AppID);
            List <string> listFri  = client.GetFocus(tmpValid);
            retList = client.GetPublishMessage(tValidator, listFri, 500);
            ClientAdapt.Close();
            break;
        }

        default:
        {
            break;
        }
        }

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

        foreach (TMessages msg in retList)
        {
            if (msg.FileOject.FileKind == TContentKind.Weibo)
            {
                listReal.Add(System.Text.Encoding.UTF8.GetString(msg.FileOject.FileContent));
            }
        }

        ClientAdapt.Close();

        Response.Write("{Data:[" + string.Join(",", listReal.ToArray()) + "]}");
        Response.End();
    }
Beispiel #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["fileID"] == null)
        {
            Response.Write("NOPARAMS");
            Response.End();
            return;
        }

        string fileID = Request["fileID"];



        if (HttpContext.Current.Session["UserLogin"] == null)
        {
            Response.Write("NOLOGIN");
            Response.End();
            return;
        }

        TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"];

        try
        {
            ClientAdapt.Open();
            TVssService.Client client = ClientAdapt.GetClient();
            TFile file = client.Get(tValidator, fileID);
            ClientAdapt.Close();


            switch (file.FileKind)
            {
            case TContentKind.Weibo:
            {
                Response.ContentType = "text/html";
                Response.Write(System.Text.Encoding.UTF8.GetString(file.FileContent));
                break;
            }

            case TContentKind.Picture:
            {
                Response.ContentType = "image/jpeg";
                Response.BinaryWrite(file.FileContent);
                break;
            }

            default:
            {
                Response.ContentType = "text/html";
                Response.BinaryWrite(file.FileContent);
                break;
            }
            }
        }
        catch
        {
            ;
        }

        Response.End();
    }