public bool IsDuplicateCategory(int?categoryID, ReferenceType refType, int?auxID, string text)
        {
            text = text.Trim();
            CustomFieldCategories cats = new CustomFieldCategories(TSAuthentication.GetLoginUser());

            cats.LoadByRefType(refType, auxID);

            foreach (CustomFieldCategory item in cats)
            {
                if (categoryID != null && item.CustomFieldCategoryID == categoryID)
                {
                    continue;
                }

                if (item.Category.Trim().ToLower() == text.ToLower())
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        public List <WikiArticleListSubItem> GetWikiParentChildren(int parentID)
        {
            WikiArticles subArticles = WikiArticles.GetWikiSubArticles(TSAuthentication.GetLoginUser(), parentID);

            if (subArticles != null)
            {
                List <WikiArticleListSubItem> children = new List <WikiArticleListSubItem>();
                foreach (WikiArticle subArticle in subArticles)
                {
                    children.Add(new WikiArticleListSubItem
                    {
                        ID    = subArticle.ArticleID,
                        Title = subArticle.ArticleName
                    });
                }
                return(children);
            }
            else
            {
                return(null);
            }
        }
        public void Auth(string channel_name, string socket_id, int userID)
        {
            Users u = new Users(TSAuthentication.GetLoginUser());

            u.LoadByUserID(userID);

            var channelData = new PresenceChannelData()
            {
                user_id   = userID.ToString(),
                user_info = new
                {
                    name   = TSAuthentication.GetLoginUser().GetUserFullName(),
                    userid = userID.ToString(),
                    avatar = string.Format("/dc/{0}/UserAvatar/{1}/120", u[0].OrganizationID.ToString(), userID)
                }
            };

            var auth = pusher.Authenticate(channel_name, socket_id, channelData);
            var json = auth.ToJson();

            Context.Response.Write(json);
        }
Пример #4
0
        public List <TaskDTO> GetTasks(int from, int count, pageTab tab)
        {
            LoginUser      loginUser = TSAuthentication.GetLoginUser();
            List <TaskDTO> taskList  = new List <TaskDTO>();

            Tasks tasksHelper = new Tasks(loginUser);

            if (tab == pageTab.mytasks)
            {
                taskList = tasksHelper.LoadMyTasks(from, count, loginUser.UserID, true, false);
            }
            else if (tab == pageTab.assigned)
            {
                taskList = tasksHelper.LoadAssignedTasks(from, count, loginUser.UserID, true, false);
            }
            else if (tab == pageTab.completed)
            {
                taskList = tasksHelper.LoadCompleted(from, count, loginUser.UserID, false, true);
            }

            return(convertToClientTasksList(taskList, loginUser));
        }
Пример #5
0
        public AutocompleteItem[] FindAsset(string searchTerm)
        {
            Assets assets = new Assets(TSAuthentication.GetLoginUser());

            assets.LoadByLikeNameOrSerial(TSAuthentication.OrganizationID, searchTerm, 25);

            List <AutocompleteItem> list = new List <AutocompleteItem>();

            foreach (Asset asset in assets)
            {
                if (!string.IsNullOrEmpty(asset.SerialNumber))
                {
                    list.Add(new AutocompleteItem(string.Format("{0} ({1})", asset.Name, asset.SerialNumber), asset.AssetID.ToString()));
                }
                else
                {
                    list.Add(new AutocompleteItem(asset.Name, asset.AssetID.ToString()));
                }
            }

            return(list.ToArray());
        }
Пример #6
0
        public string GetShortNameFromID(int taskID)
        {
            Tasks tasks = new Tasks(TSAuthentication.GetLoginUser());

            tasks.LoadByTaskID(taskID);

            if (tasks.IsEmpty)
            {
                return("N/A");
            }

            string result = tasks[0].ReminderID.ToString();

            if (!String.IsNullOrEmpty(tasks[0].Name))
            {
                if (tasks[0].Name.Length > 10)
                {
                    result = tasks[0].Name.Substring(0, 10).ToString() + "...";
                }
                else
                {
                    result = tasks[0].Name.ToString();
                }
            }
            else if (!String.IsNullOrEmpty(tasks[0].Description))
            {
                if (tasks[0].Description.Length > 10)
                {
                    result = tasks[0].Description.Substring(0, 10).ToString() + "...";
                }
                else
                {
                    result = tasks[0].Description.ToString();
                }
            }

            return(result);
        }
Пример #7
0
        public WikiArticleListItem[] GetWikiMenuItems()
        {
            WikiArticles articles = WikiArticles.GetWikiParentArticles(TSAuthentication.GetLoginUser());
            List <WikiArticleListItem> wikiList = new List <WikiArticleListItem>();

            if (articles == null)
            {
                return(null);
            }

            foreach (WikiArticle article in articles)
            {
                WikiArticleListItem parent = new WikiArticleListItem
                {
                    ID    = article.ArticleID,
                    Title = article.ArticleName
                };

                WikiArticles subArticles = WikiArticles.GetWikiSubArticles(TSAuthentication.GetLoginUser(), article.ArticleID);
                if (subArticles != null)
                {
                    List <WikiArticleListSubItem> children = new List <WikiArticleListSubItem>();
                    foreach (WikiArticle subArticle in subArticles)
                    {
                        children.Add(new WikiArticleListSubItem
                        {
                            ID    = subArticle.ArticleID,
                            Title = subArticle.ArticleName
                        });
                    }
                    parent.SubArticles = children.ToArray();
                }

                wikiList.Add(parent);
            }

            return(wikiList.ToArray());
        }
Пример #8
0
        public string GetShortNameFromID(int assetID)
        {
            Assets assets = new Assets(TSAuthentication.GetLoginUser());

            assets.LoadByAssetID(assetID);

            if (assets.IsEmpty)
            {
                return("N/A");
            }

            string result = assets[0].AssetID.ToString();

            if (!String.IsNullOrEmpty(assets[0].Name))
            {
                if (assets[0].Name.Length > 10)
                {
                    result = assets[0].Name.Substring(0, 10).ToString() + "...";
                }
                else
                {
                    result = assets[0].Name.ToString();
                }
            }
            else if (!String.IsNullOrEmpty(assets[0].SerialNumber))
            {
                if (assets[0].SerialNumber.Length > 10)
                {
                    result = assets[0].SerialNumber.Substring(0, 10).ToString() + "...";
                }
                else
                {
                    result = assets[0].SerialNumber.ToString();
                }
            }

            return(result);
        }
Пример #9
0
        public ReportFolderProxy SaveFolder(int?folderID, string name)
        {
            ReportFolder folder = null;

            if (folderID == null)
            {
                folder = (new ReportFolders(TSAuthentication.GetLoginUser())).AddNewReportFolder();
                folder.OrganizationID = TSAuthentication.OrganizationID;
                folder.CreatorID      = TSAuthentication.UserID;
            }
            else
            {
                folder = ReportFolders.GetReportFolder(TSAuthentication.GetLoginUser(), (int)folderID);
                if (!TSAuthentication.IsSystemAdmin && folder.CreatorID != TSAuthentication.UserID)
                {
                    return(folder.GetProxy());
                }
            }

            folder.Name = name.Trim();
            folder.Collection.Save();
            return(folder.GetProxy());
        }
Пример #10
0
        public ReportItem[] GetDashboardReports()
        {
            string            data   = GetDashboard();
            List <ReportItem> result = new List <ReportItem>();

            if (!string.IsNullOrWhiteSpace(data))
            {
                DashboardItem[] items  = JsonConvert.DeserializeObject <DashboardItem[]>(GetDashboard());
                List <string>   idlist = new List <string>();
                foreach (DashboardItem item in items)
                {
                    idlist.Add(item.ReportID.ToString());
                }
                Reports reports = new Reports(TSAuthentication.GetLoginUser());
                reports.LoadList(TSAuthentication.OrganizationID, TSAuthentication.UserID, idlist.ToArray());
                foreach (Report report in reports)
                {
                    result.Add(new ReportItem(report, true));
                }
            }

            return(result.ToArray());
        }
Пример #11
0
 public void AdminTestQuery(int reportID, string query)
 {
     if (TSAuthentication.UserID != 34 && TSAuthentication.UserID != 47 && TSAuthentication.UserID != 4759191)
     {
         return;
     }
     if (!string.IsNullOrWhiteSpace(query))
     {
         Report report   = Reports.GetReport(TSAuthentication.GetLoginUser(), reportID);
         string oldQuery = report.Query;
         try
         {
             report.Query = query;
             report.Collection.Save();
             Reports.GetReportData(TSAuthentication.GetLoginUser(), reportID, 1, 10, "", true, false);
         }
         finally
         {
             report.Query = oldQuery;
             report.Collection.Save();
         }
     }
 }
Пример #12
0
        public bool SetScheduledReportIsActive(int scheduledReportId, bool isActive)
        {
            bool isSuccessful = false;

            try
            {
                LoginUser        loginUser        = TSAuthentication.GetLoginUser();
                ScheduledReports scheduledReports = new ScheduledReports(loginUser);
                scheduledReports.LoadById(scheduledReportId);

                if (scheduledReports != null && scheduledReports.Any())
                {
                    scheduledReports[0].IsActive = isActive;

                    if (!isActive)
                    {
                        scheduledReports[0].NextRun = null;
                    }
                    else
                    {
                        scheduledReports[0].SetNextRun();
                    }

                    scheduledReports[0].ModifierId = loginUser.UserID;
                    scheduledReports.Save();
                    isSuccessful = true;
                }
            }
            catch (Exception ex)
            {
                isSuccessful = false;
                ExceptionLogs.LogException(TSAuthentication.GetLoginUser(), ex, "ReportService.SetScheduledReportIsActive");
            }

            return(isSuccessful);
        }
Пример #13
0
        public int[] DeleteReports(string reportIDs)
        {
            List <int> result = new List <int>();

            int[] ids = JsonConvert.DeserializeObject <int[]>(reportIDs);
            for (int i = 0; i < ids.Length; i++)
            {
                int    reportID = ids[i];
                Report report   = Reports.GetReport(TSAuthentication.GetLoginUser(), reportID);
                if (report.OrganizationID == null && TSAuthentication.IsSystemAdmin)
                {
                    Reports.HideStockReport(TSAuthentication.GetLoginUser(), TSAuthentication.OrganizationID, reportID);
                    result.Add(reportID);
                }
                else if (report.OrganizationID == TSAuthentication.OrganizationID && (TSAuthentication.UserID == report.CreatorID || TSAuthentication.IsSystemAdmin))
                {
                    report.Delete();
                    report.Collection.Save();
                    result.Add(reportID);
                }
            }

            return(result.ToArray());
        }
        public bool DeleteMessage(int messageID)
        {
            //WatercoolerMsg wcm = new WatercoolerMsg(TSAuthentication.GetLoginUser());
            //wcm.LoadByMessageID(messageID);

            WatercoolerMsgItem wcm = WatercoolerMsg.GetWatercoolerMsgItem(TSAuthentication.GetLoginUser(), messageID);

            if (wcm.OrganizationID != TSAuthentication.OrganizationID)
            {
                return(false);
            }
            if (wcm.UserID != TSAuthentication.UserID && !TSAuthentication.IsSystemAdmin)
            {
                return(false);
            }

            wcm.IsDeleted = true;
            wcm.Collection.Save();

            //wcm[0].Delete();
            //wcm[0].Collection.Save();

            return(true);
        }
        public CustomFieldCategoryProxy SaveCategory(int categoryID, string text, int productFamilyID)
        {
            if (!TSAuthentication.IsSystemAdmin)
            {
                return(null);
            }
            CustomFieldCategory cat = CustomFieldCategories.GetCustomFieldCategory(TSAuthentication.GetLoginUser(), categoryID);

            if (cat.OrganizationID != TSAuthentication.OrganizationID)
            {
                return(null);
            }
            cat.Category = text.Trim();
            if (productFamilyID != -1)
            {
                cat.ProductFamilyID = productFamilyID;
            }
            else
            {
                cat.ProductFamilyID = null;
            }
            cat.Collection.Save();
            return(cat.GetProxy());
        }
Пример #16
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.AddHeader("Expires", "-1");
            context.Response.AddHeader("Pragma", "no-cache");

            if (TSAuthentication.Ticket == null)
            {
                context.Response.ContentType = "text/plain";
                context.Response.StatusCode  = (int)HttpStatusCode.Forbidden;
                context.Response.ClearContent();
                context.Response.End();
                return;
            }

            string sessionID = context.Request.Url.Segments[context.Request.Url.Segments.Length - 1];

            TsMainPageUpdate update = new TsMainPageUpdate();

            try
            {
                update.IsDebug   = TSAuthentication.OrganizationID == 1078 || TSAuthentication.IsBackdoor;
                update.IsExpired = false;

                using (SqlConnection connection = new SqlConnection(LoginUser.Anonymous.ConnectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand();
                    command.Connection  = connection;
                    command.CommandText = "SELECT EnforceSingleSession, SessionID, IsActive, MarkDeleted FROM Users WHERE UserID = @UserID";
                    command.Parameters.AddWithValue("UserID", TSAuthentication.UserID);
                    SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow);
                    if (reader.Read())
                    {
                        if (!(bool)reader[2] || (bool)reader[3])
                        {
                            update.IsExpired = true;
                        }
                        else if ((bool)reader[0] && reader[1] != DBNull.Value)
                        {
                            if (sessionID != null && sessionID.ToLower() != reader[1].ToString().ToLower() && !TSAuthentication.IsBackdoor)
                            {
                                update.IsExpired = true;
                            }
                        }
                    }
                    reader.Close();
                }

                update.RefreshID           = int.Parse(SystemSettings.ReadString(LoginUser.Anonymous, "RefreshID", "-1"));
                update.ExpireTime          = TSAuthentication.Ticket.Expiration.ToShortTimeString();
                update.Version             = GetVersion(context);
                update.MyUnreadTicketCount = Tickets.GetMyOpenUnreadTicketCount(TSAuthentication.GetLoginUser(), TSAuthentication.UserID);
            }
            catch (Exception ex)
            {
                ex.Data["SessionID"] = sessionID;
                ExceptionLogs.LogException(LoginUser.Anonymous, ex, "GetUserStatusUpdate");
            }


            context.Response.ContentType = "application/json; charset=utf-8";
            context.Response.Write(JsonConvert.SerializeObject(update));
        }
Пример #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["AssetID"] == null)
        {
            EndResponse("Invalid Asset");
        }

        int       assetID   = int.Parse(Request["AssetID"]);
        LoginUser loginUser = TSAuthentication.GetLoginUser();
        Asset     asset     = Assets.GetAsset(loginUser, assetID);

        if (asset == null)
        {
            EndResponse("Invalid Asset");
        }

        if (asset.OrganizationID != TSAuthentication.OrganizationID)
        {
            EndResponse("Invalid Asset");
        }

        tipAsset.InnerText = asset.Name;
        tipAsset.Attributes.Add("onclick", "top.Ts.MainPage.openAsset(" + assetID.ToString() + "); return false;");

        StringBuilder props = new StringBuilder();

        if (!string.IsNullOrEmpty(asset.SerialNumber))
        {
            props.Append(string.Format("<dt>{0}</dt><dd>{1}</dd>", "Serial Number", asset.SerialNumber));
        }
        if (!string.IsNullOrEmpty(asset.Location))
        {
            props.Append(string.Format("<dt>{0}</dt><dd>{1}</dd>", "Location", asset.Location));
        }
        switch (asset.Location.Trim())
        {
        case "1": props.Append("<dt>Location</dt><dd>Assigned</dd>"); break;

        case "2": props.Append("<dt>Location</dt><dd>Warehouse</dd>"); break;

        case "3": props.Append("<dt>Location</dt><dd>Junkyard</dd>"); break;

        default: props.Append("<dt>Location</dt><dd>Unknown</dd>"); break;
        }
        if (!string.IsNullOrEmpty(asset.Status))
        {
            props.Append(string.Format("<dt>{0}</dt><dd>{1}</dd>", "Status", asset.Status));
        }
        if (asset.WarrantyExpiration != null)
        {
            props.Append(string.Format("<dt>{0:d}</dt><dd>{1}</dd>", "Warranty Expiration", (DateTime)asset.WarrantyExpiration));
        }

        if (asset.ProductID != null)
        {
            Product product = Products.GetProduct(loginUser, (int)asset.ProductID);
            if (product != null)
            {
                props.Append(string.Format("<dt>{0}</dt><dd>{1}</dd>", "Product", product.Name));
            }
        }

        if (asset.Location.Trim() == "1")
        {
            AssetAssignmentsView assetAssignments = new AssetAssignmentsView(loginUser);
            assetAssignments.LoadByAssetID(assetID);
            if (assetAssignments.Count > 0)
            {
                props.Append(string.Format("<dt>{0}</dt><dd>{1}</dd>", "Assigned To", assetAssignments[0].NameAssignedTo));
            }
        }


        if (!string.IsNullOrEmpty(asset.Notes))
        {
            props.Append(string.Format("<dt>{0}</dt><dd>{1}</dd>", "Notes", asset.Notes));
        }

        tipProps.InnerHtml = props.ToString();
    }
