Exemplo n.º 1
0
 public bool ExternelServerStart()
 {
     try
     {
         DelegateState.InvokeDispatchStateEvent("正在初始化外围服务...");
         string    FILEPATH    = Application.StartupPath + @"/sysconfig.xml";
         Hashtable htServer    = XMLClass.GetXMLByParentNode(FILEPATH, XMLConstClass.NODE_SERVER);
         string    port        = "2018";
         string    maxclient   = "200";
         string    rcvtimeout  = "100";
         string    sendtimeout = "100";
         string    buffersize  = "128";
         if (htServer.Contains(XMLConstClass.PORT))
         {
             port = htServer[XMLConstClass.PORT].ToString();
         }
         if (htServer.Contains(XMLConstClass.MAXCONNECTCOUNT))
         {
             maxclient = htServer[XMLConstClass.MAXCONNECTCOUNT].ToString();
         }
         if (htServer.Contains(XMLConstClass.RECTIMEOUT))
         {
             rcvtimeout = htServer[XMLConstClass.RECTIMEOUT].ToString();
         }
         if (htServer.Contains(XMLConstClass.SENDTIMEOUT))
         {
             sendtimeout = htServer[XMLConstClass.SENDTIMEOUT].ToString();
         }
         if (htServer.Contains(XMLConstClass.BUFFERSIZE))
         {
             buffersize = htServer[XMLConstClass.BUFFERSIZE].ToString();
         }
         IServerConfig nannyclient_serverconfig = new SocketServer.ServerConfig()
         {
             Port = Convert.ToInt16(port), MaxClientCount = Convert.ToInt16(maxclient), RecOutTime = Convert.ToInt16(rcvtimeout), ReceiveBufferSize = Convert.ToInt16(buffersize), SendBufferSize = Convert.ToInt16(buffersize)
         };
         if (_server == null)
         {
             _server             = new TCPServer();
             _server.ReceiveMes += _server_ReceiveMes;
         }
         if (!_server.Setup(nannyclient_serverconfig))
         {
             return(false);
         }
         else
         {
             if (!_server.Start())
             {
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         DelegateState.InvokeDispatchStateEvent(ex.Message);
         return(false);
     }
 }
Exemplo n.º 2
0
        private void FrmSecondDMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (MsgBox.ShowQuestion("确定退出当前系统?") != DialogResult.Yes)
                {
                    e.Cancel = true; return;
                }
                string RemeberFilePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\SkinFile.txt";
                if (File.Exists(RemeberFilePath))
                {
                    File.Delete(RemeberFilePath);
                }
                File.AppendAllText(RemeberFilePath, UserLookAndFeel.Default.ActiveSkinName);

                string          path            = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\StorageColor.txt";
                BackgroundLayer layer           = m_canvas.Model.BackgroundLayer as BackgroundLayer;
                Color           BackGroundColor = layer.Color;
                Hashtable       hs = new Hashtable();
                hs["BackGroundColor"] = BackGroundColor.R + "," + BackGroundColor.G + "," + BackGroundColor.B;
                XMLClass.AppendXML(path, "StorageColor", hs);
            }
            catch (Exception ex)
            { MsgBox.ShowError(ex.Message); }
        }
Exemplo n.º 3
0
 private static void CollectAttributes(ref XMLClass xmlClass, XmlNode node)
 {
     foreach (XmlAttribute attr in node.Attributes)
     {
         if (null == xmlClass.Elements.SingleOrDefault(o => o.Name == attr.Name))
         {
             xmlClass.Elements.Add(new Element("string ", attr.Name, XMLType.Attribute));
         }
     }
 }
Exemplo n.º 4
0
        private static void SendMail()
        {
            XMLClass oXMLeParamts = new XMLClass();
            string   eToWho1      = "*****@*****.**";
            string   eFromWho1    = oXMLeParamts.GetParaXml("eFromWho");

            using (NSysDB.NTSQL.SQL1 query = new NSysDB.NTSQL.SQL1())
            {
                query.AutoEMail(eToWho1, "", eFromWho1, "", "PDF未產生,盡速處理");
            }
        }
