Exemplo n.º 1
0
        // Functional
        public void noteFor(SDataPayload opportunityPayload)
        {
            try
            {
                // Initializing the variables used to populate the payload. Each variable gets a value using a random value generator as defined below the creation functions.
                string type = "atNote";
                string category = "Note";
                string description = randomDescriptionGenerator(category);
                SDataPayload key = (SDataPayload)opportunityPayload.Values["Account"];
                SDataSingleResourceRequest getAccount = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "accounts",
                    ResourceSelector = "'" + key.Key + "'"
                };
                var rawr = getAccount.Read();
                SDataPayload accountPayload = rawr.GetSDataPayload();
                string notes = randomNoteGenerator(category, accountPayload, description);

                int accId = rand.Next(2000);

                SDataTemplateResourceRequest noteHistoryTemplate = new SDataTemplateResourceRequest(dynamic);
                noteHistoryTemplate.ResourceKind = "history";
                Sage.SData.Client.Atom.AtomEntry tempEntry = noteHistoryTemplate.Read();

                SDataPayload payload = tempEntry.GetSDataPayload();
                payload.Values["OpportunityName"] = opportunityPayload.Values["Description"];
                payload.Values["OpportunityId"] = opportunityPayload.Key;
                payload.Values["Type"] = type;
                payload.Values["Category"] = category;
                payload.Values["Description"] = description;
                payload.Values["Notes"] = notes;
                payload.Values["LongNotes"] = notes;
                payload.Values["AccountName"] = accountPayload.Values["AccountName"];
                payload.Values["AccountId"] = accountPayload.Key;
                payload.Values["StartDate"] = DateTimeOffset.Now.ToUniversalTime();
                payload.Values["CompletedDate"] = DateTime.Now.ToUniversalTime();
                if (accountPayload.Values["Contacts"] != null)
                {
                    SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                    {
                        ResourceKind = "contacts",
                        QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                    };
                    var feed = contact.Read();
                    SDataPayload contactPayload = null;
                    if (feed.Entries.Count() != 0)
                    {
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            contactPayload = entry.GetSDataPayload();
                            break;
                        }
                        payload.Values["ContactName"] = contactPayload.Values["Name"];
                        payload.Values["ContactId"] = contactPayload.Key;
                    }
                }

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "history",
                    Entry = tempEntry
                };

                request.Create();
                notesCount++;
                SetNotesCreated(notesCount.ToString());
                Log("Created Note: " + payload.Values["Description"] + "... at time " + DateTime.Now, fileName);
            }
            catch (Exception e)
            {
                Log(e.ToString(),fileName);;
            }
        }
Exemplo n.º 2
0
        // Needs help!
        public void promoteLead()
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                SDataTemplateResourceRequest contactTemplate = new SDataTemplateResourceRequest(dynamic);
                contactTemplate.ResourceKind = "contacts";

                Sage.SData.Client.Atom.AtomEntry tempEntry = contactTemplate.Read();
                //SDataPayload payload = tempEntry.GetSDataPayload();

                Sage.SData.Client.Atom.AtomEntry leadEntry = null;
                do
                {
                    leadEntry = fetchLead();
                } while (leadEntry == null);

                SDataPayload leadPayload = leadEntry.GetSDataPayload();
                bool check = false;
                var feed = new Sage.SData.Client.Atom.AtomFeed();

                SDataPayload accountPayload = null;
                int i = 0;
                do
                {
                    accountPayload = fetchAccount();
                    i++;
                } while (accountPayload == null && i < 50);

                if (i == 50)
                    return;

                do
                {
                    try
                    {
                        SDataResourceCollectionRequest search = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "accounts",
                            QueryValues = { { "where", "AccountName eq '" + leadPayload.Values["Company"] + "'" } }
                        };

                        feed = search.Read();
                    }
                    catch { check = true; }
                } while (check);

                bool test = false;
                foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                {
                    if (entry != null)
                    {
                        accountPayload = entry.GetSDataPayload();
                        test = true;
                        break;
                    }
                    else
                        test = false;
                }

                if (!test)
                {
                    var request = new SDataServiceOperationRequest(dynamic)
                    {
                        ResourceKind = "leads",
                        Entry = new Sage.SData.Client.Atom.AtomEntry(),
                        OperationName = "ConvertLeadToContact"
                    };


                    //if (leadPayload.Values["Company"] != null)
                    //{
                    //    accountPayload = makeAccountWithName((string)leadPayload.Values["Company"]);
                    //}

                    var entity = new SDataPayload()
                    {
                        Key = leadPayload.Key
                    };
                    request.Entry.SetSDataPayload(
                       new SDataPayload
                       {
                           ResourceName = "LeadConvertLeadToContact",
                           Namespace = "http://schemas.sage.com/dynamic/2007",
                           Values = {
                       {"request", new SDataPayload
                           {
                           Values = {
                               {"entity", leadPayload},
                               {"LeadId", entity},
                               {"contact", tempEntry},
                               {"account", leadPayload.Values["Company"]},
                               {"rule", ""}
                                    }
                           }
                        }
                                 }
                       });
                    request.Create();
                    float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                    float timed = (after - previous) / 1000;
                    Log(DateTime.Now + " - Converted " + leadPayload.Values["FirstName"] + " " + leadPayload.Values["LastName"] + " to a contact - " + timed + " seconds", fileName);
                }
                else
                {
                    SDataServiceOperationRequest request = new SDataServiceOperationRequest(dynamic)
                    {
                        ResourceKind = "leads",
                        //Entry = leadEntry,
                        Entry = new Sage.SData.Client.Atom.AtomEntry(),
                        OperationName = "ConvertLeadToAccount"
                    };
                    var entity = new SDataPayload()
                    {
                        Key = leadPayload.Key
                    };

                    request.Entry.SetSDataPayload(
                       new SDataPayload
                       {
                           ResourceName = "LeadConvertLeadToAccount",
                           Namespace = "http://schemas.sage.com/dynamic/2007",
                           Values = {
                       {"request", new SDataPayload
                           {
                           Values = {
                               {"entity", leadPayload},
                               {"LeadId", entity},
                               {"account", accountPayload.Key}
                                    }
                           }
                        }
                                 }
                       });
                    request.Create();
                    float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                    float timed = (after - previous) / 1000;
                    Log(DateTime.Now + " - Converted " + leadPayload.Values["FirstName"] + " " + leadPayload.Values["LastName"] 
                        + " to a contact with Account " + leadPayload.Values["Company"] + " - " + timed + " seconds", fileName);
                }
                leadsPromotedCount++;
                SetLeadsPromoted(leadsPromotedCount.ToString());
            }
            catch (Exception e) { 
                Log(e.ToString(), fileName); 
            }
        }
