Exemple #1
0
        private void bt_sqltest_Click(object sender, EventArgs e)
        {
            string cons = string.Format(
                "Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3}",
                this.tb_ip.Text.Trim(), this.tb_ku.Text.Trim(), this.tb_name.Text.Trim(), this.tb_pw.Text.Trim());
            XElement xe = XElement.Load("constring.xml");

            //string a = xe.Element("type").Value;
            xe.Element("type").Value = "MSSQL";
            xe.Element("sqlserver").Element("simple").Value             = cons;
            xe.Element("sqlserver").Element("ip").Value                 = this.tb_ip.Text.Trim();
            xe.Element("sqlserver").Element("databasename").Value       = this.tb_ku.Text.Trim();
            xe.Element("sqlserver").Element("username").Value           = this.tb_name.Text.Trim();
            xe.Element("sqlserver").Element("encryptKey").Value         = "ydhydhnb";
            xe.Element("sqlserver").Element("passwordencryption").Value = IoRyClass.EncryptDES(this.tb_pw.Text.Trim(), "ydhydhnb");
            xe.Save("constring.xml");

            IoRyClass ic = new IoRyClass();

            try
            {
                ic.GetTable("select 1");
                MessageBox.Show("连接正常");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void bt_create_Click(object sender, EventArgs e)
        {
            try
            {
                //删除文件夹
                if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "CreateClass"))
                {
                    Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + "CreateClass", true);
                }

                IoRyClass ic = new IoRyClass();
                common.inamespace   = this.tb_namespace.Text.Trim();
                common.prefix       = this.tb_prefix.Text.Trim();
                common.calltype     = this.cb_calltype.Text.Trim();
                common.IoRyClassXML = this.tb_icxml.Text.Trim();
                common.WCFIPport    = this.tb_wcfxml.Text.Trim();
                common.WebApiUrl    = this.tb_webapi.Text.Trim();
                common.create(ic);
                MessageBox.Show("生成成功!");
            }
            catch (Exception me)
            {
                MessageBox.Show(me.Message);
            }
        }
