Esempio n. 1
0
        private bool Delete()
        {
            bool   boRetValue = false;
            string stIDs      = "";

            foreach (DataListItem item in lstItem.Items)
            {
                HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList");
                if (chkList != null)
                {
                    if (chkList.Checked == true)
                    {
                        stIDs     += chkList.Value + ",";
                        boRetValue = true;
                    }
                }
            }
            if (boRetValue)
            {
                AccountSummaries clsAccountSummary = new AccountSummaries();
                clsAccountSummary.Delete(stIDs.Substring(0, stIDs.Length - 1));
                clsAccountSummary.CommitAndDispose();
            }

            return(boRetValue);
        }
Esempio n. 2
0
        /// <summary>
        /// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
        /// Documentation: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries/list
        /// </summary>
        /// <param name="service">Valid authenticated Analytics Service</param>
        /// <returns>List of Account Summaries resource - https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries</returns>
        public static AccountSummaries AccountSummaryList(AnalyticsService service)
        {
            //List all of the activities in the specified collection for the current user.
            // Documentation: https://developers.google.com/+/api/latest/activities/list

            ManagementResource.AccountSummariesResource.ListRequest list = service.Management.AccountSummaries.List();
            list.MaxResults = 1000;  // Maximum number of Account Summaries to return per request.

            AccountSummaries      feed    = list.Execute();
            List <AccountSummary> allRows = new List <AccountSummary>();

            //// Loop through until we arrive at an empty page
            while (feed.Items != null)
            {
                allRows.AddRange(feed.Items);

                // We will know we are on the last page when the next page token is
                // null.
                // If this is the case, break.
                if (feed.NextLink == null)
                {
                    break;
                }

                // Prepare the next page of results
                list.StartIndex = feed.StartIndex + list.MaxResults;
                // Execute and process the next page request
                feed = list.Execute();
            }

            feed.Items = allRows;

            return(feed);
        }
Esempio n. 3
0
        private void DisplayTransactions()
        {
            var transactionData = _accountService.GetAccountTransactionSummary(SelectedAccount, _applicationState.CurrentWorkPeriod);

            AccountDetails.Clear();
            AccountDetails.AddRange(transactionData.Transactions);
            AccountSummaries.Clear();
            AccountSummaries.AddRange(transactionData.Summaries);

            RaisePropertyChanged(() => TotalBalance);
        }
