예제 #1
0
        public static void Run()
        {
            // Using lambda operator

            FormatDateTime czechFormat = dateTime => $"{dateTime:dd.MM.yyyy}";

            czechFormat += dateTime => $"{dateTime:dd.MM.yy}";

            Console.WriteLine($"Czech format: {czechFormat(DateTime.Now)}");

            // Asking for invocation list

            var invocations = czechFormat.GetInvocationList();

            foreach (var invocation in invocations)
            {
                Console.WriteLine($"invocation.Method: {invocation.Method}");
                Console.WriteLine($"invocation.Target: {invocation.Target}");
            }

            // Using asynchronous support

            SimpleDelegate simpleDelegate = () => { Thread.Sleep(1000); };

            Console.WriteLine("The delegate invoked asynchronously is starting ...");

            simpleDelegate.BeginInvoke(HandleEndOfSimpleDelegateInvocation, null);

            Console.WriteLine("Processing is going on ...");
        }
예제 #2
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //*防止限制漏洞导致拒绝服务攻击
            //if (filterContext.RequestContext.HttpContext.Request.HttpMethod == "POST"
            //    && filterContext.RequestContext.HttpContext.Request.ContentLength > 1024 * 1024)
            //    return;

            #region 身份验证
            LoginUserModel loginUserModel = UserLogin(filterContext);
            if (loginUserModel != null && loginUserModel.AdminUserInfo != null)
            {
                _currentLoginModel        = loginUserModel;
                UserID                    = loginUserModel.AdminUserInfo.id;
                UserName                  = loginUserModel.AdminUserInfo.UserName;
                IsAdmin                   = loginUserModel.AdminUserInfo.IsAdmin;
                ViewData["PermissionSet"] = loginUserModel.PermissionSet;
                ViewBag.UserMenu          = loginUserModel.MenuList;
                ViewBag.AdminUserInfo     = loginUserModel.AdminUserInfo;
                ViewBag.UserName          = UserName;
                ViewBag.User              = UserName;
            }
            #endregion
            if (Request["PageName"] != null)
            {
                CurrPageName = Request["PageName"];
            }
            else
            {
                string url = filterContext.HttpContext.Request.Url.AbsolutePath;
                CurrPageName = url.Substring(url.LastIndexOf('/') + 1);
            }
            //当前页面
            ViewBag.PageName = CurrPageName;
            //初始化页面时间控件值
            CreateTimeStart = Request["CreateTimeStart"];
            CreateTimeEnd   = Request["CreateTimeEnd"];
            //第一次加载页面时,初始时间范围为一个月
            if (string.IsNullOrEmpty(CreateTimeStart) &&
                string.IsNullOrEmpty(CreateTimeEnd) &&
                Request.HttpMethod == "GET" &&
                Request["PageNo"] == null)
            {
                CreateTimeStart = FormatDateTime.ToDate(DateTime.Now.AddMonths(-1));
                CreateTimeEnd   = FormatDateTime.ToDate(DateTime.Now);
            }
            //是否可以查询
            //if (Request.HttpMethod == "POST" || Request["PageNo"] != null)
            {
                CanSearch = true;
            }
        }
