예제 #1
0
        protected void butSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                SolutionModel model = new SolutionModel();
                model.SlnName = txtDescption.Text.Trim();
                model.Namespace = txtNamespace.Text.Trim();
                model.RefNamespace = txtRefNamespace.Text.Trim();
                model.GameID = Convert.ToInt32((string)txtGameID.Text);
                model.Url = txtUrl.Text.Trim();
                model.SerUseScript = ddSerUseScript.Text;
                model.CliUseScript = ddCliUseScript.Text;
                model.RespContentType = ddResponseContentType.Text.ToInt();
                model.IsDParam = ckIsDParam.Checked;
                if (DbDataLoader.Add(model) > 0)
                {
                    BindData();
                }

            }
            catch (Exception ex)
            {
                Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败,填写重复!')</script>");
            }
        }
예제 #2
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                int id = Convert.ToInt32((string)GridView1.DataKeys[e.RowIndex].Values[0].ToString());
                string SlnName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("SlnName")).Text;
                string Namespace = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Namespace")).Text;
                string RefNamespace = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("RefNamespace")).Text;
                string url = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Url")).Text;
                string gameid = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("gameid")).Text;

                SolutionModel mode = new SolutionModel();
                mode.SlnID = id;
                mode.SlnName = SlnName;
                mode.Namespace = Namespace;
                mode.RefNamespace = RefNamespace;
                mode.Url = url;
                mode.GameID = Convert.ToInt32(gameid);
                if (DbDataLoader.Update(mode))
                {
                    GridView1.EditIndex = -1;
                    BindData();
                }
            }

            catch (Exception erro)
            {
                Response.Write("错误信息:" + erro.Message);
            }
        }
예제 #3
0
 /// <summary>
 /// ɾ��һ������
 /// </summary>
 public static bool Delete(SolutionModel model)
 {
     var command = _dbBaseProvider.CreateCommandStruct("Solutions", CommandMode.Delete);
     command.Filter = _dbBaseProvider.CreateCommandFilter();
     command.Filter.Condition = _dbBaseProvider.FormatFilterParam("SlnID");
     command.Filter.AddParam("SlnID", model.SlnID);
     command.Parser();
     return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0;
 }
예제 #4
0
파일: DbDataLoader.cs 프로젝트: 0jpq0/Scut
 public static int Add(SolutionModel model)
 {
     var command = _dbBaseProvider.CreateCommandStruct("Solutions", CommandMode.Insert);
     command.AddParameter("SlnName", model.SlnName);
     command.AddParameter("Namespace", model.Namespace);
     command.AddParameter("Url", model.Url);
     command.AddParameter("GameID", model.GameID);
     command.ReturnIdentity = true;
     command.Parser();
     return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters);
 }
예제 #5
0
        public static bool Update(SolutionModel model)
        {
            var command = _dbBaseProvider.CreateCommandStruct("Solutions", CommandMode.Modify);
            command.AddParameter("SlnName", model.SlnName);
            command.AddParameter("Namespace", model.Namespace);
            command.AddParameter("RefNamespace", model.RefNamespace);
            command.AddParameter("Url", model.Url);
            command.AddParameter("GameID", model.GameID);
            command.Filter = _dbBaseProvider.CreateCommandFilter();
            command.Filter.Condition = _dbBaseProvider.FormatFilterParam("SlnID");
            command.Filter.AddParam("SlnID", model.SlnID);
            command.Parser();
            return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0;

        }
예제 #6
0
        public static string FormatActionDefineTemp(string content, List<ContractModel> contractList, SolutionModel slnRecord)
        {
            string[] expressList = new string[] { "##FieldList##", "##Namespace##", "##RefNamespace##" };

            foreach (string exp in expressList)
            {
                StringBuilder fieldBuilder = new StringBuilder();
                fieldBuilder.Append(exp.Replace("##", ""));

                if (fieldBuilder.ToString() == "Namespace")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(slnRecord == null ? "" : slnRecord.Namespace);
                }
                else if (fieldBuilder.ToString() == "RefNamespace")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(slnRecord == null ? "" : slnRecord.RefNamespace);
                }
                else if (fieldBuilder.ToString() == "FieldList")
                {
                    string currIndent = GetSpaceIndent(2, 0);
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    foreach (var contract in contractList)
                    {
                        fieldBuilder.Append("///<summary>");
                        fieldBuilder.Append(Environment.NewLine);
                        fieldBuilder.Append(currIndent);

                        fieldBuilder.AppendFormat("///{0}", contract.Descption);
                        fieldBuilder.Append(Environment.NewLine);
                        fieldBuilder.Append(currIndent);

                        fieldBuilder.Append("///</summary>");
                        fieldBuilder.Append(Environment.NewLine);
                        fieldBuilder.Append(currIndent);

                        fieldBuilder.AppendFormat("public const Int16 Cst_Action{0} = {0};", contract.ID);
                        fieldBuilder.Append(Environment.NewLine);
                        fieldBuilder.Append(Environment.NewLine);
                        fieldBuilder.Append(currIndent);
                    }
                }
                content = content.Replace(exp, fieldBuilder.ToString());
            }
            return content;
        }
