Exemplo n.º 1
0
        public static BlackBerryUserStatsResult GetBlackBerryUserStats(int itemId, int accountId)
        {
            BlackBerryUserStatsResult res = TaskManager.StartResultTask <BlackBerryUserStatsResult>("BLACKBERRY",
                                                                                                    "DELETE_BLACKBERRY_USER");
            BlackBerry blackBerry;

            try
            {
                blackBerry = GetBlackBerryProxy(itemId);
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, BlackBerryErrorsCodes.CANNOT_GET_BLACKBERRY_PROXY, ex);
                return(res);
            }

            OrganizationUser user;

            try
            {
                user = OrganizationController.GetAccount(itemId, accountId);

                if (user == null)
                {
                    throw new ApplicationException(
                              string.Format("User is null. ItemId={0}, AccountId={1}", itemId,
                                            accountId));
                }
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, ErrorCodes.CANNOT_GET_ACCOUNT, ex);
                return(res);
            }

            try
            {
                BlackBerryUserStatsResult tmp = blackBerry.GetBlackBerryUserStats(user.PrimaryEmailAddress);
                res.ErrorCodes.AddRange(tmp.ErrorCodes);
                if (!tmp.IsSuccess)
                {
                    TaskManager.CompleteResultTask(res, BlackBerryErrorsCodes.CANNOT_GET_USER_STATS);
                    return(res);
                }

                res.Value = tmp.Value;
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, BlackBerryErrorsCodes.CANNOT_GET_USER_STATS, ex);
                return(res);
            }

            TaskManager.CompleteResultTask();
            return(res);
        }
Exemplo n.º 2
0
        public static ResultObject SetActivationPasswordWithExpirationTime(int itemId, int accountId, string password, int time)
        {
            BlackBerryUserStatsResult res = TaskManager.StartResultTask <BlackBerryUserStatsResult>("BLACKBERRY",
                                                                                                    "DELETE_BLACKBERRY_USER");
            BlackBerry blackBerry;

            try
            {
                blackBerry = GetBlackBerryProxy(itemId);
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, BlackBerryErrorsCodes.CANNOT_GET_BLACKBERRY_PROXY, ex);
                return(res);
            }

            OrganizationUser user;

            try
            {
                user = OrganizationController.GetAccount(itemId, accountId);

                if (user == null)
                {
                    throw new ApplicationException(
                              string.Format("User is null. ItemId={0}, AccountId={1}", itemId,
                                            accountId));
                }
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, ErrorCodes.CANNOT_GET_ACCOUNT, ex);
                return(res);
            }

            try
            {
                ResultObject tmp = blackBerry.SetActivationPasswordWithExpirationTime(user.PrimaryEmailAddress, password, time);
                res.ErrorCodes.AddRange(tmp.ErrorCodes);
                if (!tmp.IsSuccess)
                {
                    TaskManager.CompleteResultTask(res, BlackBerryErrorsCodes.CANNOT_SET_ACTIVATION_PASSWORD);
                    return(res);
                }
            }
            catch (Exception ex)
            {
                TaskManager.CompleteResultTask(res, BlackBerryErrorsCodes.CANNOT_SET_ACTIVATION_PASSWORD, ex);
                return(res);
            }

            TaskManager.CompleteResultTask();
            return(res);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BlackBerryUserStatsResult stats = ES.Services.BlackBerry.GetBlackBerryUserStats(PanelRequest.ItemID, PanelRequest.AccountID);

            if (stats.IsSuccess)
            {
                dvStats.Visible    = true;
                dvStats.DataSource = stats.Value;
                dvStats.DataBind();
            }
            else
            {
                dvStats.Visible = false;
                messageBox.ShowWarningMessage(CANNOT_GET_BLACKBERRY_STATS);
            }
        }
Exemplo n.º 4
0
        internal override BlackBerryUserStatsResult GetBlackBerryUserStatsInternal(string primaryEmailAddress)
        {
            BlackBerryUserStatsResult res =
                HostedSolutionLog.StartLog <BlackBerryUserStatsResult>("GetBlackBerry5UserStatsInternal");

            string[] keys;
            string[] values;

            ResultObject tempRes = GetBlackBerryUserData(primaryEmailAddress, out keys, out values);

            res.ErrorCodes.AddRange(tempRes.ErrorCodes);
            if (!res.IsSuccess)
            {
                HostedSolutionLog.EndLog("GetBlackBerry5UserStatsInternal", res);
                return(res);
            }

            try
            {
                List <BlackBerryStatsItem> items = new List <BlackBerryStatsItem>();

                int[] inds = new int[] { 3, 4, 5, 7, 8, 10, 11, 12, 13, 14, 15, 25 };

                foreach (int i in inds)
                {
                    if (keys.Length > i && values.Length > i)
                    {
                        items.Add(new BlackBerryStatsItem()
                        {
                            Name = keys[i], Value = values[i]
                        });
                    }
                }


                res.Value = items;
            }
            catch (Exception ex)
            {
                HostedSolutionLog.EndLog("GetBlackBerry5UserStatsInternal", res, BlackBerryErrorsCodes.CANNOT_POPULATE_STATS, ex);
                return(res);
            }

            HostedSolutionLog.EndLog("GetBlackBerry5UserStatsInternal");
            return(res);
        }
