Example #1
0
            public string CreateText(Tem tem, string msg, string tableName, DataXml data)
            {
                string head = @"<?xml version=""1.0"" encoding=""gb2312"" ?>  <freeforms> {0}</freeforms> ";

                msg = string.Format(head, msg);
                XmlDocument model = new XmlDocument();

                //存放保存方法
                StringBuilder SaveModel = new StringBuilder();
                WebForm1      com       = new WebForm1();

                model.LoadXml(msg);

                StringReader sRead = new StringReader(msg);
                DataSet      ds    = new DataSet();

                ds.ReadXml(sRead, XmlReadMode.InferTypedSchema);


                StringBuilder sb   = new StringBuilder();
                DataTable     row  = ds.Tables["row"];
                DataTable     col  = ds.Tables["col"];
                DataTable     lab  = ds.Tables["label"];
                DataTable     edit = ds.Tables["editor"];

                for (int i = 0; i < row.Rows.Count; i++)
                {
                    sb.Append("<tr>");

                    DataRow[] colView  = col.AsDataView().Table.Select("row_ID= '" + i + "'");
                    var       rowValue = "";

                    for (int k = 0; k < colView.Length; k++)
                    {
                        int num = (int)colView[k]["col_ID"];

                        if (num % 2 == 0)
                        {
                            rowValue = lab.Select("col_ID = " + num + "")[0]["dbname"] as string;
                            sb.AppendFormat(@"<td class=""label-bg"" style=""width: 100px; "">{0}</td>", com.GetChina(rowValue, tableName, data));
                        }
                        else
                        {
                            rowValue = edit.Select("col_ID = " + num + "")[0]["dbname"] as string;
                            sb.AppendFormat(@"<td>  <input type=""text"" size=""10"" id=""{0}"" name=""{0}"" value=""<%=model.{0}%>""/> </td>", rowValue);
                        }

                        sb.Append(Environment.NewLine);

                        SaveModel.AppendFormat(" head.{0} = Post(\"{0}\");", rowValue);
                        SaveModel.AppendLine();
                    }

                    sb.Append("</tr>");
                    sb.Append(Environment.NewLine);
                }

                return(sb.ToString() + tem.NewLine + SaveModel.ToString());
            }
Example #2
0
 private void viewdata(DataXml data, RichTextBox richTextBox)
 {
     richTextBox.Clear();
     foreach (var item in data)
     {
         richTextBox.AppendText(item);
     }
 }
Example #3
0
        public string GetChina(string col, string table, DataXml data)
        {
            var china = data.MessageXml.Where(x => x.TableName == table && x.ColumnName == col).FirstOrDefault();

            if (china == null)
            {
                return(col);
            }
            return(china.value);
        }
Example #4
0
        public DataXml SaveInXmlFormat(Data data)
        {
            DataXml dataXml = new DataXml();

            foreach (var item in data)
            {
                var serializer = new ConfigurationContainer().Create();
                var xml        = serializer.Serialize(item);
            }
            return(dataXml);
        }
        static void Main(string[] args)
        {
            //Xml Declaration
            DataXml       dataXml        = new DataXml();
            XmlSerializer DataSerializer = new XmlSerializer(typeof(DataXml));

            //Management Class declaration
            Employer_Manager _Employer = new Employer_Manager();
            Company_Manager  _Company  = new Company_Manager();

            //Creating data
            //Company samsung = new Company("Samsung", "Electronic fabrication", "korea", new DateTime(1938, 3, 1));
            //Employer employer1 = new Employer("Daniel kochima", 45, samsung.Name);
            //Employer employer2 = new Employer("Park jie hum", 32, null);
            //Employer employer3 = new Employer("Jamal idrissi", 19, null);
            //samsung.AddEmployer(employer1);
            //_Employer.Add(employer1);
            //_Employer.Add(employer2);
            //_Employer.Add(employer3);
            //_Company.AddCompany(samsung);

            //save
            //dataXml.Save(DataSerializer, new StreamWriter("Data.xml"), _Company, _Employer);

            //load
            dataXml.Load(DataSerializer, new StreamReader("Data.xml"), ref _Company, ref _Employer);

            bool   Program = true;
            string Input   = "";

            while (Program)
            {
                Console.WriteLine("________COMPANIES AND EMPLOYERS________");
                Console.WriteLine("1/Employers erea\t2/Companies erea");
                Console.Write("Your Choice : ");
                Input = Console.ReadLine();
                if (Input == "1")
                {
                    EmployerErea(_Employer);
                }
                else if (Input == "2")
                {
                    EspaceEntreprise(_Company, _Employer);
                }
                else
                {
                    Console.WriteLine("=> The command cannot be found !!");
                }

                Console.WriteLine("________COMPANIES AND EMPLOYERS________");
                Program = Leave();
            }
            dataXml.Save(DataSerializer, new StreamWriter("Data.xml"), _Company, _Employer);
        } //done