예제 #7
0
        protected void butSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                SolutionModel model = new SolutionModel();
                model.SlnName = txtDescption.Text.Trim();
                model.Namespace = txtNamespace.Text.Trim();
                model.RefNamespace = txtRefNamespace.Text.Trim();
                model.GameID = Convert.ToInt32((string) txtGameID.Text);
                model.Url = txtUrl.Text.Trim();
                if (DbDataLoader.Add(model) > 0)
                {
                    Response.Redirect("SolutionsList.aspx");
                }

            }
            catch(Exception ex)
            {
                Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败,填写重复!')</script>");
            }
        }
예제 #8
0
 public static List<SolutionModel> GetSolution(Action<CommandFilter> match)
 {
     var command = _dbBaseProvider.CreateCommandStruct("Solutions", CommandMode.Inquiry);
     command.Columns = "SlnID,SlnName,Namespace,RefNamespace,Url,GameID";
     command.OrderBy = "SlnID ASC";
     command.Filter = _dbBaseProvider.CreateCommandFilter();
     if (match != null)
     {
         match(command.Filter);
     }
     command.Parser();
     var list = new List<SolutionModel>();
     using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
     {
         while (reader.Read())
         {
             SolutionModel model = new SolutionModel();
             model.SlnID = reader["SlnID"].ToInt();
             model.GameID = reader["GameID"].ToInt();
             model.SlnName = reader["SlnName"].ToNotNullString();
             model.Namespace = reader["Namespace"].ToNotNullString();
             model.RefNamespace = reader["RefNamespace"].ToNotNullString();
             model.Url = reader["Url"].ToNotNullString();
             list.Add(model);
         }
     }
     return list;
 }
예제 #9
0
        internal static string FormatPython(string content, List<ParamInfoModel> paramList, List<ParamInfoModel> reqParams, SolutionModel slnRecord, string title)
        {
            string[] expressList = new string[] { "##Description##", "##UrlParam##", "##getUrlElement##", "##actionResult##", "##buildPacket##" };
            foreach (string exp in expressList)
            {
                StringBuilder fieldBuilder = new StringBuilder();
                switch (exp)
                {
                    case "##Description##":
                        fieldBuilder.Append(title);
                        break;
                    case "##UrlParam##":
                        {
                            string currIndent = GetSpaceIndent(2, 0);
                            foreach (var paramInfo in paramList)
                            {
                                FieldType fieldType = paramInfo.FieldType;
                                if (FieldType.Record.Equals(fieldType) || FieldType.End.Equals(fieldType))
                                {
                                    continue;

                                }
                                if (paramInfo.ParamType == 1)
                                {
                                    fieldBuilder.Append(currIndent);
                                    if (fieldType == FieldType.Byte
                                   || fieldType == FieldType.Int
                                   || fieldType == FieldType.Short
                                   || fieldType == FieldType.Long
                                   || fieldType == FieldType.UInt
                                   || fieldType == FieldType.UShort
                                   || fieldType == FieldType.ULong
                                   )
                                    {
                                        fieldBuilder.Append(string.Format("self.{0} = 0", ToMemberVarName(paramInfo.Field)));
                                    }
                                    else if (fieldType == FieldType.String || fieldType == FieldType.Password)
                                    {
                                        fieldBuilder.Append(string.Format("self.{0} = ''", ToMemberVarName(paramInfo.Field)));
                                    }
                                    fieldBuilder.Append(Environment.NewLine);
                                }

                            }
                        }
                        break;

                    case "##getUrlElement##":
                        ReplacePythonCheckRequest(fieldBuilder, reqParams);
                        break;
                    case "##actionResult##":
                        ReplacePythonAction(fieldBuilder, paramList);
                        break;
                    case "##buildPacket##":
                        ReplacePythonBuildPacket(fieldBuilder, paramList);
                        break;
                }
                content = content.Replace(exp, fieldBuilder.ToString());

            }
            return content;
        }
