|
|
using System; using System.Runtime.Remoting; using System.Collections; using System.Reflection; using System.Runtime.Remoting; using System.Text.RegularExpressions; using System.Linq; using System.Data.Linq; using System.Xml; using System.IO; using ICSSoft.Base.Config.AppConfig; using System.Collections.Specialized; using ICSSoft.Frame.Data.Entity; using ICSSoft.Frame.DataConnect.Action; using System.Data; using ICSSoft.Frame.Helper; using ICSSoft.Frame.Data.Entity; using ICSSoft.Base.Config.DBHelper; using System.Collections.Generic; using System.Data.SqlClient;
namespace ICSSoft.Frame.DataConnect {
/// <summary>
/// BaseModel ��ժҪ˵����
/// ���: BaseModel.cs
/// �� ��: ����ģ��ά����̨
/// �� ��:
/// </summary>
public class ICSBaseModel { FramDataContext domainDataProvider = new Data.Entity.FramDataContext(); private FramDataContext _domainDataProvider = null; private const string TS_Operation = "TS";
public ICSBaseModel(FramDataContext domainDataProvider) { this._domainDataProvider = domainDataProvider; }
public ICSBaseModel() { }
public FramDataContext DataProvider { get { return _domainDataProvider; } }
#region Segment
/// <summary>
/// ** ��������: ��SegmentCode����Segment
/// ** �� ��:
/// ** �� ��:
/// ** �汾
/// </summary>
/// <param name="segmentCode"></param>
/// <returns></returns>
public object GetSegment(string segmentCode) { return this.DataProvider.ICSSEG.SingleOrDefault(a => a.SEGCODE == segmentCode && a.WorkPoint == AppConfig.WorkPointCode); }
#endregion
#region ICSSS
public object GetStepSequence(string stepSequenceCode) { return this.DataProvider.ICSSS.SingleOrDefault(a => a.SSCODE == stepSequenceCode && a.WorkPoint == AppConfig.WorkPointCode); }
/// <summary>
/// ** ��������: ��ѯICSSS��������
///
/// </summary>
/// <param name="stepSequenceCode">StepSequenceCode��ģ����ѯ</param>
/// <param name="segmentCode">SegmentCode��ģ����ѯ</param>
/// <returns>ICSSS���ܼ�¼��</returns>
public int QueryStepSequenceCount(string stepSequenceCode, string segmentCode, string BigStepSequenceCode) { var ssline = from a in DataProvider.ICSSS join b in DataProvider.ICSSEG on a.SEGID equals b.ID where a.WorkPoint == AppConfig.WorkPointCode && b.WorkPoint == AppConfig.WorkPointCode select new { a, b }; if (stepSequenceCode != null && stepSequenceCode.Length != 0) { ssline = ssline.Where(p=>p.a.SSCODE==stepSequenceCode); }
if (segmentCode != null && segmentCode.Length != 0) { if (segmentCode.IndexOf(",") >= 0) { ssline = ssline.Where(p => segmentCode.Contains(p.b.SEGCODE)); } else { ssline = ssline.Where(p=>p.b.SEGCODE.StartsWith(segmentCode)); } } if (ssline != null) { return ssline.ToList().Count; } else { return 0; } }
/// <summary>
/// ** ��������: ��ҳ��ѯICSSS
/// </summary>
/// <param name="stepSequenceCode">StepSequenceCode��ģ����ѯ</param>
/// <param name="segmentCode">SegmentCode��ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns></returns>
public object[] QueryStepSequence(string stepSequenceCode, string segmentCode) { try { var ssline = from a in DataProvider.ICSSS join b in DataProvider.ICSSEG on a.SEGID equals b.ID where a.WorkPoint == AppConfig.WorkPointCode && b.WorkPoint == AppConfig.WorkPointCode orderby a.SSCODE select new { a, b };
if (stepSequenceCode != null && stepSequenceCode.Length != 0) { ssline = ssline.Where(p=>p.a.SSCODE.StartsWith(stepSequenceCode)); }
if (segmentCode != null && segmentCode.Length != 0) { if (segmentCode.IndexOf(",") >= 0) { ssline = ssline.Where(p => segmentCode.Contains(p.b.SEGCODE)); } else { ssline = ssline.Where(p => p.b.SEGCODE.StartsWith(segmentCode)); } }
return ssline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.CustomQuery(typeof(ICSSS), new SQLCondition(string.Format( "select * from TBLSS where 1=1 {0} order by SSSEQ", condition )));
//return this.DataProvider.CustomQuery(typeof(ICSSS), new PagerCondition(string.Format(, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSSS)), condition), "SEGCODE"));
}
/// <summary>
/// ** ��������: �������е�ICSSS
/// </summary>
/// <returns>���е�ICSSS</returns>
public object[] GetAllStepSequence() { try { var line = DataProvider.ICSSS.Where(p => p.WorkPoint == AppConfig.WorkPointCode); return line.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); }
// return this.DataProvider.CustomQuery(typeof(ICSSS), new SQLCondition(string.Format("select {0} from TBLSS where 1=1 " + " and WorkPoint ='"+AppConfig.WorkPointCode+"'" + " order by SSCODE", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSSS)))));
}
/// <summary>
/// ** ��������: ����Segment�����е�ICSSS
/// </summary>
/// <returns>Segment�����е�ICSSS</returns>
public object[] GetStepSequenceBySegmentCode(string segmentCode) {
try { var ssline = from a in DataProvider.ICSSS join b in DataProvider.ICSSEG on a.SEGID equals b.ID where a.WorkPoint == AppConfig.WorkPointCode && b.WorkPoint == AppConfig.WorkPointCode && b.SEGCODE==segmentCode orderby a.SSCODE select new { a, b }; return ssline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSSS), new SQLCondition(string.Format("select {0} from TBLSS where 1=1 " + " and WorkPoint ='"+AppConfig.WorkPointCode+"'" + " and SEGCODE='{1}' order by SSCODE", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSSS)), segmentCode)));
} #endregion
#region ICSRES
//������Դ��Ӧ�����Ƿ���;�̵ĵ�һ������
private void CheckResource(ICSRES resource) { var resline = from a in DataProvider.ICSOP2RES join b in DataProvider.ICSROUTE2OP on a.OPCODE equals b.OPCODE join c in DataProvider.ICSROUTE on b.ROUTECODE equals c.ROUTECODE where a.RESCODE == resource.RESCODE && c.ROUTETYPE == "Rework" && a.WorkPoint == AppConfig.WorkPointCode && b.WORKPOINT == AppConfig.WorkPointCode && c.WorkPoint == AppConfig.WorkPointCode select new { b.ROUTECODE };
if (resource.ID != null && resline != null) { ICSOP2RES op = this.GetOperationByResource(resource.RESCODE); if (op == null) { throw new Exception("$Error_Res_not_belong_To_Op"); }
object op2 = GetFirstOperationOfRoute(resline.ToList()[0].ToString()) as ICSOP; if (op2 == null) { throw new Exception("$error_route_no_op"); } if (((ICSOP)op2).OPCODE != op.OPCODE) { throw new Exception("$error_res_not_first_op"); } }
}
public object GetResource(string resourceCode) { try { var line = DataProvider.ICSRES.SingleOrDefault(a => a.RESCODE == resourceCode); return line; } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary>
/// ** ��������: ��ѯICSRES��������
/// </summary>
/// <param name="resourceCode">ResourceCode��ģ����ѯ</param>
/// <returns> ICSRES���ܼ�¼��</returns>
public int QueryResourceCount(string resourceCode, string stepSequenceCode, string crewCode) { var resline = from a in DataProvider.ICSRES join b in DataProvider.ICSSS on a.SSID equals b.ID where a.RESCODE.StartsWith(resourceCode) && a.WorkPoint==AppConfig.WorkPointCode && b.WorkPoint==AppConfig.WorkPointCode select new { a, b }; if (stepSequenceCode != "") { if (stepSequenceCode.IndexOf(",") >= 0) { resline= resline.Where(p=>stepSequenceCode.Contains(p.b.SSCODE)); } else { resline = resline.Where(p => p.b.SSCODE.StartsWith(stepSequenceCode)); } } if (crewCode != "") { resline = resline.Where(p => p.a.CREWCODE.StartsWith(crewCode)); } return resline.ToList().Count; }
public object[] CheckResource(string ssCode) { try { var resline = from a in DataProvider.ICSSS where ssCode.ToUpper().StartsWith(a.SSCODE) && a.WorkPoint == AppConfig.WorkPointCode select a; return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); }
//return this.DataProvider.CustomQuery(typeof(ICSSS), new SQLCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSSS)), ssCode)));
}
/// <summary>
/// ** ��������: ��ҳ��ѯICSRES
/// </summary>
/// <param name="resourceCode">ResourceCode��ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns> ICSRES����</returns>
public object[] QueryResource(string resourceCode, string stepSequenceCode, string crewCode) { try { var resline = from a in DataProvider.ICSRES join b in DataProvider.ICSSS on a.SSID equals b.ID where a.RESCODE.StartsWith(resourceCode) && a.WorkPoint==AppConfig.WorkPointCode && b.WorkPoint==AppConfig.WorkPointCode select new { a, b }; if (stepSequenceCode != "") { if (stepSequenceCode.IndexOf(",") >= 0) { resline = resline.Where(p => stepSequenceCode.Contains(p.b.SSCODE)); } else { resline = resline.Where(p => p.b.SSCODE.StartsWith(stepSequenceCode)); } } //stepSequenceCode�����ݿ�������Ϊ��,
if (crewCode != "") { resline = resline.Where(p => p.a.CREWCODE.StartsWith(crewCode)); } return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSRES), new PagerCondition(qSql, "RESCODE", inclusive, exclusive));
} /// <summary>
/// ** ��������: �������е�ICSRES
/// </summary>
/// <returns>ICSRES���ܼ�¼��</returns>
public object[] GetAllResource() { try { var resline = from a in DataProvider.ICSRES where a.WorkPoint == AppConfig.WorkPointCode orderby a.RESCODE select a; return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSRES), new SQLCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSRES)))));
} /// <summary>
/// ** ��������: ����ShiftTypeCode�õ�ICSRESʵ��
/// </summary>
/// <param name="segmentCode">SegmentCode</param>
/// <returns>ICSRES����</returns>
public object[] QueryResourceBySegmentCode(string segmentCode) { try { var resline = from a in DataProvider.ICSRES join b in DataProvider.ICSSEG on a.SEGID equals b.ID where b.SEGCODE == segmentCode && a.WorkPoint == AppConfig.WorkPointCode && b.WorkPoint == AppConfig.WorkPointCode select new { a, b };
return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } // End Added
// return this.DataProvider.CustomQuery(typeof(ICSRES), new SQLCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSRES)), segmentCode)));
}
#endregion
#region ICSOP
public object GetOperation(string opCode) { try { var opline = from a in DataProvider.ICSOP where a.OPCODE == opCode && a.WorkPoint == AppConfig.WorkPointCode select a;
return opline; } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomSearch(typeof(ICSOP), new object[] { opCode });
}
/// <summary>
/// ** ��������: ��ѯICSOP��������
/// </summary>
/// <param name="oPCode">OPCODE��ģ����ѯ</param>
/// <returns> ICSOP���ܼ�¼��</returns>
public int QueryOperationCount(string oPCode) { var resline = from a in DataProvider.ICSOP where oPCode.StartsWith(oPCode) && a.WorkPoint == AppConfig.WorkPointCode select a; return resline.ToList().Count;
//return this.DataProvider.GetCount(new SQLCondition(string.Format("select count(*) from TBLOP where 1=1 and OPCODE like '{0}%'", oPCode)));
}
/// <summary>
/// ** ��������: ��ѯICSOP
/// </summary>
/// <param name="oPCode">OPCODE��ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns> ICSOP����</returns>
public object[] QueryOperation(string oPCode) { try { var resline = from a in DataProvider.ICSOP where a.OPCODE.StartsWith(oPCode) && a.WorkPoint==AppConfig.WorkPointCode select a; return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); }
//return this.DataProvider.CustomQuery(typeof(ICSOP), new PagerCondition(string.Format("select {0} from TBLOP where 1=1 and OPCODE like '{1}%'", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSOP)), oPCode), "OPCODE", inclusive, exclusive));
}
public object[] QueryOperation() { try { var resline = DataProvider.ICSOP.Where(p => p.WorkPoint == AppConfig.WorkPointCode); return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.CustomQuery(typeof(ICSOP), new SQLCondition("select distinct opcode from TBLOP ORDER BY opcode"));
}
/// <summary>
/// ** ��������: �������е�ICSOP
/// </summary>
/// <returns>ICSOP���ܼ�¼��</returns>
public object[] GetAllOperation() { try { var resline = from a in DataProvider.ICSOP where a.WorkPoint == AppConfig.WorkPointCode select a; return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSOP), new SQLCondition(string.Format("select {0} from TBLOP order by OPCODE ", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSOP)))));
}
public bool IsOperationInRoute(string routeCode, string opCode) { var resline = DataProvider.ICSROUTE2OP.Where(p=>p.ROUTECODE==routeCode&&p.OPCODE==opCode&&p.WORKPOINT==AppConfig.WorkPointCode); if (resline != null) { return true; } else { return false; } } #endregion
#region ICSROUTE
/// <summary>
/// ** ��������: ��ѯICSROUTE��������
/// </summary>
/// <param name="routeCode">RouteCode��ģ����ѯ</param>
/// <returns> ICSROUTE���ܼ�¼��</returns>
public int QueryRouteCount(string routeCode) { var resline = DataProvider.ICSROUTE.Where(p=>p.ROUTECODE.StartsWith(routeCode)); return resline.ToList().Count; //return this.DataProvider.GetCount(new SQLCondition(string.Format("select count(*) from TBLROUTE where 1=1 and ROUTECODE like '{0}%' ", routeCode)));
}
/// <summary>
/// ** ��������: ��ҳ��ѯICSROUTE
/// </summary>
/// <param name="routeCode">RouteCode��ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns> ICSROUTE����</returns>
public object[] QueryRoute(string routeCode) { try { var resline = DataProvider.ICSROUTE.Where(p => p.ROUTECODE.StartsWith(routeCode)&&p.WorkPoint==AppConfig.WorkPointCode);
return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.CustomQuery(typeof(ICSROUTE), new PagerCondition(string.Format("select {0} from TBLROUTE where 1=1 and ROUTECODE like '{1}%'", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSROUTE)), routeCode), "ROUTECODE ", inclusive, exclusive));
}
/// <summary>
/// ** ��������: ��ҳ��ѯICSROUTE
/// </summary>
/// <param name="routeCode">RouteCode��ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns> ICSROUTE����</returns>
public object[] QueryICSITEM2ROUTE(string itemCode) { try { var resline = DataProvider.ICSITEM2ROUTE.Where(p=>p.ITEMCODE==itemCode && p.WorkPoint==AppConfig.WorkPointCode); return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); }
//return this.DataProvider.CustomQuery(typeof(ICSITEM2ROUTE),
// new PagerCondition(string.Format("select {0} from TBLICSITEM2ROUTE where ITEMCODE = '{1}'"
// + " and WorkPoint ='"+AppConfig.WorkPointCode+"'",
// DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSITEM2ROUTE)), itemCode),
// "ITEMCODE ", inclusive, exclusive));
}
/// <summary>
/// ** ��������: ��ҳ��ѯICSROUTE
/// </summary>
/// <param name="routeCode">RouteCode��ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns> ICSROUTE����</returns>
public int GetICSITEM2ROUTECount(string itemCode) { try { var resline = DataProvider.ICSITEM2ROUTE.Where(p => p.ITEMCODE == itemCode && p.WorkPoint == AppConfig.WorkPointCode); return resline.ToList().Count; } catch (Exception) { throw; } }
/// <summary>
/// ** ��������: �������е�ICSROUTE
/// </summary>
/// <returns>ICSROUTE���ܼ�¼��</returns>
public object[] GetAllRoute() { try { var resline = DataProvider.ICSROUTE.Where(p=>p.WorkPoint==AppConfig.WorkPointCode); return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSROUTE), new SQLCondition(string.Format("select {0} from TBLROUTE order by ROUTECODE", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSROUTE)))));
}
/// <summary>
/// ** ��������: �������е�ICSROUTE
/// </summary>
/// <returns>ICSROUTE���ܼ�¼��</returns>
public object[] GetAllRouteEnabled() { try { var resline = DataProvider.ICSROUTE.Where(p=>p.WorkPoint==AppConfig.WorkPointCode&&p.ENABLED=="��Ч"&&p.WorkPoint==AppConfig.WorkPointCode); return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); }
// return this.DataProvider.CustomQuery(typeof(ICSROUTE), new SQLCondition(string.Format("select {0} from TBLROUTE where enabled='1' order by ROUTECODE", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSROUTE)))));
}
public object GetOPFromRoute2OP(string routeCode, string resourceCode) { try { var resline = from a in DataProvider.ICSROUTE2OP join b in DataProvider.ICSOP2RES on a.OPCODE equals b.OPCODE select new { a, b };
if (routeCode.Trim() != string.Empty) { resline = resline.Where(p=>p.a.ROUTECODE==routeCode.Trim().ToUpper()); }
if (resourceCode.Trim() != string.Empty) { resline = resline.Where(p => p.b.RESCODE == resourceCode.Trim().ToUpper()); }
return resline.ToArray() ; } catch (Exception ex) { throw new Exception(ex.Message); }
//object[] returnObjects = this.DataProvider.CustomQuery(typeof(ICSROUTE2OP), new SQLCondition(sql));
//if (returnObjects != null)
//{
// return returnObjects[0];
//}
//return null;
}
/// <summary>
/// ** ��������: �������е�ICSROUTE
/// </summary>
/// <param name="routeCode"></param>
/// <returns></returns>
public bool IsRouteRef(string routeCode) { var resline = DataProvider.ICSITEM2ROUTE.Where(p=>p.ISREF=="��" && p.ROUTECODE==routeCode && p.WorkPoint==AppConfig.WorkPointCode); if (resline!=null) { return true; } else { return false; } //return (this.DataProvider.GetCount(new SQLCondition(string.Format(" select count(*) from ICSITEM2ROUTE where ISREF='��' AND ROUTECODE='{0}' ", routeCode))) > 0);
} #endregion
public void AddOrEdit(string Type) { System.Type type = System.Type.GetType(Type);
}
#region ICSROUTE2OP
public ICSROUTE2OP CreateNewRoute2Operation() { return new ICSROUTE2OP(); }
public void AddAndUpdateRoute2Operation(ICSROUTE2OP route2Operation) {
try { bool isNew = false; var line = DataProvider.ICSROUTE2OP.SingleOrDefault(a => a.ROUTEID == route2Operation.ROUTEID && a.OPID == route2Operation.OPID);
if (line == null) { isNew = true; line = new ICSROUTE2OP(); line.OPID = route2Operation.OPID; line.ROUTEID = route2Operation.ROUTEID; } line.ROUTECODE = route2Operation.ROUTECODE; line.OPCODE = route2Operation.OPCODE; line.OPSEQ = route2Operation.OPSEQ; line.OPCONTROL = route2Operation.OPCONTROL; line.MUSER = route2Operation.MUSER; line.MUSERName = route2Operation.MUSERName; line.MTIME = route2Operation.MTIME; line.WORKPOINT = route2Operation.WORKPOINT; line.EATTRIBUTE1 = route2Operation.EATTRIBUTE1;
if (isNew) DataProvider.ICSROUTE2OP.InsertOnSubmit(line);
DataProvider.SubmitChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void AddRoute2Operation(ICSROUTE2OP[] route2Operations) { try { foreach (ICSROUTE2OP route2Operation in route2Operations) { bool isNew = false; var line = DataProvider.ICSROUTE2OP.SingleOrDefault(a => a.ROUTEID == route2Operation.ROUTEID && a.OPID == route2Operation.OPID);
if (line == null) { isNew = true; line = new ICSROUTE2OP(); line.OPID = route2Operation.OPID; line.ROUTEID = route2Operation.ROUTEID; } line.ROUTECODE = route2Operation.ROUTECODE; line.OPCODE = route2Operation.OPCODE; line.OPSEQ = route2Operation.OPSEQ; line.OPCONTROL = route2Operation.OPCONTROL; line.MUSER = route2Operation.MUSER; line.MUSERName = route2Operation.MUSERName; line.MTIME = route2Operation.MTIME; line.WORKPOINT = route2Operation.WORKPOINT; line.EATTRIBUTE1 = route2Operation.EATTRIBUTE1;
if (isNew) DataProvider.ICSROUTE2OP.InsertOnSubmit(line); } DataProvider.SubmitChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void UpdateRoute2Operation(ICSROUTE2OP route2Operation) { UpdateRoute2Operation(route2Operation, true); }
public void UpdateRoute2Operation(ICSROUTE2OP route2Operation, bool checkSeq) { if (checkSeq) { var resline = DataProvider.ICSROUTE2OP.Where(p => p.ROUTECODE == route2Operation.ROUTECODE);
//object[] route2Ops = this.DataProvider.CustomQuery(typeof(ICSROUTE2OP),
// new SQLCondition(string.Format("select {0} from tblroute2op where routecode = '{1}'", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSROUTE2OP)), route2Operation.RouteCode)));
if (resline != null) { foreach (ICSROUTE2OP route2Op in resline) { if (route2Op.OPSEQ== route2Operation.OPSEQ && route2Op.OPCODE != route2Operation.OPCODE) { throw new Exception("$Error_Route2Operation_Sequence_Cannot_Repeat"); } } } }
AddAndUpdateRoute2Operation(route2Operation); }
/// <summary>
/// sammer kong 2005/05/21 route in usage
/// </summary>
/// <param name="route2Operation"></param>
public void DeleteRoute2Operation(ICSROUTE2OP route2Operation) { try { var lines = DataProvider.ICSROUTE2OP.Where(a => a.OPID == route2Operation.OPID && a.ROUTEID == route2Operation.ROUTEID);
DataProvider.ICSROUTE2OP.DeleteAllOnSubmit(lines);
DataProvider.SubmitChanges();
} catch (Exception ex) { throw ex; } }
public void DeleteRoute2Operation(ICSROUTE2OP[] route2Operations) { try { foreach (ICSROUTE2OP route2Operation in route2Operations) { var lines = DataProvider.ICSROUTE2OP.Where(a => a.OPID == route2Operation.OPID && a.ROUTEID == route2Operation.ROUTEID);
DataProvider.ICSROUTE2OP.DeleteAllOnSubmit(lines); }
DataProvider.SubmitChanges();
} catch (Exception ex) { throw ex; } }
public bool IsRouteOperationInUsage(string routeCode, string opCode) { object obj = this.GetRoute2Operation(routeCode, opCode); if (obj != null && obj is ICSROUTE2OP) { //_standardRouteInUsage usageCheck = new _standardRouteInUsage(obj as ICSROUTE2OP, this.DataProvider);
//return !usageCheck.Check();
} else { //ExceptionManager.Raise(this.GetType(), "Error_Argument_Null");
} return false; }
public object GetRoute2Operation(string routeCode, string opCode) { try {
var line = DataProvider.ICSROUTE2OP.SingleOrDefault(a => a.OPID == opCode && a.ROUTEID == routeCode); return line; } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomSearch(typeof(ICSROUTE2OP), new object[] { routeCode, opCode });
}
//���ݲ�Ʒ;�̹���������ȡ����
public object[] QueryCurrentRoute2Operation(string itemCode, string routeCode, string opCode) { try { var resline = DataProvider.ICSITEMROUTE2OP.Where(p=>p.ITEMCODE==itemCode&&p.ROUTECODE==routeCode&&p.OPCODE==opCode);
return resline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); }
//return this.DataProvider.CustomQuery(
// typeof(ICSITEM2ROUTE),
// new SQLCondition(
// string.Format(" select {0} from TBLITEMROUTE2OP where itemcode = '{1}' and routecode = '{2}' and opcode = '{3}'" + " and WorkPoint ='" + AppConfig.WorkPointCode + "'",
// DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSITEM2ROUTE)), itemCode, routeCode, opCode)));
}
#region ICSROUTE --> ICSOP
/// <summary>
/// ** ��������: ��RouteCode����ICSOP
/// </summary>
/// <param name="routeCode">RouteCode,��ȷ��ѯ</param>
/// <returns>ICSOP����</returns>
public object[] GetOperationByRouteCode(string routeCode) { string sql = string.Format("select * from ICSOP where OPCODE in ( select OPCODE from ICSROUTE2OP where ROUTECODE='{0}')", routeCode); DataTable dt = DBHelper.ExecuteDataset(sql, CommandType.Text, AppConfig.AppConnectString).Tables[0]; ICSOP[] entity = new ICSOP[dt.Rows.Count]; try { int i = 0; foreach (DataRow dr in dt.Rows) { var line = DataProvider.ICSOP.SingleOrDefault(a => a.ID == dr["ID"].ToString() ); entity[i] = line; i++; } return entity; } catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.CustomQuery(typeof(ICSOP), new SQLCondition(string.Format("select {0} from TBLOP where OPCODE in ( select OPCODE from TBLROUTE2OP where ROUTECODE='{1}')", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSOP)), routeCode)));
}
/// <summary>
/// ** ��������: ��RouteCode��������ICSROUTE��ICSOP������
/// </summary>
/// <param name="routeCode">RouteCode,��ȷ��ѯ</param>
/// <param name="oPCode">OPCODE,ģ����ѯ</param>
/// <returns>ICSOP������</returns>
public int GetSelectedOperationByRouteCodeCount(string routeCode, string oPCode) { string sql = string.Format("select * from ICSROUTE2OP where ROUTECODE ='{0}' and OPCODE like '{1}%'", routeCode, oPCode); DataTable dt = DBHelper.ExecuteDataset(sql, CommandType.Text, AppConfig.AppConnectString).Tables[0]; ICSROUTE2OP[] entity = new ICSROUTE2OP[dt.Rows.Count]; try { int i = 0; foreach (DataRow dr in dt.Rows) { var line = DataProvider.ICSROUTE2OP.SingleOrDefault(a => a.ROUTEID == dr["ROUTEID"].ToString() && a.OPID == dr["OPID"].ToString()); entity[i] = line; i++; } return entity.Length; } catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.GetCount(new SQLCondition(string.Format("select count(*) from TBLROUTE2OP where ROUTECODE ='{0}' and OPCODE like '{1}%'", routeCode, oPCode)));
}
/// <summary>
/// ** ��������: ��RouteCode��������ICSROUTE��ICSOP����ҳ
/// </summary>
/// <param name="routeCode">RouteCode,��ȷ��ѯ</param>
/// <param name="oPCode">OPCODE,ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns>ICSOP����</returns>
public object[] GetSelectedOperationByRouteCode(string routeCode, string oPCode) { string sql = string.Format("select * from ICSOP where OPCODE in ( select OPCODE from ICSROUTE2OP where ROUTECODE ='{0}') and OPCODE like '{1}%'", routeCode, oPCode); DataTable dt = DBHelper.ExecuteDataset(sql, CommandType.Text, AppConfig.AppConnectString).Tables[0]; ICSOP[] entity = new ICSOP[dt.Rows.Count]; try { int i = 0; foreach (DataRow dr in dt.Rows) { var line = DataProvider.ICSOP.SingleOrDefault(a => a.ID == dr["OPID"].ToString()); entity[i] = line; i++; } return entity; } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSOP),
// new PagerCondition(string.Format("select {0} from TBLOP where OPCODE in ( select OPCODE from TBLROUTE2OP where ROUTECODE ='{1}') and OPCODE like '{2}%'", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSOP)), routeCode, oPCode), "OPCODE", inclusive, exclusive));
}
/// <summary>
/// ** ��������: ��RouteCode������ICSROUTE��ICSOP������
/// </summary>
/// <param name="routeCode">RouteCode,��ȷ��ѯ</param>
/// <param name="oPCode">OPCODE,ģ����ѯ</param>
/// <returns>ICSOP������</returns>
public int GetUnselectedOperationByRouteCodeCount(string routeCode, string oPCode) { string sql = string.Format("select * from ICSOP where OPCODE not in ( select OPCODE from ICSROUTE2OP where ROUTECODE ='{0}') and OPCODE like '{1}%'", routeCode, oPCode); DataTable dt = DBHelper.ExecuteDataset(sql, CommandType.Text, AppConfig.AppConnectString).Tables[0]; ICSOP[] entity = new ICSOP[dt.Rows.Count]; try { int i = 0; foreach (DataRow dr in dt.Rows) { var line = DataProvider.ICSOP.SingleOrDefault(a => a.ID == dr["OPID"].ToString()); entity[i] = line; i++; } return entity.Length; } catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.GetCount(new SQLCondition(string.Format("select count(*) from TBLOP where OPCODE not in ( select OPCODE from TBLROUTE2OP where ROUTECODE ='{0}') and OPCODE like '{1}%'", routeCode, oPCode)));
}
/// <summary>
/// ** ��������: ��RouteCode���ò�����ICSROUTE��ICSOP����ҳ
/// </summary>
/// <param name="routeCode">RouteCode,��ȷ��ѯ</param>
/// <param name="oPCode">OPCODE,ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns>ICSOP����</returns>
public object[] GetUnselectedOperationByRouteCode(string routeCode, string oPCode, int inclusive, int exclusive) { string sql = string.Format("select * from ICSOP where OPCODE not in ( select OPCODE from ICSROUTE2OP where ROUTECODE ='{0}') and OPCODE like '{1}%'", routeCode, oPCode); DataTable dt = DBHelper.ExecuteDataset(sql, CommandType.Text, AppConfig.AppConnectString).Tables[0]; ICSOP[] entity = new ICSOP[dt.Rows.Count]; try { int i = 0; foreach (DataRow dr in dt.Rows) { var line = DataProvider.ICSOP.SingleOrDefault(a => a.ID == dr["OPID"].ToString()); entity[i] = line; i++; } return entity; } catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.CustomQuery(typeof(ICSOP),
//new PagerCondition(string.Format("select {0} from TBLOP where OPCODE not in ( select OPCODE from TBLROUTE2OP where ROUTECODE ='{1}') and OPCODE like '{2}%'", DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSOP)), routeCode, oPCode), "OPCODE", inclusive, exclusive));
}
/// <summary>
/// ** ��������: ��RouteCode��������ICSROUTE��OperationOfRoute����ҳ
/// </summary>
/// <param name="routeCode">RouteCode,��ȷ��ѯ</param>
/// <param name="oPCode">OPCODE,ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns>OperationOfRoute����</returns>
public object[] GetSelectedOperationOfRouteByRouteCode(string routeCode, string opCode) { string sql = string.Format("select {0}, ICSROUTE2OP.OPSEQ, ICSROUTE2OP.ROUTECODE from ICSOP a,ICSROUTE2OP b where ICSOP.OPCODE = ICSROUTE2OP.OPCODE and ICSROUTE2OP.ROUTECODE='{1}' and a.WORKPOINT='" + AppConfig.WorkPointCode + "' and b.WORKPOINT='" + AppConfig.WorkPointCode + "' and ICSROUTE2OP.OPCODE like '{2}%'", "ICSROUTE2OP.OPCODE,ICSOP.OPDESC,ICSOP.OPCOLLECTION,ICSROUTE2OP.OPCONTROL,ICSROUTE2OP.MUSERName,ICSROUTE2OP.MTIME,ICSROUTE2OP.EAttribute1", routeCode, opCode); DataTable dt = DBHelper.ExecuteDataset(sql, CommandType.Text, AppConfig.AppConnectString).Tables[0]; Object[] entity = new Object[dt.Rows.Count]; try { int i = 0; foreach (DataRow dr in dt.Rows) { Object[] obj = new Object[dt.Columns.Count]; for (int m = 0; m < dt.Columns.Count; m++) { obj[m] = dr[m]; } entity[i]=obj; i++; } return entity; } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(FormOperationOfRouteModel), new PagerCondition(string.Format("select {0}, TBLROUTE2OP.OPSEQ, TBLROUTE2OP.ROUTECODE from TBLOP,TBLROUTE2OP where TBLOP.OPCODE = TBLROUTE2OP.OPCODE and TBLROUTE2OP.ROUTECODE='{1}' and TBLROUTE2OP.OPCODE like '{2}%'", "TBLROUTE2OP.OPCODE,TBLOP.OPDESC,TBLOP.OPCOLLECTION,TBLROUTE2OP.OPCONTROL,TBLROUTE2OP.MUSER,TBLROUTE2OP.MDATE,TBLROUTE2OP.MTIME,TBLROUTE2OP.EAttribute1", routeCode, opCode), "TBLROUTE2OP.OPSEQ", inclusive, exclusive));
} #endregion
#endregion
#region ICSOP2RES
public ICSOP2RES CreateNewOperation2Resource() { return new ICSOP2RES(); }
public void AddAndUpdateOperation2Resource(ICSOP2RES operation2Resource) { try { bool isNew = false; var line = DataProvider.ICSOP2RES.SingleOrDefault(a => a.RESID == operation2Resource.RESID && a.OPID == operation2Resource.OPID);
if (line == null) { isNew = true; line = new ICSOP2RES(); line.OPID = operation2Resource.OPID; line.RESID = operation2Resource.RESID; } line.RESCODE = operation2Resource.RESCODE; line.OPCODE = operation2Resource.OPCODE; line.RESSEQ = operation2Resource.RESSEQ; line.MUSER = operation2Resource.MUSER; line.MUSERName = operation2Resource.MUSERName; line.MTIME = operation2Resource.MTIME; line.WorkPoint = operation2Resource.WorkPoint; line.EATTRIBUTE1 = operation2Resource.EATTRIBUTE1;
if (isNew) DataProvider.ICSOP2RES.InsertOnSubmit(line); DataProvider.SubmitChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } //this._helper.AddDomainObject(operation2Resource);
}
public void AddOperation2Resource(ICSOP2RES[] operation2Resources) { try { foreach (ICSOP2RES operation2Res in operation2Resources) { bool isNew = false; var line = DataProvider.ICSOP2RES.SingleOrDefault(a => a.RESID == operation2Res.RESID && a.OPID == operation2Res.OPID);
if (line == null) { isNew = true; line = new ICSOP2RES(); line.OPID = operation2Res.OPID; line.RESID = operation2Res.RESID; } line.RESCODE = operation2Res.RESCODE; line.OPCODE = operation2Res.OPCODE; line.RESSEQ = operation2Res.RESSEQ; line.MUSER = operation2Res.MUSER; line.MUSERName = operation2Res.MUSERName; line.MTIME = operation2Res.MTIME; line.WorkPoint = operation2Res.WorkPoint; line.EATTRIBUTE1 = operation2Res.EATTRIBUTE1;
if (isNew) DataProvider.ICSOP2RES.InsertOnSubmit(line); } DataProvider.SubmitChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } //this._helper.AddDomainObject(operation2Resources);
}
//public void UpdateOperation2Resource(ICSOP2RES operation2Resource)
//{
// this._helper.UpdateDomainObject(operation2Resource);
//}
public void DeleteOperation2Resource(ICSOP2RES operation2Resource) { try { var lines = DataProvider.ICSOP2RES.Where(a => a.OPID == operation2Resource.OPID && a.RESID == operation2Resource.RESID);
DataProvider.ICSOP2RES.DeleteAllOnSubmit(lines);
DataProvider.SubmitChanges();
} catch (Exception ex) { throw ex; } //this._helper.DeleteDomainObject(operation2Resource);
}
public void DeleteOperation2Resource(ICSOP2RES[] operation2Resources) { try { for (int i = 0; i < operation2Resources.Length;i++ ) { var lines = DataProvider.ICSOP2RES.Where(a => a.OPID == operation2Resources[i].OPID && a.RESID == operation2Resources[i].RESID);
DataProvider.ICSOP2RES.DeleteAllOnSubmit(lines); }
DataProvider.SubmitChanges();
} catch (Exception ex) { throw ex; } }
public object GetOperation2Resource(string operationCode, string resourceCode) { try { var resline = DataProvider.ICSOP2RES.SingleOrDefault(p => p.OPCODE == operationCode && p.RESCODE == resourceCode && p.WorkPoint == AppConfig.WorkPointCode); return resline; } catch (Exception ex) { throw new Exception(ex.Message); } }
#region ICSOP --> ICSRES
/// <summary>
/// ** ��������: ��OPCODE����ICSRES
/// </summary>
/// <param name="oPCode">OPCODE,��ȷ��ѯ</param>
/// <returns>ICSRES����</returns>
public object[] GetResourceByOperationCode(string oPCode) { try { var opline=from a in DataProvider.ICSRES where (from b in DataProvider.ICSOP2RES where b.OPCODE==oPCode && b.WorkPoint==AppConfig.WorkPointCode select b.RESCODE).Contains(a.RESCODE) && a.WorkPoint==AppConfig.WorkPointCode select a; return opline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSRES), new SQLCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSRES)), oPCode)));
}
public ICSOP2RES GetOperationByResource(string rescode) { try { var opline = from a in DataProvider.ICSOP2RES where a.RESCODE == rescode && a.WorkPoint == AppConfig.WorkPointCode select a;
return opline.ToList()[0]; } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary>
/// ** ������������ICSSS����ICSRES
/// </summary>
/// <param name="ICSSS">ICSSS,��ȷ��ѯ</param>
/// <returns>ICSRES ����</returns>
public object[] GetResourceByStepSequenceCode(string StepSequenceCode) { try { var opline = from a in DataProvider.ICSRES where (from b in DataProvider.ICSSS where b.SSCODE == StepSequenceCode && b.WorkPoint == AppConfig.WorkPointCode select b.ID).Contains(a.SSID) && a.WorkPoint == AppConfig.WorkPointCode select a; return opline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSRES), new SQLCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSRES)), StepSequenceCode)));
}
/// <summary>
/// ** ��������: ��OPCODE��������ICSOP��ICSRES������
/// </summary>
/// <param name="oPCode">OPCODE,��ȷ��ѯ</param>
/// <param name="resourceCode">ResourceCode,ģ����ѯ</param>
/// <returns>ICSRES������</returns>
public int GetSelectedResourceByOperationCodeCount(string oPCode, string resourceCode) { var opline = from a in DataProvider.ICSOP2RES join b in DataProvider.ICSRES on a.RESCODE equals b.RESCODE where a.OPCODE == oPCode && b.RESCODE.StartsWith(resourceCode) && a.WorkPoint == AppConfig.WorkPointCode select new { a, b }; return opline.ToList().Count; //return this.DataProvider.GetCount(new SQLCondition(string.Format(sql, oPCode, resourceCode)));
}
public int GetResourceByOpCodeAndDctCodeCount(string oPCode, string dctCode) { var opline = from a in DataProvider.ICSOP2RES join b in DataProvider.ICSRES on a.RESCODE equals b.RESCODE where a.OPCODE == oPCode && b.DCTCODE.StartsWith(dctCode) && a.WorkPoint == AppConfig.WorkPointCode select new { a, b }; return opline.ToList().Count;
//return this.DataProvider.GetCount(new SQLCondition(string.Format(sql, oPCode, dctCode)));
}
/// <summary>
/// ** ��������: ��OPCODE��������ICSOP��ICSRES����ҳ
/// </summary>
/// <param name="oPCode">OPCODE,��ȷ��ѯ</param>
/// <param name="resourceCode">ResourceCode,ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns>ICSRES����</returns>
public object[] GetSelectedResourceByOperationCode(string oPCode, string resourceCode) { try { var opline = from a in DataProvider.ICSRES where (from b in DataProvider.ICSOP2RES where b.OPCODE == oPCode && b.WorkPoint == AppConfig.WorkPointCode select b.RESCODE).Contains(a.RESCODE) && a.RESCODE.StartsWith(resourceCode) && a.WorkPoint == AppConfig.WorkPointCode select a; return opline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSRES),
// new PagerCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSRES)), oPCode, resourceCode), "RESCODE", inclusive, exclusive));
}
public object[] GetResourceByDCTCode(string dctCode) { try { var opline = from a in DataProvider.ICSRES where a.DCTCODE==dctCode && a.WorkPoint == AppConfig.WorkPointCode select a; return opline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSRES),
//new PagerCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSRES)), dctCode), "dctcode", inclusive, exclusive));
}
/// <summary>
/// ** ��������: ��OPCODE������ICSOP��ICSRES������
/// </summary>
/// <param name="oPCode">OPCODE,��ȷ��ѯ</param>
/// <param name="resourceCode">ResourceCode,ģ����ѯ</param>
/// <returns>ICSRES������</returns>
public int GetUnselectedResourceByOperationCodeCount(string oPCode, string resourceCode) { try { var opline = from a in DataProvider.ICSRES where !(from b in DataProvider.ICSOP2RES where 1 == 1 && b.WorkPoint == AppConfig.WorkPointCode select b.RESCODE).Contains(a.RESCODE) && a.RESCODE.StartsWith(oPCode) && a.WorkPoint == AppConfig.WorkPointCode select a; return opline.ToList().Count; } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.GetCount(new SQLCondition(string.Format(sql, oPCode, resourceCode)));
}
public int GetUnselectedResourceByDCTCodeCount(string dctCode, string resourceCode) { try { var opline = from a in DataProvider.ICSRES where !a.DCTCODE.ToUpper().StartsWith(dctCode) && a.RESCODE.StartsWith(resourceCode) && a.WorkPoint == AppConfig.WorkPointCode select a; return opline.ToList().Count; } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.GetCount(new SQLCondition(string.Format(sql, dctCode, resourceCode)));
}
public int GetResourceByresAndDCTCodeCount(string resourceCode, string dctCode) { try { var opline = from a in DataProvider.ICSRES where a.DCTCODE == resourceCode && a.RESCODE.StartsWith(resourceCode) && a.WorkPoint == AppConfig.WorkPointCode select a; return opline.ToList().Count; } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.GetCount(new SQLCondition(string.Format(sql, dctCode, resourceCode)));
}
/// <summary>
/// ** ��������: ��OPCODE���ò�����ICSOP��ICSRES����ҳ
/// </summary>
/// <param name="oPCode">OPCODE,��ȷ��ѯ</param>
/// <param name="resourceCode">ResourceCode,ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns>ICSRES����</returns>
public object[] GetUnselectedResourceByOperationCode(string oPCode, string resourceCode) { try { var opline = from a in DataProvider.ICSRES where !(from b in DataProvider.ICSOP2RES where b.RESCODE.ToUpper().StartsWith(resourceCode)&& b.OPCODE==oPCode && b.WorkPoint==AppConfig.WorkPointCode select b.RESCODE).Contains(a.RESCODE) && a.RESCODE.StartsWith(resourceCode) && a.WorkPoint==AppConfig.WorkPointCode select a; return opline.ToArray();
} catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.CustomQuery(typeof(ICSRES),
// new PagerCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSRES)), oPCode, resourceCode), "RESCODE", inclusive, exclusive));
}
public object[] GetUnselectedResourceByDCTCode(string dctCode, string resourceCode) { try { var opline = from a in DataProvider.ICSRES where !(from b in DataProvider.ICSRES where b.DCTCODE.ToUpper().StartsWith(dctCode) && b.WorkPoint==AppConfig.WorkPointCode select b.RESCODE).Contains(a.RESCODE) && a.RESCODE.StartsWith(resourceCode) && a.WorkPoint==AppConfig.WorkPointCode select a; return opline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } //return this.DataProvider.CustomQuery(typeof(ICSRES),
// new PagerCondition(string.Format(sql, DomainObjectUtility.GetDomainObjectFieldsString(typeof(ICSRES)), dctCode, resourceCode), "RESCODE", inclusive, exclusive));
} /// <summary>
/// ** ��������: ��OPCODE��������ICSOP��ResourceOfOperation����ҳ
/// </summary>
/// <param name="oPCode">OPCODE,��ȷ��ѯ</param>
/// <param name="resourceCode">ResourceCode,ģ����ѯ</param>
/// <param name="inclusive">��ʼ����</param>
/// <param name="exclusive">��������</param>
/// <returns>ResourceOfOperation����</returns>
public object[] GetSelectedResourceOfOperationByOperationCode(string opCode, string resCode, int inclusive, int exclusive) { try { var opline = from a in DataProvider.ICSOP2RES join b in DataProvider.ICSRES on a.RESCODE equals b.RESCODE where a.OPCODE == opCode && b.RESCODE.StartsWith(resCode) //&& a.WorkPoint == AppConfig.WorkPointCode && b.WorkPoint == AppConfig.WorkPointCode
select new {b}; DataProvider.Connection.Close(); return opline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); } // return this.DataProvider.CustomQuery(typeof(ResourceOfOperation), new PagerCondition(string.Format(sql,
// DomainObjectUtility.GetDomainObjectFieldsStringWithTableName(typeof(ICSRES)), opCode, resCode), "TBLOP2RES.RESSEQ", inclusive, exclusive));
}
/// <summary>
/// ** ������������moCode����ICSRES
/// </summary>
/// <param name="MOCode">moCode,��ȷ��ѯ</param>
/// <returns>ICSRES ����</returns>
public object[] GetResourceByMoCode(string MOCode) {
try { var opline = from a in DataProvider.ICSRES join b in DataProvider.ICSOP2RES on a.RESCODE equals b.RESCODE join c in DataProvider.ICSOP on b.OPCODE equals c.OPCODE join d in DataProvider.ICSROUTE2OP on c.OPCODE equals d.OPCODE join e in DataProvider.ICSROUTE on d.ROUTECODE equals e.ROUTECODE join f in DataProvider.ICSMO2ROUTE on e.ROUTECODE equals f.ROUTECODE join g in DataProvider.ICSMO on f.MOCODE equals g.MOCODE where g.MOCODE == MOCode && a.WorkPoint == AppConfig.WorkPointCode && b.WorkPoint == AppConfig.WorkPointCode && c.WorkPoint == AppConfig.WorkPointCode && d.WORKPOINT == AppConfig.WorkPointCode && f.WorkPoint == AppConfig.WorkPointCode && g.WorkPoint == AppConfig.WorkPointCode orderby a.RESCODE select new { a,b,c,d,e,f,g};
return opline.ToArray(); } catch (Exception ex) { throw new Exception(ex.Message); }
//if (GlobalVariables.CurrentOrganizations.GetSQLConditionWithoutColumnName().Length > 0)
//{
// sql += " and TBLRES.ORGID in (" + GlobalVariables.CurrentOrganizations.GetSQLConditionWithoutColumnName() + ")";
//}
//return this.DataProvider.CustomQuery(typeof(ICSRES), new SQLCondition(string.Format(sql, MOCode)));
}
/// <summary>
/// ** ������������moCode����SMTResource
/// </summary>
/// <param name="MOCode">moCode,��ȷ��ѯ</param>
/// <returns>ICSRES ����</returns>
//public object[] GetSMTResourceByMoCode(string MOCode)
//{
//
// string sql = "";
// sql += "select ICSRES.* from ICSRES where RESCODE IN (select RESCODE from ICSSMTRESBOM where MOCODE = '{0}') ";
// sql += " and WorkPoint ='" + AppConfig.WorkPointCode + "'";
// sql += " ORDER BY TBLRES.rescode ";
// // End Added
// return this.DataProvider.CustomQuery(typeof(ICSRES), new SQLCondition(string.Format(sql, MOCode)));
//}
#endregion
#endregion
#region ICSROUTE --> ICSOP --> ICSRES
/// <summary>
/// ** ��������: ��ICSROUTE��ICSRES����ICSOP
/// </summary>
/// <param name="routeCode">RouteCode</param>
/// <param name="resourceCode">ResourceCode</param>
/// <returns></returns>
public object GetOperationByRouteAndResource(string routeCode, string resourceCode) { try { var resline = from a in DataProvider.ICSOP join b in DataProvider.ICSROUTE2OP on a.OPCODE equals b.OPCODE join c in DataProvider.ICSOP2RES on a.OPCODE equals c.OPCODE where b.ROUTECODE == routeCode && c.RESCODE == resourceCode select a; return resline.ToList()[0] ; } catch (Exception ex) { throw new Exception(ex.Message); }
// object[] objs = this.DataProvider.CustomQuery(typeof(ICSOP), new SQLCondition(string.Format(@"select {0} from TBLOP,TBLROUTE2OP,TBLOP2RES where TBLOP.OPCODE = TBLOP2RES.OPCODE and
// TBLOP.OPCODE = TBLROUTE2OP.OPCODE and TBLROUTE2OP.ROUTECODE='{1}' and TBLOP2RES.RESCODE='{2}'",
// DomainObjectUtility.GetDomainObjectFieldsStringWithTableName(typeof(ICSOP)), routeCode, resourceCode)));
//if (objs != null && objs.Length > 0)
//{
// return objs[0];
//}
//return null;
}
/// <summary>
/// ** ��������: ����ICSROUTE�ĵ�һ��ICSOP
/// </summary>
/// <param name="routeCode">RouteCode</param>
/// <returns></returns>
public object GetFirstOperationOfRoute(string routeCode) { var resline = from a in DataProvider.ICSOP join b in DataProvider.ICSROUTE2OP on a.OPCODE equals b.OPCODE where b.ROUTECODE == routeCode && a.WorkPoint == AppConfig.WorkPointCode && b.WORKPOINT == AppConfig.WorkPointCode orderby b.OPSEQ select a.OPCODE; try {
if (resline != null && resline.ToList().Count > 0) { return resline.ToList()[0]; } else { return null; } } catch (Exception ex) { throw new Exception(ex.Message); } //object[] objs = this.DataProvider.CustomQuery(typeof(ICSOP), new SQLCondition(string.Format(@"select routeCode from TBLOP,TBLROUTE2OP where TBLOP.OPCODE = TBLROUTE2OP.OPCODE and TBLROUTE2OP.ROUTECODE='{1}' order by TBLROUTE2OP.OPSEQ",
// DomainObjectUtility.GetDomainObjectFieldsStringWithTableName(typeof(ICSOP)), routeCode)));
}
/// <summary>
/// ** ��������: ����ICSROUTE����һ��ICSOP
/// </summary>
/// <param name="routeCode">RouteCode</param>
/// <param name="currentOperationCode">��ǰOP</param>
/// <returns></returns>
public object GetNextOperationOfRoute(string routeCode, string currentOperationCode) { try { var opline = from a in DataProvider.ICSOP join b in DataProvider.ICSROUTE2OP on a.OPCODE equals b.OPCODE where b.ROUTECODE == routeCode && (from c in DataProvider.ICSROUTE2OP where c.ROUTECODE == routeCode && c.OPCODE == currentOperationCode && c.WORKPOINT == AppConfig.WorkPointCode select c.OPSEQ).Equals(b.OPSEQ-1) && a.OPCODE == currentOperationCode && a.WorkPoint == AppConfig.WorkPointCode select new { a };
if (opline != null && opline.ToList().Count > 0) { return opline.ToList()[0]; } else { return null; } } catch (Exception ex) { throw new Exception(ex.Message); } //operations = this.DataProvider.CustomQuery(typeof(ICSOP), new SQLCondition(string.Format("select {0} from TBLOP,TBLROUTE2OP where TBLOP.OPCODE = TBLROUTE2OP.OPCODE and TBLROUTE2OP.ROUTECODE='{1}' and TBLROUTE2OP.OPSEQ > {2} order by TBLROUTE2OP.OPSEQ",
// DomainObjectUtility.GetDomainObjectFieldsStringWithTableName(typeof(ICSOP)), routeCode, ((ICSROUTE2OP)relation).OPSEQ)));
}
#region this is for cs
public ICSITEMROUTE2OP GetMORouteFirstOperation(string moCode, string routeCode) { ICSMO mo = this._domainDataProvider.ICSMO.SingleOrDefault(a => a.MOCODE == moCode && a.WorkPoint == AppConfig.WorkPointCode ); string selectSql = " select * " + " from ICSITEMROUTE2OP where itemcode = '" + mo.ITEMCODE + "' and routecode = '" + routeCode + "' and " + " opseq = (select min(opseq) from ICSITEMROUTE2OP" + " where itemcode = '" + mo.ITEMCODE + "' and routecode = '" + routeCode + "' And workpoint = '" + AppConfig.WorkPointCode + "')"; List<ICSITEMROUTE2OP> list = this.DataProvider.ExecuteQuery<ICSITEMROUTE2OP>(selectSql).ToList(); if (list == null || list.Count ==1) { throw new Exception("$Error_ItemRoute_NotExist" + String.Format("[$Itemcode='{0}',$routecode='{1}']", mo.ITEMCODE, routeCode)); } return (ICSITEMROUTE2OP)list[0]; }
public ICSITEMROUTE2OP GetMORouteNextOperation(string moCode, string routeCode, string opCode) { ICSMO mo = this._domainDataProvider.ICSMO.SingleOrDefault(a => a.MOCODE == moCode && a.WorkPoint == AppConfig.WorkPointCode); if (mo == null) { throw new Exception("$Error_MONotExisted"); } string selectSql = " select * " + " from ICSITEMROUTE2OP where itemcode = '" + mo.ITEMCODE + "' and routecode = '" + routeCode + "' " + " and workpoint = '"+AppConfig.WorkPointCode+"'" + " and opseq > (select opseq from ICSITEMROUTE2OP" + " where itemcode = '" + mo.ITEMCODE + "' and routecode = '" + routeCode + "' and opcode='" + opCode + "' and workpoint = '" + AppConfig.WorkPointCode + "' order by opseq"; List<ICSITEMROUTE2OP> list = this.DataProvider.ExecuteQuery<ICSITEMROUTE2OP>(selectSql).ToList(); if (list == null || list.Count == 1) { throw new Exception("$Error_ItemRoute_NotExist" + String.Format("[$Itemcode='{0}',$routecode='{1}']", mo.ITEMCODE, routeCode)); }
return (ICSITEMROUTE2OP)list[0]; }
public bool OperationIsRouteLastOperation(string moCode, string routeCode, string OpCode) { ICSMO mo = this._domainDataProvider.ICSMO.SingleOrDefault(a => a.MOCODE == moCode && a.WorkPoint == AppConfig.WorkPointCode); if (mo == null) { throw new Exception("$Error_MONotExisted"); } string selectSql = " select count(*) " + " from ICSITEMROUTE2OP where itemcode = '" + mo.ITEMCODE + "' and routecode = '" + routeCode + "' And workpoint = '"+AppConfig.WorkPointCode+"'" + " and opseq = (select max(opseq) from ICSITEMROUTE2OP" + " where itemcode = '" + mo.ITEMCODE + "' and routecode = '" + routeCode + "' And workpoint = '" + AppConfig.WorkPointCode + "') and opcode='" + OpCode + "'"; var query = this.DataProvider.ExecuteQuery<int>(selectSql); int iCount = query.First<int>(); if (iCount > 0) { return true; } return false;
}
#endregion
#endregion
#region Time Period
/// <summary>
/// ** ��������: ����Shift�����е�TimePeriod
/// ** �� ��:
/// ** �� ��:
/// </summary>
/// <param name="shiftCode">ShiftCode</param>
/// <returns>TimePeriod����</returns>
public List<ICSTP> GetTimePeriodByShiftCode(string shiftCode) { string sqlStr = "select * from ICSLTP where SHIFTCODE='"+shiftCode+"' order by TPSEQ"; return this.DataProvider.ExecuteQuery<ICSTP>(sqlStr).ToList(); }
public object GetTimePeriod(string timePeriodCode) { return this.DataProvider.ICSTP.SingleOrDefault(a => a.TPCODE == timePeriodCode && a.WorkPoint == AppConfig.WorkPointCode); }
/// <summary>
/// ��ȡTimePeriod��ʼʱ��
/// </summary>
/// <param name="timePeriodCode"></param>
/// <returns></returns>
public int GetTimePeriodBeginTime(string timePeriodCode) {
return this.DataProvider.ICSTP.SingleOrDefault(a => a.TPCODE == timePeriodCode && a.WorkPoint == AppConfig.WorkPointCode).TPBTIME; }
/// <summary>
/// ��ȡTimePeriod����ʱ��
/// </summary>
/// <param name="timePeriodCode"></param>
/// <returns></returns>
public int GetTimePeriodEndTime(string timePeriodCode) { return this.DataProvider.ICSTP.SingleOrDefault(a => a.TPCODE == timePeriodCode && a.WorkPoint == AppConfig.WorkPointCode).TPETIME; }
public int GetShiftDay(ICSTP currentTimePeriod, DateTime currentDateTime) { int shiftDay = FormatHelper.TODateInt(currentDateTime);
if (currentTimePeriod != null) { if (currentTimePeriod.ISOVERDATE == FormatHelper.TRUE_STRING) { if (currentTimePeriod.TPBTIME < currentTimePeriod.TPETIME) { shiftDay = FormatHelper.TODateInt(currentDateTime.AddDays(-1)); } else if (FormatHelper.TOTimeInt(currentDateTime) < currentTimePeriod.TPBTIME) { shiftDay = FormatHelper.TODateInt(currentDateTime.AddDays(-1)); } } }
return shiftDay; }
public int GetShiftDayBySS(ICSSS stepSequence, DateTime currentDateTime) { int returnValue = FormatHelper.TODateInt(currentDateTime);
if (stepSequence != null) { ICSTP tp = (ICSTP)GetTimePeriod(stepSequence.SHIFTTYPEID, FormatHelper.TOTimeInt(currentDateTime)); if (tp != null) { returnValue = GetShiftDay(tp, currentDateTime); } }
return returnValue; }
public ICSSHIFT GetShift(string shiftTypeId, int time) { ICSSHIFT returnValue = null; ICSTP tp = (ICSTP)GetTimePeriod(shiftTypeId, time); if (tp != null) { returnValue = this.DataProvider.ICSSHIFT.SingleOrDefault(a => a.ID == tp.SHIFTID); }
return returnValue; }
/// <summary>
/// ** ��������: ���ݸ���ʱ�估ShiftType ����Ψһ�� TimePeriod
/// ** �� ��: Jane Shu
/// ** �� ��: 2005-03-08
/// ** �� ��: Jane Shu
/// ** �� ��: 2005-07-25
/// </summary>
/// <param name="shiftTypeCode"></param>
/// <param name="time"></param>
/// <returns></returns>
public object GetTimePeriod(string shiftTypeId, int time) {
string sqlStr = @"select * from icstp where shifttypeid= '"+shiftTypeId+@"' and (
(tpbtime < tpetime and " +time+@" between tpbtime and tpetime ) or (tpbtime > tpetime and " + time + @" < tpbtime and " + time + @" + 240000 between tpbtime and tpetime + 240000) or (tpbtime > tpetime and " + time + @" > tpbtime and " + time + @" between tpbtime and tpetime + 240000) )";
List < ICSTP > list = this.DataProvider.ExecuteQuery<ICSTP>(sqlStr).ToList(); if (list != null && list.Count > 0) { return list[0]; }
return null; }
#endregion
} }
|