Пример #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["TicketID"] == null)
        {
            EndResponse("Invalid Ticket");
        }

        int             ticketID = int.Parse(Request["TicketID"]);
        TicketsViewItem ticket   = TicketsView.GetTicketsViewItem(TSAuthentication.GetLoginUser(), ticketID);

        CultureInfo us = new CultureInfo(TSAuthentication.GetLoginUser().CultureInfo.ToString());

        if (ticket == null)
        {
            EndResponse("Invalid Ticket");
        }

        if (ticket.SlaViolationTime < 0)
        {
            tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-bad");
        }
        else if (ticket.SlaWarningTime < 0)
        {
            tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-warning");
        }
        else
        {
            tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-good");
        }


        tipNumber.InnerText = "Ticket #" + ticket.TicketNumber.ToString();
        tipNumber.Attributes.Add("onclick", "top.Ts.MainPage.openTicket(" + ticket.TicketNumber + "); return false;");
        tipName.InnerHtml = ticket.Name;

        StringBuilder props = new StringBuilder();

        AddStringProperty(props, "Assigned To", ticket.UserName, true, "", "openUser", ticket.UserID);
        AddStringProperty(props, "Group", ticket.GroupName, true, null, null, null);
        AddStringProperty(props, "Type", ticket.TicketTypeName, false, null, null, null);
        AddStringProperty(props, "Status", ticket.Status, false, null, null, null);
        AddStringProperty(props, "Severity", ticket.Severity, false, null, null, null);
        AddStringProperty(props, "Customers", GetCustomerLinks(ticketID), false, null, null, null);
        AddStringProperty(props, "Tags", GetTagLinks(ticketID), false, null, null, null);
        if (ticket.DueDate != null)
        {
            DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc((DateTime)ticket.DueDateUtc, TSAuthentication.GetLoginUser().TimeZoneInfo);

            if (ticket.DueDateUtc < DateTime.UtcNow)
            {
                AddStringProperty(props, "Due Date", cstTime.ToString(us.DateTimeFormat.ShortDatePattern + "  HH:mm"), false, null, null, null, true);
            }
            else
            {
                AddStringProperty(props, "Due Date", cstTime.ToString(us.DateTimeFormat.ShortDatePattern + "  HH:mm"), false, null, null, null);
            }
        }
        tipProps.InnerHtml = props.ToString();
    }
