Exemple #1
0
        //仅修改逻辑缓存中的值,不直接修改配置文件
        public void ApplyRow(int branchIdx, IDListItem item)
        {
            //if(currentTablediffs.Count > branchIdx && currentTables.Count > branchIdx + 1 &&
            //    currentTablediffs[branchIdx] != null && currentTables[branchIdx + 1] != null &&
            //    item != null && item.States.Count > branchIdx)
            //{
            //}
            table     lt  = currentLuaTableData.tables[0];             //local table
            table     bt  = currentLuaTableData.tables[branchIdx + 1]; //branch table
            tablediff btd = currentLuaTableData.tableDiffs[branchIdx]; //branch tablediff

            if (bt == null)
            {
                bt = new table(lt);
                currentLuaTableData.tables[branchIdx + 1] = bt;
            }

            string status = item.States[branchIdx];

            btd.Apply(status, item.ID, bt, lt);
            if (currentLuaTableData.applyedRows == null)
            {
                currentLuaTableData.applyedRows = new Dictionary <string, Dictionary <int, string> >();
            }
            if (!currentLuaTableData.applyedRows.ContainsKey(item.ID))
            {
                currentLuaTableData.applyedRows[item.ID] = new Dictionary <int, string>();
            }
            currentLuaTableData.applyedRows[item.ID][branchIdx] = item.States[branchIdx];
            int index = currentLuaTableData.idList.IndexOf(item);

            _lTableDataDic[currentExcelpath].idList[index].SetStates(STATUS_NONE, branchIdx);
        }
Exemple #2
0
 public void ThenIShouldBeAbletoLogin(table table)
 {
     NavigationPage.NavigateToHomePage();
     NavigationPage.NavigateToLoginPage();
     _ScenarioData = table.CreateDynamicInstance();
     RegisterUserPage.RegisterUser((string)_ScenarioData.EmailAdd, (string)_ScenarioData.Password);
 }
Exemple #3
0
        public void Apply(string status, string key, table bt, table lt)
        {
            config cfg;

            switch (status)
            {
            case DifferController.STATUS_ADDED:
                addedrows.Remove(key);
                cfg = lt.configsDic[key];
                bt.Apply(status, cfg);
                break;

            case DifferController.STATUS_DELETED:
                deletedrows.Remove(key);
                bt.Apply(status, null, key);
                break;

            case DifferController.STATUS_MODIFIED:
                modifiedrowsAppled.Add(key, modifiedrows[key]);
                modifiedrows.Remove(key);
                cfg = lt.configsDic[key];
                bt.Apply(status, cfg);
                break;

            default: break;
            }
        }
        public async Task <IActionResult> Puttable(int id, table table)
        {
            if (id != table.Id)
            {
                return(BadRequest());
            }

            _context.Entry(table).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #5
0
        /// <summary>
        /// 创建表格
        /// </summary>
        /// <param name="connection">SQL连接</param>
        /// <param name="table">表格信息</param>
        internal unsafe override bool createTable(DbConnection connection, table table)
        {
            string name = table.Columns.Name;

            if (connection != null && name != null && name.Length != 0 && table.Columns != null && table.Columns.Columns.Length != 0)
            {
                pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();
                try
                {
                    using (charStream sqlStream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize))
                    {
                        sqlStream.SimpleWriteNotNull("create table ");
                        sqlStream.SimpleWriteNotNull(name);
                        sqlStream.SimpleWriteNotNull(" (");
                        bool isNext = false;
                        foreach (column column in table.Columns.Columns)
                        {
                            if (isNext)
                            {
                                sqlStream.Write(',');
                            }
                            sqlStream.SimpleWriteNotNull(column.SqlName);
                            sqlStream.Write(' ');
                            sqlStream.Write(column.DbType.getSqlTypeName());
                            isNext = true;
                        }
                        sqlStream.Write(')');
                        return(executeNonQuery(connection, sqlStream.ToString()) >= 0);
                    }
                }
                finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
            }
            return(false);
        }
Exemple #6
0
        static void table_deduplication(ref table table, Dictionary <string, Dictionary <string, string> > basedic)
        {
            if (basedic.Count < 1)
            {
                return;
            }
            property temp;
            Dictionary <string, string> basekv = new Dictionary <string, string>();

            for (int i = 0; i < table.configs.Count; i++)
            {
                if (basedic.ContainsKey(table.configs[i].key))
                {
                    basekv = basedic[table.configs[i].key];
                    for (int j = 0; j < table.configs[i].properties.Count; j++)
                    {
                        temp = table.configs[i].properties[j];
                        if (basekv.ContainsKey(temp.name) && basekv[temp.name] == temp.value)
                        {
                            table.configs[i].properties.RemoveAt(j--);
                        }
                    }
                }
            }
        }
Exemple #7
0
        static List <List <config> > build_group(table table)
        {
            List <List <SkillGroupNode> > lists = new List <List <SkillGroupNode> >();

            for (int i = 0; i < table.configs.Count; i++)
            {
                string _Nextid = get_nextid(table.configs[i]);
                if (_Nextid != null)
                {
                    SkillGroupNode node = new SkillGroupNode
                    {
                        nextid = _Nextid,
                        config = table.configs[i]
                    };
                    insert_node(ref lists, node);
                }
            }
            List <List <config> > group = new List <List <config> >();

            for (int i = 0; i < lists.Count; i++)
            {
                group.Add(new List <config>());
                for (int j = 0; j < lists[i].Count; j++)
                {
                    group[i].Add(lists[i][j].config);
                }
            }
            return(group);
        }
Exemple #8
0
        //static string gen_metatable(Dictionary<string, Dictionary<string, int>> basedic)

        static string gen_normal(table table, Dictionary <string, string> basekv)
        {
            //去除不需要生成的属性
            property temp;

            for (int i = 0; i < table.configs.Count; i++)
            {
                for (int j = 0; j < table.configs[i].properties.Count; j++)
                {
                    temp = table.configs[i].properties[j];
                    if (basekv.ContainsKey(temp.name) && basekv[temp.name] == temp.value)
                    {
                        table.configs[i].properties.RemoveAt(j--);
                    }
                }
            }

            Func <string> genmeta = () =>
            {
                string meta = "local __default = {\n";
                foreach (var item in basekv)
                {
                    meta = string.Format("{0}\t{1} = {2},\n", meta, item.Key, item.Value);
                }
                meta = string.Format("{0}}}\ndo\n\tlocal base = {{\n\t\t__index = __default,\n\t\t--__newindex = function()\n\t\t\t--禁止写入新值\n\t\t\t--error(\"Attempt to modify read-only table\")\n\t\t--end\n\t}}\n\tfor k, v in pairs({1}) do\n\t\tsetmetatable(v, base)\n\tend\n\tbase.__metatable = false\nend\n", meta, table.name);
                return(meta);
            };

            return(table.GenString(genmeta));
        }
        public userControlEditTable()
        {
            InitializeComponent();

            tablita = new table();
            txtTable.Focus();
        }
