Пример #1
0
    /*****************************************************
    * - Function name : searchData
    * - Description : 查询目标数据
    * - Variables : void
    *****************************************************/
    public void searchData()
    {
        DataManagerService DMS = new DataManagerService();

        DM.setSummary(DMS.set(DM.getDeal_kind()));
        DM.setRecord(DMS.getRecords(DM.getDeal_kind()));
    }
Пример #2
0
        public override async Task CreateAsync(AuthenticationTokenCreateContext context)
        {
            var clientid = context.Ticket.Properties.Dictionary["as:client_id"];

            if (string.IsNullOrEmpty(clientid))
            {
                return;
            }

            var refreshTokenId = Guid.NewGuid().ToString("n");

            using (DataManagerService _repo = new DataManagerService())
            {
                var client = _repo.FindClient(clientid);
                var refreshTokenLifeTime = context.OwinContext.Get <string>("as:clientRefreshTokenLifeTime");

                var token = new Client_RefreshTokens()
                {
                    RefreshToken = refreshTokenId,
                    ClientId     = client.Id,
                    UserName     = context.Ticket.Identity.Name,
                    IssuedUtc    = DateTime.UtcNow,
                    ExpiresUtc   = DateTime.UtcNow.AddMinutes(Convert.ToDouble(refreshTokenLifeTime))
                };
                context.Ticket.Properties.IssuedUtc  = token.IssuedUtc;
                context.Ticket.Properties.ExpiresUtc = token.ExpiresUtc;
                token.ProtectedTicket = context.SerializeTicket();
                var result = await _repo.AddRefreshToken(token);

                if (result)
                {
                    context.SetToken(refreshTokenId);
                }
            }
        }
        public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        {
            string clientId            = string.Empty;
            string clientSecret        = string.Empty;
            RestfullAPI_Clients client = null;

            if (!context.TryGetBasicCredentials(out clientId, out clientSecret))
            {
                context.TryGetFormCredentials(out clientId, out clientSecret);
            }

            if (context.ClientId == null)
            {
                //Remove the comments from the below line context.SetError, and invalidate context
                //if you want to force sending clientId/secrects once obtain access tokens.
                context.SetError("Invalid_ClientId", "ClientId should be provided!");
                return(Task.FromResult <object>(null));
            }

            using (DataManagerService _repo = new DataManagerService())
            {
                client = _repo.FindClient(context.ClientId);
            }

            if (client == null)
            {
                context.SetError("Invalid_ClientId", string.Format("Client '{0}' is not registered in the system.", context.ClientId));
                return(Task.FromResult <object>(null));
            }

            if (client.ApplicationType == (int)AppTypes.AngularApp)
            {
                if (string.IsNullOrWhiteSpace(clientSecret))
                {
                    context.SetError("invalid_clientId", "Client secret should be sent.");
                    return(Task.FromResult <object>(null));
                }
                else
                {
                    if (client.Secret != clientSecret)
                    {
                        context.SetError("invalid_clientId", "Client secret is invalid.");
                        return(Task.FromResult <object>(null));
                    }
                }
            }

            if (!client.Active)
            {
                context.SetError("Error", "Provided ClientId is currently inactive.");
                return(Task.FromResult <object>(null));
            }
            context.OwinContext.Set <string>("as:clientAllowedOrigin", client.AllowedOrigin);
            context.OwinContext.Set <string>("as:clientRefreshTokenLifeTime", client.RefreshTokenLifeTime.ToString());
            context.Validated();
            return(Task.FromResult <object>(null));
        }
 private void Init()
 {
     DocumentTypesList    = DocumentService.ReadDocumentTypes();
     SelectedDocumentType = DocumentTypesList[0];
     BrokersList          = DataManagerService.TradingInstance().ReadBrokers();
     SelectedBroker       = BrokersList[0];
     CompaniesStorageList = DataManagerService.TradingInstance().GetCompanies();
     SelectedCompany      = CompaniesStorageList[0];
     AuthorsList          = DataManagerService.TradingInstance().ReadTraders();
     SelectedAuthor       = AuthorsList[0];
     DocumentDate         = DateTime.Now;
 }