Exemplo n.º 5
0
        protected override ResultObject GetBlackBerryUserData(string primaryEmailAddress, out string[] keys, out string[] values)
        {
            BlackBerryUserStatsResult res =
                HostedSolutionLog.StartLog <BlackBerryUserStatsResult>("GetBlackBerry5UserData");


            string file = Path.Combine(UtilityPath, "besuseradminclient.exe");

            if (!File.Exists(file))
            {
                HostedSolutionLog.EndLog("GetBlackBerry5UserData", res, BlackBerryErrorsCodes.FILE_PATH_IS_INVALID);
                keys   = null;
                values = null;

                return(res);
            }
            string arguments = string.Format(" -username {0} -password {1} -stats -u {2} -b {3} -n {4}",
                                             User,
                                             Password,
                                             primaryEmailAddress,
                                             EnterpriseServer,
                                             EnterpriseServerFQDN);

            string output;
            string error;

            try
            {
                int exitCode = Execute(file, arguments, out output, out error);
                if (exitCode == 0)
                {
                    Log.WriteInfo(output);
                }
                else
                {
                    throw new ApplicationException(
                              string.Format("Exit code is not 0. {0}, ExitCode = {1}", error, exitCode));
                }
            }
            catch (Exception ex)
            {
                HostedSolutionLog.EndLog("GetBlackBerry5UserData", res, BlackBerryErrorsCodes.CANNOT_EXECUTE_COMMAND, ex);
                keys   = null;
                values = null;
                return(res);
            }

            try
            {
                string[] data  = output.Split('\n');
                Regex    regex = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");

                int startRow = 0;

                if (data.Length > 0)
                {
                    for (startRow = data.Length - 1; startRow >= 0; startRow--)
                    {
                        if (!string.IsNullOrEmpty(data[startRow]) && !string.IsNullOrEmpty(data[startRow].Trim()))
                        {
                            break;
                        }
                    }
                }


                keys   = regex.Split(data[startRow - 1]);
                values = regex.Split(data[startRow]);
            }
            catch (Exception ex)
            {
                HostedSolutionLog.EndLog("GetBlackBerry5UserData", res, BlackBerryErrorsCodes.CANNOT_SPLIT_STATS, ex);
                keys   = null;
                values = null;
                return(res);
            }

            HostedSolutionLog.EndLog("GetBlackBerry5UserData");
            return(res);
        }
Exemplo n.º 6
0
        protected virtual ResultObject GetBlackBerryUserData(string primaryEmailAddress, out string [] keys, out string [] values)
        {
            BlackBerryUserStatsResult res =
                HostedSolutionLog.StartLog <BlackBerryUserStatsResult>("GetBlackBerryUserData");


            string file = Path.Combine(UtilityPath, "besuseradminclient.exe");

            if (!File.Exists(file))
            {
                HostedSolutionLog.EndLog("GetBlackBerryUserData", res, BlackBerryErrorsCodes.FILE_PATH_IS_INVALID);
                keys   = null;
                values = null;

                return(res);
            }
            string arguments = string.Format("-stats -u {0} -p {1} -b {2} -n {3}",
                                             primaryEmailAddress,
                                             Password,
                                             EnterpriseServer,
                                             AdministrationToolService);

            string output;
            string error;

            try
            {
                int exitCode = Execute(file, arguments, out output, out error);
                if (exitCode == 0)
                {
                    Log.WriteInfo(output);
                }
                else
                {
                    throw new ApplicationException(
                              string.Format("Exit code is not 0. {0}, ExitCode = {1}", error, exitCode));
                }
            }
            catch (Exception ex)
            {
                HostedSolutionLog.EndLog("GetBlackBerryUserData", res, BlackBerryErrorsCodes.CANNOT_EXECUTE_COMMAND, ex);
                keys   = null;
                values = null;
                return(res);
            }

            try
            {
                string[] data  = output.Split('\n');
                Regex    regex = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");

                keys   = regex.Split(data[0]);
                values = regex.Split(data[1]);
            }
            catch (Exception ex)
            {
                HostedSolutionLog.EndLog("GetBlackBerryUserData", res, BlackBerryErrorsCodes.CANNOT_SPLIT_STATS, ex);
                keys   = null;
                values = null;
                return(res);
            }

            HostedSolutionLog.EndLog("GetBlackBerryUserData");
            return(res);
        }