예제 #1
0
        private void UpdateGenevaActivityRun(int activityId, string name, string datatype, string source, int numrecs, XmlDocument xmldoc, loaderResultsStruct loaderResults)
        {
            WfmAdapter wfmAdapter = new WfmAdapter("Geneva",
                GetBamGenevaConnectionString(), "MarketDataSqlAlias");

            wfmAdapter.AddActivityDetailAlias = "BAMMarketPriceLoader.AddActivityRunDetail";

            wfmAdapter.UpdateActivityRun(activityId, name, datatype, source, numrecs,
                xmldoc, LoaderResults2Xml(loaderResults));
        }
예제 #2
0
        private XmlDocument LoaderResults2Xml(loaderResultsStruct loaderResults)
        {
            XmlDocument xdoc = new XmlDocument();
            xdoc.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "loaderResults", ""));
            foreach (loaderResultsVectorElement record in loaderResults.results)
            {
                XmlNode node = xdoc.CreateNode(XmlNodeType.Element, "result", "");
                ((XmlElement)node).SetAttribute("code", record.code);
                ((XmlElement)node).SetAttribute("keyvalue", record.keyValue);
                ((XmlElement)node).SetAttribute("message", record.message);
                ((XmlElement)node).SetAttribute("recordnumber", record.recordNumber.ToString());
                ((XmlElement)node).SetAttribute("status", record.status);

                xdoc.FirstChild.AppendChild(node);
            }
            return xdoc;
        }
