private static void AddMurocProduct(LoginUser loginUser, int organizationID, int productID) { OrganizationProducts ops = new OrganizationProducts(loginUser); try { OrganizationProduct op = ops.AddNewOrganizationProduct(); op.OrganizationID = organizationID; op.ProductID = productID; op.ProductVersionID = null; op.IsVisibleOnPortal = true; ops.Save(); } catch (Exception) { } }
private static void SyncNewOrg(HttpContext context) { /* * payload.OrganizationID = orgID; * payload.Company = company; * payload.UserID = userID; * payload.FirstName = firstName; * payload.LastName = lastName; * payload.Email = email; * payload.PhoneNumber = phoneNumber; * payload.ProductType = (int)productType; * payload.Promo = promo; * payload.HubSpotUtk = hubSpotUtk; * payload.Source = source; * payload.Campaign = campaign; * payload.PodName = SystemSettings.GetPodName(); * payload.Key = "81f4060c-2166-48c3-a126-b12c94f1fd9d"; * payload.PotentialSeats = 0; * */ try { dynamic data = JObject.Parse(ReadJsonData(context)); if (data.Key != "81f4060c-2166-48c3-a126-b12c94f1fd9d") { return; } LoginUser loginUser = LoginUser.Anonymous; Organization tsOrg = (new Organizations(loginUser)).AddNewOrganization(); tsOrg.ParentID = 1078; tsOrg.Name = data.Company; tsOrg.ImportID = data.PodName.ToString() + "-" + data.OrganizationID.ToString(); tsOrg.HasPortalAccess = true; tsOrg.IsActive = true; tsOrg.PotentialSeats = data.PotentialSeats; tsOrg.Collection.Save(); User tsUser = (new Users(loginUser)).AddNewUser(); tsUser.OrganizationID = tsOrg.OrganizationID; tsUser.FirstName = data.FirstName.ToString(); tsUser.LastName = data.LastName.ToString(); tsUser.Email = data.Email.ToString(); tsUser.IsActive = true; tsUser.IsPortalUser = true; tsUser.ImportID = data.UserID.ToString(); tsUser.Collection.Save(); tsOrg.PrimaryUserID = tsUser.UserID; tsOrg.Collection.Save(); PhoneNumber phone = (new PhoneNumbers(loginUser)).AddNewPhoneNumber(); phone.RefID = tsOrg.OrganizationID; phone.RefType = ReferenceType.Organizations; phone.Number = data.PhoneNumber.ToString(); phone.Collection.Save(); OrganizationProducts ops = new OrganizationProducts(loginUser); try { OrganizationProduct op = ops.AddNewOrganizationProduct(); op.OrganizationID = tsOrg.OrganizationID; op.ProductID = 219; op.ProductVersionID = null; op.IsVisibleOnPortal = true; op = ops.AddNewOrganizationProduct(); op.OrganizationID = tsOrg.OrganizationID; op.ProductID = 44639; op.ProductVersionID = null; op.IsVisibleOnPortal = true; ops.Save(); } catch (Exception ex) { ExceptionLogs.LogException(loginUser, ex, "signup"); } /* string[] salesGuys = SystemSettings.ReadString(loginUser, "SalesGuys", "Jesus:1045957|Leon:1045958").Split('|'); * int nextSalesGuy = int.Parse(SystemSettings.ReadString(loginUser, "NextSalesGuy", "0")); * if (nextSalesGuy >= salesGuys.Length || nextSalesGuy < 0) nextSalesGuy = 0; * string salesGuy = salesGuys[nextSalesGuy].Split(':')[0]; * string salesGuyID = salesGuys[nextSalesGuy].Split(':')[1]; * nextSalesGuy++; * if (nextSalesGuy >= salesGuys.Length) nextSalesGuy = 0; * SystemSettings.WriteString(loginUser, "NextSalesGuy", nextSalesGuy.ToString()); */ string promo = data.Promo.ToString(); string hubSpotUtk = data.HubSpotUtk.ToString(); string source = data.Source.ToString(); string campaign = data.Campaign.ToString(); string potentialSeats = data.PotentialSeats.ToString(); ProductType productType = (ProductType)int.Parse(data.ProductType.ToString()); string version = productType == ProductType.HelpDesk ? "Support Desk" : "Enterprise"; try { CustomFields customFields = new CustomFields(loginUser); customFields.LoadByOrganization(1078); CustomValues.UpdateByAPIFieldName(loginUser, customFields, tsOrg.OrganizationID, "Version", version); CustomValues.UpdateByAPIFieldName(loginUser, customFields, tsOrg.OrganizationID, "PodName", data.PodName.ToString()); CustomValues.UpdateByAPIFieldName(loginUser, customFields, tsOrg.OrganizationID, "TeamSupportOrganizationID", data.OrganizationID.ToString()); CustomValues.UpdateByAPIFieldName(loginUser, customFields, tsOrg.OrganizationID, "LifecycleStatus", "Trial"); } catch (Exception ex) { ExceptionLogs.LogException(loginUser, ex, "SyncOrg - Custom Fields"); } try { TSHubSpot.HubspotPost(tsUser.FirstName, tsUser.LastName, tsUser.Email, tsOrg.Name, phone.Number, promo, potentialSeats, source, hubSpotUtk, productType); } catch (Exception ex) { ExceptionLogs.LogException(loginUser, ex, "Sign Up - HubSpot", "UserID: " + tsUser.UserID.ToString()); } try { int hrCompanyID = TSHighrise.CreateCompany(tsOrg.Name, phone.Number, tsUser.Email, productType, "", source, campaign, "", new string[] { "trial" }); int hrContactID = TSHighrise.CreatePerson(tsUser.FirstName, tsUser.LastName, tsOrg.Name, phone.Number, tsUser.Email, productType, "", source, campaign, ""); //1. New Trial Check In:1496359 //3. End of trial: 1496361 //Eric's ID 159931 //TSHighrise.CreateTaskFrame("", "today", "1496359", "Party", hrContactID.ToString(), salesGuyID, true, true); //TSHighrise.CreateTaskDate("", DateTime.Now.AddDays(14), "1496361", "Company", hrCompanyID.ToString(), "159931", true, false);// } catch (Exception ex) { ExceptionLogs.LogException(loginUser, ex, "Sign Up - Highrise", "UserID: " + tsUser.UserID.ToString()); } } catch (Exception ex) { ExceptionLogs.LogException(LoginUser.Anonymous, ex, "SyncUser"); throw; } }