CRM项目技术总结

 

一,换皮肤

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Suzsoft.CRM.Common.Entity;
using Suzsoft.CRM.BusinessFacade;

public partial class CRMMain : System.Web.UI.MasterPage
{
    #region Page Load
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Login_UserID"] != null)
        {
            lblUserName.Text = ((UsersEntity)Session["UserEntity"]).UserName;
        }
        if (!IsPostBack)
        {
            ddlThemes.SelectedValue = Profile.ThemePreference;
        }
    }
    #endregion

    #region BaseUrl
    /// <summary>
    /// 主页地址
    /// </summary>
    public string BaseUrl
    {
        get
        {
            string strUrl;
            if (null != ViewState["BASEURL_0"])
            {
                strUrl = ViewState["BASEURL_0"].ToString();
            }
            else
            {
                strUrl = new Suzsoft.CRM.Web.PageBase().BaseUrl;
                ViewState["BASEURL_0"] = strUrl;
            }
            return strUrl;
        }
    }
    #endregion

    #region 更改主题
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Profile.ThemePreference = ddlThemes.SelectedValue;
        Response.Redirect(Request.Path);
    }
    #endregion
}
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Web;
using System.Web.Profile;

 

public class ProfileCommon : System.Web.Profile.ProfileBase {
   
    public virtual string ThemePreference {
        get {
            return ((string)(this.GetPropertyValue("ThemePreference")));
        }
        set {
            this.SetPropertyValue("ThemePreference", value);
        }
    }
   
    public virtual ProfileCommon GetProfile(string username) {
        return ((ProfileCommon)(ProfileBase.Create(username)));
    }
}
二.webcofig配置

1.换皮肤

<system.web>
  <authentication mode="Forms" />
  <pages>
   <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   </controls>
  </pages>
  <profile>
   <properties>
    <add name="ThemePreference" type="string" defaultValue="Sugar Classic"/>
   </properties>
  </profile>

 <httpHandlers>
   <remove verb="*" path="*.asmx"/>
   <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
  </httpHandlers>
  <httpModules>
   <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </httpModules>
 </system.web>

2.配置数据库

方法一.<connectionStrings>
  <clear/>
  <add name="LocalSqlServer" connectionString="data source=DotNet_Serv_001/SQL2005; User ID=CRM; Password=CRM;;Initial Catalog=aspnetdb;" providerName="System.Data.SqlClient"/>
  <add name="CRMConnectionString" connectionString="Data Source=DOTNET_SERV_001/SQL2005;Initial Catalog=CRM;User ID=CRM;Password=CRM" providerName="System.Data.SqlClient"/>


 </connectionStrings>

 

方法2.<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <maxConnection>500</maxConnection>
 <databaseTypes>
  <databaseType name="SQLSERVER" type="Suzsoft.DotNet.DAL.SqlDBConnection" filePath="" assemblyName="SQLServerBroker"/>
    <databaseType name="ORACLE" type="Suzsoft.DotNet.DAL.OracleDBConnection" filePath="" assemblyName="OracleBroker"/>
 </databaseTypes>
 <instances defaultInstance="DBInstance1">
        <instance name="DBInstance1" type="SQLSERVER" connectionString="Sql Connection String" isFullString="false" isEncrypt="false"/>
        <instance name="DBInstance2" type="ORACLE" connectionString="Oracle Connection String" isFullString="false" isEncrypt="false"/>
    </instances>
    <connectionStrings>
      <connectionString name="Sql Connection String">
        <parameters>
          <parameter name="database" value="CRM" isSensitive="false" />
          <parameter name="server" value="DotNet_Serv_001/SQL2005" isSensitive="false"/>
          <parameter name="user" value="CRM"></parameter>
          <parameter name="pwd" value="CRM"></parameter>
        </parameters>
        <fullString></fullString>
      </connectionString>
      <connectionString name="Oracle Connection String">
        <parameters>
          <parameter name="Data Source" value="DTSERP" isSensitive="false" />
          <parameter name="User ID" value="autocode"></parameter>
          <parameter name="Password" value="autocode"></parameter>
        </parameters>
        <fullString></fullString>
      </connectionString>
    </connectionStrings>
</configuration>

三.设置GridView样式

  public void GridLineStyle(System.Web.UI.WebControls.GridView objGrid)
        {
            foreach (GridViewRow row in objGrid.Rows)
            {
                row.Attributes.Add("onMouseOver", "this.style.background='#DEEFFF'");
                if (row.RowIndex % 2 != 0)
                {
                    row.Attributes.Add("onMouseOut", "this.style.background='#F1F1F1'");
                }
                else
                {
                    row.Attributes.Add("onMouseOut", "this.style.background='#FDFDFD'");
                }
            }
        }
四.压缩文件

using System;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;