Esempio n. 4
0
        private void LoadOptions()
        {
            AccountSummaries clsAccountSummary = new AccountSummaries();
            DataClass        clsDataClass      = new DataClass();

            cboAccountSummary.DataTextField  = "AccountSummaryName";
            cboAccountSummary.DataValueField = "AccountSummaryID";
            cboAccountSummary.DataSource     = clsDataClass.DataReaderToDataTable(clsAccountSummary.List("AccountSummaryName", SortOption.Ascending)).DefaultView;
            cboAccountSummary.DataBind();
            cboAccountSummary.SelectedIndex = cboAccountSummary.Items.Count - 1;
            clsAccountSummary.CommitAndDispose();
        }
 /// <summary>
 /// Retrives a full list of Accounts, Web Properties and Views for a Autenticated user.
 /// </summary>
 /// <param name="service">Analtyics service</param>
 /// <returns></returns>
 public static AccountSummaries AccountSummaryList(AnalyticsService service)
 {
     ManagementResource.AccountSummariesResource.ListRequest request = service.Management.AccountSummaries.List();
     try
     {
         AccountSummaries result = request.Execute();
         return(result);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 6
0
        private void LoadRecord()
        {
            Int32                 iID = Convert.ToInt32(Common.Decrypt(Request.QueryString["id"], Session.SessionID));
            AccountSummaries      clsAccountSummary = new AccountSummaries();
            AccountSummaryDetails clsDetails        = clsAccountSummary.Details(iID);

            clsAccountSummary.CommitAndDispose();

            lblAccountSummaryID.Text = clsDetails.AccountSummaryID.ToString();
            cboAccountClassification.SelectedIndex = cboAccountClassification.Items.IndexOf(cboAccountClassification.Items.FindByValue(clsDetails.AccountClassificationDetails.AccountClassificationID.ToString()));
            txtAccountSummaryCode.Text             = clsDetails.AccountSummaryCode;
            txtAccountSummaryName.Text             = clsDetails.AccountSummaryName;
        }
        public async Task <List <AccountSummary> > GetAccounts(string userId)
        {
            ApiUserIdModel userIdModel = new ApiUserIdModel()
            {
                UserId = userId
            };
            string url = $"{_settings.GatewayEndpoint}api/MyAccounts/GetMyAccounts";

            ApiAccountSummaries apiSummary = await _restClient.PostAsync <ApiUserIdModel, ApiAccountSummaries>(url, userIdModel);

            AccountSummaries serviceSummary = _mapper.Map <ApiAccountSummaries, AccountSummaries>(apiSummary);

            return(serviceSummary.Accounts);
        }
        public async Task <List <AccountSummary> > GetMyAccountsSummary(string lowellReference)
        {
            var request = new ApiAccountIdModel()
            {
                AccountId = lowellReference
            };

            var url = $"{_settings.GatewayEndpoint}api/MyAccounts/GetMyAccountsSummary";

            ApiAccountSummaries apiAccount = await _restClient.PostAsync <ApiAccountIdModel, ApiAccountSummaries>(url, request);

            AccountSummaries accountSummaries = _mapper.Map <ApiAccountSummaries, AccountSummaries>(apiAccount);

            return(accountSummaries.Accounts);
        }
Esempio n. 9
0
        private void SaveRecord()
        {
            AccountSummaryDetails clsDetails = new AccountSummaryDetails();

            clsDetails.AccountSummaryID             = Convert.ToInt16(lblAccountSummaryID.Text);
            clsDetails.AccountClassificationDetails = new AccountClassificationDetails
            {
                AccountClassificationID = Convert.ToInt16(cboAccountClassification.SelectedItem.Value)
            };
            clsDetails.AccountSummaryCode = txtAccountSummaryCode.Text;
            clsDetails.AccountSummaryName = txtAccountSummaryName.Text;

            AccountSummaries clsAccountSummary = new AccountSummaries();

            clsAccountSummary.Update(clsDetails);
            clsAccountSummary.CommitAndDispose();
        }
Esempio n. 10
0
        private Int32 SaveRecord()
        {
            AccountSummaryDetails clsDetails = new AccountSummaryDetails();

            clsDetails.AccountClassificationDetails = new AccountClassificationDetails
            {
                AccountClassificationID = Convert.ToInt16(cboAccountClassification.SelectedItem.Value)
            };
            clsDetails.AccountSummaryCode = txtAccountSummaryCode.Text;
            clsDetails.AccountSummaryName = txtAccountSummaryName.Text;

            AccountSummaries clsAccountSummary = new AccountSummaries();
            Int32            id = clsAccountSummary.Insert(clsDetails);

            clsAccountSummary.CommitAndDispose();

            return(id);
        }
        private void DisplayTransactions()
        {
            AccountDetails.Clear();
            AccountSummaries.Clear();

            var transactions = Dao.Query(GetCurrentRange(x => x.AccountId == SelectedAccount.Id)).OrderBy(x => x.Date);

            AccountDetails.AddRange(transactions.Select(x => new AccountDetailViewModel(x, SelectedAccount)));

            if (FilterType != Resources.All)
            {
                var pastDebit    = Dao.Sum(x => x.Debit, GetPastRange(x => x.AccountId == SelectedAccount.Id));
                var pastCredit   = Dao.Sum(x => x.Credit, GetPastRange(x => x.AccountId == SelectedAccount.Id));
                var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(x => x.AccountId == SelectedAccount.Id));
                if (pastCredit > 0 || pastDebit > 0)
                {
                    AccountSummaries.Add(new AccountSummaryViewModel(Resources.Total, AccountDetails.Sum(x => x.Debit), AccountDetails.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailViewModel(new AccountTransactionValue
                    {
                        Name     = Resources.PastTransactions,
                        Credit   = pastCredit,
                        Debit    = pastDebit,
                        Exchange = pastExchange
                    }, SelectedAccount);
                    AccountDetails.Insert(0, detailValue);
                    detailValue.IsBold = true;
                }
            }

            AccountSummaries.Add(new AccountSummaryViewModel(Resources.GrandTotal, AccountDetails.Sum(x => x.Debit), AccountDetails.Sum(x => x.Credit)));

            for (var i = 0; i < AccountDetails.Count; i++)
            {
                AccountDetails[i].Balance = (AccountDetails[i].Debit - AccountDetails[i].Credit);
                if (i > 0)
                {
                    (AccountDetails[i].Balance) += (AccountDetails[i - 1].Balance);
                }
            }

            RaisePropertyChanged(() => TotalBalance);
        }
        private void DisplayTransactions()
        {
            if (FilterType != Resources.Default)
            {
                var dateRange = _accountService.GetDateRange(FilterType, _applicationState.CurrentWorkPeriod);
                Start = dateRange.Start;
                End   = dateRange.End;
            }

            var transactionData = _accountService.GetAccountTransactionSummary(SelectedAccount, _applicationState.CurrentWorkPeriod, Start, End);

            Start = transactionData.Start;
            End   = transactionData.End != transactionData.Start ? transactionData.End : null;

            AccountDetails.Clear();
            AccountDetails.AddRange(transactionData.Transactions);
            AccountSummaries.Clear();
            AccountSummaries.AddRange(transactionData.Summaries);

            RaisePropertyChanged(() => TotalBalance);
        }
Esempio n. 13
0
        private void LoadAccountSummaryList()
        {
            AccountSummaries clsAccountSummary = new AccountSummaries();
            DataClass        clsDataClass      = new DataClass();

            string SortField = "AccountSummaryCode";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            if (Request.QueryString["Search"] == null)
            {
                PageData.DataSource = clsDataClass.DataReaderToDataTable(clsAccountSummary.List(SortField, sortoption)).DefaultView;
            }
            else
            {
                string SearchKey = Common.Decrypt((string)Request.QueryString["search"], Session.SessionID);
                PageData.DataSource = clsDataClass.DataReaderToDataTable(clsAccountSummary.Search(SearchKey, SortField, sortoption)).DefaultView;
            }

            clsAccountSummary.CommitAndDispose();

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = iPageSize;
            try
            {
                PageData.CurrentPageIndex    = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstAccountSummary.DataSource = PageData;
                lstAccountSummary.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex    = 1;
                lstAccountSummary.DataSource = PageData;
                lstAccountSummary.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int i = 0; i < PageData.PageCount; i++)
            {
                int iValue = i + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == i)
                {
                    cboCurrentPage.Items[i].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[i].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }
Esempio n. 14
0
        // GET: Analysis 可使用三種權限取得analysis資訊
        public ActionResult Index()
        {

            //自己service 版本
            //將自己的驗證json檔放到app_data
            string[] scopes = new string[] { AnalyticsService.Scope.AnalyticsReadonly }; // view and manage your Google Analytics data

            var keyFilePath = HttpContext.Server.MapPath("~/App_Data/6c7504a5781f.p12");    // Downloaded from https://console.developers.google.com
            var serviceAccountEmail = "*****@*****.**";  // found https://console.developers.google.com

            //loading the Key file
            var certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable);
            var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
            {
                Scopes = scopes
            }.FromCertificate(certificate));

            //需要授權的版本
            //string[] scopes = new string[] {
            //    AnalyticsService.Scope.Analytics,               // view and manage your Google Analytics data
            //    AnalyticsService.Scope.AnalyticsEdit,           // Edit and manage Google Analytics Account
            //    AnalyticsService.Scope.AnalyticsManageUsers,    // Edit and manage Google Analytics Users
            //    AnalyticsService.Scope.AnalyticsReadonly};      // View Google Analytics Data

            //var clientId = "385316856762-m2rkgg70628r406pqbv9qvkb9s345c2f.apps.googleusercontent.com";      // From https://console.developers.google.com
            //var clientSecret = "mhZFbaucc40BdXushfG6KIC9";          // From https://console.developers.google.com
            //                                   // here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
            //var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
            //{
            //    ClientId = clientId,
            //    ClientSecret = clientSecret
            //},
            //scopes,
            //Environment.UserName,
            //CancellationToken.None,
            //new FileDataStore("Daimto.GoogleAnalytics.Auth.Store")).Result;

            var service = new AnalyticsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "Analytics API Sample",
            });


            //AnalyticsService service = new AnalyticsService(new BaseClientService.Initializer()
            //{
            //    ApiKey = "AIzaSyD8BPsvUGtt_OMt_DTAvEkcnyYyAIrVQPQ",  // from https://console.developers.google.com (Public API access)
            //    ApplicationName = "Analytics API Sample",
            //});

            ManagementResource.AccountSummariesResource.ListRequest list = service.Management.AccountSummaries.List();
            list.MaxResults = 1000;  // Maximum number of Account Summaries to return per request. 

            AccountSummaries feed = list.Execute();
            List<AccountSummary> allRows = new List<AccountSummary>();

            //// Loop through until we arrive at an empty page
            while (feed.Items != null)
            {
                allRows.AddRange(feed.Items);

                // We will know we are on the last page when the next page token is
                // null.
                // If this is the case, break.
                if (feed.NextLink == null)
                {
                    break;
                }

                // Prepare the next page of results             
                list.StartIndex = feed.StartIndex + list.MaxResults;
                // Execute and process the next page request
                feed = list.Execute();

            }

            feed.Items = allRows;  // feed.Items not contains all of the rows even if there are more then 1000 


            //Get account summary and display them.
            foreach (AccountSummary account in feed.Items)
            {
                // Account
                Console.WriteLine("Account: " + account.Name + "(" + account.Id + ")");
                foreach (WebPropertySummary wp in account.WebProperties)
                {
                    // Web Properties within that account
                    Console.WriteLine("\tWeb Property: " + wp.Name + "(" + wp.Id + ")");

                    //Don't forget to check its not null. Believe it or not it could be.
                    if (wp.Profiles != null)
                    {
                        foreach (ProfileSummary profile in wp.Profiles)
                        {
                            // Profiles with in that web property.
                            Console.WriteLine("\t\tProfile: " + profile.Name + "(" + profile.Id + ")");
                        }
                    }
                }
            }

            return View();
        }