예제 #3
0
        private int UpdateActivityRun(int jobKeyCode, int activityId, string name, string dataType, string source, int numrecs,
            loaderResultsStruct loaderReturn, Hashtable htIdentifierRef, Hashtable htSubTypeRef, Hashtable htTypeRef, Hashtable htXmlData, Dictionary<string, string> subTypesKeys)
        {
            int ret = 0;
	        log.InfoFormat(jobKeyCode, "Saving upload details in WFM");
            try
            {
				//string strUserIdentity = "fountainhead\bgoff";
				//GenericIdentity objGenericIdentity = new GenericIdentity(strUserIdentity);
				//CredentialPrincipal credPrincipal = new CredentialPrincipal(objGenericIdentity, null, strPerms); ;

                Hashtable ht = new Hashtable();
                Hashtable htRef = BuildSubTypeNameLookup();
                Hashtable htRecType = BuildRecordTypeLookup();

                int i = 0;
                if (loaderReturn.results != null)
                {
                    foreach (loaderResultsVectorElement result in loaderReturn.results)
                    {
                        string subTypeName = String.Empty;
                        string recType = String.Empty; string identifier = String.Empty;

                        if (htRef.ContainsKey(result.message))
                            subTypeName = htRef[result.message].ToString();
                        if (htRecType.ContainsKey(result.message))
                            recType = htRecType[result.message].ToString();

                        if (subTypeName.Equals(String.Empty))
                        {
                            if (result.keyValue.Equals(String.Empty))
                            {
                                identifier = htIdentifierRef[i].ToString();
                            }
                            else if (htTypeRef.ContainsKey(result.keyValue))
                            {
                                subTypeName = htSubTypeRef[result.keyValue].ToString();
                                identifier = result.keyValue;
                                recType = htTypeRef[result.keyValue].ToString();
                            }
                            else
                            {
                                //subTypeName = "EquityNewType";
								if (!subTypesKeys.TryGetValue(result.keyValue,out subTypeName)) 
									subTypeName = "EquityNewType"; 
								
								if (string.IsNullOrEmpty(recType)) 
									subTypesKeys.TryGetValue(result.keyValue,out recType); 
									
                                identifier = result.keyValue;
                            }
                        }

                        int rc = 0;
                        Int32.TryParse(result.code, out rc);

                        XmlDocument xdocXmlData = (XmlDocument)htXmlData[i++];

                        if (xdocXmlData != null)
                        {
                            XmlNode exceptionsNode = xdocXmlData.CreateElement("Exceptions", xdocXmlData.DocumentElement.NamespaceURI);

                            XmlNode exceptionNode = xdocXmlData.CreateElement("GenevaErrorCode", xdocXmlData.DocumentElement.NamespaceURI);
                            exceptionNode.InnerXml = result.code;
                            XmlNode exceptionMsgNode = xdocXmlData.CreateElement("Message", xdocXmlData.DocumentElement.NamespaceURI);
                            exceptionMsgNode.InnerXml = result.message;

                            exceptionsNode.AppendChild(exceptionNode);
                            exceptionsNode.AppendChild(exceptionMsgNode);
                            xdocXmlData.FirstChild.AppendChild(exceptionsNode);

                            SqlParameter[] wfmActivityDetailsPars = new SqlParameter[] {
							new SqlParameter("@RunID", activityId),
							new SqlParameter("@xmlData", xdocXmlData.InnerXml),
							new SqlParameter("@SubTypeName",subTypeName ),
							new SqlParameter("@Identifier", identifier),
							new SqlParameter("@UserID", (object)0 ),
							new SqlParameter("@UserGroupID",(object)0 ),
							new SqlParameter("@ExceptionStatusCode","m" ),
							new SqlParameter("@UserName",String.Empty ),
							new SqlParameter("@dataType",dataType ),
							new SqlParameter("@RecordType", recType),
							new SqlParameter("@RecordType2", (dataType.Contains("Transaction") ? "UserTranId1": "Code")),
							new SqlParameter("@Code", rc),
							new SqlParameter("@Message", result.message),
							new SqlParameter("@SuccessKeyValue", result.keyValue)};

							DatabaseUtils.ExecuteStoredProc(wfmAddActivityRunDetailSpName, wfmActivityDetailsPars);


	                        #region Old way using Persistence

	                        /*
							ht.Clear();
                            ht.Add("RunID", activityId);
                            ht.Add("xmlData", xdocXmlData.InnerXml);
                            ht.Add("SubTypeName", subTypeName);
                            ht.Add("Identifier", identifier);
                            ht.Add("UserID", 0);
                            ht.Add("UserGroupID", 0);
                            ht.Add("ExceptionStatusCode", "m");
                            ht.Add("UserName", String.Empty);
                            ht.Add("dataType", dataType);
                            ht.Add("RecordType", recType);
                            ht.Add("RecordType2", (dataType.Contains("Transaction") ? "UserTranId1": "Code"));
                            ht.Add("Code", rc);
                            ht.Add("Message", result.message);
                            ht.Add("SuccessKeyValue", result.keyValue);

                            Repository.GetRepository("BamGeneva").ExecuteScalar("BamGeneva.AddActivityRunDetail", ht);
							*/

	                        #endregion
 
                        }
                    }
                }
                else
                    log.Warn(jobKeyCode, "No results received from SOAP update.");

				SqlParameter[] wfmActivityPars = new SqlParameter[]
					{
						new SqlParameter("@RunID", activityId),
						new SqlParameter("@StatusCode", 'e'),
						new SqlParameter("@EndDateTime", DateTime.Now),
						new SqlParameter("@NumberOfRecords", numrecs),
						new SqlParameter("@Note", String.Empty),
						new SqlParameter("@Source", source),
						new SqlParameter("@MessageId", String.Empty)
					};

				DatabaseUtils.ExecuteStoredProc(wfmUpdateActivityRunSpName, wfmActivityPars);
				log.InfoFormat(jobKeyCode,"Uppload details saved in WFM");

	            #region Persistence way - Retired

				//ht.Clear();
				//ht.Add("RunID", activityId);
				//ht.Add("StatusCode", 'e');
				//ht.Add("EndDateTime", DateTime.Now);
				//ht.Add("NumberOfRecords", numrecs);
				//ht.Add("Note", "");
				//ht.Add("Source", source);
				//ht.Add("MessageId", "");

				//ret = Repository.GetRepository("BamGeneva").ExecuteScalar("BamGeneva.UpdateActivityRun", ht);

	            #endregion
            }
            catch (Exception ex)
            {
				log.ErrorFormat(jobKeyCode,"Could not update WFM activity recirds {0}", ex.Message);
				log.Error(jobKeyCode, ex);
            }

            return ret;
        }
