Example #1
0
        public static void CreateMATTxt()
        {
            StringBuilder sb = new StringBuilder();
            //int iRes = 14;
            //string sMat = "XCPP-1816";
            string sTxt = "";
            string sMat = System.IO.File.ReadAllText(@"E:\vs2015_project\ODBCtest\ConTestODBC\bin\Debug\MatText.txt");

            string[] aRes = ReadFiles.ReadRes();
            for (int i = 0; i < aRes.Length; i++)
            {
                sb.Append(sMat + Environment.NewLine);
            }
            sTxt = sb.ToString().Substring(0, sb.ToString().LastIndexOf("\r\n"));//去掉最后一个逗号sb.ToString().Length - 1

            BaseCreateFiles.Save_txt(sTxt, "CreateMat");
        }
Example #2
0
        public static void CreateTimeTxt()
        {
            string sMat = "";
            string stxt = "";

            string[]      arrayTime = ReadFiles.ReadTime();
            string[]      arrayRes  = ReadFiles.ReadRes();
            StringBuilder sTime     = new StringBuilder();

            for (int i = 0; i < arrayTime.Length; i++)
            {
                sTime.Append((Convert.ToDouble(arrayTime[i]) * 60).ToString() + "\r\n");
                stxt = CreateTestData.CreateTxt(sTime.ToString().Substring(0, sTime.ToString().LastIndexOf("\r\n")), arrayRes.Length);
            }
            //stxt = stxt.ToString().Substring(0, stxt.LastIndexOf("\r\n"));

            BaseCreateFiles.Save_txt(stxt, "CreateTime");
        }
Example #3
0
        /// <summary>
        /// 根据Mat的行数生成重复iMat行的Res文本
        /// </summary>
        /// <param name="iMat"></param>
        public static void CreateRESTxt()
        {
            StringBuilder sb = new StringBuilder();
            //int iRes = 14;
            //string sMat = "XCPP-1816";
            string sRes = "";

            string[] aMat = ReadFiles.ReadMat();
            string[] aRes = ReadFiles.ReadRes();
            for (int j = 0; j < aRes.Length; j++)
            {
                for (int i = 0; i < aMat.Length; i++)
                {
                    sb.Append(aRes[j] + Environment.NewLine);
                }
            }
            sRes = sb.ToString().Substring(0, sb.ToString().LastIndexOf("\r\n"));//去掉最后一个逗号sb.ToString().Length - 1
            BaseCreateFiles.Save_txt(sRes, "CreateRes");
        }
Example #4
0
        public static void CreateClientUpdateDetailTxt(string sServerName, string sExplain = "   ")
        {
            StringBuilder sb        = new StringBuilder();
            string        sUserType = sServerName.Substring(0, 3);
            string        sTxt      = "";

            sb.Append("#region " + sServerName + sExplain + Environment.NewLine);
            sb.Append("public static bool " + CommonUtils.CreateMethodName(sServerName) + "(char cStep)" + Environment.NewLine);
            sb.Append("{" + Environment.NewLine);
            sb.Append("try" + Environment.NewLine);
            sb.Append("{" + Environment.NewLine);
            sb.Append("if(cStep!=' ')" + Environment.NewLine);
            sb.Append("{" + Environment.NewLine);
            sb.Append("TRSNode in_node = new TRSNode(\"VIEW_DETAIL_IN\");" + Environment.NewLine);
            sb.Append("TRSNode out_node = new TRSNode(\"VIEW_DETAIL_OUT\");" + Environment.NewLine);
            sb.Append("" + Environment.NewLine);
            sb.Append("CommonRoutine.SetInMsg(in_node);" + Environment.NewLine);
            sb.Append("in_node.ProcStep =cStep;" + Environment.NewLine);
            for (int i = 0; i < aInFields.Length; i++)
            {
                sb.Append("in_node.Add" + CommonUtils.FirstToUpper(aInType[i]) + "(\"" + aInFields[i].ToUpper() + "\", txtDesc);" + Environment.NewLine);
            }
            sb.Append(" if (CommonRoutine.CallService(\"" + sUserType + "\", \"" + sServerName + "\", in_node, ref out_node) == false)" + Environment.NewLine);
            sb.Append("{" + Environment.NewLine);
            sb.Append("return false;" + Environment.NewLine);
            sb.Append("}" + Environment.NewLine);
            sb.Append("return true;" + Environment.NewLine);
            sb.Append("}" + Environment.NewLine);
            sb.Append("else" + Environment.NewLine);
            sb.Append("{" + Environment.NewLine);
            sb.Append("return false;" + Environment.NewLine);
            sb.Append("}" + Environment.NewLine);
            sb.Append("}" + Environment.NewLine);
            sb.Append("catch (Exception ex)" + Environment.NewLine);
            sb.Append("{" + Environment.NewLine);
            sb.Append("CommonFunction.ShowMsgBox(ex.Message);" + Environment.NewLine);
            sb.Append("return false;" + Environment.NewLine);
            sb.Append("}" + Environment.NewLine);
            sb.Append("}" + Environment.NewLine);
            sb.Append("#endregion ");
            BaseCreateFiles.Save_txt(sb.ToString(), "CreateClientUpdateDetail");
        }