Exemple #3
0
        private void bt_adddb_Click(object sender, EventArgs e)
        {
            string sqlsub    = "";
            string key       = "";
            string tablename = this.dgv_tables.CurrentRow.Cells[0].Value.ToString();

            XElement xe = XElement.Load("DataTables.xml");
            var      ml = xe.Elements(tablename).Select(x =>
                                                        new
            {
                列名称  = x.Attribute("columnname").Value,
                列类型  = x.Attribute("columntype").Value,
                是否为空 = x.Attribute("isnull").Value,
                是否自增 = x.Attribute("identity").Value,
                是否主键 = x.Attribute("iskey").Value
            }).ToList();

            foreach (var item in ml)
            {
                sqlsub += "[" + item.列名称 + "] ";
                sqlsub += item.列类型 + " ";
                if (item.是否自增 == "是")
                {
                    sqlsub += "IDENTITY(1,1) ";
                }
                if (item.是否为空 == "是")
                {
                    sqlsub += "NULL,";
                }
                else
                {
                    sqlsub += "NOT NULL,";
                }
                if (item.是否主键 == "是")
                {
                    key = item.列名称;
                }
            }

            string sql = string.Format(@"CREATE TABLE [{0}](
{1}
 CONSTRAINT [PK_{0}] PRIMARY KEY CLUSTERED 
(
	[{2}] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]", tablename, sqlsub, key);

            IoRyClass ic = new IoRyClass();

            try
            {
                ic.ExecuteSql(sql);
                MessageBox.Show("创建表成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #4
0
        /// <summary>
        /// 异步的得到DataSet的方法,可以和按钮与进度条相关联用
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="cuser">执行者</param>
        /// <param name="myobj">可以传送到事件里面的东西</param>
        public async Task <DataSet> GetDataSet_Async(string sql, string cuser)
        {
            BllClass bc = await WC.CallWebAPI_Async(sql, cuser, "GetDataSet");

            this.Core2Framework(bc);
            byte[] mbs = IoRyClass.StringToBytes(bc.JsonOut);
            return(IoRyClass.RetrieveXmlDataSet(mbs));
        }
Exemple #5
0
        /// <summary>
        /// 同步的取得DataSet的方法
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="cuser">执行者</param>
        /// <returns></returns>
        public DataSet GetDataSet_Syn(string sql, string cuser)
        {
            BllClass bc = WC.CallWebAPI_Syn(sql, cuser, "GetDataSet_Log");

            this.Core2Framework(bc);
            byte[] mbs = IoRyClass.StringToBytes(bc.JsonOut);
            return(IoRyClass.RetrieveXmlDataSet(mbs));
        }
Exemple #6
0
        /// <summary>
        /// 异步的执行事务的方法.
        /// </summary>
        /// <param name="sql"></param>
        public async Task <DataSet> ExcutSP_Async(string SPname, List <DbParameter> DbParameterS)
        {
            BllClass bc = await WC.CallWebAPI_Async(SPname, DbParameterS, "ExcutSP");

            this.Core2Framework(bc);
            byte[] mbs = IoRyClass.StringToBytes(bc.JsonOut);
            return(IoRyClass.RetrieveXmlDataSet(mbs));
        }
Exemple #7
0
        /// <summary>
        /// 异步的执行事务的方法.
        /// </summary>
        /// <param name="sql"></param>
        public void ExcutSqlTran_Async(string sql)
        {
            this.checkProgressBarAndButtons();
            string EncryptString = IoRyClass.EncryptRSA_long(sql, Encrypt);
            string xl            = myxml(Xml, "ExecuteSqlTran", new List <string> {
                EncryptString
            });

            MyISC.ClientSendMessage("InvokeMember", xl, this.cOperator, "ydh");
        }
Exemple #8
0
        /// <summary>
        /// 异步的得到DataSet的方法,可以和按钮与进度条相关联用
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="myobj">可以传送到事件里面的东西</param>
        public void GetDataSet_Async(string sql, object myobj)
        {
            obj = myobj;
            this.checkProgressBarAndButtons();
            string EncryptString = IoRyClass.EncryptRSA_long(sql, Encrypt);
            string xl            = myxml(Xml, "GetDataSet", new List <string> {
                EncryptString
            });

            MyISC.ClientSendMessage("InvokeMember", xl, this.cOperator, "ydh");
        }
        void ImyService.ClientSendMessage(string methodName, string xmlParam, string callOperator, string certificate)
        {
            ConsoleMsg(AddMsgClient("用户调用ClientSendMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam, myTransport.ClientToService));
            //验证验证码
            if (certificate != LoadBalanceService.GetConfigValue("MyCheck"))
            {
                mCB.ServerSendMessage(methodName, mywrong("certificate is wrong!"));
                return;
            }
            try
            {
                XElement xmdata = XElement.Parse(xmlParam);
                string   fname  = xmdata.Element("Function").Value;
                string   fpath  = xmdata.Element("xmlPath").Value;
                string   fparam = xmdata.Element("Param").Value;
                switch (methodName)
                {
                case "CallBLL":
                    BllClass bc       = JsonConvert.DeserializeObject <BllClass>(fparam);
                    Assembly assembly = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + bc.DLLName);
                    object   obj      = assembly.CreateInstance(bc.ClassName);
                    object   ret      = obj.GetType().InvokeMember(bc.Function, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, obj, new object[] { fparam });

                    byte[] bts = IoRyClass.StringToBytes(mycorrect(ret.ToString(), methodName));
                    System.ComponentModel.BackgroundWorker bw1 = new System.ComponentModel.BackgroundWorker();
                    bw1.DoWork += new System.ComponentModel.DoWorkEventHandler(Bytes_DoWork);
                    bw1.RunWorkerAsync(bts);

                    ConsoleMsg(AddMsgClient(mycorrect(ret.ToString(), methodName), myTransport.ServiceToClient));
                    break;

                default:
                    ConsoleErrorMsg(AddMsgClient("用户调用ClientSendMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam + "\r\n" + "Error报错:" + "服务不提供此方法!", myTransport.ServiceToClient));
                    mCB.ServerSendMessage(methodName, mywrong("服务不提供此方法!"));
                    break;
                }
            }
            catch (Exception me)
            {
                string exmsg = "";
                while (me.InnerException != null)
                {
                    exmsg += me.Message + "\r\n------>\r\n";
                    me     = me.InnerException;
                }
                exmsg += me.Message;
                ConsoleErrorMsg(AddMsgClient("用户调用ClientSendMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam + "\r\n" + "Error报错:" + exmsg, myTransport.ServiceToClient));
                mCB.ServerSendMessage(methodName, mywrong(exmsg));
            }
        }
Exemple #10
0
        /// <summary>
        /// 同步的执行Sql的方法,Oracle不支持事务
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public string ExcutSql_Syn(string sql)
        {
            sql = IoRyClass.EncryptRSA_long(sql, Encrypt);
            string xl = myxml(Xml, "ExecuteSql", new List <string> {
                sql
            });
            string   rst    = MyISC.SynMessage("InvokeMember", xl, this.cOperator, "ydh");
            XElement xmdata = XElement.Parse(rst);

            if (xmdata.Element("correct").Value == "false")
            {
                throw new Exception(xmdata.Element("Exception").FirstNode.ToString());
            }
            return(xmdata.Element("return").FirstNode.ToString());
        }
Exemple #11
0
        bool ImyCallBack.ServerSendData(ydhDeliver dler)
        {
            //检测上传是否重复.
            if (myList.Any(x => x.Name == dler.Name && x.Index == dler.Index))
            {
                foreach (var item in myList.Where(x => x.Name == dler.Name && x.Index == dler.Index))
                {
                    myList.Remove(item);
                }
            }
            //保存
            myList.Add(dler);
            //最终拼接.
            if (dler.IsFinish)
            {
                //这里再2015-11-13发现了一个边界bug,当传输的数据正好到达边界后,服务端还会再传输一个byte[0]的dler过来,需要处理掉
                if (dler.Context.Count() == 0)
                {
                    return(true);
                }

                var         re   = myList.Where(x => x.Name == dler.Name).OrderBy(x => x.Index);
                List <byte> mybt = new List <byte>();
                foreach (var item in re)
                {
                    mybt.AddRange(item.Context.ToList());
                }
                switch (dler.FunctionName)
                {
                case "Json":
                    string mjson = IoRyClass.BytesToString(mybt.ToArray());
                    if (eAsnyCallBll != null)
                    {
                        this.eAsnyCallBll(mjson, this._obj);
                    }
                    break;
                }
                myList.Clear();
            }

            if (eGetDeliver != null)
            {
                this.eGetDeliver(dler);
            }

            return(true);
        }
Exemple #12
0
        /// <summary>
        /// 异步的执行事务的方法.
        /// </summary>
        /// <param name="sql"></param>
        public void ExcutSP_Async(string SPname, List <DbParameter> DbParameterS, object myobj)
        {
            obj = myobj;
            this.checkProgressBarAndButtons();
            List <string> rc       = new List <string>();
            string        jmapname = "<SPname>" + IoRyClass.EncryptRSA_long(SPname, Encrypt) + "</SPname>";

            rc.Add(jmapname);
            foreach (var item in DbParameterS)
            {
                string cs = "<ParameterName>" + item.ParameterName + "</ParameterName><Value>" + item.Value.ToString() + "</Value>";
                rc.Add(cs);
            }
            string xl = myxml(Xml, "ExecuteSP", rc);

            MyISC.ClientSendMessage("ExcutSP", xl, this.cOperator, "ydh");
        }
Exemple #13
0
        /// <summary>
        /// 同步的取得DataSet的方法
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public DataSet GetDataSet_Syn(string sql)
        {
            sql = IoRyClass.EncryptRSA_long(sql, Encrypt);
            string xl = myxml(Xml, "GetDataSet", new List <string> {
                sql
            });
            string   rst    = MyISC.SynMessage("InvokeMember", xl, this.cOperator, "ydh");
            XElement xmdata = XElement.Parse(rst);

            if (xmdata.Element("correct").Value == "false")
            {
                throw new Exception(xmdata.Element("Exception").FirstNode.ToString());
            }
            byte[]  mbs = IoRyClass.StringToBytes(xmdata.Element("return").FirstNode.ToString());
            DataSet ds  = IoRyClass.RetrieveXmlDataSet(mbs);

            return(ds);
        }
Exemple #14
0
        /// <summary>
        /// 获取单一文件夹下所有的文件及其属性
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        string GetFolderFiles(string path)
        {
            DirectoryInfo TheFolder = new DirectoryInfo(path);

            if (!Directory.Exists(path))
            {
                TheFolder.Create();
            }
            XElement fxs = new XElement("files");

            foreach (FileInfo NextFile in TheFolder.GetFiles())
            {
                XElement fx = new XElement("file");
                fx.Add(new XAttribute("Extension", NextFile.Extension));
                fx.Add(new XAttribute("Name", NextFile.Name));
                if (NextFile.Extension.ToLower() == ".exe" || NextFile.Extension.ToLower() == ".dll")
                {
                    FileVersionInfo myFileVersion = FileVersionInfo.GetVersionInfo(NextFile.FullName);
                    //也有.net认不出版本号的dll
                    if (myFileVersion.ProductVersion != null)
                    {
                        fx.Add(new XAttribute("ProductVersion", myFileVersion.ProductVersion));
                    }
                    else
                    {
                        fx.Add(new XAttribute("MD5", IoRyClass.MD5(File.ReadAllBytes(NextFile.FullName))));
                    }
                }
                else
                {
                    fx.Add(new XAttribute("MD5", IoRyClass.MD5(File.ReadAllBytes(NextFile.FullName))));
                }
                fxs.Add(fx);
            }
            return(fxs.ToString());
        }
Exemple #15
0
        /// <summary>
        /// 执行存储过程,注意,调用服务的就没有out形式的入参了,这个失效
        /// </summary>
        /// <param name="SPname">存储过程名</param>
        /// <param name="DbParameterS">参数</param>
        /// <returns></returns>
        public DataSet ExcutSP_Syn(string SPname, List <DbParameter> DbParameterS)
        {
            List <string> rc       = new List <string>();
            string        jmapname = "<SPname>" + IoRyClass.EncryptRSA_long(SPname, Encrypt) + "</SPname>";

            rc.Add(jmapname);
            foreach (var item in DbParameterS)
            {
                string cs = "<ParameterName>" + item.ParameterName + "</ParameterName><Value>" + item.Value.ToString() + "</Value>";
                rc.Add(cs);
            }
            string   xl     = myxml(Xml, "ExecuteSP", rc);
            string   rst    = MyISC.SynMessage("ExcutSP", xl, this.cOperator, "ydh");
            XElement xmdata = XElement.Parse(rst);

            if (xmdata.Element("correct").Value == "false")
            {
                throw new Exception(xmdata.Element("Exception").FirstNode.ToString());
            }
            byte[]  mbs = IoRyClass.StringToBytes(xmdata.Element("return").FirstNode.ToString());
            DataSet ds  = IoRyClass.RetrieveXmlDataSet(mbs);

            return(ds);
        }
Exemple #16
0
        /// <summary>
        /// Callback 成员
        /// </summary>
        /// <param name="dler"></param>
        /// <returns></returns>
        public bool ServerSendData(ydhDeliver dler)
        {
            //检测上传是否重复.
            if (myList.Any(x => x.Name == dler.Name && x.Index == dler.Index))
            {
                foreach (var item in myList.Where(x => x.Name == dler.Name && x.Index == dler.Index))
                {
                    myList.Remove(item);
                }
            }
            //保存
            myList.Add(dler);
            if (myProgressBar != null)
            {
                if (myProgressBar.Value < myProgressBar.Maximum)
                {
                    myProgressBar.Value++;
                }
            }
            //最终拼接.
            if (dler.IsFinish)
            {
                //这里再2015-11-13发现了一个边界bug,当传输的数据正好到达边界后,服务端还会再传输一个byte[0]的dler过来,需要处理掉
                if (dler.Context.Count() == 0)
                {
                    return(true);
                }

                var         re   = myList.Where(x => x.Name == dler.Name).OrderBy(x => x.Index);
                List <byte> mybt = new List <byte>();
                foreach (var item in re)
                {
                    mybt.AddRange(item.Context.ToList());
                }
                switch (dler.FunctionName)
                {
                case "DataSet":
                    DataSet DS = IoRyClass.RetrieveXmlDataSet(mybt.ToArray());
                    if (myDataGridView != null)
                    {
                        myDataGridView.DataSource = DS.Tables[0];
                    }
                    if (myAsnyGetDataSet != null)
                    {
                        this.myAsnyGetDataSet(DS, obj);
                    }
                    break;

                case "GetFolderXml":
                    string xml = IoRyClass.BytesToString(mybt.ToArray());
                    if (DuxMessage != null)
                    {
                        this.DuxMessage(xml, "GetFolderXml");
                    }
                    break;

                case "CheckUpdateFiles":
                    try
                    {
                        File.WriteAllBytes(System.AppDomain.CurrentDomain.BaseDirectory + dler.Name, mybt.ToArray());
                    }
                    catch (Exception me)
                    {
                        if (DuxMessage != null)
                        {
                            this.DuxMessage(me.Message, "Error");
                        }
                    }
                    break;
                }
                if (myProgressBar != null)
                {
                    myProgressBar.Visible = false;
                    myProgressBar.Value   = 0;
                }
                if (MyButtons.Count != 0)
                {
                    foreach (Button item in MyButtons)
                    {
                        item.Enabled = true;
                    }
                }
                myList.Clear();
            }

            if (eGetDeliver != null)
            {
                this.eGetDeliver(ConvertDeliver(dler));
            }

            return(true);
        }
Exemple #17
0
        private void bt_createxml_Click(object sender, EventArgs e)
        {
            string    sql = @"
select b.name as tablename,a.name as cname,c.name as ctype,COLUMNPROPERTY( a.id,a.name,'IsIdentity') as IsIdentity,
 (case when (SELECT count(*) FROM sysobjects  
 WHERE (name in (SELECT name FROM sysindexes  
 WHERE (id = a.id) AND (indid in  
 (SELECT indid FROM sysindexkeys  
 WHERE (id = a.id) AND (colid in  
 (SELECT colid FROM syscolumns WHERE (id = a.id) AND (name = a.name)))))))  
 AND (xtype = 'PK'))>0 then 'true' else 'false' end) ckey,
 a.isnullable,b.xtype ,g.value as gnote from syscolumns a
join sysobjects b on a.id=b.id
join systypes c on a.xtype=c.xusertype
left join sys.extended_properties g on a.id=g.major_id AND a.colid=g.minor_id
 where a.id in (select id from sysobjects where xtype in ('U'))
 order by a.id,a.colorder";
            IoRyClass ic  = new IoRyClass();
            DataTable dt  = ic.GetTable(sql);
            XElement  xe  = new XElement("classforms");

            foreach (var item in dt.AsEnumerable().Select(x => x.Field <string>("tablename")).Distinct())
            {
                XElement xezi = new XElement("classform");
                xezi.Add(new XElement("className", item));
                int hang = 1;
                int lie  = 1;
                foreach (var itemzi in dt.AsEnumerable().Where(x => x.Field <string>("tablename") == item))
                {
                    //这里控制行列,目前一列最多20个 以后可以改,目前这个也可以直接改xml文件
                    if (hang > 20)
                    {
                        lie++;
                        hang = hang - 20;
                    }

                    if (itemzi.Field <string>("gnote") != null && itemzi.Field <string>("gnote") != "")
                    {
                        XElement xezizi = new XElement("Property");
                        xezizi.Add(new XElement("column", lie));

                        xezizi.Add(new XElement("row", hang));
                        hang++;
                        xezizi.Add(new XElement("height", this.txt_height.Text));
                        xezizi.Add(new XElement("width", this.txt_width.Text));
                        xezizi.Add(new XElement("textstart", this.txt_textstart.Text));
                        xezizi.Add(new XElement("textwidth", this.txt_textwidth.Text));
                        xezizi.Add(new XElement("name", itemzi.Field <string>("cname")));
                        xezizi.Add(new XElement("displayname", itemzi.Field <string>("gnote")));
                        xezizi.Add(new XElement("valuetype", common.igetctype(itemzi.Field <string>("ctype"))));
                        xezizi.Add(new XElement("isPassword"), "");
                        xezizi.Add(new XElement("checkRepeat"), "");
                        xezizi.Add(new XElement("comboTable"), "");
                        xezizi.Add(new XElement("comboDisplay"), "");
                        xezizi.Add(new XElement("comboValue"), "");
                        xezizi.Add(new XElement("comboDefault"), "");
                        xezi.Add(xezizi);
                    }
                }
                xe.Add(xezi);
            }
            //删除文件夹
            if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "CXML"))
            {
                Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + "CXML", true);
            }
            //创建文件夹
            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "CXML"))
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "CXML");
            }
            try
            {
                xe.Save(AppDomain.CurrentDomain.BaseDirectory + "CXML\\ClassXML.xml");
                MessageBox.Show("生成成功!");
            }
            catch (Exception me)
            {
                MessageBox.Show(me.Message);
            }
        }
Exemple #18
0
        public BllClass Post(BllClass bcin)
        {
            try
            {
                string sin = JsonConvert.SerializeObject(bcin);
                if (bcin.IsLog)
                {
                    Ydhlog.Info("入参:");
                    Ydhlog.Info(sin);
                }
                DLLjson   dj            = JsonConvert.DeserializeObject <DLLjson>(bcin.JsonIn);
                IoRyClass ic            = new IoRyClass(dj.ConfigPath);
                DataSet   ds            = null;
                byte[]    mbs           = null;
                string    StringDataSet = null;
                switch (bcin.RouteName)
                {
                case "GetDataSet":
                    ds = ic.GetDataSet(dj.SQL_string);
                    //StringDataSet = JsonConvert.SerializeObject(ds, new Newtonsoft.Json.Converters.DataSetConverter());
                    mbs           = IoRyClass.GetXmlFormatDataSet(ds);
                    StringDataSet = IoRyClass.BytesToString(mbs);
                    //StringDataSet = Convert.ToBase64String(mbs);

                    //byte[] mbs1 = IoRyClass.StringToBytes(StringDataSet);
                    //DataSet ds1 = IoRyClass.RetrieveXmlDataSet(mbs1);
                    //DataSet ds1 = JsonConvert.DeserializeObject<DataSet>(StringDataSet, new Newtonsoft.Json.Converters.DataSetConverter());

                    bcin.JsonOut = StringDataSet;
                    break;

                case "GetDataSet_Log":
                    ds            = ic.Log_GetDataSet(dj.SQL_string, dj.Operater);
                    mbs           = IoRyClass.GetXmlFormatDataSet(ds);
                    StringDataSet = IoRyClass.BytesToString(mbs);
                    bcin.JsonOut  = StringDataSet;
                    break;

                case "ExcutSqlTran":
                    StringDataSet = ic.ExecuteSqlTran(dj.SQL_string);
                    bcin.JsonOut  = StringDataSet;
                    break;

                case "ExcutSqlTran_Log":
                    StringDataSet = ic.Log_ExecuteSqlTran(dj.SQL_string, dj.Operater);
                    bcin.JsonOut  = StringDataSet;
                    break;

                case "ExcutSP":
                    List <DbParameter> LD = new List <DbParameter>();
                    foreach (var item in dj.DbParaList)
                    {
                        //这里就先只写SqlServer的吧,其他的数据库类型,用到了再说
                        SqlParameter sp = new SqlParameter();
                        sp.Value         = item.Value;
                        sp.ParameterName = item.Name;
                        LD.Add(sp);
                    }
                    ds            = ic.ExecuteSP(dj.SQL_string, LD);
                    mbs           = IoRyClass.GetXmlFormatDataSet(ds);
                    StringDataSet = IoRyClass.BytesToString(mbs);
                    bcin.JsonOut  = StringDataSet;
                    break;

                default:
                    bcin.IsNormal = false;
                    bcin.ErrorMsg = "找不到此RouteName";
                    break;
                }
                string sout = JsonConvert.SerializeObject(bcin);
                if (bcin.IsLog)
                {
                    Ydhlog.Info("出参:");
                    Ydhlog.Info(sout);
                }
                if (!bcin.IsNormal)
                {
                    Ydhlog.Error("可预期的错误:");
                    Ydhlog.Error(sout);
                }
                return(bcin);
            }
            catch (Exception me)
            {
                string exmsg = "";
                while (me.InnerException != null)
                {
                    exmsg += me.Message + "\r\n------>\r\n";
                    me     = me.InnerException;
                }
                exmsg += me.Message;

                Ydhlog.Error(exmsg);

                bcin.IsNormal = false;
                bcin.ErrorMsg = exmsg;
                return(bcin);
            }
        }
Exemple #19
0
        /// <summary>
        /// 主函数,将目标库中所有的表和视图生成类,并且根据选择生成处理类
        /// </summary>
        /// <param name="iic"></param>
        public static void create(IoRyClass iic)
        {
            //获取数据库中的表,视图信息.
            string    sql = @"
select b.name as tablename,a.name as cname,c.name as ctype,COLUMNPROPERTY( a.id,a.name,'IsIdentity') as IsIdentity,
 (case when (SELECT count(*) FROM sysobjects  
 WHERE (name in (SELECT name FROM sysindexes  
 WHERE (id = a.id) AND (indid in  
 (SELECT indid FROM sysindexkeys  
 WHERE (id = a.id) AND (colid in  
 (SELECT colid FROM syscolumns WHERE (id = a.id) AND (name = a.name)))))))  
 AND (xtype = 'PK'))>0 then 'true' else 'false' end) ckey,
 a.isnullable,b.xtype ,g.value as gnote,a.status from syscolumns a
join sysobjects b on a.id=b.id
join systypes c on a.xtype=c.xusertype
left join sys.extended_properties g on a.id=g.major_id AND a.colid=g.minor_id
 where a.id in (select id from sysobjects where xtype in ('U','V','P'))
  order by a.id,a.colorder";
            DataTable dt  = iic.GetTable(sql);

            //创建文件夹
            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "CreateClass"))
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "CreateClass");
            }

            //取得所有的表,视图,存储过程名称
            var ltnames = dt.AsEnumerable().Select(x => x.Field <string>("tablename")).Distinct();

            //遍历所有的表,视图,存储过程
            foreach (var item in ltnames)
            {
                CreatProcedureCS(dt, item);
                CreatViewCS(dt, item);
                CreatTableCS(dt, item);
            }
            //写其他的文件
            string mystr = "";

            switch (calltype)
            {
            case "IoRyClass":
                //写IoRyFunction类
                mystr  = myRead("IoRyClass\\function1.txt");
                mystr  = mystr.Replace("yezhanbafang", common.inamespace);
                mystr += @"
        public static string IoRyClassXmlPath = " + "\"" + IoRyClassXML + "\"" + @";
";
                mystr += myRead("IoRyClass\\function2.txt");
                myWrite(mystr, "IoRyFunction");
                mystr = myRead("IoRyClass\\col.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyCol");
                mystr = myRead("IoRyClass\\entity.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyEntity");
                mystr = myRead("IoRyClass\\rowinterface.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyRowInterface");
                mystr = myRead("IoRyClass\\SortBindingCollection.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "SortBindingCollection");
                mystr = myRead("IoRyClass\\IoRyAttribute.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyAttribute");
                mystr = myRead("IoRyClass\\IoRyTransaction.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyTransaction");
                //调试的时候先把生成DLL去了,总是影响跟踪代码 20200418 有了nuget不用再生成DLL了
                //if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "CreateClass\\DLL"))
                //{
                //    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "CreateClass\\DLL");
                //}
                //System.IO.File.Copy("IoRyClass\\IoRyClass.dll", "CreateClass\\DLL\\IoRyClass.dll", true);
                //System.IO.File.Copy("IoRyClass\\IoRyClass.xml", "CreateClass\\DLL\\IoRyClass.xml", true);
                System.IO.File.Copy("constring.xml", "CreateClass\\" + IoRyClassXML, true);
                break;

            case "WCF":
                //写IoRyFunction类
                mystr  = myRead("WCFv5\\function1.txt");
                mystr  = mystr.Replace("yezhanbafang", common.inamespace);
                mystr += @"
        public static string mxml = " + "\"" + IoRyClassXML + "\";" + @"
        public static string url = " + "\"" + WCFIPport + "\";";
                mystr += myRead("WCFv5\\function2.txt");
                myWrite(mystr, "IoRyFunction");
                mystr = myRead("WCFv5\\col.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyCol");
                mystr = myRead("WCFv5\\entity.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyEntity");
                mystr = myRead("WCFv5\\rowinterface.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyRowInterface");
                mystr = myRead("WCFv5\\SortBindingCollection.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "SortBindingCollection");
                mystr = myRead("WCFv5\\IoRyAttribute.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyAttribute");
                mystr = myRead("IoRyClass\\IoRyTransaction.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyTransaction");
                //调试的时候先把生成DLL去了,总是影响跟踪代码 20200418 有了nuget不用再生成DLL了
                //if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "CreateClass\\DLL"))
                //{
                //    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "CreateClass\\DLL");
                //}
                //System.IO.File.Copy("WCFv5\\IoRyClass.dll", "CreateClass\\DLL\\IoRyClass.dll", true);
                //System.IO.File.Copy("WCFv5\\IoRyWCFClientV5.dll", "CreateClass\\DLL\\IoRyWCFClientV5.dll", true);
                //System.IO.File.Copy("WCFv5\\IoRyClass.xml", "CreateClass\\DLL\\IoRyClass.xml", true);
                //System.IO.File.Copy("WCFv5\\IoRyWCFClientV5.xml", "CreateClass\\DLL\\IoRyWCFClientV5.xml", true);
                break;

            case "WebAPI":
                mystr  = myRead("WebAPI\\function1.txt");
                mystr  = mystr.Replace("yezhanbafang", common.inamespace);
                mystr += @"
        public static string IoRyClassXmlPath = " + "\"" + IoRyClassXML + "\";" + @"
        public static string WebApiUrl = " + "\"" + WebApiUrl + "\";";
                mystr += myRead("WebAPI\\function2.txt");
                myWrite(mystr, "IoRyFunction");
                mystr = myRead("WebAPI\\col.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyCol");
                mystr = myRead("WebAPI\\entity.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyEntity");
                mystr = myRead("WebAPI\\rowinterface.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyRowInterface");
                mystr = myRead("WebAPI\\SortBindingCollection.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "SortBindingCollection");
                mystr = myRead("WebAPI\\IoRyAttribute.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyAttribute");
                mystr = myRead("IoRyClass\\IoRyTransaction.txt");
                mystr = mystr.Replace("yezhanbafang", common.inamespace);
                myWrite(mystr, "IoRyTransaction");
                break;
            }
        }