コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
        /// <summary>
        /// Web bacjground job - Create Siebel Quote
        /// </summary>
        /// <param name="active"></param>
        /// <returns></returns>
        public static bool BatchCreateSiebelQuote(SiebelActive active)
        {
            string _wspara = string.Empty;
            string _errmsg = string.Empty;

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

                //先檢查QuotationMaster & QuotationDetail
                if (active.QuotationMaster == null)
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Quote failed: No quote master data in eQuotation", _wspara);
                    return(false);
                }
                if (active.QuotationDetail == null)
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Quote failed: No quote detail data in eQuotation", _wspara);
                    return(false);
                }

                //無論有無optyId都去呼叫Siebel web service
                string SiebelQuoteRowID = SiebelBusinessLogic.CreateSiebelQuoteWithOpty(active.QuoteID, active.OptyID, ref _wspara, ref _errmsg);

                if (!string.IsNullOrEmpty(_errmsg))
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Quote through Siebel WS failed: " + _errmsg, _wspara);
                    return(false);
                }
                if (string.IsNullOrEmpty(SiebelQuoteRowID))
                {
                    active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Quote through Siebel WS failed: Quote row id WS returned is String.IsNullOrEmpty", _wspara);
                    return(false);
                }

                //quoteID有值才代表成功
                active.UpdateActiveSuccess(SiebelActiveUpdatedUser.System, _wspara);

                //quoteSiebelQuote table不需要再insert,已經在SiebelDa做了
                return(true);
            }
            catch (Exception ex)
            {
                active.UpdateActiveFailed(SiebelActiveUpdatedUser.System, "Create Siebel Quote failed: " + ex.ToString(), _wspara);
                return(false);
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
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);
        }
コード例 #7
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);
            }
        }
コード例 #8
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);
            }
        }