Пример #1
0
        /// <summary>
        /// Create QuoteActive的指令檔,quoteID必填,同時必須有對應的QuotationMaster資料
        /// </summary>
        /// <param name="active"></param>
        /// <returns>true or false</returns>
        public static bool CreateQuoteActive(SiebelActive active)
        {
            if (string.IsNullOrEmpty(active.QuoteID))
            {
                active.FailedLog = "eQuote ID is null";
                return(false);
            }

            if (active.QuotationMaster == null)
            {
                active.FailedLog = "No QuotationMaster data!";
                return(false);
            }

            active.ActiveSource    = SiebelActiveSource.eQuotation.ToString();
            active.ActiveType      = SiebelActiveType.CreateActivity.ToString();
            active.Status          = SiebelActiveStatus.UnProcess.ToString();
            active.CreatedDate     = DateTime.Now;
            active.LastUpdatedDate = DateTime.Now;

            if (!SiebelDAL.CreateSiebelActive(active))
            {
                return(false); //創建SiebelActive失敗,錯誤訊息紀錄在active.FailedLog內
            }
            return(true);
        }
Пример #2
0
        public static List <SiebelActive> GetQuotationMasterForProductForecast(DateTime dt)
        {
            var qm = SiebelDAL.GetQuotationMasterForProductForecast(dt);

            List <SiebelActive> result = new List <SiebelActive>();

            foreach (var q in qm)
            {
                if (q.QuotationOpty != null && !string.IsNullOrEmpty(q.QuotationOpty.optyId) && q.QuotationDetail.Count > 0)
                {
                    string       errMsg = string.Empty;
                    SiebelActive sa     = new SiebelActive();
                    sa.OptyID  = q.QuotationOpty.optyId;
                    sa.QuoteID = q.quoteId;
                    if (SiebelDAL.UpdateForecast(q, ref errMsg) == false)
                    {
                        sa.FailedLog = errMsg;
                    }
                    else
                    {
                        sa.FailedLog = "Success";
                    }
                    result.Add(sa);
                }
            }
            return(result);
        }
Пример #3
0
        public static string CreateSiebelQuoteWithOpty(string eQuoteID, string optyid, ref string WSParameters, ref string ErrorMSG)
        {
            if (string.IsNullOrEmpty(eQuoteID))
            {
                ErrorMSG = "eQuotation Quote ID is string.IsNullOrEmpty";
                return(string.Empty);
            }
            try
            {
                QuotationMaster QM = QuoteBusinessLogic.GetQuotationMaster(eQuoteID);
                if (QM == null)
                {
                    ErrorMSG = "Quote master cannot be found in eQuotation";
                    return(string.Empty);
                }
                List <QuotationDetail> QD = QuoteBusinessLogic.GetQuotationDetail(eQuoteID);

                //ICC 2015/11/3 Use new Siebel web service to add quote
                return(SiebelDAL.CreateSiebelQuoteV2(QM, QD, optyid, ref WSParameters, ref ErrorMSG));
                //return SiebelDAL.CreateSiebelQuote(QM, QD, optyid, ref WSParameters, ref ErrorMSG);
                //return SiebelDAL.CreateSiebelQuote(QM, QD, optyid, WS_ID, WS_PASSWORD);
            }
            catch (Exception ex)
            {
                ErrorMSG = ex.Message;
            }
            return(string.Empty);
        }
