예제 #1
0
        }       //	prepare

        /// <summary>
        ///	Process - Test EMail
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            MClient client = MClient.Get(GetCtx(), _AD_Client_ID);

            log.Info(client.ToString());

            //	 Test Client Mail
            String clientTest = client.TestEMail();

            AddLog(0, null, null, client.GetName() + ": " + clientTest);

            //	Test Client DocumentDir
            if (!Ini.IsClient())
            {
                String documentDir = client.GetDocumentDir();
                if (documentDir == null || documentDir.Length == 0)
                {
                    documentDir = ".";
                }
                //File file = new File (documentDir);
                //System.IO.FileInfo  file= new System.IO.FileInfo(documentDir);
                System.IO.FileAttributes fil = new System.IO.FileAttributes();
                fil = System.IO.File.GetAttributes(documentDir);
                //if (file.Exists() && file.isDirectory())
                if ((fil & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory)
                {
                    AddLog(0, null, null, "Found Directory: " + client.GetDocumentDir());
                }
                else
                {
                    AddLog(0, null, null, "Not Found Directory: " + client.GetDocumentDir());
                }
            }

            MStore[] wstores = MStore.GetOfClient(client);
            for (int i = 0; i < wstores.Length; i++)
            {
                MStore store = wstores[i];
                String test  = store.TestEMail();
                AddLog(0, null, null, store.GetName() + ": " + test);
            }

            return(clientTest);
        } //	doIt
예제 #2
0
        }       //	doIt

        /// <summary>
        ///	Send to InterestArea
        /// </summary>
        private void SendInterestArea()
        {
            log.Info("R_InterestArea_ID=" + _R_InterestArea_ID);
            _ia = MInterestArea.Get(GetCtx(), _R_InterestArea_ID);
            String unsubscribe = null;

            if (_ia.IsSelfService())
            {
                unsubscribe = "\n\n---------.----------.----------.----------.----------.----------\n"
                              + Msg.GetElement(GetCtx(), "R_InterestArea_ID")
                              + ": " + _ia.GetName()
                              + "\n" + Msg.GetMsg(GetCtx(), "UnsubscribeInfo")
                              + "\n";
                MStore[] wstores = MStore.GetOfClient(_client);

                int index = 0;
                for (int i = 0; i < wstores.Length; i++)
                {
                    if (wstores[i].IsDefault())
                    {
                        index = i;
                        break;
                    }
                }
                if (wstores.Length > 0)
                {
                    unsubscribe += wstores[index].GetWebContext(true);
                }
            }

            //
            String sql = "SELECT u.Name, u.EMail, u.AD_User_ID "
                         + "FROM R_ContactInterest ci"
                         + " INNER JOIN AD_User u ON (ci.AD_User_ID=u.AD_User_ID) "
                         + "WHERE ci.IsActive='Y' AND u.IsActive='Y'"
                         + " AND ci.OptOutDate IS NULL"
                         + " AND u.EMail IS NOT NULL"
                         + " AND ci.R_InterestArea_ID=@param1";

            SqlParameter[] param = new SqlParameter[1];
            DataTable      dt    = null;
            IDataReader    idr   = null;

            try
            {
                param[0] = new SqlParameter("@param1", _R_InterestArea_ID);
                idr      = DataBase.DB.ExecuteReader(sql, param, Get_TrxName());
                dt       = new DataTable();
                dt.Load(idr);
                foreach (DataRow dr in dt.Rows)
                {
                    Boolean ok = SendIndividualMail(Utility.Util.GetValueOfString(dr[0]), Utility.Util.GetValueOfInt(dr[2]), unsubscribe);
                    if (ok)
                    {
                        _counter++;
                    }
                    else
                    {
                        _errors++;
                    }
                }
            }

            catch (Exception ex)
            {
                log.Log(Level.SEVERE, sql, ex);
            }
            finally
            {
                dt = null;
                idr.Close();
            }
        }       //	sendInterestArea