/// <summary> /// Aborts the import. /// </summary> /// <param name="importHistory">The import history.</param> private void AbortImport(IImportHistory importHistory) { try { IRepository <IImportHistory> rep = EntityFactory.GetRepository <IImportHistory>(); IQueryable qry = (IQueryable)rep; IExpressionFactory ep = qry.GetExpressionFactory(); Sage.Platform.Repository.ICriteria crit = qry.CreateCriteria(); crit.Add(ep.Eq("Id", importHistory.Id)); IProjections projections = qry.GetProjectionsFactory(); crit.SetProjection(projections.Property("ProcessState")); object state = crit.UniqueResult(); if (state != null) { ImportProcessState processState = (ImportProcessState)Enum.Parse(typeof(ImportProcessState), state.ToString()); if (!processState.Equals(ImportProcessState.Completed) || !processState.Equals(ImportProcessState.Abort)) { SetProcessState(importHistory.Id.ToString(), Enum.GetName(typeof(ImportProcessState), ImportProcessState.Abort), "Aborted"); } } } catch (Exception) { //throw new ApplicationException("Error getting process state"); } }
public virtual void Validate(ImportProcessState item) { string strMsg = string.Empty; if (item.Feed.ID <= 0) { strMsg += "FeedId Id nao pode ser menor ou igual a zero." + Environment.NewLine; } if (strMsg != string.Empty) { throw new TebaldiMarketDataException(strMsg); } }
/// <summary> /// Loads the form. /// </summary> private void LoadForm() { IImportHistory importHistory = BindingSource.Current as IImportHistory; if (importHistory != null) { txtImportFileName.Text = importHistory.Description; txtStatus.Text = importHistory.Status; txtImportId.Text = importHistory.ImportNumber; txtTemplate.Text = importHistory.Template; dtpStartDate.DateTimeValue = importHistory.CreateDate; dtpCompleteDate.DateTimeValue = importHistory.ModifyDate; usrStartedBy.LookupResultValue = importHistory.CreateUser; txtTotalRecords.Text = importHistory.RecordCount.ToString(); txtRecordsProcessed.Text = importHistory.ProcessedCount.ToString(); txtRecordsImported.Text = importHistory.ImportedCount.ToString(); txtTotalErrors.Text = importHistory.ErrorCount.ToString(); txtWarningCount.Text = importHistory.WarningCount.ToString(); txtDuplicateCount.Text = importHistory.DuplicateCount.ToString(); txtMergedCount.Text = importHistory.MergeCount.ToString(); var entityType = Type.GetType(importHistory.EntityType); string entityName = entityType.Name[0] == 'I' ? entityType.Name.Substring(1) : entityType.Name; lnkLink.NavigateUrl = string.Format(@"~/{0}.aspx?gid={1}&modeid=list", entityName, importHistory.PrimaryEntityGroup); if (!string.IsNullOrEmpty(importHistory.ProcessState)) { try { ImportProcessState processState = (ImportProcessState)Enum.Parse(typeof(ImportProcessState), importHistory.ProcessState); if ((processState.Equals(ImportProcessState.Completed)) || (processState.Equals(ImportProcessState.Abort))) { cmdAbort.Visible = false; } else { cmdAbort.Visible = true; } } catch (Exception ex) { log.Error("Unexpected error in LoadForm().", ex); cmdAbort.Visible = false; } } } }
/// <summary> /// Loads the form. /// </summary> private void LoadForm() { IImportHistory importHistory = BindingSource.Current as IImportHistory; if (importHistory != null) { txtImportFileName.Text = importHistory.Description; txtStatus.Text = importHistory.Status; txtImportId.Text = importHistory.ImportNumber; txtTemplate.Text = importHistory.Template; dtpStartDate.DateTimeValue = importHistory.CreateDate; dtpCompleteDate.DateTimeValue = importHistory.ModifyDate; usrStartedBy.LookupResultValue = importHistory.CreateUser; txtTotalRecords.Text = importHistory.RecordCount.ToString(); txtRecordsProcessed.Text = importHistory.ProcessedCount.ToString(); txtRecordsImported.Text = importHistory.ImportedCount.ToString(); txtTotalErrors.Text = importHistory.ErrorCount.ToString(); txtWarningCount.Text = importHistory.WarningCount.ToString(); txtDuplicateCount.Text = importHistory.DuplicateCount.ToString(); txtMergedCount.Text = importHistory.MergeCount.ToString(); if (!string.IsNullOrEmpty(importHistory.ProcessState)) { try { ImportProcessState processState = (ImportProcessState)Enum.Parse(typeof(ImportProcessState), importHistory.ProcessState); if ((processState.Equals(ImportProcessState.Completed)) || (processState.Equals(ImportProcessState.Abort))) { cmdAbort.Visible = false; } else { cmdAbort.Visible = true; } } catch (Exception ex) { log.Error("Unexpected error in LoadForm().", ex); cmdAbort.Visible = false; } } } }
private List <ImportProcessState> GetImportProcesses(int?id) { IDbCommand cmd; string strSQL; Tebaldi.MarketData.Models.State.ImportProcessState obj = new ImportProcessState(); strSQL = "procGetProcess"; cmd = DataLayer.CreateCommand(strSQL, mstrConnectString); cmd.CommandType = CommandType.StoredProcedure; if (id != null) { cmd.Parameters.Add(DataLayer.CreateParameter("@Id", DbType.Int32, id, mstrConnectString)); } DataSet ds = DataLayer.GetDataSet(cmd, mstrConnectString); List <ImportProcessState> lst = (from dr in ds.Tables[0].AsEnumerable() select new State.ImportProcessState() { Id = Convert.ToInt32(dr[obj.Schema.Id]), Name = Convert.ToString(dr[obj.Schema.Name]), Feed = new FeedState { ID = Convert.ToInt32(dr[obj.Schema.FeedId]) }, AutoQueue = Convert.ToBoolean(dr[obj.Schema.AutoQueue]), Active = Convert.ToBoolean(dr[obj.Schema.Active]) }).ToList(); FeedHandler feed_handller = new FeedHandler(mstrConnectString); foreach (ImportProcessState item in lst) { item.Feed = feed_handller.GetFeed(item.Feed.ID); } return(lst); }
public ImportProcessState GetImportProcess(int id) { ImportProcessState obj = GetImportProcesses(id).Find(f => f.Id == id); return(obj); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnPreRender(EventArgs e) { ImportManager importManager = Page.Session["importManager"] as ImportManager; IImportHistory importHistory = null; string historyId = Page.Session["importHistoryId"] as string; importHistory = Sage.Platform.EntityFactory.GetById <IImportHistory>(historyId); if (importHistory == null) { if (importManager != null) { //importHistory = importManager.ImportHistory; } } if (importHistory != null) { try { lnkImportNumber.Text = string.Format("{0}-{1}", importHistory.Alternatekeyprefix, importHistory.Alternatekeysuffix); ImportProcessState processState = (ImportProcessState)Enum.Parse(typeof(ImportProcessState), importHistory.ProcessState); if (processState.Equals(ImportProcessState.Abort)) { //lblHeader.Text = string.Format(GetLocalResourceObject("AbortMsg").ToString()); if (importHistory.ErrorCount > 0) { lblHeader2.Text = string.Format("{0} {1}", GetLocalResourceObject("ViewImportHistoryMsgWithErrors").ToString(), GetLocalResourceObject("ViewImportHistoryMsg").ToString()); } else { lblHeader2.Text = string.Format("{0}", GetLocalResourceObject("ViewImportHistoryMsg").ToString()); } cmdAbort.Visible = false; } else { if (processState.Equals(ImportProcessState.Completed)) { cmdAbort.Visible = false; lblHeader.Text = string.Format(GetLocalResourceObject("CompletedMsg").ToString()); if (importHistory.ErrorCount > 0) { lblHeader2.Text = string.Format("{0} {1}", GetLocalResourceObject("ViewImportHistoryMsgWithErrors").ToString(), GetLocalResourceObject("ViewImportHistoryMsg").ToString()); } else { lblHeader2.Text = string.Format("{0}", GetLocalResourceObject("ViewImportHistoryMsg").ToString()); } importManager = null; Page.Session["importManager"] = null; //Page.Session["importHistoryId"] = null; radImportProcessArea.Visible = false; } else { cmdAbort.Visible = true; lblHeader.Text = string.Format(GetLocalResourceObject("lblPrimary_Progress.Caption").ToString()); lblHeader2.Text = string.Format(GetLocalResourceObject("ProcessingMsg").ToString()); } } } catch (Exception) { } } else { } base.OnPreRender(e); }