Пример #4
0
        /// <summary>
        /// Update Opty的指令檔,quoteID必填,同時必須有對應的QuotationMaster資料
        /// </summary>
        /// <param name="active"></param>
        /// <returns></returns>
        public static bool UpdateOpportunityCommand(SiebelActive active)
        {
            if (string.IsNullOrEmpty(active.OptyID) && string.IsNullOrEmpty(active.QuoteID))
            {
                //eQuoteID有可能有null,因為有可能從MyAdvantech過來,所以改為QuoteID & OptyID 同時都是空時才報錯
                active.FailedLog = "eQuote ID and Opportunity ID are all null";
                return(false);
            }

            if (string.IsNullOrEmpty(active.OptyID) && active.QuotationMaster == null)
            {
                active.FailedLog = "No QuotationMaster data!";
                return(false);
            }

            ////檢查 optyName (原本Business.vb的邏輯)
            //if (string.IsNullOrEmpty(active.OptyName))
            //{
            //    if (active.QuotationMaster.Revision_Number != null && active.QuotationMaster.Revision_Number > 0)
            //    {
            //        active.OptyName = string.Format("{0}V{1}", active.SiebelOpty.optyName, active.QuotationMaster.Revision_Number);
            //    }
            //}

            ////檢查Owner email (原本SiebelTools的邏輯)
            //if (string.IsNullOrEmpty(active.OptyOwnerEmail) && active.QuotationMaster != null)
            //{
            //    if (!string.IsNullOrEmpty(active.QuotationMaster.salesEmail))
            //        active.OptyOwnerEmail = active.QuotationMaster.salesEmail;
            //    else if (!string.IsNullOrEmpty(active.QuotationMaster.createdBy))
            //        active.OptyOwnerEmail = active.QuotationMaster.createdBy;
            //    else if (string.IsNullOrEmpty(active.QuotationMaster.attentionRowId))
            //        active.OptyOwnerEmail = active.QuotationMaster.attentionRowId;
            //}

            if (string.IsNullOrEmpty(active.ActiveSource))
            {
                active.ActiveSource = SiebelActiveSource.eQuotation.ToString();
            }
            if (string.IsNullOrEmpty(active.ActiveType))
            {
                active.ActiveType = SiebelActiveType.UpdateOpportunity.ToString();
            }
            if (string.IsNullOrEmpty(active.Status))
            {
                active.Status = SiebelActiveStatus.UnProcess.ToString();
            }
            active.CreatedDate     = DateTime.Now;
            active.LastUpdatedDate = DateTime.Now;

            if (!SiebelDAL.CreateSiebelActive(active))
            {
                return(false); //創建SiebelActive失敗,錯誤訊息紀錄在active.FailedLog內
            }
            return(true);
        }
Пример #5
0
 public static bool AssociateSiebelSAPAccountContact(bool isTesting, string orderNo, string ERPID)
 {
     Advantech.Myadvantech.DataAccess.Entities.Order order = BBeStoreDAL.GetBBeStoreOrderByOrderNo(orderNo);
     if (order != null && order.Cart != null && order.Cart.SoldToContact != null)
     {
         DataAccess.SAPDAL.CreateSAPContact(isTesting, ERPID, order.Cart.SoldToContact.FirstName, order.Cart.SoldToContact.LastName, order.UserID, string.Empty, string.Empty, "0005", "12");
         return(SiebelDAL.AssociateSiebelSAPAccountContact(order.UserID, order.Cart.SoldToContact.FirstName, order.Cart.SoldToContact.LastName, ERPID.ToUpper(), string.Empty, false, true));
     }
     return(false);
 }
Пример #6
0
        /// <summary>
        /// Web bacjground job - Create Siebel Activity
        /// </summary>
        /// <param name="active"></param>
        /// <returns></returns>
        public static bool BatchCreateSiebelActivity(SiebelActive active)
        {
            string wsparas  = string.Empty;
            string wserrmsg = string.Empty;

            try
            {
                //先把狀態更新成Processing以免任何失敗造成job一直執行這筆指令
                active.UpdateActiveProcessing(SiebelActiveUpdatedUser.System);

                if (string.IsNullOrEmpty(active.QuoteID) || active.QuotationMaster == null)
                {
                    //active.FailedLog = "Create Siebel Activity failed! No master data";
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Activity failed: No Quotation master data in eQuotation", "");
                    return(false);
                }

                string SiebelActivityRowID = SiebelDAL.CreateSiebleActivityV2(active, ref wsparas, ref wserrmsg);

                if (!string.IsNullOrEmpty(wserrmsg))
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Activity failed: " + wserrmsg, wsparas);
                    return(false);
                }

                if (string.IsNullOrEmpty(SiebelActivityRowID))
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Acvivity Row ID Siebel WS returned is string.IsNullOrEmpty", wsparas);
                    return(false);
                }

                active.UpdateActiveSuccess(SiebelActiveUpdatedUser.System, wsparas);
                return(true);
            }
            catch (Exception ex)
            {
                active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Activity failed: " + ex.ToString(), wsparas);
                return(false);
            }
        }
Пример #7
0
 public static List <SiebelActive> GetActiveList(SiebelActiveStatus status, SiebelActiveType type, int count = 10)
 {
     return(SiebelDAL.GetActiveList(status, type, count));
 }
Пример #8
0
 public static bool UpdateSiebelContactByWS(SIEBEL_CONTACT contact)
 {
     return(SiebelDAL.UpdateSiebelContactByWS(contact));
 }
Пример #9
0
 public static string CreateSiebelContactByWS(SIEBEL_CONTACT contact)
 {
     return(SiebelDAL.CreateSiebelContactByWS(contact));
 }