Exemplo n.º 3
0
        // Not utilized in this build, was a POC that did not get implemented/was found to be unnecessary upon creation of
        // a viable UI for the program.
        #region Spreadsheet Data Creation
        // Functions that create entries into the database.
        public void note(List<string> write)
        {
            try
            {
                // Initializing the variables used to populate the payload. Each variable gets a value using a random value generator as defined below the creation functions.
                string type = "atNote";
                string category = "Note";
                //string description = randomDescriptionGenerator(category);
                SDataPayload accountPayload = null;
                int i = 0;
                do
                {
                    accountPayload = fetchAccount();
                    i++;
                } while (accountPayload == null && i < 50);

                if (i == 50)
                    return;
                //string notes = randomNoteGenerator(category, accountPayload, description);

                int accId = rand.Next(2000);

                SDataTemplateResourceRequest noteHistoryTemplate = new SDataTemplateResourceRequest(dynamic);
                noteHistoryTemplate.ResourceKind = "history";
                Sage.SData.Client.Atom.AtomEntry tempEntry = noteHistoryTemplate.Read();

                SDataPayload payload = tempEntry.GetSDataPayload();
                payload.Values["Type"] = type;
                payload.Values["Category"] = category;
                payload.Values["Description"] = write[3];
                payload.Values["Notes"] = write[2];
                payload.Values["LongNotes"] = write[3];
                payload.Values["AccountName"] = accountPayload.Values["AccountName"];
                payload.Values["AccountId"] = accountPayload.Key;

                // Checks if there is an associated contact with the account.
                if (accountPayload.Values["Contacts"] != null)
                {
                    SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                    {
                        ResourceKind = "contacts",
                        QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                    };
                    var feed = contact.Read();
                    SDataPayload contactPayload = null;
                    if (feed.Entries.Count() != 0)
                    {
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            contactPayload = entry.GetSDataPayload();
                            break;
                        }
                        payload.Values["ContactName"] = contactPayload.Values["Name"];
                        payload.Values["ContactId"] = contactPayload.Key;
                    }
                }

                // Checks if there is an associated opportunity with the account, similar to how the contact was found.
                if (accountPayload.Values["Opportunities"] != null)
                {
                    SDataResourceCollectionRequest opp = new SDataResourceCollectionRequest(dynamic)
                    {
                        ResourceKind = "opportunities",
                        QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                    };
                    var feed = opp.Read();
                    SDataPayload oppPayload = null;
                    if (feed.Entries.Count() != 0)
                    {
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            oppPayload = entry.GetSDataPayload();
                            break;
                        }
                        payload.Values["OpportunityName"] = oppPayload.Values["Description"];
                        payload.Values["OpportunityId"] = oppPayload.Key;
                    }
                }

                // Checks if there is an associated ticket with the account, similar to how the contact was found.
                if (accountPayload.Values["Tickets"] != null)
                {
                    SDataResourceCollectionRequest tick = new SDataResourceCollectionRequest(dynamic)
                    {
                        ResourceKind = "tickets",
                        QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                    };
                    var feed = tick.Read();
                    SDataPayload ticketPayload = null;
                    if (feed.Entries.Count() != 0)
                    {
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            ticketPayload = entry.GetSDataPayload();
                            break;
                        }
                        payload.Values["TicketNumber"] = ticketPayload.Values["TicketNumber"];
                        payload.Values["TicketId"] = ticketPayload.Key;
                    }
                }
                payload.Values["StartDate"] = DateTimeOffset.Now.ToUniversalTime();
                payload.Values["CompletedDate"] = DateTime.Now.ToUniversalTime();

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "history",
                    Entry = tempEntry
                };

                request.Create();
                notesCount++;
                SetNotesCreated(notesCount.ToString());
                Log("Created Note: " + payload.Values["Description"] + "... at time " + DateTime.Now, fileName);
            }
            catch (Exception e)
            {
                Log(e.ToString(),fileName);;
            }

        }
Exemplo n.º 4
0
        // Functional
        public void makeOpportunity()
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                SDataTemplateResourceRequest opportunityTemplate = new SDataTemplateResourceRequest(dynamic);
                opportunityTemplate.ResourceKind = "opportunities";

                Sage.SData.Client.Atom.AtomEntry tempEntry = opportunityTemplate.Read();
                SDataPayload payload = tempEntry.GetSDataPayload();

                SDataPayload accountPayload = null;
                int i = 0;
                do
                {
                    accountPayload = fetchAccount();
                    i++;
                } while (accountPayload == null && i < 50);

                if (i == 50)
                    return;   

                int oppValue = 500 * rand.Next(5, 1000);
                DateTime closeDate = DateTime.Now;
                closeDate = closeDate.AddMonths(3);
                int month = rand.Next(0, 12);
                int day = rand.Next(0, 30);
                closeDate = closeDate.AddMonths(month);
                closeDate = closeDate.AddDays(day);

                string type = "";
                int x = rand.Next(1, 2);
                switch (language)
                {
                    case "English":
                        if (x == 1)
                            type = "Add-On";
                        else
                            type = "New";
                    break;
                    case "Chinese":
                        if (x == 1)
                            type = "附加";
                        else
                            type = "新";
                    break;
                }

                var getUserRequest = new SDataServiceOperationRequest(service)
                {
                    OperationName = "getCurrentUser",
                    Entry = new Sage.SData.Client.Atom.AtomEntry()
                };
                var temp = getUserRequest.Create();
                var userPayload = temp.GetSDataPayload();
                userPayload = (SDataPayload)userPayload.Values["response"];

                //payload.Values["ActualAmount"] = oppValue;
                payload.Values["CreateUser"] = UserID;
                payload.Values["Description"] = accountPayload.Values["AccountName"] + " - Phase " + rand.Next(0, 10);
                payload.Values["Account"] = accountPayload;
                payload.Values["Owner"] = accountPayload.Values["Owner"];
                //payload.Values["SalesAmount"] = oppValue;
                payload.Values["SalesPotential"] = oppValue;
                payload.Values["CloseProbability"] = 1;//5 * rand.Next(0, 20);
                payload.Values["EstimatedClose"] = closeDate;
                payload.Values["Stage"] = "1-Prospect";
                payload.Values["LeadSource"] = fetchLeadSource();
                payload.Values["Type"] = type;
                payload.Values["AccountManager"] = accountPayload.Values["AccountManager"];
                //payload.Values["Weighted"] = oppValue / 100;
                //payload.Values["OverrideSalesPotential"] = false;
                //payload.Values["EstimatedClose"] = randomDateGenerator();

                if (accountPayload.Values["Contacts"] != null)
                {
                    SDataBatchRequest contact = new SDataBatchRequest(dynamic)
                    {
                        ResourceKind = "contacts",
                        QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                    };


                    /*
                    var feed = contact.Read();
                    SDataPayload contactPayload = ;
                    if (feed.Entries.Count() != 0)
                    {
                        int i = 1;
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            contactPayload.Values["Contact" + i] = entry.GetSDataPayload();
                            i++;
                        } */
                    payload.Values["Contacts"] = contact;
                    //}
                }

                tempEntry.SetSDataPayload(payload);

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "opportunities",
                    Entry = tempEntry
                };
                request.Create();
                float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                float timed = (after - previous) / 1000;
                opportunitiesCount++;
                SetOppsCreated(opportunitiesCount.ToString());
                Log(DateTime.Now + " - Opportunity made for account: " + accountPayload.Values["AccountName"] + " - " + timed + " seconds", fileName);
            }
            catch (Exception e) { 
                Log(e.ToString(), fileName); 
            }
        }