Пример #5
0
            public WebRtcOutgoingDataStream(DataManagerService dataManagerService, File file)
            {
                _dataManagerService = dataManagerService;
                _file = file;
                _guid = Guid.NewGuid();

                _dataParameters = new DataParameters
                {
                    From   = DataFromType.Outgoing,
                    Time   = DateTime.Now.ToString("HH:mm"),
                    Object = file
                };
                dataManagerService.DataParametersList.Add(_dataParameters);
            }
        public void UploadDocumentParams(Document document)
        {
            this.document = document;

            DocumentName         = document.name;
            DocumentNumber       = document.number;
            SelectedDocumentType = DocumentTypesList.First(d => d.id == document.type);
            SelectedBroker       = BrokersList.First(b => b.ShortName == document.broker);

            if (CompaniesStorageList.Count(c => c.name.ToLower().Contains(document.company.ToLower())) > 0)
            {
                SelectedCompany = CompaniesStorageList.First(c => c.name.ToLower().Contains(document.company.ToLower()));
            }

            SearchCompanyTxt = document.company;
            SelectedAuthor   = AuthorsList.FirstOrDefault(a => a.name == document.author);

            if (SelectedAuthor == null)
            {
                SelectedAuthor = AuthorsList.First(a => a.name.ToLower().Contains("не наз"));
            }

            DocumentDate        = document.createdDate;
            DocumentDescription = document.description;

            if (CurrentPresentation == PresentationEnum.Archive)
            {
                DocumentYear         = document.year;
                DocumentCase         = document.case_;
                DocumentVolume       = document.volume;
                DocumentSerialNumber = document.serialNumber == null ? 0 : (int)document.serialNumber;
            }

            AttachedDocument = DataManagerService.Instanse().ReadDocumentLink(document.id);

            if (!string.IsNullOrEmpty(AttachedDocument))
            {
                IsAttach = true;
            }
        }
Пример #7
0
        public override async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            var allowedOrigin = context.OwinContext.Get <string>("as:clientAllowedOrigin");

            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin });

            string hashedTokenId = context.Token;

            using (DataManagerService _repo = new DataManagerService())
            {
                var refreshToken = _repo.FindRefreshToken(hashedTokenId);
                if (refreshToken != null)
                {
                    //Get protectedTicket from refreshToken class
                    context.DeserializeTicket(refreshToken.ProtectedTicket);
                    var result = await _repo.RemoveRefreshToken(hashedTokenId);
                }
                else
                {
                    context.Response.StatusCode   = 401;
                    context.Response.ReasonPhrase = "Invalid or expired refresh token has been provided.";
                }
            }
        }