Пример #10
0
 public static SIEBEL_CONTACT GetSiebelContact(string RowID)
 {
     return(SiebelDAL.GetSiebelContact(RowID));
 }
Пример #11
0
        /// <summary>
        /// Create Opty的指令檔,quoteID必填,同時必須有對應的QuotationMaster資料
        /// </summary>
        /// <param name="active"></param>
        /// <returns>true or false</returns>
        public static bool CreateOpportunityCommand(SiebelActive active)
        {
            if (string.IsNullOrEmpty(active.QuoteID))
            {
                active.FailedLog = "eQuote ID is null";
                return(false);
            }
            if (SiebelDAL.GetActiveListForCheck(SiebelActiveStatus.UnProcess, SiebelActiveType.CreateOpportunity, active.QuoteID, active.OptyName, 1).Count() > 0)
            {
                active.FailedLog = "Opportunity is already exists";
                return(false);
            }
            if (active.QuotationMaster == null)
            {
                active.FailedLog = "No QuotationMaster data!";
                return(false);
            }
            //2015/6/9 Add new rule to check opty owner email
            if (string.IsNullOrEmpty(active.OptyOwnerEmail))
            {
                active.FailedLog = "No Opty owner email";
                return(false);
            }
            //檢查 optyName (原本Business.vb的邏輯)
            if (string.IsNullOrEmpty(active.OptyName))
            {
                if (active.QuotationMaster.Revision_Number != null && active.QuotationMaster.Revision_Number > 0)
                {
                    active.OptyName = string.Format("{0}V{1}", active.SiebelOpty.optyName, active.QuotationMaster.Revision_Number);
                }
            }

            //檢查 optySate (原本Business.vs的邏輯)
            if (string.IsNullOrEmpty(active.OptyStage))
            {
                active.OptyStage = "25% Proposing/Quoting";
            }

            //檢查Owner email (原本SiebelTools的邏輯) 2015/6/9 This rule is still in Business.vb and it will prevent someone's eQutation ID is not equal to SIEBEL ID.
            //if (string.IsNullOrEmpty(active.OptyOwnerEmail))
            //{
            //    if (!string.IsNullOrEmpty(active.QuotationMaster.salesEmail))
            //        active.OptyOwnerEmail = active.QuotationMaster.salesEmail;
            //    else if (!string.IsNullOrEmpty(active.QuotationMaster.createdBy))
            //        active.OptyOwnerEmail = active.QuotationMaster.createdBy;
            //    else if (string.IsNullOrEmpty(active.QuotationMaster.attentionRowId))
            //        active.OptyOwnerEmail = active.QuotationMaster.attentionRowId;
            //}

            active.ActiveSource    = SiebelActiveSource.eQuotation.ToString();
            active.ActiveType      = SiebelActiveType.CreateOpportunity.ToString();
            active.Status          = SiebelActiveStatus.UnProcess.ToString();
            active.CreatedDate     = DateTime.Now;
            active.LastUpdatedDate = DateTime.Now;

            if (!SiebelDAL.CreateSiebelActive(active))
            {
                return(false); //創建SiebelActive失敗,錯誤訊息紀錄在active.FailedLog內
            }
            return(true);
        }
Пример #12
0
        /// <summary>
        /// Web background job - Update Siebel Opportunity
        /// </summary>
        /// <param name="active"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public static bool BatchUpdateSiebelOpportunity(SiebelActive active)
        {
            string wsparas  = string.Empty;
            string wserrmsg = string.Empty;

            try
            {
                //先把狀態更新成Processing以免任何失敗造成job一直執行這筆指令
                active.UpdateActiveProcessing(SiebelActiveUpdatedUser.System);

                if (string.IsNullOrEmpty(active.OptyID))
                {
                    if (active.SiebelOpty == null)
                    {
                        //Opportunity ID 是空 而且optyQuote的optyID也找不到
                        active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Update Siebel Opportunity failed: Object SiebelOpty is null", wsparas);
                        return(false);
                    }

                    if (string.IsNullOrEmpty(active.SiebelOpty.optyId))
                    {
                        //Opportunity ID 是空 而且optyQuote的optyID也找不到
                        active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Update Siebel Opportunity failed: OptyID of Object SiebelOpty is null", wsparas);
                        return(false);
                    }

                    active.OptyID = active.SiebelOpty.optyId;
                }

                if (!SiebelDAL.UpdateSiebelOptyV2(active, ref wsparas, ref wserrmsg))
                {
                    //Update Siebel Opportunity fail
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Update Siebel Opportunity through Siebel WS failed: " + wserrmsg, wsparas);
                    return(false);
                }

                //Frank 20150411先暫時不用執行這段
                ////走到這表示update成功,最後將SiebelActive的數據更新到optyQuote
                //if (active.SiebelOpty != null)
                //{
                //    if (!string.IsNullOrEmpty(active.OptyName))
                //        active.SiebelOpty.optyName = active.OptyName;

                //    if (!string.IsNullOrEmpty(active.OptyStage))
                //        active.SiebelOpty.optyStage = active.OptyStage;

                //    if (!string.IsNullOrEmpty(active.OptyOwnerEmail))
                //        active.SiebelOpty.Opty_Owner_Email = active.OptyOwnerEmail;

                //    active.SiebelOpty.Update();
                //}

                //Update Siebel Opportunity success
                active.UpdateActiveSuccess(SiebelActiveUpdatedUser.System, wsparas);
                return(true);
            }
            catch (Exception ex)
            {
                active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Update Siebel Opportunity failed: " + ex.ToString(), wsparas);
                return(false);
            }
        }
