/// <summary> /// 获取T_FB_ORDERCODE信息 /// </summary> /// <param name="strOrderCodeId">主键索引</param> /// <returns></returns> public T_FB_ORDERCODE GetOrderCodeByID(string strOrderCodeId) { if (string.IsNullOrEmpty(strOrderCodeId)) { return(null); } OrderCodeDAL dalOrderCode = new OrderCodeDAL(); StringBuilder strFilter = new StringBuilder(); List <string> objArgs = new List <string>(); if (!string.IsNullOrEmpty(strOrderCodeId)) { strFilter.Append(" TABLENAME == @0"); objArgs.Add(strOrderCodeId); } T_FB_ORDERCODE entRd = dalOrderCode.GetOrderCodeRdByMultSearch(strFilter.ToString(), objArgs.ToArray()); return(entRd); }
public static string GetOrderCode(T_FB_ORDERCODE orderCode) { lock (lockObject) { DateTime CurrentDate = orderCode.CURRENTDATE.Value; if (CurrentDate.Date != System.DateTime.Now.Date) { orderCode.CURRENTDATE = System.DateTime.Now.Date; orderCode.RUNNINGNUMBER = 1; } string shortName = orderCode.PRENAME; decimal curNumber = orderCode.RUNNINGNUMBER.Value; string strDate = orderCode.CURRENTDATE.Value.ToString("yyyyMMdd"); string code = shortName + "_" + strDate + curNumber.ToString().PadLeft(6, '0'); orderCode.RUNNINGNUMBER = Convert.ToInt32(curNumber + 1); using (FBEntityBLL bll = new FBEntityBLL()) { bll.BassBllSave(orderCode, FBEntityState.Modified); } return(code); } }
public static string GetOrderCode(T_FB_ORDERCODE orderCode) { lock (lockObject) { DateTime CurrentDate = orderCode.CURRENTDATE.Value; if (CurrentDate.Date != System.DateTime.Now.Date) { orderCode.CURRENTDATE = System.DateTime.Now.Date; orderCode.RUNNINGNUMBER = 1; } string shortName = orderCode.PRENAME; decimal curNumber = orderCode.RUNNINGNUMBER.Value; string strDate = orderCode.CURRENTDATE.Value.ToString("yyyyMMdd"); string code = shortName + "_" + strDate + curNumber.ToString().PadLeft(6, '0'); orderCode.RUNNINGNUMBER = Convert.ToInt32(curNumber + 1); using (FBEntityBLL bll = new FBEntityBLL()) { bll.BassBllSave(orderCode, FBEntityState.Modified); } return code; } }
/// <summary> /// 获取单据编号 /// </summary> /// <param name="entity"></param> /// <returns></returns> //public static string GetAutoOrderCode(EntityObject entity) //{ // string strRes = string.Empty; // string tablename = GetTableName(entity); // if (string.IsNullOrWhiteSpace(tablename)) // { // return strRes; // } // OrderCodeDAL dalOrderCode = new OrderCodeDAL(); // var ents = from n in dalOrderCode.GetObjects<T_FB_ORDERCODE>() // where n.TABLENAME == tablename // select n; // T_FB_ORDERCODE orderCode = ents.FirstOrDefault(); // if (orderCode == null) // { // return strRes; // } // DateTime CurrentDate = orderCode.CURRENTDATE.Value; // if (CurrentDate.Date != System.DateTime.Now.Date) // { // orderCode.CURRENTDATE = System.DateTime.Now.Date; // orderCode.RUNNINGNUMBER = 1; // } // string shortName = orderCode.PRENAME; // decimal curNumber = orderCode.RUNNINGNUMBER.Value; // string strDate = orderCode.CURRENTDATE.Value.ToString("yyyyMMdd"); // string code = shortName + "_" + strDate + curNumber.ToString().PadLeft(6, '0'); // orderCode.RUNNINGNUMBER = curNumber + 1; // dalOrderCode.Update(orderCode); // return code; //} /// <summary> /// 获取单据编号 /// </summary> /// <param name="entity"></param> /// <returns></returns> public string GetAutoOrderCode(EntityObject entity) { string strRes = string.Empty; string tablename = GetTableName(entity); if (string.IsNullOrWhiteSpace(tablename)) { return(strRes); } OrderCodeDAL dalOrderCode = new OrderCodeDAL(); var ents = from n in dalOrderCode.GetObjects <T_FB_ORDERCODE>() where n.TABLENAME == tablename select n; T_FB_ORDERCODE orderCode = ents.FirstOrDefault(); if (orderCode == null) { return(strRes); } string shortName = orderCode.PRENAME; DateTime CurrentDate = orderCode.CURRENTDATE.Value; if (CurrentDate.Date != System.DateTime.Now.Date) { orderCode.CURRENTDATE = System.DateTime.Now.Date; orderCode.RUNNINGNUMBER = 1; lock (this) { string strclear = @"declare n number(10); tsql varchar2(1000); begin select " + tablename + "_SEQ.nextval into n from dual; " + " n:=-(n);" + " tsql:= 'alter sequence " + tablename + "_SEQ increment by '|| n;" + " execute immediate tsql; " + " select " + tablename + "_SEQ.nextval into n from dual; " + " tsql:= 'alter sequence " + tablename + "_SEQ increment by 1 '; " + " execute immediate tsql; " + " end; "; dalOrderCode.ExecuteCustomerSql(strclear); //string strclear = " DROP SEQUENCE T_FB_CHARGEAPPLYMASTER_SEQ "; //dalOrderCode.ExecuteCustomerSql(strclear); //strclear = " create sequence T_FB_CHARGEAPPLYMASTER_SEQ minvalue 0 maxvalue 999999999999999999999999999 start with 1 increment by 1 cache 20 "; //dalOrderCode.ExecuteCustomerSql(strclear); } } decimal curNumber = 0; string strNextSqense = @" select " + tablename + "_SEQ.nextval from dual"; curNumber = decimal.Parse(dalOrderCode.ExecuteCustomerSql(strNextSqense).ToString()); string strDate = orderCode.CURRENTDATE.Value.ToString("yyyyMMdd"); string code = shortName + "_" + strDate + curNumber.ToString().PadLeft(6, '0'); orderCode.RUNNINGNUMBER = Convert.ToInt32(curNumber + 1); dalOrderCode.Update(orderCode); return(code); }
public static T_FB_ORDERCODE CreateT_FB_ORDERCODE(string tABLENAME, string fIELDNAME) { T_FB_ORDERCODE t_FB_ORDERCODE = new T_FB_ORDERCODE(); t_FB_ORDERCODE.TABLENAME = tABLENAME; t_FB_ORDERCODE.FIELDNAME = fIELDNAME; return t_FB_ORDERCODE; }
public void AddToT_FB_ORDERCODE(T_FB_ORDERCODE t_FB_ORDERCODE) { base.AddObject("T_FB_ORDERCODE", t_FB_ORDERCODE); }
/// <summary> /// 获取单据编号 /// </summary> /// <param name="entity"></param> /// <returns></returns> public string GetAutoOrderCode(string tablename) { string strclear = string.Empty; try { string strRes = string.Empty; if (string.IsNullOrWhiteSpace(tablename)) { return(strRes); } var ents = from n in GetTable <T_FB_ORDERCODE>() where n.TABLENAME == tablename select n; T_FB_ORDERCODE orderCode = ents.FirstOrDefault(); if (orderCode == null) { return(strRes); } string shortName = orderCode.PRENAME; DateTime CurrentDate = orderCode.CURRENTDATE.Value; using (BaseDAL dal = new BaseDAL()) { Tracer.Debug("模块代码:" + tablename); switch (tablename) { case "T_FB_COMPANYBUDGETAPPLYMASTER": tablename = "T_FB_COMPANYBUDGETAPPLY"; //名称太长导致无法创建sequence break; case "T_FB_COMPANYBUDGETMODMASTER": tablename = "T_FB_COMPANYBUDGETMOD"; //名称太长导致无法创建sequence break; case "T_FB_COMPANYBUDGETSUMMASTER": tablename = "T_FB_COMPANYBUDGETSUM"; //名称太长导致无法创建sequence break; case "T_FB_PERSONMONEYASSIGNMASTER": tablename = "T_FB_PERSONMONEYASSIGN"; //名称太长导致无法创建sequence break; default: break; } if (CurrentDate.Date != System.DateTime.Now.Date) { orderCode.CURRENTDATE = System.DateTime.Now.Date; orderCode.RUNNINGNUMBER = 1; strclear = @"declare n number(10); tsql varchar2(1000); begin select " + tablename + "_SEQ.nextval into n from dual; " + " n:=-(n);" + " tsql:= 'alter sequence " + tablename + "_SEQ increment by '|| n;" + " execute immediate tsql; " + " select " + tablename + "_SEQ.nextval into n from dual; " + " tsql:= 'alter sequence " + tablename + "_SEQ increment by 1 '; " + " execute immediate tsql; " + " end; "; Tracer.Debug("ExecuteCustomerSql:" + strclear); dal.ExecuteCustomerSql(strclear); } decimal curNumber = 0; string strNextSqense = @" select " + tablename + "_SEQ.nextval from dual"; Tracer.Debug("调用新生成单号接口:tablename:" + tablename + " ExecuteCustomerSql:" + strNextSqense); curNumber = decimal.Parse(dal.ExecuteCustomerSql(strNextSqense).ToString()); string strDate = orderCode.CURRENTDATE.Value.ToString("yyyyMMdd"); string code = shortName + "_" + strDate + curNumber.ToString().PadLeft(6, '0'); Tracer.Debug("生成单号:" + code); orderCode.RUNNINGNUMBER = Convert.ToInt32(curNumber + 1); Update(orderCode); return(code); } } catch (Exception ex) { Tracer.Debug("ExecuteCustomerSql:" + strclear + ex.ToString()); throw (ex); } }
public static void AddAutoOrderCode(EntityObject entity) { string tablename = GetTableName(entity); T_FB_ORDERCODE orderCode = listOrderCode.FirstOrDefault(item => { return(item.TABLENAME == tablename); }); if (orderCode == null) { Tracer.Debug("生成编号失败:在T_FB_ORDERCODE表中未找到此表配置项目:" + tablename); return; } //string code = GetOrderCode(orderCode);张秉福旧方法 //新方法 string code = string.Empty; using (OrderCodeBLL bll = new OrderCodeBLL()) { code = bll.GetAutoOrderCode(tablename); } string codePropertyName = orderCode.FIELDNAME; entity.SetValue(codePropertyName, code); //开始更新元数据单号 string Formid = string.Empty; Tracer.Debug("开始更新元数据:" + tablename); try { switch (tablename) { case "T_FB_TRAVELEXPAPPLYMASTER": //T_FB_TRAVELEXPAPPLYMASTER item = (T_FB_TRAVELEXPAPPLYMASTER)entity; //Formid = item.T_FB_EXTENSIONALORDER.ORDERID; //出差报销在OA中出差报销审核的业务逻辑中处理 break; default: Formid = entity.EntityKey.EntityKeyValues[0].Value.ToString(); SMT.SaaS.BLLCommonServices.FlowWFService.ServiceClient client = new SaaS.BLLCommonServices.FlowWFService.ServiceClient(); Tracer.Debug("开始调用元数据获取接口:FlowWFService.GetMetadataByFormid(" + Formid + ")"); string xml = string.Empty; xml = client.GetMetadataByFormid(Formid); if (string.IsNullOrEmpty(xml)) { Tracer.Debug("XML元数据为空,跳过:" + xml); break; } Tracer.Debug("获取到的元数据:" + xml); xml = xml.Replace("自动生成", code); Tracer.Debug("替换单号后的XML:" + xml); client.UpdateMetadataByFormid(Formid, xml); break; } } catch (Exception ex) { Tracer.Debug(ex.ToString()); } }