Exemplo n.º 5
0
        private void InitCanvas(string filename, bool IsNew)
        {
            if (!IsNew)
            {
                try
                {
                    AGVDAccess.AGVClientDAccess.GetPlanSet();
                    string tempFile = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\temSet.agv";
                    if (File.Exists(tempFile))
                    {
                        filename = tempFile;
                    }
                }
                catch (Exception ex)
                { MsgBox.ShowError(ex.Message); }
            }
            try
            {
                m_data = new DataModel();
                if (filename.Length > 0 && File.Exists(filename) && m_data.Load(filename, null))
                {
                    m_filename = filename;
                }
                m_canvas      = new CanvasCtrller(this, m_data);
                m_canvas.Dock = DockStyle.Fill;
                pclMain.Controls.Clear();
                pclMain.Controls.Add(m_canvas);
                m_canvas.SetCenter(new UnitPoint(0, 0));
                m_canvas.IsChooseSpecial = false;


                string storageColorPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\StorageColor.txt";
                //加载记忆画布背景颜色
                if (File.Exists(storageColorPath))
                {
                    Hashtable hs = XMLClass.GetXMLByParentNode(storageColorPath, "StorageColor");
                    if (hs["BackGroundColor"] != null && !string.IsNullOrEmpty(hs["BackGroundColor"].ToString()))
                    {
                        string[] bgColor         = hs["BackGroundColor"].ToString().Split(',');
                        Color    BackGroundColor = Color.FromArgb(Convert.ToInt16(bgColor[0]), Convert.ToInt16(bgColor[1]), Convert.ToInt16(bgColor[2]));
                        if (m_canvas != null)
                        {
                            BackgroundLayer layer = m_canvas.Model.BackgroundLayer as BackgroundLayer;
                            layer.Color = BackGroundColor;
                        }
                    }
                }
            }
            catch (Exception ex)
            { MsgBox.ShowError(ex.Message); }
        }
Exemplo n.º 6
0
        public void MoveTicketToInProgressColumn()
        {
            string testName = "MoveTicketToInProgressColumn";

            Console.WriteLine("Test " + testName + " has started.");
            string asserMsg     = "";
            bool   isTestPassed = false;

            try
            {
                XMLClass.LoadDocument();
                GoToURL(XMLClass.GetUrl());

                if (IsKanbanBoardOpened())
                {
                    ToDoColumn.ClickAddButton();
                    int numberBeforeMovingTicket  = ToDoColumn.CountTickets();
                    int numberOfInProgressTickets = InProgressColumn.CountTickets();

                    ToDoColumn.MoveAddedTicketToInProgressColumn();
                    int numberOfToDoTickets     = ToDoColumn.CountTickets();
                    int numberAfterMovingTicket = InProgressColumn.CountTickets();

                    if ((numberOfToDoTickets == numberBeforeMovingTicket - 1) && (numberAfterMovingTicket == numberOfInProgressTickets + 1))
                    {
                        isTestPassed = true;
                        Console.WriteLine("Test passed.");
                    }
                    else
                    {
                        Console.WriteLine("Drag and drop is not performed.");
                        Console.WriteLine("Test failed.");
                    }
                }
            }
            catch (Exception ex)
            {
                asserMsg = ex.Message;
                Console.WriteLine(asserMsg);
            }
            finally
            {
                Assert.IsTrue(isTestPassed, asserMsg);
            }
        }
Exemplo n.º 7
0
 private static void CollectChildClass(ref Dictionary <string, XMLClass> xmlClsCollection, XmlNode node)
 {
     foreach (XmlNode childNode in node.ChildNodes)
     {
         XMLClass xmlClass;
         if (xmlClsCollection.ContainsKey(childNode.Name))
         {
             xmlClass = xmlClsCollection[childNode.Name];
         }
         else
         {
             xmlClass = new XMLClass();
             xmlClsCollection.Add(childNode.Name, xmlClass);
         }
         CollectAttributes(ref xmlClass, childNode);
         CollectElements(ref xmlClass, childNode);
         CollectChildClass(ref xmlClsCollection, childNode);
     }
 }