예제 #4
0
        private XmlDocument GetActivityLog(int jobKeyCode, int activityId, loaderResultsStruct loaderReturn)
		{

			XmlDocument genevaActivitiLog ;
			try
			{
				XElement genevaReposnd = new XElement("GenevaRespond",
							 from resultStruct in loaderReturn.results
							 select new XElement("GenevaRespondElement",
										new XElement("status", resultStruct.status),
										new XElement("externalId", resultStruct.externalId),
										new XElement("keyValue", resultStruct.keyValue),
										new XElement("message", resultStruct.message),
										new XElement("recordNumber", resultStruct.recordNumber)
										));

				genevaReposnd.SetAttributeValue("activityId", activityId);
				genevaReposnd.SetAttributeValue("jobKeyCode", jobKeyCode);

				genevaActivitiLog = new XmlDocument();
				genevaActivitiLog.Load(genevaReposnd.CreateReader());
				log.InfoFormat(jobKeyCode, "Created log for Geneva reponse ", activityId);
			}
			catch (Exception ex)
			{
				log.ErrorFormat(jobKeyCode, "Could not create log for Geneva reponse", activityId);
				log.Error(jobKeyCode, ex);
				genevaActivitiLog = null;
			}			
					
			return genevaActivitiLog;
		}
예제 #5
0
		private DataTable GetTranIdUserTranIdPairTable(XmlDocument sourceXdoc, string nsuri, loaderResultsStruct loaderReturn, string tranIdPairTablename)
		{
			DataTable result = new DataTable(tranIdPairTablename);
			result.Columns.Add(new DataColumn("UserTranId"));
			result.Columns.Add(new DataColumn("TranId"));

			XNamespace gnXns = nsuri;
			int seq = 1;

			try
			{
				if (XDocument.Parse(sourceXdoc.InnerXml).Descendants(gnXns + "TransactionRecords").Count() > 0)
				{
					var userTranIdSeq = (from loadableRecord in XDocument.Parse(sourceXdoc.InnerXml).Descendants()
										 where loadableRecord.AncestorsAndSelf().Count() == 3
										 select new { key = seq++, val = loadableRecord.Element(gnXns + "KeyValue") != null ? loadableRecord.Element(gnXns + "KeyValue").Value : null })
																.ToDictionary(k => k.key, v => v.val);
					var pairs = from loaderResult in loaderReturn.results
								where loaderResult.status == "Success"
								select new
								{
									UserTranId = userTranIdSeq[loaderResult.recordNumber],
									TranId = loaderResult.keyValue
								};

					if (pairs.Count() > 0)
						result = pairs.CopyToDataTable(result, LoadOption.PreserveChanges);

					log.InfoFormat(jobKeyCode, "Produced {0} UserTranId/GenevaTranId pair(s)", result.Rows.Count);
				}
			}
			catch (Exception ex)
			{
				log.ErrorFormat(jobKeyCode,"Failed to produce UserTranId/GenevaTranId pairs {0}",ex.Message);
				log.Error(jobKeyCode, ex);
			} 

			return result;
		}