Exemplo n.º 5
0
        // Functional
        public void makeTicket()
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                SDataTemplateResourceRequest ticketTemplate = new SDataTemplateResourceRequest(dynamic);
                ticketTemplate.ResourceKind = "tickets";

                Sage.SData.Client.Atom.AtomEntry tempEntry = ticketTemplate.Read();
                SDataPayload payload = tempEntry.GetSDataPayload();

                SDataPayload accountPayload = null;
                int j = 0;
                do
                {
                    accountPayload = fetchAccount();
                    j++;
                } while (accountPayload == null && j < 50);
                //accountPayload.Values["UserField1"] = UserID;
                if (j == 50)
                    return;

                // Only need account name for the payload to be complete
                payload.Values["Account"] = accountPayload;
                try
                {
                    if (accountPayload.Values["Contacts"] != null)
                    {
                        SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "contacts",
                            QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                        };
                        var feed = contact.Read();
                        SDataPayload contactPayload = null;
                        if (feed.Entries.Count() != 0)
                        {
                            foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                            {
                                contactPayload = entry.GetSDataPayload();
                                break;
                            }
                            payload.Values["Contact"] = contactPayload;
                        }
                    }
                    else
                    {
                        int i = rand.Next(0, 150);
                        SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "contacts",
                            QueryValues = { { "startIndex", i.ToString() } }
                        };
                        var feed = contact.Read();
                        SDataPayload contactPayload = null;
                        if (feed.Entries.Count() != 0)
                        {
                            foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                            {
                                contactPayload = entry.GetSDataPayload();
                                break;
                            }
                            payload.Values["Contact"] = contactPayload;
                        }
                    }
                }
                catch (Exception e)
                {
                    Log(e.ToString(), fileName);
                }

                tempEntry.SetSDataPayload(payload);

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "tickets",
                    Entry = tempEntry
                };
                request.Create();
                float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                float timed = (after - previous) / 1000;
                Log(DateTime.Now + " - Created ticket number: " + accountPayload.Values["AccountName"] +  " - " + timed + " seconds", fileName);
                ticketsCount++;
                SetTicketsCreated(ticketsCount.ToString());
            }
            catch (Exception e) { 
                Log(e.ToString(), fileName); 
            }

        }
 private SDataPayload GetEntityTemplate(string entitytypename)
 {
     // SDataTemplateResourceRequest needs .Core so I have a using.
     SDataTemplateResourceRequest req = new SDataTemplateResourceRequest(_service);
     req.ResourceKind = entitytypename;
     //AtomEntry needs Sage.SData.Client.Atom so I added a using
     AtomEntry entry = req.Read();
     return  entry.GetSDataPayload();
 }
Exemplo n.º 7
0
        // Functional
        public void lead()
        {
            SDataTemplateResourceRequest leadsTemplate = new SDataTemplateResourceRequest(dynamic);
            leadsTemplate.ResourceKind = "leads";

            bool checker = true;
            string firstName = "";
            string lastName = "";

            Sage.SData.Client.Atom.AtomEntry tempEntry = leadsTemplate.Read();
            SDataPayload payload = tempEntry.GetSDataPayload();
            // Checks to see if there is a lead with that name already created
            do
            {
                firstName = GetFakeFirstName();
                lastName = GetFakeLastName();
                SDataResourceCollectionRequest check = new SDataResourceCollectionRequest(dynamic)
                {
                    ResourceKind = "contacts",
                    QueryValues = { { "where", "LastName eq '" + lastName + "'" } }
                };
                var feed = check.Read();
                foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                {
                    SDataPayload tempPayload = entry.GetSDataPayload();
                    if ((string)tempPayload.Values["FirstName"] == firstName)
                    {
                        checker = true;
                        break;
                    }
                    else
                        checker = false;
                }
            } while (checker);

            string emailProvider = "gmail";
            int temp = rand.Next(0, 4);
            switch (temp)
            {
                case 0:
                    emailProvider = "yahoo";
                    break;
                case 1:
                    emailProvider = "gmail";
                    break;
                case 2:
                    emailProvider = "mail";
                    break;
                case 3:
                    emailProvider = "me";
                    break;
                default:
                    emailProvider = "hotmail";
                    break;

            }
            string phone = rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString();
            payload.Values["CreateUser"] = UserID;
            payload.Values["CreateDate"] = DateTime.Now.ToUniversalTime();
            payload.Values["Company"] = GetFakeCompanyName();
            payload.Values["Email"] = firstName.ToLower() + lastName.ToLower() + "@" + emailProvider + ".com";
            payload.Values["FirstName"] = firstName;
            payload.Values["LastName"] = lastName;
            payload.Values["LastNameUpper"] = lastName.ToUpper();
            payload.Values["Mobile"] = phone;
            payload.Values["LeadNameFirstLast"] = firstName + " " + lastName;
            payload.Values["LeadNameLastFirst"] = lastName + ", " + firstName;

            SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
            {
                ResourceKind = "leads",
                Entry = tempEntry
            };

            /*SDataServiceOperationRequest request = new SDataServiceOperationRequest(service)
            {
                ResourceKind = "leads",
                //OperationName = "Save",
                Entry = tempEntry
            }; */
            request.Create();
            Debug.WriteLine(payload.Values["Company"] + ", " + payload.Values["LeadNameFirstLast"]);
            leadsCount++;
                // In this case the notes created label becomes the leads generated label
            SetLeadsCreated(leadsCount.ToString());
        }
Exemplo n.º 8
0
        // Functional
        public void makeAccount()
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                SDataTemplateResourceRequest accountTemplate = new SDataTemplateResourceRequest(dynamic);
                accountTemplate.ResourceKind = "accounts";
                Sage.SData.Client.Atom.AtomEntry tempEntry = accountTemplate.Read();
                SDataPayload payload = tempEntry.GetSDataPayload();
                bool checker = false;
                string accountName = "";

                do
                {
                    accountName = localize(language, "Fake Company Name", null, null, null, true);
                    try
                    {
                        SDataResourceCollectionRequest check = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "accounts",
                            QueryValues = { { "where", "AccountNameUpper eq '" + accountName.ToUpper() + "'" } }
                        };
                        var feed = check.Read();
                        if (feed.Entries.Count() == 0)
                            checker = false;
                        else
                            checker = true;
                    }
                    catch (Exception e) { 
                        Log(e.ToString(),fileName);
                    }
                } while (checker == true);

                payload.Values["AccountName"] = accountName;
                payload.Values["AccountNameUpper"] = accountName.ToUpper();
                payload.Values["CreateDate"] = DateTime.Now;
                payload.Values["CreateUser"] = UserID;
                payload.Values["Type"] = localize(language, "Account Type", null, null, null, true);
                payload.Values["Status"] = localize(language, "Account Status", null, null, null, true);

                tempEntry.SetSDataPayload(payload);

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "accounts",
                    Entry = tempEntry
                };
                request.Create();
                float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                float timed = (after - previous) / 1000;
                accountsCount++;
                SetAccountsCreated(accountsCount.ToString());
                Log(DateTime.Now + " - Created new account: " + payload.Values["AccountName"] + " - " + timed + " seconds", fileName);
            }
            catch (Exception e) { 
                Log(e.ToString(),fileName);
            }
        }
