示例#1
0
        public static List <FBProject> GetFBProjects(Instance_Config instanceConfig, int page, int limit, int clientID, int staffID)
        {
            List <FBProject> arrProjects;
            string           result = FreshBooks.GetProjectsList(instanceConfig, out arrProjects, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret, limit, page, clientID, staffID);

            if (result == "ok")
            {
                return(arrProjects);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
示例#2
0
        public static FBClient CreateClient(ApiUser User, Instance_Config instanceConfig, int accountID)
        {
            FBClient fbClient;
            string   result = FreshBooks.CreateClient(User.OrganizationId, User.DepartmentId, instanceConfig, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret, accountID, out fbClient);

            if (result == "ok")
            {
                return(fbClient);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
示例#3
0
        public static QBEmployee CreateEmployee(ApiUser User, Instance_Config instanceConfig, int user_id)
        {
            QBEmployee qbEmployee;
            string     result = QuickBooks.CreateEmployee(User.OrganizationId, User.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey,
                                                          instanceConfig.QBoAuthSecret, user_id, out qbEmployee);

            if (result == "ok")
            {
                return(qbEmployee);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
示例#4
0
        public static QBCustomer CreateCustomer(ApiUser User, Instance_Config instanceConfig, int account_id)
        {
            QBCustomer qbCustomer;
            string     result = QuickBooks.CreateCustomer(User.OrganizationId, User.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey,
                                                          instanceConfig.QBoAuthSecret, account_id, out qbCustomer);

            if (result == "ok")
            {
                return(qbCustomer);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
示例#5
0
        public static List <FBTask> GetFBTasks(Instance_Config instanceConfig, int page, int limit, int projectID)
        {
            List <FBTask> arrTasks;
            string        result = bigWebApps.bigWebDesk.Data.FreshBooks.GetTasksList(instanceConfig, out arrTasks, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret,
                                                                                      limit, page, projectID);

            if (result == "ok")
            {
                return(arrTasks);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
示例#6
0
        public static FBTask CreateTask(ApiUser User, Instance_Config instanceConfig, int taskTypeID, int fbProjectID)
        {
            FBTask fbTask;
            string result = FreshBooks.CreateTask(User.OrganizationId, User.DepartmentId, instanceConfig, instanceConfig.FBoAuthConsumerKey,
                                                  instanceConfig.FBoAuthSecret, taskTypeID, fbProjectID, out fbTask);

            if (result == "ok")
            {
                return(fbTask);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
示例#7
0
        public static FBTask FindFBTask(Instance_Config instanceConfig, string name)
        {
            FBTask arrTask;
            string result = FreshBooks.FindTask(instanceConfig, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret,
                                                name, out arrTask);

            if (result == "ok")
            {
                if (arrTask == null)
                {
                    arrTask = new FBTask(0, "");
                }
                return(arrTask);
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, Utils.ClearString(result));
            }
        }
示例#8
0
文件: Assets.cs 项目: evgeniynet/API5
        public static Asset GetAsset(ApiUser hdUser, int id)
        {
            Instance_Config config = new Instance_Config(hdUser);

            AssetsConfig assetsconfig = config.Assets;

            DataRow dr = GetAssetRow(hdUser, id);

            Asset asset = new Asset(dr);
            List <KeyValuePair <string, string> > unique_fields = new List <KeyValuePair <string, string> >();

            for (int i = 1; i < 8; i++)
            {
                if (!string.IsNullOrEmpty(assetsconfig.Captions[i - 1]))
                {
                    unique_fields.Add(new KeyValuePair <string, string>(assetsconfig.Captions[i - 1] + " (Unique" + i + ")", dr.GetString("Unique" + i)));
                }
            }
            asset.UniqueFields = unique_fields.ToList();
            return(asset);
        }
示例#9
0
 public static void DeleteFreshBooksCategory(ApiUser hdUser, Instance_Config instanceConfig, string categoryID)
 {
     FreshBooks.DeleteAndUnlinkCategory(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret, categoryID);
 }
示例#10
0
 public static void DeleteQuickBooksEmployee(ApiUser hdUser, Instance_Config instanceConfig, int userID)
 {
     QuickBooks.DeleteAndUnlinkEmployee(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, userID);
 }
示例#11
0
 public static void DeleteQuickBooksExpense(ApiUser hdUser, Instance_Config instanceConfig, string expenseID)
 {
     QuickBooks.DeleteAndUnlinkExpense(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, expenseID);
 }
示例#12
0
        public static Account_Details GetAccountDetails(ApiUser user, int accountId, bool is_with_statistics)
        {
            Models.Account_Details account = null;
            Instance_Config        config  = new Instance_Config(user);
            DataRow accountDetails         = bigWebApps.bigWebDesk.Data.Accounts.SelectOne(user.DepartmentId, accountId, user.OrganizationId);

            if (accountDetails != null)
            {
                account = new Account_Details(accountDetails);
            }
            else if (accountId == -1 || accountId == 0)
            {
                DataTable table = new DataTable();
                table.Columns.Add("Name", typeof(string));
                table.Columns.Add("Id", typeof(int));

                account      = new Account_Details(table.NewRow());
                account.Name = user.DepartmentName;
                account.Id   = -1;
            }
            else
            {
                throw new HttpError(HttpStatusCode.NotFound, "Incorrect account id");
            }
            if (config.LocationTracking)
            {
                account.Locations = new Locations(bigWebApps.bigWebDesk.Data.Accounts.SelectLocations(user.OrganizationId, user.DepartmentId, accountId)).List;
            }

            /*
             * if (account.ClientContractID.HasValue)
             * {
             *  DataRow row = bigWebApps.bigWebDesk.Data.Accounts.SelectAccountContract(user.OrganizationId, user.DepartmentId, account.ClientContractID.Value);
             *  account.contract_renewal_date = Functions.DisplayDate((DateTime)row["EndDate"], 0, false);
             * }
             */

            account.Primary_Contact = Address.GetAccountAddress(user.OrganizationId, user.DepartmentId, accountId);

            account.Users = AccountUsers.GetAccountUsers(user.OrganizationId, user.DepartmentId, accountId);

            //Assets
            if (config.AssetTracking)
            {
                account.Assets = Models.Assets.AccountAssets(user, config.Assets, accountId);
            }

            if (config.ProjectTracking)
            {
                account.Projects = AccountProjects.GetAccountProjects(user.OrganizationId, user.DepartmentId, accountId);
            }

            //Custom fields
            if (accountId > 0)
            {
                List <KeyValuePair <string, string> > customFields = new List <KeyValuePair <string, string> >();
                for (int i = 1; i < 16; i++)
                {
                    if ((bool)accountDetails["btCust" + i.ToString() + "On"])
                    {
                        customFields.Add(new KeyValuePair <string, string>(accountDetails["vchCust" + i.ToString() + "Cap"].ToString(), accountDetails["vchCust" + i.ToString()].ToString()));
                    }
                }

                if (!accountDetails.IsNull("btDateCust1On") && (bool)accountDetails["btDateCust1On"])
                {
                    customFields.Add(new KeyValuePair <string, string>(accountDetails["vchDateCust1Cap"].ToString(), accountDetails.IsNull("dtCust1") ? "" : Functions.DisplayDate((DateTime)accountDetails["dtCust1"], user.TimeZoneOffset, false)));
                }
                if (!accountDetails.IsNull("btDateCust2On") && (bool)accountDetails["btDateCust2On"])
                {
                    customFields.Add(new KeyValuePair <string, string>(accountDetails["vchDateCust2Cap"].ToString(), accountDetails.IsNull("dtCust2") ? "" : Functions.DisplayDate((DateTime)accountDetails["dtCust2"], user.TimeZoneOffset, false)));
                }

                account.CustomFields = customFields.ToList();
            }

            account.Files = Models.Files.GetFiles(user.InstanceId, accountId, user.OrganizationId, "accounts-accounts-files");

            string accountLogoUrl = "";

            if (accountId > 0)
            {
                accountLogoUrl = Models.Files.GetAccountLogoUrl(user.InstanceId, accountId, user.OrganizationId);
            }
            else
            {
                accountLogoUrl = string.IsNullOrEmpty(user.InstanceLogoImageUrl) ? user.OrganizationLogoImageUrl : user.InstanceLogoImageUrl;
            }

            account.Logo = accountLogoUrl;

            if (is_with_statistics)
            {
                account.account_statistics = AccountStats.GetStatistics(accountId, user.OrganizationId, user.DepartmentId, user.UserId);
            }

            return(account);
        }
示例#13
0
 public static string CreateTimeEntry(ApiUser hdUser, Instance_Config instanceConfig, int staffID, int projectID, int taskID,
                                      decimal hours, string notes, DateTime date, int timeLogID, bool isProjectLog, int timeEntryID)
 {
     return(FreshBooks.CreateTimeEntry(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret,
                                       staffID, projectID, taskID, hours, notes, date, timeLogID, isProjectLog, timeEntryID));
 }
示例#14
0
 public static void DeleteFreshBooksExpense(ApiUser hdUser, Instance_Config instanceConfig, int accountID)
 {
     FreshBooks.DeleteAndUnlinkClient(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret, accountID);
 }
示例#15
0
 public static void DeleteQuickBooksCustomer(ApiUser hdUser, Instance_Config instanceConfig, int account_id)
 {
     QuickBooks.DeleteAndUnlinkCustomer(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, account_id);
 }
示例#16
0
 public static string CreateExpense(ApiUser hdUser, Instance_Config instanceConfig, int staffID, int projectID, int categoryID, int clientID, decimal amount,
                                    string vendor, string notes, DateTime date, string expenseID, int fbExpenseID)
 {
     return(FreshBooks.CreateExpense(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret,
                                     staffID, projectID, categoryID, clientID, amount, vendor, notes, date, expenseID, fbExpenseID));
 }
示例#17
0
 public static void DeleteFreshBooksProject(ApiUser hdUser, Instance_Config instanceConfig, int projectID)
 {
     FreshBooks.DeleteAndUnlinkProject(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret, projectID);
 }
示例#18
0
 public static void DeleteQuickBooksTravel(ApiUser hdUser, Instance_Config instanceConfig, int travel_id)
 {
     QuickBooks.DeleteAndUnlinkTravel(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, travel_id);
 }
示例#19
0
        public static List <Account> SearchAccounts(ApiUser user, string search, bool is_with_statistics, bool is_open_tickets, bool is_watch_info, bool is_locations_info, int page = 0, int limit = 25)
        {
            bigWebApps.bigWebDesk.Data.Accounts.ActiveStatus _status = bigWebApps.bigWebDesk.Data.Accounts.ActiveStatus.Active;

            // _status = Data.Accounts.ActiveStatus.Inactive;

            Instance_Config config = new Instance_Config(user);

            bigWebApps.bigWebDesk.Data.Accounts.Filter _filter = new bigWebApps.bigWebDesk.Data.Accounts.Filter(_status, search);
            if (!config.LocationTracking)
            {
                _filter.FilterLocation = !config.LocationTracking;
            }

            /*if (m_TktId != 0)
             * {
             * if (Request.QueryString["vw"] == "0") _filter.UserId = User.lngUId;
             * else if (Request.QueryString["vw"] == "2") _filter.UserId = 0;
             * else _filter.UserId = m_Tkt.TechnicianId;
             * }
             * else
             * {
             * _filter.UserId = User.lngUId;
             * _filter.SupportGroupId = User.lngGSpGrp;
             * }
             * _filter.SaveToSession();
             */
            var m_ColSet = new bigWebApps.bigWebDesk.Data.Accounts.ColumnsSetting(user.DepartmentId, user.UserId, user.OrganizationId);

            if (!user.IsTechAdmin)
            {
                m_ColSet.ListViewMode = bigWebApps.bigWebDesk.Data.Accounts.ViewMode.MyAccounts;
                _filter.UserId        = user.UserId;
            }
            if (!is_open_tickets && m_ColSet.BrowseColumnsCount > 1)
            {
                m_ColSet.SetBrowseColumn(1, bigWebApps.bigWebDesk.Data.Accounts.BrowseColumn.Updated);
            }

            limit = limit <= 0 ? 25 : limit;
            page  = page < 0 ? 0 : page;
            string pager = string.Format(" OFFSET ({0} * {1}) ROWS FETCH NEXT {1} ROWS ONLY ", page, limit);

            Accounts _userAccountsList = new Accounts(bigWebApps.bigWebDesk.Data.Accounts.SelectFiltered(user.OrganizationId, user.DepartmentId, "", user.UserId, m_ColSet, _filter, false, pager));
            var      userAccountsList  = _userAccountsList.List;
            int      account           = user.AccountId <= 0 ? -1 : user.AccountId;
            var      fix = userAccountsList.FirstOrDefault(acc => acc.Id == account);

            if (fix != null)
            {
                fix.name = user.DepartmentName;
            }

            List <TaskType> task_types = null;

            if (is_watch_info || is_locations_info)
            {
                task_types = Models.TaskTypes.SelectAccountTaskTypes(user.OrganizationId, user.DepartmentId, user.UserId, userAccountsList.First().Id.Value);
            }

            foreach (var userAccount in userAccountsList)
            {
                if (is_locations_info)
                {
                    if (config.ProjectTracking)
                    {
                        userAccount.projects = Projects.GetProjects(user.OrganizationId, user.DepartmentId, userAccount.Id.Value, user.IsTechAdmin ? 0 : user.UserId, config.AccountManager, false);
                    }
                    if (config.LocationTracking)
                    {
                        userAccount.locations = Locations.GetAccountLocations(user.OrganizationId, user.DepartmentId, userAccount.Id.Value, 0, "", true);
                    }
                    userAccount.task_types = task_types;
                }
                else if (is_watch_info)
                {
                    if (config.ProjectTracking)
                    {
                        userAccount.projects = Projects.GetProjects(user.OrganizationId, user.DepartmentId, userAccount.Id.Value, user.IsTechAdmin ? 0 : user.UserId, config.AccountManager, false);
                    }
                    //foreach (var projectAccount in userAccount.projects) {
                    //	projectAccount.task_types = Models.TaskTypes.SelectProjectTaskTypes (user.OrganizationId, user.DepartmentId, user.UserId, projectAccount.Id);
                    //}
                    userAccount.task_types = task_types;
                }
                else if (is_with_statistics)
                {
                    userAccount.account_statistics = AccountStats.GetStatistics(userAccount.Id.Value, user.OrganizationId, user.DepartmentId, user.UserId);
                }
                else if (is_open_tickets)
                {
                    int open         = userAccount.Row.Get <int> ("OpenTickets");
                    var account_stat = new AccountStats();
                    account_stat.ticket_counts     = AccountTicketCount.GetAccountStat(open);
                    userAccount.account_statistics = account_stat;
                }
            }

            return(userAccountsList);
        }
示例#20
0
 public static void DeleteQuickBooksTimeActivity(ApiUser hdUser, Instance_Config instanceConfig, int timeLogID, bool isProjectLog)
 {
     QuickBooks.DeleteAndUnlinkTimeActivity(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, timeLogID, isProjectLog);
 }
示例#21
0
        public static List <WorklistTicket> GetTickets(ApiUser hdUser, Guid OrgId, int DeptId, int UserId, string status, string role, string Class, string account, string location, string project, bool IsTechAdmin, bool IsUseWorkDaysTimer, string sort_order, string sort_by, string search = "", int page = 0, int limit = 25, DateTime?start_date = null, DateTime?end_date = null)
        {
            string tkts = "";

            if (!string.IsNullOrWhiteSpace(search) && Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Integration.Azure.Search.Enabled)
            {
                tkts = bigWebApps.bigWebDesk.Data.Tickets.SearchTicketsInAzure(hdUser.OrganizationId, hdUser.DepartmentId, false, search);

                /*if (string.IsNullOrEmpty(tkts))
                 * {
                 *  return new List<WorklistTicket>();
                 * //tkts = "0";
                 * }
                 */
            }
            Worklist.QueryFilter _qFilter = new Worklist.QueryFilter();
            if (string.IsNullOrEmpty(role) || role.ToLower() == "all")
            {
                role = "notset";
            }
            if (!string.IsNullOrEmpty(status))
            {
                string originalstatus = status;
                status = status.Replace(",", "").Replace("_", "").ToLowerInvariant();
                Worklist.TicketStatusMode ticketStatusMode;
                if (Enum.TryParse <Worklist.TicketStatusMode>(status, true, out ticketStatusMode))
                {
                    _qFilter.TicketStatus = ticketStatusMode;
                }
                else
                {
                    if (originalstatus.Contains(","))
                    {
                        string statuses     = originalstatus.Replace("_", "").ToLowerInvariant();
                        string status_query = string.Empty;
                        foreach (string _status in statuses.Split(','))
                        {
                            switch (_status.ToLower())
                            {
                            case "closed":
                                status_query += " OR tkt.status='Closed' ";
                                break;

                            case "open":
                                status_query += " OR tkt.status='Open' ";
                                break;

                            case "onhold":
                                status_query += " OR tkt.status='On Hold' ";
                                break;

                            case "partsonorder":
                                status_query += " OR tkt.status='Parts On Order' ";
                                break;

                            case "waiting":
                                status_query += " OR (tkt.status='Open' AND tkt.WaitingDate is not null) ";
                                break;
                            }
                        }

                        if (!string.IsNullOrEmpty(status_query))
                        {
                            _qFilter.SQLWhere = " AND (" + status_query.Substring(3) + ")";
                        }
                    }
                    else
                    {
                        switch (status)
                        {
                        case "waiting": _qFilter.TicketStatus = Worklist.TicketStatusMode.OpenWaitingOnResponse;
                            break;

                        case "newmessages":
                            switch (role)
                            {
                            case "tech": _qFilter.ShowNewMessages = Worklist.NewMessagesMode.User; break;

                            case "user": _qFilter.ShowNewMessages = Worklist.NewMessagesMode.Technician; break;

                            default: _qFilter.ShowNewMessages = Worklist.NewMessagesMode.UserAndTech; break;
                            }
                            ;
                            break;

                        case "closed": _qFilter.TicketStatus = Worklist.TicketStatusMode.Close;
                            break;
                        }
                    }
                }
            }

            Worklist.SortMode ticketSortMode;
            if (Enum.TryParse <Worklist.SortMode>(role, true, out ticketSortMode))
            {
                _qFilter.Sort = ticketSortMode;
            }
            else
            {
                switch (role)
                {
                case "tech": _qFilter.Sort = Worklist.SortMode.MyTickets; break;

                case "user": _qFilter.Sort = Worklist.SortMode.MyTicketsAsUser; break;

                case "alt_tech": _qFilter.Sort = Worklist.SortMode.MyTicketsAsAlternateTech; break;
                }
            }
            int queueId;

            if (int.TryParse(Class, out queueId))
            {
                _qFilter.TechnicianId = queueId;
                Class = "";
            }
            if (!string.IsNullOrEmpty(Class))
            {
                int class_id = 0;
                if (int.TryParse(Class, out class_id))
                {
                    if (class_id > 0)
                    {
                        _qFilter.SQLWhere += " AND tkt.class_id = " + class_id;
                    }
                }
                else
                {
                    _qFilter.SQLWhere += " AND dbo.fxGetFullClassName(" + DeptId.ToString() + ", tkt.class_id) like '%" + Class + "%'";
                }
            }
            if (!string.IsNullOrEmpty(account))
            {
                int account_id = 0;
                if (int.TryParse(account, out account_id))
                {
                    if (account_id != 0)
                    {
                        _qFilter.AccountId = account_id;
                    }
                }
                else
                {
                    _qFilter.SQLWhere += " AND (ISNULL(acct.vchName, CASE WHEN ISNULL(tkt.btNoAccount, 0) = 0 THEN co.company_name ELSE '' END) like '%" + account + "%')";
                }
            }
            if (!string.IsNullOrEmpty(project))
            {
                int project_id = 0;
                if (int.TryParse(project, out project_id))
                {
                    if (project_id != 0)
                    {
                        _qFilter.ProjectID = project_id;
                    }
                }
                else
                {
                    _qFilter.SQLWhere += " AND dbo.fxGetFullProjectName(" + DeptId.ToString() + ", tkt.ProjectID) like '%" + project + "%'";
                }
            }
            if (!string.IsNullOrEmpty(location))
            {
                int location_id = 0;
                if (int.TryParse(location, out location_id))
                {
                    if (location_id != 0)
                    {
                        _qFilter.AccountLocationId = location_id;
                    }
                }
                else
                {
                    _qFilter.SQLWhere += " AND dbo.fxGetUserLocationName(" + DeptId.ToString() + ", tkt.LocationId) like '%" + location + "%'";
                }
            }

            if (start_date.HasValue)
            {
                if (start_date.Value.TimeOfDay.TotalSeconds > 0)
                {
                    start_date = start_date.Value.Date;
                }
                _qFilter.SQLWhere += string.Format(" AND tkt.CreateTime >= '{0}'", start_date.Value.ToString("yyyy-MM-dd hh:mm:ss"));
            }
            if (end_date.HasValue)
            {
                if (end_date.Value.TimeOfDay.TotalSeconds == 0)
                {
                    end_date = end_date.Value.Date.AddDays(1).AddSeconds(-1);
                }
                _qFilter.SQLWhere += string.Format(" AND tkt.CreateTime <= '{0}'", end_date.Value.ToString("yyyy-MM-dd hh:mm:ss"));
            }

            Instance_Config config = new Instance_Config(hdUser);

            if (!string.IsNullOrWhiteSpace(search))
            {
                string _query = "";
                if (!string.IsNullOrEmpty(tkts))
                {
                    _query += " AND (tkt.Id IN (" + tkts + ")";
                }
                else
                {
                    _query           += " AND (tkt.subject LIKE '%" + search + "%' OR ISNULL(tlip2.CountFoundInitPost, 0) > 0 OR tkt.note LIKE '%" + search + "%' OR ISNULL(tlcn2.CountFoundClosureNotes, 0) > 0";
                    _qFilter.SQLJoin += " LEFT OUTER JOIN (SELECT TId, COUNT(*) AS CountFoundInitPost FROM TicketLogs WHERE DId=" + hdUser.DepartmentId + " AND vchType = 'Initial Post' AND vchNote LIKE '%" + search + "%' GROUP BY TId) tlip2 ON tlip2.TId = tkt.Id "
                                        + "LEFT OUTER JOIN (SELECT TId, COUNT(*) AS CountFoundClosureNotes FROM TicketLogs WHERE DId=" + hdUser.DepartmentId + " AND vchType = 'Closed' AND vchNote LIKE '%" + search + "%' GROUP BY TId) tlcn2 ON tlcn2.TId = tkt.Id ";
                }

                if (config.SerialNumber)
                {
                    _query += " OR tkt.SerialNumber LIKE '%" + search + "%'";
                }
                _query            += ")";
                _qFilter.SQLWhere += _query;
            }

            limit = limit <= 0 ? 25 : limit;
            page  = page < 0 ? 0 : page;
            string pager = string.Format(" OFFSET ({0} * {1}) ROWS FETCH NEXT {1} ROWS ONLY ", page, limit);

            _qFilter.PageIndex = page;

            if (sort_by != "days_old")
            {
                _qFilter.SortColumnIndex    = 0;
                _qFilter.IsSortColumnDesc   = "desc" == sort_order;
                _qFilter.SortColumnSQLAlias = sort_by ?? "CreateTime";
            }


            bigWebApps.bigWebDesk.UserAuth userAuth = new bigWebApps.bigWebDesk.UserAuth
            {
                Role            = hdUser.Role,
                OrgID           = hdUser.OrganizationId,
                lngDId          = hdUser.DepartmentId,
                tintTicketTimer = hdUser.tintTicketTimer,
                lngUId          = hdUser.UserId,
                InstanceID      = hdUser.InstanceId
                                  //ee.strGSUserRootLocationId
                                  //ee.sintGSUserType
            };
            //Use global filters
            bool useGlobalFilters       = hdUser.Role != bigWebApps.bigWebDesk.UserAuth.UserRole.Administrator && (role == "notset" || role == "tech");
            bool limitToAssignedTickets = (useGlobalFilters) ? GlobalFilters.IsFilterEnabled(hdUser.OrganizationId, hdUser.DepartmentId, UserId, GlobalFilters.FilterState.LimitToAssignedTickets) : false;

            if (limitToAssignedTickets)
            {
                _qFilter.SQLWhere += " AND tkt.technician_id=" + UserId.ToString();
                _qFilter.SQLJoin  += " LEFT OUTER JOIN TicketAssignment AS TA2 ON TA2.DepartmentId=" + hdUser.DepartmentId + " AND TA2.TicketId = tkt.Id AND TA2.UserId = " + UserId + " AND TA2.AssignmentType = " + ((int)Ticket.TicketAssignmentType.Technician).ToString() + " AND TA2.IsPrimary = 0 AND TA2.StopDate IS NULL";
            }

            //Use global filters
            if (useGlobalFilters)
            {
                _qFilter.SQLWhere += GlobalFilters.GlobalFiltersSqlWhere(userAuth, config, "tkt.", "tlj2.", "SupGroupID", null);
            }
            //(limitToAssignedTickets ? "TA2." : null

            //bigWebApps.bigWebDesk.Data.Worklist.Filter m_Filter = new bigWebApps.bigWebDesk.Data.Worklist.Filter(tt.DepartmentId, tt.UserId, true, tt.OrganizationId);
            //bool shortMode = true;
            //Worklist.ColumnsSetting m_ColSet = shortMode ? new Worklist.ColumnsSetting("0,2", tt.DepartmentId, tt.UserId, config.AccountManager && config.LocationTracking, tt.OrganizationId) :
            //    new Worklist.ColumnsSetting(tt.DepartmentId, tt.UserId, config.AccountManager && config.LocationTracking, tt.OrganizationId);
            //if sherpadesk
            //DataTable dt = Worklist.SelectTicketsByFilter(ee, config, m_ColSet, m_Filter, _qFilter, false, FilesSources.AzureFileService, limit);

            DataTable dt = Worklist.SelectTicketsByFilter(OrgId, DeptId, UserId, _qFilter, IsTechAdmin, pager);

            if (dt != null)
            {
                //var config = new Instance_Config()
                dt.Columns.Add(new DataColumn("DaysOldSort", typeof(long)));
                dt.Columns.Add(new DataColumn("DaysOlds", typeof(string)));
                foreach (DataRow dr in dt.Rows)
                {
                    int min = Utils.GetDaysOldInMinutes(OrgId, DeptId, IsUseWorkDaysTimer, dr.GetString("Status"), dr.Get <DateTime>("CreateTime"), dr.Get <DateTime?>("ClosedTime") ?? DateTime.UtcNow);
                    dr["DaysOldSort"] = min;
                    dr["DaysOlds"]    = bigWebApps.bigWebDesk.Functions.DisplayDateDuration(min, config.BusinessDayLength, true);
                }
            }
            IEnumerable <WorklistTicket> wrklisttickets = new WorklistTickets(dt);

            return(wrklisttickets.ToList());
        }
示例#22
0
 public static void DeleteFreshBooksTask(ApiUser hdUser, Instance_Config instanceConfig, int taskTypeID)
 {
     FreshBooks.DeleteAndUnlinkTask(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.FBoAuthConsumerKey, instanceConfig.FBoAuthSecret, taskTypeID);
 }
示例#23
0
 public static void DeleteQuickBooksService(ApiUser hdUser, Instance_Config instanceConfig, int task_type_id)
 {
     QuickBooks.DeleteAndUnlinkService(hdUser.OrganizationId, hdUser.DepartmentId, instanceConfig, instanceConfig.QBoAuthConsumerKey, instanceConfig.QBoAuthSecret, task_type_id);
 }