00001 from vyperlogix.classes.CooperativeClass import Cooperative 00002 00003 import os, sys, traceback 00004 00005 from vyperlogix import misc 00006 from vyperlogix.misc import _utils 00007 from vyperlogix.hash import lists 00008 from vyperlogix.misc import ObjectTypeName 00009 00010 try: 00011 from cStringIO import StringIO as StringIO 00012 except: 00013 from StringIO import StringIO as StringIO 00014 00015 from vyperlogix.sf.abstract import SalesForceAbstract 00016 00017 __copyright__ = """\ 00018 (c). Copyright 1990-2008, Vyper Logix Corp., All Rights Reserved. 00019 00020 Published under Creative Commons License 00021 (http://creativecommons.org/licenses/by-nc/3.0/) 00022 restricted to non-commercial educational use only., 00023 00024 See also: http://www.VyperLogix.com and http://www.pypi.info for details. 00025 00026 THE AUTHOR VYPER LOGIX CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO 00027 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 00028 FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00029 INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00030 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00031 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00032 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! 00033 00034 USE AT YOUR OWN RISK. 00035 """ 00036 00037 class SalesForceSolutions(SalesForceAbstract): 00038 def __init__(self, sfQuery): 00039 super(SalesForceSolutions, self).__init__(sfQuery,object_name='Solution') 00040 00041 def getNewSolutions(self,num_days=30,limit=5): 00042 num_days = int(num_days) if (str(num_days).isdigit()) else num_days 00043 limit = int(limit) if (str(limit).isdigit()) else limit 00044 today_iso = _utils.todayForSalesForce_localtime(_utils.days_timedelta(num_days=num_days),begin_at_midnight=True) 00045 try: 00046 limit = int(str(limit)) 00047 except: 00048 limit = 5 00049 soql = "Select s.Id, s.Account_Name__c, s.IsDeleted, s.IsPublished, s.LastModifiedDate, s.Portal_Account_Name__c, s.Published_Date__c, s.Question_Problem__c, s.Region__c, s.SME_Reviewer__c, s.Solution_Answer__c, s.Solution_Type__c, s.Solution_Workaround__c, s.SolutionName, s.SolutionNote, s.SolutionNumber, s.Special_Build__c, s.Status from Solution s WHERE (s.Status = 'Published') AND (s.IsDeleted = False) AND (s.LastModifiedDate > %s) ORDER BY s.LastModifiedDate DESC LIMIT %d" % (today_iso,limit) 00050 solutions = self.sf_query(soql) 00051 return solutions 00052 00053 def getNewSolutionsCount(self,num_days=30): 00054 num_days = int(num_days) if (str(num_days).isdigit()) else num_days 00055 today_iso = _utils.todayForSalesForce_localtime(_utils.days_timedelta(num_days=num_days),begin_at_midnight=True) 00056 soql = "Select COUNT() from Solution s WHERE (s.Status = 'Published') AND (s.IsDeleted = False) AND (s.LastModifiedDate > %s)" % (today_iso) 00057 solutions = self.sf_query(soql) 00058 count = [item for item in solutions if (str(item).isdigit())][0] 00059 return count 00060 00061 def getSolutionsViewsFrequencies(self,num_days=30): 00062 from vyperlogix.sf.magma.solution_views import SalesForceMoltenSolutionViews 00063 sf_solution_views = SalesForceMoltenSolutionViews(self.sfQuery) 00064 00065 num_days = int(num_days) if (str(num_days).isdigit()) else num_days 00066 00067 d = lists.HashedLists() 00068 views = sf_solution_views.getSolutionsViews(num_days=num_days) 00069 try: 00070 for view in views: 00071 if (view.has_key('Solution__c')): 00072 d[view['Solution__c']] = view 00073 except: 00074 pass 00075 d_freqs = lists.HashedLists() 00076 for k,v in d.iteritems(): 00077 d_freqs[len(v)] = k 00078 l_freqs = misc.sort(d_freqs.keys()) 00079 return (l_freqs,d_freqs,d) 00080 00081 def getSpecificSolutions(self,solutions=[]): 00082 solutions = [] 00083 if (len(solutions) > 0): 00084 soql = "Select %s from Solution s WHERE (s.Status = 'Published') AND (s.IsDeleted = False) AND (s.Id in (%s))" % (', '.join(self.names),','.join(["'%s'" % (item) for item in solutions])) 00085 solutions = self.sf_query(soql) 00086 return solutions 00087 00088 def getCustomHomePagesForAccount(self,account_id): 00089 soql = "Select %s from Solution s WHERE (s.Status = 'Published') AND (s.IsDeleted = False) AND (s.Portal_Account_Name__c = '%s')" % (', '.join(self.names),account_id) 00090 solutions = self.sf_query(soql) 00091 return solutions 00092 00093 if __name__ == "__main__": 00094 import sys 00095 print >>sys.stdout, __copyright__ 00096 print >>sys.stderr, __copyright__ 00097 00098
© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved; If you reference this document or any part of this document you must use the citation verbatim (including the link) "© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved."
Notice: This source code contained in this document is NOT open source and is NOT being distributed as open source.
122,241 lines of code and growing...