Exemplo n.º 8
0
        public void DeleteAddedTicket()
        {
            string testName = "DeleteAddedTicket";

            Console.WriteLine("Test " + testName + " has started.");
            string asserMsg     = "";
            bool   isTestPassed = false;

            try
            {
                XMLClass.LoadDocument();
                GoToURL(XMLClass.GetUrl());

                if (IsKanbanBoardOpened())
                {
                    int numberBeforeAddingTicket = ToDoColumn.CountTickets();
                    ToDoColumn.ClickAddButton();

                    ToDoColumn.ClickDeleteButton();
                    int numberAfterDeletingTicket = ToDoColumn.CountTickets();

                    if (numberAfterDeletingTicket == numberBeforeAddingTicket)
                    {
                        isTestPassed = true;
                        Console.WriteLine("Test passed.");
                    }
                    else
                    {
                        Console.WriteLine("Delete option is not working.");
                        Console.WriteLine("Test failed.");
                    }
                }
            }
            catch (Exception ex)
            {
                asserMsg = ex.Message;
                Console.WriteLine(asserMsg);
            }
            finally
            {
                Assert.IsTrue(isTestPassed, asserMsg);
            }
        }
Exemplo n.º 9
0
        public static int GetCertificateState(string xml)
        {
            WebClient wc = new WebClient();

            byte[]          bytes  = wc.DownloadData(caCertUrl);
            BIO             bio    = new BIO(bytes);
            X509Certificate certca = X509Certificate.FromDER(bio);

            XMLClass xmlEx = new XMLClass();

            byte[]          bytesCert = UTF8Encoding.UTF8.GetBytes(xml);
            string          sCert     = xmlEx.getX509FromXMLbytes(bytesCert);
            BIO             bCert     = new BIO(Convert.FromBase64String(sCert));
            X509Certificate cert      = X509Certificate.FromDER(bCert);

            int result = cert.CheckOCSP(certca, ocspUrl);

            return(result);
        }
Exemplo n.º 10
0
        public void AddNewTicketAndPopulate()
        {
            string testName = "AddNewTicketAndPopulate";

            Console.WriteLine("Test " + testName + " has started.");
            string asserMsg     = "";
            bool   isTestPassed = false;

            try
            {
                XMLClass.LoadDocument();
                GoToURL(XMLClass.GetUrl());

                if (IsKanbanBoardOpened())
                {
                    ToDoColumn.ClickAddButton();
                    ToDoColumn.PopulateText(XMLClass.GetTicketText());

                    if (ToDoColumn.CheckText(XMLClass.GetTicketText()))
                    {
                        isTestPassed = true;
                        Console.WriteLine("Test passed.");
                    }
                    else
                    {
                        Console.WriteLine("Test failed.");
                    }
                }
            }
            catch (Exception ex)
            {
                asserMsg = ex.Message;
                Console.WriteLine(asserMsg);
            }
            finally
            {
                Assert.IsTrue(isTestPassed, asserMsg);
            }
        }
Exemplo n.º 11
0
    /// <summary>
    /// 获取每一层节点的信息并储存
    /// </summary>
    public List <XMLClass> GetNodes(string[] sArray)
    {
        //WorkShop[@Name = ''] 从路径分别截取WorkShop Name ''里的字符串
        List <XMLClass> xmlClasses = new List <XMLClass>();

        for (int i = 0; i < sArray.Length; i++)
        {
            XMLClass xmlClass = new XMLClass();
            if (sArray[i].Contains("="))
            {
                string[] sA1 = sArray[i].Split('[');
                xmlClass.className = sA1[0];
                xmlClass.keyWord   = GetLimitStr(sA1[1], "@", "=");
                xmlClass.value     = GetLimitStr(sA1[1], "'", "']");
            }
            else
            {
                xmlClass.className = sArray[i];
            }
            xmlClasses.Add(xmlClass);
        }
        return(xmlClasses);
    }
