Created
September 24, 2017 18:26
-
-
Save imvision/c2ed715c95dff9e729f62762406eabbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using saleforce.SFDC; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace saleforce | |
{ | |
class F3_AccountOperation : IF3_AccountOperation | |
{ | |
F3_AccountDocument f3_AccountDocument = new F3_AccountDocument(); | |
List<F3_AccountDocument> f3_AcountList = new List<F3_AccountDocument>(); | |
public List <F3_AccountDocument> list() | |
{ | |
Console.WriteLine("ENTER THE limit"); | |
int limit; | |
limit = Convert.ToInt32(Console.ReadLine()); | |
Console.WriteLine(string.Format("\t\t\t\t\t ACCOUNT DETAILS\t\t\t\t\t")); | |
Console.WriteLine(string.Format("{0, -18}\t{1, -20}\t{2, -15}\t\t{3, -20}\t{4, -20}\t{5,-20" + | |
"}\t{6,-25}", "ID", "NAME"," ACCOUNTSITE", "BILLINGSTATE", "PHONE", "TYPE" , "OWNER")); | |
int page = 0; | |
int offset = 0; | |
offset = page * limit; | |
QueryResult queryResult = null; | |
String SOQL = ""; | |
string AccountId = ""; | |
SOQL = string.Format("SELECT Account.id, Account.Name , Account.Site, Account.BillingState, Account.Phone,Account.Type, Account.Owner.Name from Account LIMIT {0} OFFSET {1}", limit, offset); | |
queryResult = Connection.sfdcBinding.query(SOQL); | |
if (queryResult.size > 0) | |
{ | |
for (int i = 0; i < queryResult.records.Count(); i++) | |
{ | |
Account readAccount = (Account)queryResult.records[i]; | |
string AccountName = readAccount.Name; | |
AccountId = readAccount.Id; | |
string accId = readAccount.Id; | |
if (!string.IsNullOrEmpty(accId) && accId.Length > 15) | |
{ | |
accId = accId + ".."; | |
} | |
if (!string.IsNullOrEmpty(readAccount.Name) && readAccount.Name.Length > 15) | |
{ | |
readAccount.Name = readAccount.Name + ".."; | |
} | |
if (!string.IsNullOrEmpty(readAccount.Site) && readAccount.Site.Length > 15) | |
{ | |
readAccount.Site = readAccount.Site + ".."; | |
} | |
if (!string.IsNullOrEmpty(readAccount.BillingState) && readAccount.BillingState.Length > 15) | |
{ | |
readAccount.BillingState = readAccount.BillingState + ".."; | |
} | |
if (!string.IsNullOrEmpty(readAccount.Phone) && readAccount.Phone.Length > 15) | |
{ | |
readAccount.Phone = readAccount.Phone + ".."; | |
} | |
if (!string.IsNullOrEmpty(readAccount.Type) && readAccount.Type.Length > 15) | |
{ | |
readAccount.Type = readAccount.Type + ".."; | |
} | |
string Owner = readAccount.Owner.ToString(); | |
if (!string.IsNullOrEmpty(Owner) && Owner.Length > 15) | |
{ | |
Owner= Owner + ".."; | |
} | |
string account_info = string.Format("{0, -15}\t{1, -15}\t{2, -15}\t{3, -15}\t{4, -15},{5,-15},{6,-15}", accId, readAccount.Name, readAccount.Site,readAccount.BillingState, readAccount.Phone, readAccount.Type,Owner); | |
F3_AccountDocument f3_AccountDocument = new F3_AccountDocument() | |
{ | |
ID = readAccount.Id, | |
Name = readAccount.Name, | |
Billing = readAccount.BillingState, | |
Phone = readAccount.Phone, | |
Type = readAccount.Type, | |
Site = readAccount.Site, | |
Owner = readAccount.Owner.Name.ToString() | |
}; | |
f3_AcountList.Add(f3_AccountDocument); | |
} | |
} | |
else | |
{ | |
string message = "No records returned."; | |
Console.WriteLine("\n" + message); | |
} | |
return f3_AcountList; | |
} | |
public F3_AccountDocument get(string id) | |
{ | |
string SOQL = string.Format("SELECT Account.Name, Account.Site, Account.BillingState, Account.Type, Account.Phone,Account.Owner.Name FROM Account WHERE Id='{0}'", id); | |
QueryResult queryResult = Connection.sfdcBinding.query(SOQL); | |
if (queryResult.size > 0) | |
{ | |
Account readAccount = (Account)queryResult.records[0]; | |
f3_AccountDocument.Name = readAccount.Name; | |
f3_AccountDocument.ID = readAccount.Id; | |
f3_AccountDocument.Phone = readAccount.Phone; | |
f3_AccountDocument.Billing = readAccount.BillingState; | |
f3_AccountDocument.Type = readAccount.Type; | |
f3_AccountDocument.Site = readAccount.Site; | |
f3_AccountDocument.Owner = readAccount.Owner.Name.ToString(); | |
} | |
return f3_AccountDocument; | |
} | |
public void update() | |
{ | |
} | |
public void add() | |
{ | |
} | |
} | |
public class F3_AccountDocument | |
{ | |
public string ID { get; set; } | |
public string Name { get; set; } | |
public string Billing { get; set; } | |
public string Phone { get; set; } | |
public string Type { get; set; } | |
public string Site { get; set; } | |
public string Owner { get; set; } | |
} | |
public class F3_AccountView | |
{ | |
F3_AccountOperation f3_AccountOperation = new F3_AccountOperation(); | |
F3_AccountDocument f3_AccountDocument = new F3_AccountDocument(); | |
public void methodView() | |
{ | |
List<F3_AccountDocument> result = new List<F3_AccountDocument>(); | |
result = f3_AccountOperation.list(); | |
if (result!=null) | |
{ | |
foreach (F3_AccountDocument c in result) | |
{ | |
Console.WriteLine("{0, -18}\t{1, -20}\t{2, -20}\t{3, -20}\t{4, -20}\t{5,-20}\t{6,-20}", c.ID, c.Name,c.Site, c.Billing, c.Phone, c.Type,c.Owner); | |
} | |
} | |
else | |
{ | |
Console.WriteLine("NoRecords"); | |
} | |
f3_BackToMainPage(); | |
} | |
public void methodViewById(string get_Id) | |
{ | |
f3_AccountDocument = f3_AccountOperation.get(get_Id); | |
if(f3_AccountDocument!=null) | |
{ | |
Console.WriteLine("Name is " + f3_AccountDocument.Name); | |
Console.WriteLine("Billing State is " + f3_AccountDocument.Billing); | |
Console.WriteLine("Phone is " + f3_AccountDocument.Phone); | |
Console.WriteLine("Type is " + f3_AccountDocument.Type); | |
Console.WriteLine("Site is " + f3_AccountDocument.Site); | |
Console.WriteLine("Owner is " + f3_AccountDocument.Owner); | |
} | |
else | |
{ | |
Console.WriteLine("No records found"); | |
} | |
f3_BackToMainPage(); | |
} | |
public void f3_BackToMainPage() | |
{ | |
Console.WriteLine("\nPress M for main page and X to exit"); | |
string input = Console.ReadLine(); | |
switch (input) | |
{ | |
case "x": | |
break; | |
case "M": | |
f3_Main main = new f3_Main(); | |
main.mainPage(); | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment