Пример #1
0
        public bool SendConfigState(int type, bool state)
        {
            string name = string.Empty;

            switch (type)
            {
            case 1:
                name = "AAS";
                break;

            case 2:
                name = "DailyAwardState";
                break;

            default:
                return(false);
            }
            if (StaticFunction.UpdateConfig("Center.Service.exe.config", name, state.ToString()))
            {
                switch (type)
                {
                case 1:
                    this.ASSState = state;
                    break;

                case 2:
                    this.DailyAwardState = state;
                    break;
                }
                this.SendConfigState();
                return(true);
            }
            return(false);
        }
Пример #2
0
        /// <summary>
        /// 极速达取消订单
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public async Task <ResultData <string> > CancelOrder(HttpCancelOrderParameter param)
        {
            Dictionary <string, string> dirList = new Dictionary <string, string>();

            dirList.Add("OrderCode", param.OrderCode);
            dirList.Add("cancelBy", param.cancelBy);

            dirList.Add("app_id", "jsd");
            dirList.Add("timestamp", StaticFunction.GetTimestamp(0).ToString() + "000");
            dirList.Add("ecOrderNumber", param.OrderCode);
            var str  = StaticFunction.GetEcoParamSrc(dirList);
            var sign = MD5Utils.MD5Encrypt(eco_app_token + str + eco_app_token).ToUpper();


            dirList.Add("sign", sign);

            var returnStr = await WebAPIHelper.HttpPostAsync(ECOUrl + "/api/order/cancelOrder", JsonConvert.SerializeObject(dirList));

            var result = JsonConvert.DeserializeObject <HttpCancelOrderResult>(returnStr);

            if (result.success)
            {
                this._logger.LogInformation("订单号为:" + param.OrderCode + "取消成功");
                return(ResultData <string> .CreateResultDataSuccess("成功"));
            }
            this._logger.LogWarning("订单号为:" + param.OrderCode + "取消失败,原因:" + (result.errorMsg ?? "调用极速达取消接口失败"));
            return(ResultData <string> .CreateResultDataFail(result.errorMsg ?? "调用极速达取消接口失败"));
        }
Пример #3
0
        private SerializableFLInstruction ParseInstruction(
            List <StaticFunction> functionHeaders,
            DefineStatement[] definedBuffers,
            DefineStatement[] definedScripts,
            StaticFunction currentFunction, int instructionIndex)
        {
            StaticInstruction instruction = currentFunction.Body[instructionIndex];

            if (instruction.Key == "")
            {
                return(null);
            }

            //Create Argument List
            List <SerializableFLInstructionArgument> args = new List <SerializableFLInstructionArgument>();

            for (int i = 0; i < instruction.Arguments.Length; i++)
            {
                args.Add(
                    ParseInstructionArgument(
                        functionHeaders,
                        definedBuffers,
                        definedScripts,
                        instruction.Arguments[i],
                        currentFunction
                        )
                    );
            }


            return(new SerializableFLInstruction(instruction.Key, args));
        }
Пример #4
0
 public void GenerateQuestion(Node _node)
 {
     _node.isQuestion = StaticFunction.randomTrueAndFalse(QuestionRate);
     //  Debug.Log(_node.isQuestion);
     if (_node.isQuestion)
     {
         questionNumber++;
     }
 }
Пример #5
0
 public bool SendAAS(bool state)
 {
     if (StaticFunction.UpdateConfig("Center.Service.exe.config", "AAS", state.ToString()))
     {
         this.ASSState = state;
         GSPacketIn gSPacketIn = new GSPacketIn(7);
         gSPacketIn.WriteBoolean(state);
         this.SendToALL(gSPacketIn);
         return(true);
     }
     return(false);
 }
Пример #6
0
        public void GetCusName()
        {
            string   designId = Request["designId"];
            Database db       = new Database("BE_Customer_Proc", "GETCUSNAME", 0, 0, designId, "", "");

            using (SqlDataReader dr = db.ExecuteReader())
            {
                DataTable dt   = StaticFunction.ConvertDataReaderToDataTable(dr);
                string    json = JSONHelper.SerializeObject(dt);
                this.Response.Write(json);
            }
        }
Пример #7
0
 public bool SendAAS(bool state)
 {
     if (StaticFunction.UpdateConfig("Center.Service.exe.config", "AAS", state.ToString()))
     {
         ASSState = state;
         GSPacketIn pkg = new GSPacketIn((byte)ePackageType.UPDATE_ASS);
         pkg.WriteBoolean(state);
         SendToALL(pkg);
         return(true);
     }
     return(false);
 }
