1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
| using Camstar.InterfaceSet.Models.CommonModel; using Camstar.InterfaceSet.Models.ServiceModel.MES; using System; using Camstar.InterfaceSet.Results.Common; using Camstar.WCF.ObjectStack; using Camstar.WCF.Services; using Camstar.InterfaceSet.Service.Common; using System.Collections.Generic; using System.Linq; using System.Web; using UserDll; using UserDll.Base;
namespace Camstar.InterfaceSet.Service.MES { public class MES_CreateLDCodeParaService { public ApiResult CreateLDCodePara(MES_CreateLDCodeParaReq req) { var ar = new ApiResult();
try { UserProfile userProfile = UserConfig.getUserProfileInstance(); ahLDCodeParameterMaintService service = new ahLDCodeParameterMaintService(userProfile);
string paraName = req.Name; string ruleName = req.LDCodeRule; if (string.IsNullOrEmpty(paraName)) { ar.bSucc = false; ar.strMsg = string.Format("镭雕打码参数建模创建失败!建模名称为空!"); AvaryLog.AddLog(LogLevel.Error, PubCommon.GetLineNum() + ar.strMsg, "CreateLDCodeParaServiceError"); return ar; } if (!string.IsNullOrEmpty(ruleName) && !checkRuleExist(ruleName)) { ar.bSucc = false; ar.strMsg = string.Format("镭雕打码参数建模创建失败!镭雕码规则{0}未定义!", ruleName); AvaryLog.AddLog(LogLevel.Error, PubCommon.GetLineNum() + ar.strMsg, "CreateLDCodeParaServiceError"); return ar; }
if (checkParaExist(paraName)) { using (OracleDataOpt dataOpt = new OracleDataOpt(PubCommon.GetConStr("MES"))) { string sql = @"SELECT COUNT(1) FROM AHLDCODEPARAMETER A INNER JOIN AHSTRIPCODEPARA D ON D.AHLDCODEPARAMETERID = A.AHLDCODEPARAMETERID WHERE A.AHLDCODEPARAMETERNAME = :Name"; int count = dataOpt.GetCount(sql, paraName);
ahLDCodeParameterMaint data = new ahLDCodeParameterMaint(); ahLDCodeParameterMaint data1 = new ahLDCodeParameterMaint(); ahLDCodeParameterChanges changes = new ahLDCodeParameterChanges(); data.ObjectToChange = new NamedObjectRef(paraName); service.BeginTransaction(); service.Load(data); List<ahStripCodeParaChanges> list = new List<ahStripCodeParaChanges>();
if (count > 0) { for (int l = count - 1; l >= 0; l--) { ahStripCodeParaChanges details = new ahStripCodeParaChanges(); details.ListItemAction = ListItemAction.Delete; details.ListItemIndex = l; list.Add(details); } } if (req.StripCodePara != null && req.StripCodePara.Count > 0) { foreach (var item in req.StripCodePara) { ahStripCodeParaChanges details = new ahStripCodeParaChanges(); details.ListItemAction = ListItemAction.Add;
details.ahSeq = Convert.ToInt32(item.Seq); details.ahCodeType = item.CodeType; details.ahCodeAngle = item.CodeAngle; details.ahCodeLength = item.CodeLength; details.ahCodeWidth = item.CodeWidth; details.ahLocationX = item.LocationX; details.ahLocationY = item.LocationY;
list.Add(details); } } changes.ahStripCodePara = list.ToArray();
if (!string.IsNullOrEmpty(ruleName)) changes.ahLDCodeRule = new NamedObjectRef(ruleName); changes.ahPnlLocationX = req.PnlLocationX; changes.ahPnlLocationY = req.PnlLocationY; changes.ahPnlCodeAngle = req.PnlCodeAngle; changes.ahPnlCodeLength = req.PnlCodeLength; changes.ahPnlCodeWidth = req.PnlCodeWidth; changes.ahALocationX = req.ALocationX; changes.ahALocationY = req.ALocationY; changes.ahBLocationX = req.BLocationX; changes.ahBLocationY = req.BLocationY; changes.ahCLocationX = req.CLocationX; changes.ahCLocationY = req.CLocationY; changes.ahDLocationX = req.DLocationX; changes.ahDLocationY = req.DLocationY; changes.ahStripCodeRule = req.StripCodeRule;
data1.ObjectChanges = changes; service.ExecuteTransaction(data1); ResultStatus resultStatus = service.CommitTransaction(); if (resultStatus.IsSuccess) { ar.bSucc = true; ar.strMsg = "镭雕打码参数建模更新成功!" + resultStatus.Message; AvaryLog.AddLog(LogLevel.Trace, paraName + "镭雕打码参数建模更新成功!", "CreateLDCodeParaServiceSuccess"); } else { ar.bSucc = false; ar.strMsg = "镭雕打码参数建模更新失败!" + resultStatus.ExceptionData.Description; AvaryLog.AddLog(LogLevel.Trace, paraName + "镭雕打码参数建模更新失败!" + resultStatus.ExceptionData.Description, "CreateLDCodeParaServiceError"); } } } else { ahLDCodeParameterMaint data = new ahLDCodeParameterMaint(); ahLDCodeParameterChanges changes = new ahLDCodeParameterChanges(); List<ahStripCodeParaChanges> list = new List<ahStripCodeParaChanges>(); changes.Name = paraName;
if (!string.IsNullOrEmpty(ruleName)) changes.ahLDCodeRule = new NamedObjectRef(ruleName); changes.ahPnlLocationX = req.PnlLocationX; changes.ahPnlLocationY = req.PnlLocationY; changes.ahPnlCodeAngle = req.PnlCodeAngle; changes.ahPnlCodeLength = req.PnlCodeLength; changes.ahPnlCodeWidth = req.PnlCodeWidth; changes.ahALocationX = req.ALocationX; changes.ahALocationY = req.ALocationY; changes.ahBLocationX = req.BLocationX; changes.ahBLocationY = req.BLocationY; changes.ahCLocationX = req.CLocationX; changes.ahCLocationY = req.CLocationY; changes.ahDLocationX = req.DLocationX; changes.ahDLocationY = req.DLocationY; changes.ahStripCodeRule = req.StripCodeRule;
if (req.StripCodePara != null && req.StripCodePara.Count > 0) { foreach (var item in req.StripCodePara) { ahStripCodeParaChanges details = new ahStripCodeParaChanges();
details.ahSeq = Convert.ToInt32(item.Seq); details.ahCodeType = item.CodeType; details.ahCodeAngle = item.CodeAngle; details.ahCodeLength = item.CodeLength; details.ahCodeWidth = item.CodeWidth; details.ahLocationX = item.LocationX; details.ahLocationY = item.LocationY;
list.Add(details); } } changes.ahStripCodePara = list.ToArray(); data.ObjectChanges = changes; service.BeginTransaction(); service.New(); service.ExecuteTransaction(data); ResultStatus resultStatus = service.CommitTransaction(); if (resultStatus.IsSuccess) { ar.bSucc = true; ar.strMsg = "镭雕打码参数建模创建成功!" + resultStatus.Message; AvaryLog.AddLog(LogLevel.Trace, paraName + "镭雕打码参数建模创建成功!", "CreateLDCodeParaServiceSuccess"); } else { ar.bSucc = false; ar.strMsg = "镭雕打码参数建模创建失败!" + resultStatus.ExceptionData.Description; AvaryLog.AddLog(LogLevel.Trace, paraName + "镭雕打码参数建模创建失败!" + resultStatus.ExceptionData.Description, "CreateLDCodeParaServiceError"); } } } catch (Exception ex) { ar = new ApiResult("0001", "镭雕打码参数建模创建失败!" + ex.Message, "CreateLDCodeParaServiceError"); AvaryLog.AddLog(LogLevel.Error, ex.ToString(), "CreateLDCodeParaServiceError"); } return ar; }
private bool checkParaExist(string Name) { using (OracleDataOpt dataOpt = new OracleDataOpt(PubCommon.GetConStr("MES"))) { string sql = @"SELECT COUNT(1) FROM AHLDCODEPARAMETER A WHERE A.AHLDCODEPARAMETERNAME = :Name"; int count = dataOpt.GetCount(sql, Name); if (count > 0) return true; else return false; } }
private bool checkRuleExist(string Name) { using (OracleDataOpt dataOpt = new OracleDataOpt(PubCommon.GetConStr("MES"))) { string sql = @"SELECT COUNT(1) FROM AHLDCODERULE A WHERE A.AHLDCODERULENAME = :Name"; int count = dataOpt.GetCount(sql, Name); if (count > 0) return true; else return false; } } } }
|