예제 #3
0
        public bool setFieldDateTime(Guid guidList, string displayName, string name, bool hidden, bool required, FormatDateTime format)
        {
            //Se puede sacar informacion de esta web: https://karinebosch.wordpress.com/my-articles/creating-fields-using-csom/
            //Informacion de las propiedades del campo https://docs.microsoft.com/es-es/sharepoint/dev/schema/field-element-field
            try
            {
                var list = _context.Web.Lists.GetById(guidList);
                if (list != null)
                {
                    var field = list.Fields.AddFieldAsXml("<Field id='" + Guid.NewGuid().ToString() + "'" +
                                                          " Name='" + name + "'" +
                                                          " StaticName='" + name + "'" +
                                                          " DisplayName='" + displayName + "'" +
                                                          " Type='DateTime'" +
                                                          " Format='" + format + "'" +
                                                          " Hidden='" + hidden.ToString().ToUpper() + "'" +
                                                          " Required='" + required.ToString().ToUpper() + "'" +
                                                          "/>"
                                                          , true, AddFieldOptions.DefaultValue);

                    list.Update();
                    _context.ExecuteQuery();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #4
0
        private static void Main(string[] args)
        {
            string   str      = "";
            DateTime dateTime = DateTime.Parse("2000-01-01");
            DateTime now      = DateTime.Now;
            bool     flag     = false;

            try
            {
                Comm.Key = FormatDateTime.GetDiskInfo();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, Localization.Get("系统错误"));
                return;
            }
            if ((Comm.Key == null ? false : Comm.Key.Length == 16))
            {
                try
                {
                    Comm.Text = File.ReadAllText(string.Concat(Comm.Key, ".ini"), Encoding.UTF8);
                    if (!string.IsNullOrEmpty(Comm.Text))
                    {
                        string[] strArrays = SecurityUtil.DesDecode(Comm.Text, Comm.Key).Split(new char[] { '|' });
                        if ((int)strArrays.Length == 5)
                        {
                            DateTime.Parse(strArrays[0]);
                            str      = strArrays[2];
                            flag     = bool.Parse(strArrays[1]);
                            dateTime = DateTime.Parse(strArrays[4]);
                        }
                    }
                    else
                    {
                        DateTime now1 = DateTime.Now;
                    }
                }
                catch
                {
                    File.WriteAllText(string.Concat(Comm.Key, ".ini"), "", Encoding.UTF8);
                    DateTime dateTime1 = DateTime.Now;
                }
                try
                {
                    if (!Directory.Exists("Log"))
                    {
                        Directory.CreateDirectory("Log");
                    }
                    Configs.LoadConfigs();
                    Configs.BaseConfig.LicenseAd   = Localization.Get("站群系统,防封IP采集,各类软件定制 http://biqu01.com/");
                    Configs.BaseConfig.LicenseOk   = (str == Comm.Key ? true : Comm.Text == "");
                    Configs.BaseConfig.LicenseVip  = flag;
                    Configs.BaseConfig.LicenseTime = dateTime;
                    if (DateTime.Now > Configs.BaseConfig.LicenseTime)
                    {
                        Configs.BaseConfig.LicenseVip = false;
                    }
                }
                catch (Exception exception1)
                {
                    MessageBox.Show(exception1.Message, Localization.Get("错误提示"));
                    return;
                }
                try
                {
                    NovelSpider.NativeMethods.FreeConsole();
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(true);
                    Class19.Q77LubhzKM3NS();
                    Application.Run(new MdiForm());
                }
                finally
                {
                    Localization.Refresh();
                    NovelSpider.NativeMethods.FreeConsole();
                }
            }
            else
            {
                MessageBox.Show(Localization.Get("系统编码失败,请联系管理员。"), Localization.Get("系统错误"));
            }
        }
예제 #5
0
        private void SupplierQueryListToExcel(IList <SupplierAbstractModel> list)
        {
            #region 导出Excel
            HSSFWorkbook workbook    = new HSSFWorkbook();
            ISheet       sheet       = workbook.CreateSheet("Sheet1");
            var          rowIndex    = 3;
            ExcelHelper  excelHelper = new ExcelHelper();
            //大标题
            excelHelper.SetBigTitle(sheet, workbook, "商家列表", 9);
            //子标题
            excelHelper.SetSubTitle(sheet, workbook, "商家賬號,公司名稱,入駐時間,商家狀態,在售SKU數量", 2);
            #region 填充数据

            ICellStyle itemStyle = workbook.CreateCellStyle();
            itemStyle.BorderBottom = BorderStyle.Thin;
            itemStyle.BorderLeft   = BorderStyle.Thin;
            itemStyle.BorderRight  = BorderStyle.Thin;
            itemStyle.BorderTop    = BorderStyle.Thin;

            foreach (var entity in list)
            {
                #region
                var   listRow = sheet.CreateRow(rowIndex++);
                ICell cell;
                cell = excelHelper.CreateCell(listRow, 0, CellType.String, string.Format("{0}", entity.UserName), itemStyle);
                cell = excelHelper.CreateCell(listRow, 1, CellType.String, string.Format("{0}", entity.CompanyName), itemStyle);
                cell = excelHelper.CreateCell(listRow, 2, CellType.String, string.Format("{0}", FormatDateTime.ToDateTimeMM(entity.CreateTime)), itemStyle);
                cell = excelHelper.CreateCell(listRow, 3, CellType.String, string.Format("{0}", entity.SupplierStatus), itemStyle);
                cell = excelHelper.CreateCell(listRow, 4, CellType.String, string.Format("{0}", entity.SkuNumber), itemStyle);
                #endregion
            }
            excelHelper.AutoColumnWidth(sheet, 15);

            #endregion

            Stream ouputStream = Response.OutputStream;
            workbook.Write(ouputStream);
            ouputStream.Flush();
            ouputStream.Close();
            #endregion
        }