Esempio n. 1
0
        private string GetRhinoDocumentPathFromLayerName(string LayerName)
        {
            string[] DocumentPaths = RhinoDocument.Worksession.ModelPaths;

            if (DocumentPaths != null)
            {
                foreach (string CurrentPath in DocumentPaths)
                {
                    if (CurrentPath.Contains(LayerName))
                    {
                        return(CurrentPath);
                    }
                }
            }

            return(null);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            pFoot.InnerHtml = String.Format("UpdateServer({0}) at {1}"
                                            , System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
                                            , Request.Headers["host"]
                                            );
            if (!IsPostBack)
            {
                softHelper = new SoftwareHelper(RootPath);
                if (CurrentPath == null || !CurrentPath.Contains(RootPath))
                {
                    CurrentPath = RootPath;
                }

                if (CurrentPath.Equals(RootPath))
                {
                    lblCurrentPath.Text = "\\";
                }
                else
                {
                    lblCurrentPath.Text = CurrentPath.ToString().Substring(RootPath.Length);
                }


                if (String.IsNullOrEmpty(ClientQueryString))
                {
                    //如果没有QueryString,则显示文件列表
                    BindFolderInfoData();
                    BindFileInfoData();
                }
                else
                {
                    //动作
                    String Action = Request.QueryString["Action"];
                    if (Action == null)
                    {
                        Action = String.Empty;
                    }

                    //更新器版本
                    String UpdaterVersion = Request.QueryString["UpdaterVersion"];

                    //写到客户端的字符串
                    String ToWriteString = String.Empty;
                    switch (Action)
                    {
                        #region 获取软件列表 - Action:GetSoftwareList
                    case "GetSoftwareList":
                    {
                        //获取软件列表

                        Response.ContentType = "text/xml";
                        ToWriteString        = softHelper.GetSoftwareListXml();
                        break;
                    }
                        #endregion

                        #region 获取软件信息 - Action:GetSoftwareInfo
                    case "GetSoftwareInfo":
                    {
                        //获取软件信息

                        Response.ContentType = "text/xml";
                        String SoftwareName = Request.QueryString["SoftwareName"];
                        if (String.IsNullOrEmpty(SoftwareName))
                        {
                            ToWriteString = "请输入软件名称";
                        }
                        else
                        {
                            String ErrMsg;
                            ToWriteString = softHelper.GetSoftwareInfoXml(SoftwareName, out ErrMsg);
                            if (ToWriteString == null)
                            {
                                String tmpSoftwareName = String.Empty;

                                /*
                                 * SetQueryStringEncoding(Encoding.Default);
                                 * tmpSoftwareName = Request.QueryString["SoftwareName"];
                                 * ToWriteString = softHelper.GetSoftwareInfoXml(tmpSoftwareName);
                                 */
                                if (ToWriteString == null)
                                {
                                    ToWriteString = String.Format("未找到软件 {0}({1})。错误描述:{2}", SoftwareName, tmpSoftwareName, ErrMsg);
                                }
                            }
                        }
                        break;
                    }
                        #endregion

                        #region 获取软件LOGO - Action:GetSoftwareLogo
                    case "GetSoftwareLogo":
                    {
                        String SoftwareName = Request.QueryString["SoftwareName"];
                        String LogoSize     = Request.QueryString["LogoSize"];

                        if (String.IsNullOrEmpty(SoftwareName))
                        {
                            ToWriteString = "请输入软件名称";
                        }
                        else
                        {
                            DirectoryInfo dir = softHelper.GetSoftwareDirectoryInfo(SoftwareName);
                            if (dir == null)
                            {
                                String tmpSoftwareName = String.Empty;

                                /*
                                 * SetQueryStringEncoding(Encoding.Default);
                                 * tmpSoftwareName = Request.QueryString["SoftwareName"];
                                 * dir = softHelper.GetSoftwareDirectoryInfo(tmpSoftwareName);
                                 */
                                if (dir == null)
                                {
                                    ToWriteString = String.Format("未找到软件 {0}({1})", SoftwareName, tmpSoftwareName);
                                    break;
                                }
                            }
                            String logoFileFullPath = Path.Combine(dir.FullName, "Logo.png");

                            Response.Clear();
                            if (File.Exists(logoFileFullPath))
                            {
                                Bitmap bmp         = new Bitmap(logoFileFullPath);
                                int    intLogoSize = 32;
                                if (!String.IsNullOrEmpty(LogoSize) && Int32.TryParse(LogoSize, out intLogoSize))
                                {
                                    bmp = new Bitmap(bmp, new Size(intLogoSize, intLogoSize));
                                }
                                MemoryStream ms = new MemoryStream();
                                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                                ms.Position = 0;

                                FileInfo newFileInfo = new FileInfo(logoFileFullPath);
                                Response.ContentType = "application";
                                Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(newFileInfo.Name, System.Text.Encoding.UTF8));
                                Response.AddHeader("Content-Length", ms.Length.ToString());
                                Response.BinaryWrite(ms.ToArray());
                            }
                            else
                            {
                                Response.AddHeader("Content-Length", "0");
                            }
                            Response.Flush();
                            Response.Close();
                        }
                        break;
                    }
                        #endregion

                        #region 获取文件版本 - Action:GetFileVersion
                    case "GetFileVersion":
                    {
                        //获取文件版本

                        String    FileName    = Request.QueryString["FileName"];
                        DataTable dtFileInfos = GetFileInfos(FileName, RootPath, SearchOption.AllDirectories);
                        if (dtFileInfos.Rows.Count == 0)
                        {
                            return;
                        }

                        String fileVersionString = dtFileInfos.Rows[0]["FileVersion"].ToString();
                        ToWriteString = fileVersionString;
                        break;
                    }
                        #endregion

                        #region  载文件 - Action:DownloadFile
                    case "DownloadFile":
                    {
                        //下载文件
                        String FileName     = Request.QueryString["FileName"];
                        String fileFullPath = String.Empty;

                        bool IsChangedEncoding = false;
                        while (true)
                        {
                            if (!FileName.StartsWith("."))
                            {
                                DataTable dtFileInfos = GetFileInfos(FileName, RootPath, SearchOption.AllDirectories);
                                if (dtFileInfos.Rows.Count != 0)
                                {
                                    fileFullPath = dtFileInfos.Rows[0]["FileFullPath"].ToString();
                                }
                            }
                            else
                            {
                                fileFullPath = RootPath + FileName.Substring(1);
                            }

                            if (File.Exists(fileFullPath))
                            {
                                break;
                            }
                            if (IsChangedEncoding)
                            {
                                break;
                            }

                            //SetQueryStringEncoding(Encoding.Default);
                            FileName          = Request.QueryString["FileName"];
                            IsChangedEncoding = true;
                        }

                        if (!File.Exists(fileFullPath))
                        {
                            ToWriteString = "未找到该文件!";
                            break;
                        }
                        FileInfo newFileInfo = new FileInfo(fileFullPath);
                        Response.ContentType = "application";
                        Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(newFileInfo.Name, System.Text.Encoding.UTF8));
                        Response.AddHeader("Content-Length", newFileInfo.Length.ToString());
                        Response.WriteFile(newFileInfo.FullName);
                        Response.Flush();
                        Response.Close();
                        break;
                    }
                        #endregion

                        #region 清除Session - Action:ClearSession
                    case "ClearSession":
                    {
                        //清除Session
                        Session.Clear();
                        ToWriteString = "Session已清除!";
                        break;
                    }
                        #endregion

                    default:
                    {
                        ToWriteString = "未定义的命令!";
                        break;
                    }
                    }

                    if (!String.IsNullOrEmpty(ToWriteString))
                    {
                        Response.Charset = "utf-8";
                        Response.AddHeader("Content-Length", Encoding.UTF8.GetByteCount(ToWriteString).ToString());
                        Response.Write(ToWriteString);
                        Response.Flush();
                        Response.Close();
                    }
                }
            }
        }
