/// <summary>
 /// 绑定DropDownList的方法
 /// </summary>
 /// <param name="dropDownList"></param>
 /// <param name="configTypeName"></param>
 /// <param name="tipString"></param>
 protected void DropDownListDataBind(DropDownList dropDownList, ConfigTypeName configTypeName, string tipString)
 {
     try
     {
         //DataTable dt = new ConfigureBLL().GetConfig(configTypeName.ToString());
         DataTable dtConfig = dtConfig = new ConfigureBLL().GetConfig();
         DataTable dtNew    = dtConfig.Clone();
         DataRow[] drArray  = dtConfig.Select("configtypename='" + configTypeName + "'");
         for (int i = 0; i < drArray.Length; i++)
         {
             dtNew.ImportRow(drArray[i]);
         }
         dropDownList.DataSource     = dtNew;
         dropDownList.DataTextField  = "configvalue";
         dropDownList.DataValueField = "configkey";
         dropDownList.DataBind();
         dtNew = null;
         if (configTypeName == ConfigTypeName.奖励与处罚类型)
         {
             dropDownList.Items.Insert(0, new ListItem(tipString, string.Empty));
         }
     }
     catch (Exception ex)
     {
         LogHelper.WriteLine(ex.Message + ex.StackTrace);
     }
 }
Exemple #2
0
        protected void LoadData()
        {
            DataTable dtShops = new ConfigureBLL().GetShopKeys();

            gvShop.DataSource = dtShops;
            gvShop.DataBind();
        }
Exemple #3
0
        protected void LoadOperateType()
        {
            DataTable dt = new ConfigureBLL().GetConfig("日志记录操作类型");

            ddlOperateType.DataSource     = dt;
            ddlOperateType.DataTextField  = "configvalue";
            ddlOperateType.DataValueField = "configkey";
            ddlOperateType.DataBind();
            ddlOperateType.Items.Insert(0, new ListItem("--", string.Empty));
        }
 private void UpdateConfigCache()
 {
     System.Data.DataTable dtConfig = null;
     if (Cache["dtConfig"] != null)
     {
         HttpRuntime.Cache.Remove("dtConfig");
     }
     dtConfig = new ConfigureBLL().GetConfig();
     Cache.Insert("dtConfig", dtConfig, null, DateTime.Now.AddHours(1.5), System.Web.Caching.Cache.NoSlidingExpiration);
 }
        protected void LoadData()
        {
            DataTable dtShop = new ConfigureBLL().GetShopKeys();
            string    shopId = Request.QueryString["shopid"];

            if (!string.IsNullOrEmpty(shopId))
            {
                txtShopId.Text      = shopId;
                txtShopId.Enabled   = false;
                txtShopName.Text    = dtShop.AsEnumerable().Where(item => item.Field <string>("shopid") == shopId).Select(t => t.Field <string>("configValue")).FirstOrDefault();
                txtShopName.Enabled = false;
                txtAccessKey.Text   = dtShop.AsEnumerable().Where(item => item.Field <string>("shopid") == shopId).Select(t => t.Field <string>("AccessKey")).FirstOrDefault();
                txtSecretKey.Text   = dtShop.AsEnumerable().Where(item => item.Field <string>("shopid") == shopId).Select(t => t.Field <string>("SecretKey")).FirstOrDefault();
            }
        }
Exemple #6
0
 protected void gvShop_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Disable")
     {
         string ID   = e.CommandArgument.ToString();
         bool   flag = new ConfigureBLL().DisableShop(ID);
         if (flag)
         {
             LoadData();
             ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "alert('更新成功!');", true);
             return;
         }
         ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "alert('更新失败!');", true);
         return;
     }
 }