Пример #8
0
    /*****************************************************
    * - Function name : ButtonRefresh2_Click
    * - Description : 刷新第二个汇总表
    * - Variables : object sender, EventArgs e
    *****************************************************/
    protected void ButtonRefresh2_Click(object sender, EventArgs e)
    {
        // 查看是否已登录
        if (Session["FinanceDepartmentUsername"] == null)
        {
            Response.Write("<script>alert('请先登录!');</script>");
            return;
        }

        // 实例化一个DataManager服务类
        DataManagerService DMS = new DataManagerService();

        // 查询供应商个数
        int N = DMS.getProviders();

        // 建立数组缓存供应商编号
        string[] pid = new string[N];

        // 读取机型编号
        int    i    = 0;
        string link = string.Format("server={0};User Id={1};password={2};Database={3}",
                                    MDB.getServer(), MDB.getUser(), MDB.getPassword(), MDB.getDatabase());
        MySqlConnection mycon = new MySqlConnection(link);

        mycon.Open();
        string          sql    = string.Format("select pr_number from provider_table");
        MySqlCommand    mycmd  = new MySqlCommand(sql, mycon);
        MySqlDataReader reader = null;

        reader = mycmd.ExecuteReader();
        while (reader.Read())
        {
            pid[i++] = reader[0].ToString();
        }
        reader.Close();
        mycon.Close();

        // 挨个供应商汇总
        for (i = 0; i < N; i++)
        {
            int    amount     = 0; // 数量
            double summary    = 0; // 总价
            int    kinds      = 0; // 商品种类
            int    finished   = 0; // 已完成订单
            int    unfinished = 0; // 未完成订单

            // 统计数量
            amount = DMS.getAmountOf("count(*)", "purchase_detail_table", "where pr_number='" + pid[i] + "'");

            // 统计总价
            summary = DMS.getAmountOf("sum(p_summary)", "purchase_detail_table", "where pr_number='" + pid[i] + "'");

            // 统计已收货数量
            kinds = DMS.getAmountOf("count(*)", "purchase_detail_table", "where pur_received='是' and pr_number='" + pid[i] + "'");

            // 统计未收货数量
            finished = DMS.getAmountOf("count(*)", "purchase_detail_table", "where pur_received='否' and pr_number='" + pid[i] + "'");

            // 统计总单数
            unfinished = DMS.getAmountOf("count(*)", "purchase_detail_table", "where pr_number='" + pid[i] + "'");

            // 查看汇总表是否有相关供应商记录
            int hash = 0;
            hash = DMS.getAmountOf("count(*)", "purchase_summary_provider_table", "where pr_number='" + pid[i] + "'");

            // 存回数据库
            if (hash == 0)
            {
                // 当之前没有该机型信息汇总,插入操作
                if (!DMS.saveProviderSummary(pid[i], amount, summary, kinds, unfinished, finished, "insert"))
                {
                    Response.Write("<script>alert('汇总过程出错[机型:" + pid + "]');</script>");
                }
            }
            else
            {
                // 存在汇总操作时进行更新
                if (!DMS.saveProviderSummary(pid[i], amount, summary, kinds, unfinished, finished, "update"))
                {
                    Response.Write("<script>alert('汇总过程出错[机型:" + pid + "]');</script>");
                }
            }
        }

        // 提示完成
        Response.Write("<script>alert('汇总完成');</script>");

        // 刷新
        Label2.Text = "上一次汇总:" + System.DateTime.Now.ToString();
        bind(SELECT_PROVIDER_SUMMARY, 2);
    }
Пример #9
0
    /*****************************************************
    * - Function name : ButtonRefresh1_Click
    * - Description : 刷新第一个汇总表
    * - Variables : object sender, EventArgs e
    *****************************************************/
    protected void ButtonRefresh1_Click(object sender, EventArgs e)
    {
        // 查看是否已登录
        if (Session["FinanceDepartmentUsername"] == null)
        {
            Response.Write("<script>alert('请先登录!');</script>");
            return;
        }

        // 实例化一个DataManager服务类
        DataManagerService DMS = new DataManagerService();

        // 查询机型个数
        int N = DMS.getPhoneKinds();

        // 建立数组缓存机型编号
        string[] pid = new string[N];

        // 读取机型编号
        int    i    = 0;
        string link = string.Format("server={0};User Id={1};password={2};Database={3}",
                                    MDB.getServer(), MDB.getUser(), MDB.getPassword(), MDB.getDatabase());
        MySqlConnection mycon = new MySqlConnection(link);

        mycon.Open();
        string          sql    = string.Format("select p_id from phone_table");
        MySqlCommand    mycmd  = new MySqlCommand(sql, mycon);
        MySqlDataReader reader = null;

        reader = mycmd.ExecuteReader();
        while (reader.Read())
        {
            pid[i++] = reader[0].ToString();
        }
        reader.Close();
        mycon.Close();

        // 挨个机型汇总
        for (i = 0; i < N; i++)
        {
            int    amount     = 0; // 数量
            double summary    = 0; // 总价
            int    received   = 0; // 已收货
            int    unreceived = 0; // 未收货
            int    purAmount  = 0; // 总单数

            // 统计数量
            amount = DMS.getAmountOf("sum(pur_amount)", "purchase_detail_table", "");

            // 统计总价
            summary = DMS.getAmountOf("sum(p_summary)", "purchase_detail_table", "");

            // 统计已收货数量
            received = DMS.getAmountOf("count(*)", "purchase_detail_table", "where pur_received='是'");

            // 统计未收货数量
            unreceived = DMS.getAmountOf("count(*)", "purchase_detail_table", "where pur_received='否'");

            // 统计总单数
            purAmount = DMS.getAmountOf("count(*)", "purchase_detail_table", "where p_id='" + pid[i] + "'");

            // 查看汇总表是否有机型记录
            int hash = 0;
            hash = DMS.getAmountOf("count(*)", "purchase_summary_good_table", "where p_id='" + pid[i] + "'");

            // 存回数据库
            if (hash == 0)
            {
                // 当之前没有该机型信息汇总,插入操作
                if (!DMS.saveSummary(pid[i], amount, summary, received, unreceived, purAmount, "insert"))
                {
                    Response.Write("<script>alert('汇总过程出错[机型:" + pid + "]');</script>");
                }
            }
            else
            {
                // 存在汇总操作时进行更新
                if (!DMS.saveSummary(pid[i], amount, summary, received, unreceived, purAmount, "update"))
                {
                    Response.Write("<script>alert('汇总过程出错[机型:" + pid + "]');</script>");
                }
            }
        }

        // 提示完成
        Response.Write("<script>alert('汇总完成');</script>");

        // 刷新
        Label1.Text = "上一次汇总:" + System.DateTime.Now.ToString();
        bind(SELECT_GOOD_SUMMARY, 1);
    }
