Пример #1
0
        public static eModuleList GetModules()
        {
            string strUserID = clsSuiteCRMHelper.GetUserId();

            if (strUserID == "")
            {
                SuiteCRMUserSession.Login();
            }
            object data = new
            {
                @session = SuiteCRMUserSession.id
            };

            return(clsGlobals.GetResponse <eModuleList>("get_available_modules", data));
        }
        private ArrayList GetValidContactIDs(string strExcludedEmails = "")
        {
            string strUserID = clsSuiteCRMHelper.GetUserId();

            if (strUserID == "")
            {
                SuiteCRMUserSession.Login();
            }

            ArrayList arrRet         = new ArrayList();
            ArrayList arrCheckedList = new ArrayList();
            string    strEmails      = "";

            strEmails = From + ";" + To;
            //if (ArchiveType == 1)
            //    strEmails = From + ";" + To;
            //else if (ArchiveType == 2)
            //    strEmails = From;
            //else if (ArchiveType == 3)
            //    strEmails = To;
            if (strEmails != "")
            {
                try
                {
                    foreach (string strEmail in strEmails.Split(';'))
                    {
                        if (arrCheckedList.Contains(strEmail))
                        {
                            continue;
                        }

                        // To check Excluded Emails
                        if (strExcludedEmails != "")
                        {
                            string   strMails = strExcludedEmails;
                            string[] arrMails = strMails.Split(',', ';', '\n', ':', ' ', '\t');
                            foreach (string strSplitEmails in arrMails)
                            {
                                if (strEmail.Trim().ToUpper() == strSplitEmails.Trim().ToUpper())
                                {
                                    return(new ArrayList());
                                }
                            }
                        }

                        contactData = new
                        {
                            @session       = SuiteCRMUserSession.id,
                            @module_name   = "Contacts",
                            @query         = GetContactIDQuery(strEmail),
                            @order_by      = "",
                            @offset        = 0,
                            @select_fields = new string[] { "id" },
                            @max_results   = 1
                        };
                        var contactReturn = clsGlobals.GetResponse <RESTObjects.eContacts>("get_entry_list", contactData);

                        if (contactReturn.entry_list.Count > 0)
                        {
                            arrRet.Add(contactReturn.entry_list[0].id);
                        }
                        arrCheckedList.Add(strEmail);
                    }
                }
                catch (Exception ex)
                {
                    string strLog;
                    strLog  = "------------------" + System.DateTime.Now.ToString() + "-----------------\n";
                    strLog += "clsEmailArchive.GetValidContactIDs method General Exception:\n";
                    strLog += "Message:" + ex.Message + "\n";
                    strLog += "Source:" + ex.Source + "\n";
                    strLog += "StackTrace:" + ex.StackTrace + "\n";
                    strLog += "HResult:" + ex.HResult.ToString() + "\n";
                    strLog += "Inputs:" + "\n";
                    strLog += "Data:" + contactData.ToString() + "\n";
                    strLog += "-------------------------------------------------------------------------\n";
                    clsSuiteCRMHelper.WriteLog(strLog);

                    throw ex;
                }
            }
            return(arrRet);
        }