コード例 #1
0
        /// <summary>
        /// Update Employee
        /// </summary>
        /// <param name="arg"></param>
        public void UpdateEmployee(Employee arg)
        {
            string sql = @"UPDATE [HR].[Employees]
                           SET [LastName] = @LastName,[FirstName] = @FirstName,[Title] = @Title,
                               [TitleOfCourtesy] = @TitleOfCourtesy,[BirthDate] = @BirthDate,
                               [HireDate] = @HireDate,[Address] = @Address,[City] = @City,
                               [Country] = @Country,[Phone] = @Phone,[ManagerID] = @ManagerID,
                               [Gender] = @Gender,[MonthlyPayment] = @MonthlyPayment,
                               [YearlyPayment] = @YearlyPayment
                            WHERE [EmployeeID] = @EmployeeID";

            using (SqlConnection conn = new SqlConnection(ConfigTool.GetDBConnectionString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add(new SqlParameter("@LastName", NullToDBNullValue(arg.LastName, true)));
                cmd.Parameters.Add(new SqlParameter("@FirstName", NullToDBNullValue(arg.FirstName, true)));
                cmd.Parameters.Add(new SqlParameter("@Title", NullToDBNullValue(arg.Title, true)));
                cmd.Parameters.Add(new SqlParameter("@TitleOfCourtesy", NullToDBNullValue(arg.TitleOfCourtesy, true)));
                cmd.Parameters.Add(new SqlParameter("@BirthDate", NullToDBNullValue(arg.BirthDate, true)));
                cmd.Parameters.Add(new SqlParameter("@HireDate", NullToDBNullValue(arg.HireDate, true)));
                cmd.Parameters.Add(new SqlParameter("@Address", NullToDBNullValue(arg.Address, true)));
                cmd.Parameters.Add(new SqlParameter("@City", NullToDBNullValue(arg.City, true)));
                cmd.Parameters.Add(new SqlParameter("@Country", NullToDBNullValue(arg.Country, true)));
                cmd.Parameters.Add(new SqlParameter("@Phone", NullToDBNullValue(arg.Phone, true)));
                cmd.Parameters.Add(new SqlParameter("@ManagerID", NullToDBNullValue(arg.ManagerID, true)));
                cmd.Parameters.Add(new SqlParameter("@Gender", NullToDBNullValue(arg.Gender, true)));
                cmd.Parameters.Add(new SqlParameter("@MonthlyPayment", NullToDBNullValue(arg.MonthlyPayment, true)));
                cmd.Parameters.Add(new SqlParameter("@YearlyPayment", NullToDBNullValue(arg.YearlyPayment, true)));
                cmd.Parameters.Add(new SqlParameter("@EmployeeID", arg.EmployeeID));
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
コード例 #2
0
        /// <summary>
        /// 取得emp by 表單上的data
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        public DataTable GetSearchResultByArg(EmployeeSearchArg arg)
        {
            DataTable dt  = new DataTable();
            string    sql = @"SELECT hs.EmployeeID, hs.FirstName + hs.LastName AS EmployeeName, 
                                  ct1.CodeId + '-' + ct1.CodeVal AS Type, convert(varchar, hs.HireDate, 111) HireDate,
                                  ct2.CodeVal AS Gender, Year(GETDATE())-Year(BirthDate) Age
                            FROM HR.Employees hs JOIN CodeTable ct1
	                            ON (ct1.CodeId = hs.Title AND ct1.CodeType = 'TITLE')
								LEFT JOIN CodeTable ct2
								ON (ct2.CodeId = hs.Gender AND ct2.CodeType = 'GENDER') 
                            WHERE (@employeeID IS NULL OR @employeeID = EmployeeID) AND
	                              (@employeeName IS NULL OR FirstName LIKE '%' + @employeeName + '%' OR hs.LastName LIKE '%' + @employeeName + '%') AND
	                              (@codeVal IS NULL OR @codeVal = hs.Title) AND
	                              (@startHireDate IS NULL OR @endHireDate IS NULL OR HireDate BETWEEN @startHireDate AND @endHireDate)  ;"    ;

            using (SqlConnection conn = new SqlConnection(ConfigTool.GetDBConnectionString()))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add(new SqlParameter("@employeeID", NullToDBNullValue(arg.EmployeeId, true)));
                cmd.Parameters.Add(new SqlParameter("@employeeName", NullToDBNullValue(arg.EmployeeName, true)));
                cmd.Parameters.Add(new SqlParameter("@codeVal", NullToDBNullValue(arg.Title, true)));
                cmd.Parameters.Add(new SqlParameter("@startHireDate", NullToDBNullValue(arg.StartHireDate, true)));
                cmd.Parameters.Add(new SqlParameter("@endHireDate", NullToDBNullValue(arg.EndHireDate, true)));
                /*如果用string的方式,可以改成下面這兩行*/
                //cmd.Parameters.Add(new SqlParameter("@startHireDate", arg.StartHireDate.ToString() == null ? string.Empty : arg.StartHireDate.ToString()));
                //cmd.Parameters.Add(new SqlParameter("@endHireDate", arg.EndHireDate.ToString() == null ? string.Empty : arg.EndHireDate.ToString()));
                SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd);
                sqlAdapter.Fill(dt);
                conn.Close();
            }
            return(dt);
        }
コード例 #3
0
        /// <summary>
        /// 지정된 DB Name의 Provider에 따라, IAdoRepository 인스턴스 생성 함수를 다르게 합니다.
        /// SQL Server인 경우, 자동으로 <see cref="SqlRepositoryImpl"/>을 사용하게 하여, 확장을 보장받을 수 있게 하였습니다.
        /// </summary>
        /// <param name="dbName"></param>
        /// <returns></returns>
        internal static Func <string, IAdoRepository> GetAdoRepositoryFactoryFunction(string dbName)
        {
            if (dbName.IsNotWhiteSpace())
            {
                var settings = ConfigTool.GetConnectionSettings(dbName);

                var isSqlClient = settings != null && settings.ProviderName.Contains("SqlClient");

                if (isSqlClient)
                {
                    if (IsDebugEnabled)
                    {
                        log.Debug("Database가 SQL Server이므로, SqlRepositoryImpl을 생성하는 Factory 함수를 반환합니다. dbName=[{0}]", dbName);
                    }

                    return(name => new SqlRepositoryImpl(name));
                }
            }

            if (IsDebugEnabled)
            {
                log.Debug("Database가 SQL Server가 아니므로, 기본 Repository인 AdoRepositoryImpl를 생성하는 Factory 함수를 반환합니다. dbName=[{0}]", dbName);
            }

            return(name => new AdoRepositoryImpl(name));
        }
コード例 #4
0
        private void FrmBinaryClock_Load(object sender, EventArgs e)
        {
            this.SuspendLayout();
            if (!ConfigTool.ConfigExits(Global.ConfigFile))
            {
                ChangeSize();
                ChangeColor(Global.DefaultColor, Global.DefaultShadow);

                this.Opacity = 0.45;
                int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width - 50;
                int y = Screen.PrimaryScreen.WorkingArea.Top + 50;
                this.Location = new Point(x, y);
            }
            else
            {
                GetConfiguration();
                ChangeSize();
                ChangeColor(Global.ClockColor, Global.ShadowColor);
            }

            timer.Start();

            notifyIcon.ContextMenuStrip.Opening += ContextMenuStrip_Opening;
            notifyIcon.ContextMenuStrip.Closing += ContextMenuStrip_Closing;
            AddItemClickEvent(notifyIcon.ContextMenuStrip.Items);

            //DrawIcon();
            this.ResumeLayout();
        }
コード例 #5
0
        private string GetRandHostUrl()
        {
            Random ran     = new Random();
            int    RandKey = ran.Next(4, 9);
            string randUrl = "";

            try
            {
                string   hosturl  = ConfigTool.ReadVerifyConfig("Host", "Other");
                string[] sArray   = hosturl.Split(',');
                Random   ran1     = new Random();
                int      RandKey1 = ran.Next(0, sArray.Length);//随机选中域名


                randUrl = GenerateRandomNumber(RandKey);

                if (string.IsNullOrEmpty(sArray[RandKey1]))
                {
                    randUrl = randUrl + "." + ConfigTool.ReadVerifyConfig("exp", "Other");
                }
                else
                {
                    randUrl = randUrl + "." + sArray[RandKey1] + "";
                }
            }
            catch (Exception ex)
            {
                randUrl = "abc." + ConfigTool.ReadVerifyConfig("exp", "Other");
                //randUrl = ex.Message.ToString();
                return(randUrl);
            }
            return(randUrl);
        }
コード例 #6
0
 /// <summary>
 /// 환경설정에 정의된 모든 Database Connection 에 해당하는 ConnectionPool을 제거합니다.
 /// </summary>
 public static void ClearAllConnectionPoolsFromConfiguration()
 {
     foreach (var connSettings in ConfigTool.GetConnectionStringSettings())
     {
         ClearConnectionPoolInternal(connSettings.ProviderName);
     }
 }
コード例 #7
0
ファイル: qzoneH5.ashx.cs プロジェクト: yangmain/WeChatTools
        private void getImg(HttpContext context)
        {
            HttpHelper helper = new HttpHelper();

            string hosturl = ConfigTool.ReadVerifyConfig("qqzoneImg", "Other");//这些域名都需要指向用户最终要访问的站点

            string[] sArray   = hosturl.Split(',');
            Random   ran      = new Random();
            int      RandKey1 = ran.Next(0, sArray.Length);//随机选中action
            string   imgName  = sArray[RandKey1];

            string url = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + "/wechat/" + imgName;

            HttpItem item = new HttpItem()
            {
                URL     = url,
                Referer = "",                                                                                                                                  //必填参数,这里置空

                UserAgent  = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176 MicroMessenger/4.3.2", //useragent可有可无
                ResultType = ResultType.Byte
            };

            HttpResult res = helper.GetHtml(item);

            string code = "data:image/webp;base64," + Convert.ToBase64String(res.ResultByte);

            context.Response.ContentType = "image/webp";
            context.Response.OutputStream.Write(res.ResultByte, 0, res.ResultByte.Length);
        }
コード例 #8
0
        public static void LoadConfig()
        {
            PointList = new Dictionary <string, Dictionary <string, RobotPoint> >();
            //Dictionary<string, object> keyValues = new Dictionary<string, object>();
            //string Sql = @"SELECT t.node_name AS NodeName,t.position AS POSITION,t.position_type AS PositionType,t.point as Point, t.mapping_point as MappingPoint, t.pre_mapping_point as PreMappingPoint, t.`offset` as Offset
            //                FROM config_point t
            //                WHERE t.equipment_model_id = @equipment_model_id";
            //keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
            //DataTable dt = dBUtil.GetDataTable(Sql, keyValues);
            //string str_json = JsonConvert.SerializeObject(dt, Formatting.Indented);
            //List<RobotPoint> Points = JsonConvert.DeserializeObject<List<RobotPoint>>(str_json);
            List <RobotPoint> RobotPointList = new ConfigTool <List <RobotPoint> >().ReadFile("config/Point.json");

            foreach (RobotPoint each in RobotPointList)
            {
                Dictionary <string, RobotPoint> tmp;
                if (PointList.TryGetValue(each.NodeName, out tmp))
                {
                    if (tmp.ContainsKey(each.Position))
                    {
                        tmp.Remove(each.Position);
                    }
                    tmp.Add(each.Position, each);
                }
                else
                {
                    tmp = new Dictionary <string, RobotPoint>();
                    tmp.Add(each.Position, each);
                    PointList.Add(each.NodeName, tmp);
                }
            }
        }
コード例 #9
0
        private string gotoRedirectUrl = ConfigTool.ReadVerifyConfig("DefaultUrl", "JumpDomain");//最终用户访问的网址

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string getJump = QueryString("key");   //参数1:授权key
            string getUrl  = QueryString("qqmap"); //参数1:用户传当前推广的网址,url需要编码

            if (string.IsNullOrEmpty(getJump) || string.IsNullOrEmpty(getUrl))
            {
                context.Response.Redirect(gotoRedirectUrl);
            }
            else
            {
                getJump = getJump + "!" + getUrl;

                string domainLeft = "http://";

                string isHttps = ConfigTool.ReadVerifyConfig("IsSSL", "JumpDomain");//这些域名都需要指向用户最终要访问的站点

                if (isHttps.ToLower() == "true")
                {
                    domainLeft = "https://";
                }

                string domainCenter = GetRandHostUrl();
                gotoRedirectUrl = domainLeft + domainCenter + "/home/GoToNovel";
                // string xxx =PostHtml(gotoRedirectUrl, getJump);

                string html = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "dev/sply.html");
                html = html.Replace("$newsView", gotoRedirectUrl).Replace("$newsValue", getJump);
                //  LogTools.WriteLine(getJump);

                context.Response.Write(html);
            }
            context.Response.End();
        }