Пример #8
0
        private SerializableFLFunction ParseFunctionObject(
            List <StaticFunction> functionHeaders,
            DefineStatement[] definedBuffers,
            DefineStatement[] definedScripts,
            StaticFunction currentFunction)
        {
            List <SerializableFLInstruction> instructions =
                ParseInstructions(functionHeaders, definedBuffers, definedScripts, currentFunction);

            return(new SerializableFLFunction(
                       currentFunction.Name,
                       currentFunction.Body,
                       instructions,
                       currentFunction.Modifiers
                       ));
        }
        /// <summary>
        /// 设计ID查询
        /// </summary>
        public void CheckDn()
        {
            string kw        = Request["kw"].ToString();
            string partNerId = "";

            if (CurrentUser.PartnerID != Guid.Empty)
            {
                partNerId = CurrentUser.PartnerID.ToString();
            }
            Database db = new Database("BE_RoomDesigner_Proc", "CHECKDN", 4, 0, kw, partNerId, kw);

            using (SqlDataReader dr = db.ExecuteReader())
            {
                DataTable dt   = StaticFunction.ConvertDataReaderToDataTable(dr);
                string    json = JSONHelper.SerializeObject(dt);// JsonConvert.SerializeObject(dt);
                HttpContext.Current.Response.Write(json);
            }
        }
Пример #10
0
        private List <SerializableFLInstruction> ParseInstructions(
            List <StaticFunction> functionHeaders,
            DefineStatement[] definedBuffers,
            DefineStatement[] definedScripts,
            StaticFunction currentFunction)
        {
            List <SerializableFLInstruction> instructions = new List <SerializableFLInstruction>();

            for (int i = 0; i < currentFunction.Body.Length; i++)
            {
                SerializableFLInstruction inst =
                    ParseInstruction(functionHeaders, definedBuffers, definedScripts, currentFunction, i);
                if (inst != null)
                {
                    instructions.Add(inst);
                }
            }

            return(instructions);
        }
Пример #11
0
        public bool SendConfigState(int type, bool state)
        {
            string config = string.Empty;

            switch (type)
            {
            case 1:
                config = "AAS";
                break;

            case 2:
                config = "DailyAwardState";
                break;

            default:
                return(false);
            }

            //TODO:修改数据库里面的配置

            if (StaticFunction.UpdateConfig("Center.Service.exe.config", config, state.ToString()))
            {
                switch (type)
                {
                case 1:
                    ASSState = state;
                    break;

                case 2:
                    DailyAwardState = state;
                    break;
                }
                SendConfigState();
                return(true);
            }

            return(false);
        }
Пример #12
0
    IEnumerator Start()
    {
        while (true)
        {
            if (StaticFunction.ConvertByte2MB(Profiler.usedHeapSizeLong) + StaticFunction.ConvertByte2MB(Profiler.GetMonoUsedSizeLong()) > SystemInfo.systemMemorySize * LimitPercent)
            {
                if (IsLimitedOverflow == false)
                {
                    IsLimitedOverflow = true;
                }

                Debug.LogWarning($"HeapSize : {StaticFunction.ConvertByte2MBStr(Profiler.usedHeapSizeLong)}, LimitMemory : {SystemInfo.systemMemorySize * LimitPercent}MB");
            }
            else
            {
                if (IsLimitedOverflow == true)
                {
                    IsLimitedOverflow = false;
                }
            }

            yield return(new WaitForSeconds(3f));
        }
    }