Exemplo n.º 9
0
        // Functional
        public SDataPayload makeAccountWithName(string accountName)
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                SDataTemplateResourceRequest accountTemplate = new SDataTemplateResourceRequest(dynamic);
                accountTemplate.ResourceKind = "accounts";
                Sage.SData.Client.Atom.AtomEntry tempEntry = accountTemplate.Read();
                SDataPayload payload = tempEntry.GetSDataPayload();

                payload.Values["AccountName"] = accountName;
                payload.Values["AccountNameUpper"] = accountName.ToUpper();
                payload.Values["CreateDate"] = DateTime.Now;
                payload.Values["CreateUser"] = UserID;
                payload.Values["Type"] = localize(language, "Account Type", null, null, null, true);
                payload.Values["Status"] = localize(language, "Account Status", null, null, null, true);

                tempEntry.SetSDataPayload(payload);

                /*SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "accounts",
                    Entry = tempEntry
                };
                request.Create(); */
                float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                float timed = (after - previous) / 1000;
                accountsCount++;
                SetAccountsCreated(accountsCount.ToString());
                Log(DateTime.Now + " - Created new account: " + payload.Values["AccountName"] +  " - " + timed + " seconds", fileName);
                return payload;
            }
            catch { return null; }
        }
Exemplo n.º 10
0
        // Functional
        public void makeActivity()
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                // Initializing the variables used to populate the payload. Each variable gets a value using a random value
                // generator as defined below the creation functions.
                string temp = localize(language, "Type Generator", null, null, null, true);
                string category = localize(language, "Category Generator", null, temp, null, true);
                string description = localize(language, "Description Generator", null, temp, null, true);
                string type = "at" + temp;
                string location = localize(language, "Location Generator", null, temp, null, true);
                DateTime startTime = randomDateGenerator();
                string priority = localize(language, "Priority Generator", null, null, null, true);
                SDataPayload accountPayload = null;
                int i = 0;
                do
                {
                    accountPayload = fetchAccount();
                    i++;
                } while (accountPayload == null && i < 50);

                if (i == 50)
                    return;

                string notes = randomNoteGenerator(temp, accountPayload, description);
                DateTime alarm = startTime.AddMinutes(-15);

                SDataTemplateResourceRequest activityTemplate = new SDataTemplateResourceRequest(service);
                activityTemplate.ResourceKind = "activities";
                Sage.SData.Client.Atom.AtomEntry tempEntry = activityTemplate.Read();

                SDataPayload payload = tempEntry.GetSDataPayload();

                payload.Values["Type"] = type;
                payload.Values["Category"] = category;
                // Get the program to query the server for the contact name, account name, and retrieve the respective ids for each.
                payload.Values["AccountName"] = accountPayload.Values["AccountName"];
                payload.Values["AccountId"] = accountPayload.Key;
                // Checks to make sure there is a contact associated with the account, and if so calls a request to get the payload
                // associated to that contact; then filling in payload.Values
                if (accountPayload.Values["Contacts"] != null)
                {
                    SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                    {
                        ResourceKind = "contacts",
                        QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                    };
                    var feed = contact.Read();
                    SDataPayload contactPayload = null;
                    if (feed.Entries.Count() != 0)
                    {
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            contactPayload = entry.GetSDataPayload();
                            break;
                        }
                        payload.Values["ContactName"] = contactPayload.Values["Name"];
                        payload.Values["ContactId"] = contactPayload.Key;
                    }
                }

                if (temp != "Personal")
                {
                    // Checks if there is an associated opportunity with the account, similar to how the contact was found.
                    if (accountPayload.Values["Opportunities"] != null)
                    {
                        SDataResourceCollectionRequest opp = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "opportunities",
                            QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                        };
                        var feed = opp.Read();
                        SDataPayload oppPayload = null;
                        if (feed.Entries.Count() != 0)
                        {
                            foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                            {
                                oppPayload = entry.GetSDataPayload();
                                break;
                            }
                            payload.Values["OpportunityName"] = oppPayload.Values["Description"];
                            payload.Values["OpportunityId"] = oppPayload.Key;
                        }
                    }

                    // Checks if there is an associated ticket with the account, similar to how the contact was found.
                    if (accountPayload.Values["Tickets"] != null)
                    {
                        SDataResourceCollectionRequest tick = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "tickets",
                            QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                        };
                        var feed = tick.Read();
                        SDataPayload ticketPayload = null;
                        if (feed.Entries.Count() != 0)
                        {
                            foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                            {
                                ticketPayload = entry.GetSDataPayload();
                                break;
                            }
                            payload.Values["TicketNumber"] = ticketPayload.Values["TicketNumber"];
                            payload.Values["TicketId"] = ticketPayload.Key;
                        }
                    }
                }
                payload.Values["Description"] = description;
                payload.Values["StartDate"] = startTime;
                payload.Values["Location"] = location;
                payload.Values["Priority"] = priority;
                payload.Values["LongNotes"] = notes;
                payload.Values["Notes"] = notes;
                payload.Values["AlarmTime"] = alarm;

                tempEntry.SetSDataPayload(payload);

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(service)
                {
                    ResourceKind = "activities",
                    Entry = tempEntry
                };

                //Creating the entry...
                request.Create();
                float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                float timed = (after - previous) / 1000;
                activitiesCount++;
                SetActivitiesCreated(activitiesCount.ToString());
                Log(DateTime.Now + " - Created Activity: " + payload.Values["Type"] + " - " + timed + " seconds", fileName);
            }
            catch (Exception e)
            {
                Log(e.ToString(),fileName);;
            }
   
        }
