Example #1
0
        public bool IntegrateSFDCId_OperatortoDB(string Usernames, string UserName, string Password)
        {
            logger.Info("Scheduled Driver job triggered");
            bool                result  = false;
            SoapClient          ss      = new SoapClient();
            LoginResult         lr      = new LoginResult();
            DBAction            dba     = new DBAction(_integrationAppSettings);
            List <ClsUsersList> ObjList = new List <ClsUsersList>();

            if (sessionId == null | sessionId == "")
            {
                // Login Call
                var lastintegratedDate = dba.GetLastintegratedDateandTime("Integrate_CustomerInfo");
                lr = ss.login(null, UserName, Password);
                if (!lr.passwordExpired)
                {
                    sessionId = lr.sessionId.ToString().Trim();
                    serverUrl = lr.serverUrl.ToString().Trim();
                    // Store SessionId in SessionHeader; We will need while making query() call
                    SessionHeader sHeader = new SessionHeader();
                    sHeader.sessionId = sessionId;

                    // Variable to store query results
                    QueryResult qr  = new QueryResult();
                    SoapClient  ss1 = new SoapClient();
                    ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(serverUrl);
                    ss1.query(sHeader, null, null, null, @"Select Id,EmployeeNumber,UserRoleID,IsActive,Username,CompanyName From User WHERE Username IN (" + Usernames + ")", out qr);

                    sObject[] records = qr.records;
                    if (records != null)
                    {
                        if (records.Length > 0)
                        {
                            for (int i = 0; i <= records.Length - 1; i++)
                            {
                                ClsUsersList Obj = new ClsUsersList();
                                Obj.Id         = ((SfServiceRef.User)qr.records[i]).Id;
                                Obj.IsActive   = (bool)((SfServiceRef.User)qr.records[i]).IsActive;
                                Obj.UserName   = ((SfServiceRef.User)qr.records[i]).Username;
                                Obj.UserRoleID = ((SfServiceRef.User)qr.records[i]).UserRoleId;
                                ObjList.Add(Obj);
                            }
                            dba.IntegrateAllDriver(ObjList);
                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                    }
                }
            }
            return(result);
        }
Example #2
0
        public bool IntegerateSfCustServiceLine(string userName, string password)
        {
            logger.Info("Scheduled Customer Service Line job triggered");
            DBAction dba          = new DBAction(_integrationAppSettings);
            string   filterstring = dba.GetSalesforceInformation().Replace("\n", "");
            bool     result       = false;
            List <CustomerServiceLine> ltsCusline = new List <CustomerServiceLine>();

            SoapClient       ss = new SoapClient();
            LoginResult      lr = new LoginResult();
            LoginScopeHeader LH = new LoginScopeHeader();

            if (sessionId == null | sessionId == "")
            {
                lr = ss.login(null, userName, password);
                if (!lr.passwordExpired)
                {
                    sessionId = lr.sessionId.ToString().Trim();
                    serverUrl = lr.serverUrl.ToString().Trim();
                }
            }

            // Store SessionId in SessionHeader; We will need while making query() call
            SessionHeader sHeader = new SessionHeader();

            sHeader.sessionId = sessionId;

            // Variable to store query results
            QueryResult qr  = new QueryResult();
            SoapClient  ss1 = new SoapClient();

            ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(serverUrl);

            var lastintegratedDate = dba.GetLastintegratedDateandTime("Last_CustomerLineIntegrate");

            // if (lastintegratedDate == null)
            ss1.query(sHeader, null, null, null, @"SELECT Id
                                                    ,Name
                                                    ,enrtcr__Remaining__c
                                                    ,enrtcr__Item_Overclaim__c
                                                    ,enrtcr__Support_Contract__c
                                                    ,enrtcr__Support_Contract__r.Name
                                                    ,enrtcr__Support_Contract__r.enrtcr__End_Date__c
                                                    ,enrtcr__Support_Contract__r.enrtcr__Status__c
                                                    ,enrtcr__Support_Contract__r.enrtcr__Funding_Type__c
                                                    ,enrtcr__Support_Contract__r.enrtcr__Funding_Management__c
                                                    ,enrtcr__Support_Contract__r.enrtcr__Client__c
                                                    ,enrtcr__Category_Item__r.enrtcr__Support_Category_Amount__c
                                                    ,enrtcr__Category_Item__r.enrtcr__Delivered__c
                                                    ,enrtcr__Site__c
                                                    ,enrtcr__Site__r.Name
                                                    ,enrtcr__Site__r.enrtcr__Site_GL_Code__c
                                                    ,enrtcr__Service__c
                                                    ,enrtcr__Service__r.Name
                                                    ,enrtcr__Site_Service_Program__c
                                                    ,enrtcr__Rate__c
                                                    ,enrtcr__Rate__r.Name
                                                    ,enrtcr__Rate__r.enrtcr__Amount_Ex_GST__c
                                                    ,enrtcr__Rate__r.enrtcr__Quantity_Type__c
                                                    ,enrtcr__Rate__r.enrtcr__Allow_Rate_Negotiation__c
                                                    FROM enrtcr__Support_Contract_Item__c
                                                    WHERE(" + filterstring + ") AND enrtcr__Support_Contract__r.enrtcr__Status__c = 'Current' ", out qr);
            //else
            //{
            //    var UTCTime = Convert.ToDateTime(lastintegratedDate).ToString("yyyy-MM-dd") + "T" + Convert.ToDateTime(lastintegratedDate).ToString("HH:mm:ss") + "Z";
            //    ss1.query(sHeader, null, null, null, @"SELECT Id
            //                                        ,Name
            //                                        ,enrtcr__Remaining__c
            //                                        ,enrtcr__Item_Overclaim__c
            //                                        ,enrtcr__Support_Contract__c
            //                                        ,enrtcr__Support_Contract__r.Name
            //                                        ,enrtcr__Support_Contract__r.enrtcr__End_Date__c
            //                                        ,enrtcr__Support_Contract__r.enrtcr__Status__c
            //                                        ,enrtcr__Support_Contract__r.enrtcr__Funding_Type__c
            //                                        ,enrtcr__Support_Contract__r.enrtcr__Funding_Management__c
            //                                        ,enrtcr__Support_Contract__r.enrtcr__Client__c
            //                                        ,enrtcr__Category_Item__r.enrtcr__Support_Category_Amount__c
            //                                        ,enrtcr__Category_Item__r.enrtcr__Delivered__c
            //                                        ,enrtcr__Site__c
            //                                        ,enrtcr__Site__r.Name
            //                                        ,enrtcr__Site__r.enrtcr__Site_GL_Code__c
            //                                        ,enrtcr__Service__c
            //                                        ,enrtcr__Service__r.Name
            //                                        ,enrtcr__Site_Service_Program__c
            //                                        ,enrtcr__Rate__c
            //                                        ,enrtcr__Rate__r.Name
            //                                        ,enrtcr__Rate__r.enrtcr__Amount_Ex_GST__c
            //                                        ,enrtcr__Rate__r.enrtcr__Quantity_Type__c
            //                                        ,enrtcr__Rate__r.enrtcr__Allow_Rate_Negotiation__c,LastModifiedDate
            //                                        FROM enrtcr__Support_Contract_Item__c
            //                                        WHERE(" + filterstring + ") AND enrtcr__Support_Contract__r.enrtcr__Status__c = 'Current' and LastModifiedDate > YESTERDAY", out qr);

            //}

            sObject[] records = qr.records;

            if (records != null)
            {
                if (records.Length > 0)
                {
                    for (var i = 0; i <= records.Length - 1; i++)
                    {
                        CustomerServiceLine csl = new CustomerServiceLine();
                        var customerId          = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Client__c;
                        csl.ServiceAgreementCustomerId = dba.GetCustomerId(customerId);
                        csl.ServiceAgreementId         = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__c;;
                        csl.ServiceAgreementName       = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.Name;
                        csl.ServiceAgreementEndDate    = Convert.ToDateTime(((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__End_Date__c);

                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Current")
                        {
                            csl.ServiceAgreementStatus = (int)CustomerStatus.Current;
                        }
                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Expired")
                        {
                            csl.ServiceAgreementStatus = (int)CustomerStatus.Expired;
                        }
                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Rollover")
                        {
                            csl.ServiceAgreementStatus = (int)CustomerStatus.Rollover;
                        }
                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Cancelled")
                        {
                            csl.ServiceAgreementStatus = (int)CustomerStatus.Cancelled;
                        }
                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Quote Submitted")
                        {
                            csl.ServiceAgreementStatus = (int)CustomerStatus.QuoteSubmitted;
                        }
                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Client Declined")
                        {
                            csl.ServiceAgreementStatus = (int)CustomerStatus.ClientDeclined;
                        }

                        csl.ServiceAgreementFundingManagement = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Funding_Management__c;
                        csl.ServiceAgreementFundingType       = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Funding_Type__c;
                        csl.ServiceAgreementItemId            = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).Id;
                        csl.ServiceAgreementItemName          = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).Name;
                        csl.SupportCategoryAmount             = (float)((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Category_Item__r.enrtcr__Support_Category_Amount__c;
                        csl.SupportCategoryDelivered          = (float?)((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Category_Item__r.enrtcr__Delivered__c;
                        csl.FundsRemaining = (float?)((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Remaining__c;

                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Item_Overclaim__c == "Allow")
                        {
                            csl.ItemOverclaim = (int)ItemOverClaim.Allow;
                        }
                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Item_Overclaim__c == "Warn")
                        {
                            csl.ItemOverclaim = (int)ItemOverClaim.Warn;
                        }
                        if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Item_Overclaim__c == "Prevent")
                        {
                            csl.ItemOverclaim = (int)ItemOverClaim.Prevent;
                        }


                        csl.SiteId   = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site__c;
                        csl.SiteName = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site__r.Name;
                        // csl.SiteGlCode = "";
                        csl.SiteServiceProgramId = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site_Service_Program__c;
                        csl.ServiceId            = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Service__c;
                        csl.ServiceName          = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Service__r.Name;
                        csl.RateId               = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__c;
                        csl.RateName             = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.Name;
                        csl.RateAmount           = (float?)((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Amount_Ex_GST__c;
                        csl.RateType             = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Quantity_Type__c;
                        csl.AllowRateNegotiation = Convert.ToBoolean(((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Allow_Rate_Negotiation__c == null ? false : true);
                        csl.Default              = false;
                        ltsCusline.Add(csl);
                    }
                    //Insert record to Database

                    dba.IntegrateCustomerLineinfointoDB(ltsCusline);
                }
                result = true;
            }
            return(result);
        }
Example #3
0
        public bool IntegerateSfCustomeList(string userName, string password)
        {
            logger.Info("Scheduled Customer List job triggered");
            List <Customer> lstCus = new List <Customer>();
            bool            result = false;

            SoapClient       ss    = new SoapClient();
            LoginResult      lr    = new LoginResult();
            LoginScopeHeader LH    = new LoginScopeHeader();
            DBAction         dba   = new DBAction(_integrationAppSettings);
            var lastintegratedDate = dba.GetLastintegratedDateandTime("Last_CustomerIntegrate");

            if (sessionId == null | sessionId == "")
            {
                lr = ss.login(null, userName, password);
                if (!lr.passwordExpired)
                {
                    sessionId = lr.sessionId.ToString().Trim();
                    serverUrl = lr.serverUrl.ToString().Trim();
                    // Store SessionId in SessionHeader; We will need while making query() call
                    SessionHeader sHeader = new SessionHeader();
                    sHeader.sessionId = sessionId;

                    // Variable to store query results
                    QueryResult qr  = new QueryResult();
                    SoapClient  ss1 = new SoapClient();
                    ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(serverUrl);

                    //  if (lastintegratedDate == null)
                    ss1.query(sHeader, null, null, null, @"SELECT Id,Name,OtherStreet,OtherCity,OtherState,OtherPostalCode,RecordType.Name,Enrite_Care_Auto_Number__c,enrtcr__Status__c,LastModifiedDate FROM Contact WHERE RecordType.Name = 'Client' 
                        AND (enrtcr__Status__c='Current' OR enrtcr__Status__c='Deceased' OR enrtcr__Status__c='Inactive')", out qr);
                    //else
                    //{
                    //    var UTCDate = Convert.ToDateTime(lastintegratedDate);
                    //    var UTCTime = UTCDate.ToString("yyyy-MM-dd") + "T" + UTCDate.ToString("HH:mm:ss") + "Z";

                    //    ss1.query(sHeader, null, null, null, @"SELECT Id,Name,OtherStreet,OtherCity,OtherState,OtherPostalCode,RecordType.Name,Enrite_Care_Auto_Number__c,enrtcr__Status__c,LastModifiedDate FROM Contact WHERE RecordType.Name = 'Client'
                    //    AND (enrtcr__Status__c='Current' OR enrtcr__Status__c='Deceased' OR enrtcr__Status__c='Inactive') and LastModifiedDate >YESTERDAY", out qr);

                    //}
                    sObject[] records = qr.records;
                    if (records != null)
                    {
                        if (records.Length > 0)
                        {
                            for (var i = 0; i <= records.Length - 1; i++)
                            {
                                Customer cs = new Customer();
                                cs.CustomerId = ((SfServiceRef.Contact)qr.records[i]).Id;
                                cs.Name       = ((SfServiceRef.Contact)qr.records[i]).Name;
                                cs.Street     = ((SfServiceRef.Contact)qr.records[i]).OtherStreet;
                                cs.City       = ((SfServiceRef.Contact)qr.records[i]).OtherCity;
                                cs.State      = ((SfServiceRef.Contact)qr.records[i]).OtherState;
                                cs.PostalCode = ((SfServiceRef.Contact)qr.records[i]).OtherPostalCode;
                                cs.LumaryId   = ((SfServiceRef.Contact)qr.records[i]).Enrite_Care_Auto_Number__c;
                                if (((SfServiceRef.Contact)qr.records[i]).enrtcr__Status__c != null)
                                {
                                    cs.Active = false;
                                    if (((SfServiceRef.Contact)qr.records[i]).enrtcr__Status__c == "Current")
                                    {
                                        cs.Status = 1;
                                    }
                                    if (((SfServiceRef.Contact)qr.records[i]).enrtcr__Status__c == "Deceased")
                                    {
                                        cs.Status = 2;
                                    }
                                    if (((SfServiceRef.Contact)qr.records[i]).enrtcr__Status__c == "Inactive")
                                    {
                                        cs.Status = 3;
                                    }
                                }
                                cs.Active = true;
                                cs.OnHold = false;
                                lstCus.Add(cs);
                            }
                        }

                        dba.IntegrateCustomerInfotoDB(lstCus);
                    }
                }
                result = true;
            }
            return(result);
        }