Exemple #10
0
        public static tablediff CompareTable(table left, table right)
        {
            tablediff tdiff = new tablediff();

            if (left != null && right != null)
            {
                for (int i = 0; i < right.configs.Count; i++)
                {
                    if (left.configsDic.ContainsKey(right.configs[i].key))
                    {
                        CompareTablerow(left.configsDic[right.configs[i].key], right.configs[i], ref tdiff);
                    }
                    else
                    {
                        tdiff.deletedrows.Add(right.configs[i].key, right.configs[i]);
                    }
                }
            }
            if (left != null)
            {
                foreach (var item in left.configsDic)
                {
                    if (right == null || !right.configsDic.ContainsKey(item.Key))
                    {
                        tdiff.addedrows.Add(item.Key, item.Value);
                    }
                }
            }
            return(tdiff);
        }
    void SaveTable()
    {
        FileStream file = null;

        try
        {
            BinaryFormatter bf = new BinaryFormatter();
            file = File.Create(Application.persistentDataPath + basefileName + numOfExistingtables.ToString());

            table t = new table(roomNameInput.text, tableCode, numOfGlinds.text, bootValue.text, raise.text, buyInAmt.text, numofPlayers.text, variation.text);
            bf.Serialize(file, t);
        }
        catch (Exception e)
        {
            if (e != null)
            {
                ;
            }
            // Handle Exception
        }
        finally
        {
            if (file != null)
            {
                file.Close();
            }
        }
    }
        public async Task <ActionResult <table> > Posttable(table table)
        {
            _context.table.Add(table);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Gettable", new { id = table.Id }, table));
        }
    public void report_by_rating_record_test()
    {
        var student = table_student.instanse();
        var rating  = table_academic_progress.instanse();

        student.clear();
        rating.clear();

        const string code_group   = "0";
        const string code_student = "0";

        string[] arg_student = new string[] { code_student, "Фамилия", "Имя", "Отчество", code_group, "Форма обучения", "Дата рождения", "Адрес", "Телефон", "E-mail" };
        student.add_record(arg_student);

        string[] arg_rating = new string[] { code_student, "Код предмета", "Форма контроля", "Оценка", "Дата", "Код преподавателя" };

        const int n = 10;

        for (int i = 0; i < n; i++)
        {
            rating.add_record(arg_rating);
        }

        var contr = new report_contr();

        table new_table = contr.report_by_rating();
        int   new_size  = new_table.size();

        Assert.AreEqual(new_size, n);
    }
Exemple #14
0
    private void selectTable()
    {
        if (current != null)
        {
            current.RemoveHighlight();
        }

        if (tablelist.Count > 0)
        {
            table selected  = null;
            float Idistance = 1000f;
            foreach (table f in tablelist)
            {
                float distance = Vector3.Distance(transform.position, f.transform.position);
                if (distance < Idistance)
                {
                    Idistance = distance;
                    selected  = f;
                }
            }

            if (selected != null)
            {
                //Debug.Log("El mas cercano es: " + selected.name);
                selected.Highlight();
                current = selected;
                //transform.localScale += new Vector3(0.1F, 0, 0);
            }
        }
    }
    public void request_by_rating_4_and_5_test()
    {
        var student = table_student.instanse();
        var rating  = table_academic_progress.instanse();

        student.clear();
        rating.clear();

        const string code_group   = "0";
        const string code_student = "0";
        const string rate_1       = "5";
        const string rate_2       = "4";

        string[] arg_student = new string[] { code_student, "Фамилия", "Имя", "Отчество", code_group, "Форма обучения", "Дата рождения", "Адрес", "Телефон", "E-mail" };
        student.add_record(arg_student);

        string[] arg_rating = new string[] { code_student, "Код предмета", "экзамен", rate_2, "Дата", "Код преподавателя" };
        rating.add_record(arg_rating);

        arg_rating = new string[] { code_student, "Код предмета", "экзамен", rate_1, "Дата", "Код преподавателя" };
        rating.add_record(arg_rating);

        var contr = new request_contr();

        table new_table = contr.find_by_rating(request_contr.by_rating._4_and_5);
        int   new_size  = new_table.size();

        Assert.AreEqual(new_size, 1);
    }
    public void report_group_test()
    {
        var student = table_student.instanse();
        var group   = table_group.instanse();

        student.clear();
        group.clear();

        const string code_group = "0";
        const string name_code  = "группа";

        string[] arg_student = new string[] { "0", "Фамилия", "Имя", "Отчество", code_group, "Форма обучения", "Дата рождения", "Адрес", "Телефон", "E-mail" };

        const int n = 10;

        for (int i = 0; i < n; i++)
        {
            student.add_record(arg_student);
        }

        string[] arg_group = new string[] { code_group, name_code, "Курс", "Код специальности", "Код факультета" };
        group.add_record(arg_group);

        var contr = new report_contr();

        table new_table = contr.report_by_group();
        int   new_size  = new_table.size();

        Assert.AreEqual(new_size, n);
    }