예제 #10
0
        /// <summary>
        /// 赋值模板
        /// </summary>
        /// <param name="content"></param>
        /// <param name="paramList"></param>
        /// <param name="slnRecord"></param>
        /// <param name="title"></param>
        /// <param name="reqParams"></param>
        /// <returns></returns>
        public static string FormatTemp(string content, int contractId, List<ParamInfoModel> paramList, List<ParamInfoModel> reqParams, SolutionModel slnRecord, string title)
        {
            string[] expressList = new string[] { "##ID##", "##Description##", "##Field##", "##Namespace##", "##RefNamespace##" };
            foreach (string exp in expressList)
            {
                StringBuilder fieldBuilder = new StringBuilder();
                fieldBuilder.Append(exp.Replace("##", ""));

                if (fieldBuilder.ToString() == "ID")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(contractId);

                }
                else if (fieldBuilder.ToString() == "Description")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(title);
                }
                else if (fieldBuilder.ToString() == "Namespace")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(slnRecord == null ? "" : slnRecord.Namespace);
                }
                else if (fieldBuilder.ToString() == "RefNamespace")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(slnRecord == null ? "" : slnRecord.RefNamespace);
                }

                else if (fieldBuilder.ToString() == "Field")
                {
                    int depth = 0;
                    string listVar = "_dsItemList";
                    string className;
                    int recordIndex = 0;
                    int[] indexList = new int[forVarChars.Length];
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    var list = new List<ParamInfoModel>(reqParams.Where(t => t.FieldType != FieldType.Void));
                    list.AddRange(paramList.Where(t => t.FieldType != FieldType.Void));

                    var classList = new List<StringBuilder>();
                    var classStack = new Stack<StringBuilder>();
                    StringBuilder memberBuilder = new StringBuilder();

                    foreach (var paramInfo in list)
                    {
                        string descp = paramInfo.Descption + paramInfo.Remark;
                        string spaceString = GetSpaceIndent(2, depth);
                        FieldType fieldType = paramInfo.FieldType;
                        if (fieldType == FieldType.Void) continue;

                        if (FieldType.Record.Equals(fieldType))
                        {
                            if (depth < indexList.Length)
                            {
                                recordIndex = indexList[depth];
                                recordIndex++;
                                indexList[depth] = recordIndex;
                            }
                            string memberName = string.IsNullOrEmpty(paramInfo.Field) ? listVar + "_" + recordIndex : paramInfo.Field + "List";
                            listVar = listVar + "_" + recordIndex;
                            className = string.IsNullOrEmpty(paramInfo.Field)
                                ? listVar.Replace("_dsItemList", "Class")
                                : paramInfo.Field;
                            //add class's member
                            if (depth > 0)
                            {
                                var classMemberBuilder = classStack.Peek();
                                BuildMemberCodeByList(classMemberBuilder, GetSpaceIndent(2, depth), className, descp, memberName, true);
                            }
                            else
                            {
                                BuildMemberCodeByList(memberBuilder, spaceString, className, descp, memberName);
                            }
                            var classBuilder = new StringBuilder();
                            BuildClassCode(classBuilder, GetSpaceIndent(2, 0), descp, className);
                            classBuilder.Append(GetSpaceIndent(1, 0));
                            classStack.Push(classBuilder);
                            depth++;
                            continue;
                        }
                        if (FieldType.End.Equals(fieldType))
                        {
                            listVar = listVar.Substring(0, listVar.LastIndexOf('_'));

                            var classMemberBuilder = classStack.Pop();
                            classMemberBuilder.AppendLine("");
                            classMemberBuilder.Append(GetSpaceIndent(2, 0));
                            classMemberBuilder.AppendLine("}");
                            classList.Add(classMemberBuilder);
                            depth--;
                            continue;
                        }
                        if (depth > 0)
                        {
                            var classMemberBuilder = classStack.Peek();
                            BuildMemberCode(classMemberBuilder, GetSpaceIndent(2, 1), paramInfo, true);
                            continue;
                        }

                        BuildMemberCode(memberBuilder, spaceString, paramInfo);
                    }

                    fieldBuilder.AppendLine();
                    fieldBuilder.Append(GetSpaceIndent(2, 0));
                    fieldBuilder.AppendLine("#region class object");
                    foreach (var builder in classList)
                    {
                        fieldBuilder.Append(builder);
                        fieldBuilder.AppendLine();
                    }
                    fieldBuilder.Append(GetSpaceIndent(2, 0));
                    fieldBuilder.AppendLine("#endregion");
                    fieldBuilder.AppendLine();
                    fieldBuilder.Append(GetSpaceIndent(2, 0));
                    fieldBuilder.Append(memberBuilder);
                }
                content = content.Replace(exp, fieldBuilder.ToString());

            }
            content = ReplaceCheckRequest(content, reqParams);
            content = ReplaceBuildPack(content, paramList);
            return content;
        }