Esempio n. 15
0
        public async Task GetAccountsTest()
        {
            string userId = Guid.NewGuid().ToString();
            string uri    = $"{_portalSettings.GatewayEndpoint}api/MyAccounts/GetMyAccounts";

            ApiAccountSummaries apiModel = new ApiAccountSummaries()
            {
                Accounts = new List <ApiAccountSummary>()
                {
                    new ApiAccountSummary()
                    {
                        AccountReference = "11111111"
                    },
                    new ApiAccountSummary()
                    {
                        AccountReference = "22222222"
                    },
                    new ApiAccountSummary()
                    {
                        AccountReference = "33333333"
                    },
                    new ApiAccountSummary()
                    {
                        AccountReference = "44444444"
                    },
                    new ApiAccountSummary()
                    {
                        AccountReference = "55555555"
                    },
                }
            };

            AccountSummaries serviceModel = new AccountSummaries()
            {
                Accounts = new List <AccountSummary>()
                {
                    new AccountSummary()
                    {
                        AccountReference = "11111111"
                    },
                    new AccountSummary()
                    {
                        AccountReference = "22222222"
                    },
                    new AccountSummary()
                    {
                        AccountReference = "33333333"
                    },
                    new AccountSummary()
                    {
                        AccountReference = "44444444"
                    },
                    new AccountSummary()
                    {
                        AccountReference = "55555555"
                    },
                }
            };

            List <AccountSummary> expected = new List <AccountSummary>()
            {
                new AccountSummary()
                {
                    AccountReference = "11111111"
                },
                new AccountSummary()
                {
                    AccountReference = "22222222"
                },
                new AccountSummary()
                {
                    AccountReference = "33333333"
                },
                new AccountSummary()
                {
                    AccountReference = "44444444"
                },
                new AccountSummary()
                {
                    AccountReference = "55555555"
                },
            };

            this._restClient.Setup(x => x.PostAsync <ApiUserIdModel, ApiAccountSummaries>(uri, It.Is <ApiUserIdModel>(m => m.UserId == userId))).Returns(Task.FromResult(apiModel));
            this._mapper.Setup(x => x.Map <ApiAccountSummaries, AccountSummaries>(apiModel)).Returns(serviceModel);

            List <AccountSummary> result = await _service.GetAccounts(userId);

            string expectedStr = JsonConvert.SerializeObject(expected);
            string resultStr   = JsonConvert.SerializeObject(result);

            Assert.AreEqual(expectedStr, resultStr);
        }