Пример #19
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {            //https://host/wiki/wikidocs/{path}
                         //https://app.teamsupport.com/Wiki/WikiDocs/1078/images/Misc%20Graphics/BlueBadge.png


                StringBuilder builder = new StringBuilder();
                bool          flag    = false;
                foreach (string item in context.Request.Url.Segments)
                {
                    string segment = item.ToLower().TrimEnd('/');
                    if (!flag)
                    {
                        if (segment == "wiki")
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        builder.Append(segment);
                        builder.Append("\\");
                    }
                }

                string path = HttpUtility.UrlDecode(builder.ToString().TrimEnd('\\'));
                //string root = SystemSettings.ReadString("FilePath", "");
                FilePaths filePaths = new FilePaths(TSAuthentication.GetLoginUser());
                filePaths.LoadByID(1);
                string   root     = filePaths[0].Value;
                string   fileName = Path.Combine(root, path);
                FileInfo info     = new FileInfo(fileName);
                context.Response.ContentType = DataUtils.MimeTypeFromFileName(fileName);
                context.Response.AddHeader("Content-Length", info.Length.ToString());
                context.Response.WriteFile(fileName);

                //bool allowAttachmentViewing = false;
                //int organizationId = 0;

                ////See above for how the Wiki url is supposed to look like, based on that the following check of the Segments
                //if (context.Request.Url.Segments.Any()
                //	&& context.Request.Url.Segments.Length > 3
                //	&& int.TryParse(context.Request.Url.Segments[3].TrimEnd('/'), out organizationId))
                //{
                //	Organization organization = Organizations.GetOrganization(LoginUser.Anonymous, organizationId);
                //	allowAttachmentViewing = organizationId == TSAuthentication.OrganizationID || organization.AllowUnsecureAttachmentViewing;
                //}

                //if (allowAttachmentViewing)
                //{
                //	string path = HttpUtility.UrlDecode(builder.ToString().TrimEnd('\\'));
                //	string root = SystemSettings.ReadString("FilePath", "");
                //	string fileName = Path.Combine(root, path);
                //	FileInfo info = new FileInfo(fileName);
                //	context.Response.ContentType = DataUtils.MimeTypeFromFileName(fileName);
                //	context.Response.AddHeader("Content-Length", info.Length.ToString());
                //	context.Response.WriteFile(fileName);
                //}
                //else
                //{
                //	context.Response.Write("Unauthorized");
                //	context.Response.ContentType = "text/html";
                //	return;
                //}
            }
            catch (Exception ex)
            {
                context.Response.ContentType = "text/html";
                context.Response.Write(ex.Message + "<br />" + ex.StackTrace);
            }
            context.Response.End();
        }
