真爱无限的知识驿站

学习积累技术经验,提升自身能力

asp.net调用飞信免费发短信

之前用过一段时间,已经证实不能再用!

        #region 免费发送飞们接口(2014-01-06 16:20测试有效)
        /// <summary>
        /// 免费发送飞们接口(要开通飞信把对方加为好友才能发,也可以给自己发做测试)
        /// </summary>
        /// <param name="sendNumber">登陆飞信手机号</param>
        /// <param name="sendPassword">登陆密码</param>
        /// <param name="receiveNumber">接收手机</param>
        /// <param name="Content">短信内容</param>
        /// <returns></returns>
        public bool sendfetion(string sendNumber, string sendPassword, string receiveNumber, string Content)
        {
            string url = string.Format("https://quanapi.sinaapp.com/fetion.php?u={0}&p={1}&to={2}&m={3}", sendNumber, sendPassword, receiveNumber, HttpUtility.UrlEncode(Content));
            string strRet = "";
            try
            {
                HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(url);
                hr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
                hr.Method = "GET";
                hr.Timeout = 30 * 60 * 1000;
                WebResponse hs = hr.GetResponse();
                Stream sr = hs.GetResponseStream();
                StreamReader ser = new StreamReader(sr, Encoding.Default);
                strRet = ser.ReadToEnd();
            }
            catch (Exception er)
            {
                strRet = "";
            }
            if (!strRet.Contains(":0")) return false;//成功时返回数据:{"result":0,"message":"u53d1u9001u6210u529f"}
            return true;
        } 
        #endregion


asp.net两种方式的短信接口使用(提供接口的都是收费的)

一种是http请求的方式,另一种就是提供WebService接口供调用的。


asp.net中缓存类DataCache(依赖文件缓存和时间缓存,或两者)


更新:2013-12-29

linux下c通过虚拟地址映射读写文件

code:

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<string.h>
#include<sys/mman.h>
struct stu
{
char name[20];
int age;
float score;
};
//1 打开文件,2 映射到虚拟地址,3 写入数据,4 卸载虚拟地址,5关闭文件
main()
{
int fd;
struct stu *s;
struct stat st;
int size;
int count;
struct stu record;
memset(&record,0,sizeof(struct stu));
fd=open("newstu.dat",O_RDWR|O_CREAT|O_EXCL,0666);
if(fd==-1)
{
fd=open("newstu.dat",O_RDWR);
if(fd==-1) printf("::%m
"),exit(-1);
}
fstat(fd,&st);
size=st.st_size;//原大小 
count=size/sizeof(struct stu);
ftruncate(fd,size+sizeof(struct stu));;//改变文件大小,在munmap前调用就行,+ 就是增大,-就是减小
s=mmap(0,size+sizeof(struct stu),
PROT_READ|PROT_WRITE,
MAP_SHARED,fd,0);
//*
printf("输入姓名:");
scanf("%s",s[count].name);
printf("输入年龄:");
scanf("%s",&(s[count].age)); 
printf("输入分数:");
scanf("%f",&(s[count].score));
//*/
int i;
for(i=0;i<count-1;i++)
{
printf("%s,%d,%.2f
",s[i].name,s[i].age,s[i].score);
}
munmap(s,size+sizeof(struct stu));
close(fd);
}


网站权限问题要重视-维护服务器后的看法

今天维护了一台某公司的网站服务器,就是访问文件突然不存在了,花了些时间看了一下,原因如下:

Global.asax 被改,变成了系统文件,还隐藏了。。

SQLiteHelper类,操作SQLite数据库

操作类:

using System;
using System.Data;
using System.Text.RegularExpressions;
using System.Xml;
using System.IO;
using System.Collections;
using System.Data.SQLite;
using System.Configuration;//添加.net引用
namespace Tools.Common
{
    /// <summary>
    /// 对SQLite操作的类
    /// 引用:System.Data.SQLite.dll【版本:3.6.23.1(原始文件名:SQlite3.DLL)】
    /// </summary>
    public class SQLiteHelper
    {
        /// <summary>
        /// 所有成员函数都是静态的,构造函数定义为私有
        /// </summary>
        private SQLiteHelper()
        {
        }
        /// <summary>
        /// 连接字符串
        /// </summary>
        public static string ConnectionString
        {//"Data Source=Test.db3;Pooling=true;FailIfMissing=false";
            get
            {
                ////(AppSettings节点下的"SQLiteConnectionString")
                string text = ConfigurationManager.AppSettings["SQLiteConnectionString"];
                string str2 = ConfigurationManager.AppSettings["IsEncrypt"];
                if (str2 == "true")
                {
                    text = DesEncrypt.Decrypt(text);
                }
                return text;
            }
        }
        private static SQLiteConnection _Conn = null;


c#利用反射,实现将model类变成字符串、再还原成mode对象的功能

处理类:

public string ToString(UserGiftCardModel model)
        {
            if (model == null) return "";
            string sb = "";
            Type type =model.GetType() ;//assembly.GetType("Reflect_test.PurchaseOrderHeadManageModel", true, true); //命名空间名称 + 类名  
            //创建类的实例  
            //object obj = Activator.CreateInstance(type, true);
            //获取公共属性  
            PropertyInfo[] Propertys = type.GetProperties();


C#批量去掉文件前缀,最近用动软代码生成器,文件名在代码里改不了。

code:

 

         static void Main(string[] args)
        {
            Console.WriteLine("本程序去掉当前目录及子目录下的文件前缀");
            Console.Write("请输入要去掉的前缀:");
            string stringFront = Console.ReadLine();
            if (stringFront != "")
            {
                string dir = AppDomain.CurrentDomain.BaseDirectory;
                RenameFile(dir, stringFront);
            }
            else Console.WriteLine("请输入要去掉的前缀!");
            Console.WriteLine("操作已完成");
            Console.ReadKey();
        }
        public static void RenameFile(string ParentDir,string stringFront)
        {
            string[] files = Directory.GetFiles(ParentDir, "*.cs", SearchOption.TopDirectoryOnly);
            foreach (string file in files)
            {
                string filename = Path.GetFileName(file);
                string pathname = Path.GetDirectoryName(file);
                if (filename.StartsWith(stringFront, true, null))
                {
                    filename = filename.Substring(stringFront.Length);
                    FileInfo fi = new FileInfo(file);
                    fi.MoveTo(Path.Combine(pathname,filename));
                }
            }
            string[] dirs = Directory.GetDirectories(ParentDir);
            foreach(string dir in dirs)
            {
                RenameFile(dir,stringFront);
            }
        }


留言本

欢迎给我留言,您也可以通过邮箱pukuimin@qq.com联系

留言时,请留下称呼或姓名

js行背景变色、显示提示层的代码

JS代码:

function showHelp(id) {  

    var obj = document.getElementById(id);  

    obj.style.display = "";  

<< < 14 15 16 17 18 19 20 21 22 23 > >>

Powered By Z-BlogPHP 1.7.3

Copyright 2024-2027 pukuimin Rights Reserved.
粤ICP备17100155号