Exemplo n.º 11
0
        // Functional
        public void makeActivityFor(SDataPayload opportunityPayload)
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                // Initializing the variables used to populate the payload. Each variable gets a value using a random value generator as defined below the creation functions.
                string temp = localize(language, "Type Generator", null, null, null, true);
                string category = localize(language, "Category Generator", null, temp, null, true);
                string description = localize(language, "Description Generator", null, temp, null, true);
                string type = "at" + temp;
                string location = localize(language, "Location Generator", null, temp, null, true);
                DateTime startTime = randomDateGenerator();
                string priority = localize(language, "Priority Generator", null, null, null, true);
                SDataPayload key = (SDataPayload)opportunityPayload.Values["Account"];
                SDataSingleResourceRequest getAccount = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "accounts",
                    ResourceSelector = "'" + key.Key + "'"
                };
                var rawr = getAccount.Read();
                SDataPayload accountPayload = rawr.GetSDataPayload();
                string notes = randomNoteGenerator(temp, accountPayload, description);
                DateTime alarm = startTime.AddMinutes(-15);
                DateTime duration;

                SDataTemplateResourceRequest activityTemplate = new SDataTemplateResourceRequest(service);
                activityTemplate.ResourceKind = "activities";
                Sage.SData.Client.Atom.AtomEntry tempEntry = activityTemplate.Read();

                SDataPayload payload = tempEntry.GetSDataPayload();

                payload.Values["OpportunityName"] = opportunityPayload.Values["Description"];
                payload.Values["OpportunityId"] = opportunityPayload.Key;
                payload.Values["Type"] = type;
                payload.Values["Category"] = category;
                // Get the program to query the server for the contact name, account name, and retrieve the respective ids for each.
                payload.Values["AccountName"] = accountPayload.Values["AccountName"];
                payload.Values["AccountId"] = accountPayload.Key;
                payload.Values["Description"] = description;
                //payload.Values["Duration"] = "15 minutes";
                payload.Values["StartDate"] = startTime;
                payload.Values["Location"] = location;
                payload.Values["Priority"] = priority;
                payload.Values["LongNotes"] = notes;
                payload.Values["Notes"] = notes;
                payload.Values["AlarmTime"] = alarm;
                

                tempEntry.SetSDataPayload(payload);

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(service)
                {
                    ResourceKind = "activities",
                    Entry = tempEntry
                };

                //Creating the entry...
                request.Create();
                float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                float timed = (after - previous) / 1000;
                activitiesCount++;
                SetActivitiesCreated(activitiesCount.ToString());
                Log(DateTime.Now + " - Created Activity: " + payload.Values["Type"] +  " - " + timed + " seconds", fileName);
            }
            catch (Exception e)
            {
                Log(e.ToString(),fileName);;
            }
        }
Exemplo n.º 12
0
        // Needs help!
        public void promoteSpecificLead()
        {
            SDataTemplateResourceRequest contactTemplate = new SDataTemplateResourceRequest(dynamic);
            contactTemplate.ResourceKind = "contacts";

            Sage.SData.Client.Atom.AtomEntry tempEntry = contactTemplate.Read();
            SDataPayload payload = tempEntry.GetSDataPayload();

            Sage.SData.Client.Atom.AtomEntry leadEntry = null;
            do
            {
                leadEntry = fetchLead();
            } while (leadEntry == null);

            SDataPayload leadPayload = leadEntry.GetSDataPayload();

            SDataResourceCollectionRequest search = new SDataResourceCollectionRequest(dynamic)
            {
                ResourceKind = "accounts",
                QueryValues = { { "where", "AccountName eq '" + leadPayload.Values["Company"] + "'" } }
            };

            var feed = search.Read();
            bool test = false;
            foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
            {
                if (entry != null)
                {
                    test = true;
                    break;
                }
                else
                    test = false;
            }

            if (test)
            {
                SDataServiceOperationRequest request = new SDataServiceOperationRequest(service)
                {
                    ResourceKind = "leads",
                    Entry = leadEntry,
                    OperationName = "ConvertLeadToContact"
                };
                request.Create();
                Debug.WriteLine("Converted " + leadPayload.Values["FirstName"] + " " + leadPayload.Values["LastName"] + " to a contact");
                /*
                payload.Values["AccountName"] = leadPayload.Values["Company"];
                payload.Values["CreateDate"] = DateTime.Now;
                payload.Values["CreateUser"] = UserID;
                payload.Values["CuisinePreference"] = "Asian, Grill, or Mexican";
                payload.Values["Email"] = leadPayload.Values["Email"];
                payload.Values[""] = "";*/
            }
            else
            {
                SDataServiceOperationRequest request = new SDataServiceOperationRequest(service)
                {
                    ResourceKind = "leads",
                    Entry = leadEntry,
                    OperationName = "ConvertLeadToAccount"
                };
                request.Create();
                Debug.WriteLine("Converted " + leadPayload.Values["FirstName"] + " " + leadPayload.Values["LastName"] + " to a contact with Account " + leadPayload.Values["Company"]);
            }


        }
Exemplo n.º 13
0
        // Functional
        public void ticket()
        {
            SDataTemplateResourceRequest ticketTemplate = new SDataTemplateResourceRequest(dynamic);
            ticketTemplate.ResourceKind = "tickets";

            Sage.SData.Client.Atom.AtomEntry tempEntry = ticketTemplate.Read();
            SDataPayload payload = tempEntry.GetSDataPayload();

            SDataPayload accountPayload = null;
            int i = 0;
            do
            {
                accountPayload = fetchAccount();
                i++;
            } while (accountPayload == null && i < 50);

            if (i == 50)
                return;

            //accountPayload.Values["UserField1"] = UserID;

            // Only need account name for the payload to be complete
            payload.Values["Account"] = accountPayload;
            try
            {
                if (accountPayload.Values["Contacts"] != null)
                {
                    SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                    {
                        ResourceKind = "contacts",
                        QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                    };
                    var feed = contact.Read();
                    SDataPayload contactPayload = null;
                    if (feed.Entries.Count() != 0)
                    {
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            contactPayload = entry.GetSDataPayload();
                            break;
                        }
                        payload.Values["Contact"] = contactPayload;
                    }
                }
            }
            catch (Exception e)
            {
                Log(e.ToString(),fileName);;
            }

            tempEntry.SetSDataPayload(payload);

            SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
            {
                ResourceKind = "tickets",
                Entry = tempEntry
            };
            request.Create();
            //Sage.SData.Client.Atom.AtomEntry ent = request.Read();
            //SDataPayload tempLoad = ent.GetSDataPayload();
            Debug.WriteLine("Created ticket number: " + accountPayload.Values["AccountName"]);
            ticketsCount++;
            // in this case notes created is for tickets for helper and for ticker maker
            SetNotesCreated(ticketsCount.ToString());
            //SDataServiceOperationRequest

        }