Пример #20
0
        public void DeleteOrganizationProduct(int organizationProductID, bool bypass = true)
        {
            if (!UserSession.CurrentUser.IsSystemAdmin && bypass)
            {
                return;
            }
            try
            {
                OrganizationProducts organizationProducts = new OrganizationProducts(UserSession.LoginUser);
                organizationProducts.LoadByOrganizationProductID(organizationProductID);
                UserProducts userProducts = new UserProducts(UserSession.LoginUser);
                //userProducts.LoadByOrganizationProductAndVersionID(organizationProducts[0].OrganizationID, "hola", "adios");
                userProducts.LoadByOrganizationProductAndVersionID(organizationProducts[0].OrganizationID, organizationProducts[0].ProductID, organizationProducts[0].ProductVersionID);
                userProducts.DeleteAll();
                userProducts.Save();
                organizationProducts.DeleteFromDB(organizationProductID);

                Product p           = Products.GetProduct(TSAuthentication.GetLoginUser(), organizationProducts[0].ProductID);
                string  description = String.Format("{0} deleted product association to {1} ", TSAuthentication.GetUser(TSAuthentication.GetLoginUser()).FirstLastName, p.Name);
                ActionLogs.AddActionLog(TSAuthentication.GetLoginUser(), ActionLogType.Delete, ReferenceType.Organizations, organizationProducts[0].OrganizationID, description);
            }
            catch (Exception ex)
            {
                DataUtils.LogException(UserSession.LoginUser, ex);
            }
        }
