public void Insert(LanguageWord languageObject, string language) { try { CheckLanguage(language); if (_domainDataProvider.CustomSearch(typeof(LanguageWord), new string[] { "ControlID" }, new object[] { languageObject.ControlID }) != null) { if (language.IndexOf(LanguageType.English) != -1) { _domainDataProvider.CustomUpdate(languageObject, new string[] { "ControlENText" }, new object[] { languageObject.ControlENText }); } if (language.IndexOf(LanguageType.SimplifiedChinese) != -1) { _domainDataProvider.CustomUpdate(languageObject, new string[] { "ControlCHSText" }, new object[] { languageObject.ControlCHSText }); } if (language.IndexOf(LanguageType.TraditionalChinese) != -1) { _domainDataProvider.CustomUpdate(languageObject, new string[] { "ControlCHTText" }, new object[] { languageObject.ControlCHTText }); } } else { _domainDataProvider.Insert(languageObject); } } catch (Exception ex) { //throw new Exception(languageObject.ControlID + ":" + languageObject.ControlCHSText + ":" + ex.Message, ex); ExceptionManager.Raise(this.GetType(), "$Error_Language_Object", string.Format("[$ControlCHSText={0}]", languageObject.ControlCHSText), ex); } }
public void Insert(LanguageWord languageObject, string language) { try { CheckLanguage(language); if (_domainDataProvider.CustomSearch(typeof(LanguageWord), new string[] { "ControlID" }, new object[] { languageObject.ControlID }) != null) { if (language.IndexOf("ENU") != -1) { _domainDataProvider.CustomUpdate(languageObject, new string[] { "ControlENText" }, new object[] { languageObject.ControlENText }); } if (language.IndexOf("CHS") != -1) { _domainDataProvider.CustomUpdate(languageObject, new string[] { "ControlCHSText" }, new object[] { languageObject.ControlCHSText }); } if (language.IndexOf("CHT") != -1) { _domainDataProvider.CustomUpdate(languageObject, new string[] { "ControlCHTText" }, new object[] { languageObject.ControlCHTText }); } } else { _domainDataProvider.Insert(languageObject); } } catch (Exception ex) { throw new Exception(languageObject.ControlID + ":" + languageObject.ControlCHSText + ":" + ex.Message, ex); } }
public void SetUp() { _domainDataProvider = DomainDataProviderManager.DomainDataProvider(); if (_domainDataProvider.CustomSearch(typeof(User), new object[] { "UserCode" }) == null) { User user = new User(); user.UserCode = "UserCode"; user.UserPassword = "******"; user.UserDepartment = "GRD2"; user.MaintainUser = "******"; user.MaintainDate = 20050412; user.MaintainTime = 190212; _domainDataProvider.Insert(user); } }
public void ImportWorkPlan(bool isRollBack) { ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this._DataProvider); DBDateTime now = FormatHelper.GetNowDBDateTime(this._DataProvider); object[] objs = ConvertArrayListToObjectArray(_ImportDataTable); object[] objDt = ConvertArrayListToObjectArray(_ImportDataTable); try { _DataProvider.BeginTransaction(); if (objs != null && objDt != null) { for (int i = 0; i < objs.Length; i++) { try { GridRecord row = _ImportGridRow[i] as GridRecord; WorkPlan workPlanFromExcel = objs[i] as WorkPlan; int shiftDay = shiftModelFacade.GetShiftDayByBigSSCode(workPlanFromExcel.BigSSCode, now.DateTime); if (_MaterialFacade == null) { _MaterialFacade = new MaterialFacade(_DataProvider); } WorkPlan objWorkPlanFromDB = (WorkPlan)_MaterialFacade.GetWorkPlan(workPlanFromExcel.BigSSCode, workPlanFromExcel.PlanDate, workPlanFromExcel.MoCode, workPlanFromExcel.MoSeq); if (objWorkPlanFromDB != null) { ((WorkPlan)objs[i]).MaterialQty = objWorkPlanFromDB.MaterialQty; ((WorkPlan)objs[i]).ActQty = objWorkPlanFromDB.ActQty; ((WorkPlan)objs[i]).MaterialStatus = objWorkPlanFromDB.MaterialStatus; ((WorkPlan)objs[i]).ActionStatus = objWorkPlanFromDB.ActionStatus; ((WorkPlan)objs[i]).ItemCode = objWorkPlanFromDB.ItemCode; ((WorkPlan)objs[i]).PromiseTime = objWorkPlanFromDB.PromiseTime; ((WorkPlan)objs[i]).LastReqTime = objWorkPlanFromDB.LastReqTime; ((WorkPlan)objs[i]).LastReceiveTime = objWorkPlanFromDB.LastReceiveTime; ((WorkPlan)objs[i]).PlanEndTime = objWorkPlanFromDB.PlanEndTime; ((WorkPlan)objDt[i]).MaterialQty = objWorkPlanFromDB.MaterialQty; ((WorkPlan)objDt[i]).ActQty = objWorkPlanFromDB.ActQty; ((WorkPlan)objDt[i]).MaterialStatus = objWorkPlanFromDB.MaterialStatus; ((WorkPlan)objDt[i]).ActionStatus = objWorkPlanFromDB.ActionStatus; ((WorkPlan)objDt[i]).ItemCode = objWorkPlanFromDB.ItemCode; ((WorkPlan)objDt[i]).PromiseTime = objWorkPlanFromDB.PromiseTime; ((WorkPlan)objDt[i]).LastReqTime = objWorkPlanFromDB.LastReqTime; ((WorkPlan)objDt[i]).LastReceiveTime = objWorkPlanFromDB.LastReceiveTime; ((WorkPlan)objDt[i]).PlanEndTime = objWorkPlanFromDB.PlanEndTime; _DataProvider.Update(objs[i]); _DataProvider.Update(objDt[i]); row.Items.FindItemByKey("ImportResult").Text = _LanguageComponent1.GetString("$CycleImport_Success"); row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue"; } else { if ((workPlanFromExcel.PlanDate) >= shiftDay) { _DataProvider.Insert(objDt[i]); row.Items.FindItemByKey("ImportResult").Text = _LanguageComponent1.GetString("$CycleImport_Success"); row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue"; } } } catch (Exception ex) { GridRecord row = _ImportGridRow[i] as GridRecord; row.Items.FindItemByKey("ImportResult").Text = _LanguageComponent1.GetString("$CycleImport_Error"); row.Items.FindItemByKey("ImportResult").CssClass = "ForeColorRed"; this.ErrorArray.Add(ex); } } } _DataProvider.CommitTransaction(); } catch (Exception ex) { _DataProvider.RollbackTransaction(); this.ErrorArray.Add(ex); } }
protected void AssignData() { if (!(((Array)_data.Content[0]).Length > 1)) { return; //如果是空行,不操作 } int len = _format.ObjectMap.ColumnFormats.Length; Type type = Type.GetType(_format.ObjectMap.ObjectTypeName); object obj = type.Assembly.CreateInstance(_format.ObjectMap.ObjectTypeName.Split(new char[] { ',' })[0].ToString()); for (int i = 0; i < len; i++) { ColumnFormat col = _format.ObjectMap.ColumnFormats[i]; string attributeName = col.AttributeName; string columnName = col.ColumnName; // vizo:这里要获得数据的实际值 string objValue = string.Empty; switch (col.DataSource) { case DataSource.FileName: objValue = GetSubString(_data.GetFileName(col.DataLine, col.DataColumn), col.DataStringFrom, col.DataStringTo); break; case DataSource.Header: objValue = GetSubString(_data.GetHeader(col.DataLine, col.DataColumn), col.DataStringFrom, col.DataStringTo);; break; case DataSource.Content: objValue = GetSubString(_data.GetContent(col.DataLine, col.DataColumn), col.DataStringFrom, col.DataStringTo);; break; case DataSource.DefaultValue: objValue = col.Default; break; default: objValue = col.Default; break; } //added by jessie lee,2005/9/28 //对取出的数据进行trim objValue = objValue.Trim(); //objValue = this.SubStringStr(objValue); if (objValue == string.Empty) { objValue = col.Default; } // 数据强行转换 try { if (col.DataType == BenQGuru.eMES.Web.Helper.DataType.Int) { objValue = this.ConvertToInt(objValue).ToString(); } else if (col.DataType == BenQGuru.eMES.Web.Helper.DataType.Float) { objValue = this.ConvertToFloat(objValue).ToString(); } else if (col.DataType == BenQGuru.eMES.Web.Helper.DataType.DateTime) { objValue = this.ConvertToDateTimeFloat(objValue).ToString("#"); } else if (col.DataType == BenQGuru.eMES.Web.Helper.DataType.Date) { objValue = this.ConvertToDateFloat(objValue).ToString("#"); } else if (col.DataType == BenQGuru.eMES.Web.Helper.DataType.Time) { objValue = this.ConvertToTimeFloat(objValue).ToString("#"); } BenQGuru.eMES.Common.Domain.DomainObjectUtility.SetValue(obj, attributeName, objValue); } catch { throw new Exception("$Format_Error [$Line=" + (_ary.Count + 1).ToString() + " $Column=" + (i + 1).ToString() + " $Data=" + objValue + "]"); } } // vizo 2005-04-14 // 多加了一个委托的判断 bool objectValid = true; if (this.CheckValidHandle != null) { objectValid = this.CheckValidHandle(obj); } // 如果 object 是无效的,不操作 if (objectValid) { _ary.Add(obj); if (_format.SaveDataDirectly) { _dataProvider.Insert(obj); } } }
/// <summary> /// /// </summary> /// <param name="isRollBack">true:出错就回滚;false:出错skip到下一个</param> public void Import(bool isRollBack) { ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this._dataProvider); DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this._dataProvider); object[] objDt = null; if (string.Compare(ImportType, "IndirectManCount", true) == 0) { objDt = ConvertArrayListToObjectArray(ImportDatatable, "IndirectManCount"); } if (string.Compare(ImportType, "Line2Crew", true) == 0) { objDt = ConvertArrayListToObjectArray(ImportDatatable, "Line2Crew"); } try { _dataProvider.BeginTransaction(); if (string.Compare(ImportType, "IndirectManCount", true) == 0) { if (objDt != null) { for (int i = 0; i < objDt.Length; i++) { try { GridRecord row = ImportGridRow[i] as GridRecord; IndirectManCount IndirectManCountExcel = objDt[i] as IndirectManCount; if (_Facade == null) { _Facade = new PerformanceFacade(_dataProvider); } IndirectManCount getWorkPlanFromDB = (IndirectManCount)_Facade.GetIndirectManCount(IndirectManCountExcel.ShiftDate, IndirectManCountExcel.ShiftCode, IndirectManCountExcel.CrewCode, IndirectManCountExcel.FactoryCode, IndirectManCountExcel.FirstClass); if (getWorkPlanFromDB != null) { ((IndirectManCount)objDt[i]).FactoryCode = IndirectManCountExcel.FactoryCode; ((IndirectManCount)objDt[i]).FirstClass = IndirectManCountExcel.FirstClass; _dataProvider.Update(objDt[i]); row.Items.FindItemByKey("ImportResult").Text = _languageComponent1.GetString("$CycleImport_Success"); row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue"; } else { _dataProvider.Insert(objDt[i]); row.Items.FindItemByKey("ImportResult").Text = _languageComponent1.GetString("$CycleImport_Success"); row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue"; } } catch (Exception ex) { GridRecord row = ImportGridRow[i] as GridRecord; row.Items.FindItemByKey("ImportResult").Text = _languageComponent1.GetString("$CycleImport_Error"); row.Items.FindItemByKey("ImportResult").CssClass = "ForeColorRed"; this.ErrorArray.Add(ex); } } } } if (string.Compare(ImportType, "Line2Crew", true) == 0) { if (objDt != null) { for (int i = 0; i < objDt.Length; i++) { try { GridRecord row = ImportGridRow[i] as GridRecord; Line2Crew Line2CrewExcel = objDt[i] as Line2Crew; if (_Facade == null) { _Facade = new PerformanceFacade(_dataProvider); } Line2Crew getLine2CrewFromDB = (Line2Crew)_Facade.GetLine2Crew(Convert.ToInt32(Line2CrewExcel.ShiftDate), Line2CrewExcel.SSCode.ToString(), Line2CrewExcel.ShiftCode); if (getLine2CrewFromDB != null) { getLine2CrewFromDB.CrewCode = Line2CrewExcel.CrewCode; _dataProvider.Update(getLine2CrewFromDB); row.Items.FindItemByKey("ImportResult").Text = _languageComponent1.GetString("$CycleImport_Success"); row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue"; } else { _dataProvider.Insert(objDt[i]); row.Items.FindItemByKey("ImportResult").Text = _languageComponent1.GetString("$CycleImport_Success"); row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue"; } } catch (Exception ex) { GridRecord row = ImportGridRow[i] as GridRecord; row.Items.FindItemByKey("ImportResult").Text = _languageComponent1.GetString("$CycleImport_Error"); row.Items.FindItemByKey("ImportResult").CssClass = "ForeColorRed"; this.ErrorArray.Add(ex); } } } } _dataProvider.CommitTransaction(); } catch (Exception ex) { _dataProvider.RollbackTransaction(); this.ErrorArray.Add(ex); } }