예제 #11
0
        public static string FormatLua(string content, int contractId, List<ParamInfoModel> responseParams, List<ParamInfoModel> requestParams, SolutionModel slnRecord, string title)
        {
            string[] expressList = new string[] { "##ID##", "##Description##", "##getUrlElement##", "##buildPacket##" };
            foreach (string exp in expressList)
            {
                StringBuilder fieldBuilder = new StringBuilder();
                switch (exp)
                {
                    case "##ID##":
                        fieldBuilder.Append(contractId);
                        break;
                    case "##Description##":
                        fieldBuilder.Append(title);
                        break;
                    case "##getUrlElement##":
                        ReplaceLuaCheckRequest(fieldBuilder, requestParams);
                        break;
                    case "##buildPacket##":
                        ReplaceLuaBuildPacket(fieldBuilder, responseParams);
                        break;
                }
                content = content.Replace(exp, fieldBuilder.ToString());

            }
            return content;
        }
예제 #12
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                int id = Convert.ToInt32((string)GridView1.DataKeys[e.RowIndex].Values[0].ToString());
                string SlnName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("SlnName")).Text;
                string Namespace = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Namespace")).Text;
                string RefNamespace = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("RefNamespace")).Text;
                string url = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Url")).Text;
                string gameid = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("gameid")).Text;

                string SerUseScript = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("SerUseScript")).Text;
                string CliUseScript = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("CliUseScript")).Text;
                string RespContentType = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("RespContentType")).Text;
                bool IsDParam = ((CheckBox)GridView1.Rows[e.RowIndex].FindControl("IsDParam")).Checked;

                SolutionModel mode = new SolutionModel();
                mode.SlnID = id;
                mode.SlnName = SlnName;
                mode.Namespace = Namespace;
                mode.RefNamespace = RefNamespace;
                mode.Url = url;
                mode.GameID = Convert.ToInt32(gameid);
                mode.SerUseScript = SerUseScript;
                mode.CliUseScript = CliUseScript;
                mode.RespContentType = RespContentType.ToInt();
                mode.IsDParam = IsDParam;
                if (DbDataLoader.Update(mode))
                {
                    GridView1.EditIndex = -1;
                    BindData();
                }
            }

            catch (Exception erro)
            {
                Response.Write("错误信息:" + erro.Message);
            }
        }
