bremen_short_url/App_Code/urlObj.cs

145 lines
4.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Runtime.Serialization.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Web.Services.Protocols;
using System.Security.Cryptography;
using System.Text;
using System.Web.SessionState;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.Serialization;
/// <summary>
/// urlObj 的摘要描述
/// </summary>
public class urlObj : urlBase
{
autoBindDataTable urlSQL;
DataRow urlRow;
[IgnoreDataMember] Boolean isNew = false;
[IgnoreDataMember] public string update_result = "";
public userdata url_createUser;
public urlObj() : base()
{
//
// TODO: 在這裡新增建構函式邏輯
//
string urlString = "select * from url where url_sn = -1";
urlSQL = new autoBindDataTable(urlString);
urlRow = urlSQL.newRow;
urlSQL.dataRows.Add(urlRow);
isNew = true;
try {
authPermission objAuth = new authPermission();
url_createUid = objAuth.user_uid;
url_createUser = new userdata(url_createUid);
} catch (Exception ex) { }
}
public urlObj(string _url_uid) : base(_url_uid)
{
urlSQL = urlBaseSQL;
urlRow = urlBaseRow;
}
public urlObj(DataRow _urlRow) : base(_urlRow)
{
urlRow = _urlRow;
}
public Boolean updateData()
{
Boolean result = false;
update_result = "更新失敗!";
authPermission objAuth = new authPermission();
if (objAuth.isLogin() == false)
{
update_result = "無權限!";
return result;
}
if (imageChange)
{
string filePath = string.Format("upload_pics/{0}.png", url_uid);
string path = System.Web.HttpContext.Current.Server.MapPath("~/");
//using (System.IO.MemoryStream oMS = new System.IO.MemoryStream())
//{
// //將oTarImg儲存指定到記憶體串流中
// _picImage.Save(oMS, System.Drawing.Imaging.ImageFormat.Png);
// //將串流整個讀到陣列中,寫入某個路徑中的某個檔案裡
// using (System.IO.FileStream oFS = System.IO.File.Open(path + filePath.Replace("/", "\\"), System.IO.FileMode.OpenOrCreate))
// { oFS.Write(oMS.ToArray(), 0, oMS.ToArray().Length); }
//}
_picImage.Save(path + filePath.Replace("/", "\\"), ImageFormat.Png);
url_fbImage = "/" + filePath;
if (url_photoId == "") {
url_photoId = globalClass.CreateRandomCode(24);
}
}
urlRow["url_uid"] = url_uid;
urlRow["project_uid"] = project_uid;
urlRow["url_descript"] = url_descript;
urlRow["url_directToUrl"] = url_directToUrl;
urlRow["url_Code"] = url_Code;
urlRow["url_gifTag"] = url_gifTag;
urlRow["url_gifLink"] = url_gifLink;
urlRow["url_fbTag"] = url_fbTag;
urlRow["url_fbTitle"] = url_fbTitle;
urlRow["url_fbDescript"] = url_fbDescript;
urlRow["url_fbImage"] = url_fbImage;
urlRow["url_fbPixel"] = url_fbPixel;
urlRow["url_fbPixelCode"] = url_fbPixelCode;
urlRow["url_googleAds"] = url_googleAds;
urlRow["url_googleAwConversionId"] = url_googleAwConversionId;
urlRow["url_uploadFile"] = url_uploadFile;
urlRow["url_uploadFileClientName"] = url_uploadFileClientName;
urlRow["url_uploadFileLinkName"] = url_uploadFileLinkName;
urlRow["url_uploadFileType"] = url_uploadFileType;
urlRow["url_playBtn"] = url_playBtn;
urlRow["url_datelimit"] = url_datelimit;
urlRow["url_endDate"] = url_endDate;
urlRow["url_isRevoke"] = url_isRevoke;
urlRow["url_createUid"] = url_createUid;
urlRow["url_version"] = url_version;
urlRow["url_photoId"] = url_photoId;
try
{
urlSQL.updateDataTable();
result = true;
}
catch (Exception ex)
{
result = false;
update_result = ex.Message;
}
return result;
}
}