Ejemplo n.º 1
0
        /// <summary>
        /// 用户登录按钮点击事件
        /// </summary>
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            string ServerHost = textBoxServerHost.Text;
            string LoginId    = textBoxLoginId.Text;
            string Password   = textBoxPassword.Text;
            string AutoLogin  = checkBoxAutoLogin.Checked.ToString().ToLower();

            if (AppCommon.StringCheck(ServerHost, @"^(http|https)\:\/\/[\w\-\.\:]+\/?$") == false)
            {
                labelLoginTips.Text = LangTable["tipsServerHost"].TypeString();
                return;
            }

            AppConfig.ServerHost = ServerHost;

            if (string.IsNullOrEmpty(LoginId) == true)
            {
                labelLoginTips.Text = LangTable["tipsLoginId"].TypeString();
                return;
            }

            AppConfig.LoginId = LoginId;

            if (string.IsNullOrEmpty(Password) == true)
            {
                labelLoginTips.Text = LangTable["tipsPassword"].TypeString();
                return;
            }

            AppConfig.Password = Password;

            AppConfig.AutoLogin = AutoLogin;

            LoginProcess(ServerHost, LoginId, Password, AutoLogin, true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取自动登录状态
        /// </summary>
        private static string GetAutoLogin()
        {
            string AutoLogin = ConfigValue("AutoLogin").TypeString();

            if (AppCommon.StringCheck(AutoLogin, @"^(true|false)$") == false)
            {
                AutoLogin = "******";
            }

            return(AutoLogin);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 任务队列
        /// </summary>
        private static void TaskQueue()
        {
            XmlDocument XDocument       = new XmlDocument();
            XmlNodeList XNodes          = default(XmlNodeList);
            string      LocalFolderPath = "";
            int         NetFolderId     = 0;
            string      NetFolderPath   = "";
            string      Type            = "";

            XDocument.Load(AppConfig.DataPath);

            XNodes = XDocument.SelectNodes("/rules/item");

            foreach (XmlNode XNode in XNodes)
            {
                List <Hashtable> LocalDataList  = new List <Hashtable>();
                List <Hashtable> NetDataList    = new List <Hashtable>();
                Hashtable        NetFolderTable = new Hashtable();

                LocalFolderPath = XNode.SelectSingleNode("localFolderPath").InnerText.TypeString();
                NetFolderId     = XNode.SelectSingleNode("netFolderId").InnerText.TypeInt();
                NetFolderPath   = XNode.SelectSingleNode("netFolderPath").InnerText.TypeString();
                Type            = XNode.SelectSingleNode("type").InnerText.TypeString();

                LocalDataToList(LocalFolderPath, ref LocalDataList);

                NetDataToList(NetFolderId, ref NetDataList, ref NetFolderTable);

                // 判断网络文件夹是否具有上传权限
                if (AppCommon.StringCheck(NetFolderTable["Purview"].TypeString(), @"^(uploader|editor|manager|creator)$") == true)
                {
                    if (Type == "sync" || Type == "upload")
                    {
                        // 判断网络文件夹是否锁定状态
                        if (NetFolderTable["Lock"].TypeInt() == 0)
                        {
                            UploadScan(LocalFolderPath, ref LocalDataList, NetFolderId, NetFolderPath, NetFolderTable["Purview"].TypeString(), ref NetDataList);
                        }
                    }
                }

                // 判断网络文件夹是否具有下载权限
                if (AppCommon.StringCheck(NetFolderTable["Purview"].TypeString(), @"^(downloader|uploader|editor|manager|creator)$") == true)
                {
                    if (Type == "sync" || Type == "download")
                    {
                        DownloadScan(LocalFolderPath, ref LocalDataList, NetFolderId, NetFolderPath, NetFolderTable["Purview"].TypeString(), ref NetDataList);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取服务器主机网址
        /// </summary>
        private static string GetServerHost()
        {
            string ServerHost = ConfigValue("ServerHost").TypeString();

            if (AppCommon.StringCheck(ServerHost, @"^(http|https)\:\/\/[\w\-\.\:]+\/?$") == false)
            {
                return(string.Empty);
            }

            if (ServerHost.Substring(ServerHost.Length - 1, 1) == "/")
            {
                ServerHost = ServerHost.Substring(0, ServerHost.Length - 1);
            }

            return(ServerHost);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 网络文件夹扫描(下载文件)
        /// </summary>
        private static void DownloadScan(string LocalFolderPath, ref List <Hashtable> LocalDataList, int NetFolderId, string NetFolderPath, string NetFolderPurview, ref List <Hashtable> NetDataList)
        {
            int Index = 0;

            for (Index = 0; Index < NetDataList.Count; Index++)
            {
                // 判断是否文件版本(跳过)
                if (NetDataList[Index]["VersionId"].TypeInt() > 0)
                {
                    continue;
                }

                Hashtable LocalTable = new Hashtable();

                // 找查本地是否存在该文件并载入到LocalTable
                LocalDataTable(NetDataList[Index]["Name"].TypeString(), ref LocalDataList, ref LocalTable);

                // 判断本地是否存在该文件
                if (LocalTable["Exist"].TypeBool() == false)
                {
                    FileDownload(NetDataList[Index]["Id"].TypeInt(), NetDataList[Index]["CodeId"].TypeString(), NetDataList[Index]["Name"].TypeString(), LocalFolderPath);
                }
                else
                {
                    // 利用哈希码判断网络文件与本地文件是否相同
                    if (NetDataList[Index]["Hash"].TypeString() == LocalTable["Hash"].TypeString())
                    {
                        // 文件相同无需处理
                    }
                    else
                    {
                        // 判断网络文件夹是否具有版本下载权限
                        if (AppCommon.StringCheck(NetFolderPurview, @"^(editor|manager|creator)$") == true)
                        {
                            // 利用更新时间判断文件版本新旧
                            if (DateTime.Compare(NetDataList[Index]["UpdateTime"].TypeDateTime(), LocalTable["UpdateTime"].TypeDateTime()) > 0)
                            {
                                // 网络文件版本比本地文件版本新(下载新版本)
                                FileDownload(NetDataList[Index]["Id"].TypeInt(), NetDataList[Index]["CodeId"].TypeString(), NetDataList[Index]["Name"].TypeString(), LocalFolderPath);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 本地文件夹扫描(上传文件)
        /// </summary>
        private static void UploadScan(string LocalFolderPath, ref List <Hashtable> LocalDataList, int NetFolderId, string NetFolderPath, string NetFolderPurview, ref List <Hashtable> NetDataList)
        {
            int Index = 0;

            for (Index = 0; Index < LocalDataList.Count; Index++)
            {
                Hashtable NetTable = new Hashtable();

                // 找查网络是否存在该文件并载入到NetTable
                NetDataTable(LocalDataList[Index]["Name"].TypeString(), ref NetDataList, ref NetTable);

                // 判断网络是否存在该文件
                if (NetTable["Exist"].TypeBool() == false)
                {
                    FileUpload(LocalDataList[Index]["Path"].TypeString(), LocalDataList[Index]["Size"].TypeString(), LocalDataList[Index]["Hash"].TypeString(), NetFolderId);
                }
                else
                {
                    // 利用哈希码判断本地文件与网络文件是否相同
                    if (LocalDataList[Index]["Hash"].TypeString() == NetTable["Hash"].TypeString())
                    {
                        // 文件相同无需处理
                    }
                    else
                    {
                        // 判断文件是否锁定状态
                        if (NetTable["Lock"].TypeInt() == 0)
                        {
                            // 判断网络文件夹是否具有版本上传权限
                            if (AppCommon.StringCheck(NetFolderPurview, @"^(editor|manager|creator)$") == true)
                            {
                                // 利用哈希码判断网络是否存在该文件版本
                                if (NetVersionExist(LocalDataList[Index]["Hash"].TypeString(), NetTable["Id"].TypeInt(), NetDataList) == false)
                                {
                                    // 不存在该文件版本(上传新版本)
                                    FileUpversion(LocalDataList[Index]["Path"].TypeString(), LocalDataList[Index]["Size"].TypeString(), LocalDataList[Index]["Hash"].TypeString(), NetTable["Id"].TypeInt());
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 本地文件夹浏览按钮点击事件
        /// </summary>
        private void ButtonBrowse_Click(object sender, EventArgs e)
        {
            DialogResult Result;
            string       Path = "";

            Result = folderBrowserDialog.ShowDialog();

            if (Result == DialogResult.OK)
            {
                Path = folderBrowserDialog.SelectedPath;

                if (AppCommon.StringCheck(Path, @"^[A-Z]\:\\[\s\S]+$") == false)
                {
                    MessageBox.Show(LangTable["tipsSelectLocalFolder"].TypeString());
                    return;
                }

                textBoxLocalFolderPath.Text = Path;
            }
        }