namespace WebZipUnzip
{
    /// &lt;summary&gt;
    /// 压缩文件
    /// &lt;/summary&gt;
    public class ZipClass
    {
        public void ZipFile(string FileToZip, string ZipedFile, int CompressionLevel, int BlockSize, string password)
          {
          //如果文件没有找到,则报错
          if (! System.IO.File.Exists(FileToZip))
          {
           throw new System.IO.FileNotFoundException("The specified file " + FileToZip + " could not be found. Zipping aborderd");
          }
         
          System.IO.FileStream StreamToZip = new System.IO.FileStream(FileToZip,System.IO.FileMode.Open , System.IO.FileAccess.Read);
          System.IO.FileStream ZipFile = System.IO.File.Create(ZipedFile);
          ZipOutputStream ZipStream = new ZipOutputStream(ZipFile);
          ZipEntry ZipEntry = new ZipEntry("ZippedFile");
          ZipStream.PutNextEntry(ZipEntry);
          ZipStream.SetLevel(CompressionLevel);
          byte[] buffer = new byte[BlockSize];
          System.Int32 size =StreamToZip.Read(buffer,0,buffer.Length);
          ZipStream.Write(buffer,0,size);
          try
          {
           while (size < StreamToZip.Length)
           {
            int sizeRead =StreamToZip.Read(buffer,0,buffer.Length);
            ZipStream.Write(buffer,0,sizeRead);
            size += sizeRead;
           }
          }
          catch(System.Exception ex)
          {
           throw ex;
          }
          ZipStream.Finish();
          ZipStream.Close();
          StreamToZip.Close();
        }

        public void ZipFileMain(string[] args)
        {
            //string[] filenames = Directory.GetFiles(args[0]);
            Crc32 crc = new Crc32();
            ZipOutputStream s = new ZipOutputStream(File.Create(args[1]));

            s.SetLevel(6); // 0 - store only to 9 - means best compression

            foreach (string file in Directory.GetFiles(args[0]))
            {
                //打开压缩文件
                FileStream fs = File.OpenRead(file);
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);
                ZipEntry entry = new ZipEntry(file);

                entry.DateTime = DateTime.Now;

                // set Size and the crc, because the information
                // about the size and crc should be stored in the header
                // if it is not set it is automatically written in the footer.
                // (in this case size == crc == -1 in the header)
                // Some ZIP programs have problems with zip files that don&#39;t store
                // the size and crc in the header.
                entry.Size = fs.Length;
                fs.Close();

                crc.Reset();
                crc.Update(buffer);

                entry.Crc = crc.Value;

                s.PutNextEntry(entry);

                s.Write(buffer, 0, buffer.Length);

            }
            s.Finish();
            s.Close();
        }
    }
}
五,解压文件

using System;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;

namespace WebZipUnzip
{
    public class UnZipClass
    {
        /// &lt;summary&gt;
        /// 解压文件
        /// &lt;/summary&gt;
        /// &lt;param name="args"&gt;包含要解压的文件名和要解压到的目录名数组&lt;/param&gt;
        public void UnZip(string[] args)
        {
          ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
          try
          {   
           ZipEntry theEntry;
           while ((theEntry = s.GetNextEntry()) != null)
           {  
            string directoryName = Path.GetDirectoryName(args[1]);
            string fileName      = Path.GetFileName(theEntry.Name);
         
            //生成解压目录
            Directory.CreateDirectory(directoryName);
         
            if (fileName != String.Empty)
            {  
             //解压文件到指定的目录
             FileStream streamWriter = File.Create(args[1]+fileName);
          
             int size = 2048;
             byte[] data = new byte[2048];
             while (true)
             {
              size = s.Read(data, 0, data.Length);
              if (size > 0)
              {
               streamWriter.Write(data, 0, size);
              }
              else
              {
               break;
              }
             }
          
             streamWriter.Close();
            }
           }
           s.Close();
          }
          catch(Exception eu)
          {
           throw eu;
          }
          finally
          {
           s.Close();
          }

          }//end UnZip

        public static bool UnZipFile(string file, string dir)
        {
              try
              {
               if (!Directory.Exists(dir))
                Directory.CreateDirectory(dir);
               string fileFullName = Path.Combine(dir,file);
               ZipInputStream s = new ZipInputStream(File.OpenRead( fileFullName ));

               ZipEntry theEntry;
               while ((theEntry = s.GetNextEntry()) != null)
               {
                string directoryName = Path.GetDirectoryName(theEntry.Name);
                string fileName = Path.GetFileName(theEntry.Name);

                if (directoryName != String.Empty)
                 Directory.CreateDirectory( Path.Combine(dir, directoryName));

                if (fileName != String.Empty)
                {
                 FileStream streamWriter = File.Create( Path.Combine(dir,theEntry.Name) );
                 int size = 2048;
                 byte[] data = new byte[2048];
                 while (true)
                 {
                  size = s.Read(data, 0, data.Length);
                  if (size > 0)
                  {
                   streamWriter.Write(data, 0, size);
                  }
                  else
                  {
                   break;
                  }
                 }

                 streamWriter.Close();
                }
               }
               s.Close();
               return true;
              }
              catch (Exception)
              {
               throw;
              }
              }

    }//end UnZipClass
}
应用:


using System;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;

namespace WebZipUnzip
{
    public class AttachmentUnZip
    {
        public AttachmentUnZip()
        {
        }
        public static void UpZip(string zipFile)
        {
            string[] FileProperties = new string[2];
            FileProperties[0] = zipFile;//待解压的文件
            FileProperties[1] = zipFile.Substring(0, zipFile.LastIndexOf("//") + 1);//解压后放置的目标目录
            UnZipClass UnZc = new UnZipClass();
            UnZc.UnZip(FileProperties);
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值