Esempio n. 16
0
        public static void readAction(GAAutentication Autentication, string Action)
        {
            string[] vars = Action.Split(' ');

            switch (vars[0].ToLower())
            {
            case "menu":
                Program.ListMenu(Autentication);
                break;

            case "accounts":
                Console.WriteLine("");
                Console.WriteLine("Listing Accounts:  ");
                Accounts myAccounts = GAManagement.Accountlist(Autentication.service);
                if (myAccounts == null)
                {
                    Console.WriteLine("User does not have access to any Accounts");
                }
                else
                {
                    foreach (Account accnt in myAccounts.Items)
                    {
                        Console.WriteLine(accnt.Name + " - " + accnt.Id);
                    }
                }
                Program.PromptDoNext(Autentication);
                break;

            case "segments":
                Console.WriteLine("");
                Console.WriteLine("Listing Segments:  ");
                Segments mySegments = GAManagement.SegmentList(Autentication.service);
                foreach (Segment sgmnt in mySegments.Items)
                {
                    Console.WriteLine(sgmnt.Name + " - " + sgmnt.SegmentId);
                }

                Program.PromptDoNext(Autentication);
                break;

            case "wp":
                if (vars.Count() < 2)
                {
                    Console.WriteLine("ERROR: WebProperty list requires an account id: " + vars[0]);
                    Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("");
                    Console.WriteLine("Listing WebProperties for account:  " + vars[1]);
                    Webproperties myWebproperties = GAManagement.Propertieslist(Autentication.service, vars[1]);

                    if (myWebproperties == null)
                    {
                        Console.WriteLine("User does not have access to any Web Properties for:");
                        Console.WriteLine("     Account id:      " + vars[1]);
                    }
                    else
                    {
                        foreach (Webproperty wbprprty in myWebproperties.Items)
                        {
                            Console.WriteLine(wbprprty.Name + " - " + wbprprty.Id);
                        }
                    }
                    Program.PromptDoNext(Autentication);
                }

                break;

            case "views":

                if (vars.Count() < 3)
                {
                    Console.WriteLine("ERROR: View list requires an account id, and a webproperty id: ");
                    Program.PromptDoNext(Autentication);
                }
                else
                {
                    Console.WriteLine("");
                    Console.WriteLine("Listing WebProperties for account:  " + vars[1]);
                    Profiles myViews = GAManagement.ProfilesList(Autentication.service, vars[1], vars[2]);


                    if (myViews == null)
                    {
                        Console.WriteLine("User does not have access to any Views for:");
                        Console.WriteLine("     Account id:      " + vars[1]);
                        Console.WriteLine("     Web Property id: " + vars[2]);
                    }
                    else
                    {
                        foreach (Profile vws in myViews.Items)
                        {
                            Console.WriteLine(vws.Name + " - " + vws.Id);
                        }
                    }
                    Program.PromptDoNext(Autentication);
                }

                break;

            case "goals":

                if (vars.Count() < 4)
                {
                    Console.WriteLine("ERROR: Goal list requires an account id, webproperty id, and a profileid: ");
                    Program.PromptDoNext(Autentication);
                }
                else
                {
                    Console.WriteLine("");
                    Console.WriteLine("Listing Goals for account:  " + vars[1]);
                    Goals myGoals = GAManagement.GoalList(Autentication.service, vars[1], vars[2], vars[3]);


                    if (myGoals.Items == null)
                    {
                        Console.WriteLine("User does not have access to any Goals for:");
                        Console.WriteLine("    Account id:      " + vars[1]);
                        Console.WriteLine("    Web Property id: " + vars[2]);
                        Console.WriteLine("    Profile id:      " + vars[3]);
                    }
                    else
                    {
                        foreach (Goal gl in myGoals.Items)
                        {
                            Console.WriteLine(gl.Name + " - " + gl.Id);
                        }
                    }
                    Program.PromptDoNext(Autentication);
                }

                break;

            case "summary":

                Console.WriteLine("");
                Console.WriteLine("Listing Account Summary:  ");
                AccountSummaries mySummary = GAManagement.AccountSummaryList(Autentication.service);

                if (mySummary == null)
                {
                    Console.WriteLine("User does not have access to any Accounts");
                }
                else
                {
                    foreach (AccountSummary sum in mySummary.Items)
                    {
                        Console.WriteLine("Account name: " + sum.Name + " - " + sum.Id);
                        foreach (WebPropertySummary wpsum in sum.WebProperties)
                        {
                            Console.WriteLine("     Web Property: " + wpsum.Name + " - " + wpsum.Id);

                            if (wpsum.Profiles != null)
                            {
                                foreach (ProfileSummary pfsum in wpsum.Profiles)
                                {
                                    Console.WriteLine("          Profiles: " + pfsum.Name + " - " + pfsum.Id);
                                }
                            }
                            else
                            {
                                Console.WriteLine("          No Profiles");
                            }
                        }
                    }
                }
                Program.PromptDoNext(Autentication);
                break;

            default:
                Console.WriteLine("unknown option: " + vars[0]);
                Program.PromptDoNext(Autentication);
                break;
            }
        }