Exemple #17
0
    // вызывается из потока событий unity
    static private PacketTransformReady transform(PacketHeader packet)
    {
        PacketTransform transform = UnityEngine.JsonUtility.FromJson <PacketTransform>(packet.json_data);

        if (!idnames.ContainsKey(transform.idname))
        {
            return(new PacketTransformReady(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
        }

        int id = idnames[transform.idname];

        if (things.ContainsKey(id))
        {
            thing thing = (thing)things[id];
            List <UnityEngine.Vector3> pos = thing.GetPos();
            return(new PacketTransformReady(1, pos[0].x, pos[0].y, pos[0].z, pos[1].x, pos[1].y, pos[1].z, pos[2].x, pos[2].y, pos[2].z, pos[3].x));
        }

        if (tables.ContainsKey(id))
        {
            table table = (table)tables[id];
            List <UnityEngine.Vector3> pos = table.GetPos();
            return(new PacketTransformReady(1, pos[0].x, pos[0].y, pos[0].z, pos[1].x, pos[1].y, pos[1].z, pos[2].x, pos[2].y, pos[2].z, pos[3].x));
        }

        return(new PacketTransformReady(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
    }
    public void request_specialty_record_test()
    {
        var student   = table_student.instanse();
        var group     = table_group.instanse();
        var specialty = table_specialty.instanse();

        student.clear();
        group.clear();
        specialty.clear();

        const string code_group     = "0";
        const string name_group     = "группа";
        const string name_specialty = "специальность";
        const string code_specialty = "1";

        string[] arg_student = new string[] { "0", "Фамилия", "Имя", "Отчество", code_group, "Форма обучения", "Дата рождения", "Адрес", "Телефон", "E-mail" };
        student.add_record(arg_student);

        string[] arg_group = new string[] { code_group, name_group, "Курс", code_specialty, "код факультета" };
        group.add_record(arg_group);

        string[] arg_faculty = new string[] { code_specialty, name_specialty, "стоимость обучения" };
        specialty.add_record(arg_faculty);


        var contr = new request_contr();

        table new_table = contr.find_by_value(name_specialty, request_contr.by_value.specialty);
        int   new_size  = new_table.size();

        Assert.AreEqual(new_size, 1);
    }
Exemple #19
0
        private hand addHandToDB(HandHistory handHistory, table handTable)
        {
            hand dbHand = db.hands.Find(handHistory.HandId);

            if (dbHand != null)
            {
                return(dbHand);
            }
            IEnumerator <Card> cardList = handHistory.CommunityCards.GetEnumerator();

            dbHand = new Models.hand
            {
                HandID         = handHistory.HandId,
                TableID        = handTable.TableID,
                NumPlayers     = handHistory.NumPlayersActive,
                StartTime      = handHistory.DateOfHandUtc,
                ButtonPosition = handHistory.DealerButtonPosition,
                PotSize        = handHistory.TotalPot,
                FlopCard1      = (cardList.MoveNext()) ? cardList.Current.ToString() : null,
                FlopCard2      = (cardList.MoveNext()) ? cardList.Current.ToString() : null,
                FlopCard3      = (cardList.MoveNext()) ? cardList.Current.ToString() : null,
                TurnCard       = (cardList.MoveNext()) ? cardList.Current.ToString() : null,
                RiverCard      = (cardList.MoveNext()) ? cardList.Current.ToString() : null,
                table          = handTable,
            };
            db.hands.Add(dbHand);
            return(dbHand);
        }
    void LoadTable(int a)
    {
        FileStream file = null;

        try
        {
            BinaryFormatter bf = new BinaryFormatter();
            file = File.Open(Application.persistentDataPath + basefileName + a.ToString(), FileMode.Open);
            tableTobeRestored = bf.Deserialize(file) as table;
        }
        catch (Exception e)
        {
            if (e != null)
            {
                ;
            }
            // Handle Exception
        }
        finally
        {
            if (file != null)
            {
                file.Close();
            }
        }
    }
        public bool addAccountAndTable(String username, String password, int accTypeId, int tableNumber)
        {
            using (restaurantEntities context = new restaurantEntities())
            {
                try
                {
                    account newAcc = new account
                    {
                        username       = username,
                        password       = password,
                        AccountType_id = accTypeId,
                        active         = 1
                    };
                    context.account.Add(newAcc);
                    context.SaveChanges();

                    table newTable = new table
                    {
                        number     = tableNumber,
                        Account_id = newAcc.id
                    };
                    context.table.Add(newTable);
                    context.SaveChanges();

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }
Exemple #22
0
        private List <string> ParseHands(SiteName site, string handText, ref int parsedHands, ref int thrownOutHands)
        {
            List <string> messages = new List <string>();
            // Each poker site has its own parser so we use a factory to get the right parser.
            IHandHistoryParserFactory handHistoryParserFactory = new HandHistoryParserFactoryImpl();

            // Get the correct parser from the factory.
            IHandHistoryParser handHistoryParser = handHistoryParserFactory.GetFullHandHistoryParser(site);

            try
            {
                List <string> hands = new List <string>();
                hands = handHistoryParser.SplitUpMultipleHands(handText).ToList();
                db.Configuration.AutoDetectChangesEnabled = false;
                foreach (string hand in hands)
                {
                    try
                    {
                        // The true causes hand-parse errors to get thrown. If this is false, hand-errors will
                        // be silent and null will be returned.
                        HandHistory handHistory = handHistoryParser.ParseFullHandHistory(hand, true);

                        //handhistory can now be broken down to be put into the database

                        // Add to player table
                        Dictionary <string, player> playerDict = addPlayersToDB(handHistory);

                        // Add to table table
                        table dbTable = addTableToDB(handHistory);

                        db.SaveChanges();

                        //Add to hand table
                        hand dbHand = addHandToDB(handHistory, dbTable);

                        // Add to hand_action table
                        addHandActionToDB(handHistory, dbHand, playerDict);

                        // Add to plays table
                        addPlaysToDB(handHistory, playerDict);

                        db.SaveChanges();

                        parsedHands++;
                    }
                    catch (Exception ex)
                    {
                        messages.Add("Parsing Error: " + ex.Message);
                        thrownOutHands++;
                    }
                }
            }
            catch (Exception ex) // Catch hand-parsing exceptions
            {
                messages.Add("Parsing Error: " + ex.Message);
            }
            db.Configuration.AutoDetectChangesEnabled = true;
            return(messages);
        }
        public ActionResult DeleteConfirmed(long?id)
        {
            table table = db.tables.Find(id);

            db.tables.Remove(table);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public SGSserverForm()
 {
     InitializeComponent();
     for (int i = 0; i < 10; i++)
     {
         tab[i] = new table();
     }
 }
Exemple #25
0
    public static void addTable( int tableNum )
    {
        table aTable = new table(tableNum);
        allTables.Add (aTable);

        //		aTable.setTableBG( tableNum );
        //		aTable.tableNum = tableNum;
    }
Exemple #26
0
        //根据目前选择的操作,修改配置文件
        public void ExcuteModified(int branchIdx)
        {
            table     bt         = currentLuaTableData.tables[branchIdx + 1]; //branch table
            tablediff btd        = currentLuaTableData.tableDiffs[branchIdx]; //branch tablediff
            string    tmp        = bt.GenString(null, btd);
            string    aimTmpPath = TmpTableRealPaths[branchIdx];

            FileUtil.WriteTextFile(tmp, aimTmpPath);
        }
Exemple #27
0
        static void Main(string[] args)
        {
            table         t9      = new table(table.table9);
            ReaderResults r       = new ReaderResults("input.txt");
            List <double> Results = r.Results;

            Console.WriteLine("Считанные данные:");
            for (int i = 0; i < Results.Count; i++)
            {
                Console.Write("(" + (i + 1).ToString() + ")" + " " + Results[i] + " ");
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("1 посчитать среднее арифметическое");
            Console.WriteLine("2 посчитать доверительный интервал");
            Console.WriteLine("3 посчитать вероятность того, что погрешность не выйдет за границы");
            Console.WriteLine("q чтобы выйти");


            while (true)
            {
                string input = Console.ReadLine();
                if (input == "q")
                {
                    break;
                }
                int ans;
                if (!int.TryParse(input, out ans))
                {
                    Console.WriteLine("Число не распознано");
                    continue;
                }
                switch (ans)
                {
                case 1:
                    Console.Write("Среднее арифметическое: ");
                    Console.WriteLine(MyMath.Avg(Results));
                    break;

                case 2:
                    Console.Write("Доверительный интервал для среднего: ");
                    var t = t9.getValue(0.99);
                    Console.WriteLine(ConfidenceIntervalString(Results, t));
                    break;

                case 3:
                    Console.Write("Доверительный интервал для среднего: ");
                    //Console.WriteLine(ConfidenceIntervalString(Results));
                    break;

                default:
                    Console.WriteLine("неизвестный пункт");
                    break;
                }
            }
        }
 public ActionResult Edit([Bind(Include = "TableID,TableName,MaxPlayers,Stakes,Site,Limit")] table table)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table));
 }
Exemple #29
0
        static Setting get_table_setting(table table)
        {
            Setting type = _NormalSetting;

            if (_OptimalSetting.ContainsKey(table.name))
            {
                type = _OptimalSetting[table.name];
            }
            return(type);
        }
Exemple #30
0
        void Suko()
        {
            minimized = false;
            isFocused = false;
            conditionCtrlz.useScroll  = false;
            conditionCtrlz.ScrolWidth = 4;
//			conditionCtrlz.SizeUp();
            tabInfo = new table("", "", 0);
            ListIdx = -1;
        }
Exemple #31
0
 public void Cancel(string key, table bt)
 {
     if (modifiedrowsAppled.ContainsKey(key))
     {
         modifiedrows.Add(key, modifiedrowsAppled[key]);
         modifiedrowsAppled.Remove(key);
     }
     //table结构的回退
     bt.Cancel(key);
 }
Exemple #32
0
 public void ModifiedTables(int index, table val)
 {
     if (tables.Count > index)
     {
         tables[index] = val;
     }
     else
     {
         tables.Add(val);
     }
 }
Exemple #33
0
    private void OnTriggerEnter(Collider other)
    {
        table f = other.gameObject.GetComponent <table>();

        if (f != null)
        {
            tablelist.Add(f);
            //Debug.Log("Se agrego: " + f.name);
        }
        selectTable();
    }
Exemple #34
0
	public bool StartSkill(table.TableSkill skillTableInfo, List<Cmd.SkillHurtData> hurts)
	{
		if (skillTableInfo.path.Count == 0)
			return false;
		var path = "Prefabs/Skill/" + skillTableInfo.path[0]; // TODO: 多个技能动作按照一定规则播放
		var res = Resources.Load(path);
		if (res == null)
		{
			Debug.LogError("无法加载技能文件: " + path);
			return false;
		}

		var skill = Object.Instantiate(res) as GameObject;
		var s = skill.GetComponent<Skill>();
		s.startGo = gameObject;
		s.TableInfo = skillTableInfo;
		s.hurts = hurts;
		if (hurts.Count > 0)
		{
            s.targetGo = hurts[0].hurtid.GetGameObject();
		}
		foreach(var t in hurts)
		{
            s.targetGos.Add(t.hurtid.GetGameObject());
		}

		// 检查技能的有效性
		int count = 0;
		foreach(SendTargetEventBase t in skill.GetComponents<SendTargetEventBase>())
		{
			if (t.sendTargetEvent == true)
				count ++;
			
			if(count >= 2)
			{
				Debug.LogError("技能(" + path + ")有多个发送到达目标的组件");
				return false;
			}
		}

		foreach (SkillBase t in skill.GetComponents<SkillBase>())
		{
			t.StartSkill();
		}
		skill.transform.parent = transform;
		skill.transform.localPosition = Vector3.zero;
		return true;
	}
Exemple #35
0
        private void butApplyTemplate2_Click(object sender, EventArgs e)
        {
            char tabCaracter = '\u0009';
            try
            {

                String plantilla = util.loadFile(general.templateSelectedFullUri);

                // clean cmbGotocode
                cmbGoToCode.Items.Clear();

                table tab = new table();
                String tableSelected = cmbTablesx.Text;

                if (tableSelected.Equals(""))
                {
                    rt1.Text = "Please, select a table";
                }

                foreach (table item in general.actualProject.tables)
                {
                    if (item.Name.Equals(tableSelected))
                    {
                        tab = item;
                        if (tab.GetKey == null)
                        {
                            MessageBox.Show("Alert, review data, table doesnt have a key");
                            AsyncWriteLine("Alert, review data, table doesnt have a key");
                        }
                    }
                }

                string numerocampos = tab.fields.Count.ToString();

                try
                {
                    // si da un error en singleton es que falta la libreria commons o log4net..
                    Velocity.Init();

                    //VelocityEngine velocityEngine = new VelocityEngine();
                    //ExtendedProperties props = new ExtendedProperties();
                    //props.AddProperty("input.encoding", "UTF-8");
                    //props.AddProperty("output.encoding", "UTF-8");
                    //velocityEngine.Init(props);
                }
                catch (System.Exception exx)
                {
                    rt1.Text = "Problem initializing Velocity : " + exx;
                    return;
                }

                // lets make a Context and put data into it
                VelocityContext context = new VelocityContext();
                context.Put("project", general.actualProject);
                context.Put("table", tab);

                // lets render a template
                StringWriter writer = new StringWriter();
                try
                {

                    //Velocity.MergeTemplate(plantilla, context, writer);
                    Velocity.Evaluate(context, writer, "prueba", plantilla);

                    // now we got the template , so lets take the variables from the template
                    variablesTemplate var = new variablesTemplate();
                    var = util.getVariablesFromTemplate(writer.GetStringBuilder().ToString());

                    // now we delete the variables from the template cause there are no needed...
                    string finalText = util.deleteVariablesFromTemplate(writer.GetStringBuilder().ToString());

                    // le quitamos saltos de linea extra
                    finalText = finalText.Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n\r\n", "").Replace("\r\n\r\n\r\n\r\n", "");

                    // le quitamos los tabuladores extra
                    finalText = finalText.Replace(tabCaracter.ToString(), " ");

                    // rt1.Text = finalText;
                    writeText(finalText);

                    // number of lines written with generator
                    try
                    {
                        long numberOfLinesWrittenBefore = 0;
                        long numberOfLinesWritten = 0;

                        numberOfLinesWrittenBefore = sf.toLong(System.Configuration.ConfigurationManager.AppSettings["numberOfLinesWritten"]);
                        numberOfLinesWritten = numberOfLinesWrittenBefore + util.CountLinesInString(finalText);

                        labNumberOfLinesWritten.Values.Text = sf.cadena(numberOfLinesWritten) + " lines written with myWay";
                        // save data...
                        System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                        config.AppSettings.Settings["numberOfLinesWritten"].Value = sf.cadena(numberOfLinesWritten);
                        config.Save(ConfigurationSaveMode.Modified);
                        ConfigurationManager.RefreshSection("appSettings");
                    }
                    catch (Exception)
                    {

                        throw;
                    }

                    // now we got all the functions contained in the code
                    // and populate a combo with this...
                    // Instantiating Regex Object
                    Regex re = new Regex(@"(private|public|protected)\s\w(.)*\((.)*\)", RegexOptions.IgnoreCase);
                    MatchCollection mc = re.Matches(finalText);
                    foreach (Match mt in mc)
                    {
                        string st = "";
                        st = mt.ToString();
                        st = st.Replace("public", "");
                        st = st.Replace("private", "");
                        st = st.Replace("static", "");
                        st = st.Replace("void", "");

                        cmbGoToCode.Items.Add(st.Trim());
                        // Response.Write(mt.ToString() + "<br />");
                    }

                }
                catch (System.Exception exx)
                {
                    //util.playSimpleSound(Path.Combine(util.sound_dir, "zasentodalaboca.wav"));
                    SystemSounds.Asterisk.Play();

                    AsyncWriteLine(exx.Message);
                    rt1.Text = exx.Message;
                    //System.Console.Out.WriteLine("Problem merging template : " + exx);
                    System.Console.Out.WriteLine("Problem evaluating template : " + exx);
                }

                SystemSounds.Exclamation.Play();

                //util.playSimpleSound(Path.Combine(util.sound_dir, "risapetergriffin.wav"));

            }
            catch (Exception ex)
            {
                // util.playSimpleSound(Path.Combine(util.sound_dir, "zasentodalaboca.wav"));
                SystemSounds.Asterisk.Play();
                rt1.Text = ex.Message;
            }
        }
Exemple #36
0
 public tableNode(table tablex)
 {
     tablita = tablex;
     this.Text = tablex.Name  ;
 }
Exemple #37
0
        // funciones llamadas por los user control
        private void alterTable(string oldName, object tablita)
        {
            table tab = new table();
            tab = (table)tablita;

            // if oldName its empty its a new table...
            if (oldName.Equals(""))
            {
                actualProject.tables.Add(tab);
            }

            else
            {
                foreach (table item in actualProject.tables)
                {
                    if (item.Name.Equals(oldName))
                    {
                        item.Name = tab.Name;
                        item.nameChanged = true;

                    }
                }
            }

            actualProject.saveProject(Path.Combine(util.projects_dir, actualProject.name) + ".xml");
            cargarTablas();
            kp1.Controls.Clear();
        }
 //to view all the police
 private void PoliceReportClick(object sender, RoutedEventArgs e)
 {
     string sql = "select * from police";
     table t = new table(sql);
     t.Show();
 }
 //to view all the public place
 private void selectAllplaceClick(object sender, RoutedEventArgs e)
 {
     string sql = "select * from publicplace";
     table t = new table(sql);
     t.Show();
 }
Exemple #40
0
    public void getKeys(string cadconexion, table table)
    {
        SqlConnection conexion = null;
        try
        {
            List<String> lista = new List<String>();
            String sql = null;
            sql = String.Format(@" SELECT INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME AS TABLE_NAME,
                        INFORMATION_SCHEMA.KEY_COLUMN_USAGE.COLUMN_NAME AS COLUMN_NAME,
                        REPLACE(INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE,' ', '_') AS CONSTRAINT_TYPE
                        , INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME
                    FROM
                        INFORMATION_SCHEMA.TABLE_CONSTRAINTS
                        INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE ON
                        INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME =
                        INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME
                    WHERE
                        INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME <> N'sysdiagrams'  and
                        INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = '{0}'
                    ORDER BY
                        INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME ASC", table.Name);

            // esta sql nos da los primary key y los foreign key...

            conexion = new SqlConnection(cadconexion);
            miComando = new SqlCommand(sql);
            miComando.Connection = conexion;
            conexion.ConnectionString = cadconexion;
            conexion.Open();

            SqlDataReader dr = null;
            dr = miComando.ExecuteReader();

            while (dr.Read())
            {
                String tipo = sf.cadena(dr["CONSTRAINT_TYPE"]);
                String campo = sf.cadena(dr["COLUMN_NAME"]);
                String comentario = getComments(cadconexion, table.Name, campo);

                switch (tipo)
                {
                    case "PRIMARY_KEY":
                        foreach (field fi in table.fields)
                        {
                            if (fi.Name.Equals(campo))
                            {
                                fi.isKey = true;
                                table.keyFields.Add(fi);
                                if (table.GetKey == "")
                                    table.GetKey = campo;
                            }

                        }
                        break;
                    case "FOREIGN_KEY":
                        foreach (field fi in table.fields)
                        {
                            if (fi.Name.Equals(campo))
                            {
                                fi.isForeignKey = true;
                                table.notKeyFields.Add(fi);
                            }

                        }
                        break;
                    default:

                        foreach (field fix in table.fields)
                        {
                            if (fix.Name.Equals(campo))
                            {
                                table.notKeyFields.Add(fix);
                            }
                        }
                        break;
                }

                //foreach (field fi in table.fields)
                //{

                //    if (fi.Name.Equals(campo))
                //    {

                //        fi.comment = comentario;
                //         // switch comment....

                //    }

                //    if (comentario != "")
                //        fi.targetName = comentario.Trim();
                //}
            }
        }
        catch (Exception ep)
        {
            //  lo.tratarError(ep, "Error en dbClass.new", "");

        }
        finally
        {
            conexion.Close();
        }
    }
Exemple #41
0
    public List<table> getTables(string cadconexion, string database)
    {
        OleDbConnection conexion = null;
        try
        {
            List<table> lista = new List<table>();

            conexion = new OleDbConnection(cadconexion);
            miComando = new OleDbCommand("");
            miComando.Connection = conexion;
            conexion.ConnectionString = cadconexion;
            conexion.Open();

            System.Data.DataTable dt = new System.Data.DataTable();
            dt = conexion.GetSchema(OleDbMetaDataCollectionNames.Tables, new String[] { null, null, null, null });

            foreach (System.Data.DataRow rowDatabase in dt.Rows)
            {
                // exclude system tables...
                if (rowDatabase["table_name"].ToString().IndexOf("TMP") == -1 && rowDatabase["table_name"].ToString().IndexOf("MSys") == -1 && rowDatabase.ItemArray[3].Equals("TABLE"))
                {
                    string tableName = rowDatabase["table_name"].ToString();

                    table tab = new table();
                    tab.Name = tableName;
                    tab.TargetName = tab.Name;
                    lista.Add(tab);

                }

            }

            return lista;

        }
        catch (Exception ep)
        {
            //  lo.tratarError(ep, "Error en dbClass.new", "");
            return null;
        }
        finally
        {
            conexion.Close();
        }
    }
Exemple #42
0
    // we get extra information for the fields...
    public void getKeys(string cadconexion, table table, String database)
    {
        MySqlConnection conexion = null;
        try
        {
            List<String> lista = new List<String>();
            String sql = null;
            //sql = String.Format("SELECT  table_name, column_name, constraint_name, referenced_table_name, referenced_column_name FROM information_schema.key_column_usage WHERE TABLE_NAME = '{0}' ", table);
            sql = String.Format("SELECT  * FROM information_schema.columns WHERE TABLE_NAME = '{0}' and TABLE_SCHEMA= '{1}'", table.Name, database);

            conexion = new MySqlConnection(cadconexion);
            miComando = new MySqlCommand(sql);
            miComando.Connection = conexion;
            conexion.ConnectionString = cadconexion;
            conexion.Open();

            MySql.Data.MySqlClient.MySqlDataReader dr = null;
            dr = miComando.ExecuteReader();

            while (dr.Read())
            {
                String tipo = sf.cadena(dr["COLUMN_KEY"]);
                String campo = sf.cadena(dr["COLUMN_NAME"]);
                String comentario = sf.cadena(dr["COLUMN_COMMENT"]);
                String defecto = sf.cadena(dr["COLUMN_DEFAULT"]);
                bool isNullable = sf.boolean(dr["is_nullable"]);
                int maximumLength = sf.entero(dr["character_maximum_length"]);

                switch (tipo)
                {
                    case "PRI":
                        foreach (field fi in table.fields)
                        {
                            if (fi.Name.Equals(campo))
                            {
                                fi.isKey = true;
                                table.keyFields.Add(fi);
                                if (table.GetKey == "")
                                    table.GetKey = campo;
                            }

                        }
                        break;
                    case "MUL":
                        foreach (field fi in table.fields)
                        {
                            if (fi.Name.Equals(campo))
                            {
                                // its not clear that its a foreign key
                                // fi.isForeignKey = true;
                                table.notKeyFields.Add(fi);
                            }

                        }
                        break;
                    default:
                        foreach (field fix in table.fields)
                        {
                            if (fix.Name.Equals(campo))
                            {
                                table.notKeyFields.Add(fix);
                            }
                        }
                        break;
                }

                // ahora rellenamos los valores extra
                foreach (field fi in table.fields)
                {
                    if (fi.Name.Equals(campo))
                    {
                        if (!comentario.Equals(""))
                        {
                            fi.targetName = comentario;

                            fi.comment = comentario;
                            fi.defaultValue = defecto;
                            fi.allowNulls = isNullable;
                            fi.size = maximumLength;

                            // switch comment....
                            if (comentario.Contains("#date#"))
                            {
                                fi.targetType = field.fieldType._date;
                            }
                            if (comentario.Contains("#img#") | comentario.Contains("#image#"))
                            {
                                fi.targetType = field.fieldType._image;
                            }
                            if (comentario.Contains("#audio#"))
                            {
                                fi.targetType = field.fieldType._audio;
                            }
                            if (comentario.Contains("#money#"))
                            {
                                fi.targetType = field.fieldType._money;
                            }
                            if (comentario.Contains("#video#"))
                            {
                                fi.targetType = field.fieldType._video;
                            }
                            if (comentario.Contains("#doc#") | comentario.Contains("#document#"))
                            {
                                fi.targetType = field.fieldType._document;
                            }
                            if (comentario.Contains("#hide#"))
                            {
                                fi.invisible = true;
                                fi.targetType = field.fieldType._hidden;
                            }
                            if (comentario.Contains("#desc#"))
                            {
                                fi.isDescriptionInCombo = true;
                                table.fieldDescription = fi.Name;
                            }

                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#date#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#img#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#image#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#audio#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#money#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#video#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#doc#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#document#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#hide#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#desc#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                            // ahora reglas - now validation rules...
                            if (comentario.Contains("#url#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Url));
                            if (comentario.Contains("#email#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Email));

                            if (comentario.Contains("#requerido#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Required));

                            if (comentario.Contains("#requerido#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Required));

                            if (comentario.Contains("#alphaNumeric#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Alphanumeric));

                            if (comentario.Contains("#creditcard#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.CreditCard));

                            if (comentario.Contains("#date#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Date));

                            if (comentario.Contains("#decimal#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Decimal));

                            if (comentario.Contains("#ip#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.IP));

                            if (comentario.Contains("#isUnique#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.IsUnique));

                            if (comentario.Contains("#money#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Money));

                            if (comentario.Contains("#numeric#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Numeric));

                            if (comentario.Contains("#phone#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Phone));

                            if (comentario.Contains("#postal#"))
                                fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Postal));

                            if (comentario.Contains("#between"))
                            {
                                string IPMatchExp = @"#between(?:(?<t>[^#]*))";
                                Match theMatch = Regex.Match(comentario, IPMatchExp);
                                string st = "";
                                if (theMatch.Success)
                                    st = theMatch.Groups[1].Value;
                                if (st.Equals(""))
                                {

                                    fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Between));

                                }

                            }

                            if (comentario.Contains("#comparison"))
                            {
                                string IPMatchExp = @"#comparison(?:(?<t>[^#]*))";
                                Match theMatch = Regex.Match(comentario, IPMatchExp);
                                string st = "";
                                if (theMatch.Success)
                                    st = theMatch.Groups[1].Value;
                                if (st.Equals(""))
                                {

                                    fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Between));

                                }

                            }

                            if (comentario.Contains("#extension"))
                            {
                                string IPMatchExp = @"#extension(?:(?<t>[^#]*))";
                                Match theMatch = Regex.Match(comentario, IPMatchExp);
                                string st = "";
                                if (theMatch.Success)
                                    st = theMatch.Groups[1].Value;
                                if (st.Equals(""))
                                {

                                    fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Between));

                                }

                            }

                            if (comentario.Contains("#minLength"))
                            {
                                string IPMatchExp = @"#minLength(?:(?<t>[^#]*))";
                                Match theMatch = Regex.Match(comentario, IPMatchExp);
                                string st = "";
                                if (theMatch.Success)
                                    st = theMatch.Groups[1].Value;
                                if (st.Equals(""))
                                {

                                    fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Between));

                                }

                            }

                            if (comentario.Contains("#maxLength"))
                            {
                                string IPMatchExp = @"#maxLength(?:(?<t>[^#]*))";
                                Match theMatch = Regex.Match(comentario, IPMatchExp);
                                string st = "";
                                if (theMatch.Success)
                                    st = theMatch.Groups[1].Value;
                                if (st.Equals(""))
                                {

                                    fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Between));

                                }

                            }

                            if (comentario.Contains("#inList"))
                            {
                                string IPMatchExp = @"#inList(?:(?<t>[^#]*))";
                                Match theMatch = Regex.Match(comentario, IPMatchExp);
                                string st = "";
                                if (theMatch.Success)
                                    st = theMatch.Groups[1].Value;
                                if (st.Equals(""))
                                {

                                    fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Between));

                                }

                            }

                            if (comentario.Contains("#regexp"))
                            {
                                string IPMatchExp = @"#regexp(?:(?<t>[^#]*))";
                                Match theMatch = Regex.Match(comentario, IPMatchExp);
                                string st = "";
                                if (theMatch.Success)
                                    st = theMatch.Groups[1].Value;
                                if (st.Equals(""))
                                {

                                    fi.validationRules.Add(new validationRule(validationRule.typeOfValidation.Between));

                                }

                            }

                            //  comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#between(?:(?<t>[^#]*))#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#url#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#email#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#requerido#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#required#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#alphaNumeric#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#creditcard#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#date#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#decimal#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#ip#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#isUnique#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#money#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#numeric#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#phone#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#postal#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#comparison(?:(?<t>[^#]*))#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#between(?:(?<t>[^#]*))#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#extension(?:(?<t>[^#]*))#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#minlength(?:(?<t>[^#]*))#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#maxlength(?:(?<t>[^#]*))#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#inList(?:(?<t>[^#]*))#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                            comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#regexp(?:(?<t>[^#]*))#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                        }

                        if (comentario != "")
                            fi.targetName = comentario.Trim();

                    }

                }

            }

        }
        catch (Exception ep)
        {
            //  lo.tratarError(ep, "Error en dbClass.new", "");

        }
        finally
        {
            conexion.Close();
        }
    }
 //to view public places in one area
 private void selectOneAreaClick(object sender, RoutedEventArgs e)
 {
     string area = this.publicPlace.Text;
     if (area.Length == 0)
     {
         System.Windows.MessageBox.Show("请选择区域!", "提示", System.Windows.MessageBoxButton.OK);
         return;
     }
     string sql = "select * from publicplace where address like '" + area + "%'";
     table t = new table(sql);
     t.Show();
 }
        //create the report through status
        private void statuscreateClick(object sender, RoutedEventArgs e)
        {
            bool isempty = true;

            if(this.checkbuildcase.IsChecked == false &&
               this.checkfinishcase.IsChecked == false &&
               this.checktrialcase.IsChecked == false &&
               this.checksurveycase.IsChecked == false)
            {
                System.Windows.MessageBox.Show("没有选择任何一项!", "提示", System.Windows.MessageBoxButton.OK);
                return;
            }

            string condition = "";
            if (this.checksurveycase.IsChecked == true)
            {
                if (!isempty)
                {
                    condition += " or casestatus = '调查' ";
                }
                condition += "select * from cases where casestatus = '调查' ";
                isempty = false;
            }
            if (this.checktrialcase.IsChecked == true)
            {
                if (!isempty)
                {
                    condition += " or casestatus = '审讯' ";
                }
                condition += "select * from cases where casestatus = '审讯' ";
                isempty = false;
            }
            if (this.checkbuildcase.IsChecked == true)
            {
                if (!isempty)
                {
                    condition += " or casestatus = '立案' ";
                }
                condition += "select * from cases where casestatus = '立案' ";
                isempty = false;
            }
            if (this.checkfinishcase.IsChecked == true)
            {
                if (!isempty)
                {
                    condition += " or casestatus = '结案' ";
                }
                condition += "select * from cases where casestatus = '结案' ";
                isempty = false;
            }

            condition.Remove(condition.Length - 1);
            table t = new table(condition);
            t.Show();
        }
        //create the report through time
        private void CaseReportTimeClick(object sender, RoutedEventArgs e)
        {
            string time = this.reportTime.Text;

            try
            {
                Convert.ToDateTime(time);
            }
            catch (System.FormatException ex)
            {
                ex.ToString();
                System.Windows.MessageBox.Show("请将时间格式设置为yyyy-mm-dd!", "提示", System.Windows.MessageBoxButton.OK);
                return;
            }

            time = "'" + time + "'";
            string sql = "select * from cases where time=" + time;
            //string sql = "select * from cases";
            table t = new table(sql);
            t.Show();
        }
 /*    public int find(string s)
     {
         /*for (int i = 0; i < 10; i++)
         {
             if (ep_tab[i].usr != null)
                 if (s.Equals(ep_tab[i].usr))
                     return ep_tab[i].index;
         }
         return -1;
         if (ep_tab.ContainsKey(s))
         {
             ep e = ep_tab[s];
             return e.index;
         }
         return -1;
     } */
 public SocketServer()
 {
     InitializeComponent();
     for (int i = 0; i < 10; i++)
         tab[i] = new table();
 }
Exemple #47
0
    public List<table> getTables(string cadconexion, string database)
    {
        SqlConnection conexion = null;
        try
        {
            List<table> lista = new List<table>();

            conexion = new SqlConnection(cadconexion);
            miComando = new SqlCommand("");
            miComando.Connection = conexion;
            conexion.ConnectionString = cadconexion;
            conexion.Open();

            System.Data.DataTable dt = new System.Data.DataTable();
            dt = conexion.GetSchema(SqlClientMetaDataCollectionNames.Tables, new String[] { null, null, null, null });

            foreach (System.Data.DataRow rowDatabase in dt.Rows)
            {
                string tableName = rowDatabase["table_name"].ToString();
                if (tableName.Equals("dtproperties") || tableName.Equals("sysdiagrams"))
                {
                    // system tables
                }
                else
                {
                    table tab = new table();
                    tab.Name = tableName;
                    tab.TargetName = tab.Name;
                    lista.Add(tab);
                }

            }

            return lista;

        }
        catch (Exception ep)
        {
            //  lo.tratarError(ep, "Error en dbClass.new", "");
            return null;
        }
        finally
        {
            conexion.Close();
        }
    }
Exemple #48
0
    public List<table> getTables(string cadconexion, string database)
    {
        MySql.Data.MySqlClient.MySqlConnection conexion = null;
        try
        {
            List<table> lista = new List<table>();

            conexion = new MySql.Data.MySqlClient.MySqlConnection(cadconexion);
            miComando = new MySqlCommand("");
            miComando.Connection = conexion;
            conexion.ConnectionString = cadconexion;
            conexion.Open();

            System.Data.DataTable dt = new System.Data.DataTable();
            dt = conexion.GetSchema("Tables", new String[] { null, database, null, null });

            foreach (System.Data.DataRow rowDatabase in dt.Rows)
            {
                table tab = new table();
                tab.Name = rowDatabase["table_name"].ToString();
                tab.TargetName = tab.Name;
                lista.Add(tab);

            }

            return lista;

        }
        catch (Exception ep)
        {
            //  lo.tratarError(ep, "Error en dbClass.new", "");
            return null;
        }
        finally
        {
            conexion.Close();
        }
    }
Exemple #49
0
    public void getKeys(string cadconexion, table table)
    {
        OleDbConnection conexion = null;
        try
        {
            List<String> lista = new List<String>();

            conexion = new OleDbConnection(cadconexion);
            miComando = new OleDbCommand("");
            miComando.Connection = conexion;
            conexion.ConnectionString = cadconexion;
            conexion.Open();

            System.Data.DataTable dt = new System.Data.DataTable();
            // dt = conexion.GetSchema(OleDbMetaDataCollectionNames.Indexes, new String[] { null, null, table.ToString(), null });
            dt = conexion.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, new String[] { null, null, table.Name });

            foreach (System.Data.DataRow row in dt.Rows)
            {
                foreach (field item in table.fields)
                {
                    if (item.Name.Equals(row[3].ToString()))
                    {
                        item.isKey = true;
                        table.keyFields.Add(item);
                        if (table.GetKey == "")
                            table.GetKey = item.Name;
                    }
                    else
                    {
                        table.notKeyFields.Add(item);
                    }

                }
            }

        }
        catch (Exception ep)
        {
            //  lo.tratarError(ep, "Error en dbClass.new", "");

        }
        finally
        {
            conexion.Close();
        }
    }
        /*Unit Implementation in Web Services - End*/
        //Method to fetch the table module details
        /*Unit Implementation in Web Services - Begin*/
        //Added a new parameter - strUnit
        public List<table> getTableData(double dStnLat, double dStnLong, int iAtl, int iMaxDist, int iMaxAltDiff, IRuleSets objIRuleset, string strNode, string strNodeName, string strCultureCode, string strServiceName, string strModuleName, string strLangID,string strUnit)
        {
            DataSet dsTbl = new DataSet();
            objTableSvc.setTableWebServiceValues(dStnLat, dStnLong, iAtl, iMaxDist, iMaxAltDiff);
            /*Unit Implementation in Web Services - Begin*/
            dsTbl = objTblPre.getTableDataForService(strNode, strNodeName, objIRuleset, strServiceName, strModuleName, strCultureCode, strUnit);
            /*Unit Implementation in Web Services - End*/
            List<table> tablelist = new List<table>();
            table tbl;
            tableRow tr = new tableRow();
            tableCell tc;
            HeaderRow hr1 = new HeaderRow();
            HeaderRow hr2 = new HeaderRow();
            HeaderCell hc;

            if (dsTbl.Tables[0].TableName.ToLower().Contains("header") && dsTbl.Tables.Count == 2)
            {
                tbl = new table();
                tbl.HeaderRows = new List<HeaderRow>();
                tbl.TableName = dsTbl.Tables[1].TableName;

                hr1.HeaderCells = new List<HeaderCell>();
                hr2.HeaderCells = new List<HeaderCell>();
                int count = 0;
                string day = "";
                string prevVal = "";
                foreach (DataRow dr in dsTbl.Tables[0].Rows)
                {
                    if (count == 0)
                    {
                        hc = new HeaderCell();
                        hc.Value = "";
                        hc.Colspan = "1";
                        hr1.HeaderCells.Add(hc);
                        hc = new HeaderCell();
                        hc.Value = "";
                        hc.Colspan = "1";
                        hr2.HeaderCells.Add(hc);
                    }
                    if (prevVal != dr[0].ToString().Split(',')[0] && !(dr[0].ToString().Split(',')[1].EndsWith("0")))
                    {
                        hc = new HeaderCell();
                        day = DateTime.Parse(dr[0].ToString().Split(',')[0].ToString()).DayOfWeek.ToString();
                        hc.Value = day;
                        hc.Colspan = dr[1].ToString();
                        hr1.HeaderCells.Add(hc);
                        prevVal = dr[0].ToString().Split(',')[0];
                    }
                    HeaderCell hc1 = new HeaderCell();
                    hc1.Value = dr[0].ToString().Split(',')[1].ToString();
                    hc1.Colspan = "1";
                    hr2.HeaderCells.Add(hc1);
                    count++;
                }
                tbl.HeaderRows.Add(hr1);
                tbl.HeaderRows.Add(hr2);

                tbl.tableRows = new List<tableRow>();
                foreach (DataRow dr in dsTbl.Tables[1].Rows)
                {
                    tr = new tableRow();
                    tr.tableCells = new List<tableCell>();
                    for (int i = 0; i < (dsTbl.Tables[1].Columns.Count/3); i++)
                    {
                        tc = new tableCell();
                        tc.Value = dr[0 + (i * 3)].ToString();
                        tc.ToolTip = dr[1 + (i * 3)].ToString();
                        tc.bgColor = dr[2 + (i * 3)].ToString();
                        if (i == 0)
                        {
                            tc.Color = "";
                            tc.CellImage = "";
                        }
                        else
                        {
                            Color bgColor = new Color();
                            bgColor = ColorTranslator.FromHtml(tc.bgColor);
                            tc.Color = ColorTranslator.FromHtml("#" + objCommonUtil.ContrastColor(bgColor).Name).Name;
                            /********IM01144144 - New Agricast Webservices - icons URL - BEGIN ***************************/
                            //tc.CellImage = objCommonUtil.toBase64(GetImage(tc.Value, tc.Color, tc.bgColor));
                            tc.CellImage = GetImage(tc.Value, tc.Color, tc.bgColor);
                            /********IM01144144 - New Agricast Webservices - icons URL - END ***************************/
                        }
                        if (i == 0)
                            tc.Header = "true";
                        else
                            tc.Header = "";
                        tr.tableCells.Add(tc);
                    }
                    tbl.tableRows.Add(tr);
                }

                tablelist.Add(tbl);
            }
            else
            {
                foreach (DataTable dt in dsTbl.Tables)
                {
                    tbl = new table();
                    tbl.HeaderRows = new List<HeaderRow>();
                    tbl.TableName = dt.TableName.ToString();

                    hr1.HeaderCells = new List<HeaderCell>();
                    for (int i = 0; i < (dt.Columns.Count / 3);i++ )
                    {
                        hc = new HeaderCell();
                        if (i == 0)
                            hc.Value = objLocSearchSvc.getTranslatedText("hour", strLangID);
                        else
                            hc.Value = (i-1).ToString();
                        hc.Colspan = "1";
                        hr1.HeaderCells.Add(hc);
                    }
                    tbl.HeaderRows.Add(hr1);

                    tbl.tableRows = new List<tableRow>();
                    foreach (DataRow dr in dt.Rows)
                    {
                        tr = new tableRow();
                        tr.tableCells = new List<tableCell>();
                        for (int i = 0; i < (dr.Table.Columns.Count/3); i++)
                        {
                            tc = new tableCell();
                            tc.Value = dr[0 + (i * 3)].ToString();
                            tc.ToolTip = dr[1 + (i * 3)].ToString();
                            tc.bgColor = dr[2 + (i * 3)].ToString();
                            if (i == 0)
                            {
                                tc.Color = "";
                                tc.CellImage = "";
                            }
                            else
                            {
                                Color bgColor = new Color();
                                bgColor = ColorTranslator.FromHtml(tc.bgColor);
                                tc.Color = ColorTranslator.FromHtml("#" + objCommonUtil.ContrastColor(bgColor).Name).Name;
                                /********IM01144144 - New Agricast Webservices - icons URL - BEGIN ***************************/
                                //tc.CellImage =  objCommonUtil.toBase64(GetImage(tc.Value, tc.Color, tc.bgColor));
                                tc.CellImage = GetImage(tc.Value, tc.Color, tc.bgColor);
                                /********IM01144144 - New Agricast Webservices - icons URL - END ***************************/
                            }
                            if (i == 0)
                                tc.Header = "true";
                            else
                                tc.Header = "";
                            tr.tableCells.Add(tc);
                        }
                        tbl.tableRows.Add(tr);
                    }

                    tablelist.Add(tbl);
                }
            }
             return tablelist;
        }
Exemple #51
0
	public static GameObject Create(table.TableAvatar item)
	{
		return Create(Skeleton[item.sex], item.body, item.head, item.weapon);
	}
 public void AddNpc2(table npc)
 {
     if (Npcs2.ContainsKey(npc.UID) == false)
     {
         Npcs2.Add(npc.UID, npc);
         #region Setting the near coords invalid to avoid unpickable items.
         Floor[npc.X, npc.Y, MapObjectType.InvalidCast, npc] = false;
         if (npc.Lookface / 10 != 108 && (byte)npc.Lookface < 10)
         {
             ushort X = npc.X, Y = npc.Y;
             foreach (Enums.ConquerAngle angle in Angles)
             {
                 ushort xX = X, yY = Y;
                 UpdateCoordonatesForAngle(ref xX, ref yY, angle);
                 Floor[xX, yY, MapObjectType.InvalidCast, null] = false;
             }
         }
         #endregion
     }
 }
Exemple #53
0
		Add(table);
Exemple #54
0
    public void getKeys(string cadconexion,   table table)
    {
        OleDbConnection conexion = null;
            try
            {
                List<String> lista = new List<String>();

                conexion = new OleDbConnection(cadconexion);
                miComando = new OleDbCommand("");
                miComando.Connection = conexion;
                conexion.ConnectionString = cadconexion;
                conexion.Open();

                System.Data.DataTable dt = new System.Data.DataTable();
                dt = conexion.GetSchema(OleDbMetaDataCollectionNames.Indexes, new String[] { null, null, table.ToString(), null });

                foreach (System.Data.DataRow row in dt.Rows)
                {

                }

                //while (dr.Read())
                //{
                //    String tipo = sf.cadena(dr["CONSTRAINT_TYPE"]);
                //    String campo = sf.cadena(dr["COLUMN_NAME"]);
                //    String comentario = getComments(cadconexion, table.Name, campo);

                //    switch (tipo)
                //    {
                //        case "PRIMARY_KEY":
                //            foreach (field fi in table.fields)
                //            {
                //                if (fi.Name.Equals(campo))
                //                {
                //                    fi.isKey = true;
                //                    if (table.GetKey == "")
                //                        table.GetKey = campo;
                //                }

                //            }
                //            break;
                //        case "FOREIGN_KEY":
                //            foreach (field fi in table.fields)
                //            {
                //                if (fi.Name.Equals(campo))
                //                    fi.isForeignKey = true;
                //            }
                //            break;
                //        default:
                //            break;
                //    }

                //    foreach (field fi in table.fields)
                //    {

                //        if (fi.Name.Equals(campo))
                //        {

                //            fi.comment = comentario;
                //            if (comentario.Contains("#img#"))
                //            {
                //                comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#img#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                //                fi.targetType = field.fieldType._image;
                //            }
                //            if (comentario.Contains("#audio#"))
                //            {
                //                comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#audio#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                //                fi.targetType = field.fieldType._audio;
                //            }
                //            if (comentario.Contains("#money#"))
                //            {
                //                comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#money#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                //                fi.targetType = field.fieldType._money;
                //            }
                //            if (comentario.Contains("#video#"))
                //            {
                //                comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#video#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                //                fi.targetType = field.fieldType._video;
                //            }
                //            if (comentario.Contains("#doc#"))
                //            {
                //                comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#doc#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                //                fi.targetType = field.fieldType._document;
                //            }
                //            if (comentario.Contains("#desc#"))
                //            {
                //                comentario = System.Text.RegularExpressions.Regex.Replace(comentario, @"#desc#", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                //                fi.isDescriptionInCombo = true;
                //                table.fieldDescription = fi.Name;
                //            }

                //        }
                //    }
                //}
            }
            catch (Exception ep)
            {
                //  lo.tratarError(ep, "Error en dbClass.new", "");

            }
            finally
            {
                conexion.Close();
            }
    }