예제 #1
0
        public static string CheckBeforeAction(DynamicObject doOPP, Enum_OPPAction action)
        {
            string result = "";

            switch (action)
            {
            case Enum_OPPAction.WIN:
                result = CheckBeforeWin(doOPP);
                break;

            case Enum_OPPAction.UNWIN:
                result = CheckBeforeUnWin(doOPP);
                break;

            case Enum_OPPAction.LOSE:
                result = CheckBeforeLose(doOPP);
                break;

            case Enum_OPPAction.UNLOSE:
                result = CheckBeforeUnLose(doOPP);
                break;
            }
            return(result);
        }
예제 #2
0
        public static IOperationResult DoAction(Context context, string[] selPKArray, Enum_OPPAction action)
        {
            IOperationResult            operationResult         = new OperationResult();
            OperateResultCollection     operateResultCollection = new OperateResultCollection();
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            List <DynamicObject>        list       = new List <DynamicObject>();
            FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(context, "CRM_OPP_Opportunity", true);
            BusinessInfo businessInfo = formMetadata.BusinessInfo;

            DynamicObject[] array = BusinessDataServiceHelper.Load(context, selPKArray, businessInfo.GetDynamicObjectType());
            if (array == null || array.Length == 0)
            {
                operateResultCollection.Add(OpportunityCommon.CreateOperateResult(false, ResManager.LoadKDString("未找到对应的数据,可能已被删除!", "006008030001276", SubSystemType.CRM, new object[0])));
                operationResult.OperateResult = operateResultCollection;
                return(operationResult);
            }
            DynamicObject[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                DynamicObject dynamicObject = array2[i];
                string        text          = CheckBeforeAction(dynamicObject, action);
                if (text != "")
                {
                    operateResultCollection.Add(OpportunityCommon.CreateOperateResult(false, text));
                    operationResult.OperateResult = operateResultCollection;
                }
                else
                {
                    if (action == Enum_OPPAction.WIN)
                    {
                        dynamicObject["FDocumentStatus"] = "E";
                    }
                    else
                    {
                        if (action == Enum_OPPAction.LOSE)
                        {
                            dynamicObject["FDocumentStatus"] = "F";
                        }
                        else
                        {
                            if (action == Enum_OPPAction.UNWIN || action == Enum_OPPAction.UNLOSE)
                            {
                                dynamicObject["FDocumentStatus"] = "G";
                            }
                        }
                    }
                    if (action == Enum_OPPAction.WIN || action == Enum_OPPAction.LOSE)
                    {
                        DynamicObjectCollection dynamicObjectCollection = dynamicObject["T_CRM_OppPhase"] as DynamicObjectCollection;
                        foreach (DynamicObject current in dynamicObjectCollection)
                        {
                            if (current["FIsCurrent"].ToString() == "True")
                            {
                                current["FEndtimeReal"] = DateTime.Now;
                                break;
                            }
                        }
                    }
                    dictionary.Add(dynamicObject["Id"].ToString(), dynamicObject["FOPPName"].ToString());
                    list.Add(dynamicObject);
                }
            }
            if (list.Count > 0)
            {
                IOperationResult operationResult2 = BusinessDataServiceHelper.Save(context, businessInfo, list.ToArray(), null, "");
                if (action == Enum_OPPAction.WIN || action == Enum_OPPAction.LOSE)
                {
                    Dictionary <string, string> dictionary2 = new Dictionary <string, string>();
                    string format = ResManager.LoadKDString("赢单商机【{0}】", "006008030001476", SubSystemType.CRM, new object[0]);
                    string text2  = "Win";
                    if (action == Enum_OPPAction.LOSE)
                    {
                        format = ResManager.LoadKDString("输单商机【{0}】", "006008030001477", SubSystemType.CRM, new object[0]);
                        text2  = "Lose";
                    }
                    foreach (OperateResult current2 in operationResult2.OperateResult)
                    {
                        if (current2.SuccessStatus)
                        {
                            dictionary2.Add(current2.PKValue.ToString(), string.Format(format, dictionary[current2.PKValue.ToString()]));
                        }
                    }
                    if (dictionary2.Count > 0)
                    {
                        ILatestInfoService latestInfoService = ServiceFactory.GetLatestInfoService(context);
                        latestInfoService.AddActionInfo(context, "CRM_OPP_Opportunity", text2, dictionary2);
                    }
                }
                if (operationResult.OperateResult.Count > 0)
                {
                    using (IEnumerator <OperateResult> enumerator3 = operationResult2.OperateResult.GetEnumerator())
                    {
                        while (enumerator3.MoveNext())
                        {
                            OperateResult current3 = enumerator3.Current;
                            operationResult.OperateResult.Add(current3);
                        }
                        return(operationResult);
                    }
                }
                operationResult.OperateResult = operationResult2.OperateResult;
            }
            return(operationResult);
        }