Пример #1
0
        private void RefreshAgent()
        {
            int    i;
            string id, name;

            OKDT.ConterAgent[] readAgent;
            AgentStruct[]      agentChilds;

            AgentStruct Header = new AgentStruct("Id", "Имя поставщика");

            readAgent = OKDT.StructWorkClass.ReadAgent();
            StructureViewStack.Children.Clear();
            agentChilds         = new AgentStruct[readAgent.Length];
            AddRow.Height       = new GridLength(50);
            addStatus           = 3;
            HeaderFrame.Content = Header;

            addName          = "Agent Name";
            writeConterAgent = new AddAgentElement();
            AddFrame.Content = writeConterAgent;

            for (i = 0; i < readAgent.Length; i++)
            {
                id             = Convert.ToString(readAgent[i].Id);
                name           = readAgent[i].Name;
                agentChilds[i] = new AgentStruct(id, name);
                StructureViewStack.Children.Add(agentChilds[i]);
            }
        }
Пример #2
0
        public void AgentStructHandle(AgentStruct AgentStruct)
        {
            string select_str = "select levelId, l9, l8, l7,companyId , betSetting from [lottery].[dbo].[member] with(nolock) ";
            string where_str  = " Where id = @id ";
            var    e          = conn.Query <member>(select_str + where_str,
                                                    new { Id = AgentStruct.ParentId }).FirstOrDefault();

            select_str = "select betRate, defaultBetSetting from [lottery].[dbo].[company] with(nolock) ";
            where_str  = " Where principalId = @principalId ";
            var h = conn.Query <company>(select_str + where_str,
                                         new { principalId = AgentStruct.ParentId }).FirstOrDefault();

            Define memberDefine = new Define();

            member m = new member()
            {
                username       = AgentStruct.Username,
                password       = AgentStruct.Password,
                levelId        = memberDefine.GetNextLevelId(e.levelId),
                companyId      = 0,
                parentId       = AgentStruct.ParentId,
                externalId     = "",
                createDateTime = DateTime.Now,
                l9             = e.l9,
                l8             = e.l8,
                l7             = e.l7,
                betSetting     = e.betSetting,
                status         = Define.MemberStauts.Enable,
                nickname       = AgentStruct.Nickname
            };

            dcdc.members.InsertOnSubmit(m);
            dcdc.SubmitChanges();

            int principalId = m.id;

            company c = new company()
            {
                title             = AgentStruct.Title,
                createDateTime    = DateTime.Now,
                principalId       = principalId,
                betRate           = h.betRate,
                defaultBetSetting = h.defaultBetSetting
            };

            dcdc.companies.InsertOnSubmit(c);
            dcdc.SubmitChanges();

            int companyId = c.Id;

            if (AgentStruct.LevelId == Define.MemberLevels.UpAgent)
            {
                m.l8 = principalId;
            }
            if (AgentStruct.LevelId == Define.MemberLevels.Agent)
            {
                m.l7 = principalId;
            }

            m.companyId = companyId;

            dcdc.SubmitChanges();
        }
Пример #3
0
        public string AgentStructHandle(AgentStruct agentStruct)
        {
            string update_str = "update [lottery].[dbo].[member]  ";
            string set_str    = "";
            string where_str  = "";

            if (agentStruct.Password != null)
            {
                if (set_str != "")
                {
                    set_str += ",";
                }
                set_str += " password='******'";
            }

            if (agentStruct.Nickname != null)
            {
                if (set_str != "")
                {
                    set_str += ",";
                }
                set_str += " nickname = '" + agentStruct.Password + "'";
            }

            if (agentStruct.Stauts != null)
            {
                if (set_str != "")
                {
                    set_str += ",";
                }
                set_str += " status = " + agentStruct.Stauts;
            }

            if (agentStruct.BetSetting != null)
            {
                if (set_str != "")
                {
                    set_str += ",";
                }
                set_str += " betSetting = '" + JsonConvert.SerializeObject(agentStruct.BetSetting) + "'";
                ModuleName(agentStruct.BetSetting)
            }

            where_str += " id = " + agentStruct.AgentId.ToString();

            if (set_str != "")
            {
                if (agentStruct.UpdateUserId.HasValue)
                {
                    if (set_str != "")
                    {
                        set_str += ",";
                    }
                    set_str += " updateUserId = " + agentStruct.UpdateUserId;
                }

                set_str += ",";
                set_str += " updateDateTime='" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + "'";
                conn.Execute(update_str + " set " + set_str + " where " + where_str);
            }

            update_str = "update [lottery].[dbo].[company]  ";
            set_str    = "";
            where_str  = "";

            if (agentStruct.Title != null)
            {
                if (set_str != "")
                {
                    set_str += ",";
                }
                set_str += " title = '" + agentStruct.Title + "'";
            }

            if (agentStruct.BetRate != null)
            {
                if (set_str != "")
                {
                    set_str += ",";
                }
                set_str += " betRate = '" + JsonConvert.SerializeObject(agentStruct.BetRate) + "'";
            }

            if (agentStruct.DefaultBetSetting != null)
            {
                if (set_str != "")
                {
                    set_str += ",";
                }
                set_str += " defaultBetSetting = '" + JsonConvert.SerializeObject(agentStruct.DefaultBetSetting) + "'";
            }

            where_str += "  principalId = " + agentStruct.AgentId.ToString();

            if (set_str != "")
            {
                if (agentStruct.UpdateUserId.HasValue)
                {
                    if (set_str != "")
                    {
                        set_str += ",";
                    }
                    set_str += " updateUserId = " + agentStruct.UpdateUserId;
                }

                set_str += ",";
                set_str += " updateDateTime = '" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + "'";

                conn.Execute(update_str + " set " + set_str + " where " + where_str);
            }

            return(set_str);
        }