Пример #13
0
        /// <summary>
        /// Web background job - Create Siebel Opportunity
        /// </summary>
        /// <param name="active"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public static bool BatchCreateSiebelOpportunity(SiebelActive active)
        {
            string row_id   = string.Empty;
            string wsparas  = string.Empty;
            string wserrmsg = string.Empty;

            try {
                //先把狀態更新成Processing以免任何失敗造成job一直執行這筆指令
                active.UpdateActiveProcessing(SiebelActiveUpdatedUser.System);

                row_id = SiebelDAL.CreateSiebelOptyV2(active, ref wsparas, ref wserrmsg);

                if (!string.IsNullOrEmpty(wserrmsg))
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Opportunity through Siebel web service failed: " + wserrmsg, wsparas);
                    return(false);
                }


                if (string.IsNullOrEmpty(row_id))
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Opportunity Row id Siebel WS returned is string.isNullOrEmpty", wsparas);
                    return(false);
                }

                if (row_id.Equals("NULL", StringComparison.InvariantCultureIgnoreCase))
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Opportunity Row id Siebel WS returned is Null string!", wsparas);
                    return(false);
                }
            }
            catch (Exception e) {
                active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Opportunity failed: " + e.Message, wsparas);
                return(false);
            }

            try
            {
                /*
                 * 檢查SiebelActive裡面,是否有別的數據(同quoteID),
                 * 預防同一批次作業中,還要再Create Quote或Update Opty的情況
                 * Case 1: Create Opty後 還要Create Quote
                 * Case 2: Create Opty後 還要Update Opty
                 * Case 3: Create Opty後 先Update Opty 再Create Quote
                 */
                List <SiebelActive> list = SiebelDAL.GetSiebelActiveByQuoteID(active.QuoteID, active.ID); //必須排除自己這筆紀錄

                if (list != null)
                {
                    foreach (SiebelActive sa in list)
                    {
                        //sa.OptyID = row_id;
                        //sa.Update();
                        SiebelDAL.updateOptyID(sa.ID, row_id);
                    }
                }

                //2015/4/27 Also have to check and update [MyAdvantechGlobal].[CARTMASTERV2].[optyID] after creating Opportunity successfully
                MyAdvantechDAL.UpdateOptyID(active.QuoteID, row_id);

                /*
                 * end
                 */

                //建立Siebel opty成功
                active.UpdateActiveSuccess(SiebelActiveUpdatedUser.System, wsparas);

                active.UpdateOptyIDtoOptyQuote(active.QuoteID, row_id);

                ////檢查optyQuote table 把optyId跟相關的數據一併更新過去
                //if (active.SiebelOpty == null)
                //{
                //    optyQuote opty = new optyQuote();
                //    opty.quoteId = active.QuoteID;
                //    opty.optyId = active.OptyID;
                //    opty.optyStage = active.OptyStage;
                //    opty.Opty_Owner_Email = active.OptyOwnerEmail;
                //    opty.Add();
                //}
                //else
                //{
                //    active.SiebelOpty.optyId = active.OptyID;
                //    active.SiebelOpty.optyName = active.OptyName;
                //    active.SiebelOpty.optyStage = active.OptyStage;
                //    active.SiebelOpty.Opty_Owner_Email = active.OptyOwnerEmail;
                //    active.SiebelOpty.Update();
                //}
                return(true);
            }
            catch (Exception ex)
            {
                active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Opportunity failed: " + ex.ToString(), wsparas);
                return(false);
            }
        }