public static void GetPrimaryContactAddressStep( ICustevent custevent, out System.String result)
        {
            // TODO: Complete business rule implementation
            using (ISession session = new SessionScopeWrapper())
            {
                string sql = "select top 1 a.address1  from sysdba.opportunity_contact oc left join sysdba.contact c on oc.contactid=c.contactid left join sysdba.address a on a.entityid=c.contactid where oc.isprimary='T' and a.isprimary='T' and opportunityid='"+custevent.Id.ToString()+"'";
                string add1 = session.CreateSQLQuery(sql).UniqueResult<string>();

                sql = "select top 1 a.address2  from sysdba.opportunity_contact oc left join sysdba.contact c on oc.contactid=c.contactid left join sysdba.address a on a.entityid=c.contactid where oc.isprimary='T' and a.isprimary='T' and opportunityid='"+custevent.Id.ToString()+"'";
                string add2 = session.CreateSQLQuery(sql).UniqueResult<string>();

                sql = "select top 1 a.city  from sysdba.opportunity_contact oc left join sysdba.contact c on oc.contactid=c.contactid left join sysdba.address a on a.entityid=c.contactid where oc.isprimary='T' and a.isprimary='T' and opportunityid='"+custevent.Id.ToString()+"'";
                string city = session.CreateSQLQuery(sql).UniqueResult<string>();

                sql = "select top 1 a.state  from sysdba.opportunity_contact oc left join sysdba.contact c on oc.contactid=c.contactid left join sysdba.address a on a.entityid=c.contactid where oc.isprimary='T' and a.isprimary='T' and opportunityid='"+custevent.Id.ToString()+"'";
                string state = session.CreateSQLQuery(sql).UniqueResult<string>();

                sql = "select top 1 a.postalcode  from sysdba.opportunity_contact oc left join sysdba.contact c on oc.contactid=c.contactid left join sysdba.address a on a.entityid=c.contactid where oc.isprimary='T' and a.isprimary='T' and opportunityid='"+custevent.Id.ToString()+"'";
                string pcode = session.CreateSQLQuery(sql).UniqueResult<string>();

                sql = "select top 1 a.country  from sysdba.opportunity_contact oc left join sysdba.contact c on oc.contactid=c.contactid left join sysdba.address a on a.entityid=c.contactid where oc.isprimary='T' and a.isprimary='T' and opportunityid='"+custevent.Id.ToString()+"'";
                string country = session.CreateSQLQuery(sql).UniqueResult<string>();

                string fswon = string.Concat(add1," ",add2," ",city,", ",state," ",pcode," ",country);
                result=fswon;
            }
        }
 public static void GetWonServiceRevStep( ICustevent custevent, out System.Decimal result)
 {
     // TODO: Complete business rule implementation
     using (ISession session = new SessionScopeWrapper())
     {
         string sql = "select sum(extendedprice) from opportunity_product where status='Execution' and opportunityid='"+custevent.Id.ToString()+"'";
         decimal fswon = session.CreateSQLQuery(sql).UniqueResult<decimal>();
         result=fswon;
     }
 }
 public static void GetPrimaryContactPhoneStep2( ICustevent custevent, out System.String result)
 {
     // TODO: Complete business rule implementation
     using (ISession session = new SessionScopeWrapper())
     {
         string sql = "select top 1 c.workphone from sysdba.opportunity_contact oc left join sysdba.contact c on oc.contactid=c.contactid where oc.isprimary='T' and opportunityid='"+custevent.Id.ToString()+"'";
         string fswon = session.CreateSQLQuery(sql).UniqueResult<string>();
         result=fswon;
     }
 }
 public static void GetFirstServiceWonStep( ICustevent custevent, out System.DateTime result)
 {
     // TODO: Complete business rule implementation
     using (ISession session = new SessionScopeWrapper())
     {
         string sql = "select min(actualclose) from opportunity_product where opportunityid='"+custevent.Id.ToString()+"'";
         DateTime fswon = session.CreateSQLQuery(sql).UniqueResult<DateTime>();
         result=fswon;
     }
 }
        public static void GetInitialSalesRepStep( ICustevent custevent, out System.String result)
        {
            // TODO: Complete business rule implementation
            string fswon = string.Empty;
            try{
                using (ISession session = new SessionScopeWrapper())
                {
                    string sql = "select username from userinfo where userid='"+custevent.Account.AccountConferon.InitialSalesRep.ToString()+"'";
                    fswon = session.CreateSQLQuery(sql).UniqueResult<string>();

                }
            }
            catch(Exception){
            }
            result=fswon;
        }