Exemplo n.º 12
0
 private static void CollectElements(ref XMLClass xmlClass, XmlNode node)
 {
     foreach (XmlNode childNode in node.ChildNodes)
     {
         if (null == xmlClass.Elements.SingleOrDefault(o => o.Name == childNode.Name))
         {
             var occurance = node.ChildNodes.Cast <XmlNode>().Where(o => o.Name == childNode.Name).Count();
             var appender  = "  ";
             if (occurance > 1)
             {
                 appender = "[] ";
             }
             if (childNode.HasChildNodes || childNode.Attributes.Count > 0)
             {
                 xmlClass.Elements.Add(new Element(childNode.Name + appender, childNode.Name, XMLType.Element));
             }
             else
             {
                 xmlClass.Elements.Add(new Element("string" + appender, childNode.Name, XMLType.Element));
             }
         }
     }
 }
Exemplo n.º 13
0
        public static string GenerateXMLClass(string xmlstring)
        {
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(xmlstring);
            XmlNode rootNode           = xd.DocumentElement;
            var     xmlClassCollection = new Dictionary <string, XMLClass>();
            var     xmlClass           = new XMLClass();

            xmlClassCollection.Add(rootNode.Name, xmlClass);
            CollectAttributes(ref xmlClass, rootNode);
            CollectElements(ref xmlClass, rootNode);
            CollectChildClass(ref xmlClassCollection, rootNode);
            var clsBuilder = new StringBuilder();

            clsBuilder.AppendLine("[XmlRoot(\"" + rootNode.Name + "\")]");
            foreach (var cls in xmlClassCollection)
            {
                clsBuilder.AppendLine("public class " + cls.Key);
                clsBuilder.AppendLine("{");
                foreach (var element in cls.Value.Elements)
                {
                    if (XMLType.Element == element.XmlType)
                    {
                        clsBuilder.AppendLine("[XmlElement(\"" + element.Name + "\")]");
                    }
                    else
                    {
                        clsBuilder.AppendLine("[XmlAttribute(\"" + element.Name + "\")]");
                    }
                    clsBuilder.AppendLine("public " + element.Type + element.Name + "{get;set;}");
                }
                clsBuilder.AppendLine("}");
            }
            return(clsBuilder.ToString());
        }