Пример #13
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            this._strB = new StringBuilder();
            string        strResult  = string.Empty;
            List <string> strList    = new List <string>();
            int           listLength = (int)numUpDown.Value;

            this._sw.Restart();
            for (int i = 1; i < listLength; i++)
            {
                strList.Add(i.ToString());
            }
            this._sw.Stop();
            this._strB.AppendLine(string.Format("生成数据共耗时: {0} 毫秒", this._sw.ElapsedMilliseconds.ToString()));

            this._sw.Restart();
            strResult = StaticFunction.ToStringWithDelimiterFromStringArray(strList);
            this._sw.Stop();
            this._strB.AppendLine(
                string.Format("ToStringWithDelimiterFromStringArray()函数共耗时: {0} 毫秒", this._sw.ElapsedMilliseconds.ToString())
                );

            this._sw.Restart();
            string VerticalLineDelimiter = ClassLibrary.Constant.DelimiterConst.VerticalLine.ToString();
            string strR = StaticFunction.JoinStringArrayToStringWithDelimiter(VerticalLineDelimiter, strList);

            this._sw.Stop();
            this._strB.AppendLine(
                string.Format("string.Join()函数共耗时: {0} 毫秒", this._sw.ElapsedMilliseconds.ToString())
                );

            this._sw.Restart();
            List <string> newStrList = StaticFunction.ToStringArrayFromStringWithDelimiter(strResult);

            this._sw.Stop();
            this._strB.AppendLine(
                string.Format("ToStringArrayFromStringWithDelimiter()函数共耗时: {0} 毫秒", this._sw.ElapsedMilliseconds.ToString())
                );

            this._sw.Restart();
            List <string> otherStringList = strList.Skip(1).ToList();

            this._sw.Stop();
            this._strB.AppendLine(
                string.Format("List<string>.Skip() 函数共耗时: {0} 毫秒", this._sw.ElapsedMilliseconds.ToString())
                );

            this._sw.Restart();
            List <string> otherStringList1 = strList.GetRange(1, strList.Count - 1);

            this._sw.Stop();
            this._strB.AppendLine(
                string.Format("List<string>.GetRange() 函数共耗时: {0} 毫秒", this._sw.ElapsedMilliseconds.ToString())
                );

            //当 strList 很大(如达到千万级以上)时在现实会占用很大内存
            //this._strB.AppendLine(string.Format("转换结果:{0}", strResult));

            this.richTxtBoxTestResult.Text = this._strB.ToString();

            this.Cursor = Cursors.Default;
        }
