コード例 #1
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);
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
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);
            }
        }