Пример #21
0
        public RadComboBoxItemData[] GetKBTicketByDescription(RadComboBoxContext context)
        {
            Options options = new Options();

            options.TextFlags = TextFlags.dtsoTfRecognizeDates;

            using (SearchJob job = new SearchJob())
            {
                string searchTerm = context["FilterString"].ToString().Trim();
                job.Request            = searchTerm;
                job.FieldWeights       = "TicketNumber: 5000, Name: 1000";
                job.BooleanConditions  = "(OrganizationID::" + TSAuthentication.OrganizationID.ToString() + ") AND (IsKnowledgeBase::True)";
                job.MaxFilesToRetrieve = 25;
                job.AutoStopLimit      = 100000;
                job.TimeoutSeconds     = 10;
                job.SearchFlags        =
                    SearchFlags.dtsSearchSelectMostRecent |
                    SearchFlags.dtsSearchStemming |
                    SearchFlags.dtsSearchDelayDocInfo;

                int num = 0;
                if (!int.TryParse(searchTerm, out num))
                {
                    job.Fuzziness   = 1;
                    job.Request     = job.Request + "*";
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchFuzzy;
                }

                if (searchTerm.ToLower().IndexOf(" and ") < 0 && searchTerm.ToLower().IndexOf(" or ") < 0)
                {
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchTypeAllWords;
                }
                job.IndexesToSearch.Add(DataUtils.GetTicketIndexPath(TSAuthentication.GetLoginUser()));
                job.Execute();
                SearchResults results = job.Results;


                IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context;
                List <RadComboBoxItemData>   list = new List <RadComboBoxItemData>();
                try
                {
                    for (int i = 0; i < results.Count; i++)
                    {
                        results.GetNthDoc(i);
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        itemData.Text  = results.CurrentItem.DisplayName;
                        itemData.Value = results.CurrentItem.Filename + "," + results.CurrentItem.UserFields["TicketNumber"].ToString();
                        list.Add(itemData);
                    }
                }
                catch (Exception)
                {
                }
                if (list.Count < 1)
                {
                    RadComboBoxItemData noData = new RadComboBoxItemData();
                    noData.Text  = "[No tickets to display.]";
                    noData.Value = "-1";
                    list.Add(noData);
                }

                return(list.ToArray());
            }
        }
        public FieldItem[] GetAllFields(ReferenceType refType, int?auxID, bool isReadOnly)
        {
            List <FieldItem> items = new List <FieldItem>();
            //The fields that are synched by 'default' (stock) should not be available in the dropdown list for the mappings because this creates issues with the sync (data being overwritten). Add them to this list in lowercase.
            List <string> excludedFields = new List <string>();
            int           tableID;

            switch (refType)
            {
            case ReferenceType.Organizations: tableID = 6; break;

            case ReferenceType.Tickets: tableID = 10; break;

            case ReferenceType.Users: tableID = 11; break;

            case ReferenceType.Contacts:
                tableID = 12;
                //reference: Integration.vb UpdateContactInfo()
                excludedFields = new List <string>()
                {
                    "name", "title", "email"
                };
                break;

            case ReferenceType.TicketTypes: tableID = 16; break;

            default: return(null);
            }

            TicketTypes ticketTypes = new TicketTypes(TSAuthentication.GetLoginUser());

            ticketTypes.LoadByOrganizationID(TSAuthentication.OrganizationID);

            if (refType == ReferenceType.TicketTypes)
            {
                foreach (TicketType ticketType in ticketTypes)
                {
                    items.Add(new FieldItem(ticketType.TicketTypeID, false, ticketType.Name));
                }
            }
            else
            {
                ReportTableFields fields = new ReportTableFields(TSAuthentication.GetLoginUser());
                fields.LoadByReportTableID(tableID, isReadOnly);

                CustomFields customs = new CustomFields(fields.LoginUser);
                customs.LoadByReferenceType(TSAuthentication.OrganizationID, refType, auxID);

                foreach (ReportTableField field in fields)
                {
                    if (excludedFields.Count == 0 ||
                        (tableID == 12 &&
                         !excludedFields.Contains(field.FieldName.ToLower())))
                    {
                        items.Add(new FieldItem(field.ReportTableFieldID, false, field.FieldName));
                    }
                }

                foreach (CustomField custom in customs)
                {
                    string ticketTypeName = ticketTypes.Where(p => p.TicketTypeID == custom.AuxID).Select(t => t.Name).SingleOrDefault();
                    items.Add(new FieldItem(custom.CustomFieldID,
                                            true,
                                            string.Format("{0}{1}", custom.Name,
                                                          string.IsNullOrEmpty(ticketTypeName) ? "" : " (" + ticketTypeName + ")")));
                }
            }

            return(items.ToArray());
        }
