增加紙張尺寸設定

This commit is contained in:
2026-03-10 17:59:57 +08:00
parent bfd07ebe90
commit b66976b7c4
4 changed files with 411 additions and 129 deletions

View File

@@ -12,7 +12,7 @@ using System.Web.Http;
/// <summary>
/// designerController 的摘要描述
/// </summary>
public class designerController:ApiController
public class designerController : ApiController
{
public designerController()
{
@@ -67,8 +67,8 @@ public class designerController:ApiController
{
LogUtility log = new LogUtility();
object[] obj=new StyleDataAccess().GetStyle("","");
if (obj[0].ToString()=="Y")
object[] obj = new StyleDataAccess().GetStyle("", "");
if (obj[0].ToString() == "Y")
{
return Ok(new { result = "Y", data = obj[2] });
}
@@ -84,13 +84,13 @@ public class designerController:ApiController
[Route("api/tablet/SavDegignerData")]
public IHttpActionResult SavDegignerData([FromBody] dynamic data)
{
LogUtility log=new LogUtility();
LogUtility log = new LogUtility();
var json = data;
//json.detail.Children<JObject>()
log.writeLogPath((string)json.styleName);
TabletStyle ts=new TabletStyle();
List<TabletStyleDetail> list=new List<TabletStyleDetail>();
ts.StyleID = (json == null || json.styleID == null) ? "" : (string) json.styleID;
TabletStyle ts = new TabletStyle();
List<TabletStyleDetail> list = new List<TabletStyleDetail>();
ts.StyleID = (json == null || json.styleID == null) ? "" : (string)json.styleID;
string mode = "edit";
if (string.IsNullOrEmpty(ts.StyleID))
{
@@ -108,8 +108,8 @@ public class designerController:ApiController
foreach (var item in json.detail.Children<JObject>())
{
TabletStyleDetail tsd = new TabletStyleDetail();
tsd.StyleID=ts.StyleID;
tsd.Name=item.name==null?"":(string)item.name;
tsd.StyleID = ts.StyleID;
tsd.Name = item.name == null ? "" : (string)item.name;
tsd.Descr = item.descr == null ? "" : (string)item.descr;
tsd.ElementID = item.elementID == null ? "" : (string)item.elementID;
tsd.StartX = item.startX == null ? "" : (string)item.startX;
@@ -126,8 +126,111 @@ public class designerController:ApiController
}
if (mode == "add")
{
object[] obj= new StyleDataAccess().AddStyle(ts,list);
object[] obj = new StyleDataAccess().AddStyle(ts, list);
}
return Ok();
}
}
[HttpPost]
[Route("api/tablet/UpdateDegignerData")]
public IHttpActionResult UpdateDegignerData([FromBody] dynamic data)
{
LogUtility log = new LogUtility();
var json = data;
//json.detail.Children<JObject>()
log.writeLogPath((string)json.styleName);
TabletStyle ts = new TabletStyle();
List<TabletStyleDetail> list = new List<TabletStyleDetail>();
ts.StyleID = (json == null || json.styleID == null) ? "" : (string)json.styleID;
string mode = "edit";
if (string.IsNullOrEmpty(ts.StyleID))
{
ts.StyleID = DateTime.Now.ToString("yyyyMMddHHmmss");
mode = "add";
}
ts.Name = (json == null || json.styleName == null) ? "" : (string)json.styleName;
ts.Descr = (json == null || json.descr == null) ? "" : (string)json.descr;
ts.PaperSize = (json == null || json.paperSize == null) ? "" : (string)json.paperSize;
ts.BackendImg = (json == null || json.backendImg == null) ? "" : (string)json.backendImg;
ts.PrintSize = (json == null || json.printSize == null) ? "" : (string)json.printSize;
ts.Orientation = (json == null || json.orientation == null) ? "" : (string)json.orientation;
ts.PrintPageCount = (json == null || json.printPageCount == null) ? "" : (string)json.printPageCount;
ts.PrintMode = (json == null || json.printMode == null) ? "" : (string)json.printMode;
foreach (var item in json.detail.Children<JObject>())
{
TabletStyleDetail tsd = new TabletStyleDetail();
tsd.StyleID = ts.StyleID;
tsd.Name = item.name == null ? "" : (string)item.name;
tsd.Descr = item.descr == null ? "" : (string)item.descr;
tsd.ElementID = item.elementID == null ? "" : (string)item.elementID;
tsd.StartX = item.startX == null ? "" : (string)item.startX;
tsd.StartY = item.startY == null ? "" : (string)item.startY;
tsd.FontSize = item.fontSize == null ? "" : (string)item.fontSize;
tsd.FontFamily = item.fontFamily == null ? "" : (string)item.fontFamily;
tsd.BreakLen = item.breakLen == null ? "" : (string)item.breakLen;
tsd.Width = item.width == null ? "" : (string)item.width;
tsd.TwoOffset = item.twoOffset == null ? "" : (string)item.twoOffset;
tsd.ThreeOffset = item.threeOffset == null ? "" : (string)item.threeOffset;
tsd.FourOffset = item.fourOffset == null ? "" : (string)item.fourOffset;
tsd.IsActive = item.isActive == null ? "" : (string)item.isActive;
tsd.Width = item.width == null ? "" : (string)item.width;
tsd.Height = item.height == null ? "" : (string)item.height;
tsd.TextWidth = item.textWidth == null ? "" : (string)item.textWidth;
tsd.TextHeight = item.textHeight == null ? "" : (string)item.textHeight;
list.Add(tsd);
}
object[] obj = new StyleDataAccess().UpdateStyle(ts, list);
return Ok();
}
[HttpPost]
[Route("api/tablet/GetPaperSize")]
public IHttpActionResult GetPaperSize([FromBody] dynamic data)
{
LogUtility log = new LogUtility();
object[] obj = new StyleDataAccess().GetTabletPaper("", "");
if (obj[0].ToString() == "Y")
{
return Ok(new { result = "Y", data = obj[2] });
}
else
{
return Ok(new { result = "N", message = obj[1] });
//throw new HttpResponseException(HttpStatusCode.NotFound);
}
//return Ok(data);
}
[HttpPost]
[Route("api/tablet/SavePaperSize")]
public IHttpActionResult SavePaperSize([FromBody] dynamic data)
{
LogUtility log = new LogUtility();
var json = data;
//json.detail.Children<JObject>()
log.writeLogPath((string)json.styleName);
TabletPaperSize tps = new TabletPaperSize();
tps.PaperID = (json == null || json.PaperID == null) ? "" : (string)json.PaperID;
if (string.IsNullOrEmpty(tps.PaperID))
{
tps.PaperID = DateTime.Now.ToString("yyyyMMddHHmmss");
}
tps.PaperName = (json == null || json.PaperName == null) ? "" : (string)json.PaperName;
tps.Width = (json == null || json.Width == null) ? "" : (string)json.Width;
tps.Height = (json == null || json.Height == null) ? "" : (string)json.Height;
object[] obj = new StyleDataAccess().AddTabletPaper(tps);
return Ok();
}
}