Esempio n. 3
0
        private KeyValuePair <string, string> FindMostSpecificLongestRuleMatch()
        {
            KeyValuePair <string, string> rulePair = new KeyValuePair <string, string>(SourceHlq, TargetHlq);
            int longestMatchLength = 0;
            int matchLength        = 0;

            foreach (KeyValuePair <string, string> rule in _directoryRules)
            {
                string sourceRule = rule.Key;
                string targetRule = rule.Value;
                if (CurrentPath.StartsWith(sourceRule))
                {
                    matchLength = sourceRule.Length;
                    if (matchLength > longestMatchLength)
                    {
                        longestMatchLength = matchLength;
                        rulePair           = rule;
                    }
                }
            }
            AdvancedDirectoryEntry fileMatch = null;
            AdvancedDirectoryEntry mainMatch = null;
            AdvancedDirectoryEntry aaaMatch  = null;
            AdvancedDirectoryEntry bbbMatch  = null;

            foreach (var entry in _targetSampleDirectoryListing)
            {
                var existingFileMatches = (from existingFile in _targetSampleDirectoryListing
                                           where CurrentPath.Contains(existingFile.FolderGroupMatchFileSpec) && existingFile.StdType != "dir"
                                           select existingFile).ToList();
                if (existingFileMatches.Count() > 0)
                {
                    foreach (var existingFile in existingFileMatches)
                    {
                        if (existingFile.FolderGroup == "MAIN" || existingFile.FolderGroup == "TEST")
                        {
                            mainMatch = existingFile;
                        }
                        else if (existingFile.FolderGroup == "BBB" || existingFile.FolderGroup == "BBBTEST")
                        {
                            //Ignore BBB matches.
                        }
                        else if (existingFile.FolderGroup == "AAA" || existingFile.FolderGroup == "AAATEST")
                        {
                            aaaMatch = existingFile;
                        }
                    }
                }
            }
            if (mainMatch != null)
            {
                fileMatch = mainMatch;
            }
            else if (aaaMatch != null)
            {
                fileMatch = aaaMatch;
            }
            if (fileMatch != null)
            {
                string source = CurrentPath;
                string target = fileMatch.FolderGroupFullFileSpec.Replace(TargetSampleHlq, TargetHlq);
                rulePair = new KeyValuePair <string, string>(source, target);
            }
            else
            {
                foreach (KeyValuePair <string, string> rule in _fileRules)
                {
                    string sourceRule = rule.Key;
                    string targetRule = rule.Value;
                    if (CurrentPath.StartsWith(sourceRule))
                    {
                        matchLength = sourceRule.Length;
                        if (matchLength > longestMatchLength)
                        {
                            longestMatchLength = matchLength;
                            rulePair           = rule;
                        }
                    }
                }
            }
            return(rulePair);
        }