Exemplo n.º 14
0
        // Functional
        public void opportunity()
        {
            SDataTemplateResourceRequest opportunityTemplate = new SDataTemplateResourceRequest(dynamic);
            opportunityTemplate.ResourceKind = "opportunities";

            Sage.SData.Client.Atom.AtomEntry tempEntry = opportunityTemplate.Read();
            SDataPayload payload = tempEntry.GetSDataPayload();

            SDataPayload accountPayload = null;
            int i = 0;
            do
            {
                accountPayload = fetchAccount();
                i++;
            } while (accountPayload == null & i < 50);

            if (i == 50)
                return;

            int oppValue = 500 * rand.Next(1, 1000);
            DateTime closeDate = DateTime.Now;
            closeDate = closeDate.AddMonths(3);
            int month = rand.Next(0, 12);
            int day = rand.Next(0, 30);
            closeDate = closeDate.AddMonths(month);
            closeDate = closeDate.AddDays(day);

            payload.Values["ActualAmount"] = oppValue;
            payload.Values["CreateDate"] = DateTime.Now;
            payload.Values["CreateUser"] = UserID;
            payload.Values["Description"] = accountPayload.Values["AccountName"] + " - Phase " + rand.Next(0, 10);
            payload.Values["Account"] = accountPayload;
            payload.Values["Owner"] = UserID;
            payload.Values["SalesAmount"] = oppValue;
            payload.Values["SalesPotential"] = oppValue;
            payload.Values["CloseProbability"] = 5 * rand.Next(0, 20);
            payload.Values["EstimatedClose"] = closeDate;

            if (accountPayload.Values["Contacts"] != null)
            {
                SDataBatchRequest contact = new SDataBatchRequest(dynamic)
                {
                    ResourceKind = "contacts",
                    QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                };


                /*
                var feed = contact.Read();
                SDataPayload contactPayload = ;
                if (feed.Entries.Count() != 0)
                {
                    int i = 1;
                    foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                    {
                        contactPayload.Values["Contact" + i] = entry.GetSDataPayload();
                        i++;
                    } */
                payload.Values["Contacts"] = contact;
                //}
            }

            tempEntry.SetSDataPayload(payload);

            SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
            {
                ResourceKind = "opportunities",
                Entry = tempEntry
            };
            request.Create();
            opportunitiesCount++;
            SetOppsCreated(opportunitiesCount.ToString());
            Debug.WriteLine("Opportunity made for account: " + accountPayload.Values["AccountName"]);
        }
Exemplo n.º 15
0
        // Functional
        public void activity(List<string> write)
        {
            try
            {
                SDataTemplateResourceRequest activityTemplate = new SDataTemplateResourceRequest(service);
                activityTemplate.ResourceKind = "activities";
                Sage.SData.Client.Atom.AtomEntry tempEntry = activityTemplate.Read();

                SDataPayload payload = tempEntry.GetSDataPayload();

                payload.Values["Type"] = write[1];
                
                /*
                payload.Values["Category"] = category;
                // Get the program to query the server for the contact name, account name, and retrieve the respective ids for each.
                payload.Values["AccountName"] = accountPayload.Values["AccountName"];
                payload.Values["AccountId"] = accountPayload.Key;
                // Checks to make sure there is a contact associated with the account, and if so calls a request to get the payload associated to that contact; then filling in payload.Values
                if (accountPayload.Values["Contacts"] != null)
                {
                    SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                    {
                        ResourceKind = "contacts",
                        QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                    };
                    var feed = contact.Read();
                    SDataPayload contactPayload = null;
                    if (feed.Entries.Count() != 0)
                    {
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            contactPayload = entry.GetSDataPayload();
                            break;
                        }
                        payload.Values["ContactName"] = contactPayload.Values["Name"];
                        payload.Values["ContactId"] = contactPayload.Key;
                    }
                }

                if (temp != "Personal")
                {
                    // Checks if there is an associated opportunity with the account, similar to how the contact was found.
                    if (accountPayload.Values["Opportunities"] != null)
                    {
                        SDataResourceCollectionRequest opp = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "opportunities",
                            QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                        };
                        var feed = opp.Read();
                        SDataPayload oppPayload = null;
                        if (feed.Entries.Count() != 0)
                        {
                            foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                            {
                                oppPayload = entry.GetSDataPayload();
                                break;
                            }
                            payload.Values["OpportunityName"] = oppPayload.Values["Description"];
                            payload.Values["OpportunityId"] = oppPayload.Key;
                        }
                    }

                    // Checks if there is an associated ticket with the account, similar to how the contact was found.
                    if (accountPayload.Values["Tickets"] != null)
                    {
                        SDataResourceCollectionRequest tick = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "tickets",
                            QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                        };
                        var feed = tick.Read();
                        SDataPayload ticketPayload = null;
                        if (feed.Entries.Count() != 0)
                        {
                            foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                            {
                                ticketPayload = entry.GetSDataPayload();
                                break;
                            }
                            payload.Values["TicketNumber"] = ticketPayload.Values["TicketNumber"];
                            payload.Values["TicketId"] = ticketPayload.Key;
                        }
                    }
                }
                payload.Values["Description"] = description;
                //payload.Values["Duration"] = "15 minutes";
                payload.Values["StartDate"] = startTime;
                payload.Values["Location"] = location;
                payload.Values["Priority"] = priority;
                payload.Values["LongNotes"] = notes;
                payload.Values["Notes"] = notes;
                payload.Values["AlarmTime"] = alarm;

                tempEntry.SetSDataPayload(payload);

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(service)
                {
                    ResourceKind = "activities",
                    Entry = tempEntry
                };

                //Creating the entry...
                request.Create();
                activitiesCount++;
                SetActivitiesCreated(activitiesCount.ToString());
                 * */
            }
            catch (Exception e)
            {
                Log(e.ToString(),fileName);;
            }
                
        }