Exemplo n.º 14
0
        public static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Console.WriteLine("------------ 加载XML源文件 ------------");
            var xmlLoader = new XmlDocument();

            xmlLoader.Load("original.xml");
            stopwatch.Stop();
            Console.WriteLine($"------------ 加载成功 花费:{stopwatch.ElapsedMilliseconds}毫秒 ------------");

            var inFile       = new FileInfo("original.xml");
            var inFileLength = inFile.Length;

            Console.WriteLine($"XML大小:{CountSize ( inFileLength )}  字节数:{inFileLength}");

            stopwatch.Reset();
            stopwatch.Start();
            Console.WriteLine("------------ 解析XML为Class ------------");
            var list   = xmlLoader.GetElementsByTagName("point");
            var cls    = new XMLClass();
            var proCls = new FromProtobufClass();

            Console.WriteLine($"Items数量:{list.Count}");
            for (int i = 0; i < list.Count; i++)
            {
                XmlElement item = (XmlElement)list[i];

                cls.items.Add(new XMLClass.XMLItemClass
                {
                    id = Convert.ToInt32(item.GetAttribute("id").Trim()),
                    x  = Convert.ToInt16(item.GetAttribute("x").Trim()),
                    y  = Convert.ToInt16(item.GetAttribute("y").Trim()),
                    z  = Convert.ToInt16(item.GetAttribute("z").Trim()),
                    u  = Convert.ToSingle(item.GetAttribute("u").Trim()),
                    v  = Convert.ToSingle(item.GetAttribute("v").Trim()),
                    w  = Convert.ToSingle(item.GetAttribute("w").Trim()),
                });
                proCls.items.Add(new FromProtobufClass.ProtobufItemClass
                {
                    id = Convert.ToInt32(item.GetAttribute("id").Trim()),
                    x  = Convert.ToInt16(item.GetAttribute("x").Trim()),
                    y  = Convert.ToInt16(item.GetAttribute("y").Trim()),
                    z  = Convert.ToInt16(item.GetAttribute("z").Trim()),
                    u  = Convert.ToSingle(item.GetAttribute("u").Trim()),
                    v  = Convert.ToSingle(item.GetAttribute("v").Trim()),
                    w  = Convert.ToSingle(item.GetAttribute("w").Trim()),
                });
            }

            stopwatch.Stop();
            Console.WriteLine($"------------ 解析XML为Class 花费:{stopwatch.ElapsedMilliseconds}毫秒 ------------");

            Console.WriteLine("------------ 序列化Class ------------");
            stopwatch.Reset();
            stopwatch.Start();
            var clsBytes = BinaryObjectMapper.Serialize(cls);

            stopwatch.Stop();
            Console.WriteLine($"[使用Chaos码的] 序列化Class完成 花费:{stopwatch.ElapsedMilliseconds}毫秒 ------------");

            File.WriteAllBytes("output.config", clsBytes);
            Console.WriteLine("------------ 保存二进制流为文件:output.config 成功 ------------");

            var outFile    = new FileInfo("output.config");
            var outFileLen = outFile.Length;

            Console.WriteLine($"[使用Chaos码的] 序列化后大小:{CountSize ( outFileLen )}  字节数:{outFileLen}");
            Console.WriteLine($"[使用Chaos码的] 容量减少{(float) ( inFileLength - outFileLen ) / inFileLength:P}");

            Console.WriteLine("------------ 序列化为Protobuf ------------");
            stopwatch.Reset();
            stopwatch.Start();
            using (var file = File.Create("output.bin"))
            {
                Serializer.Serialize(file, proCls);
            }

            stopwatch.Stop();
            Console.WriteLine($"[使用Protobuf] 序列化为Protobuf成功 花费:{stopwatch.ElapsedMilliseconds}毫秒 ------------");

            var outProtoFile    = new FileInfo("output.bin");
            var outProtoFileLen = outProtoFile.Length;

            Console.WriteLine($"[使用Protobuf] 序列化后大小:{CountSize ( outProtoFileLen )}  字节数:{outProtoFileLen}");
            Console.WriteLine($"[使用Protobuf] 容量减少{(float) ( inFileLength - outProtoFileLen ) / inFileLength:P}");

            Console.WriteLine("------------ 加载output.config文件 ------------");
            var outBytes = File.ReadAllBytes("output.config");

            Console.WriteLine("------------ 反序列化 ------------");
            stopwatch.Reset();
            stopwatch.Start();
            var final = BinaryObjectMapper.Deserialize <FinalClass> (outBytes);

            stopwatch.Stop();
            Console.WriteLine($"[使用Chaos码的] 反序列化成功 花费:{stopwatch.ElapsedMilliseconds}毫秒 ------------");

            Console.WriteLine("------------ 反序列化-Protobuf ------------");
            stopwatch.Reset();
            stopwatch.Start();
            using (var file = File.OpenRead("output.bin"))
            {
                var protobufOut = Serializer.Deserialize <FromProtobufClass> (file);
            }

            stopwatch.Stop();
            Console.WriteLine($"[使用Protobuf] 反序列化-Protobuf成功 花费:{stopwatch.ElapsedMilliseconds}毫秒 ------------");

            try
            {
                Console.WriteLine("------------ 前10数据 ------------");
                for (int i = 0; i < 10; i++)
                {
                    var item = final.items[i];
                    Console.WriteLine(
                        $"[FinalClass Item] id:{item.id} "
                        + $"x:{item.x} y:{item.y} z:{item.z} "
                        + $"u:{item.u:0.00000000} v:{item.v:0.00000000} w:{item.w:0.00000000}");
                }
            }
            catch (Exception)
            {
                //
            }

            while (true)
            {
                Thread.Sleep(1);
            }
        }
    /// <summary>
    /// 写入表
    /// </summary>
    /// <typeparam name="I"></typeparam>
    /// <typeparam name="T"></typeparam>
    /// <param name="dic"></param>
    /// <param name="tablename"></param>
    /// <param name="nodePath"></param>
    public override void WriteConfig <I, T>(Dictionary <I, T> dic, string tablename, string nodePath)
    {
        #region 获取路径
        //WorkShop[@Name = ''] 从路径分别截取WorkShop Name ''里的字符串
        string[]        sArray     = nodePath.Split('/');
        List <XMLClass> xmlClasses = new List <XMLClass>();
        for (int i = 0; i < sArray.Length; i++)
        {
            XMLClass xmlClass = new XMLClass();
            if (sArray[i].Contains("="))
            {
                string[] sA1 = sArray[i].Split('[');
                xmlClass.className = sA1[0];
                xmlClass.keyWord   = GetLimitStr(sA1[1], "@", "=");
                xmlClass.value     = GetLimitStr(sA1[1], "'", "']");
            }
            else
            {
                xmlClass.className = sArray[i];
            }
            xmlClasses.Add(xmlClass);
        }
        #endregion
        string      path   = Application.dataPath + "/Config/" + tablename + ".xml";
        XmlDocument xmlDoc = new XmlDocument();
        //如果不存在创建表头 存在读取
        if (File.Exists(path))
        {
            try
            {
                xmlDoc.Load(path);
            }
            catch (Exception)
            {
                //声明xml头
                var xmldecl = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                xmlDoc.AppendChild(xmldecl);
                Debug.LogWarning("最好不要表内为空");
            }
        }
        else
        {
            //声明xml头
            var xmldecl = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
            xmlDoc.AppendChild(xmldecl);
        }
        XmlElement xmlE     = null;
        XmlElement xmlELast = null;//上一个节点
        //到倒数第二个停止循环 因为创建复数个Data时会因为这个循环创建
        //一个空的节点
        for (int i = 0; i < xmlClasses.Count - 1; i++)
        {
            if (i == 0)
            {
                //如果根节点不存在 或者根节点名字不一样
                if (xmlDoc.DocumentElement == null)
                {
                    xmlE = xmlDoc.CreateElement(xmlClasses[i].className);
                }
                else if (xmlDoc.DocumentElement.Name != xmlClasses[i].className)
                {
                    throw new Exception("一个XML不允许有两个根节点");
                }
                else
                {
                    xmlE = xmlDoc.DocumentElement;
                }
                xmlDoc.AppendChild(xmlE);
            }
            else
            {
                //创建节点
                xmlE = xmlDoc.CreateElement(xmlClasses[i].className);
                if (xmlClasses[i].keyWord != null)
                {
                    //设置名字 和属性
                    xmlE.SetAttribute(xmlClasses[i].keyWord, xmlClasses[i].value);
                }
            }
            if (xmlELast != null)
            {
                //往表里添加子节点
                xmlELast.AppendChild(xmlE);
            }
            if (i == xmlClasses.Count - 2)
            {
                CreateInsideData <I, T>(dic, xmlDoc, xmlE, xmlClasses[xmlClasses.Count - 1]);
            }

            xmlELast = xmlE;
        }

        //存表
        xmlDoc.Save(path);
        Debug.Log("XML表" + tablename + "生成完毕,在" + path + "目录下");
    }