Пример #23
0
        public string GetDateFormatNormal()
        {
            CultureInfo us = new CultureInfo(TSAuthentication.GetLoginUser().CultureInfo.ToString());

            return(us.DateTimeFormat.ShortDatePattern);
        }
Пример #24
0
        private static string AuthenticateUser(int userId, int organizationId, bool storeInfo, bool isBackDoor = false)
        {
            string    result    = string.Empty;
            LoginUser loginUser = new LoginUser(UserSession.ConnectionString, userId, organizationId, null);
            User      user      = Users.GetUser(loginUser, userId);
            string    deviceID  = GetDeviceID();

            TSAuthentication.Authenticate(user, isBackDoor, deviceID);
            if (!isBackDoor)
            {
                LoginAttempts.AddAttempt(loginUser, userId, true, HttpContext.Current.Request.UserHostAddress, HttpContext.Current.Request.Browser, HttpContext.Current.Request.UserAgent, deviceID);
                System.Web.HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser;
                ActionLogs.AddActionLog(loginUser, ActionLogType.Insert, ReferenceType.Users, userId, "Logged in (" + browser.Browser + " " + browser.Version + ")");

                ConfirmBaseData(loginUser);

                if (storeInfo)
                {
                    HttpContext.Current.Response.Cookies["rm"]["a"]    = user.Email;
                    HttpContext.Current.Response.Cookies["rm"]["b"]    = user.OrganizationID.ToString();
                    HttpContext.Current.Response.Cookies["rm"].Expires = DateTime.UtcNow.AddDays(7);
                }
                else
                {
                    HttpContext.Current.Response.Cookies["rm"].Value = "";
                }
            }

            if (user.IsPasswordExpired && !isBackDoor)
            {
                result = string.Format("vcr/1/LoginNewPassword.html?UserID={0}&Token={1}", user.UserID, user.CryptedPassword);
            }
            else
            {
                string rawQueryString = null;

                try
                {
                    rawQueryString = HttpContext.Current.Request.UrlReferrer.Query;
                }
                catch (Exception)
                {
                    //vv
                }

                if (!string.IsNullOrEmpty(rawQueryString))
                {
                    string urlRedirect = GetQueryStringValue(rawQueryString, "ReturnUrl");

                    if (!string.IsNullOrEmpty(urlRedirect) && urlRedirect.Trim().Length > 0)
                    {
                        result = urlRedirect;
                    }
                    else
                    {
                        result = ".";
                    }
                }
                else
                {
                    result = ".";
                }
            }

            return(result);
        }
Пример #25
0
        public string[] SavePassword(int userID, string token, string pw1, string pw2)
        {
            List <string> result = new List <string>();

            if (pw1 != pw2)
            {
                result.Add("Passwords do not match.");
            }
            if (!pw1.Any(char.IsUpper))
            {
                result.Add("At least one uppercase letter is required.");
            }
            if (!pw1.Any(char.IsLower))
            {
                result.Add("At least one lowercase letter is required.");
            }
            if (!pw1.Any(char.IsDigit))
            {
                result.Add("At least one number is required.");
            }
            if (pw1.Length < 8)
            {
                result.Add("Use at least 8 characters.");
            }
            if (pw1.Length > 20)
            {
                result.Add("Use less than 20 characters.");
            }

            if (result.Count < 1)
            {
                User user = null;


                if (TSAuthentication.Ticket != null)
                {
                    user = Users.GetUser(TSAuthentication.GetLoginUser(), TSAuthentication.UserID);
                }
                else
                {
                    user = Users.GetUser(LoginUser.Anonymous, userID);
                    if (user.CryptedPassword != token && user.CryptedPassword != FormsAuthentication.HashPasswordForStoringInConfigFile(token, "MD5"))
                    {
                        user = null;
                    }
                }

                if (user != null)
                {
                    user.CryptedPassword    = FormsAuthentication.HashPasswordForStoringInConfigFile(pw1, "MD5");
                    user.IsPasswordExpired  = false;
                    user.PasswordCreatedUtc = DateTime.UtcNow;
                    user.Collection.Save();
                    EmailPosts.SendChangedTSPassword(LoginUser.Anonymous, user.UserID);
                }
                else
                {
                    result.Add("There was an issue saving your password.  Please try resetting your password again.");
                }
            }

            return(result.ToArray());
        }
Пример #26
0
 public AttachmentProxy[] LoadFiles(int refID, ReferenceType refType)
 {
     return(TeamSupport.Data.Quarantine.WebAppQ.GetAttachmentProxies(refID, refType, TSAuthentication.GetLoginUser()));
 }