Exemplo n.º 16
0
        // Functional
        public void makeContact()
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                SDataTemplateResourceRequest contactTemplate = new SDataTemplateResourceRequest(dynamic);
                contactTemplate.ResourceKind = "contacts";
                Sage.SData.Client.Atom.AtomEntry tempEntry = contactTemplate.Read();
                SDataPayload payload = tempEntry.GetSDataPayload();
                SDataPayload accountPayload = null;
                int i = 0;
                do
                {
                    accountPayload = fetchAccount();
                    i++;
                } while (accountPayload == null && i < 50);

                if (i == 50)
                    return;

                string firstName = localize(language, "Fake First Name", null, null, null, true);
                string lastName = localize(language, "Fake Last Name", null, null, null, true);

                if (accountPayload.Values["Contacts"] != null)
                {
                    SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                        {
                            ResourceKind = "contacts",
                            QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                        };
                    var feed = contact.Read();
                    SDataPayload contactPayload = null;
                    if (feed.Entries.Count() != 0)
                    {
                        foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                        {
                            contactPayload = entry.GetSDataPayload();
                            if (contactPayload.Values["FirstName"] == firstName && contactPayload.Values["LastName"] == lastName)
                            {
                                do
                                {
                                    firstName = localize(language, "Fake First Name", null, null, null, true);
                                    lastName = localize(language, "Fake Last Name", null, null, null, true);
                                } while (contactPayload.Values["FirstName"] == firstName && contactPayload.Values["LastName"] == lastName);
                            }

                        }
                    }
                }

                string emailProvider = "gmail";
                int temp = rand.Next(0, 4);
                switch (temp)
                {
                    case 0:
                        emailProvider = "yahoo";
                        break;
                    case 1:
                        emailProvider = "gmail";
                        break;
                    case 2:
                        emailProvider = "mail";
                        break;
                    case 3:
                        emailProvider = "me";
                        break;
                    default:
                        emailProvider = "hotmail";
                        break;
                }

                payload.Values["FirstName"] = firstName;
                payload.Values["LastName"] = lastName;
                payload.Values["LastNameUpper"] = lastName.ToUpper();
                payload.Values["NameLF"] = lastName + ", " + firstName;
                payload.Values["Name"] = firstName + " " + lastName;
                payload.Values["FullName"] = lastName + " , " + firstName;
                payload.Values["NamePFL"] = " " + firstName + " " + lastName;
                payload.Values["IsPrimary"] = false;
                payload.Values["Salutation"] = firstName;
                payload.Values["AccountName"] = accountPayload.Values["AccountName"];
                payload.Values["Account"] = accountPayload;
                payload.Values["CreateDate"] = DateTime.Now;
                payload.Values["ModifyDate"] = DateTime.Now;
                payload.Values["ModifyUser"] = UserID;
                payload.Values["CreateUser"] = UserID;
                payload.Values["Email"] = firstName + lastName + "@" + emailProvider + ".com";
                string phone = rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + 
                    rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + 
                    rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString();
                payload.Values["WorkPhone"] = phone;
                payload.Values["Mobile"] = phone;
                payload.Values["DoNotEmail"] = false;
                payload.Values["DoNotFax"] = false;
                payload.Values["DoNotMail"] = false;
                payload.Values["DoNotPhone"] = false;
                payload.Values["DoNotSolicit"] = false;
                payload.Values["IsServiceAuthorized"] = false;
                payload.Values["WebAddress"] = accountPayload.Values["WebAddress"];
                payload.Values["Status"] = "Active";
                payload.Values["Address"] = new SDataPayload
                                        {
                                            ResourceName = "addresses",
                                            Values = {
                                            {"Description", "Office"},
                                            {"CreateDate", DateTime.Now},
                                            {"CreateUser", UserID},
                                            {"IsMailing", true},
                                            {"IsPrimary", true},
                                            {"AddressType", "Billing &amp; Shipping"}
                                        }
                                        };

                payload.Values["Description"] = accountPayload.Values["Description"];
                payload.Values["PreferredContact"] = "Unknown";

                tempEntry.SetSDataPayload(payload);

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "contacts",
                    Entry = tempEntry
                };
                request.Create();
                float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                float timed = (after - previous) / 1000;
                contactsCount++;
                SetContactsCreated(contactsCount.ToString());
                Log(DateTime.Now + " - Created contact: " + payload.Values["Name"] +  " - " + timed + " seconds", fileName);
            }
            catch (Exception e) {
                Log(e.ToString(), fileName);
            }

        }
Exemplo n.º 17
0
        // Functional
        public void activityFor(SDataPayload opportunityPayload)
        {
            try
            {
                // Initializing the variables used to populate the payload. Each variable gets a value using a random value generator as defined below the creation functions.
                string temp = randomTypeGenerator();
                string category = randomCategoryGenerator(temp);
                string description = randomDescriptionGenerator(temp);
                //if (temp == "ToDo" && (description != "Send proposal" || description != "Send quote"))
                //{ temp = todoDecoder(description); }
                string type = "at" + temp;
                string location = randomLocationGenerator(temp);
                DateTime startTime = randomDateGenerator();
                string priority = randomPriorityGenerator();
                SDataPayload key = (SDataPayload)opportunityPayload.Values["Account"];
                SDataSingleResourceRequest getAccount = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "accounts",
                    ResourceSelector = "'" + key.Key + "'"
                };
                var rawr = getAccount.Read();
                SDataPayload accountPayload = rawr.GetSDataPayload();
                string notes = randomNoteGenerator(temp, accountPayload, description);
                DateTime alarm = startTime.AddMinutes(-15);
                DateTime duration;

                SDataTemplateResourceRequest activityTemplate = new SDataTemplateResourceRequest(service);
                activityTemplate.ResourceKind = "activities";
                Sage.SData.Client.Atom.AtomEntry tempEntry = activityTemplate.Read();

                SDataPayload payload = tempEntry.GetSDataPayload();

                payload.Values["OpportunityName"] = opportunityPayload.Values["Description"];
                payload.Values["OpportunityId"] = opportunityPayload.Key;
                payload.Values["Type"] = type;
                payload.Values["Category"] = category;
                // Get the program to query the server for the contact name, account name, and retrieve the respective ids for each.
                payload.Values["AccountName"] = accountPayload.Values["AccountName"];
                payload.Values["AccountId"] = accountPayload.Key;
                payload.Values["Description"] = description;
                //payload.Values["Duration"] = "15 minutes";
                payload.Values["StartDate"] = startTime;
                payload.Values["Location"] = location;
                payload.Values["Priority"] = priority;
                payload.Values["LongNotes"] = notes;
                payload.Values["Notes"] = notes;
                payload.Values["AlarmTime"] = alarm;


                tempEntry.SetSDataPayload(payload);

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(service)
                {
                    ResourceKind = "activities",
                    Entry = tempEntry
                };

                //Creating the entry...
                request.Create();
                activitiesCount++;
                //SetActivitiesCreated(activitiesCount.ToString());
            }
            catch (Exception e)
            {
                Log(e.ToString(),fileName);;
            }
        }
