public void Parse(Stream stream)
        {
            if (stream == null)
            {
                throw new InvalidOperationException("Stream cannot be null");
            }

            GedcomLine lastLine = default;

            using (var reader = new StreamReader(stream))
            {
                var firstRawLine = reader.ReadLine();

                if (firstRawLine == null)
                {
                    throw new InvalidOperationException("File empty");
                }

                var firstLine = ParserHelper.ParseLine(firstRawLine);
                if (firstLine.Level != 0 && firstLine.GetTagOrRef() != "HEAD")
                {
                    throw new InvalidOperationException("GEDCOM Header Not Found");
                }

                LineProvider lineProvider = new LineProvider(reader);

                var gedcomHeaderParse = HeaderParser.Parse(firstLine, lineProvider);
                _headerCallback?.Invoke(gedcomHeaderParse.Result);

                var newLine = gedcomHeaderParse.Line;
                lastLine = newLine;

                while (!newLine.Equals(default))
Example #2
0
            /// <summary>
            /// 从配置文件中读取上次登录信息
            /// </summary>
            public void FromFile(string file)
            {
                string    pre = "LastLoginItem";
                Hashtable ht  = EagleFileIO.ReadEagleDotTxtFileToHashTable();

                m_username  = EagleString.egString.Null2S(ht[pre + "UserName"]);
                m_password  = EagleString.egString.Null2S(ht[pre + "PassWord"]);
                m_password  = EagleString.BaseFunc.Crypt.CryptString.DeCode(m_password);
                m_remember  = (EagleString.egString.Null2S(ht[pre + "Remember"]) == "1");
                m_autologin = (EagleString.egString.Null2S(ht[pre + "AutoLogin"]) == "1");
                try
                {
                    m_provider = (LineProvider)byte.Parse(EagleString.egString.Null2S(ht[pre + "Provider"]));
                }
                catch
                {
                    m_provider = LineProvider.DianXin;
                }
                m_server_login  = EagleString.egString.Null2S(ht[pre + "ServerLogin"]);
                m_server_update = EagleString.egString.Null2S(ht[pre + "ServerUpdate"]);
                m_btocuser      = (EagleString.egString.Null2S(ht[pre + "BtocUser"]) == "1");
                m_subnumber     = EagleString.egString.Null2S(ht[pre + "SubNumber"]);
                //m_b2cipservice = EagleString.egString.Null2S(ht[pre + "b2cIPservice"]);
                m_b2cipservice = EagleString.egString.Null2S(ht[pre + "b2cIPservice"]);
                if (m_b2cipservice.ToUpper().StartsWith("HTTP://"))
                {
                    m_b2cipservice = m_b2cipservice.Substring(7);
                }
                m_b2cipsite = EagleString.egString.Null2S(ht[pre + "b2cIPsite"]);
            }
Example #3
0
 public SC(ServerAddr sa, LineProvider lp, int index, string wservice, string wsite)
 {
     SA         = sa;
     LP         = lp;
     INDEX      = index;
     WEBSERVICE = wservice;
     WEBSITE    = wsite;
 }
Example #4
0
        public ServerCenterB2B()
        {
            int          index = 0;
            LineProvider dx    = LineProvider.DianXin;
            LineProvider wt    = LineProvider.WangTong;
            LineProvider vpn   = LineProvider.VPN;
            ServerAddr   s;

            //易格,电信
            index = 0;
            s     = ServerAddr.Eagle;
#if SHANGHAI
            m_ls.Add(new SC(s, dx, index++, "http://b2bws.cn95161.com/egws.asmx", "http://b2b.cn95161.com/login.aspx"));
#else
            m_ls.Add(new SC(s, dx, index++, "http://yinge.eg66.com/WS3/egws.asmx", "http://yinge.eg66.com/EagleWeb2/login.aspx"));
#endif
            //易格,网通
            index = 0;
#if SHANGHAI
            m_ls.Add(new SC(s, dx, index++, "http://b2bws.cn95161.com/egws.asmx", "http://b2b.cn95161.com/login.aspx"));
#else
            m_ls.Add(new SC(s, wt, index++, "http://wangtong.eg66.com/WS3/egws.asmx", "http://wangtong.eg66.com/EagleWeb2/login.aspx"));
#endif

            //郑州机场,电信
            s     = ServerAddr.ZhenZhouJiChang;
            index = 0;
            m_ls.Add(new SC(s, dx, index++, "http://10.2.1.23/ws/egws.asmx", "http://10.2.1.23/eagleweb/login.aspx"));
            //郑州机场,网通
            index = 0;
            m_ls.Add(new SC(s, wt, index++, "http://10.2.1.23/ws/egws.asmx", "http://10.2.1.23/eagleweb/login.aspx"));
            //郑州机场,VPN
            index = 0;
            m_ls.Add(new SC(s, vpn, index++, "http://www.zza96666.cn/ws/egws.asmx", "http://www.zza96666.cn/EagleWeb/login.aspx"));


            //昆明,电信
            index = 0;
            s     = ServerAddr.KunMing;
            m_ls.Add(new SC(s, dx, index++, "http://220.165.8.58/Ws3/egws.asmx", "http://220.165.8.58/EagleWeb/login.aspx"));
            //昆明,网通
            index = 0;
            m_ls.Add(new SC(s, wt, index++, "http://220.165.8.58/Ws3/egws.asmx", "http://220.165.8.58/EagleWeb/login.aspx"));

            //RWY=5
            index = 0;
            s     = ServerAddr.RWY;
            //m_ls.Add(new SC(s, dx, index++, "http://222.73.204.236/egws.asmx", "http://222.73.204.236/egws.asmx"));
            m_ls.Add(new SC(s, dx, index++, "http://www.gz161.com/ws/egws.asmx", "http://www.gz161.com/ws/egws.asmx"));
            index = 0;
            //m_ls.Add(new SC(s, wt, index++, "http://222.73.204.236/egws.asmx", "http://222.73.204.236/egws.asmx"));
            m_ls.Add(new SC(s, wt, index++, "http://www.gz161.com/ws/egws.asmx", "http://www.gz161.com/ws/egws.asmx"));

            //共享平台
            index = 0;
            s     = ServerAddr.EgShare;
            m_ls.Add(new SC(s, dx, index++, "http://59.175.179.130/egsharews/egws.asmx", "http://220.165.8.58/EagleWeb/login.aspx"));
        }
Example #5
0
        /// <summary>
        /// Creates a <see cref="HexLinePositionInfo"/>
        /// </summary>
        /// <param name="linePosition">Line position</param>
        /// <returns></returns>
        public HexLinePositionInfo GetLinePositionInfo(int linePosition)
        {
            if (linePosition >= Text.Length)
            {
                return(HexLinePositionInfo.CreateVirtualSpace(linePosition, Text.Length));
            }

            if (IsOffsetColumnPresent)
            {
                var span = GetOffsetSpan();
                if (span.Contains(linePosition))
                {
                    return(HexLinePositionInfo.CreateOffset(linePosition, linePosition - span.Start));
                }
            }

            if (IsValuesColumnPresent)
            {
                var valuesSpan = GetValuesSpan(onlyVisibleCells: false);
                if (valuesSpan.Contains(linePosition))
                {
                    int cellIndex = (linePosition - valuesSpan.Start) / LineProvider.GetCharsPerCellIncludingSeparator(HexColumnType.Values);
                    var cell      = ValueCells[cellIndex];
                    if (cell.SeparatorSpan.Contains(linePosition))
                    {
                        return(HexLinePositionInfo.CreateValueCellSeparator(linePosition, cell));
                    }
                    return(HexLinePositionInfo.CreateValue(linePosition, cell));
                }
            }

            if (IsAsciiColumnPresent)
            {
                var asciiSpan = GetAsciiSpan(onlyVisibleCells: false);
                if (asciiSpan.Contains(linePosition))
                {
                    int cellIndex = linePosition - asciiSpan.Start;
                    var cell      = AsciiCells[cellIndex];
                    return(HexLinePositionInfo.CreateAscii(linePosition, cell));
                }
            }

            foreach (var column in ColumnOrder)
            {
                var span = GetSpan(column, onlyVisibleCells: false);
                if (span.End == linePosition)
                {
                    return(HexLinePositionInfo.CreateColumnSeparator(linePosition));
                }
            }

            throw new InvalidOperationException();
        }
Example #6
0
 public void SetLoginInfo(string username, string password, LineProvider lp)
 {
     //EagleExtension.Api.login2server(false, "", "", username, password, lp, lib2c, ref li);//得到li
     li.b2b.username   = Options.GlobalVar.B2bLoginName;
     li.b2b.password   = Options.GlobalVar.B2bLoginPassword;
     li.b2b.webservice = Options.GlobalVar.B2bWebServiceURL;
     li.b2b.webside    = Options.GlobalVar.B2bLoginURL;
     if (!string.IsNullOrEmpty(Options.GlobalVar.B2bLoginXml))
     {
         li.b2b.lr = new LoginResult(Options.GlobalVar.B2bLoginXml);
     }
 }
Example #7
0
        /// <summary>
        /// 配置共享登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="newipid">共享配置信息</param>
        /// <param name="loginInfo">引用输出登录信息</param>
        public static void login2server(
            string username,
            string password,
            string newipid,
            ref EagleString.LoginInfo loginInfo
            )
        {
            string b2buser     = username;
            string b2bpass     = password;
            string loginb2bxml = string.Empty;
            bool   flagLogin   = false;

            EagleString.LineProvider    lp    = new LineProvider();
            EagleString.ServerCenterB2B scb2b = new ServerCenterB2B();
            string b2bWebSite    = "";
            string b2bWebService = "";

            scb2b.ServerAddressB2B(EagleFileIO.Server, lp, 0, ref b2bWebService, ref b2bWebSite);

            EagleWebService.kernalFunc kf = new EagleWebService.kernalFunc(b2bWebService);
            kf.LogIn(b2buser, b2bpass, ref loginb2bxml, ref flagLogin);
            if (!flagLogin)
            {
                throw new Exception("登录B2B失败,请检查网络及用户名密码是否正确!");
            }
            ///把共享的配置加进去
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(loginb2bxml);
            XmlNode xn = xmldoc.SelectSingleNode("//eg//IPS");

            xn.InnerXml += newipid;
            loginb2bxml  = xmldoc.InnerXml;
            ///共享配置加入完毕
            EagleString.LoginResult lr = new LoginResult(loginb2bxml);
            if (lr.EXPIRED)
            {
                throw new Exception("该B2B用户已失效!");
            }
            if (lr.AGENT_STAT != 0)
            {
                throw new Exception("该B2B用户所在代理商已失效!");
            }
            if (lr.USER_STAT != 0)
            {
                throw new Exception("该B2B用户状态已失效!");
            }
            loginInfo.b2b.username   = username;
            loginInfo.b2b.password   = password;
            loginInfo.b2b.webservice = b2bWebService;
            loginInfo.b2b.lr         = lr;
        }
Example #8
0
 /// <summary>
 /// 取对应运营商的Web服务地址与后台管理地址
 /// </summary>
 /// <param name="sa">运营商</param>
 /// <param name="lp">线路(电信或网通)</param>
 /// <param name="pos">当运营商有多个地址指向同一台服务器时,取pos对应的地址</param>
 /// <param name="urlWebServer">返回的Web服务地址</param>
 /// <param name="urlWebSite">返回的后台地址</param>
 public void ServerAddressB2B(ServerAddr sa, LineProvider lp, int pos, ref string urlWebService, ref string urlWebSite)
 {
     try
     {
         urlWebService = "";
         urlWebSite    = "";
         //该运营商有多少个地址?
         int count = 0;
         for (int i = 0; i < m_ls.Count; ++i)
         {
             if (m_ls[i].SA == sa && m_ls[i].LP == lp)
             {
                 count++;
             }
         }
         //计算pos对应的index
         if (count == 0)
         {
             return;
         }
         int index = pos % count;
         //再按sa,lp,index找对应的地址
         for (int i = 0; i < m_ls.Count; ++i)
         {
             if (m_ls[i].SA == sa && m_ls[i].LP == lp && index == m_ls[i].INDEX)
             {
                 urlWebService = m_ls[i].WEBSERVICE;
                 urlWebSite    = m_ls[i].WEBSITE;
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         EagleFileIO.LogWrite("ServerCenterB2B.ServerAddressB2B : " + ex.Message);
     }
 }
Example #9
0
        /// <summary>
        /// Gets the closest cell position
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="onlyVisibleCells">true to only return cells with data</param>
        /// <returns></returns>
        public HexCellPosition?GetClosestCellPosition(HexLinePositionInfo position, bool onlyVisibleCells)
        {
            switch (position.Type)
            {
            case HexLinePositionInfoType.ValueCell:
            case HexLinePositionInfoType.AsciiCell:
                break;

            case HexLinePositionInfoType.ValueCellSeparator:
                Debug.Assert(position.Cell.CellSpan.End == position.Position);
                position = HexLinePositionInfo.CreateValue(position.Cell.CellSpan.End - 1, position.Cell);
                break;

            case HexLinePositionInfoType.Offset:
            case HexLinePositionInfoType.ColumnSeparator:
            case HexLinePositionInfoType.VirtualSpace:
                var closestPos = GetClosestCellPosition(position.Position);
                if (closestPos == null)
                {
                    return(null);
                }
                Debug.Assert(closestPos.Value.IsAsciiCell || closestPos.Value.IsValueCell);
                position = closestPos.Value;
                break;

            default:
                throw new InvalidOperationException();
            }

            var cell         = position.Cell;
            int cellPosition = position.CellPosition;

            switch (position.Type)
            {
            case HexLinePositionInfoType.AsciiCell:
                if (!IsAsciiColumnPresent)
                {
                    return(null);
                }
                if (onlyVisibleCells && !cell.HasData)
                {
                    var visible = GetVisible(AsciiCells, cell);
                    if (visible == null)
                    {
                        return(null);
                    }
                    cell         = visible.Value.cell;
                    cellPosition = visible.Value.cellPosition;
                }
                return(new HexCellPosition(HexColumnType.Ascii, cell.BufferStart, cellPosition));

            case HexLinePositionInfoType.ValueCell:
                if (!IsValuesColumnPresent)
                {
                    return(null);
                }
                if (onlyVisibleCells && !cell.HasData)
                {
                    var visible = GetVisible(ValueCells, cell);
                    if (visible == null)
                    {
                        return(null);
                    }
                    cell         = visible.Value.cell;
                    cellPosition = visible.Value.cellPosition;
                }
                return(new HexCellPosition(HexColumnType.Values, LineProvider.GetValueBufferSpan(cell, cellPosition).Start, cellPosition));

            case HexLinePositionInfoType.Offset:
            case HexLinePositionInfoType.ValueCellSeparator:
            case HexLinePositionInfoType.ColumnSeparator:
            case HexLinePositionInfoType.VirtualSpace:
            default:
                throw new InvalidOperationException();
            }
        }
Example #10
0
        /// <summary>
        /// 与控件无关的登录函数,主要得到LoginInfo实例,可放到全局函数中EagleExtension.Api
        /// </summary>
        private void login2server(bool isB2c, string b2cService, string b2cManager, string username, string password, LineProvider lp, EagleString.LoginResultBtoc.LOGIN_INFO_BTOC resB2c, EagleString.LoginInfo loginInfo)
        {
            loginInfo.borc = (isB2c ? LoginInfo.BORC.b2c : LoginInfo.BORC.b2b);
            if (isB2c)
            {
                EagleExtension.EagleExtension.LoginB2c(username, password, ref resB2c, b2cManager, b2cService);
                loginInfo.b2c.username   = username;
                loginInfo.b2c.password   = password;
                loginInfo.b2c.webservice = b2cService;
                loginInfo.b2c.website    = b2cManager;
                loginInfo.b2c.lr         = resB2c;
            }
            string loginb2bxml = "";

            //here todo: get b2b webservice address
            EagleString.ServerCenterB2B scb2b = new ServerCenterB2B();
            string b2bWebSite    = "";
            string b2bWebService = "";

            scb2b.ServerAddressB2B(EagleFileIO.Server, lp, 0, ref b2bWebService, ref b2bWebSite);
            EagleWebService.kernalFunc kf = new EagleWebService.kernalFunc(b2bWebService);
            bool   flagLogin = false;
            string b2buser   = username;
            string b2bpass   = password;

            if (isB2c)
            {
                b2buser = resB2c.mapuser;
                b2bpass = resB2c.mappass;
            }
            kf.LogIn(b2buser, b2bpass, ref loginb2bxml, ref flagLogin);
            if (!flagLogin)
            {
                throw new Exception("登录失败,请检查网络及用户名密码是否正确!");
            }
            lr = new LoginResult(loginb2bxml);
            if (lr.EXPIRED)
            {
                throw new Exception("该B2B用户已失效!");
            }
            if (lr.AGENT_STAT != 0)
            {
                throw new Exception("该B2B用户所在代理商已失效!");
            }
            if (lr.USER_STAT != 0)
            {
                throw new Exception("该B2B用户状态已失效!");
            }
            loginInfo.b2b.username   = b2buser;
            loginInfo.b2b.password   = b2bpass;
            loginInfo.b2b.webservice = b2bWebService;
            loginInfo.b2b.webside    = b2bWebSite;
            loginInfo.b2b.lr         = lr;
        }