public static DataSet GetReactionDataOnID(ReactionInfo rxnInfo) { DataSet dsRxnData = null; try { using (OracleConnection oraCon = ConnectionDB.GetOracleConnection()) { using (OracleCommand oraCmd = new OracleCommand()) { oraCmd.Connection = oraCon; oraCmd.CommandText = "GET_REACTION_DATA"; oraCmd.CommandType = CommandType.StoredProcedure; oraCmd.Parameters.Add("PIN_RXN_ID", OracleDbType.Int32).Value = rxnInfo.ReactionID; oraCmd.Parameters.Add("PORC_RXN", OracleDbType.RefCursor).Direction = ParameterDirection.Output; dsRxnData = new DataSet(); OracleDataAdapter oraAdpt = new OracleDataAdapter(oraCmd); oraAdpt.Fill(dsRxnData); } } } catch (Exception) { throw; } return(dsRxnData); }
private PdfPTable GetCrossReferecneTable(ReactionInfo rxnInfo) { PdfPTable ptCrossRef = null; try { if (rxnInfo.RxnCrossRef != null) { if (rxnInfo.RxnCrossRef.Count > 0) { ptCrossRef = new PdfPTable(4); ptCrossRef.AddCell(new PdfPCell(new Phrase("Cross Reference", fontTinyItalic))); ptCrossRef.AddCell(new PdfPCell(new Phrase("Prec.To Reaction", fontTinyItalic))); ptCrossRef.AddCell(new PdfPCell(new Phrase("Succ.To Reaction", fontTinyItalic))); ptCrossRef.AddCell(new PdfPCell(new Phrase("", fontTinyItalic))); for (int i = 0; i < rxnInfo.RxnCrossRef.Count; i++) { ptCrossRef.AddCell(new PdfPCell(new Phrase("", fontTinyItalic))); ptCrossRef.AddCell(new PdfPCell(new Phrase(rxnInfo.RxnCrossRef[i].PrevReactionNo != "0" ? rxnInfo.RxnCrossRef[i].PrevReactionNo.ToString() : "", fontTinyItalic))); ptCrossRef.AddCell(new PdfPCell(new Phrase(rxnInfo.RxnCrossRef[i].SuccReactionNo != "0" ? rxnInfo.RxnCrossRef[i].SuccReactionNo.ToString() : "", fontTinyItalic))); ptCrossRef.AddCell(new PdfPCell(new Phrase("", fontTinyItalic))); } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } return(ptCrossRef); }
private void GetNextReaction() { this._app.UI.CloseDialog((Dialog)this, true); this._app.Game.RemoveReaction(this._currentReaction); ReactionInfo reactionForPlayer = this._app.Game.GetNextReactionForPlayer(this._app.LocalPlayer.ID); if (reactionForPlayer != null) { this._app.UI.CreateDialog((Dialog) new ReactionDialog(this._app, reactionForPlayer), null); } else if (!this._app.GameSetup.IsMultiplayer) { this._app.Game.Phase4_Combat(); } else if (this._app.Network.IsJoined) { this._app.GameDatabase.LogComment("SYNC (ReactionDialog.GetNextReaction)"); this._app.Network.SendHistory(this._app.GameDatabase.GetTurnCount()); } else { if (!this._app.Network.IsHosting) { return; } this._app.Network.ReactionComplete(); } }
/// <summary> /// Loads all the reactions found in the reactions file. /// </summary> /// <param name="includeDisabled"></param> /// <returns>An array of the the reactions found.</returns> public ReactionInfo[] LoadInfoFromFile(bool includeDisabled) { // Logging disabled to boost performance //using (LogGroup logGroup = LogGroup.StartDebug("Loading the reactions from the XML file.")) //{ if (Reactions == null) { List<ReactionInfo> validReactions = new List<ReactionInfo>(); ReactionInfo[] reactions = new ReactionInfo[]{}; using (StreamReader reader = new StreamReader(File.OpenRead(FileNamer.ReactionsInfoFilePath))) { XmlSerializer serializer = new XmlSerializer(typeof(ReactionInfo[])); reactions = (ReactionInfo[])serializer.Deserialize(reader); } foreach (ReactionInfo reaction in reactions) if (reaction.Enabled || includeDisabled) validReactions.Add(reaction); Reactions = validReactions.ToArray(); } //} return Reactions; }
private PdfPTable GetReactionReferecneTable(ReactionInfo rxnInfo) { PdfPTable ptRxnRef = null; try { if (rxnInfo.RxnRef != null) { if (rxnInfo.RxnRef.Count > 0) { ptRxnRef = new PdfPTable(4); ptRxnRef.AddCell(new PdfPCell(new Phrase("Reaction Reference", fontTinyItalic))); ptRxnRef.AddCell(new PdfPCell(new Phrase("Path No", fontTinyItalic))); ptRxnRef.AddCell(new PdfPCell(new Phrase("Path", fontTinyItalic))); ptRxnRef.AddCell(new PdfPCell(new Phrase("Step", fontTinyItalic))); for (int i = 0; i < rxnInfo.RxnRef.Count; i++) { ptRxnRef.AddCell(new PdfPCell(new Phrase("", fontTinyItalic))); ptRxnRef.AddCell(new PdfPCell(new Phrase(rxnInfo.RxnRef[i].ExtRegNo.ToString(), fontTinyItalic))); ptRxnRef.AddCell(new PdfPCell(new Phrase(rxnInfo.RxnRef[i].RefPath.ToString(), fontTinyItalic))); ptRxnRef.AddCell(new PdfPCell(new Phrase(rxnInfo.RxnRef[i].Step.ToString(), fontTinyItalic))); } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } return(ptRxnRef); }
public void ReactionIsLocalTest() { var builder = new ReactionInfo.ReactionBuilder(); ReactionInfo reaction = builder.Reaction; var reactantA = new SpeciesDescription("reactantA", new LocaleInfo("locale1")); var productA = new SpeciesDescription("productA", reactantA.Locale); builder.AddReactant(reactantA); builder.AddProduct(productA); Console.WriteLine("Checking for reaction.IsLocal with reactants and products in same locale..."); Expect(reaction.IsLocal); Expect(!reaction.IsDiffusion); builder = new ReactionInfo.ReactionBuilder(); reaction = builder.Reaction; var productB = new SpeciesDescription("productB", new LocaleInfo("locale2")); builder.AddReactant(reactantA); builder.AddProduct(productB); Console.WriteLine("Checking for !reaction.IsLocal with reactants and products from different locales..."); Expect(!reaction.IsLocal); Expect(reaction.IsDiffusion); Console.WriteLine(""); }
public ReactionDialog(App game, ReactionInfo reaction) : base(game, "ReactionPopup") { this._currentReaction = reaction; this._interceptFleetWidget = new FleetWidget(game, game.UI.Path(this.ID, ReactionDialog.UILeftPanel, ReactionDialog.UIFleetWidget)); this._interceptFleetWidget.EnemySelectionEnabled = true; this._interceptFleetWidget.SetSyncedFleets(reaction.fleetsInRange); }
private void ViewReactionCommand(ReactionInfo viewThis) { _logService.Write(this, "Navigate to: Project page"); _navigationService.NavigateTo("Reaction", new NavigationServiceParameter() { Person = CurrentUser, ObjParam = viewThis }); }
/// <summary> /// Disposes the reactions found by the scanner. /// </summary> public void Dispose() { using (LogGroup logGroup = LogGroup.Start("Disposing the reactions.", NLog.LogLevel.Debug)) { ReactionInfo[] reactions = new ReactionInfo[]{}; Dispose(ReactionState.Reactions.ToArray()); } }
/// <summary> /// Disposes the provided reactions. /// </summary> public void Dispose(ReactionInfo[] reactions) { using (LogGroup logGroup = LogGroup.Start("Disposing the reactions.", NLog.LogLevel.Debug)) { foreach (ReactionInfo reaction in reactions) { ReactionState.Reactions.Remove( ReactionState.Reactions[reaction.TypeName] ); } } }
public void EmptyReactionTest() { usersmock = new List <string>(); projectsmock = new List <string>(); reactioncodesmock = new List <string>(); ReactionInfo item = new ReactionInfo(); List <OutputMessage> errors = new List <OutputMessage>(); errors = item.Validate(usersmock, projectsmock, reactioncodesmock); //elvárt: üres reakcióban lesz validálásnál hiba Assert.AreNotEqual(0, errors.Count); }
private async void GetResourcesCommand() { _logService.Write(this, "Loading reaction with ID " + _reactionId, "debug"); OutputMessages.Add(new OutputMessage() { Message = "Loading reaction...", Level = "debug" }); _reaction = await _dbService.GetReactionAsync(_reactionId); var tmpsm = await _dbService.GetStartingMaterial(_reactionId); var tmpr = await _dbService.GetReagents(_reactionId); var tmps = await _dbService.GetSolvents(_reactionId); var tmpp = await _dbService.GetProducts(_reactionId); var tmpobs = await _dbService.GetObsImgs(_reactionId); _logService.Write(this, "Loaded " + _reactionId, "debug"); OutputMessages.Add(new OutputMessage() { Message = "Loaded", Level = "debug" }); StartingMaterial.Add(tmpsm); foreach (var item in tmpr) { Reagents.Add(item); } _logService.Write(this, Reagents.Count + " reagents loaded for this reaction", "debug"); foreach (var item in tmps) { Solvents.Add(item); } _logService.Write(this, Solvents.Count + " solvents loaded for this reaction", "debug"); foreach (var item in tmpp) { Products.Add(item); } _logService.Write(this, Products.Count + " products loaded for this reaction", "debug"); foreach (var item in tmpobs) { ObservationImgsByteArray.Add(item); } _logService.Write(this, ObservationImgsByteArray.Count + " observable imgs loaded for this reaction", "debug"); ConfigureReactionParameter(); }
private void btnQCDone_Click(object sender, EventArgs e) { try { if (dgvReactions.Rows.Count > 0) { List <int> lstRxnIDs = GetSelectedRxnIDsFromGrid(); if (lstRxnIDs != null) { if (ReactionCurationDB.UpdateReactionsQCCompleteStatus(ShipmentRefID, lstRxnIDs, GlobalVariables.UR_ID)) { //Refresh Reactions table ReactionInfo objReactionInfo = new ReactionInfo(); objReactionInfo.ShipmentRefID = ShipmentRefID; DataTable dtReaction = new DataTable(); ReactionCurationDB.SaveReactionInfo(DmlOperations.SELECT, objReactionInfo, out dtReaction); DataTable dtNonQcRxns = GetQcNotCompletedReactionsFromTable(dtReaction); if (dtNonQcRxns != null) { if (dtNonQcRxns.Rows.Count == 0) { QC_Done = true; DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { BindNonQCReactionsToGrid(dtNonQcRxns); } } //else //{ // QC_Done = true; // DialogResult = System.Windows.Forms.DialogResult.OK; // this.Close(); //} } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } }
public async Task <ReactionInfo> GetReactionAsync(int reactionId) { var tmp = await DbAccess.GetReactionAsync(reactionId); ReactionInfo result = new ReactionInfo() { Code = tmp.Code, Chemist = tmp.Chemist, Chiefchemist = tmp.Chiefchemist, Project = tmp.Project, Laboratory = tmp.Laboratory, StartDate = tmp.StartDate, PreviousStep = tmp.PreviousStep, Observation = tmp.Observation, Procedure = tmp.Procedure, Yield = tmp.Yield, IsSketch = tmp.IsSketch, Literature = tmp.Literature, ReactionImgByteArray = tmp.ReactionImg }; if (!tmp.IsSketch) { result.ClosureDate = tmp.ClosureDate; } return(result); }
public void CompleteReactionTest() { ReactionInfo item = new ReactionInfo(); usersmock = new List <string>(); projectsmock = new List <string>(); reactioncodesmock = new List <string>(); usersmock.Add("TestUser"); projectsmock.Add("TestProject"); item.Code = "NewTestCode"; item.Chemist = "TestUser"; item.Chiefchemist = "TestUser"; item.Project = "TestProject"; item.StartDate = DateTime.Now; item.ClosureDate = DateTime.Now; item.PreviousStep = "-"; item.Literature = "-"; item.ReactionImgPath = "test.jpg"; item.StartingMaterial = new StartingMaterial(); item.Reagents.Add(new Reagent()); item.Solvents.Add(new Solvent()); item.Products.Add(new Product()); item.Procedure = "TestProcedureText"; item.Observation = "TestObservationText"; item.Yield = "TestYieldText"; item.ObservationImgPaths.Add("testobsimg.jpg"); List <OutputMessage> errors = new List <OutputMessage>(); errors = item.Validate(usersmock, projectsmock, reactioncodesmock); int errorcount = 0; foreach (var erroritem in errors) { if (erroritem.Level == "error") { errorcount++; } } Assert.AreEqual(0, errorcount); }
public void ReactionInfoTest() { // Add a reactant, reactant shows up in Reactants list var builder = new ReactionInfo.ReactionBuilder(); ReactionInfo reaction = builder.Reaction; var reactant = new SpeciesDescription("reactant", 2012); builder.AddReactant(reactant); Console.WriteLine("Checking for reactant added to reaction with ReactionBuilder..."); Expect(reaction.Reactants.First() == reactant); // Add a product, product shows up in Products list var product = new SpeciesDescription("product", 2112); builder.AddProduct(product); Console.WriteLine("Checking for product added to reaction with ReactionBuilder..."); Expect(reaction.Products.First() == product); // Set rate, reaction rate is set. var expression = new NumericExpressionTree(string.Empty, new MultiplyOperator(new SymbolReference("reactant"), new SymbolReference("product"))); builder.SetRate(expression); Console.WriteLine("Checking for reaction rate set from ReactionBuilder..."); Expect(reaction.RateExpression == expression); Console.WriteLine("Checking !reaction.HasDelay (before calling builder.SetDelay())..."); Expect(!reaction.HasDelay); var delay = new NumericExpressionTree(string.Empty, new Constant(3.14159265f)); builder.SetDelay(delay); Console.WriteLine("Checking reaction.HasDelay (after calling builder.SetDelay())..."); Expect(reaction.HasDelay); Console.WriteLine("Checking reaction for correct delay..."); Expect(reaction.DelayExpression == delay); Console.WriteLine(""); }
public Reaction(ReactionInfo info, IDictionary <SpeciesDescription, Species> speciesMap, IDictionary <string, IValue> map) { Info = info; Reactants = new List <Species>(); foreach (SpeciesDescription speciesDescription in info.Reactants) { Reactants.Add(speciesMap[speciesDescription]); } Products = new List <Species>(); foreach (SpeciesDescription speciesDescription in info.Products) { Products.Add(speciesMap[speciesDescription]); } _rate = info.RateExpression.ResolveReferences(map); _delay = info.HasDelay ? info.DelayExpression.ResolveReferences(map) : null; }
/// <summary> /// Saves the provided reactions to file. /// </summary> /// <param name="reactions">An array of the reactions to save to file.</param> public void SaveToFile(ReactionInfo[] reactions) { // Logging disabled to boost performance //using (LogGroup logGroup = LogGroup.StartDebug("Saving the provided reactions to XML file.")) //{ string path = FileNamer.ReactionsInfoFilePath; //LogWriter.Debug("Path : " + path); if (!Directory.Exists(Path.GetDirectoryName(path))) Directory.CreateDirectory(Path.GetDirectoryName(path)); using (StreamWriter writer = File.CreateText(path)) { XmlSerializer serializer = new XmlSerializer(reactions.GetType()); serializer.Serialize(writer, reactions); writer.Close(); } //} }
public async Task <List <ReactionInfo> > GetReactions(string chemist) { var reactions = await DbAccess.GetReactionsAsync(chemist); List <ReactionInfo> result = new List <ReactionInfo>(); foreach (var item in reactions) { ReactionInfo tmp = new ReactionInfo(); tmp.ReactionID = item.ID; tmp.Code = item.ReactionCode; tmp.Chemist = item.Chemist.Name; tmp.Chiefchemist = item.Chiefchemist.Name; tmp.Laboratory = item.Laboratory; tmp.StartDate = item.StartDate; tmp.IsSketch = item.Sketch.Value; result.Add(tmp); } return(result); }
private async void DeleteReactionCommand(ReactionInfo deleteThis) { try { OutputMessages.Add(new OutputMessage { Message = "Deleting reaction(s)...", Level = "debug" }); _logService.Write(this, "Deleting reaction(s)...", "debug"); await _dbService.DeleteReaction(deleteThis.ReactionID); Reactions.Remove(deleteThis); OutputMessages.Add(new OutputMessage { Message = "Reaction(s) deleted!", Level = "debug" }); _logService.Write(this, "Deleting reaction(s)...", "debug"); } catch (Exception e) { OutputMessages.Add(new OutputMessage { Message = e.Message, Level = "fatal" }); _logService.Write(this, e.Message, "fatal"); } }
public void OnlyHeadersReactionTest() { ReactionInfo item = new ReactionInfo(); usersmock = new List <string>(); projectsmock = new List <string>(); reactioncodesmock = new List <string>(); usersmock.Add("TestUser"); projectsmock.Add("TestProject"); item.Code = "NewTestCode"; item.Chemist = "TestUser"; item.Chiefchemist = "TestUser"; item.Project = "TestProject"; item.StartDate = DateTime.Now; item.ReactionImgPath = "test.jpg"; List <OutputMessage> errors = new List <OutputMessage>(); errors = item.Validate(usersmock, projectsmock, reactioncodesmock); Assert.AreNotEqual(0, errors.Count); }
/// <summary> /// Retrieves the short type name specified by the Reaction attribute. /// </summary> /// <returns></returns> public virtual string GetTypeName() { ReactionInfo info = new ReactionInfo(this); return info.TypeName; }
/// <summary> /// Retrieves the action specified by the Reaction attribute. /// </summary> /// <returns></returns> public virtual string GetAction() { ReactionInfo info = new ReactionInfo(this); return info.Action; }
public void GenerateSingleReaction(ReactionInfo reaction) { DocxGenerator docgen = new DocxGenerator(); docgen.FilePath = reaction.SaveLocation; docgen.ReactionCode = reaction.Code; docgen.Chemist = reaction.Chemist; docgen.Chiefchemist = reaction.Chiefchemist; docgen.ProjectName = reaction.Project; docgen.Laboratory = reaction.Laboratory; docgen.StartDate = reaction.StartDate; docgen.ClosureDate = reaction.ClosureDate; docgen.PreviousStep = reaction.PreviousStep; docgen.Literature = reaction.Literature; docgen.ReactionImgPath = reaction.ReactionImgPath; docgen.StartingMaterial = new MoleculeRow { Name = reaction.StartingMaterial.Name, CAS = reaction.StartingMaterial.CAS, MWvalue = reaction.StartingMaterial.MW, Ratio = null, nvalue = reaction.StartingMaterial.nValue, mvalue = reaction.StartingMaterial.mValue, Vvalue = reaction.StartingMaterial.VValue, Denvalue = reaction.StartingMaterial.Den, Bpvalue = reaction.StartingMaterial.bpValue, Mpvalue = reaction.StartingMaterial.mpValue }; foreach (var item in reaction.Reagents) { docgen.AddReagent(new MoleculeRow { Name = item.Name, CAS = item.CAS, MWvalue = item.MW, Ratio = item.Ratio, nvalue = item.nValue, mvalue = item.mValue, Vvalue = item.VValue, Denvalue = item.Den, Bpvalue = item.bpValue, Mpvalue = item.mpValue }); } foreach (var item in reaction.Solvents) { docgen.AddSolvent(new MoleculeRow { Name = item.Name, CAS = item.CAS, MWvalue = item.MW, Vvalue = item.VValue, Denvalue = item.Den, Bpvalue = item.bpValue, Mpvalue = item.mpValue }); } foreach (var item in reaction.Products) { docgen.AddProduct(new MoleculeRow { MWvalue = item.MW, Ratio = item.Ratio, nvalue = item.nValue, mvalue = item.mValue }); } if (reaction.IsSketch) { docgen.GenerateReport(true); } else { docgen.ProcedureText = reaction.Procedure; docgen.Yield = reaction.Yield; docgen.ObservationText = reaction.Observation; foreach (var item in reaction.ObservationImgPaths) { docgen.ObservationImg.Add(item); } { } docgen.GenerateReport(false); } }
/// <summary> /// Initializes the reactions and loads all reactions to state. /// </summary> /// <param name="reactions">The reactions to initialize.</param> public void Initialize(ReactionInfo[] reactions) { ReactionState.Reactions = new ReactionStateNameValueCollection(reactions); }
/// <summary> /// Initializes the reactions and loads all reactions to state. Note: Skips initialization if already initialized. /// </summary> /// <param name="includeTestReactions"></param> public void Initialize(bool includeTestReactions) { using (LogGroup logGroup = LogGroup.StartDebug("Initializing the business reactions.")) { ReactionInfo[] reactions = new ReactionInfo[]{}; if (!ReactionState.IsInitialized) { if (IsCached) { LogWriter.Debug("Is cached. Loading from XML."); reactions = LoadReactions(); } else { LogWriter.Debug("Is not cached. Scanning from type attributes."); reactions = FindReactions(includeTestReactions); Saver.SaveToFile(reactions); } Initialize(reactions); } else LogWriter.Debug("Already initialized."); } }
public async Task AddReaction(ReactionInfo reaction) { ReactionDTO reactionDTO = new ReactionDTO { Code = reaction.Code, Chemist = reaction.Chemist, Chiefchemist = reaction.Chiefchemist, Project = reaction.Project, Laboratory = reaction.Laboratory, StartDate = reaction.StartDate, ClosureDate = reaction.ClosureDate, PreviousStep = reaction.PreviousStep, Literature = reaction.Literature, IsSketch = reaction.IsSketch, ReactionImg = convertImg(reaction.ReactionImgPath), Procedure = reaction.Procedure, Yield = reaction.Yield, Observation = reaction.Observation }; StartingMaterialDTO smDTO = new StartingMaterialDTO { MoleculeCAS = reaction.StartingMaterial.CAS, ReactionName = reaction.Code, mValue = reaction.StartingMaterial.mValue, nValue = reaction.StartingMaterial.nValue, VValue = reaction.StartingMaterial.VValue, Location = reaction.StartingMaterial.Location }; List <ReagentDTO> reagentDTOs = new List <ReagentDTO>(); foreach (var item in reaction.Reagents) { reagentDTOs.Add(new ReagentDTO { MoleculeCAS = item.CAS, ReactionName = reaction.Code, Ratio = item.Ratio, Location = item.Location, mValue = item.mValue, VValue = item.VValue }); } List <SolventDTO> solventDTOs = new List <SolventDTO>(); foreach (var item in reaction.Solvents) { solventDTOs.Add(new SolventDTO { MoleculeCAS = item.CAS, ReactionName = reaction.Code, VValue = item.VValue, Location = item.Location }); } List <ProductDTO> productDTOs = new List <ProductDTO>(); foreach (var item in reaction.Products) { productDTOs.Add(new ProductDTO { ReactionName = reaction.Code, MW = item.mValue, Ratio = item.Ratio }); } List <byte[]> observationImgs = new List <byte[]>(); foreach (var item in reaction.ObservationImgPaths) { observationImgs.Add(convertImg(item)); } reactionDTO.StartingMaterial = smDTO; reactionDTO.Reagents = reagentDTOs; reactionDTO.Solvents = solventDTOs; reactionDTO.Products = productDTOs; reactionDTO.ObservationImgs = observationImgs; await DbAccess.AddReactionAsync(reactionDTO); }
public static bool SaveReactionInfo(DmlOperations dmlEnum, ReactionInfo rxnInfo, out DataTable dtResult) { bool blStatus = false; string strTemp = String.Empty; DataTable dtReactions = new DataTable(); try { using (OracleConnection oraCon = ConnectionDB.GetOracleConnection()) { using (OracleCommand oraCmd = new OracleCommand()) { oraCmd.Connection = oraCon; oraCmd.CommandText = "REACTION_ANALYSIS.DML_REACTIONS"; oraCmd.CommandType = CommandType.StoredProcedure; oraCmd.Parameters.Add("PIN_REACTION_ID", OracleDbType.Int32).Value = rxnInfo.ReactionID; oraCmd.Parameters.Add("PIN_DOC_ID", OracleDbType.Int32).Value = rxnInfo.ShipmentRefID; oraCmd.Parameters.Add("PIC_REACTION_SCHEME", OracleDbType.Clob).Value = rxnInfo.ReactionScheme; oraCmd.Parameters.Add("PIN_REACTION_SNO", OracleDbType.Int32).Value = rxnInfo.ReactionSNo; oraCmd.Parameters.Add("PIC_OPTION", OracleDbType.Varchar2).Value = dmlEnum.ToString(); oraCmd.Parameters.Add("PIC_RXN_COMMENTS", OracleDbType.Varchar2).Value = rxnInfo.RxnComments; oraCmd.Parameters.Add("PIC_RXN_MAPPING_TYPE", OracleDbType.Varchar2).Value = rxnInfo.AtomMappingType; oraCmd.Parameters.Add("PIC_COMPLETED_STATUS", OracleDbType.Varchar2).Value = rxnInfo.RxnCompleteStatus; oraCmd.Parameters.Add("PIC_ROLE_NAME", OracleDbType.Varchar2).Value = rxnInfo.RoleName; oraCmd.Parameters.Add("PIC_IS_IMPORTANT", OracleDbType.Varchar2).Value = rxnInfo.IsImportantRxn; oraCmd.Parameters.Add("PIN_UR_ID", OracleDbType.Int32).Value = rxnInfo.UR_ID; OracleParameter paramStatus = new OracleParameter(); paramStatus.ParameterName = "POC_STATUS"; paramStatus.Direction = ParameterDirection.Output; paramStatus.OracleDbType = OracleDbType.Varchar2; paramStatus.Size = 200; oraCmd.Parameters.Add(paramStatus); oraCmd.Parameters.Add("PORC_REACTIONS", OracleDbType.RefCursor).Direction = ParameterDirection.Output; //TODO: Need to discuss with sairam to add UR_ID. // oraCmd.Parameters.Add("PIN_UR_ID", OracleDbType.Int32).Value = usrInfo.UserID; using (OracleDataAdapter dataAdapter = new OracleDataAdapter(oraCmd)) { dataAdapter.Fill(dtReactions); } if (paramStatus.Value != null) { if (paramStatus.Value.ToString().Length > 0) { strTemp = Convert.ToString(oraCmd.Parameters["POC_STATUS"].Value); if (strTemp.ToUpper() == "UPDATE SUCCESS" && dmlEnum == DmlOperations.UPDATE) { blStatus = true; } else if (strTemp.ToUpper() == "INSERT SUCCESS" && dmlEnum == DmlOperations.INSERT) { blStatus = true; } else if (strTemp.ToUpper() == "DELETE SUCCESS" && dmlEnum == DmlOperations.DELETE) { blStatus = true; } } } dtResult = dtReactions; return(blStatus); } } } catch (Exception) { throw; } return(blStatus); }
private void btnCreateRxn_Click(object sender, EventArgs e) { try { DataTable dtReactions = null; int newRxnSNo = 0; if (cmbRxnNo.SelectedItem != null) { int selRxnNo = Convert.ToInt32(cmbRxnNo.Text); newRxnSNo = rbnAfter.Checked ? selRxnNo + 1 : selRxnNo; } else if (ReactionsTbl.Rows.Count == 0) { newRxnSNo = 1; } if (!chkDuplicateWithRxn.Checked)//New Reaction { ReactionInfo rxnInfo = new ReactionInfo(); rxnInfo.ShipmentRefID = ShipmentRefID; rxnInfo.ReactionSNo = newRxnSNo; rxnInfo.UR_ID = GlobalVariables.UR_ID; if (ReactionCurationDB.SaveReactionInfo(DmlOperations.INSERT, rxnInfo, out dtReactions)) { ReactionsTbl = dtReactions; DialogResult = System.Windows.Forms.DialogResult.OK; var query = from r in dtReactions.AsEnumerable() where r.Field <Int64>("REACTION_SNO") == newRxnSNo select new { NewRxn_Id = r["REACTION_ID"] }; if (query != null) { NewRxnID = Convert.ToInt32(query.ElementAt(0).NewRxn_Id); NewRxnSNo = newRxnSNo; } DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("Error in adding new reaction", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else //Duplicate Reaction { DialogResult diaRes = MessageBox.Show("Do you want to duplicate the reaction?", GlobalVariables.MessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (diaRes == System.Windows.Forms.DialogResult.Yes) { int dupRxnID = cmbDuplicateWithRxn.SelectedItem != null?Convert.ToInt32(cmbDuplicateWithRxn.SelectedValue) : 0; int newRxnID = ReactionCurationDB.DuplicateReactionData(ShipmentRefID, dupRxnID, newRxnSNo, GlobalVariables.UR_ID); if (newRxnID > 0) { NewRxnID = newRxnID; NewRxnSNo = newRxnSNo; DuplicateRxn = true; DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("Error in duplicating reaction", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } }
/// <summary> /// Export Reactions for client delivery /// </summary> /// <param name="RefIDsList"></param> /// <param name="shipmentYear"></param> /// <param name="outputPath"></param> /// <param name="mdlStartNo"></param> /// <param name="deliveryDtls"></param> /// <param name="delivSovCats"></param> /// <returns></returns> public static bool ExportReactionsForClientDelivery(List <int> RefIDsList, string shipmentYear, string outputPath, int mdlStartNo, out Delivery deliveryDtls, out List <DeliverySolvCats> delivSovCatsList) { bool blStatus = false; Delivery objDelivery = null; List <DeliverySolvCats> lstDeliverySovCats = null; try { int mdlNo = mdlStartNo;//70000000; List <string> lstUniqSolvInchi = new List <string>(); //Define Delivery class objDelivery = new Delivery(); objDelivery.DeliveryDate = DateTime.Now; objDelivery.MDLStartNo = mdlStartNo; objDelivery.DeliveryRefCount = RefIDsList.Count; List <int> lstDelRefs = new List <int>(); List <int> lstDelRefMDLStNo = new List <int>(); List <int> lstDelRefMDLEndNo = new List <int>(); int deliveredRxnCnt = 0; lstDeliverySovCats = new List <DeliverySolvCats>(); foreach (int shipRefID in RefIDsList) { DataSet dsRxns = ReactionCurationDB.GetReactionsForExportOnDocID(shipRefID); DataTable dtRxnRefs = null; DataTable dtCrossRefs = null; //Automated Export DataSet dsRxn_CrossRefs = ReactionCurationDB.GetRxnAndCrossReferencesOnShipmentRefID(shipRefID); if (dsRxn_CrossRefs != null) { if (dsRxn_CrossRefs.Tables.Count == 2) { dtCrossRefs = dsRxn_CrossRefs.Tables[0]; dtRxnRefs = dsRxn_CrossRefs.Tables[1]; } } if (dsRxns != null) { if (dsRxns.Tables.Count == 8) { DataTable dtDocMaster = dsRxns.Tables[0]; DataTable dtReactions = dsRxns.Tables[1]; //Manual Export //DataTable dtRxnRefs = dsRxns.Tables[2]; //DataTable dtCrossRefs = dsRxns.Tables[3]; DataTable dtRxnSteps = dsRxns.Tables[4]; DataTable dtConditions = dsRxns.Tables[5]; DataTable dtParticipants = dsRxns.Tables[6]; DataTable dtProducts = dsRxns.Tables[7]; // FullArticleInfo articleInfo = GetArticleInfoFromTable(dtDocMaster); FullArticleInfo articleInfo = GetFullArticleDetailsOnShipmentRefID(Convert.ToInt32(dtDocMaster.Rows[0]["SHIPMENT_REF_ID"].ToString())); string shipementRefName = dtDocMaster.Rows[0]["REFERENCE_NAME"].ToString(); List <ReactionInfo> lstRxnInfo = new List <ReactionInfo>(); int reactionID = 0; //Add Reference Name and MDL Start No lstDelRefs.Add(shipRefID); lstDelRefMDLStNo.Add(mdlNo); //Unique ID for reaction (serial number); format: RXCInnnnnnnn;n=numerical range for backfiles is 70000001...89999999. //Feedback on 28th Oct 2014 //General: Please assign MDLnumbers according to the year, i.e. issues from 1981 should have MDLnumbers RXCI81nnnnnn, to avoid duplicates foreach (DataRow drow in dtReactions.Rows) { reactionID = Convert.ToInt32(drow["REACTION_ID"]); ReactionInfo rxnInfo = new ReactionInfo(); rxnInfo.ShipmentRefID = shipRefID; rxnInfo.ReactionID = reactionID; rxnInfo.SysNo = dtDocMaster.Rows[0]["SYS_NO"].ToString(); rxnInfo.SysText = dtDocMaster.Rows[0]["SYS_TEXT"].ToString(); rxnInfo.RxnMDLNo = "RXCI" + shipmentYear + mdlNo.ToString("000000");//RXCI81nnnnnn rxnInfo.ReactionScheme = drow["REACTION_SCHEME"]; rxnInfo.ReactionSNo = Convert.ToInt32(drow["REACTION_SNO"]); rxnInfo.RxnComments = drow["RXN_COMMENTS"].ToString(); rxnInfo.RxnRef = GetRxnRefInfoFromTableOnReactionID(dtRxnRefs, reactionID); rxnInfo.RxnCrossRef = GetCrossRefInfoFromTableOnReactionID(dtCrossRefs, reactionID); rxnInfo.RxnProducts = GetProductsFromTableOnReactionID(dtProducts, reactionID); rxnInfo.RxnSteps = GetStepsInfoFromTableOnReactionID(dtRxnSteps, dtParticipants, dtConditions, reactionID); //Add to list lstRxnInfo.Add(rxnInfo); //increment MDL Numer mdlNo++; //Count delivery Rxns deliveredRxnCnt++; } //Add Reference MDL End No lstDelRefMDLEndNo.Add(mdlNo); if (lstRxnInfo != null) { DeliverySolvCats refSovCats = new DeliverySolvCats(); if (ReactionExport.ExportToRDFile(lstRxnInfo, articleInfo, shipementRefName, outputPath, ref lstUniqSolvInchi, ref refSovCats)) { blStatus = true; if (refSovCats.RefNewSolvents != null) { refSovCats.ShipmentRefID = shipRefID; //Add Refs and SolvCats to List lstDeliverySovCats.Add(refSovCats); } } } } } } //Delivery references and Mdl Nos objDelivery.DeliveryRefsList = lstDelRefs; objDelivery.RefMdlStartNoList = lstDelRefMDLStNo; objDelivery.RefMdlEndNoList = lstDelRefMDLEndNo; objDelivery.DeliveryRxnCount = deliveredRxnCnt; objDelivery.MDLEndNo = (mdlStartNo + deliveredRxnCnt) - 1; } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } deliveryDtls = objDelivery; delivSovCatsList = lstDeliverySovCats; return(blStatus); }
public bool ExportReferenceDataToPdf(int shipmentRefID, string outFilePath) { bool blStatus = false; try { if (shipmentRefID > 0) { DataTable dtRxnRefs = null; DataTable dtCrossRefs = null; DataSet dsRxn_CrossRefs = ReactionCurationDB.GetRxnAndCrossReferencesOnShipmentRefID(shipmentRefID); if (dsRxn_CrossRefs != null) { if (dsRxn_CrossRefs.Tables.Count == 2) { dtCrossRefs = dsRxn_CrossRefs.Tables[0]; dtRxnRefs = dsRxn_CrossRefs.Tables[1]; } } DataSet dsRxns = ReactionCurationDB.GetReactionsForExportOnDocID(shipmentRefID); if (dsRxns != null) { if (dsRxns.Tables.Count == 8) { DataTable dtDocMaster = dsRxns.Tables[0]; DataTable dtReactions = dsRxns.Tables[1]; //DataTable dtRxnRefs = dsRxns.Tables[2]; //DataTable dtCrossRefs = dsRxns.Tables[3]; DataTable dtRxnSteps = dsRxns.Tables[4]; DataTable dtConditions = dsRxns.Tables[5]; DataTable dtParticipants = dsRxns.Tables[6]; DataTable dtProducts = dsRxns.Tables[7]; string rxnsRefNo = dtDocMaster.Rows[0]["REFERENCE_NAME"].ToString(); string sysText = dtDocMaster.Rows[0]["SYS_TEXT"].ToString(); string sysNo = dtDocMaster.Rows[0]["SYS_NO"].ToString(); string outFileName = outFilePath;// Path.Combine(outFilePath, rxnsRefNo + ".pdf"); List <ReactionInfo> lstRxnInfo = new List <ReactionInfo>(); int reactionID = 0; //Unique ID for reaction (serial number); format: RXCInnnnnnnn;n=numerical range for backfiles is 70000001...89999999. int mdlNo = 70000000; foreach (DataRow drow in dtReactions.Rows) { //increment MDL Numer mdlNo++; reactionID = Convert.ToInt32(drow["REACTION_ID"]); ReactionInfo rxnInfo = new ReactionInfo(); rxnInfo.ShipmentRefID = shipmentRefID; rxnInfo.ReactionID = reactionID; rxnInfo.SysNo = dtDocMaster.Rows[0]["SYS_NO"].ToString(); rxnInfo.SysText = dtDocMaster.Rows[0]["SYS_TEXT"].ToString(); rxnInfo.RxnMDLNo = "RXCI" + mdlNo; rxnInfo.ReactionScheme = drow["REACTION_SCHEME"]; rxnInfo.ReactionSNo = Convert.ToInt32(drow["REACTION_SNO"]); rxnInfo.RxnRef = GetRxnRefInfoFromTableOnReactionID(dtRxnRefs, reactionID); rxnInfo.RxnCrossRef = GetCrossRefInfoFromTableOnReactionID(dtCrossRefs, reactionID); DataTable dtRxnStages = GetStepsOnReactionID(dtRxnSteps, reactionID); DataTable participantsData = GetParticipantsForProdFormation(dtParticipants, dtConditions, dtRxnStages); rxnInfo.ParticipantsForPdf = participantsData;// GetReactionStepsInfoFromTableOnReactionID(dtRxnSteps, dtParticipants, dtConditions, reactionID); //Add to list lstRxnInfo.Add(rxnInfo); } if (lstRxnInfo != null) { if (dtReactions.Rows.Count > 0) { using (iTextSharp.text.Document doc = new iTextSharp.text.Document()) { iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new System.IO.FileStream(outFileName, FileMode.Create)); doc.Open(); //Declare Reaction Participants tables #region MyRegion DataTable dtProdTbl = null; DataTable dtReactantTbl = null; DataTable dtPartpntTbl = null; DataTable dtCondsTbl = null; DataTable dtStagesTbl = null; #endregion iTextSharp.text.Image chemimg = null; iTextSharp.text.Font georgia = FontFactory.GetFont("georgia", 10f); //Define variables #region MyRegion int intProdCnt = 0; int intReactCnt = 0; string strRxnHdr = ""; PdfPTable PdfTable = null; PdfPCell rxnCell = null; #endregion //Define font style #region MyRegion styles = new StyleSheet(); styles.LoadTagStyle("th", "size", "8px"); styles.LoadTagStyle("th", "face", "helvetica"); styles.LoadTagStyle("span", "size", "7px"); styles.LoadTagStyle("span", "face", "helvetica"); styles.LoadTagStyle("td", "size", "7px"); styles.LoadTagStyle("td", "face", "helvetica"); #endregion PdfPTable pTRxnRef = null; PdfPTable pTCrossRef = null; PdfPCell pcRxnRef = null; PdfPCell pcCrossRef = null; //Add Pdf Header to document PdfPTable ptHeader = GetPdfHeaderTable(rxnsRefNo, sysNo); doc.Add(ptHeader); //Define Participants elements List <IElement> lstPartpnt = null; foreach (ReactionInfo rxnInfo in lstRxnInfo) { //Create instance of the pdf table and set the number of column in that table PdfTable = new PdfPTable(1); PdfTable.SpacingAfter = 4f; PdfTable.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right PdfTable.TotalWidth = 800f; // doc.PageSize.Width; PdfTable.WidthPercentage = 100; //Add Reaction Header to Pdf Table strRxnHdr = "Reaction - " + rxnInfo.ReactionSNo.ToString(); rxnCell = new PdfPCell(new Phrase(strRxnHdr, fontTinyItalic)); rxnCell.Colspan = intProdCnt + intReactCnt; rxnCell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;// 0; //0=Left, 1=Centre, 2=Right rxnCell.VerticalAlignment = PdfPCell.ALIGN_TOP; rxnCell.BackgroundColor = bgcolRxnNo; PdfTable.AddCell(rxnCell); //Reaction Reference Info pTRxnRef = GetReactionReferecneTable(rxnInfo); if (pTRxnRef != null) { pcRxnRef = new PdfPCell(pTRxnRef); pcRxnRef.Border = PdfPCell.NO_BORDER; //pcRxnRef.BackgroundColor = bgcolRctNumStage; PdfTable.AddCell(pcRxnRef); } //Cross Reference Info pTCrossRef = GetCrossReferecneTable(rxnInfo); if (pTCrossRef != null) { pcCrossRef = new PdfPCell(pTCrossRef); pcCrossRef.Border = PdfPCell.NO_BORDER; //pcRxnRef.BackgroundColor = bgcolRctNumStage; PdfTable.AddCell(pcCrossRef); } if (rxnInfo.ReactionScheme != null) { System.Drawing.Image img = GetStructureImage(rxnInfo.ReactionScheme.ToString()); chemimg = iTextSharp.text.Image.GetInstance(img as System.Drawing.Image, System.Drawing.Imaging.ImageFormat.Jpeg); if (chemimg != null) { chemimg.ScaleToFit(450f, 150f); //chemimg.ScaleAbsolute((float)600f, (float)250f); chemimg.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_CENTER; //pdfCell = new PdfPCell(chemimg, true); } else { //pdfCell = new PdfPCell(new Phrase("Structure generation error", fontTinyItalic)); } PdfTable.AddCell(chemimg); } //Product Yield, CS, DS and Other information //Get Participatns text from RichTextBox object string strRtf = GetPartpntsDataBindToRichTextBox(rxnInfo.ParticipantsForPdf); //Get Participants elements from RichTextBox Rtf and convert to HTML lstPartpnt = HTMLWorker.ParseToList(new StringReader(markupConverter.ConvertRtfToHtml(strRtf)), styles); //Add Participants string in a row cell to Pdf Table PdfPCell pcPartpnt = new PdfPCell(); foreach (IElement iEle in lstPartpnt) { pcPartpnt.AddElement(iEle); } pcPartpnt.Colspan = 1;// intProdCnt + intReactCnt; //pcPartpnt.BackgroundColor = bgcolRxnPartpnt; pcPartpnt.VerticalAlignment = Element.ALIGN_TOP; pcPartpnt.HorizontalAlignment = 0;// Element.ALIGN_LEFT; //0=Left, 1=Centre, 2=Right PdfTable.AddCell(pcPartpnt); doc.Add(PdfTable); } doc.Close(); blStatus = true; } } } } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } return(blStatus); }