Esempio n. 4
0
        private void UpdatePath()
        {
            WowPosition myPosition        = StateMachine.WowDataAdapter.ActivePlayerPosition;
            Vector3     myPosAsVector     = new Vector3(myPosition.x, myPosition.y, myPosition.z);
            Vector3     targetPosAsVector = new Vector3(UnitToFollow.Position.x, UnitToFollow.Position.y, UnitToFollow.Position.z);

            List <Vector3> waypoints = new List <Vector3> {
                targetPosAsVector
            };

            if (StateMachine.PathfindingClient != null)
            {
                waypoints = StateMachine.PathfindingClient.GetPath(myPosAsVector, targetPosAsVector, StateMachine.WowDataAdapter.MapId);
                AmeisenBotLogger.Instance.Log($"[{StateMachine.WowActionExecutor.ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tFound Path with {waypoints.Count} nodes", LogLevel.Verbose);
            }

            foreach (Vector3 pos in waypoints)
            {
                WowPosition wpos = new WowPosition(pos);
                if (pos.X != myPosAsVector.X && pos.Y != myPosAsVector.Y && pos.Z != myPosAsVector.Z && CurrentPath != null && !CurrentPath.Contains(wpos))
                {
                    CurrentPath.Enqueue(wpos);
                }
            }

            if (targetPosAsVector.X != myPosAsVector.X && targetPosAsVector.Y != myPosAsVector.Y && targetPosAsVector.Z != myPosAsVector.Z)
            {
                CurrentPath.Enqueue(new WowPosition(targetPosAsVector));
            }
        }