25
2013
01

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

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


25
2013
01

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


更新:2013-12-29

24
2013
01

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\n"),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\n",s[i].name,s[i].age,s[i].score);
}
munmap(s,size+sizeof(struct stu));
close(fd);
}


24
2013
01

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

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

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

18
2013
01

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;


17
2013
01

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();


15
2013
01

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);
            }
        }


27
2012
12

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

JS代码:

function showHelp(id) {  

    var obj = document.getElementById(id);  

    obj.style.display = "";  

26
2012
12

网页中js弹出模式窗口并传值的问题

js代码:

    <script type="text/javascript">  

        //父窗体中打开模式窗口  

        function SelectClient(ctlName) {  

27
2012
10

linux下练习 gcc 静态库/动态库 编译示例

//iotool.c

#include <stdio.h>
int inputInt(const char *info)
{
int r;
printf("%s:",info);
scanf("%d",&r);
return r;
}


graphic.c