├── LICENSE
├── README.md
└── SugarRestSharpSolution
├── SugarCrm.PocoGen.Console
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Settings.StyleCop
├── StyleCop.Cache
├── SugarCrm.PocoGen.Console.csproj
└── packages.config
├── SugarCrm.PocoGen
├── DbServerProviderName.cs
├── DbServerType.cs
├── ModelTemplate.cs
├── Models
│ ├── Column.cs
│ ├── Key.cs
│ ├── Table.cs
│ ├── Tables.cs
│ └── Utils.cs
├── Properties
│ └── AssemblyInfo.cs
├── Readers
│ ├── MySqlSugarSchemaReader.cs
│ ├── SchemaReader.cs
│ └── SchemaReaderProvider.cs
├── Settings.StyleCop
├── StyleCop.Cache
├── SugarCrm.PocoGen.csproj
├── Templates
│ ├── ModelTemplate.cs
│ └── ModelTemplate.tt
├── app.config
└── packages.config
├── SugarRestSharp.IntegrationTests
├── AccountsModuleTests.cs
├── ContactsModuleTests.cs
├── CustomModels
│ ├── CustomAcccount1.cs
│ ├── CustomAcccount2.cs
│ └── CustomAcccount3.cs
├── Helpers
│ ├── AccountsModule.cs
│ ├── ContactsModule.cs
│ └── LinkedModules.cs
├── LinkedModulesTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── QueryTests.cs
├── SugarRestSharp.IntegrationTests.csproj
├── TestAccount.cs
├── WikiTester.cs
└── packages.config
├── SugarRestSharp
├── ErrorCodes.cs
├── Options.cs
├── Properties
│ └── AssemblyInfo.cs
├── QueryOperator.cs
├── QueryPredicate.cs
├── RequestType.cs
├── RestApiCalls
│ ├── EntityBase.cs
│ ├── Helpers
│ │ ├── DeserializerExceptionsContractResolver.cs
│ │ ├── JsonConverterHelper.cs
│ │ ├── JsonExtensions.cs
│ │ ├── ModelnfoExtensions.cs
│ │ └── QueryBuilder.cs
│ ├── MethodCalls
│ │ ├── Authentication.cs
│ │ ├── DeleteEntry.cs
│ │ ├── GetEntry.cs
│ │ ├── GetEntryList.cs
│ │ ├── GetLinkedEntry.cs
│ │ ├── GetLinkedEntryList.cs
│ │ ├── GetPagedEntryList.cs
│ │ ├── InsertEntries.cs
│ │ ├── InsertEntry.cs
│ │ ├── UpdateEntries.cs
│ │ ├── UpdateEntry.cs
│ │ └── Util.cs
│ ├── ModelInfo.cs
│ ├── ModelProperty.cs
│ ├── ModulePropertyAttribute.cs
│ ├── Requests
│ │ ├── JsonPredicate.cs
│ │ └── LoginRequest.cs
│ ├── Responses
│ │ ├── BaseResponse.cs
│ │ ├── DeleteEntryResponse.cs
│ │ ├── EntryListArray.cs
│ │ ├── ErrorResponse.cs
│ │ ├── Extensions
│ │ │ └── LinkedEntryListExtensions.cs
│ │ ├── InsertEntriesResponse.cs
│ │ ├── InsertEntryResponse.cs
│ │ ├── LinkedListModule.cs
│ │ ├── LinkedListModuleData.cs
│ │ ├── LinkedModuleData.cs
│ │ ├── LinkedRecordItem.cs
│ │ ├── LoginResponse.cs
│ │ ├── ReadEntryListResponse.cs
│ │ ├── ReadEntryResponse.cs
│ │ ├── ReadLinkedEntryListResponse.cs
│ │ ├── ReadLinkedEntryResponse.cs
│ │ ├── UpdateEntriesResponse.cs
│ │ └── UpdateEntryResponse.cs
│ ├── RestClientExtensions.cs
│ └── SugarApiRestResponse.cs
├── StyleCop.Cache
├── SugarCrmModels
│ ├── Account.cs
│ ├── AccountsAudit.cs
│ ├── AccountsBugs.cs
│ ├── AccountsCases.cs
│ ├── AccountsContacts.cs
│ ├── AccountsOpportunities.cs
│ ├── AclActions.cs
│ ├── AclRoles.cs
│ ├── AclRolesActions.cs
│ ├── AclRolesUsers.cs
│ ├── AddressBook.cs
│ ├── Bug.cs
│ ├── BugsAudit.cs
│ ├── Call.cs
│ ├── CallsContacts.cs
│ ├── CallsLeads.cs
│ ├── CallsUsers.cs
│ ├── Campaign.cs
│ ├── CampaignLog.cs
│ ├── CampaignTrkrs.cs
│ ├── CampaignsAudit.cs
│ ├── Case.cs
│ ├── CasesAudit.cs
│ ├── CasesBugs.cs
│ ├── Config.cs
│ ├── Contact.cs
│ ├── ContactsAudit.cs
│ ├── ContactsBugs.cs
│ ├── ContactsCases.cs
│ ├── ContactsUsers.cs
│ ├── CronRemoveDocuments.cs
│ ├── Currency.cs
│ ├── CustomFields.cs
│ ├── Document.cs
│ ├── DocumentRevisions.cs
│ ├── DocumentsAccounts.cs
│ ├── DocumentsBugs.cs
│ ├── DocumentsCases.cs
│ ├── DocumentsContacts.cs
│ ├── DocumentsOpportunities.cs
│ ├── Eapm.cs
│ ├── Email.cs
│ ├── EmailAddrBeanRel.cs
│ ├── EmailAddresses.cs
│ ├── EmailCache.cs
│ ├── EmailMarketing.cs
│ ├── EmailMarketingProspectLists.cs
│ ├── EmailTemplates.cs
│ ├── Emailman.cs
│ ├── EmailsBeans.cs
│ ├── EmailsEmailAddrRel.cs
│ ├── EmailsText.cs
│ ├── FieldsMetaData.cs
│ ├── Folder.cs
│ ├── FoldersRel.cs
│ ├── FoldersSubscriptions.cs
│ ├── ImportMaps.cs
│ ├── InboundEmail.cs
│ ├── InboundEmailAutoreply.cs
│ ├── InboundEmailCacheTs.cs
│ ├── JobQueue.cs
│ ├── Lead.cs
│ ├── LeadsAudit.cs
│ ├── LinkedDocuments.cs
│ ├── Meeting.cs
│ ├── MeetingsContacts.cs
│ ├── MeetingsLeads.cs
│ ├── MeetingsUsers.cs
│ ├── Note.cs
│ ├── OauthConsumer.cs
│ ├── OauthNonce.cs
│ ├── OauthTokens.cs
│ ├── OpportunitiesAudit.cs
│ ├── OpportunitiesContacts.cs
│ ├── Opportunity.cs
│ ├── OutboundEmail.cs
│ ├── Project.cs
│ ├── ProjectTask.cs
│ ├── ProjectTaskAudit.cs
│ ├── ProjectsAccounts.cs
│ ├── ProjectsBugs.cs
│ ├── ProjectsCases.cs
│ ├── ProjectsContacts.cs
│ ├── ProjectsOpportunities.cs
│ ├── ProjectsProducts.cs
│ ├── Prospect.cs
│ ├── ProspectListCampaigns.cs
│ ├── ProspectLists.cs
│ ├── ProspectListsProspects.cs
│ ├── Relationship.cs
│ ├── Release.cs
│ ├── Role.cs
│ ├── RolesModules.cs
│ ├── RolesUsers.cs
│ ├── SavedSearch.cs
│ ├── Scheduler.cs
│ ├── Sugarfeed.cs
│ ├── Task.cs
│ ├── Tracker.cs
│ ├── UpgradeHistory.cs
│ ├── User.cs
│ ├── UserPreferences.cs
│ ├── UsersFeeds.cs
│ ├── UsersLastImport.cs
│ ├── UsersPasswordLink.cs
│ ├── UsersSignatures.cs
│ ├── Vcal.cs
│ └── Version.cs
├── SugarRestClient.cs
├── SugarRestClientExtensions.cs
├── SugarRestRequest.cs
├── SugarRestResponse.cs
├── SugarRestSharp.1.0.0.nupkg
├── SugarRestSharp.csproj
├── SugarRestSharp.nuspec
└── packages.config
└── SugarRestSharpSolution.sln
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen.Console/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen.Console/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | using System.Reflection;
8 | using System.Runtime.CompilerServices;
9 | using System.Runtime.InteropServices;
10 |
11 | // General Information about an assembly is controlled through the following
12 | // set of attributes. Change these attribute values to modify the information
13 | // associated with an assembly.
14 | [assembly: AssemblyTitle("SugarCrm.PocoGen.Console")]
15 | [assembly: AssemblyDescription("")]
16 | [assembly: AssemblyConfiguration("")]
17 | [assembly: AssemblyCompany("")]
18 | [assembly: AssemblyProduct("SugarCrm.PocoGen.Console")]
19 | [assembly: AssemblyCopyright("Copyright © 2016")]
20 | [assembly: AssemblyTrademark("")]
21 | [assembly: AssemblyCulture("")]
22 |
23 | // Setting ComVisible to false makes the types in this assembly not visible
24 | // to COM components. If you need to access a type in this assembly from
25 | // COM, set the ComVisible attribute to true on that type.
26 | [assembly: ComVisible(false)]
27 |
28 | // The following GUID is for the ID of the typelib if this project is exposed to COM
29 | [assembly: Guid("ec482444-e8d1-4cde-a940-0d0179e3c5c6")]
30 |
31 | // Version information for an assembly consists of the following four values:
32 | //
33 | // Major Version
34 | // Minor Version
35 | // Build Number
36 | // Revision
37 | //
38 | // You can specify all the values or you can default the Build and Revision Numbers
39 | // by using the '*' as shown below:
40 | // [assembly: AssemblyVersion("1.0.*")]
41 | [assembly: AssemblyVersion("1.0.0.0")]
42 | [assembly: AssemblyFileVersion("1.0.0.0")]
43 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen.Console/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | False
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen.Console/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/DbServerProviderName.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Lite Poco Generator. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | namespace SugarCrm.PocoGen
10 | {
11 | ///
12 | /// This class represents DbServerProviderName class.
13 | ///
14 | public static class DbServerProviderName
15 | {
16 | ///
17 | /// MS SQL provider name
18 | ///
19 | public static string MsSql = "System.Data.SqlClient";
20 |
21 | ///
22 | /// Sqlite provider name
23 | ///
24 | public static string Sqlite = "System.Data.SQLite";
25 |
26 | ///
27 | /// MySql provider name
28 | ///
29 | public static string MySql = "MySql.Data.MySqlClient";
30 |
31 | ///
32 | /// PostgreSQL provider name
33 | ///
34 | public static string Postgres = "Npgsql";
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/DbServerType.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | namespace SugarCrm.PocoGen
10 | {
11 | ///
12 | /// This enum class represents DbServerType class.
13 | ///
14 | public enum DbServerType
15 | {
16 | ///
17 | /// MS SQL database type
18 | ///
19 | MsSql,
20 |
21 | ///
22 | /// Sqlite database type
23 | ///
24 | Sqlite,
25 |
26 | ///
27 | /// MySql database type
28 | ///
29 | MySql,
30 |
31 | ///
32 | /// PostgreSQL database type
33 | ///
34 | Postgres
35 | }
36 | }
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/ModelTemplate.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Lite Poco Generator. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | // ReSharper disable CheckNamespace
10 | namespace SugarCrm.PocoGen.Templates
11 | // ReSharper restore CheckNamespace
12 | {
13 | using Models;
14 |
15 | ///
16 | /// This class represents ModelTemplate class.
17 | /// This a partial class of the template class generated from ModelTemplate.tt.
18 | /// Note that the namespace - PocoGen.Templates matches the template file namespace.
19 | ///
20 | public partial class ModelTemplate
21 | {
22 | ///
23 | /// Gets or sets namespace of model
24 | ///
25 | public string Namespace { get; set; }
26 |
27 | ///
28 | /// Gets or sets a value indicating whether to include relationship
29 | ///
30 | public bool IncludeRelationships { get; set; }
31 |
32 | ///
33 | /// Gets or sets the table object
34 | ///
35 | public Table Table { get; set; }
36 |
37 | ///
38 | /// Gets or sets list of table objects
39 | ///
40 | public Tables Tables { get; set; }
41 | }
42 | }
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/Models/Column.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | namespace SugarCrm.PocoGen.Models
10 | {
11 | ///
12 | /// This class represents a table column.
13 | ///
14 | public class Column
15 | {
16 | ///
17 | /// Gets or sets name of the column name.
18 | ///
19 | public string Name { get; set; }
20 |
21 | ///
22 | /// Gets or sets name of the class property name.
23 | ///
24 | public string PropertyName { get; set; }
25 |
26 | ///
27 | /// Gets or sets name of the class property type.
28 | ///
29 | public string PropertyType { get; set; }
30 |
31 | ///
32 | /// Gets or sets a value indicating whether column is a primary key column.
33 | ///
34 | public bool IsPk { get; set; }
35 |
36 | ///
37 | /// Gets or sets a value indicating whether column is nullable.
38 | ///
39 | public bool IsNullable { get; set; }
40 |
41 | ///
42 | /// Gets or sets a value indicating whether column is an autocrement.
43 | ///
44 | public bool IsAutoIncrement { get; set; }
45 |
46 | ///
47 | /// Gets or sets a value indicating whether column should be ignored in mapping.
48 | ///
49 | public bool Ignore { get; set; }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/Models/Key.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | namespace SugarCrm.PocoGen.Models
10 | {
11 | ///
12 | /// This class represents a key of table column.
13 | ///
14 | public class Key
15 | {
16 | ///
17 | /// Gets or sets key name. For foreign key this is the constraint name.
18 | ///
19 | public string Name { get; set; }
20 |
21 | ///
22 | /// Gets or sets referenced table name.
23 | ///
24 | public string ReferencedTableName { get; set; }
25 |
26 | ///
27 | /// Gets or sets column name referenced in referenced table.
28 | ///
29 | public string ReferencedTableColumnName { get; set; }
30 |
31 | ///
32 | /// Gets or sets the refenrencing table name. This will be the table where key is defined.
33 | ///
34 | public string ReferencingTableName { get; set; }
35 |
36 | ///
37 | /// Gets or sets the refenrencing column name. This will be in the table where key is defined.
38 | ///
39 | public string ReferencingTableColumnName { get; set; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/Models/Tables.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | namespace SugarCrm.PocoGen.Models
10 | {
11 | using System.Collections.Generic;
12 | using System.Linq;
13 |
14 | ///
15 | /// This class represents all tables in the database.
16 | ///
17 | public class Tables : List
18 | {
19 | ///
20 | /// Gets a table based on table name.
21 | ///
22 | /// Table name
23 | /// Table object
24 | public Table GetTable(string tableName)
25 | {
26 | return this.Single(x => string.Compare(x.Name, tableName, System.StringComparison.OrdinalIgnoreCase) == 0);
27 | }
28 |
29 | ///
30 | /// Gets a table based on table indexed name.
31 | ///
32 | /// Table name
33 | /// Table object
34 | public Table this[string tableName]
35 | {
36 | get
37 | {
38 | return this.GetTable(tableName);
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | using System.Reflection;
10 | using System.Runtime.CompilerServices;
11 | using System.Runtime.InteropServices;
12 |
13 | // General Information about an assembly is controlled through the following
14 | // set of attributes. Change these attribute values to modify the information
15 | // associated with an assembly.
16 | [assembly: AssemblyTitle("SugarCrm.PocoGen")]
17 | [assembly: AssemblyDescription("")]
18 | [assembly: AssemblyConfiguration("")]
19 | [assembly: AssemblyCompany("")]
20 | [assembly: AssemblyProduct("SugarCrm.PocoGen")]
21 | [assembly: AssemblyCopyright("Copyright © 2016")]
22 | [assembly: AssemblyTrademark("")]
23 | [assembly: AssemblyCulture("")]
24 |
25 | // Setting ComVisible to false makes the types in this assembly not visible
26 | // to COM components. If you need to access a type in this assembly from
27 | // COM, set the ComVisible attribute to true on that type.
28 | [assembly: ComVisible(false)]
29 |
30 | // The following GUID is for the ID of the typelib if this project is exposed to COM
31 | [assembly: Guid("8bca9878-7746-4906-868a-c22495227f45")]
32 |
33 | // Version information for an assembly consists of the following four values:
34 | //
35 | // Major Version
36 | // Minor Version
37 | // Build Number
38 | // Revision
39 | //
40 | // You can specify all the values or you can default the Build and Revision Numbers
41 | // by using the '*' as shown below:
42 | // [assembly: AssemblyVersion("1.0.*")]
43 | [assembly: AssemblyVersion("1.0.0.0")]
44 | [assembly: AssemblyFileVersion("1.0.0.0")]
45 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/Readers/SchemaReader.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | namespace SugarCrm.PocoGen.Readers
10 | {
11 | using System;
12 | using Models;
13 |
14 | ///
15 | /// This abstract class for schema reading.
16 | ///
17 | public abstract class SchemaReader : IDisposable
18 | {
19 | ///
20 | /// Reads the Schema returning all tables in the databse.
21 | ///
22 | /// Connection string
23 | /// List of table objects
24 | public abstract Tables ReadSchema(string connectionString);
25 |
26 | ///
27 | /// Disposes of objects
28 | ///
29 | public abstract void Dispose();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/Readers/SchemaReaderProvider.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | // This is code is based on the T4 template from the PetaPoco project which in turn is based on the subsonic project.
5 | // This is adapted from OrmLite T4 and Dapper.SimpleCRUD Projects.
6 | //
7 | // -----------------------------------------------------------------------
8 |
9 | namespace SugarCrm.PocoGen.Readers
10 | {
11 | using System;
12 |
13 | ///
14 | /// This class represents a provier class to get right schema reader based on database type.
15 | ///
16 | public class SchemaReaderProvider
17 | {
18 | ///
19 | /// Get reader based on database type
20 | ///
21 | /// Database type [MsSql, Sqlite, MySql PostgreSQL]
22 | /// SchemaReader object
23 | public static SchemaReader GetReader(DbServerType dbserverType)
24 | {
25 | SchemaReader schemaReader = null;
26 | switch (dbserverType)
27 | {
28 | case DbServerType.MsSql:
29 | throw new NotImplementedException();
30 | case DbServerType.Sqlite:
31 | throw new NotImplementedException();
32 | case DbServerType.MySql:
33 | schemaReader = new MySqlSugarSchemaReader();
34 | break;
35 | case DbServerType.Postgres:
36 | throw new NotImplementedException();
37 | }
38 |
39 | return schemaReader;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | True
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | False
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | False
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | False
35 |
36 |
37 |
38 |
39 | False
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | False
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/Templates/ModelTemplate.tt:
--------------------------------------------------------------------------------
1 | <#@ template language="C#" #>
2 | <#@ assembly name="System.Core" #>
3 | <#@ import namespace="System.Linq" #>
4 | <#@ import namespace="System.Text" #>
5 | <#@ import namespace="System.Collections.Generic" #>
6 | <#@ import namespace="SugarCrm.PocoGen.Models" #>
7 | <#
8 | /*
9 | The contents of this file are subject to the New BSD
10 | License (the "License"); you may not use this file
11 | except in compliance with the License. You may obtain a copy of
12 | the License at http://www.opensource.org/licenses/bsd-license.php
13 |
14 | Software distributed under the License is distributed on an
15 | "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16 | implied. See the License for the specific language governing
17 | rights and limitations under the License.
18 | */
19 | #>
20 | //
21 | // This file was generated by a T4 template.
22 | // Don't change it directly as your change would get overwritten. Instead, make changes
23 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
24 |
25 | // Make sure the compiler doesn't complain about missing Xml comments
26 | #pragma warning disable 1591
27 |
28 | namespace <#=Namespace #>
29 | {
30 | using System;
31 | using Newtonsoft.Json;
32 | using Sugar.PocoGen.Console;
33 |
34 | ///
35 | /// A class which represents the <#=Table.Name#> <#=(Table.IsView)?"view":"table"#>.
36 | ///
37 | [ModuleProperty(ModuleName = "<#=Utils.PascalCase(Table.Name) #>", TableName="<#=Table.Name#>")]
38 | public partial class <#=Table.ClassName#> : EntityBase
39 | {
40 | <#foreach(Column col in from c in Table.Columns where !c.Ignore select c)
41 | {#>
42 | <#='\t'#><#='\t'#>[JsonProperty(PropertyName = "<#=col.Name #>")]
43 | <#='\t'#><#='\t'#>public virtual <#=col.PropertyType #><#=Utils.CheckNullable(col)#> <#=Utils.PascalCase(col.PropertyName) #> { get; set; }
44 |
45 | <#}#>
46 | }
47 | }
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarCrm.PocoGen/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp.IntegrationTests/CustomModels/CustomAcccount1.cs:
--------------------------------------------------------------------------------
1 | namespace SugarRestSharp.IntegrationTests.CustomModels
2 | {
3 | using Newtonsoft.Json;
4 | using SugarRestSharp.Models;
5 | using System.Collections.Generic;
6 |
7 | public class CustomAcccount1 : Account
8 | {
9 | [JsonProperty(PropertyName = "contacts")]
10 | public virtual List ContactLink { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp.IntegrationTests/CustomModels/CustomAcccount2.cs:
--------------------------------------------------------------------------------
1 | namespace SugarRestSharp.IntegrationTests.CustomModels
2 | {
3 | using Newtonsoft.Json;
4 | using SugarRestSharp.Models;
5 | using System.Collections.Generic;
6 |
7 | public class CustomAcccount2 : Account
8 | {
9 | [JsonProperty(PropertyName = "contacts")]
10 | public virtual List ContactLink { get; set; }
11 |
12 | [JsonProperty(PropertyName = "leads")]
13 | public virtual List LeadLink { get; set; }
14 |
15 | [JsonProperty(PropertyName = "cases")]
16 | public virtual List CaseLink { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp.IntegrationTests/CustomModels/CustomAcccount3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SugarRestSharp.IntegrationTests.CustomModels
8 | {
9 | using Newtonsoft.Json;
10 | using SugarRestSharp.Models;
11 | using System.Collections.Generic;
12 |
13 | public class CustomAcccount3 : Account
14 | {
15 | [JsonProperty(PropertyName = "Bugs")]
16 | public virtual List ContactLink { get; set; }
17 |
18 | [JsonProperty(PropertyName = "cases")]
19 | public virtual List CaseLink { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp.IntegrationTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SugarRestSharp.IntegrationTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SugarRestSharp.IntegrationTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b35ba57c-dc77-44ae-b145-f6dcb4b4ced1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp.IntegrationTests/TestAccount.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.IntegrationTests
8 | {
9 | public static class TestAccount
10 | {
11 | public static string Url
12 | {
13 | get
14 | {
15 | return @"http://191.101.224.189/sugar/service/v4_1/rest.php";
16 | }
17 | }
18 |
19 | public static string Username
20 | {
21 | get
22 | {
23 | return @"will";
24 | }
25 | }
26 |
27 | public static string Password
28 | {
29 | get
30 | {
31 | return @"will";
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp.IntegrationTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/ErrorCodes.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp
8 | {
9 | ///
10 | /// Represents ErrorCodes class
11 | ///
12 | internal class ErrorCodes
13 | {
14 | ///
15 | /// Invalid url error code
16 | ///
17 | public static string UrlInvalid = "Url is not valid or not provided.";
18 |
19 | ///
20 | /// Invalid username error code
21 | ///
22 | public static string UsernameInvalid = "Username is not valid or not provided.";
23 |
24 | ///
25 | /// Invalid password error code
26 | ///
27 | public static string PasswordInvalid = "Password is not valid or not provided.";
28 |
29 | ///
30 | /// Invalid entity type error code
31 | ///
32 | public static string ModulenameInvalid = "Generic type T provided is not a valid EntityBase Type. Must be valid SugarCrm model.";
33 |
34 | ///
35 | /// Invalid identifier error code
36 | ///
37 | public static string IdInvalid = "Identifier is not valid or not provided.";
38 |
39 | ///
40 | /// Invalid entity or entities data error code
41 | ///
42 | public static string DataInvalid = "Entity or entities data object provided is not valid.";
43 |
44 | ///
45 | /// Invalid linked field information missing.
46 | ///
47 | public static string LinkedFieldsInfoMissing = "Entity or entities data object provided is not valid.";
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | using System.Reflection;
8 | using System.Runtime.CompilerServices;
9 | using System.Runtime.InteropServices;
10 |
11 | // General Information about an assembly is controlled through the following
12 | // set of attributes. Change these attribute values to modify the information
13 | // associated with an assembly.
14 | [assembly: AssemblyTitle("SugarRestSharp")]
15 | [assembly: AssemblyDescription("")]
16 | [assembly: AssemblyConfiguration("")]
17 | [assembly: AssemblyCompany("")]
18 | [assembly: AssemblyProduct("SugarRestSharp")]
19 | [assembly: AssemblyCopyright("Copyright © 2016")]
20 | [assembly: AssemblyTrademark("")]
21 | [assembly: AssemblyCulture("")]
22 |
23 | // Setting ComVisible to false makes the types in this assembly not visible
24 | // to COM components. If you need to access a type in this assembly from
25 | // COM, set the ComVisible attribute to true on that type.
26 | [assembly: ComVisible(false)]
27 |
28 | // The following GUID is for the ID of the typelib if this project is exposed to COM
29 | [assembly: Guid("f0f513b8-998d-435e-92f0-42ca484d98ad")]
30 |
31 | // Version information for an assembly consists of the following four values:
32 | //
33 | // Major Version
34 | // Minor Version
35 | // Build Number
36 | // Revision
37 | //
38 | // You can specify all the values or you can default the Build and Revision Numbers
39 | // by using the '*' as shown below:
40 | // [assembly: AssemblyVersion("1.0.*")]
41 | [assembly: AssemblyVersion("1.0.0.0")]
42 | [assembly: AssemblyFileVersion("1.0.0.0")]
43 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/QueryOperator.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp
8 | {
9 | ///
10 | /// Represents the QueryOperator enum class.
11 | ///
12 | public enum QueryOperator
13 | {
14 | ///
15 | /// The "equal" operator.
16 | ///
17 | Equal,
18 |
19 | ///
20 | /// The "greater than" operator.
21 | ///
22 | GreaterThan,
23 |
24 | ///
25 | /// The "greater than or equal to" operator.
26 | ///
27 | GreaterThanOrEqualTo,
28 |
29 | ///
30 | /// The "less than" operator.
31 | ///
32 | LessThan,
33 |
34 | ///
35 | /// The "less than or equal to" operator.
36 | ///
37 | LessThanOrEqualTo,
38 |
39 | ///
40 | /// The "contains" operator.
41 | ///
42 | Contains,
43 |
44 | ///
45 | /// Gets the starts with operator.
46 | ///
47 | StartsWith,
48 |
49 | ///
50 | /// The "ends with" operator.
51 | ///
52 | EndsWith,
53 |
54 | ///
55 | /// The "between" operator.
56 | ///
57 | Between,
58 |
59 | ///
60 | /// The "where in" operator.
61 | ///
62 | WhereIn
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/QueryPredicate.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp
8 | {
9 | ///
10 | /// Represents QueryPredicate class.
11 | ///
12 | public class QueryPredicate
13 | {
14 | ///
15 | /// Initializes a new instance of the QueryPredicate class.
16 | ///
17 | /// The property name. This can be a C# model property name or json property name.
18 | /// The query operator.
19 | /// The predicate value.
20 | /// The predicate from value.
21 | /// The predicate to value.
22 | public QueryPredicate(string propertyName, QueryOperator queryOperator, object value, object fromValue = null, object toValue = null)
23 | {
24 | this.PropertyName = propertyName;
25 | this.Operator = queryOperator;
26 | this.Value = value;
27 | this.FromValue = fromValue;
28 | this.ToValue = toValue;
29 | }
30 |
31 | ///
32 | /// Gets or sets the property name.
33 | ///
34 | public string PropertyName { get; set; }
35 |
36 | ///
37 | /// Gets or sets the operator.
38 | ///
39 | public QueryOperator Operator { get; set; }
40 |
41 | ///
42 | /// Gets or sets the value.
43 | ///
44 | public object Value { get; set; }
45 |
46 | ///
47 | /// Gets or sets the from value.
48 | ///
49 | public object FromValue { get; set; }
50 |
51 | ///
52 | /// Gets or sets the to value.
53 | ///
54 | public object ToValue { get; set; }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RequestType.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp
8 | {
9 | ///
10 | /// Represents RequestType enum class
11 | ///
12 | public enum RequestType
13 | {
14 | ///
15 | /// SugarCrm get by id method call
16 | ///
17 | ReadById,
18 |
19 | ///
20 | /// SugarCrm get all method call.
21 | ///
22 | BulkRead,
23 |
24 | ///
25 | /// SugarCrm get paged method call.
26 | ///
27 | PagedRead,
28 |
29 | ///
30 | /// SugarCrm create method call.
31 | ///
32 | Create,
33 |
34 | ///
35 | /// SugarCrm bulk create method call.
36 | ///
37 | BulkCreate,
38 |
39 | ///
40 | /// SugarCrm update method call.
41 | ///
42 | Update,
43 |
44 | ///
45 | /// SugarCrm bulk update method call.
46 | ///
47 | BulkUpdate,
48 |
49 | ///
50 | /// SugarCrm delete method call.
51 | ///
52 | Delete,
53 |
54 | ///
55 | /// SugarCrm get by id method call - this gets associated linked objects serialized into a known custom type.
56 | ///
57 | LinkedReadById,
58 |
59 | ///
60 | /// SugarCrm get all method call - this gets associated linked objects serialized into a known custom type.
61 | ///
62 | LinkedBulkRead
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/EntityBase.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp
8 | {
9 | ///
10 | /// Base class for all SugarCrm models
11 | ///
12 | public class EntityBase
13 | {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Helpers/JsonExtensions.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Helpers
8 | {
9 | using System;
10 | using System.Collections;
11 | using System.Collections.Generic;
12 | using Newtonsoft.Json.Linq;
13 |
14 | ///
15 | /// This class represents JsonExtensions class.
16 | ///
17 | internal static class JsonExtensions
18 | {
19 | ///
20 | /// Converts json string to dynamic object collections datatable.
21 | ///
22 | /// Json string to extend.
23 | /// The type.
24 | /// DataTable object
25 | public static IList ToObjects(this string json, Type type)
26 | {
27 | IList data = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(type));
28 | JArray jarr = JArray.Parse(json);
29 | foreach (JObject jobject in jarr.Children())
30 | {
31 | object tempObject = JsonConverterHelper.Deserialize(jobject.ToString(), type);
32 | data.Add(tempObject);
33 | }
34 |
35 | return data;
36 | }
37 |
38 | ///
39 | /// Converts json string to dynamic object datatable.
40 | ///
41 | /// Json string to extend.
42 | /// The type.
43 | /// DataTable object
44 | public static object ToObject(this string json, Type type)
45 | {
46 | JObject jobject = JObject.Parse(json);
47 | return JsonConverterHelper.Deserialize(jobject.ToString(), type);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/MethodCalls/Util.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.MethodCalls
8 | {
9 | using System;
10 | using System.Security.Cryptography;
11 | using System.Text;
12 |
13 | ///
14 | /// Represents the Util class
15 | ///
16 | internal static class Util
17 | {
18 | ///
19 | /// Calculates and returns password hash as required by SugarCrm REST API calls
20 | ///
21 | /// The user supplied plain password
22 | /// Hased password
23 | public static string CalculateMd5Hash(string password)
24 | {
25 | MD5 md5 = MD5.Create();
26 | byte[] inputBytes = Encoding.ASCII.GetBytes(password);
27 | byte[] hash = md5.ComputeHash(inputBytes);
28 |
29 | var stringBuilder = new StringBuilder();
30 | for (int i = 0; i < hash.Length; i++)
31 | {
32 | stringBuilder.Append(hash[i].ToString("x2"));
33 | }
34 |
35 | return stringBuilder.ToString();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/ModelProperty.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp
8 | {
9 | using System;
10 |
11 | ///
12 | /// This class represents ModelProperty class.
13 | ///
14 | internal class ModelProperty
15 | {
16 | ///
17 | /// Gets or sets the C# property name.
18 | ///
19 | public string Name { get; set; }
20 |
21 | ///
22 | /// Gets or sets the property name in json.
23 | ///
24 | public string JsonName { get; set; }
25 |
26 | ///
27 | /// Gets or sets property C# object type.
28 | ///
29 | public Type Type { get; set; }
30 |
31 | ///
32 | /// Gets or sets a value indicating whether value is numeric or not.
33 | ///
34 | public bool IsNumeric
35 | {
36 | get
37 | {
38 | if (Type == null)
39 | {
40 | return false;
41 | }
42 |
43 | string typeName = Type.Name.ToLower();
44 | switch (typeName)
45 | {
46 | case "int32":
47 | case "sbyte":
48 | return true;
49 | case "string":
50 | case "datetime":
51 | return false;
52 | }
53 |
54 | return false;
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/ModulePropertyAttribute.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp
8 | {
9 | using System;
10 |
11 | ///
12 | /// SugarCrm module attributes [ModuleName - name of module, Tablename - name of associated table]
13 | ///
14 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
15 | internal class ModulePropertyAttribute : Attribute
16 | {
17 | ///
18 | /// Gets or sets module name
19 | ///
20 | public string ModuleName { get; set; }
21 |
22 | ///
23 | /// Gets or sets table name
24 | ///
25 | public string TableName { get; set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Requests/JsonPredicate.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.RestApiCalls.Requests
8 | {
9 | ///
10 | /// Represents JsonPredicate class.
11 | ///
12 | internal class JsonPredicate
13 | {
14 | ///
15 | /// Initializes a new instance of the JsonPredicate class.
16 | ///
17 | /// The property name. This can be a C# model property name or json property name.
18 | /// The query operator.
19 | /// The predicate value.
20 | /// The predicate from value.
21 | /// The predicate to value.
22 | public JsonPredicate(string propertyName, QueryOperator queryOperator, string value, string fromValue, string toValue)
23 | {
24 | this.PropertyName = propertyName;
25 | this.Operator = queryOperator;
26 | this.Value = value;
27 | this.FromValue = fromValue;
28 | this.ToValue = toValue;
29 | }
30 |
31 | ///
32 | /// Gets or sets the json property name.
33 | ///
34 | public string PropertyName { get; set; }
35 |
36 | ///
37 | /// Gets or sets the operator.
38 | ///
39 | public QueryOperator Operator { get; set; }
40 |
41 | ///
42 | /// Gets or sets the value.
43 | ///
44 | public string Value { get; set; }
45 |
46 | ///
47 | /// Gets or sets the from value.
48 | ///
49 | public string FromValue { get; set; }
50 |
51 | ///
52 | /// Gets or sets the to value.
53 | ///
54 | public string ToValue { get; set; }
55 |
56 | ///
57 | /// Gets or sets a value indicating whether value is numeric or not.
58 | ///
59 | public bool IsNumeric { get; set; }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Requests/LoginRequest.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Requests
8 | {
9 | ///
10 | /// Represents the LoginRequest class
11 | ///
12 | internal class LoginRequest
13 | {
14 | ///
15 | /// Gets or sets REST API Url
16 | ///
17 | public string Url { get; set; }
18 |
19 | ///
20 | /// Gets or sets REST API SessionId
21 | ///
22 | public string SessionId { get; set; }
23 |
24 | ///
25 | /// Gets or sets REST API Username
26 | ///
27 | public string Username { get; set; }
28 |
29 | ///
30 | /// Gets or sets REST API Password
31 | ///
32 | public string Password { get; set; }
33 | }
34 | }
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/BaseResponse.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | using System;
10 | using System.Net;
11 | using Newtonsoft.Json;
12 |
13 | ///
14 | /// Base SugarCrm REST API response object
15 | ///
16 | internal class BaseResponse
17 | {
18 | ///
19 | /// Initializes a new instance of the BaseResponse class
20 | ///
21 | public BaseResponse()
22 | {
23 | this.Time = DateTime.UtcNow;
24 | this.Error = new ErrorResponse();
25 | }
26 |
27 | ///
28 | /// Gets or sets the time the API call was made
29 | ///
30 | [JsonIgnore]
31 | public DateTime Time { get; set; }
32 |
33 | ///
34 | /// Gets or sets the raw json request sent by SugarCrm Rest API
35 | ///
36 | [JsonIgnore]
37 | public string JsonRawRequest { get; set; }
38 |
39 | ///
40 | /// Gets or sets the raw json response sent by SugarCrm Rest API
41 | ///
42 | [JsonIgnore]
43 | public string JsonRawResponse { get; set; }
44 |
45 | ///
46 | /// Gets or sets the error object
47 | ///
48 | [JsonIgnore]
49 | public ErrorResponse Error { get; set; }
50 |
51 | ///
52 | /// Gets or sets the http status code - either returned from the API call or assigned
53 | ///
54 | [JsonIgnore]
55 | public HttpStatusCode StatusCode { get; set; }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/DeleteEntryResponse.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | using Newtonsoft.Json;
10 |
11 | ///
12 | /// Represents DeleteEntryResponse class
13 | ///
14 | internal class DeleteEntryResponse : BaseResponse
15 | {
16 | ///
17 | /// Gets or sets the entity identifier of deleted entity
18 | ///
19 | [JsonProperty(PropertyName = "id")]
20 | public string Id { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/EntryListArray.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using Newtonsoft.Json;
12 | using Newtonsoft.Json.Linq;
13 |
14 | ///
15 | /// Represents EntryListArray class
16 | ///
17 | internal class EntryListArray
18 | {
19 | ///
20 | /// Gets the entity object
21 | ///
22 | public JObject Entity
23 | {
24 | get
25 | {
26 | var entity = new JObject();
27 | if (this.NameValueList == null)
28 | {
29 | return entity;
30 | }
31 |
32 | IList keys = this.NameValueList.Properties().Select(p => p.Name).ToList();
33 | foreach (var key in keys)
34 | {
35 | var newKey = (string)this.NameValueList[key]["name"];
36 | var newValue = (string)this.NameValueList[key]["value"];
37 | entity.Add(new JProperty(newKey, newValue));
38 | }
39 |
40 | return entity;
41 | }
42 | }
43 |
44 | ///
45 | /// Gets or sets the entity identifier
46 | ///
47 | [JsonProperty(PropertyName = "id")]
48 | public string Id { get; set; }
49 |
50 | ///
51 | /// Gets or sets the entity module name
52 | ///
53 | [JsonProperty(PropertyName = "module_name")]
54 | public string ModuleName { get; set; }
55 |
56 | ///
57 | /// Gets or sets the returned entity name value list
58 | ///
59 | [JsonProperty(PropertyName = "name_value_list")]
60 | public JObject NameValueList { get; set; }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/Extensions/LinkedEntryListExtensions.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.RestApiCalls.Responses.Extensions
8 | {
9 | using Newtonsoft.Json.Linq;
10 |
11 | ///
12 | /// This class represents LinkedEntryListExtensions class.
13 | ///
14 | internal static class LinkedEntryListExtensions
15 | {
16 | public static void SetModuleLinkedList(this JObject module, LinkedListModule linkedListModule)
17 | {
18 | if (linkedListModule == null)
19 | {
20 | return;
21 | }
22 |
23 | if ((linkedListModule.ModuleDataList == null) || (linkedListModule.ModuleDataList.Count == 0))
24 | {
25 | return;
26 | }
27 |
28 | foreach (var item in linkedListModule.ModuleDataList)
29 | {
30 | module[item.ModuleName] = JToken.FromObject(item.FormattedRecords);
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/InsertEntriesResponse.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | using System.Collections.Generic;
10 | using Newtonsoft.Json;
11 |
12 | ///
13 | /// Represents InsertEntriesResponse class
14 | ///
15 | internal class InsertEntriesResponse : BaseResponse
16 | {
17 | ///
18 | /// Gets or sets the entity identifier of inserted entity
19 | ///
20 | [JsonProperty(PropertyName = "ids")]
21 | public List Ids { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/InsertEntryResponse.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | using Newtonsoft.Json;
10 |
11 | ///
12 | /// Represents InsertEntryResponse class
13 | ///
14 | internal class InsertEntryResponse : BaseResponse
15 | {
16 | ///
17 | /// Gets or sets the entity identifier of inserted entity
18 | ///
19 | [JsonProperty(PropertyName = "id")]
20 | public string Id { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/LinkedListModule.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.RestApiCalls.Responses
8 | {
9 | using System.Collections.Generic;
10 | using Newtonsoft.Json;
11 | using SugarRestSharp.Responses;
12 |
13 | ///
14 | /// Represents LinkedListModule class.
15 | ///
16 | internal class LinkedListModule
17 | {
18 | ///
19 | /// Gets or sets the linked module data list info.
20 | ///
21 | [JsonProperty(PropertyName = "link_list")]
22 | public List ModuleDataList { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/LinkedListModuleData.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | using System.Collections.Generic;
10 | using Newtonsoft.Json;
11 | using Newtonsoft.Json.Linq;
12 | using RestApiCalls.Responses;
13 |
14 | ///
15 | /// Represents LinkedListModuleData class
16 | ///
17 | internal class LinkedListModuleData
18 | {
19 | ///
20 | /// Gets or sets the linked module name.
21 | ///
22 | [JsonProperty(PropertyName = "name")]
23 | public string ModuleName { get; set; }
24 |
25 | ///
26 | /// Gets or sets the linked module data.
27 | ///
28 | [JsonProperty(PropertyName = "records")]
29 | public List Records { get; set; }
30 |
31 | ///
32 | /// Gets the formatted record in json.
33 | ///
34 | public List FormattedRecords
35 | {
36 | get
37 | {
38 | var entities = new List();
39 | if (this.Records == null)
40 | {
41 | return new List();
42 | }
43 |
44 | foreach (LinkedRecordItem item in this.Records)
45 | {
46 | entities.Add(item.FormattedValue);
47 | }
48 |
49 | return entities;
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/LinkedModuleData.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using Newtonsoft.Json;
12 | using Newtonsoft.Json.Linq;
13 |
14 | ///
15 | /// Represents LinkedModuleData class
16 | ///
17 | internal class LinkedModuleData
18 | {
19 | ///
20 | /// Gets or sets the linked module name.
21 | ///
22 | [JsonProperty(PropertyName = "name")]
23 | public string ModuleName { get; set; }
24 |
25 | ///
26 | /// Gets or sets the linked module data.
27 | ///
28 | [JsonProperty(PropertyName = "records")]
29 | public List Records { get; set; }
30 |
31 | public List FormattedRecords
32 | {
33 | get
34 | {
35 | var entities = new List();
36 | if (this.Records == null)
37 | {
38 | return new List();
39 | }
40 |
41 | foreach (JObject item in this.Records)
42 | {
43 | JObject jentity = new JObject();
44 | IList keys = item.Properties().Select(p => p.Name).ToList();
45 | foreach (var key in keys)
46 | {
47 | var newKey = (string)item[key]["name"];
48 | var newValue = (string)item[key]["value"];
49 | jentity.Add(new JProperty(newKey, newValue));
50 | }
51 |
52 | entities.Add(jentity);
53 | }
54 |
55 | return entities;
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/LinkedRecordItem.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.RestApiCalls.Responses
8 | {
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using Newtonsoft.Json;
12 | using Newtonsoft.Json.Linq;
13 |
14 | ///
15 | /// Represents LinkedRecordItem class.
16 | ///
17 | internal class LinkedRecordItem
18 | {
19 | ///
20 | /// Gets or sets the json link value.
21 | ///
22 | [JsonProperty(PropertyName = "link_value")]
23 | public JObject Value { get; set; }
24 |
25 | ///
26 | /// Gets the json formatted link value.
27 | ///
28 | public JObject FormattedValue
29 | {
30 | get
31 | {
32 | if (this.Value == null)
33 | {
34 | return null;
35 | }
36 |
37 | JObject jentity = new JObject();
38 | IList keys = this.Value.Properties().Select(p => p.Name).ToList();
39 | foreach (var key in keys)
40 | {
41 | var newKey = (string)this.Value[key]["name"];
42 | var newValue = (string)this.Value[key]["value"];
43 | jentity.Add(new JProperty(newKey, newValue));
44 | }
45 |
46 | return jentity;
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/LoginResponse.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | ///
10 | /// Represents the LoginResponse class
11 | ///
12 | internal class LoginResponse : BaseResponse
13 | {
14 | ///
15 | /// Gets or sets the session identifier
16 | ///
17 | public string SessionId { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/SugarRestSharpSolution/SugarRestSharp/RestApiCalls/Responses/ReadEntryResponse.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) SugarCrm + PocoGen + REST. All rights reserved.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace SugarRestSharp.Responses
8 | {
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using Newtonsoft.Json;
12 | using Newtonsoft.Json.Linq;
13 |
14 | ///
15 | /// Represents ReadEntryResponse class
16 | ///
17 | internal class ReadEntryResponse : BaseResponse
18 | {
19 | ///
20 | /// Gets the entity returned from SugarCrm to json array object
21 | ///
22 | [JsonIgnore]
23 | public JObject Entity
24 | {
25 | get
26 | {
27 | if (this.EntryListArray == null)
28 | {
29 | return null;
30 | }
31 |
32 | var entityList = this.EntryListArray.Select(item => item.Entity).ToList();
33 |
34 | if (entityList.Count > 0)
35 | {
36 | return entityList[0];
37 | }
38 |
39 | return new JObject();
40 | }
41 | }
42 |
43 | ///
44 | /// Gets or sets the entry list in json
45 | ///
46 | [JsonProperty(PropertyName = "entry_list")]
47 | public List EntryListArray { get; set; }
48 |
49 | ///
50 | /// Gets or sets the relationship link entry list in json
51 | ///
52 | [JsonProperty(PropertyName = "relationship_list")]
53 | public List