Exemplo n.º 16
0
    /// <summary>
    /// 處理錯誤通知mail
    /// </summary>
    /// <param name="errorInfo"></param>
    private void SendErrorEmail(ErrorInfoModel errorInfo)
    {
        SQL1          sqlAdaper   = new SQL1();
        StringBuilder htmlContent = new StringBuilder();

        string propertiesHtml = string.Empty;
        var    groupData      = errorInfo.ErrorBuffer.OrderBy(o => o.Key)
                                .GroupBy(o => o.Key, o => o.Value).ToList();

        //分出A0401H,C0401H
        foreach (var group in groupData)
        {
            var    dataTotalCount = group.Sum(s => s.Details.Count);
            string einvoiceType   = group.Key;
            htmlContent.AppendLine(@"<div style=""border:solid black 1px;padding:7px;"">");
            htmlContent.AppendLine(@"<p style=""font-size:23px;"">");
            htmlContent.AppendLine("發票處理程序:" + einvoiceType + " 資料筆數:" + dataTotalCount);
            htmlContent.AppendLine("<p>");

            var errorsGroup = group.First().Details.GroupBy(g => g.ErrorGroupKey).Select(s => s);
            //分出錯誤群組
            foreach (var error in errorsGroup)
            {
                var erKey = error.Key;
                htmlContent.AppendLine("<p>");
                htmlContent.AppendLine("錯誤分類:" + erKey);
                htmlContent.AppendLine("<p>");
                int dataIndex = 1;
                foreach (var er in error)
                {
                    htmlContent.AppendLine(@"<div style=""border:solid #ccc 1px;padding:3px;"">");
                    htmlContent.AppendLine("<p>");
                    htmlContent.AppendLine("項目:" + dataIndex);
                    htmlContent.AppendLine("<p>");

                    htmlContent.AppendLine("<p>");
                    htmlContent.AppendLine("錯誤發票:" + er.EinvoiceNumber);
                    htmlContent.AppendLine("<p>");

                    htmlContent.AppendLine("<p>");
                    htmlContent.AppendLine("錯誤訊息:" + er.ErrorMessage);
                    htmlContent.AppendLine("<p>");

                    htmlContent.AppendLine("<p>");
                    htmlContent.AppendLine("其他訊息:" + er.OtherMessage);
                    htmlContent.AppendLine("<p>");

                    htmlContent.AppendLine("<p>");
                    htmlContent.AppendLine("處理程序:" + er.ProcessName);
                    htmlContent.AppendLine("<p>");
                    htmlContent.AppendLine("</div>");

                    dataIndex++;
                }
            }
            htmlContent.AppendLine("</div>");
        }
        var      viewHtml     = htmlContent.ToString();
        XMLClass oXMLeParamts = new XMLClass();
        string   eToWho1      = oXMLeParamts.GetParaXml("eToWho");
        string   eFromWho1    = oXMLeParamts.GetParaXml("eFromWho");

        sqlAdaper.AutoEMail(eToWho1, "", eFromWho1, "", htmlContent.ToString());
        sqlAdaper.Dispose();
    }