Пример #14
0
        /// <summary>
        /// 导入房屋平面图纸
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnImportHouseImage_OnClick(object sender, EventArgs e)
        {
            this.lblImportImage.Text = "";
            string importImagePath = txtImportImagePath.Text.Trim();

            if (importImagePath != "")
            {
                if (!Directory.Exists(importImagePath))
                {
                    this.lblImportImage.Text = "您输入的文件导入路径不存在!";
                    return;
                }
                int       rel      = 0;
                DataTable dtResult = new DataTable();
                dtResult.Columns.Add("Index", Type.GetType("System.String"));
                dtResult.Columns.Add("DataId", Type.GetType("System.String"));
                dtResult.Columns.Add("HouseNo", Type.GetType("System.String"));
                dtResult.Columns.Add("ImageName", Type.GetType("System.String"));

                foreach (string item in Directory.GetDirectories(importImagePath))
                {
                    DirectoryInfo     directoryinfo = new DirectoryInfo(item);
                    string            houseNo       = directoryinfo.Name;
                    DateTime          creationTime  = directoryinfo.CreationTime;
                    string            strSql        = "select * from HM_HouseBan where HouseNo =:HouseNo ";
                    OracleParameter[] parameters    =
                    {
                        new OracleParameter("HouseNo", OracleDbType.Varchar2, 50)
                    };
                    parameters[0].Value = houseNo;
                    //string strSql = "select * from HM_HouseBan where HouseNo ='"+ houseNo + "' ";

                    string connectionString = ConfigurationManager.ConnectionStrings["jmgf_new_oracle"].ConnectionString;

                    DataTable dt = OracleHelper.ExecuteDataTable(connectionString, CommandType.Text, strSql, parameters);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        try
                        {
                            Guid       fid     = Guid.Empty;
                            FileInfo[] arrFile = directoryinfo.GetFiles();

                            foreach (FileInfo fileInfo in arrFile)
                            {
                                string fileName          = Path.GetFileName(fileInfo.FullName);
                                string fileExtensionName = Path.GetExtension(fileInfo.FullName);
                                string fileid            = fileName.Replace(fileExtensionName, "");
                                Guid   fileId            = fid;
                                if (fid == Guid.Empty)
                                {
                                    fileId = Guid.NewGuid();
                                }
                                using (Stream inStream = StaticFunction.StreamToMemoryStream(fileInfo.OpenRead()))
                                {
                                    using (Stream fmpStream = FileManager.CreateFile(fileId, fileName))
                                    {
                                        StaticFunction.StreamSourceStreamToTargetStream(inStream, fmpStream);
                                        StringBuilder strSql0 = new StringBuilder();
                                        strSql0.Append(" insert into Sys_FileRelation(Id,ModuleId,KeyId,FileId,FileName,CreatorUserId,CreationTime,FileType) ");
                                        strSql0.Append(" values(SYS_FILERELATION_SEQ.Nextval,:ModuleId,:KeyId,:FileId,:FileName,:CreatorUserId,:CreationTime,:FileType)");
                                        OracleParameter[] parameters0 =
                                        {
                                            new OracleParameter("ModuleId",      OracleDbType.Int32,     10),
                                            new OracleParameter("KeyId",         OracleDbType.Int32,     10),
                                            new OracleParameter("FileId",        OracleDbType.Raw),
                                            new OracleParameter("FileName",      OracleDbType.Varchar2, 200),
                                            new OracleParameter("CreatorUserId", OracleDbType.Int32,     10),
                                            new OracleParameter("CreationTime",  OracleDbType.Date),
                                            new OracleParameter("FileType",      OracleDbType.Int32, 1)
                                        };
                                        parameters0[0].Value = Topevery.ModuleType.HouseBan;
                                        parameters0[1].Value = int.Parse(dt.Rows[0]["Id"].ToString());
                                        parameters0[2].Value = fileId.ToByteArray();
                                        parameters0[3].Value = fileName;
                                        parameters0[4].Value = 0;
                                        parameters0[5].Value = System.DateTime.Now;
                                        parameters0[6].Value = FileHelper.GetAttachType(fileExtensionName);
                                        rel += OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, strSql0.ToString(), parameters0);

                                        DataRow newRow = dtResult.NewRow();
                                        newRow["Index"]     = rel.ToString();
                                        newRow["DataId"]    = dt.Rows[0]["Id"].ToString();
                                        newRow["HouseNo"]   = houseNo;
                                        newRow["ImageName"] = fileName;
                                        dtResult.Rows.Add(newRow);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                        }
                    }
                }
                DataGridView1.DataSource = dtResult;
                DataGridView1.DataBind();
                this.lblImportImage.Text = "成功导入了" + rel + "张图片";
            }
            else
            {
                this.lblImportImage.Text = "请输入文件导入路径!";
            }
        }
Пример #15
0
        private SerializableFLInstructionArgument ParseInstructionArgument(
            List <StaticFunction> functionHeaders,
            DefineStatement[] definedBuffers,
            DefineStatement[] definedScripts,
            string argument,
            StaticFunction currentFunction)
        {
            if (decimal.TryParse(
                    argument,
                    NumberStyles.AllowDecimalPoint,
                    CultureInfo.InvariantCulture,
                    out decimal value
                    ))
            {
                return(new SerializeDecimalArgument(value));
            }

            IEnumerable <string> bufferNames = definedBuffers.Where(x => (x.Modifiers as FLBufferModifiers).IsTexture)
                                               .Select(x => x.Name);
            IEnumerable <string> arrayBufferNames = definedBuffers.Where(x => (x.Modifiers as FLBufferModifiers).IsArray)
                                                    .Select(x => x.Name);
            IEnumerable <string> scriptNames = definedScripts.Select(x => x.Name);

            StaticFunction func = functionHeaders.FirstOrDefault(x => x.Name == argument);

            if (func != null)
            {
                //if (currentFunction.Modifiers.IsStatic && !func.Modifiers.IsStatic)
                //{
                //    throw new FLInvalidFunctionUseException($"{currentFunction}", "Can not call a non static function from a static function");
                //}
                return(new SerializeFunctionArgument(argument));
            }

            if (argument.StartsWith("~"))
            {
                //if (currentFunction.Modifiers.IsStatic)
                //{
                //    throw new FLInvalidFunctionUseException($"{currentFunction}", "Can not Access Buffers from a static function");
                //}

                string n = argument.Remove(0, 1);
                if (arrayBufferNames.Contains(n))
                {
                    return(new SerializeArrayLengthArgument(n));
                }

                if (bufferNames.Contains(n))
                {
                    throw new InvalidOperationException("Only array buffers can be queried for length: " + n);
                }


                throw new InvalidOperationException("Invalid Length operator. Can not find buffer with name: " + n);
            }

            if (bufferNames.Contains(argument))
            {
                //if (currentFunction.Modifiers.IsStatic)
                //{
                //    throw new FLInvalidFunctionUseException($"{currentFunction}", "Can not Access Buffers from a static function");
                //}

                return(new SerializeBufferArgument(argument));
            }

            if (arrayBufferNames.Contains(argument))
            {
                //if (currentFunction.Modifiers.IsStatic)
                //{
                //    throw new FLInvalidFunctionUseException($"{currentFunction}", "Can not Access Buffers from a static function");
                //}

                return(new SerializeArrayBufferArgument(argument));
            }

            if (SerializeArrayElementArgument.TryParse(
                    arrayBufferNames,
                    argument,
                    out SerializeArrayElementArgument arg
                    ))
            {
                return(arg);
            }

            if (scriptNames.Contains(argument))
            {
                return(new SerializeExternalFunctionArgument(argument));
            }

            //if (currentFunction.Modifiers.IsStatic)
            //{
            //    throw new FLInvalidFunctionUseException($"{currentFunction}", "Can not Access Variables from a static function");
            //}
            //else
            //{
            return(new SerializeNameArgument(argument));

            //}


            //throw new InvalidOperationException("Can not parse argument: " + argument);
        }
Пример #16
0
        public JsonResult UploadFile()
        {
            // 获取从MIME中读取出来的文件
            var    listFile      = Request.Files;
            Guid   fid           = Guid.Empty;
            string fileId2Return = "";
            string message       = "";

            if (!string.IsNullOrEmpty(Request.QueryString["fileId"]))
            {
                fid = new Guid(Request.QueryString["fileId"]);
            }
            var islocal = Request.QueryString["islocal"];

            if (islocal == "1")
            {
                string filePath = Server.MapPath("~/Content/images/header/");
                for (int n = 0; n < listFile.Count; n++)
                {
                    var fileId = Guid.NewGuid().ToString().ToUpper() + Path.GetExtension(listFile[n].FileName);
                    listFile[n].SaveAs(filePath + fileId);
                    fileId2Return += fileId.ToString() + ";";
                }
            }
            else
            {
                for (int n = 0; n < listFile.Count; n++)
                {
                    Guid fileId = fid;
                    if (fid == Guid.Empty)
                    {
                        fileId = Guid.NewGuid();
                    }
                    HttpPostedFileBase file = listFile[n];
                    if (!string.IsNullOrEmpty(file?.FileName))
                    {
                        fileId2Return += fileId.ToString() + ";";
                        string fileName = Path.GetFileName(file.FileName);
                        //string FileNameNotExtension = Path.GetFileNameWithoutExtension(file.FileName);
                        //string FileExtensionName = Path.GetExtension(file.FileName);

                        try
                        {
                            using (Stream inStream = StaticFunction.StreamToMemoryStream(file.InputStream))
                            {
                                using (Stream fmpStream = FileManager.CreateFile(fileId, fileName))
                                {
                                    StaticFunction.StreamSourceStreamToTargetStream(inStream, fmpStream);
                                }

                                //OpenFileItemData context = new OpenFileItemData();
                                //context.FileID = fileId;
                                //context.UpdateMode = UpdateMode.None;
                                //context.FileAccess = Topevery.FMP.ObjectModel.FileAccess.ReadWrite;
                                //context.FileMode = Topevery.FMP.ObjectModel.FileMode.Create;
                                //context.ClientFileName = fileName;
                            }
                        }
                        catch (Exception ex)
                        {
                            message = ex.ToString();
                            Logger.Error("FMP错误", ex);
                            throw ex;
                        }
                    }
                }
            }


            if (string.IsNullOrEmpty(message) && !string.IsNullOrEmpty(fileId2Return))
            {
                return(Json(new AjaxResponse <string> {
                    Success = true, Result = fileId2Return.Substring(0, fileId2Return.Length - 1)
                }));
            }
            return(Json(new AjaxResponse {
                Success = false, Error = new ErrorInfo(message)
            }));
        }
Пример #17
0
        //为图片添加边框
        public void Btn_AddBoarder_Click(object sender, RibbonControlEventArgs e)
        {
            Application wdApp = Globals.ThisAddIn.Application;

            StaticFunction.AddBoadersForInlineshapes(wdApp, pictureParagraphStyle: "图片");
        }
Пример #18
0
        //设置超链接
        public void Button1_Click(object sender, RibbonControlEventArgs e)
        {
            Application wdApp = Globals.ThisAddIn.Application;

            StaticFunction.SetHyperLink(wdApp);
        }
Пример #19
0
        //清理文本格式
        public void Button_ClearTextFormat_Click(object sender, RibbonControlEventArgs e)
        {
            Application wdApp = Globals.ThisAddIn.Application;

            StaticFunction.ClearTextFormat(wdApp, pictureParagraphStyle: "图片");
        }
Пример #20
0
        /// <summary>
        /// 将多个段落转换为一个段落
        /// </summary>
        /// <remarks>比如将从PDF中粘贴过来的多段文字转换为一个段落。具体操作为:将选择区域的文字中的换行符转换为空格</remarks>
        public void buttonPdfReformat_Click(object sender, RibbonControlEventArgs e)
        {
            Application wdApp = Globals.ThisAddIn.Application;

            StaticFunction.PdfReformat(wdApp);
        }
Пример #21
0
 void OnTriggerEnter()
 {
     healthVariable = StaticFunction.Subtract(healthVariable, damage);
     StartCoroutine(damageHalo());
 }