예제 #13
0
        /// <summary>
        /// 赋值模板
        /// </summary>
        /// <param name="content"></param>
        /// <param name="paramList"></param>
        /// <param name="slnRecord"></param>
        /// <param name="title"></param>
        /// <param name="reqParams"></param>
        /// <returns></returns>
        public static string FormatTemp(string content, int contractId, List<ParamInfoModel> paramList, List<ParamInfoModel> reqParams, SolutionModel slnRecord, string title)
        {
            int n = 8;
            string[] expressList = new string[] { "##ID##", "##Description##", "##Field##", "##Namespace##", "##RefNamespace##" };
            foreach (string exp in expressList)
            {
                StringBuilder fieldBuilder = new StringBuilder();
                fieldBuilder.Append(exp.Replace("##", ""));

                if (fieldBuilder.ToString() == "ID")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(contractId);

                }
                else if (fieldBuilder.ToString() == "Description")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(title);
                }
                else if (fieldBuilder.ToString() == "Namespace")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(slnRecord == null ? "" : slnRecord.Namespace);
                }
                else if (fieldBuilder.ToString() == "RefNamespace")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(slnRecord == null ? "" : slnRecord.RefNamespace);
                }

                else if (fieldBuilder.ToString() == "Field")
                {

                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    var list = new List<ParamInfoModel>(reqParams);
                    list.AddRange(paramList);
                    foreach (var paramInfo in list)
                    {

                        FieldType fieldType = paramInfo.FieldType;
                        if (FieldType.Record.Equals(fieldType) || FieldType.End.Equals(fieldType))
                        {
                            continue;

                        }
                        fieldBuilder.Append("private ");

                        fieldBuilder.Append(fieldType.ToString().ToLower());
                        fieldBuilder.Append(" ");
                        fieldBuilder.Append(paramInfo.Field);
                        fieldBuilder.Append(";");
                        fieldBuilder.Append(Environment.NewLine);
                        fieldBuilder.Append(GetspaceIndent(n));
                    }
                }
                content = content.Replace(exp, fieldBuilder.ToString());

            }
            content = ReplaceJudge(content, reqParams);
            content = Replacejohc(content, paramList);
            return content;
        }
예제 #14
0
        /// <summary>
        /// 赋值模板
        /// </summary>
        /// <param name="content"></param>
        /// <param name="paramList"></param>
        /// <param name="slnRecord"></param>
        /// <param name="title"></param>
        /// <param name="reqParams"></param>
        /// <returns></returns>
        public static string FormatTemp(string content, int contractId, List<ParamInfoModel> paramList, List<ParamInfoModel> reqParams, SolutionModel slnRecord, string title)
        {
            string[] expressList = new string[] { "##ID##", "##Description##", "##Field##", "##Namespace##", "##RefNamespace##" };
            foreach (string exp in expressList)
            {
                StringBuilder fieldBuilder = new StringBuilder();
                fieldBuilder.Append(exp.Replace("##", ""));

                if (fieldBuilder.ToString() == "ID")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(contractId);

                }
                else if (fieldBuilder.ToString() == "Description")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(title);
                }
                else if (fieldBuilder.ToString() == "Namespace")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(slnRecord == null ? "" : slnRecord.Namespace);
                }
                else if (fieldBuilder.ToString() == "RefNamespace")
                {
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    fieldBuilder.Append(slnRecord == null ? "" : slnRecord.RefNamespace);
                }

                else if (fieldBuilder.ToString() == "Field")
                {
                    int depth = 0;
                    string listVar = "_dsItemList";
                    int recordIndex = 0;
                    int[] indexList = new int[forVarChars.Length];
                    fieldBuilder.Remove(0, fieldBuilder.Length);
                    var list = new List<ParamInfoModel>(reqParams);
                    list.AddRange(paramList);

                    foreach (var paramInfo in list)
                    {
                        FieldType fieldType = paramInfo.FieldType;
                        if (FieldType.Record.Equals(fieldType))
                        {
                            if (depth < indexList.Length)
                            {
                                recordIndex = indexList[depth];
                                recordIndex++;
                                indexList[depth] = recordIndex;
                            }
                            listVar = listVar + "_" + recordIndex;
                            fieldBuilder.AppendFormat("private List<Object> {0};", listVar);
                            fieldBuilder.Append(Environment.NewLine);
                            fieldBuilder.Append(GetSpaceIndent(0, 2));
                            depth++;
                            continue;
                        }
                        if (FieldType.End.Equals(fieldType))
                        {
                            listVar = listVar.Substring(0, listVar.LastIndexOf('_'));
                            depth--;
                            continue;
                        }
                        if (depth > 0)
                        {
                            continue;
                        }
                        fieldBuilder.Append("private ");

                        fieldBuilder.Append(fieldType.ToString().ToLower());
                        fieldBuilder.Append(" ");
                        fieldBuilder.Append(ToMemberVarName(paramInfo.Field));
                        fieldBuilder.Append(";");
                        fieldBuilder.Append(Environment.NewLine);
                        fieldBuilder.Append(GetSpaceIndent(0, 2));
                    }
                }
                content = content.Replace(exp, fieldBuilder.ToString());

            }
            content = ReplaceCheckRequest(content, reqParams);
            content = ReplaceBuildPack(content, paramList);
            return content;
        }