예제 #6
0
        public override StateEnums.Status Execute(Object o, Hashtable inputData)
        {
            log.InfoFormat(jobKeyCode, "Module {0} received {1} inputs.", name, inputData != null ? inputData.Count.ToString() : "no");

            State state = (State)o;
            StateEnums.Status retval = StateEnums.Status.Success;
            int runId = 0;
            double duration = 0;

            if (IfResetOnEachRun)
                ResetOutput();

            PassAlongOutputs(inputData);

            int activityIdStarting = UpdateProcessStatus(Enums.ProcessStatus.Starting, "", (State)o);
            XmlDocument sourceXdoc = new XmlDocument();

            if (inputData.Count > 0)
            {
                PerfTimer hpt = new PerfTimer();
                hpt.Start();

                string flags = "-x";

	            if (!ConfigUtils.GlobalConfig.WfmConnectonString.Equals(String.Empty))
	            {
		            WfmConnectonString = ConfigUtils.GlobalConfig.WfmConnectonString;
		            log.InfoFormat(jobKeyCode, "WfmConnectionString recieved from GlobalConfig. {0}", WfmConnectonString);
	            }
	            else
	            {
					log.WarnFormat(jobKeyCode, "WfmConnectionString was NOT recieved from GlobalConfig");
					log.WarnFormat(jobKeyCode, "WfmConnectionString will be assigned from job spec {0}",wfmConnectonString);

		            if (wfmConnectonString.Equals(String.Empty) ||
		                ConfigUtils.GlobalConfig.ConnectionSettings.Connections.ContainsKey(wfmConnectonString) == false)
		            {
			            retval = StateEnums.Status.Error;
			            log.ErrorFormat(jobKeyCode,
			                            "WFM Connection {0} is not defined.  Please add to config file and restart the service.",
			                            wfmConnectonString);
			            return retval;
		            }
				}

				DbConnectionDetail dbConnDetail =
			        (DbConnectionDetail) ConfigUtils.GlobalConfig.ConnectionSettings.Connections[wfmConnectonString];
		        if (!DatabaseUtils.Connect(dbConnDetail.DefaultConnectString))
		        {
			        retval = StateEnums.Status.Error;
			        log.ErrorFormat(jobKeyCode, "Could not establish connection to WFM. {0}", wfmConnectonString);
			        throw new ApplicationException("WFM Database connection could not be established.");
			        return retval;
		        }
	            

	            try
                {
					loaderResultsStruct loaderReturn = null;
                    string mail_distribution = MetaTagReplacer.GetMetaTagValue("*SOAP_ERROR_DISTRIBUTION*",
                                                                                state.CurrentParameters.ProcessInputDates,
                                                                                null);

                    string runrepSessionID = String.Empty;
                     Service webServ = null;

                    if (InputToProcess.CompareTo(String.Empty) != 0)
                        sourceXdoc = (XmlDocument)inputData[InputToProcess];
                    else
                        sourceXdoc = (XmlDocument)inputData[0];

                    if (inputData.ContainsKey("ActivityName"))
                        activityName = inputData["ActivityName"].ToString();

                    if (sourceXdoc != null && sourceXdoc.InnerXml != null && !sourceXdoc.InnerXml.Equals(String.Empty) && sourceXdoc.DocumentElement.FirstChild.ChildNodes.Count > 0)
                    {
                        sourceXdoc.InnerXml = sourceXdoc.InnerXml.Replace("http://www.advent.com/SchemaRevLevel248/Geneva", "http://www.advent.com/SchemaRevLevel371/Geneva");

                        if (nsuri.Equals(String.Empty))
                            nsuri = ((sourceXdoc).DocumentElement).NamespaceURI;
                        int i = 0;

                        Hashtable htXmlData = new Hashtable();
                        Hashtable htUserTranId1Ref = new Hashtable();
                        Hashtable htIdentifierRef = new Hashtable();
                        Hashtable htTypeIndicatorRef = new Hashtable();
                        Hashtable htSubTypeIndicatorRef = new Hashtable();

                        XmlNodeList nodeList = null;

                        if (sourceXdoc.DocumentElement.FirstChild.Name.Equals("GenevaLoader"))
                            nodeList = sourceXdoc.DocumentElement.FirstChild.ChildNodes;
                        else
                            nodeList = sourceXdoc.DocumentElement.ChildNodes;

                        string dataType = sourceXdoc.DocumentElement.FirstChild.Name;

                        foreach (XmlNode node in nodeList)
                        {
                            string loaderType = String.Empty;
                            string loaderAction = String.Empty;
                            string userTranId1 = String.Empty;
                            string identifier = String.Empty;
                            foreach (XmlNode subNode in node.ChildNodes)
                            {
                                XmlDocument xdocXmlData = new XmlDocument();
                                XmlNode rootXmlData = xdocXmlData.CreateElement(recordType);
                                xdocXmlData.AppendChild(rootXmlData);

                                string[] loaderKeys = subNode.Name.Split('_');
                                loaderType = loaderKeys[0];
                                if (loaderKeys.Length > 1)
                                    loaderAction = loaderKeys[1];
                                else
                                    loaderAction = "InsertUpdate";

                                recCountTotal = subNode.ChildNodes.Count;

                                GetGenevaTransactionKeys(htUserTranId1Ref, htTypeIndicatorRef, ref loaderType, ref loaderAction, ref userTranId1, ref identifier, subNode, loaderKeys);

                                XmlNode subNodeCopy = xdocXmlData.CreateElement(subNode.Name);
                                subNodeCopy.InnerXml = subNode.InnerXml;
                                xdocXmlData.FirstChild.AppendChild(subNodeCopy);

                                if (!htSubTypeIndicatorRef.Contains(identifier))
                                    htSubTypeIndicatorRef.Add(identifier, loaderAction + "Type");

                                htXmlData.Add(i, ConvertXmlData(jobKeyCode, xdocXmlData));
                                htIdentifierRef.Add(i, identifier);

                                i++;
                            }
                        }

                        try
                        {
                            ifRetry = true;
                            int numtries = 1;
                            bool isContingency = false;
                            DateTime runStartTime = DateTime.Now;

                            GetSubAdvisorActivityName(state, ref activityName);
                            runId = AddActivityRun(activityName, state.SourceFileName, sourceXdoc.DocumentElement.FirstChild.ChildNodes.Count);

                            while (ifRetry)
                            {
                                try
                                {
                                    webServ = null;
                                    while (webServ == null && numtries < 12)
                                    {
                                        log.InfoFormat(jobKeyCode, "Attempting Geneva SOAP RunCallableLoader [retry #{3}] on {0}:{1} with flags {2}", host, port, flags, numtries);
                                        webServ = new Service();
                                        if (webServ == null)
                                            Thread.Sleep(5000);
                                        numtries++;
                                    }

                                    if (webServ == null)
                                    {
                                        log.ErrorFormat(jobKeyCode, "Web service not constructed (null value)");
                                        retval = StateEnums.Status.Warnings;
                                        throw new System.Web.Services.Protocols.SoapException();
                                    }
                                    else
                                    {
                                        log.InfoFormat(jobKeyCode, "Web service constructed successfully");

                                        webServ.Timeout = timeout;
                                        log.InfoFormat(jobKeyCode, "Web service timeout assigned: {0}", timeout);

                                        webServ.Url = this.Url;
                                        log.InfoFormat(jobKeyCode, "Web url assigned: {0}", webServ.Url);

                                        if (runrepSessionID.Equals(String.Empty))
                                            try
                                            {
                                                runrepSessionID = webServ.StartCallableLoader(port, host, uid, pwd);
                                                log.InfoFormat(jobKeyCode, "Runrep session started successfully [Runrep ID: {0}]", runrepSessionID);
                                            }
                                            catch (Exception ex)
                                            {
                                                log.WarnFormat(jobKeyCode, "Failed to start runrep session: {0} [Runrep ID: {1}]", ex, runrepSessionID);
                                                retval = StateEnums.Status.Warnings;
                                                throw new System.Web.Services.Protocols.SoapException();
                                            }
                                    }

                                    try
                                    {
                                        try
                                        {
                                            loaderReturn = webServ.RunCallableLoader(runrepSessionID, sourceXdoc.InnerXml, flags);
                                        }
                                        catch(Exception ex)
                                        {
                                            if(ex.Message.Contains("Unknown element"))
                                                throw new ApplicationException(ex.Message);
                                            else
                                                throw new Exception(ex.Message);
                                        }
                                        log.InfoFormat(jobKeyCode, "Callable Loader session was successful [Runrep ID: {0}]", runrepSessionID);

                                        DataTable dtResults = new DataTable();
                                        dtResults.Columns.Add("Status");
                                        dtResults.Columns.Add("Message");
                                        dtResults.Columns.Add("KeyValue");

                                        for (int j = 0; j < loaderReturn.results.Length; j++)
                                        {
                                            DataRow dr = dtResults.NewRow();
                                            dr["Status"] = loaderReturn.results[j].status.ToString();
                                            dr["Message"] = loaderReturn.results[j].message.ToString();
                                            dr["KeyValue"] = loaderReturn.results[j].keyValue.ToString();
                                            dtResults.Rows.Add(dr);
                                        }
                                        dtResults.DefaultView.Sort = "Status,Message,KeyValue";
                                        mailEnvelop = String.Empty;
                                        string lastStatus = "";
                                        string lastmsgg = "";
                                        foreach (DataRowView dr in dtResults.DefaultView)
                                        {
                                            if (!dr["Status"].ToString().Equals(lastStatus))
                                            {
                                                mailEnvelop += String.Format("Status: {0}<br>", dr["Status"].ToString());
                                                lastStatus = dr["Status"].ToString();
                                            }

                                            if (!dr["Message"].ToString().Equals(lastmsgg))
                                            {
                                                mailEnvelop += String.Format("Message: {0}<br>", dr["Message"].ToString());
                                                lastmsgg = dr["Message"].ToString();
                                            }

                                            mailEnvelop += String.Format("Trade Id: {0}<br>", dr["KeyValue"].ToString());
                                        }
                                    }
                                    catch (ApplicationException aex)
                                    {
                                        //bubble up application exception.  this difference here is that we'll avoid the web service retry loop
                                        throw new ApplicationException(aex.Message);
                                    }
                                    catch (Exception ex)
                                    {
                                        log.ErrorFormat(jobKeyCode, "Failed to run Callable Loader session: {0} [Runrep ID: {1}]", ex, runrepSessionID);
                                        retval = StateEnums.Status.Warnings;
                                        throw new System.Web.Services.Protocols.SoapException();
                                    }

                                    if (isContingency)
                                        SendMailMessage(jobKeyCode, mail_distribution, "BITS,[email protected]", Subject, "Geneva SOAP call succeeded.");

                                    try
                                    {
                                        webServ.ShutdownCallableSession(runrepSessionID);
                                        retval = StateEnums.Status.Warnings;
                                        log.InfoFormat(jobKeyCode, "Shut down SOAP session OK {0}.", runrepSessionID);
                                    }
                                    catch (Exception ex)
                                    {
                                        log.WarnFormat(jobKeyCode, "Error shutting down SOAP session: {0} [Runrep ID: {1}]", ex, runrepSessionID);
                                    }

                                    recCountSuccess++;
                                    ifRetry = false;
                                }

                                catch (ApplicationException aex)
                                {
                                    //use this type of exception to avoid the web service retry loop
                                    try
                                    {
                                        webServ.ShutdownCallableSession(runrepSessionID);
                                        ifRetry = false;
                                        retval = StateEnums.Status.Warnings;
                                        log.InfoFormat(jobKeyCode, "Shut down SOAP session OK {0}.", runrepSessionID);
                                        log.WarnFormat(jobKeyCode, "Bailing out of Geneva Update because of application error [{0}]", aex.Message);
                                    }
                                    catch (Exception ex)
                                    {
                                        log.WarnFormat(jobKeyCode, "Error shutting down SOAP session: {0} [Runrep ID: {1}]", ex, runrepSessionID);
                                    }
                                }
                                catch (Exception wex)
                                {
                                    try
                                    {
                                        webServ.ShutdownCallableSession(runrepSessionID);
                                        retval = StateEnums.Status.Warnings;
                                        log.InfoFormat(jobKeyCode, "Shut down SOAP session OK {0}.", runrepSessionID);
                                    }
                                    catch (Exception ex)
                                    {
                                        log.WarnFormat(jobKeyCode, "Error shutting down SOAP session: {0} [Runrep ID: {1}]", ex, runrepSessionID);
                                    }

                                    if (wex.Message.IndexOf("Unknown element") > -1)
                                        throw (new ApplicationException(wex.Message));

                                    if (DateTime.Now.CompareTo(runStartTime.AddMinutes(minutesSoapRetry)) < 0)
                                    {
                                        isContingency = true;
                                        runrepSessionID = String.Empty;
                                        ifRetry = ifOverrideSoapErrorRetry ? false : true;
                                        SendMailMessage(jobKeyCode, mail_distribution, "BITS,[email protected]", Subject, wex.ToString());
                                        retval = StateEnums.Status.Warnings;

                                        Thread.Sleep(60000);
                                    }
                                    else
                                    {
                                        log.ErrorFormat(jobKeyCode, "Geneva SOAP call timed out. Giving up now.");
                                        SendMailMessage(jobKeyCode, mail_distribution, "BITS,[email protected]", Subject, "Geneva SOAP call timed out. Giving up now.");
                                        ifRetry = false;
                                        //retval = StateEnums.Status.Error;
                                        retval = StateEnums.Status.Warnings;
                                    }
                                }
                            }
                        }
                        catch (Exception exl)
                        {
                            log.Warn(jobKeyCode, exl);
                            retval = StateEnums.Status.Warnings;
                        }
                        finally
                        {
                            if (loaderReturn == null)
                            {
                                loaderReturn = new loaderResultsStruct();
                            }

                            UpdateActivityRun(jobKeyCode,runId, activityName, dataType, state.SourceFileName, sourceXdoc.DocumentElement.FirstChild.ChildNodes.Count,                            
                                loaderReturn, htIdentifierRef, htUserTranId1Ref, htTypeIndicatorRef, htXmlData, GetSubtypes_Keys(sourceXdoc,nsuri));
							

							AddToOutputs(this.Name + "_ActivityLog", GetActivityLog(jobKeyCode, runId, loaderReturn));
							AddToOutputs(this.Name + "_DataTable_TranIdPair", GetTranIdUserTranIdPairTable(sourceXdoc, nsuri, loaderReturn, this.Name + "_DataTable_TranIdPair"));
							//else
                            //    log.WarnFormat(((State)o).CurrentJobHash, "{0} is not set up in Geneva as valid Activity.", activityName);
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.ErrorFormat(jobKeyCode, "Error : {0}", ex);
                    //retval = StateEnums.Status.Error;
                    retval = StateEnums.Status.Warnings;
                }

                hpt.Stop();
                duration = hpt.Duration;
            }

            AddToOutputs(this.Name, sourceXdoc);
            AddToOutputs(this.Name + "_MailEnvelop", mailEnvelop);

            int activityIdEnding = UpdateProcessStatus(Enums.ProcessStatus.Success, "", (State)o);
            UpdateRecordCount(activityIdEnding, recCountTotal, recCountSuccess, recCountFailed);

            log.InfoFormat(jobKeyCode, "GenevaSoapSelect {0} processed {1} of {2} records in {1} seconds.", Name, recCountSuccess, recCountTotal, duration);

            return retval;
        }
예제 #7
0
        private int UpdateActivityRun(int activityId, string name, string dataType, string source, int numrecs,
            loaderResultsStruct loaderReturn, Hashtable htIdentifierRef, Hashtable htSubTypeRef, Hashtable htTypeRef, Hashtable htXmlData)
        {
            int ret = 0;

            try
            {
                string strUserIdentity = "fountainhead\bgoff";
                GenericIdentity objGenericIdentity = new GenericIdentity(strUserIdentity);
                CredentialPrincipal credPrincipal = new BAM.Repository.CredentialPrincipal(objGenericIdentity, null, strPerms); ;

                _dataRepository = config.GetRepository("GenevaPersistence");

                Hashtable ht = new Hashtable();
                Hashtable htRef = BuildSubTypeNameLookup();
                Hashtable htRecType = BuildRecordTypeLookup();

                int i = 0;
                if (loaderReturn.results != null)
                {
                    foreach (loaderResultsVectorElement result in loaderReturn.results)
                    {
                        string subTypeName = String.Empty;
                        string recType = String.Empty; string identifier = String.Empty;

                        if (htRef.ContainsKey(result.message))
                            subTypeName = htRef[result.message].ToString();
                        if (htRecType.ContainsKey(result.message))
                            recType = htRecType[result.message].ToString();

                        if (subTypeName.Equals(String.Empty))
                        {
                            if (result.keyValue.Equals(String.Empty))
                            {
                                identifier = htIdentifierRef[i].ToString();
                            }
                            else if (htTypeRef.ContainsKey(result.keyValue))
                            {
                                subTypeName = htSubTypeRef[result.keyValue].ToString();
                                identifier = result.keyValue;
                                recType = htTypeRef[result.keyValue].ToString();
                            }
                            else
                            {
                                subTypeName = "EquityNewType";
                                identifier = result.keyValue;
                            }
                        }

                        int rc = 0;
                        Int32.TryParse(result.code, out rc);

                        XmlDocument xdocXmlData = (XmlDocument)htXmlData[i++];

                        if (xdocXmlData != null)
                        {
                            XmlNode exceptionsNode = xdocXmlData.CreateElement("Exceptions", xdocXmlData.DocumentElement.NamespaceURI);

                            XmlNode exceptionNode = xdocXmlData.CreateElement("GenevaErrorCode", xdocXmlData.DocumentElement.NamespaceURI);
                            exceptionNode.InnerXml = result.code;
                            XmlNode exceptionMsgNode = xdocXmlData.CreateElement("Message", xdocXmlData.DocumentElement.NamespaceURI);
                            exceptionMsgNode.InnerXml = result.message;

                            exceptionsNode.AppendChild(exceptionNode);
                            exceptionsNode.AppendChild(exceptionMsgNode);
                            xdocXmlData.FirstChild.AppendChild(exceptionsNode);

                            ht.Clear();
                            ht.Add("RunID", activityId);
                            ht.Add("xmlData", xdocXmlData.InnerXml);
                            ht.Add("SubTypeName", subTypeName);
                            ht.Add("Identifier", identifier);
                            ht.Add("UserID", 0);
                            ht.Add("UserGroupID", 0);
                            ht.Add("ExceptionStatusCode", "m");
                            ht.Add("UserName", String.Empty);
                            ht.Add("dataType", dataType);
                            ht.Add("RecordType", recType);
                            ht.Add("Code", rc);
                            ht.Add("Message", result.message);
                            ht.Add("SuccessKeyValue", result.keyValue);

                            _dataRepository.ExecuteScalar("GenevaPersistence.AddActivityRunDetail", ht);
                        }
                    }
                }
                else
                    log.Warn(job.KeyCode, "No results received from SOAP update.");

                ht.Clear();
                ht.Add("RunID", activityId);
                ht.Add("StatusCode", 'e');
                ht.Add("EndDateTime", DateTime.Now);
                ht.Add("NumberOfRecords", numrecs);
                ht.Add("Note", "");
                ht.Add("Source", source);
                ht.Add("MessageId", "");

                ret = _dataRepository.ExecuteScalar("GenevaPersistence.UpdateActivityRun", ht);
            }
            catch (Exception ex)
            {
                log.Error(job.KeyCode, ex);
            }

            return ret;
        }