Пример #10
0
    /*****************************************************
    * - Function name : ButtonRefresh_Click
    * - Description : 刷新汇总数据
    * - Variables : object sender, EventArgs e
    *****************************************************/
    protected void ButtonRefresh_Click(object sender, EventArgs e)
    {
        // 查看是否已登录
        if (Session["FinanceDepartmentUsername"] == null)
        {
            Response.Write("<script>alert('请先登录!');</script>");
            return;
        }

        // 实例化一个DataManager服务类
        DataManagerService DMS = new DataManagerService();

        // 查询售出过的机型个数
        int N = DMS.getSaledPhones();

        // 建立缓存数组
        string[] pid = new string[N];

        // 挨个汇总
        int    i   = 0;
        double sum = 0;

        for (i = 0; i < N; i++)
        {
            int    store  = 0;  // 库存量
            int    saled  = 0;  // 售出量
            double earned = 0;  // 总收入

            try
            {
                // 统计库存量
                store = DMS.getAmountOf("count(*)", "phone_detail_table", "where p_id='" + pid[i] + "' and saled='否'");

                // 统计售出量
                saled = DMS.getAmountOf("count(*)", "sale_detail_table", "where p_id='" + pid[i] + "'");

                // 总收入
                earned = DMS.getSaledSummary(pid[i]);
                sum   += earned;

                // 查看汇总表是否有机型记录
                int hash = 0;
                hash = DMS.getAmountOf("count(*)", "sale_summary_table", "where p_id='" + pid[i] + "'");

                // 存回数据库
                if (hash == 0)
                {
                    // 当之前没有该机型信息汇总,插入操作
                    if (!DMS.saveSaledSummary(pid[i], store, saled, earned, "insert"))
                    {
                        Response.Write("<script>alert('汇总过程出错[机型:" + pid[i] + "]');</script>");
                    }
                }
                else
                {
                    // 存在汇总操作时进行更新
                    if (!DMS.saveSaledSummary(pid[i], store, saled, earned, "update"))
                    {
                        Response.Write("<script>alert('汇总过程出错[机型:" + pid[i] + "]');</script>");
                    }
                }
            }
            catch (Exception ex) {
            }
        }


        // 提示完成
        Response.Write("<script>alert('汇总完成');</script>");

        // 修改总收入显示
        LabelSummary.Text = "总收入:" + sum + "元";
    }