Exemplo n.º 18
0
        // Functional
        public void makeLead()
        {
            try
            {
                float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                SDataTemplateResourceRequest leadsTemplate = new SDataTemplateResourceRequest(dynamic);
                leadsTemplate.ResourceKind = "leads";

                bool checker = true;
                string firstName = "";
                string lastName = "";

                Sage.SData.Client.Atom.AtomEntry tempEntry = leadsTemplate.Read();
                SDataPayload payload = tempEntry.GetSDataPayload();
                // Checks to see if there is a lead with that name already created
                do
                {
                    firstName = localize(language, "Fake First Name", null, null, null, true);
                    lastName = localize(language, "Fake Last Name", null, null, null, true);
                    SDataResourceCollectionRequest check = new SDataResourceCollectionRequest(dynamic)
                    {
                        ResourceKind = "contacts",
                        QueryValues = { { "where", "LastName eq '" + lastName + "'" } }
                    };
                    var feed = check.Read();
                    foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                    {
                        SDataPayload tempPayload = entry.GetSDataPayload();
                        if ((string)tempPayload.Values["FirstName"] == firstName)
                        {
                            checker = true;
                            break;
                        }
                        else
                            checker = false;
                    }
                } while (checker);

                string emailProvider = "gmail";
                int temp = rand.Next(0, 4);
                switch (temp)
                {
                    case 0:
                        emailProvider = "yahoo";
                        break;
                    case 1:
                        emailProvider = "gmail";
                        break;
                    case 2:
                        emailProvider = "mail";
                        break;
                    case 3:
                        emailProvider = "me";
                        break;
                    default:
                        emailProvider = "hotmail";
                        break;

                }
                string phone = rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString()
                    + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString()
                    + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString();
                payload.Values["CreateUser"] = UserID;
                payload.Values["CreateDate"] = DateTime.Now.ToUniversalTime();
                payload.Values["Company"] = localize(language, "Fake Company Name", null, null, null, true);
                payload.Values["Email"] = firstName.ToLower() + lastName.ToLower() + "@" + emailProvider + ".com";
                payload.Values["FirstName"] = firstName;
                payload.Values["LastName"] = lastName;
                payload.Values["LastNameUpper"] = lastName.ToUpper();
                payload.Values["Mobile"] = phone;
                payload.Values["LeadNameFirstLast"] = firstName + " " + lastName;
                payload.Values["LeadNameLastFirst"] = lastName + ", " + firstName;

                SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
                {
                    ResourceKind = "leads",
                    Entry = tempEntry
                };

                request.Create();
                float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                float timed = (after - previous) / 1000;
                Log(DateTime.Now + " - Created lead: " + payload.Values["Company"] + ", " + payload.Values["LeadNameFirstLast"] + " - " + timed + " seconds", fileName);
                leadsCount++;
                SetLeadsCreated(leadsCount.ToString());
            }
            catch (Exception e) { 
                Log(e.ToString(), fileName); 
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            // SDataTemplateResourceRequest needs .Core so I have a using.
            SDataTemplateResourceRequest req = new SDataTemplateResourceRequest(_service);
            req.ResourceKind = "contacts";
            //AtomEntry needs Sage.SData.Client.Atom so I added a using
            AtomEntry entry = req.Read();
            var contact = entry.GetSDataPayload();

            //get rid of these guys since we do not want to set them.
            contact.Values.Remove("CreateDate");
            contact.Values.Remove("CreateUser");
            contact.Values.Remove("ModifyDate");
            contact.Values.Remove("ModifyUser");

            contact.Values["Account"] = GetEntityPayload("accounts", "AA2EK0013031");
            contact.Values["Email"] = "*****@*****.**";
            contact.Values["FirstName"] = "Jason";
            contact.Values["LastName"] = "Huber";

            //removing the address, but you would want it, and it would be another payload like account....
               //payload.Values.Remove("Address");

            //updated to go and get a new address template and get it in there..

               SDataPayload address = GetEntityTemplate("addresses");

               address.Values["Description"] = "SalesLogix/Act Office";
               address.Values["Address1"] = "8800 n. Gainey Center Drive";
               address.Values["City"] = "Scottsdale";
               address.Values["State"] = "AZ";

               contact.Values["Address"] = address;
            //payload.Values["Description"] = txtProjectDesc.Text;
            //payload.Values["StartDate"] = Convert.ToDateTime(dtStartDate.Text).ToString("yyyy-MM-dd");
            //payload.Values["EndDate"] = Convert.ToDateTime(dtEndDate.Text).ToString("yyyy-MM-dd");

            //now we can send the entry in.
            //need to go and get the task, then update it, then send it back.
            Sage.SData.Client.Core.SDataSingleResourceRequest rcu = new Sage.SData.Client.Core.SDataSingleResourceRequest(_service);

            rcu.ResourceKind = "contacts";
            rcu.Entry = entry;
            try
            {
                AtomEntry result = rcu.Create();
                //the result here should be 201 instead of 200 because it is a create.
                //http://interop.sage.com/daisy/sdata/CreateOperation/ErrorHandling.html

                if (result.GetSDataHttpStatus() == System.Net.HttpStatusCode.Created)
                {
                    MessageBox.Show("I added the contact!");
                }
                else
                {
                    MessageBox.Show("Insert Failed. /n" + result.GetSDataHttpMessage());
                }
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 20
0
        // Needs help!
        public void contact()
        {
            SDataTemplateResourceRequest contactTemplate = new SDataTemplateResourceRequest(dynamic);
            contactTemplate.ResourceKind = "contacts";
            Sage.SData.Client.Atom.AtomEntry tempEntry = contactTemplate.Read();
            SDataPayload payload = tempEntry.GetSDataPayload();
            SDataPayload accountPayload = null;
            int i = 0;
            do
            {
                accountPayload = fetchAccount();
                i++;
            } while (accountPayload == null && i < 50);

            if (i == 50)
                return;

            string firstName = GetFakeFirstName();
            string lastName = GetFakeLastName();

            if (accountPayload.Values["Contacts"] != null)
            {
                SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic)
                {
                    ResourceKind = "contacts",
                    QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } }
                };
                var feed = contact.Read();
                SDataPayload contactPayload = null;
                if (feed.Entries.Count() != 0)
                {
                    foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries)
                    {
                        contactPayload = entry.GetSDataPayload();
                        if (contactPayload.Values["FirstName"] == firstName && contactPayload.Values["LastName"] == lastName)
                        {
                            do
                            {
                                firstName = GetFakeFirstName();
                                lastName = GetFakeLastName();
                            } while (contactPayload.Values["FirstName"] == firstName && contactPayload.Values["LastName"] == lastName);
                        }

                    }
                    payload.Values["FirstName"] = firstName;
                    payload.Values["LastName"] = lastName;
                    payload.Values["LastNameUpper"] = lastName.ToUpper();
                    payload.Values["NameLF"] = lastName + ", " + firstName;
                    payload.Values["Name"] = firstName + " " + lastName;
                    payload.Values["FullName"] = lastName + " , " + firstName;
                    payload.Values["NamePFL"] = " " + firstName + " " + lastName;
                }
            }
            string emailProvider = "gmail";
            int temp = rand.Next(0, 4);
            switch (temp)
            {
                case 0:
                    emailProvider = "yahoo";
                    break;
                case 1:
                    emailProvider = "gmail";
                    break;
                case 2:
                    emailProvider = "mail";
                    break;
                case 3:
                    emailProvider = "me";
                    break;
                default:
                    emailProvider = "hotmail";
                    break;
            }

            payload.Values["AccountName"] = accountPayload.Values["AccountName"];
            payload.Values["Account"] = accountPayload;
            payload.Values["CreateDate"] = DateTime.Now;
            payload.Values["CreateUser"] = UserID;
            payload.Values["Email"] = firstName + lastName + "@" + emailProvider + ".com";
            string phone = rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString();
            payload.Values["WorkPhone"] = phone;
            payload.Values["Mobile"] = phone;
            payload.Values["DoNotEmail"] = false;
            payload.Values["DoNotFax"] = false;
            payload.Values["DoNotMail"] = false;
            payload.Values["DoNotPhone"] = false;
            payload.Values["DoNotSolicit"] = false;
            payload.Values["IsServiceAuthorized"] = false;
            payload.Values["IsPrimary"] = false;
            payload.Values["Status"] = "Active";
            payload.Values["Owner"] = "Everyone";
            payload.Values["PreferredContact"] = "Unknown";


            tempEntry.SetSDataPayload(payload);

            SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic)
            {
                ResourceKind = "contacts",
                Entry = tempEntry
            };
            request.Create();
            Log("Created contact: " + payload.Values["Name"], fileName);

        }