Example #6
0
        /// <summary>
        /// 批量发送短信
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static SMSReceiveModel SendBatchSMS(string phone, string body)
        {
            string postReturn = string.Empty;

            try
            {
                string strReturnXML = PostWebRequest(url, sendBatchMessage(phone, body));
                postReturn = DataXml.GetResultCode(strReturnXML);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(GetPostReturn(postReturn));
        }
Example #7
0
            public string CreateText(Tem tem, string msg, string tableName, DataXml data)
            {
                string        text      = Environment.NewLine;
                WebForm1      com       = new WebForm1();
                var           modelList = data.TableXml.Where(x => x.TableName == tableName);
                StringBuilder GetModel  = new StringBuilder();
                string        DDL       = "            yield return new NameValue() {{ Name = \"{0}\", Value = cod.GetDDLTextByValue(\"{1}\", entity.{0}) }};";
                string        noDDL     = "            yield return new NameValue() {{ Name = \"{0}\", Value = entity.{0}.ToString() }};";

                string[] model = msg.Split('|');
                for (int i = 0; i < model.Length; i++)
                {
                    if (string.IsNullOrEmpty(tableName))
                    {
                        text += string.Format(tem.ColText, com.GetSizeStatus(model[i], data.size), com.GetSizeStatus(model[i], data.size));
                    }
                    else
                    {
                        text += string.Format(tem.ColText, model[i], com.GetChina(model[i], tableName, data));
                        var currData = modelList.Where(x => x.ColumnName == model[i]).FirstOrDefault();

                        if (string.IsNullOrEmpty(currData.DDL))
                        {
                            GetModel.AppendFormat(noDDL, model[i]);
                        }
                        else
                        {
                            GetModel.AppendFormat(DDL, model[i], currData.DDL);
                        }
                        GetModel.Append(tem.NewLine);
                    }
                    if (i < model.Length - 1)
                    {
                        text += ",";
                    }
                    text += tem.NewLine;
                }
                var ColText = string.Format(tem.COLS, text);

                return(ColText + tem.NewLine + GetModel.ToString());
            }
Example #8
0
            public string CreateText(Tem tem, string msg, string tableName, DataXml data)
            {
                StringBuilder GetModel = new StringBuilder();
                string        DDL      = "            yield return new NameValue() {{ Name = \"{0}\", Value = cod.GetDDLTextByValue(\"{1}\", entity.{0}) }};";
                string        noDDL    = "            yield return new NameValue() {{ Name = \"{0}\", Value = entity.{0}.ToString() }};";

                var models = data.TableXml.Where(x => x.TableName == tableName);

                foreach (var i in models)
                {
                    if (string.IsNullOrEmpty(i.DDL))
                    {
                        GetModel.AppendFormat(noDDL, i.ColumnName);
                    }
                    else
                    {
                        GetModel.AppendFormat(DDL, i.ColumnName, i.DDL);
                    }
                    GetModel.AppendLine();
                }

                return(GetModel.ToString());
            }
Example #9
0
            public string CreateText(Tem tem, string msg, string tableName, DataXml data)
            {
                return("");
                //    string tem = @"<?xml version=""1.0"" encoding=""gb2312"" ?>  <freeforms> {0}</freeforms> ";
                //    msg = string.Format(tem, msg);
                //    XmlDocument model = new XmlDocument();
                //    model.LoadXml(msg);

                //    StringReader sRead = new StringReader(msg);
                //    DataSet ds = new DataSet();
                //    ds.ReadXml(sRead, XmlReadMode.InferTypedSchema);

                //    StringBuilder sb = new StringBuilder();
                //    DataTable row = ds.Tables["row"];
                //    DataTable col = ds.Tables["col"];
                //    DataTable lab = ds.Tables["label"];
                //    DataTable edit = ds.Tables["editor"];

                //    for (int i = 0; i < row.Rows.Count; i++)
                //    {
                //        sb.Append("<tr>");

                //        DataRow[] colView = col.AsDataView().Table.Select("row_ID= '" + i + "'");
                //        var rowValue = "";

                //        for (int k = 0; k < colView.Length; k++)
                //        {
                //            int num = (int)colView[k]["col_ID"];

                //            //10 - 10
                //            //if (num % 2 == 0)
                //            //{
                //            //    rowValue = lab.Select("col_ID = " + num + "")[0]["dbname"] as string;
                //            //    sb.AppendFormat(@"<td class=""label-bg"" style=""width: 100px; "">{0}</td>", rowValue);
                //            //}
                //            //else
                //            //{
                //            //    rowValue = edit.Select("col_ID = " + num + "")[0]["dbname"] as string;
                //            //    sb.AppendFormat(@"<td>  <input type=""text"" size=""10"" id=""{0}"" name=""{0}"" value=""<%=head.{0}%>""/> </td>", rowValue);
                //            //}


                //            //10 - > 2015

                //            if (num % 2 == 0)
                //            {
                //                rowValue = lab.Select("col_ID = " + num + "")[0]["dbname"] as string;
                //                sb.AppendFormat(@"<td style='width: 100px;' class='label-bg'> @Html.LabelFor( x => x.{0}) </td>", rowValue);
                //            }
                //            else
                //            {
                //                var temModel = edit.Select("col_ID = " + num + "")[0];
                //                rowValue = temModel["dbname"] as string;
                //                if (temModel["controltype"].ToString() == "UltraTextEditor")
                //                {
                //                    sb.AppendFormat(@"<td> <input type='text' id='{0}' name ='{0}' class='easyui-validatebox tb' data-options='required: true' value = '@Model.{0}' /> </td>", rowValue);
                //                }
                //                else
                //                {
                //                    sb.AppendFormat(@" <td>                                <select id=""{0}"" name=""{0}""  class=""easyui-combobox"" style =""width: 200px; height: 27px; ""
                //                                title = ""@Html.DisplayNameFor(model => model.{0})"" panelwidth = ""300"" data-options = ""required:true""
                //                                panelheight = '200' >
                //                            <option id = """" value = """" ></option >
                //                               @Html.Raw({0})
                //                           </select> </td>", rowValue);
                //                }

                //            }
                //            sb.Append(Environment.NewLine);
                //        }

                //        sb.Append("</tr>");
                //        sb.Append(Environment.NewLine);
                //    }

                //    return sb.ToString();
                //}
            }