public string CreateTextControl(CustomField field, bool isEditable = false, int organizationID = -1) { StringBuilder html = new StringBuilder(); if (isEditable) { CustomValue value = CustomValues.GetValue(TSAuthentication.GetLoginUser(), field.CustomFieldID, organizationID); html.AppendFormat(@"<div class='form-group'> <label for='{0}' class='col-xs-4 control-label'>{1}</label> <div class='col-xs-8'> <p class='form-control-static'><a class='editable' id='{0}' data-type='text'>{2}</a></p> </div> </div>", field.CustomFieldID, field.Name, value.Value); } else { StringBuilder mask = new StringBuilder(); if (!String.IsNullOrEmpty(field.Mask)) { mask.Append("placeholder='" + field.Mask + "'"); } html.AppendFormat("<div class='col-xs-8'><input class='form-control col-xs-10 customField {1}' id='{0}' name='{0}' {2}></div>", field.CustomFieldID, field.IsRequired ? "required" : "", mask.ToString()); } return(html.ToString()); }
public CustomValueProxy[] GetValues(ReferenceType refType, int id) { CustomValues values = new CustomValues(TSAuthentication.GetLoginUser()); values.LoadByReferenceType(TSAuthentication.OrganizationID, refType, id); return(values.GetCustomValueProxies()); }
public CustomValueProxy SaveCustomValue(int customFieldID, int refID, object value) { CustomValue customValue = CustomValues.GetValue(TSAuthentication.GetLoginUser(), customFieldID, refID); if (value == null) { customValue.Value = ""; customValue.Collection.Save(); return(null); } switch (customValue.FieldType) { case CustomFieldType.DateTime: customValue.Value = ((DateTime)value).ToString(); break; case CustomFieldType.Date: customValue.Value = ((DateTime)value).ToShortDateString(); break; default: customValue.Value = DataUtils.CleanValueScript(value.ToString()); break; } customValue.Collection.Save(); return(customValue.GetProxy()); }
public void SaveCustomFieldText(int refID, int fieldID, string value) { CustomValue customValue = CustomValues.GetValue(UserSession.LoginUser, fieldID, refID); customValue.Value = value; customValue.Collection.Save(); }
public void SaveCustomFieldBool(int refID, int fieldID, bool value) { CustomValue customValue = CustomValues.GetValue(UserSession.LoginUser, fieldID, refID); customValue.Value = value.ToString(); customValue.Collection.Save(); }
public void SaveCustomFieldDate(int refID, int fieldID, DateTime?value) { DateTime?date; try { if (value == null) { date = null; } else { date = Convert.ToDateTime(value); } } catch (Exception) { date = null; } CustomValue customValue = CustomValues.GetValue(UserSession.LoginUser, fieldID, refID); if (date != null) { customValue.Value = DataUtils.DateToUtc(UserSession.LoginUser, date).ToString(); } else { customValue.Value = ""; } customValue.Collection.Save(); }
private void RecoverTicketCustomValues(int orgID, int badTicketID, int goodTicketID) { CustomValues badCustomValues = new CustomValues(GetCorrupteLoginUser()); badCustomValues.LoadByReferenceTypeModifiedAfterRecovery(orgID, ReferenceType.Tickets, badTicketID); foreach (CustomValue badCustomValue in badCustomValues) { try { if (badCustomValue == null) { continue; } CustomValue goodCustomValue = CustomValues.GetValue(GetReviewLoginUser(), goodTicketID, badCustomValue.ApiFieldName); if (goodCustomValue != null) { goodCustomValue.Value = badCustomValue.Value; goodCustomValue.Collection.Save(); } } catch (Exception ex) { _exceptionOcurred = true; ExceptionLogs.LogException(GetCorrupteLoginUser(), ex, "recover"); } } }
public string CreatePickListControl(CustomField field, bool isEditable = false, int organizationID = -1) { StringBuilder html = new StringBuilder(); string[] items = field.ListValues.Split('|'); if (isEditable) { CustomValue value = CustomValues.GetValue(TSAuthentication.GetLoginUser(), field.CustomFieldID, organizationID); html.AppendFormat(@"<div class='form-group'> <label for='{0}' class='col-xs-4 control-label'>{1}</label> <div class='col-xs-8'> <p class='form-control-static'><a class='editable' id='{0}' data-type='select'>{2}</a></p> </div> </div>", field.CustomFieldID, field.Name, value.Value); } else { html.AppendFormat("<div class='col-xs-8'><select class='form-control customField' id='{0}' name='{0}' type='picklist'>", field.CustomFieldID); foreach (string item in items) { html.AppendFormat("<option value='{0}'>{1}</option>", item, item); } html.Append("</select></div>"); } return(html.ToString()); }
public ActionResult PlantDetails(PlantDto plantDto) { var plantDir = Server.MapPath("~/Images/Plant/" + plantDto.ID.ToString()); List <Images> imgList = Mappers.ImageMapper.MapHTTPToImage(plantDto.Images, plantDto, plantDir); foreach (var img in imgList) { ImageCRUD.Insert(img); } //List<Images> pltImgList = ImageCRUD.GetByPlantID(plantDto.ID); //foreach(var img in pltImgList) //{ // imgList.Add(img); //} PlantDAL.EDMX.Plant plant = Mappers.PlantMapper.MapDtoToDAL(plantDto, imgList); plant.UserID = User.Identity.GetUserId(); if (plantDto.CustomValues1 != null) { CustomValues cv1 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues1, 1) as CustomValues; plant.CustomValues = cv1; plant.CustomValueOneID = cv1.ID; } if (plantDto.CustomValues2 != null) { CustomValues cv2 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues2, 2) as CustomValues; plant.CustomValues1 = cv2; plant.CustomValueTwoD = cv2.ID; } if (plantDto.CustomValues3 != null) { CustomValues cv3 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues3, 3) as CustomValues; plant.CustomValues2 = cv3; plant.CustomValueThreeID = cv3.ID; } if (plantDto.CustomValues4 != null) { CustomValues cv4 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues4, 4) as CustomValues; plant.CustomValues3 = cv4; plant.CustomValueFourID = cv4.ID; } if (plantDto.CustomValues5 != null) { CustomValues cv5 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues5, 5) as CustomValues; plant.CustomValues4 = cv5; plant.CustomValueFiveID = cv5.ID; } PlantCRUD.Update(plant); return(RedirectToAction("PlantTable")); }
private string GetUserSlackID(int userID) { CustomValue customValue = CustomValues.GetValue(LoginUser, userID, "slackname"); if (customValue != null && !string.IsNullOrWhiteSpace(customValue.Value)) { return(customValue.Value); } return(null); }
public static string GetCustomValue(RestCommand command, int customValueID) { CustomValue customValue = CustomValues.GetCustomValue(command.LoginUser, customValueID); if (customValue.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } return(customValue.GetXml("CustomValue", true)); }
private T?GetValue <T>(string key) where T : struct { key = makeKey(key); if (CustomValues.ContainsKey(key)) { var val = CustomValues[key].ToNullable <T>(); return(val); } return(null); }
public static CustomValues GetByID(Guid?id) { CustomValues cv = new CustomValues(); using (PlantTrackerDBEntities ctx = new PlantTrackerDBEntities()) { cv = ctx.CustomValues.FirstOrDefault(x => x.ID == id); } return(cv); }
override protected void GetNextRecord() { Product product = Products.GetProduct(_loginUser, _itemIDList[_rowIndex]); _lastItemID = product.ProductID; UpdatedItems.Add((int)_lastItemID); StringBuilder builder = new StringBuilder(); builder.AppendLine(product.Description + " " + product.Name + " " + product.DateCreated + " " + product.DateModified); DocText = builder.ToString(); _docFields.Clear(); AddDocField("ProductID", product.ProductID); AddDocField("Name", product.Name); if (product.ProductFamilyID != null) { AddDocField("ProductFamilyID", (int)product.ProductFamilyID); } DocDisplayName = product.Name; ProductSearch productItem = new ProductSearch(product); Tickets tickets = new Tickets(_loginUser); productItem.openTicketCount = tickets.GetProductTicketCount(product.ProductID, 0); AddDocField("**JSON", JsonConvert.SerializeObject(productItem)); CustomValues customValues = new CustomValues(_loginUser); customValues.LoadByReferenceType(_organizationID, ReferenceType.Products, product.ProductID); foreach (CustomValue value in customValues) { object o = value.Row["CustomValue"]; string s = o == null || o == DBNull.Value ? "" : o.ToString(); AddDocField(value.Row["Name"].ToString(), s); } DocFields = _docFields.ToString(); DocIsFile = false; DocName = product.ProductID.ToString(); try { DocCreatedDate = (DateTime)product.Row["DateCreated"]; DocModifiedDate = (DateTime)product.Row["DateModified"]; } catch (Exception) { } }
public void SaveCustomFields() { CustomFields fields = new CustomFields(UserSession.LoginUser); fields.LoadByReferenceType(UserSession.LoginUser.OrganizationID, _refType, _auxID); foreach (CustomField field in fields) { Control control = GetCustomControl(_table, FieldIDToControlID(field.CustomFieldID)); if (control != null) { CustomValue value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, _refID); if (control is RadInputControl) { value.Value = (control as RadInputControl).Text; } else if (control is CheckBox) { value.Value = (control as CheckBox).Checked.ToString(); } else if (control is RadComboBox) { value.Value = (control as RadComboBox).SelectedValue; } else if (control is RadDatePicker) { if (control is RadTimePicker) { DateTime?selectedNullableDateTime = (control as RadTimePicker).SelectedDate; if (selectedNullableDateTime != null) { DateTime selectedDateTime = (DateTime)selectedNullableDateTime; DateTime timeOnly = new DateTime(1970, 1, 1, selectedDateTime.Hour, selectedDateTime.Minute, 0, 0, UserSession.LoginUser.CultureInfo.Calendar); value.Value = DataUtils.DateToUtc(UserSession.LoginUser, timeOnly).ToString(); } } else { value.Value = DataUtils.DateToUtc(UserSession.LoginUser, (control as RadDatePicker).SelectedDate).ToString(); } } else if (control is RadDateTimePicker) { value.Value = DataUtils.DateToUtc(UserSession.LoginUser, (control as RadDateTimePicker).SelectedDate).ToString(); } value.Collection.Save(); } } }
public static string GetCustomValues(RestCommand command) { CustomValues customValues = new CustomValues(command.LoginUser); customValues.LoadByOrganizationID(command.Organization.OrganizationID); if (command.Format == RestFormat.XML) { return(customValues.GetXml("CustomValues", "CustomValue", true, command.Filters)); } else { throw new RestException(HttpStatusCode.BadRequest, "Invalid data format"); } }
public string CheckRequiredCustomFields() { CustomFields fields = new CustomFields(UserSession.LoginUser); fields.LoadByReferenceType(UserSession.LoginUser.OrganizationID, _refType, _auxID); foreach (CustomField field in fields) { Control control = GetCustomControl(_table, FieldIDToControlID(field.CustomFieldID)); if (control != null) { CustomValue value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, _refID); if (value.IsRequired) { if (control is RadInputControl) { value.Value = (control as RadInputControl).Text; } else if (control is CheckBox) { value.Value = (control as CheckBox).Checked.ToString(); } else if (control is RadComboBox) { if (field.IsFirstIndexSelect && (control as RadComboBox).SelectedIndex == 0) { value.Value = ""; } else { value.Value = (control as RadComboBox).SelectedValue; } } else if (control is RadDateTimePicker) { value.Value = DataUtils.DateToUtc(UserSession.LoginUser, (control as RadDateTimePicker).SelectedDate).ToString(); } if (value.Value == "" || value.Value == null) { return(value.Name + " is a required value, please enter a value before saving"); } } } } return(""); }
public static void Update(CustomValues cv) { try { using (PlantTrackerDBEntities ctx = new PlantTrackerDBEntities()) { ctx.CustomValues.Attach(cv); ctx.Entry(cv).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } } catch (Exception ex) { ex.ToString(); } }
public ActionResult NewPlant(PlantDto plantDto) { Guid id = Guid.NewGuid(); plantDto.ID = id; plantDto.UserID = User.Identity.GetUserId(); var plantDir = Server.MapPath("~/Images/Plant/" + id.ToString()); List <Images> imgList = Mappers.ImageMapper.MapHTTPToImage(plantDto.Images, plantDto, plantDir); PlantDAL.EDMX.Plant plant = Mappers.PlantMapper.MapDtoToDAL(plantDto, imgList); if (plantDto.CustomValues1 != null) { plantDto.CustomValues1.ID = Guid.NewGuid(); CustomValues cv1 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues1, 1) as CustomValues; plant.CustomValues = cv1; } if (plantDto.CustomValues2 != null) { plantDto.CustomValues2.ID = Guid.NewGuid(); CustomValues cv2 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues2, 2) as CustomValues; plant.CustomValues1 = cv2; } if (plantDto.CustomValues3 != null) { plantDto.CustomValues3.ID = Guid.NewGuid(); CustomValues cv3 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues3, 3) as CustomValues; plant.CustomValues2 = cv3; } if (plantDto.CustomValues4 != null) { plantDto.CustomValues4.ID = Guid.NewGuid(); CustomValues cv4 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues4, 4) as CustomValues; plant.CustomValues3 = cv4; } if (plantDto.CustomValues5 != null) { plantDto.CustomValues5.ID = Guid.NewGuid(); CustomValues cv5 = Mappers.CustomValueMapper.MapDtoToDAL(plantDto.CustomValues5, 5) as CustomValues; plant.CustomValues4 = cv5; } PlantCRUD.Insert(plant); return(RedirectToAction("PlantTable")); }
private void Start() { if (!IsEditor) { // This disables the debugger if it isn't played in-game. Debugger = new CustomValues { IsEnabled = false }; // This will load the Rust library. It causes problems in the editor, which is why it is in here. if (!_isRustLoaded) { try { PathManager.LoadLibrary(ModBundleName, Engine.LibraryName); } catch (FileNotFoundException e) { Panic("The Rust library failed to load! Please provide a FULL log file to @Emik#0001 on Discord", e); return; } } } // This is a test to make sure the library works, if it isn't loaded the module will solve here. try { Engine.IsLegalMove("", 0, 0); Engine.Calculate("", 0, true); } catch (DllNotFoundException e) { Panic("The Rust library file couldn't be found! Please reinstall the module, and check for the integrity of the /dlls folder! There should be a .so, .dylib, and .bundle file in the root, as well as 2 folders containing a dll.", e); return; } // Once we get here, we know that the library works, and therefore don't need to attempt to load it again. _isRustLoaded = true; _bestMove = new Work <string, int, bool, CGameResult>( work: Engine.Calculate, allowSimultaneousActive: true, maximumThreadsActive: 1); }
public string CreateBooleanControl(CustomField field, bool isEditable = false, int organizationID = -1) { StringBuilder html = new StringBuilder(); if (isEditable) { CustomValue value = CustomValues.GetValue(TSAuthentication.GetLoginUser(), field.CustomFieldID, organizationID); html.AppendFormat(@"<div class='form-group'> <label for='{0}' class='col-xs-4 control-label'>{1}</label> <div class='col-xs-8'> <p class='form-control-static'><a class='editable' id='{0}' data-type='text'>{2}</a></p> </div> </div>", field.CustomFieldID, field.Name, value.Value); } else { html.AppendFormat("<div class='col-xs-1'><label><input class='customField' id='{0}' type='checkbox'></label></div>", field.CustomFieldID); } return(html.ToString()); }
public static void WriteTicketsViewItemXml(RestCommand command, XmlWriter writer, TicketsViewItem ticket, CustomFields customFields) { if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.BadRequest, "Invalid TicketID"); } writer.WriteElementString("TicketID", ticket.TicketID.ToString()); writer.WriteElementString("TicketNumber", ticket.TicketNumber.ToString()); writer.WriteElementString("TicketType", ticket.TicketTypeName.ToString()); writer.WriteElementString("Name", ticket.Name.ToString()); writer.WriteElementString("IsClosed", ticket.IsClosed.ToString()); if (customFields != null) { foreach (CustomField field in customFields) { CustomValue value = CustomValues.GetValue(command.LoginUser, field.CustomFieldID, ticket.TicketID); writer.WriteElementString(field.ApiFieldName, value.Value); } } }
override protected void GetNextRecord() { ProductVersionsViewItem productVersion = ProductVersionsView.GetProductVersionsViewItem(_loginUser, _itemIDList[_rowIndex]); _lastItemID = productVersion.ProductVersionID; UpdatedItems.Add((int)_lastItemID); DocText = HtmlToText.ConvertHtml(productVersion.Description == null ? string.Empty : productVersion.Description); _docFields.Clear(); foreach (DataColumn column in productVersion.Collection.Table.Columns) { object value = productVersion.Row[column]; string s = value == null || value == DBNull.Value ? "" : value.ToString(); AddDocField(column.ColumnName, s); } ProductVersionsSearch productVersionsSearch = new ProductVersionsSearch(productVersion); Tickets tickets = new Tickets(_loginUser); productVersionsSearch.openTicketCount = tickets.GetProductVersionTicketCount(productVersion.ProductVersionID, 0, _organizationID); AddDocField("**JSON", JsonConvert.SerializeObject(productVersionsSearch)); CustomValues customValues = new CustomValues(_loginUser); customValues.LoadByReferenceType(_organizationID, ReferenceType.ProductVersions, null, productVersion.ProductVersionID); foreach (CustomValue value in customValues) { object o = value.Row["CustomValue"]; string s = o == null || o == DBNull.Value ? "" : o.ToString(); AddDocField(value.Row["Name"].ToString(), s); } DocFields = _docFields.ToString(); DocIsFile = false; DocName = productVersion.ProductVersionID.ToString(); DocCreatedDate = productVersion.DateCreatedUtc; DocModifiedDate = DateTime.UtcNow; }
public static object MapDALToDto(CustomValues customValue, int i) { var cv = new CustomValueDto(); if (i == 1) { cv.ID = customValue.ID; cv.Name = customValue.Name; cv.Notes = customValue.Notes; } else if (i == 2) { cv.ID = customValue.ID; cv.Name = customValue.Name; cv.Notes = customValue.Notes; } else if (i == 3) { cv.ID = customValue.ID; cv.Name = customValue.Name; cv.Notes = customValue.Notes; } else if (i == 4) { cv.ID = customValue.ID; cv.Name = customValue.Name; cv.Notes = customValue.Notes; } else { cv.ID = customValue.ID; cv.Name = customValue.Name; cv.Notes = customValue.Notes; } return(cv); }
public ActionResult DeletePlant(string PlantId, string FilePath) { try { var curUrl = ConfigurationManager.AppSettings["url"].TrimEnd('/'); var pathDelete = FilePath.Replace(curUrl, "").Replace("/", "\\"); var serverDir = Server.MapPath("/").TrimEnd('\\'); var fileDel = serverDir + pathDelete; int idx = fileDel.IndexOf(PlantId); if (idx != -1) { fileDel = fileDel.Substring(0, idx + 36); System.IO.Directory.Delete(fileDel, true); } Guid plantId = Guid.Parse(PlantId); PlantDAL.EDMX.Plant plant = PlantCRUD.GetByID(plantId); List <Images> images = ImageCRUD.GetByPlantID(plantId); foreach (var img in images) { ImageCRUD.Delete(img); } if (plant.CustomValueOneID != null) { CustomValues cv = CustomValueCRUD.GetByID(plant.CustomValueOneID); CustomValueCRUD.Delete(cv); } if (plant.CustomValueTwoD != null) { CustomValues cv = CustomValueCRUD.GetByID(plant.CustomValueTwoD); CustomValueCRUD.Delete(cv); } if (plant.CustomValueThreeID != null) { CustomValues cv = CustomValueCRUD.GetByID(plant.CustomValueThreeID); CustomValueCRUD.Delete(cv); } if (plant.CustomValueFourID != null) { CustomValues cv = CustomValueCRUD.GetByID(plant.CustomValueFourID); CustomValueCRUD.Delete(cv); } if (plant.CustomValueFiveID != null) { CustomValues cv = CustomValueCRUD.GetByID(plant.CustomValueFiveID); CustomValueCRUD.Delete(cv); } List <PlantDAL.EDMX.Journal> journals = JournalCRUD.GetByPlantID(plant.ID); foreach (var jour in journals) { List <Images> jourImages = ImageCRUD.GetByJournalID(jour.ID); foreach (var img in jourImages) { ImageCRUD.Delete(img); } JournalCRUD.Delete(jour); } List <PlantDAL.EDMX.Plant> childrenPlants = PlantCRUD.GetByParentId(plant.ID); foreach (var plt in childrenPlants) { if (plt.ParentOneID == plant.ID) { plt.ParentOneID = null; } if (plt.ParentTwoID == plant.ID) { plt.ParentTwoID = null; } PlantCRUD.Update(plt); } PlantCRUD.Delete(plant); } catch (Exception ex) { ex.ToString(); } return(Json(new { IsError = false, message = "success", data = true }, JsonRequestBehavior.AllowGet)); }
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; } }
public void LoadValues() { CustomFields fields = new CustomFields(UserSession.LoginUser); fields.LoadByReferenceType(UserSession.LoginUser.OrganizationID, _refType, _auxID); foreach (CustomField field in fields) { Control control = GetCustomControl(_table, FieldIDToControlID(field.CustomFieldID)); CustomValue value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, _refID); if (control != null && value != null) { try { if (control is RadInputControl) { (control as RadInputControl).Text = value.Value; } else if (control is CheckBox) { (control as CheckBox).Checked = bool.Parse(value.Value); } else if (control is RadComboBox) { (control as RadComboBox).SelectedValue = value.Value; } else if (control is RadDatePicker) { if (control is RadTimePicker) { if (value.Value == "") { (control as RadTimePicker).SelectedDate = null; } else { (control as RadTimePicker).SelectedDate = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); } } else { if (value.Value == "") { (control as RadDatePicker).SelectedDate = null; } else { (control as RadDatePicker).SelectedDate = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); } } } else if (control is RadDateTimePicker) { if (value.Value == "") { (control as RadDateTimePicker).SelectedDate = null; } else { (control as RadDateTimePicker).SelectedDate = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); } } } catch (Exception ex) { } } } }
public int SaveAsset(string data) { NewAssetSave info; try { info = Newtonsoft.Json.JsonConvert.DeserializeObject <NewAssetSave>(data); } catch (Exception e) { return(-1); } LoginUser loginUser = TSAuthentication.GetLoginUser(); Assets assets = new Assets(loginUser); Asset asset = assets.AddNewAsset(); asset.OrganizationID = TSAuthentication.OrganizationID; asset.Name = info.Name; asset.ProductID = info.ProductID; asset.ProductVersionID = info.ProductVersionID; asset.SerialNumber = info.SerialNumber; asset.WarrantyExpiration = DataUtils.DateToUtc(TSAuthentication.GetLoginUser(), info.WarrantyExpiration); asset.Notes = info.Notes; //Location 1=assigned (shipped), 2=warehouse, 3=junkyard asset.Location = "2"; asset.DateCreated = DateTime.UtcNow; asset.DateModified = DateTime.UtcNow; asset.CreatorID = loginUser.UserID; asset.ModifierID = loginUser.UserID; asset.Collection.Save(); string description = String.Format("Created asset {0} ", GetAssetReference(asset)); ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Insert, ReferenceType.Assets, asset.AssetID, description); foreach (CustomFieldSaveInfo field in info.Fields) { CustomValue customValue = CustomValues.GetValue(TSAuthentication.GetLoginUser(), field.CustomFieldID, asset.AssetID); if (field.Value == null) { customValue.Value = ""; } else { if (customValue.FieldType == CustomFieldType.DateTime) { customValue.Value = ((DateTime)field.Value).ToString(); //DateTime dt; //if (DateTime.TryParse(((string)field.Value), System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal, out dt)) //{ // customValue.Value = dt.ToUniversalTime().ToString(); //} } else { customValue.Value = field.Value.ToString(); } } customValue.Collection.Save(); } AssetHistory history = new AssetHistory(loginUser); AssetHistoryItem historyItem = history.AddNewAssetHistoryItem(); historyItem.OrganizationID = loginUser.OrganizationID; historyItem.Actor = loginUser.UserID; historyItem.AssetID = asset.AssetID; historyItem.ActionTime = DateTime.UtcNow; historyItem.ActionDescription = "Asset created."; historyItem.ShippedFrom = 0; historyItem.ShippedTo = 0; historyItem.TrackingNumber = string.Empty; historyItem.ShippingMethod = string.Empty; historyItem.ReferenceNum = string.Empty; historyItem.Comments = string.Empty; history.Save(); return(asset.AssetID); }
private void WriteProperties(TicketGridViewItem ticket) { lblTitle.Text = "Ticket Number: " + ticket.TicketNumber.ToString(); lblDescription.Text = ticket.Name; StringBuilder builder = new StringBuilder(); builder.Append("<tr>"); builder.Append(GetColumn("Opened By", ticket.CreatorName)); builder.Append(GetColumn("Opened On", ticket.DateCreated.ToString("g", UserSession.LoginUser.CultureInfo))); builder.Append("</tr>"); builder.Append("<tr>"); builder.Append(GetColumn("Last Modified By", ticket.ModifierName)); // builder.Append("<td>Last Modified By:</td><td> <a href=\"../Default.aspx?UserID=" + ticket.ModifierID + "\" target=\"TSMain\">"); builder.Append(GetColumn("Last Modified On", ticket.DateModified.ToString("g", UserSession.LoginUser.CultureInfo))); builder.Append("</tr>"); builder.Append("<tr>"); if (ticket.IsClosed) { builder.Append(GetColumn("Days Closed", ticket.DaysClosed.ToString())); } else { builder.Append(GetColumn("Days Opened", ticket.DaysOpened.ToString())); } builder.Append(GetColumn("Total Time Spent", DataUtils.MinutesToDisplayTime(Tickets.GetTicketActionTime(UserSession.LoginUser, ticket.TicketID)))); builder.Append("</tr>"); if (ticket.IsClosed && ticket.DateClosed != null) { builder.Append("<tr>"); if (ticket.CloserID != null) { builder.Append(GetColumn("Closed By", ticket.CloserName)); } builder.Append(GetColumn("Closed On", ((DateTime)ticket.DateClosed).ToString("g", UserSession.LoginUser.CultureInfo))); builder.Append("</tr>"); } builder.Append("<tr>"); builder.Append(GetColumn("Ticket Type", ticket.TicketTypeName)); builder.Append(GetColumn("Assigned Group", ticket.GroupName)); builder.Append("</tr>"); builder.Append("<tr>"); builder.Append(GetColumn("Status", ticket.Status)); builder.Append(GetColumn("Product", ticket.ProductName)); builder.Append("</tr>"); builder.Append("<tr>"); builder.Append(GetColumn("Severity", ticket.Severity)); builder.Append(GetColumn("Reported Version", ticket.ReportedVersion)); builder.Append("</tr>"); builder.Append("<tr>"); builder.Append(GetColumn("Assigned To", ticket.UserName)); builder.Append(GetColumn("Resolved Version", ticket.SolvedVersion)); builder.Append("</tr>"); builder.Append("<tr>"); builder.Append(GetColumn("Visible On Portal", ticket.IsVisibleOnPortal.ToString())); builder.Append(GetColumn("Knowledge Base", ticket.IsKnowledgeBase.ToString())); builder.Append("</tr>"); builder.Append("<tr>"); builder.Append(GetColumn("Due Date", ticket.DueDate == null ? "" : ((DateTime)ticket.DueDate).ToString("g", UserSession.LoginUser.CultureInfo))); CustomFields fields = new CustomFields(UserSession.LoginUser); fields.LoadByTicketTypeID(UserSession.LoginUser.OrganizationID, ticket.TicketTypeID); bool flag = true; foreach (CustomField field in fields) { flag = !flag; if (flag) { builder.Append("<tr>"); } CustomValue value; value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, ticket.TicketID, false); builder.Append(GetColumn(field.Name + "", value.Value)); if (!flag) { builder.Append("</tr>"); } } if (flag) { builder.Append("</tr>"); } litProperties.Text = builder.ToString(); }
protected void Page_Load(object sender, EventArgs e) { int productID; try { productID = int.Parse(Request["ProductID"]); } catch (Exception) { Response.Write(""); Response.End(); return; } lblProperties.Visible = true; Product product = (Product)Products.GetProduct(UserSession.LoginUser, productID); lblProperties.Visible = product == null; if (product == null) { return; } DataTable table = new DataTable(); table.Columns.Add("Name"); table.Columns.Add("Value"); table.Rows.Add(new string[] { "Name:", product.Name }); table.Rows.Add(new string[] { "Description:", product.Description }); table.Rows.Add(new string[] { "Product ID:", product.ProductID.ToString() }); CustomFields fields = new CustomFields(UserSession.LoginUser); fields.LoadByReferenceType(UserSession.LoginUser.OrganizationID, ReferenceType.Products); StringBuilder valueAsString = null; foreach (CustomField field in fields) { CustomValue value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, productID); switch (value.FieldType) { case CustomFieldType.Date: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("d", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() }); break; case CustomFieldType.Time: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("t", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() }); break; case CustomFieldType.DateTime: valueAsString = new StringBuilder(); if (!string.IsNullOrEmpty(value.Value)) { try { DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value)); valueAsString.Append(valueAsDateTime.ToString("g", UserSession.LoginUser.CultureInfo)); } catch { valueAsString.Append(value.Value); } } table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() }); break; default: table.Rows.Add(new string[] { field.Name + ":", value.Value }); break; } } rptProperties.DataSource = table; rptProperties.DataBind(); }