Пример #27
0
        public int ReturnAsset(int assetID, string data)
        {
            AssignAssetSave info;

            try
            {
                info = Newtonsoft.Json.JsonConvert.DeserializeObject <AssignAssetSave>(data);
            }
            catch (Exception e)
            {
                return(-1);
            }

            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Asset     o         = Assets.GetAsset(loginUser, assetID);

            //Location 1=assigned (shipped), 2=warehouse, 3=junkyard
            o.Location   = "2";
            o.AssignedTo = null;
            DateTime now = DateTime.UtcNow;

            o.DateModified = now;
            o.ModifierID   = loginUser.UserID;
            o.Collection.Save();

            AssetAssignmentsView assetAssignmentsView = new AssetAssignmentsView(loginUser);

            assetAssignmentsView.LoadByAssetID(assetID);

            AssetHistory     assetHistory     = new AssetHistory(loginUser);
            AssetHistoryItem assetHistoryItem = assetHistory.AddNewAssetHistoryItem();

            assetHistoryItem.AssetID            = assetID;
            assetHistoryItem.OrganizationID     = loginUser.OrganizationID;
            assetHistoryItem.ActionTime         = DateTime.UtcNow;
            assetHistoryItem.ActionDescription  = "Item returned to warehouse on " + info.DateShipped.Month.ToString() + "/" + info.DateShipped.Day.ToString() + "/" + info.DateShipped.Year.ToString();
            assetHistoryItem.ShippedFrom        = assetAssignmentsView[0].ShippedTo;
            assetHistoryItem.ShippedFromRefType = assetAssignmentsView[0].RefType;
            assetHistoryItem.ShippedTo          = loginUser.OrganizationID;
            assetHistoryItem.RefType            = (int)ReferenceType.Organizations;
            assetHistoryItem.TrackingNumber     = info.TrackingNumber;
            assetHistoryItem.ShippingMethod     = info.ShippingMethod;
            assetHistoryItem.ReferenceNum       = info.ReferenceNumber;
            assetHistoryItem.Comments           = info.Comments;

            assetHistoryItem.DateCreated  = now;
            assetHistoryItem.Actor        = loginUser.UserID;
            assetHistoryItem.DateModified = now;
            assetHistoryItem.ModifierID   = loginUser.UserID;

            assetHistory.Save();

            AssetAssignments assetAssignments = new AssetAssignments(loginUser);

            foreach (AssetAssignmentsViewItem assetAssignmentViewItem in assetAssignmentsView)
            {
                assetAssignments.DeleteFromDB(assetAssignmentViewItem.AssetAssignmentsID);
            }

            ActionLogs.AddActionLog(loginUser, ActionLogType.Update, ReferenceType.Assets, assetID, "Returned asset.");

            return(assetID);
        }
Пример #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["TicketID"] == null)
        {
            EndResponse("Invalid Ticket");
        }
        LoginUser loginUser = TSAuthentication.GetLoginUser();
        int       ticketID  = int.Parse(Request["TicketID"]);
        Ticket    ticket    = Tickets.GetTicket(loginUser, ticketID);

        if (ticket == null)
        {
            EndResponse("Invalid Ticket");
        }

        tipNumber.InnerText = "Ticket #" + ticket.TicketNumber.ToString();
        tipNumber.Attributes.Add("onclick", "top.Ts.MainPage.openTicket(" + ticket.TicketNumber + "); return false;");
        tipName.InnerHtml = ticket.Name;

        bool      isStatusPaused = false;
        SlaTicket slaTicket      = SlaTickets.GetSlaTicket(loginUser, ticket.TicketID);

        if (slaTicket != null)
        {
            SlaTrigger slaTrigger = SlaTriggers.GetSlaTrigger(loginUser, slaTicket.SlaTriggerId);

            if (slaTrigger != null)
            {
                isStatusPaused = ticket.IsSlaStatusPaused();
                string slaName = new SlaLevels(TSAuthentication.GetLoginUser()).GetSlaveLevelName(slaTicket.SlaTriggerId);
                wslaName.InnerText = slaName;
            }
            else
            {
                ticket.SlaViolationInitialResponse = null;
                ticket.SlaViolationTimeClosed      = null;
                ticket.SlaViolationLastAction      = null;
                ticket.SlaWarningInitialResponse   = null;
                ticket.SlaWarningTimeClosed        = null;
                ticket.SlaWarningLastAction        = null;
                ticket.Collection.Save();
            }
        }

        if (isStatusPaused)
        {
            wClose.InnerText = "Paused";
            vClose.InnerText = "Paused";
            wLast.InnerText  = "Paused";
            vLast.InnerText  = "Paused";
            wInit.InnerText  = "Paused";
            vInit.InnerText  = "Paused";
            wNext.InnerText  = "Paused";
            vNext.InnerText  = "Paused";
        }
        else
        {
            DateTime?nextViolation = GetUtcDate(ticket, "SlaViolationInitialResponse");
            nextViolation = GetMinDate(loginUser, nextViolation, GetUtcDate(ticket, "SlaViolationLastAction"));
            nextViolation = GetMinDate(loginUser, nextViolation, GetUtcDate(ticket, "SlaViolationTimeClosed"));

            DateTime?nextWarning = GetUtcDate(ticket, "SlaWarningInitialResponse");
            nextWarning = GetMinDate(loginUser, nextWarning, GetUtcDate(ticket, "SlaWarningLastAction"));
            nextWarning = GetMinDate(loginUser, nextWarning, GetUtcDate(ticket, "SlaWarningTimeClosed"));

            if (nextViolation != null && nextViolation < DateTime.UtcNow)
            {
                tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-bad");
            }
            else if (nextWarning != null && nextWarning < DateTime.UtcNow)
            {
                tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-warning");
            }
            else
            {
                tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-good");
            }

            wClose.InnerText = GetDateString(loginUser, GetUtcDate(ticket, "SlaWarningTimeClosed"));
            vClose.InnerText = GetDateString(loginUser, GetUtcDate(ticket, "SlaViolationTimeClosed"));
            wLast.InnerText  = GetDateString(loginUser, GetUtcDate(ticket, "SlaWarningLastAction"));
            vLast.InnerText  = GetDateString(loginUser, GetUtcDate(ticket, "SlaViolationLastAction"));
            wInit.InnerText  = GetDateString(loginUser, GetUtcDate(ticket, "SlaWarningInitialResponse"));
            vInit.InnerText  = GetDateString(loginUser, GetUtcDate(ticket, "SlaViolationInitialResponse"));
            wNext.InnerText  = GetDateString(loginUser, nextWarning);
            vNext.InnerText  = GetDateString(loginUser, nextViolation);
        }
    }