Exemplo n.º 17
0
    /// <summary>
    /// 创建最里层复数个数据
    /// </summary>
    /// <typeparam name="I"></typeparam>
    /// <typeparam name="T"></typeparam>
    /// <param name="dic"></param>
    /// <param name="xmlDoc"></param>
    /// <param name="parentXmlE"></param>
    /// <param name="childXmlC"></param>
    public void CreateInsideData <I, T>(Dictionary <I, T> dic, XmlDocument xmlDoc, XmlElement parentXmlE, XMLClass childXmlC)
    {
        XmlElement xmlChild;                        //最底层的子节点

        FieldInfo[] fields = typeof(T).GetFields(); //类里的属性
        string      val;                            //枚举类型转换临时储存

        foreach (var item in dic)
        {
            //创建最里层
            xmlChild = xmlDoc.CreateElement(childXmlC.className);
            //反射出改类的类型 和属性
            for (int k = 0; k < fields.Length; k++)
            {
                //判断是否是枚举
                if (fields[k].FieldType.IsEnum)
                {
                    val = ((int)fields[k].GetValue(item.Value)).ToString();
                }
                else
                {
                    val = fields[k].GetValue(item.Value).ToString();
                }
                xmlChild.SetAttribute(fields[k].Name, val);
            }
            parentXmlE.AppendChild(xmlChild);
        }
    }