Exemple #7
0
 /// <summary>
 /// 集中绑定DropDownList
 /// </summary>
 public void DropDownListDataBind()
 {
     System.Data.DataTable dtConfig = null;
     if (Cache["dtConfig"] == null)
     {
         dtConfig = new ConfigureBLL().GetConfig();
         Cache.Insert("dtConfig", dtConfig, null, DateTime.Now.AddHours(1.5), System.Web.Caching.Cache.NoSlidingExpiration);
     }
     dtConfig = (DataTable)Cache["dtConfig"];
     DropDownListDataBind(ddlShop, dtConfig, ConfigTypeName.店铺编号名称, "-请选择-");
     DropDownListDataBind(ddlStructureForm, dtConfig, ConfigTypeName.建筑类型, "-请选择-");
     DropDownListDataBind(ddlBuildingType, dtConfig, ConfigTypeName.结构类型, "-请选择-");
     DropDownListProvinceBind();
     DropDownListDataBind(ddlTransactionStatus, dtConfig, ConfigTypeName.交易状态, "-请选择-");
     DropDownListDataBind(ddlModelingSoftware, dtConfig, ConfigTypeName.建模软件, "-请选择-");
 }
        /// <summary>
        /// 获取淘宝订单信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetTaobaoOrderInfo(HttpContext context)
        {
            StringBuilder sbJsonResult = new StringBuilder();
            DataTable     dtShop       = new ConfigureBLL().GetShopKeys();
            string        AccessKey    = string.Empty; //AK
            string        SecretKey    = string.Empty; //SK
            string        tid          = context.Request.Params["tid"].Trim();

            if (dtShop != null && dtShop.Rows.Count > 0)
            {
                for (int i = 0; i < dtShop.Rows.Count; i++)
                {
                    AccessKey = dtShop.Rows[i]["accessKey"]?.ToString();
                    SecretKey = dtShop.Rows[i]["SecretKey"]?.ToString();
                    if (!string.IsNullOrWhiteSpace(AccessKey) && !string.IsNullOrWhiteSpace(SecretKey))
                    {
                        SignatureEncryption SE = new SignatureEncryption();
                        Get    G         = new Get();
                        string requestId = Guid.NewGuid().ToString();                       //请求的UUID,每个请求都要求使用不同的UUID,服务端会拦截UUID重复的请求
                        string timeStamp = DateTime.UtcNow.ToString("yyyyMMddHHmmss+0000"); //当前的时间戳,UTC时间,带时区,例如(20160619160421+0000)

                        Dictionary <string, string> Parameter = new Dictionary <string, string>();
                        Parameter.Add("fields", "tid,pay_time,total_fee, payment,received_payment, buyer_nick,shop_pick");             //  type,status,payment,orders,promotion_details,,
                        Parameter.Add("tid", tid);                                                                                     // close 416046851854648869             有效的:293410926387038206    ,  274050855711040792

                        string PostUrl           = SE.ProduceUrl("trade", "TradeFullinfoGetRequest", Parameter);                       //生成Url链接  Step1: 构造 HTTP请求:设置访问地址 URL
                        string HeadField         = SE.HeadField(timeStamp, requestId, PostUrl);                                        //生成头域字符串        Step2: 添加必须的头域
                        string WaitForSignString = SE.GetStringA();                                                                    //生成待签名字符串   Step3: 将上述请求转换为"待签名字符串 A"
                        string Sign = SE.GetSignString(AccessKey, requestId, WaitForSignString);                                       //签名

                        string Authorization  = SE.Ty(AccessKey, Sign);                                                                //添加鉴权头域 Authorization  这个是没用的 错误的 鉴权头域
                        string Authorization2 = SE.GetAuthorizationHeader("GET", PostUrl, timeStamp, requestId, AccessKey, SecretKey); //添加鉴权头域 Authorization2    正确的鉴权头域
                        string GetPutDBInfo   = G.GetResponseData(PostUrl, timeStamp, requestId, Authorization2);
                        if (GetPutDBInfo.Contains("trade_fullinfo_get_response"))
                        {
                            sbJsonResult.Append(GetPutDBInfo.Replace("}}", ",\"shopid\":\"" + dtShop.Rows[i]["shopId"].ToString() + "\"}}"));
                            break;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(sbJsonResult.ToString()))
            {
                return(sbJsonResult.ToString());
            }
            return(sbJsonResult.Append("{\"success\":\"false\"}").ToString());
        }
        /// <summary>
        /// 获取所有的交易状态值
        /// </summary>
        /// <returns></returns>
        private string GetAllTransactionStatus()
        {
            StringBuilder sbJsonResult        = new StringBuilder();
            ConfigureBLL  cBll                = new ConfigureBLL();
            DataTable     dtTransactionStatus = cBll.GetConfig(ConfigTypeName.交易状态.ToString());

            if (dtTransactionStatus != null && dtTransactionStatus.Rows.Count > 0)
            {
                sbJsonResult.Append("[");
                for (int i = 0; i < dtTransactionStatus.Rows.Count; i++)
                {
                    sbJsonResult.Append("{\"key\":\"" + dtTransactionStatus.Rows[i]["configKey"].ToString() + "\",\"value\":\"" + dtTransactionStatus.Rows[i]["configValue"].ToString() + "\"}");
                    if (i != dtTransactionStatus.Rows.Count - 1)
                    {
                        sbJsonResult.Append(",");
                    }
                }
                sbJsonResult.Append("]");
            }
            return(sbJsonResult.ToString());
        }
 protected void LoadData()
 {
     try
     {
         string fileHistoryId = Request.QueryString["fileHistoryId"];
         if (string.IsNullOrEmpty(fileHistoryId))
         {
             return;
         }
         string    prjId      = fhBll.GetProjectIdById(fileHistoryId);
         Project   prj        = new ProjectBLL().GetModel(prjId);
         DataTable dtShopName = new ConfigureBLL().GetConfig("店铺编号名称");
         lblShopName.Text = dtShopName.AsEnumerable().Where(item => item.Field <string>("configKey") == prj.SHOP).Select(item2 => item2.Field <string>("configValue")).FirstOrDefault();
     }
     catch (Exception ex)
     {
         LogHelper.WriteLine("文件分享初始化异常," + ex.Message + ex.StackTrace);
         lblShopName.Text      = "Shop 初始化异常";
         lblShopName.ForeColor = System.Drawing.Color.Red;
     }
 }
Exemple #11
0
 /// <summary>
 /// 绑定省份
 /// </summary>
 private void DropDownListProvinceBind()
 {
     try
     {
         DataTable dt = null;
         if (Cache["dtProvince"] == null)
         {
             dt = new ConfigureBLL().GetProvince();
             Cache.Insert("dtProvince", dt, null, DateTime.Now.AddDays(5), System.Web.Caching.Cache.NoSlidingExpiration);
         }
         dt = Cache["dtProvince"] as DataTable;
         ddlProvince.DataSource     = dt;
         ddlProvince.DataTextField  = "Name";
         ddlProvince.DataValueField = "Code";
         ddlProvince.DataBind();
         dt = null;
         ddlProvince.Items.Insert(0, new ListItem("-请选择-", string.Empty));
     }
     catch (Exception ex)
     {
         LogHelper.WriteLine("省份绑定出错!" + ex.Message + ex.StackTrace);
     }
 }
Exemple #12
0
        public void DownloadFile()
        {
            string returnMsg = string.Empty;
            int    errorCode = 0;

            // 校验参数
            string[] parametersRequired = { "fileHistoryId" };
            if (!CheckParamsRequired(parametersRequired, out errorCode, out returnMsg))
            {
                JsonResult <string> resultPra = new JsonResult <string> {
                    Code = errorCode, Message = returnMsg, Rows = 0, Result = null
                };
                GenerateJson(resultPra);
                return;
            }

            string actPath                = string.Empty;
            string taskRootFolder         = string.Empty;
            string taskFolderWithoutEmpNo = string.Empty;
            string fileHistoryId          = context.Request["fileHistoryId"];
            // 根据 ID 获取到 fileHistory 对象
            FileHistory fileHistory        = new FileHistoryBLL().GetModel(fileHistoryId);
            DataTable   dtPrjIdAndCategory = new FileCategoryBLL().GetProjectIdByFileHistoryId(fileHistoryId).Tables[0];
            string      projectId          = Convert.ToString(dtPrjIdAndCategory.Rows[0]["PROJECTID"]);
            string      category           = Convert.ToString(dtPrjIdAndCategory.Rows[0]["category"]);
            string      folderName         = Convert.ToString(dtPrjIdAndCategory.Rows[0]["folderName"]);
            bool        flag             = new FileCategoryBLL().GetFilePathByProjectId(projectId, category, folderName, false, out actPath, out taskRootFolder, out taskFolderWithoutEmpNo, out errorCode);
            string      physicalFileName = Path.Combine(actPath, fileHistory.FILENAME);

            if (File.Exists(physicalFileName))
            {
                string           userId           = UserProfile.GetInstance()?.ID;
                string           operateTypeName  = "下载";
                int              operateTypeKey   = new ConfigureBLL().GetConfig(ConfigTypeName.文件操作类型.ToString()).AsEnumerable().Where(item => item["configValue"].ToString() == operateTypeName).Select(item => Convert.ToInt32(item["configKey"])).FirstOrDefault();
                FileOperationLog fileOperationLog = new FileOperationLog();
                fileOperationLog.ID             = Guid.NewGuid().ToString();
                fileOperationLog.PROJECTID      = projectId;
                fileOperationLog.EMPLOYEEID     = userId;
                fileOperationLog.FILENAME       = fileHistory.FILENAME;
                fileOperationLog.OPERATETYPE    = operateTypeKey;
                fileOperationLog.OPERATEDATE    = DateTime.Now;
                fileOperationLog.OPERATECONTENT = operateTypeName + fileHistory.FILENAME;
                fileOperationLog.OPERATEUSER    = userId;
                new FileOperationLogBLL().Add(fileOperationLog);

                System.IO.Stream iStream = null;
                // Buffer to read 10K bytes in chunk:
                byte[] buffer = new Byte[10000];
                // Length of the file:
                int length;
                // Total bytes to read.
                long dataToRead;
                // Identify the file to download including its path.
                string filepath = physicalFileName;
                // Identify the file name.
                string filename = System.IO.Path.GetFileName(filepath);
                try
                {
                    // Open the file.
                    iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
                                                       System.IO.FileAccess.Read, System.IO.FileShare.Read);
                    // Total bytes to read.
                    dataToRead = iStream.Length;
                    context.Response.Clear();
                    context.Response.ClearHeaders();
                    context.Response.ClearContent();
                    context.Response.ContentType = "text/plain"; // Set the file type
                    context.Response.AddHeader("Content-Length", dataToRead.ToString());
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + "");

                    // Read the bytes.
                    while (dataToRead > 0)
                    {
                        // Verify that the client is connected.
                        if (context.Response.IsClientConnected)
                        {
                            // Read the data in buffer.
                            length = iStream.Read(buffer, 0, 10000);

                            // Write the data to the current output stream.
                            context.Response.OutputStream.Write(buffer, 0, length);

                            // Flush the data to the HTML output.
                            context.Response.Flush();

                            buffer     = new Byte[10000];
                            dataToRead = dataToRead - length;
                        }
                        else
                        {
                            // Prevent infinite loop if user disconnects
                            dataToRead = -1;
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Trap the error, if any.
                    context.Response.Write("Error : " + ex.Message);
                }
                finally
                {
                    if (iStream != null)
                    {
                        //Close the file.
                        iStream.Close();
                    }
                    context.Response.End();
                }
            }
            errorCode = 6001;
            returnMsg = ErrorCode.GetCodeMessage(errorCode);
            JsonResult <string> result = new JsonResult <string> {
                Code = errorCode, Message = returnMsg, Rows = 0, Result = null
            };

            GenerateJson(result);
            return;
        }
Exemple #13
0
        public void DeleteFile()
        {
            string returnMsg = string.Empty;
            int    errorCode = 0;

            // 校验参数
            string[] parametersRequired = { "fileHistoryId" };
            if (!CheckParamsRequired(parametersRequired, out errorCode, out returnMsg))
            {
                JsonResult <string> result = new JsonResult <string> {
                    Code = errorCode, Message = returnMsg, Rows = 0, Result = null
                };
                GenerateJson(result);
                return;
            }

            string fileHistoryId = context.Request["fileHistoryId"];
            // 根据 ID 获取到 fileHistory 对象
            FileHistory fileHistory = new FileHistoryBLL().GetModel(fileHistoryId);

            if (fileHistoryId != null)
            {
                fileHistory.ISDELETED = true;
                bool delFlag = new FileHistoryBLL().Update(fileHistory);
                // 逻辑删除成功
                if (delFlag)
                {
                    string    actPath                = string.Empty;
                    string    taskRootFolder         = string.Empty;
                    string    deletedFolder          = ConfigurationManager.AppSettings["fileDeletedFolder"].ToString();
                    string    taskFolderWithoutEmpNo = string.Empty;
                    DataTable dtPrjIdAndCategory     = new FileCategoryBLL().GetProjectIdByFileHistoryId(fileHistoryId).Tables[0];
                    string    projectId              = Convert.ToString(dtPrjIdAndCategory.Rows[0]["PROJECTID"]);
                    string    category               = Convert.ToString(dtPrjIdAndCategory.Rows[0]["category"]);
                    string    folderName             = Convert.ToString(dtPrjIdAndCategory.Rows[0]["folderName"]);
                    bool      flag             = new FileCategoryBLL().GetFilePathByProjectId(projectId, category, folderName, false, out actPath, out taskRootFolder, out taskFolderWithoutEmpNo, out errorCode);
                    string    physicalFileName = Path.Combine(actPath, fileHistory.FILENAME);
                    string    timeStr          = DateTime.Now.ToString("yyyyMMddHHmmss");
                    string    destFileName     = Path.Combine(deletedFolder, timeStr + fileHistory.FILENAME);
                    if (File.Exists(physicalFileName))
                    {
                        try
                        {
                            // 如果目标位置文件已存在,则先将其删除
                            if (File.Exists(destFileName))
                            {
                                File.Delete(destFileName);
                            }
                            // 移动文件到删除暂存目录
                            File.Move(physicalFileName, destFileName);
                        }
                        catch (IOException ioEx)
                        {
                            errorCode = 1;
                            returnMsg = ioEx.Message;
                            LogHelper.WriteLine("文件删除失败:" + ioEx.Message);
                        }
                        finally
                        {
                            if (File.Exists(physicalFileName))
                            {
                                fileHistory.ISDELETED = false;
                                new FileHistoryBLL().Update(fileHistory);
                                errorCode = 1;
                            }
                            else
                            {
                                // 记录操作日志
                                string           operateTypeName  = "删除";
                                int              operateTypeKey   = new ConfigureBLL().GetConfig(ConfigTypeName.文件操作类型.ToString()).AsEnumerable().Where(item => item["configValue"].ToString() == operateTypeName).Select(item => Convert.ToInt32(item["configKey"])).FirstOrDefault();
                                FileOperationLog fileOperationLog = new FileOperationLog();
                                fileOperationLog.ID             = Guid.NewGuid().ToString();
                                fileOperationLog.PROJECTID      = projectId;
                                fileOperationLog.EMPLOYEEID     = UserProfile.GetInstance()?.ID;
                                fileOperationLog.FILENAME       = fileHistory.FILENAME;
                                fileOperationLog.OPERATETYPE    = operateTypeKey;
                                fileOperationLog.OPERATEDATE    = DateTime.Now;
                                fileOperationLog.OPERATECONTENT = operateTypeName + fileHistory.FILENAME;
                                fileOperationLog.OPERATEUSER    = UserProfile.GetInstance()?.ID;
                                new FileOperationLogBLL().Add(fileOperationLog);
                            }
                        }
                    }
                }
                else
                {
                    errorCode = 1;
                }
                JsonResult <string> result = new JsonResult <string> {
                    Code = errorCode, Message = returnMsg, Rows = 0, Result = null
                };
                GenerateJson(result);
                return;
            }
            JsonResult <string> resultFinal = new JsonResult <string> {
                Code = errorCode, Message = returnMsg, Rows = 0, Result = null
            };

            GenerateJson(resultFinal);
            return;
        }
Exemple #14
0
        public void UploadSuccess()
        {
            string returnMsg        = string.Empty;
            int    errorCode        = 0;
            string projectId        = string.Empty;
            string category         = string.Empty;
            string folder           = string.Empty;
            string userId           = string.Empty;
            string physicalFileName = string.Empty;

            // 校验参数
            string[] parametersRequired = { "parentId", "description", "taskid", "filename" };
            if (!CheckParamsRequired(parametersRequired, out errorCode, out returnMsg))
            {
                JsonResult <string> resultChkPar = new JsonResult <string> {
                    Code = errorCode, Message = returnMsg, Rows = 0, Result = null
                };
                GenerateJson(resultChkPar);
                return;
            }
            string       taskid       = context.Request["taskid"].ToString();
            string       filename     = context.Request["filename"].ToString();
            string       parentId     = Convert.ToString(context.Request["parentId"]);
            string       description  = Convert.ToString(context.Request["description"]);
            FileCategory fileCategory = new FileCategoryBLL().GetModel(parentId);

            if (fileCategory != null)
            {
                projectId = fileCategory.PROJECTID;
                folder    = fileCategory.FOLDERNAME;
                category  = fileCategory.CATEGORY;
                bool flag = MergeSplitFile(taskid, projectId, category, folder, filename, out physicalFileName, out errorCode);
                if (flag)
                {
                    userId = UserProfile.GetInstance()?.ID;
                    string fileNameRelativeToTaskFolder = Path.Combine(folder, filename);
                    bool   addFileHisFlag = new FileHistoryBLL().AddFileHistory(parentId, filename, fileNameRelativeToTaskFolder, description, userId);
                    if (addFileHisFlag)
                    {
                        string           operateTypeName  = "上传";
                        int              operateTypeKey   = new ConfigureBLL().GetConfig(ConfigTypeName.文件操作类型.ToString()).AsEnumerable().Where(item => item["configValue"].ToString() == operateTypeName).Select(item => Convert.ToInt32(item["configKey"])).FirstOrDefault();
                        FileOperationLog fileOperationLog = new FileOperationLog();
                        fileOperationLog.ID             = Guid.NewGuid().ToString();
                        fileOperationLog.PROJECTID      = projectId;
                        fileOperationLog.EMPLOYEEID     = userId;
                        fileOperationLog.FILENAME       = filename;
                        fileOperationLog.OPERATETYPE    = operateTypeKey;
                        fileOperationLog.OPERATEDATE    = DateTime.Now;
                        fileOperationLog.OPERATECONTENT = operateTypeName + filename;
                        fileOperationLog.OPERATEUSER    = userId;
                        new FileOperationLogBLL().Add(fileOperationLog);
                        JsonResult <string> resultOprLog = new JsonResult <string> {
                            Code = errorCode, Message = returnMsg, Rows = 0, Result = null
                        };
                        GenerateJson(resultOprLog);
                        return;
                    }
                    // 添加失败时,需删除已上传的文件
                    else
                    {
                        if (File.Exists(physicalFileName))
                        {
                            File.Delete(physicalFileName);
                        }
                        JsonResult <string> resultAddDb2 = new JsonResult <string> {
                            Code = errorCode, Message = "数据库记录添加失败", Rows = 0, Result = null
                        };
                        GenerateJson(resultAddDb2);
                        return;
                    }
                }
                returnMsg = ErrorCode.GetCodeMessage(errorCode);
                JsonResult <string> resultAddDb = new JsonResult <string> {
                    Code = errorCode, Message = returnMsg, Rows = 0, Result = null
                };
                GenerateJson(resultAddDb);
                return;
            }
            JsonResult <string> result = new JsonResult <string> {
                Code = errorCode, Message = "未找到 projectId 对应的记录", Rows = 0, Result = null
            };

            GenerateJson(result);
            return;
        }