Пример #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string domain = SystemSettings.GetAppUrl();

        if (Request["CustomerID"] == null)
        {
            EndResponse("Invalid Customer");
        }

        int          organizationID = int.Parse(Request["CustomerID"]);
        Organization organization   = Organizations.GetOrganization(TSAuthentication.GetLoginUser(), organizationID);

        if (organization == null)
        {
            EndResponse("Invalid Customer");
        }

        if (organization.OrganizationID != TSAuthentication.OrganizationID && organization.ParentID != TSAuthentication.OrganizationID)
        {
            EndResponse("Invalid Customer");
        }

        tipCompany.InnerText = organization.Name;
        tipCompany.Attributes.Add("onclick", "top.Ts.MainPage.openNewCustomer(" + organizationID.ToString() + "); return false;");

        StringBuilder props = new StringBuilder();

        if (!string.IsNullOrEmpty(organization.Website))
        {
            string website;
            website = organization.Website;
            if (organization.Website.IndexOf("http://") < 0 && organization.Website.IndexOf("https://") < 0)
            {
                website = "http://" + organization.Website;
            }
            props.Append(string.Format("<dt>Website</dt><dd><a target=\"_blank\" href=\"{0}\">{0}</a></dd>", website));
        }

        if (organization.SAExpirationDate != null)
        {
            string css = organization.SAExpirationDate <= DateTime.UtcNow ? "tip-customer-expired" : "";
            props.Append(string.Format("<dt>Service Expiration</dt><dd class=\"{0}\">{1:D}</dd>", css, (DateTime)organization.SAExpirationDate));
        }

        PhoneNumbersView numbers = new PhoneNumbersView(organization.Collection.LoginUser);

        numbers.LoadByID(organization.OrganizationID, ReferenceType.Organizations);

        foreach (PhoneNumbersViewItemProxy number in numbers.GetPhoneNumbersViewItemProxies())
        {
            props.Append(string.Format("<dt>{0}</dt><dd><a href=\"tel:{1}\">{1} {2}</a></dd>", number.PhoneType, number.FormattedPhoneNumber, number.Extension));
        }

        tipProps.InnerHtml = props.ToString();

        TicketsView tickets = new TicketsView(TSAuthentication.GetLoginUser());

        tickets.LoadLatest5Tickets(organizationID);
        StringBuilder recent = new StringBuilder();

        foreach (TicketsViewItem t in tickets)
        {
            if (t.TicketNumber != null && t.Name != null && t.Status != null)
            {
                recent.Append(string.Format("<div><a href='{0}?TicketNumber={1}' target='_blank' onclick='top.Ts.MainPage.openTicket({2}); return false;'><span class='ticket-tip-number'>{3}</span><span class='ticket-tip-status'>{4}</span><span class='ticket-tip-name'>{5}</span></a></div>", domain, t.TicketNumber, t.TicketNumber, t.TicketNumber, t.Status.Length > 17 ? t.Status.Substring(0, 15) + "..." : t.Status, t.Name.Length > 35 ? t.Name.Substring(0, 33) + "..." : t.Name));
            }
        }

        if (recent.Length == 0)
        {
            recent.Append("There are no recent tickets for this organization");
        }

        tipRecent.InnerHtml = recent.ToString();

        //Support Hours
        StringBuilder supportHours = new StringBuilder();

        if (organization.SupportHoursMonth > 0)
        {
            tipTimeSpent.Visible = true;
            double timeSpent = organization.GetTimeSpentMonth(TSAuthentication.GetLoginUser(), organization.OrganizationID) / 60;
            supportHours.AppendFormat("<div class='ui-widget-content ts-separator'></div><div id='tipRecent' runat='server'><dt>Monthly Support Hours</dt><dt>Hours Used</dt><dd>{0}</dd><dt>Hours Remaining</dt>", Math.Round(timeSpent, 2));

            if (timeSpent > organization.SupportHoursMonth)
            {
                supportHours.AppendFormat("<dd class='red'>-{0}</dd>", Math.Round(timeSpent - organization.SupportHoursMonth, 2));
            }
            else
            {
                supportHours.AppendFormat("<dd>{0}</dd>", Math.Round(organization.SupportHoursMonth - timeSpent, 2));
            }
        }


        tipTimeSpent.InnerHtml = supportHours.ToString();

        // Customer Notes
        StringBuilder notesString = new StringBuilder();
        NotesView     notes       = new NotesView(TSAuthentication.GetLoginUser());

        notes.LoadbyCustomerID(organizationID);

        foreach (NotesViewItem t in notes)
        {
            notesString.Append(string.Format("<div><a href='#' target='_blank' onclick='top.Ts.MainPage.openNewCustomerNote({0},{1}); return false;'><span class='ticket-tip-name'>{2}</span></a></div>", t.RefID, t.NoteID, t.Title.Length > 65 ? t.Title.Substring(0, 65) + "..." : t.Title));
        }

        if (notesString.Length == 0)
        {
            notesString.Append("");
        }

        tipNotes.InnerHtml = notesString.ToString();
    }
Пример #30
0
        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);
        }