コード例 #10
0
        private string gotoRedirectUrl = ConfigTool.ReadVerifyConfig("DefaultUrl", "WapToWeiXin");//最终用户访问的网址

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string getJump = QueryString("jump");//参数1:用户传当前推广的网址

            if (string.IsNullOrEmpty(getJump))
            {
                context.Response.Redirect(gotoRedirectUrl);
            }
            else
            {
                Random ran     = new Random();
                int    RandKey = ran.Next(00, 99);
                getJump = getJump + "!" + RandKey;

                string domainLeft = "https://";
                string isHttps    = ConfigTool.ReadVerifyConfig("IsSSL", "WapToWeiXin");
                if (isHttps.ToLower() == "false")
                {
                    domainLeft = "http://";
                }

                string domainCenter = GetRandHostUrl();
                gotoRedirectUrl = domainLeft + domainCenter + "/home/GoToWX";


                string html = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "dev/sply.html");
                html = html.Replace("$actionUrl", gotoRedirectUrl).Replace("$jumpValue", getJump);


                context.Response.Write(html);
            }
            context.Response.End();
        }
コード例 #11
0
        /// <summary>
        /// Retorna una ENTIDAD de registro de la Entidad Maestros.Configuracion
        /// En la BASE de DATO la Tabla : [Maestros.Configuracion]
        /// <summary>
        /// <returns>Entidad</returns>
        public static string AppConfig(int codEmpresa, ConfigTool pcodKeyConfig)
        {
            ConfigValor configuracion = new ConfigValor();

            try
            {
                string conexion = GlobalSettings.GetBDCadenaConexion("cnxCROMSystema");
                using (DBML_ConfigDataContext SQLDC = new DBML_ConfigDataContext(conexion))
                {
                    var resul = SQLDC.omgc_S_Configuracion(codEmpresa, null, pcodKeyConfig.ToString(), null, null);
                    foreach (var item in resul)
                    {
                        configuracion = new ConfigValor()
                        {
                            desValor = item.desValor,
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                configuracion.desValor = string.IsNullOrEmpty(configuracion.desValor) ? string.Empty : configuracion.desValor;
            }
            return(configuracion.desValor);
        }
コード例 #12
0
        public void Init()
        {
            ConfigTool.GetConfigSettings(cfg);
            client = new DiscordClient(c =>
            {
                c.AppName    = "sharkbot";
                c.AppVersion = "1.0.0.0";
                c.LogHandler = log;
                c.LogLevel   = LogSeverity.Debug;
            });

            client.UsingCommands(c =>
            {
                c.PrefixChar         = cfg.CommandPrefix;
                c.AllowMentionPrefix = true;
            });

            client.MessageReceived += (s, e) =>
            {
                Logger.LogInfo(e.Message.Text, e.Channel.Name);
            };

            cmdService = client.GetService <CommandService>();
            registerCommands();

            Task.Factory.StartNew(() =>
            {
                client.ExecuteAndWait(async() =>
                {
                    await client.Connect(cfg.Token, TokenType.Bot);
                });
            }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
        }
コード例 #13
0
        /// <summary>
        /// 지정된 Database의 Connection Pool을 모두 제거합니다.
        /// </summary>
        /// <param name="databaseName"></param>
        public static void ClearAllConnectionPools(string databaseName)
        {
            var connSettings = ConfigTool.GetConnectionSettings(databaseName ?? DefaultDatabaseName);

            connSettings.ShouldNotBeNull("connSettings");

            ClearConnectionPoolInternal(connSettings.ProviderName);
        }
コード例 #14
0
 private void UpdateAppConfig()
 {
     ConfigTool.Set("ip", tbIP.Text);
     ConfigTool.Set("port", tbPort.Text);
     ConfigTool.Set("interval", tbInterval.Text);
     ConfigTool.Set("connect", tbConCount.Text);
     ConfigTool.Set("senddata", tbData.Text);
 }
コード例 #15
0
 private void InstallAppConfig()
 {
     tbIP.Text       = ConfigTool.Get("ip");
     tbPort.Text     = ConfigTool.Get("port");
     tbInterval.Text = ConfigTool.Get("interval");
     tbConCount.Text = ConfigTool.Get("connect");
     tbData.Text     = ConfigTool.Get("senddata");
 }
コード例 #16
0
        private string gotoRedirectUrl = "/404.html";                                                 //最终用户访问的网址

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string jump    = QueryString("jump"); //参数1:用户传当前推广的网址
            string getJump = jump;                //参数1:用户传当前推广的网址

            if (string.IsNullOrEmpty(getJump))
            {
                context.Response.Redirect(gotoRedirectUrl);
            }
            else
            {
                Random ran     = new Random();
                int    RandKey = ran.Next(00, 99);
                getJump = getJump + "!" + RandKey;

                string   hosturl    = ConfigTool.ReadVerifyConfig("ActionName", "WeChatAnti"); //这些域名都需要指向用户最终要访问的站点
                string[] sArray     = hosturl.Split(',');
                int      RandKey1   = ran.Next(0, sArray.Length);                              //随机选中action
                string   actionName = sArray[RandKey1];
                string   domainLeft = "http://";

                string isHttps = ConfigTool.ReadVerifyConfig("IsSSL", "WeChatAnti");//这些域名都需要指向用户最终要访问的站点

                if (isHttps.ToLower() == "true")
                {
                    string agent = context.Request.UserAgent;
                    if (!agent.Contains("Macintosh") && !agent.Contains("iPhone") && !agent.Contains("iPod") && !agent.Contains("iPad") && !agent.Contains("Windows Phone") && !agent.Contains("Windows NT"))
                    {
                        domainLeft = "https://";
                    }
                }

                string domainCenter = GetRandHostUrl();
                if (string.IsNullOrEmpty(domainCenter))
                {
                    context.Response.Redirect(gotoRedirectUrl);
                }
                else
                {
                    gotoRedirectUrl = domainLeft + domainCenter + "/" + actionName;
                    // string xxx =PostHtml(gotoRedirectUrl, getJump);

                    string html = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "dev/sply.html");
                    html = html.Replace("$newsView", gotoRedirectUrl).Replace("$newsValue", getJump);

                    bool check = RedisCacheTools.Exists(jump + "IsTitle");
                    if (check)
                    {
                        html = html.Replace("太阳湾软件", "");
                    }


                    context.Response.Write(html);
                }
            }
            context.Response.End();
        }
コード例 #17
0
        private string GetRandHostUrl()
        {
            Random ran = new Random();

            string randUrl = "";

            bool isBlacklist = true;

            // int xx = 0;//没有做剔除操作,暂时限制循环次数。
            while (isBlacklist)
            {
                try
                {
                    string   hosturl = ConfigTool.ReadVerifyConfig("HostHttp", "HostUrl");//这些域名都需要指向用户最终要访问的站点
                    string[] sArray  = hosturl.Split(',');

                    int RandKey1 = ran.Next(0, sArray.Length);//随机选中域名
                    randUrl = sArray[RandKey1];


                    wxCheckApi    = ConfigTool.ReadVerifyConfig("wxCheckApi", "WeiXin");;
                    wxCheckApiKey = ConfigTool.ReadVerifyConfig("wxCheckApiKey", "WeiXin");

                    WebRequest wr     = (HttpWebRequest)WebRequest.Create(wxCheckApi + "?key=" + wxCheckApiKey + "&url=http://" + randUrl);
                    var        stream = wr.GetResponse().GetResponseStream();
                    var        sr     = new StreamReader(stream, Encoding.GetEncoding("UTF-8"));
                    var        all    = sr.ReadToEnd();
                    sr.Close();
                    stream.Close();
                    //读取网站的数据
                    if (all.Contains("屏蔽"))
                    {
                        //剔除域名
                        if (hosturl.Contains(sArray[RandKey1] + ","))
                        {
                            hosturl = hosturl.Replace(sArray[RandKey1] + ",", "");
                        }
                        if (hosturl.Contains("," + sArray[RandKey1]))
                        {
                            hosturl = hosturl.Replace("," + sArray[RandKey1], "");
                        }
                        ConfigTool.WriteVerifyConfig("Host", hosturl, "HostUrl");//剔除黑名单域名
                    }
                    else
                    {
                        isBlacklist = false;
                        return(randUrl);
                    }
                }
                catch (Exception ex)
                {
                    randUrl = "";
                    //randUrl = ex.Message.ToString();
                    return(randUrl);
                }
            }
            return(randUrl);
        }
コード例 #18
0
        protected void LocaleKey_Changed(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo(localeKeys.SelectedValue);

            var cookieName = ConfigTool.GetAppSettings("Localization.UserLocale.CookieName", "_LOCALE_KEY_");

            CookieTool.Set(cookieName, localeKeys.SelectedValue);

            Response.Redirect(Request.RawUrl);
        }
コード例 #19
0
        public void ProcessRequest(HttpContext context)
        {
            //正式用
            userIP = GetWebClientIp(context);
            context.Response.ContentType = "text/plain";
            string result = string.Empty;

            if (!string.IsNullOrEmpty(context.Request["url"]) && !string.IsNullOrEmpty(context.Request["key"]) && context.Request["key"].Length == 32)
            {
                string userKey = context.Request["key"]; //key ,md5值
                wxCheckApiKey = ConfigTool.ReadVerifyConfig("wxCheckApiKey", "WeiXin");
                if (userKey.Trim() == wxCheckApiKey)
                {
                    context.Response.Write("参数错误,进qq群交流:41977413!");
                }
                else
                {
                    //需要检测的网址
                    string urlCheck = context.Request["url"]; //检测的值
                    urlCheck = urlCheck.Replace("https://", "").Replace("http://", "");
                    string json2 = "{\"Mode\":\"AuthKey\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + userKey + "\'}\"}";

                    ServiceApiClient SpVoiceObj2 = new ServiceApiClient("NetTcpBinding_IServiceApi2");
                    SpVoiceObj2.Open();
                    result = SpVoiceObj2.Api(json2);
                    SpVoiceObj2.Close();
                    JsonObject.Results aup = JsonConvert.DeserializeObject <JsonObject.Results>(result);

                    if (aup.State == true)
                    {
                        string           json       = "{\"Mode\":\"WXCheckUrl\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + userKey + "\'}\"}";
                        ServiceApiClient SpVoiceObj = new ServiceApiClient("NetTcpBinding_IServiceApi");
                        SpVoiceObj.Open();
                        result = SpVoiceObj.Api(json);
                        SpVoiceObj.Close();
                    }

                    Logger.WriteLoggger(userIP + ":" + userKey + ":" + result);

                    if (!string.IsNullOrEmpty(context.Request.QueryString["callback"]))
                    {
                        string callBack = context.Request.QueryString["callback"].ToString(); //回调
                        result = callBack + "(" + result + ")";
                    }

                    context.Response.Write(result);
                }
            }
            else
            {
                context.Response.Write("参数错误,进qq群交流:41977413!");
            }

            context.Response.End();
        }
コード例 #20
0
        public static IAdoProvider CreateByName(string dbName)
        {
            if (IsDebugEnabled)
            {
                log.Debug("IAdoProvider 구현 인스턴스를 생성합니다. dbName=[{0}]", dbName);
            }

            var connSettings = ConfigTool.GetConnectionSettings(dbName);

            return(Create(connSettings.ConnectionString, connSettings.ProviderName));
        }
コード例 #21
0
        public static void Save()
        {
            List <Node> result = NodeList.Values.ToList();

            result.Sort((x, y) => { return(x.Name.CompareTo(y.Name)); });
            new ConfigTool <List <Node> >().WriteFile("config/Node.json", result);
            //簡潔化
            List <NodeConfig> cvt = new ConfigTool <List <NodeConfig> >().ReadFile("config/Node.json");

            new ConfigTool <List <NodeConfig> >().WriteFile("config/Node.json", cvt);
        }
コード例 #22
0
        public override void Application_Start(object sender, EventArgs e)
        {
            base.Application_Start(sender, e);

            using (var conn = new OracleConnection(ConfigTool.GetConnectionString("LOCAL_XE"))) {
                log.Info("LOCAL_XE에 대한 OracleConnection을 빌드하고, 연결합니다...");

                conn.Open();
                conn.Ping();
            }
        }
コード例 #23
0
        private string GetRandHostUrl()
        {
            string randUrl = "";

            //  bool isBlacklist = true;
            //  while (isBlacklist)
            //  {
            try
            {
                string   hosturl  = ConfigTool.ReadVerifyConfig("Domain", "WeChatAnti"); //这些域名都需要指向用户最终要访问的站点
                string[] sArray   = hosturl.Split(',');
                Random   ran      = new Random();
                int      RandKey1 = ran.Next(0, sArray.Length);//随机选中域名
                randUrl = sArray[RandKey1];

                WebRequest wr     = (HttpWebRequest)WebRequest.Create(wxCheckApi + "?key=" + wxCheckApiKey + "&url=http://" + randUrl);
                var        stream = wr.GetResponse().GetResponseStream();
                var        sr     = new StreamReader(stream, Encoding.GetEncoding("UTF-8"));
                var        all    = sr.ReadToEnd();
                sr.Close();
                stream.Close();

                //读取网站的数据
                if (all.Contains("屏蔽"))
                {
                    /*
                     * //剔除域名
                     * if (hosturl.Contains(sArray[RandKey1] + ","))
                     * {
                     *  hosturl = hosturl.Replace(sArray[RandKey1] + ",", "");
                     * }
                     * if (hosturl.Contains("," + sArray[RandKey1]))
                     * {
                     *  hosturl = hosturl.Replace("," + sArray[RandKey1], "");
                     * }
                     * ConfigTool.WriteVerifyConfig("Domain", hosturl, "WeChatAnti");//剔除黑名单域名
                     */
                    randUrl = "";
                }
                else
                {
                    // isBlacklist = false;
                    return(randUrl);
                }
            }
            catch (Exception ex)
            {
                randUrl = "";
                return(randUrl);
            }
            // }

            return(randUrl);
        }
コード例 #24
0
ファイル: BaseModel.cs プロジェクト: zhizhen/thewar
    private static Dictionary <string, object> GetConfigVoDic <T>() where T : new()
    {
        var data = ConfigTool.GetInstance().AnalyseBinaryConfig <T> ();

        if (data == null)
        {
            throw new InvalidOperationException(string.Format("{0} not exist", typeof(T).Name));
        }
        else
        {
            return(data);
        }
    }
コード例 #25
0
        /// <summary>
        /// Parameter 정보를 파싱해서, 원하는 결과를 만듭니다.
        /// </summary>
        /// <param name="context"></param>
        private void ParseRequestParams(HttpContext context)
        {
            var request = context.Request;

            // var _encoding = context.Response.ContentEncoding;

            var setName  = request["S"].AsText();
            var fileName = request["F"].AsText();
            var version  = request["V"].AsText("1.0");

            _contentType   = request["T"].AsText(FileTool.DEFAULT_MIME_TYPE);
            _cacheDuration = TimeSpan.FromDays(request["Ex"].AsInt(30));

            // 유일한 캐시키가 만들어집니다^^
            _cacheKey = GetCacheKey(setName, fileName, version);

            if (IsDebugEnabled)
            {
                log.Debug("요청정보. S=[{0}], F=[{1}], C=[{2}], V=[{3}], _cacheKey=[{4}]", setName, fileName, _contentType, version,
                          _cacheKey);
            }


            // NOTE: Handler를 재사용하는 경우, 꼭 초기화를 시켜주어야 합니다.
            //
            _filenames.Clear();

            // 요청 파일 정보를 파싱해서 넣습니다.
            if (setName.IsNotWhiteSpace() && ConfigTool.HasAppSettings(setName))
            {
                var setFiles = ConfigTool.GetAppSettings(setName, string.Empty);
                if (setFiles.IsNotWhiteSpace())
                {
                    var filenames = setFiles.Split(new[] { FileDelimiter }, StringSplitOptions.RemoveEmptyEntries);
                    filenames.RunEach(n => _filenames.Add(n));
                }
            }

            if (fileName.IsNotWhiteSpace())
            {
                var filenames = fileName.Split(new[] { FileDelimiter }, StringSplitOptions.RemoveEmptyEntries);
                filenames.RunEach(n => _filenames.Add(n));
            }

            if (IsDebugEnabled)
            {
                log.Debug("요청파일=[{0}]", FileDelimiter.ToString().Join(_filenames.ToArray()));
            }
        }
コード例 #26
0
ファイル: Default.aspx.cs プロジェクト: 15831944/NFramework
        protected void Page_Load(object sender, EventArgs e)
        {
            int companyCount = 0;

            using (var conn = new OracleConnection(ConfigTool.GetConnectionString("LOCAL_XE")))
                using (var cmd = new OracleCommand("SELECT COUNT(*) FROM NH_COMPANY", conn)) {
                    conn.Open();
                    companyCount = cmd.ExecuteScalar().AsInt();
                }

            lblMessage.Text = "CompanyCount=" + companyCount;


            lblMessage2.Text = "CompanyCount=" + Repository <Company> .Count();
        }
コード例 #27
0
        /// <summary>
        /// 환경설정에 정의된 옵션에 따라 Chart 의 속성을 설정할 수 있다.
        /// 기본적으로는 Export Image에 대한 환경설정을 수행한다.
        /// </summary>
        /// <param name="chart"></param>
        protected virtual void SetChartAttributes(IChart chart)
        {
            // var exportEnabled = ConfigTool.GetAppSettings(HandlerSettings.ExportEnabledAppKey, true);
            var exportPath = ConfigTool.GetAppSettings(HandlerSettings.ExportPathAppKey, HandlerSettings.ExportHandler);

            if (IsDebugEnabled)
            {
                log.Debug("Settings export Image/PDF attributes, FusionCharts.Export.Path=[{0}]", exportPath);
            }

            // if (exportEnabled)
            //{
            chart.SetExportInServer(exportPath);
            //}
        }
コード例 #28
0
        public void ProcessRequest(HttpContext context)
        {
            //GET /index.php?g=Wap&m=Vote&a=index&token=uDSrEHNs9CFGcTSC&wecha_id=ocMqvwRjzPH9eseHRc_Z9nlP-DSM&id=25&iMicms=mp.weixin.qq.com HTTP/1.1
            context.Response.ContentType = "text/plain";
            pToken = QueryString("token");
            pWecha_id = QueryString("wecha_id");
            pId = QueryString("id");
            iMicms = QueryString("iMicms");

            stateUrl = ConfigTool.ReadVerifyConfig("state", "Other");

            if (stateUrl.Equals("true"))
            {
                string tokens = ConfigTool.ReadVerifyConfig("tokens", "Other");
                if (tokens.Contains(pToken))
                {
                    string pRedirectUrl = "http://" + GetRandHostUrl() + "/index.php?g=Wap&m=Vote&a=index&id=" + pId + "&token=" + pToken + "&wecha_id=" + pWecha_id + "&iMicms=" + iMicms;

                    string json = "{\"Mode\": \"WXCheckUrl\", \"Param\": \"{\'CheckUrl\':\'" + pRedirectUrl + "\'}\"}";
                    _service = new ServiceApi();
                    string resultCheck = _service.Api(json);

                    if (!resultCheck.Contains("屏蔽"))
                    {
                        //域名未被微信封号
                        hmdOpenid = ConfigTool.ReadVerifyConfig("hmdOpenid", "Other");
                        if (!hmdOpenid.Contains(pWecha_id))
                        {
                            //当前访问的用户不在黑名单
                            redirectUrl = pRedirectUrl;
                            Logger.WriteLoggger("openid:" + pWecha_id);  //后续可以扩展,可以屏蔽一些恶意投诉的微信号
                        }
                    }
                    else
                    {

                        //修改投票状态
                        ConfigTool.WriteVerifyConfig("state", "false", "Other");
                        Logger.WriteLoggger("恶意的openid:" + pWecha_id);  //后续可以扩展,可以屏蔽一些恶意投诉的微信号
                    }
                }

            }

            context.Response.Redirect(redirectUrl);
            // context.Response.Write(redirectUrl);
            context.Response.End();
        }
コード例 #29
0
        private string GetRandHostUrl()
        {
            Random ran = new Random();

            string randUrl = "";

            string hosturl = ConfigTool.ReadVerifyConfig("Domain", "JumpDomain");//这些域名都需要指向用户最终要访问的站点

            string[] sArray = hosturl.Split(',');

            int RandKey1 = ran.Next(0, sArray.Length);//随机选中域名

            randUrl = sArray[RandKey1];

            return(randUrl);
        }
コード例 #30
0
        /// <summary>
        /// 테스트할 DB 이름입니다.
        /// </summary>
        /// <returns></returns>
        protected virtual string GetDatabaseName()
        {
            var databaseEngineKind = GetDatabaseEngine();

            if (databaseEngineKind == DatabaseEngine.DevartOracle)
            {
                return(ConfigTool.GetConnectionString("LOCAL_XE"));
            }

            if (databaseEngineKind == DatabaseEngine.MySql)
            {
                return(ConfigTool.GetConnectionString("LOCAL_MySQL"));
            }

            return(@"NSoft_NFramework_DATA");
        }