Example #5
0
        public static void CreateTransformText()
        {
            StringBuilder sb = new StringBuilder();
            //int iRes = 14;
            //string sMat = "XCPP-1816";
            string sRes = "";

            string[] aEnglish = ReadFiles.ReadInText();
            string[] aChinese = ReadFiles.ReadChineseText();
            for (int i = 0; i < aEnglish.Length; i++)
            {
                sb.Append("<Text Key=\"" + aEnglish [i] + "\">" + Environment.NewLine);
                sb.Append("<L>" + aEnglish[i] + "</L>" + Environment.NewLine);
                sb.Append("<L>" + aChinese[i] + "</L>" + Environment.NewLine);
                sb.Append("<L></L>" + Environment.NewLine);
                sb.Append("</Text>" + Environment.NewLine);
            }
            sRes = sb.ToString().Substring(0, sb.ToString().LastIndexOf("\r\n"));//去掉最后一个逗号sb.ToString().Length - 1
            BaseCreateFiles.Save_txt(sRes, "CreateTransformation");
        }
Example #6
0
        public static void CreateListRoutineTxt(string sServerName, string sExplain = "   ")
        {
            StringBuilder sb        = new StringBuilder();
            string        sUserType = sServerName.Substring(0, 3);
            string        sTxt      = "";

            if (sServerName.ToLower().Contains("_view_") && sServerName.ToLower().Contains("_list"))
            {
                sb.Append("#region " + sServerName + sExplain + Environment.NewLine);
                sb.Append("public static DataTable " + CommonUtils.CreateMethodName(sServerName) + "()" + Environment.NewLine);
                sb.Append("{" + Environment.NewLine);
                sb.Append("try" + Environment.NewLine);
                sb.Append("{" + Environment.NewLine);
                sb.Append("DataTable dtResult = new DataTable();" + Environment.NewLine);
                sb.Append("ArrayList a_list;" + Environment.NewLine);
                sb.Append("TRSNode in_node = new TRSNode(\"VIEW_LIST_IN\");" + Environment.NewLine);
                sb.Append("TRSNode out_node;" + Environment.NewLine);
                for (int i = 0; i < aOutFields.Length; i++)
                {
                    sb.Append("dtResult.Columns.Add(\"" + aOutFields[i].ToUpper() + "\");" + Environment.NewLine);
                }
                sb.Append("a_list = new ArrayList();" + Environment.NewLine);
                sb.Append("CommonRoutine.SetInMsg(in_node);" + Environment.NewLine);
                sb.Append("in_node.ProcStep = '1';" + Environment.NewLine);
                sb.Append("in_node.AddString(\"NEXT_ITEM_ID\", \"\");" + Environment.NewLine);
                sb.Append("" + Environment.NewLine);
                sb.Append("do" + Environment.NewLine);
                sb.Append("{" + Environment.NewLine);
                sb.Append("out_node = new TRSNode(\"VIEW_LIST_OUT\");" + Environment.NewLine);
                sb.Append("if (CommonRoutine.CallService(\"" + sUserType + "\", \"" + sServerName + "\", in_node, ref out_node) == false)" + Environment.NewLine);
                sb.Append("{" + Environment.NewLine);
                sb.Append("return null;" + Environment.NewLine);
                sb.Append("}" + Environment.NewLine);
                sb.Append("a_list.Add(out_node);" + Environment.NewLine);
                sb.Append("in_node.SetString(\"NEXT_ITEM_ID\", out_node.GetString(\"NEXT_ITEM_ID\"));" + Environment.NewLine);
                sb.Append("} while (in_node.GetString(\"NEXT_ITEM_ID\") != \"\");" + Environment.NewLine);
                sb.Append("" + Environment.NewLine);
                sb.Append("foreach (object obj in a_list)" + Environment.NewLine);
                sb.Append("{" + Environment.NewLine);
                sb.Append("out_node = null;" + Environment.NewLine);
                sb.Append("out_node = (TRSNode)obj;" + Environment.NewLine);
                sb.Append("for (int i = 0; i < out_node.GetList(0).Count; i++)" + Environment.NewLine);
                sb.Append("{" + Environment.NewLine);
                sb.Append("dtResult.Rows.Add(" + Environment.NewLine);
                for (int i = 0; i < aOutFields.Length; i++)
                {
                    sb.Append("out_node.GetList(0)[i].Get" + CommonUtils.FirstToUpper(aOutType[i]) + "(\"" + aOutFields[i].ToUpper() + "\")," + Environment.NewLine);
                }
                sb.Remove(sb.Length - 3, 1);//删除最后一个换行符(占两个字符)和逗号
                sb.Append(" );" + Environment.NewLine);
                sb.Append("}" + Environment.NewLine);
                sb.Append("}" + Environment.NewLine);
                sb.Append("dtResult.AcceptChanges();//保存更改,便于界面判断是否有修改" + Environment.NewLine);
                sb.Append("return dtResult;" + Environment.NewLine);
                sb.Append("}" + Environment.NewLine);
                sb.Append("catch (Exception ex)" + Environment.NewLine);
                sb.Append("{" + Environment.NewLine);
                sb.Append("CommonFunction.ShowMsgBox(ex.Message);" + Environment.NewLine);
                sb.Append("return null;" + Environment.NewLine);
                sb.Append("}" + Environment.NewLine);
                sb.Append("}" + Environment.NewLine);
                sb.Append("#endregion ");
            }


            //sTxt = sb.ToString().Substring(0, sb.ToString().LastIndexOf("\r\n"));//去掉最后一个逗号sb.ToString().Length - 1

            BaseCreateFiles.Save_txt(sb.ToString(), "CreateClientListRoutine");
        }
        public static void CreateSQLScript()
        {
            string text = System.IO.File.ReadAllText(@"E:\vs2015_project\ODBCtest\ConTestODBC\bin\Debug\CreateServer\FieldsForSQLText.txt");

            string[]      arrayInFieldsRow = text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            List <string> Fieldlist        = new List <string>();
            List <string> Typelist         = new List <string>();
            List <string> PKlist           = new List <string>();

            foreach (var item in arrayInFieldsRow)
            {
                string[] aFieldsDetail = item.Split(new string[] { " " }, StringSplitOptions.None);
                Fieldlist.Add(aFieldsDetail[1]);
                Typelist.Add(aFieldsDetail[3].ToUpper());
                if (aFieldsDetail[4] == "是")
                {
                    PKlist.Add(aFieldsDetail[1]);
                }
            }
            List <string> TypeTranlist = new List <string>();
            List <string> Defaultlist  = new List <string>();

            foreach (var item in Typelist)
            {
                if (item.Contains("VARCHAR"))
                {
                    TypeTranlist.Add((item.Replace(")", " CHAR)")).Replace(("VARCHAR"), "VARCHAR2"));
                    Defaultlist.Add("' '");
                }
                else if (item.Contains("CHAR"))
                {
                    TypeTranlist.Add((item.Replace(")", " CHAR)")));
                    Defaultlist.Add("' '");
                }
                else
                {
                    TypeTranlist.Add(item);
                    Defaultlist.Add("0");
                }
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("ALTER TABLE " + sDBName + "." + sTableName + Environment.NewLine);
            sb.Append(" DROP PRIMARY KEY CASCADE;" + Environment.NewLine);
            sb.Append("" + Environment.NewLine);
            sb.Append("DROP TABLE " + sDBName + "." + sTableName + " CASCADE CONSTRAINTS;" + Environment.NewLine);
            sb.Append("CREATE TABLE " + sDBName + "." + sTableName + Environment.NewLine);
            sb.Append("(" + Environment.NewLine);


            for (int i = 0; i < Fieldlist.Count; i++)
            {
                sb.Append(Fieldlist[i] + "            " + TypeTranlist[i] + "          DEFAULT " + Defaultlist[i] + "                   NOT NULL," + Environment.NewLine);
            }
            sb.Remove(sb.Length - 3, 1);//删除最后一个换行符(占两个字符)和逗号

            sb.Append(")" + Environment.NewLine);
            sb.Append("TABLESPACE " + sDBName + Environment.NewLine);
            sb.Append("RESULT_CACHE (MODE DEFAULT)" + Environment.NewLine);
            sb.Append("PCTUSED    0" + Environment.NewLine);
            sb.Append("PCTFREE    10" + Environment.NewLine);
            sb.Append("INITRANS   1" + Environment.NewLine);
            sb.Append("MAXTRANS   255" + Environment.NewLine);
            sb.Append("STORAGE    (" + Environment.NewLine);
            sb.Append("             PCTINCREASE      0" + Environment.NewLine);
            sb.Append("             BUFFER_POOL      DEFAULT" + Environment.NewLine);
            sb.Append("             FLASH_CACHE      DEFAULT" + Environment.NewLine);
            sb.Append("             CELL_FLASH_CACHE DEFAULT" + Environment.NewLine);
            sb.Append("            )" + Environment.NewLine);
            sb.Append("LOGGING " + Environment.NewLine);
            sb.Append("NOCOMPRESS " + Environment.NewLine);
            sb.Append("NOCACHE" + Environment.NewLine);
            sb.Append("NOPARALLEL" + Environment.NewLine);
            sb.Append("MONITORING;" + Environment.NewLine);
            sb.Append("" + Environment.NewLine);
            sb.Append("" + Environment.NewLine);
            sb.Append("CREATE UNIQUE INDEX " + sDBName + "." + sTableName + "_PK ON " + sDBName + "." + sTableName + Environment.NewLine);
            string PrimaryKey = "";
            string Result     = "";

            foreach (var item in PKlist)
            {
                PrimaryKey += item + ",";
            }
            Result = PrimaryKey.Substring(0, PrimaryKey.LastIndexOf(","));//去掉最后一个逗号sb.ToString().Length - 1
            sb.Append("(" + Result + ")" + Environment.NewLine);
            sb.Append("LOGGING" + Environment.NewLine);
            sb.Append("TABLESPACE " + sDBName + Environment.NewLine);
            sb.Append("PCTFREE    10" + Environment.NewLine);
            sb.Append("INITRANS   2" + Environment.NewLine);
            sb.Append("MAXTRANS   255" + Environment.NewLine);
            sb.Append("STORAGE    (" + Environment.NewLine);
            sb.Append("             PCTINCREASE      0" + Environment.NewLine);
            sb.Append("             BUFFER_POOL      DEFAULT" + Environment.NewLine);
            sb.Append("             FLASH_CACHE      DEFAULT" + Environment.NewLine);
            sb.Append("             CELL_FLASH_CACHE DEFAULT" + Environment.NewLine);
            sb.Append("            )" + Environment.NewLine);
            sb.Append("NOPARALLEL;" + Environment.NewLine);
            sb.Append("" + Environment.NewLine);
            sb.Append("" + Environment.NewLine);
            sb.Append("ALTER TABLE " + sDBName + "." + sTableName + " ADD (" + Environment.NewLine);
            sb.Append(" CONSTRAINT " + sTableName + "_PK" + Environment.NewLine);
            sb.Append(" PRIMARY KEY" + Environment.NewLine);
            sb.Append("(" + Result + ")" + Environment.NewLine);
            sb.Append("USING INDEX " + sDBName + "." + sTableName + "_PK" + Environment.NewLine);
            sb.Append("  ENABLE VALIDATE);" + Environment.NewLine);
            sb.Append("" + Environment.NewLine);
            sb.Append("" + Environment.NewLine);

            BaseCreateFiles.Save_txt(sb.ToString(), "CreateSQLScript");
        }