コード例 #1
0
        /// <summary>
        /// The method executes the stored procedure using (impersonating) the identity of the windows domain account.
        /// the account has access on the sql server database.
        /// </summary>
        
        /// <returns></returns>
        public int Add(string <param1>, string <param2>)
        {
            try
            {
                var DomainAccountUserNameToImpersonate = ConfigurationManager.AppSettings["DomainAccountUserNameToImpersonate"].ToString().Trim();
                var DomainAccountPasswordToImpersonate = Encryption.Decrypt(ConfigurationManager.AppSettings["DomainAccountPasswordToImpersonate"].ToString().Trim());
                var DomainName = ConfigurationManager.AppSettings["DomainName"].ToString().Trim();

                using (new Impersonation(DomainName, DomainAccountUserNameToImpersonate, DomainAccountPasswordToImpersonate))
                {
                    SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(strConnection, "<SP NAME>", true);

                    SqlHelper.AssignParameterValues(commandParameters, new object[] { 0, <param1>, <param2> });
                    SqlHelper.ExecuteNonQuery(strConnection, CommandType.StoredProcedure, "<SP NAME>", commandParameters);

                    return (int)commandParameters[0].Value;
                }
            }
            catch (Exception ex)
            {
                try
                {
                    new Emailer().SendMail(ex.Message, "FAILURE");
                }
                catch (Exception){}
                
                return -1;
            }
            finally
            {
                //this.CloseConnection();
            }
        }
コード例 #2
0
 internal ScopeVariableIgnoreCase(string casing)
 {
     _firstCasing   = casing;
     _firstVariable = new ScopeVariable();
 }
コード例 #3
0
 /// <summary>
 /// Gets the ScopeVariable for the scope in a case-sensitive manner.
 ///
 /// The ScopeVariable can be held onto and get/set/deleted without performing
 /// a dictionary lookup on subsequent accesses.
 /// </summary>
 public ScopeVariable GetScopeVariable(string name)
 {
     return(GetScopeVariableIgnoreCase(name).GetCaseSensitiveStorage(name));
 }
コード例 #4
0
        /// <summary>
        /// Returns the standard path to the build receipt for a given target
        /// </summary>
        /// <param name="BaseDir">Base directory for the target being built; either the project directory or engine directory.</param>
        /// <param name="TargetName">The target being built</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Configuration">The target configuration</param>
        /// <param name="BuildArchitecture">The architecture being built</param>
        /// <returns>Path to the receipt for this target</returns>
        public static FileReference GetDefaultPath(DirectoryReference BaseDir, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string BuildArchitecture)
        {
            // Get the architecture suffix. Platforms have the option of overriding whether to include this string in filenames.
            string ArchitectureSuffix = "";

            if (UEBuildPlatform.GetBuildPlatform(Platform).RequiresArchitectureSuffix())
            {
                ArchitectureSuffix = BuildArchitecture;
            }

            // Build the output filename
            if (String.IsNullOrEmpty(ArchitectureSuffix) && Configuration == UnrealTargetConfiguration.Development)
            {
                return(FileReference.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}.target", TargetName)));
            }
            else
            {
                return(FileReference.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}-{1}-{2}{3}.target", TargetName, Platform.ToString(), Configuration.ToString(), ArchitectureSuffix)));
            }
        }
コード例 #5
0
 protected override void OnMenuItemClick(object sender, EventArgs e)
 {
     if (!this.RaiseClickEvent(sender, null))
     {
         DXMenuItem item = sender as DXMenuItem;
         if (item.Tag != null)
         {
             if (item.Tag is GridColumn)
             {
                 GridColumn tag = item.Tag as GridColumn;
                 tag.VisibleIndex = (tag.VisibleIndex >= 0) ? -1 : base.View.VisibleColumns.Count;
             }
             else if (item.Tag.ToString() == "Customization")
             {
                 base.View.ColumnsCustomization();
             }
             else if (item.Tag.ToString() == "BestFit")
             {
                 base.View.BestFitColumns();
             }
             else if (item.Tag.ToString() != "Filter")
             {
                 if (item.Tag.ToString() == "HideGroupPanel")
                 {
                     base.View.OptionsView.ShowGroupPanel = false;
                 }
                 else if (item.Tag.ToString() == "ShowGroupPanel")
                 {
                     base.View.OptionsView.ShowGroupPanel = true;
                 }
                 else if (item.Tag.ToString() == "SelectAll")
                 {
                     base.View.SelectAll();
                 }
                 else if (item.Tag.ToString() == "UnSelectAll")
                 {
                     base.View.ClearSelection();
                 }
                 else if (item.Tag.ToString() == "SaveLayout")
                 {
                     try
                     {
                         string pathXml = this.PathXml;
                         if (!Directory.Exists(pathXml))
                         {
                             Directory.CreateDirectory(pathXml);
                             if (!Directory.Exists(pathXml))
                             {
                                 return;
                             }
                         }
                         if ((this.ParentControlName == "") || (this.ParentControlName == null))
                         {
                             base.View.SaveLayoutToXml(this.PathXml + @"\" + this.ParentControl.Name + ".xml", OptionsLayoutBase.FullLayout);
                         }
                         else
                         {
                             base.View.SaveLayoutToXml(this.PathXml + @"\" + this.ParentControlName + ".xml", OptionsLayoutBase.FullLayout);
                         }
                     }
                     catch
                     {
                     }
                 }
                 else if (item.Tag.ToString() == "DefaultLayout")
                 {
                     try
                     {
                         FileInfo info;
                         if ((this.ParentControlName == "") || (this.ParentControlName == null))
                         {
                             info = new FileInfo(this.PathXml + @"\" + this.ParentControl.Name + ".xml");
                         }
                         else
                         {
                             info = new FileInfo(this.PathXml + @"\" + this.ParentControlName + ".xml");
                         }
                         info.Delete();
                     }
                     catch
                     {
                     }
                 }
             }
         }
     }
 }
コード例 #6
0
 public SelectionHistoryMemento(string name, ImageResource image, IHistoryWorkspace historyWorkspace)
     : base(name, image)
 {
     this.historyWorkspace   = historyWorkspace;
     this.savedSelectionData = this.historyWorkspace.Selection.Save();
 }
コード例 #7
0
ファイル: TM.cs プロジェクト: ppatole/ReportServer0.1
		public TM(IMessage theMessage, string description)
			: base(theMessage, description)
		{
		}
コード例 #8
0
        public static TaskFunc ProcessNand(string nandDump, NandTasks task)
        {
            return (Tasker tasker, Object sync) =>
            {
                NandTasks[] validTasks = { NandTasks.DumpNand, NandTasks.DumpNandB, NandTasks.DumpNandC, NandTasks.FlashNandB, NandTasks.FlashNandC, NandTasks.FormatNandC };
                if (!validTasks.Contains(task))
                    throw new ArgumentOutOfRangeException("task");
                
                if (task == NandTasks.FlashNandB && !Files.CheckFileType.IsSquashFs(nandDump))
                    throw new Exception(Properties.Resources.InvalidHsqs);


                bool isTar = false;
                if (task == NandTasks.FlashNandC)
                {
                    isTar = Files.CheckFileType.IsTar(nandDump);
                    if (!(isTar || Files.CheckFileType.IsExtFs(nandDump)))
                        throw new Exception(Properties.Resources.InvalidUserDataBackup);
                }

                long partitionSize = 300 * 1024 * 1024;
                var splitStream = new SplitterStream(Program.debugStreams);
                switch (task)
                {
                    case NandTasks.DumpNandB:
                    case NandTasks.FlashNandB:
                        hakchi.Shell.Execute("hakchi umount_base", null, splitStream, splitStream);
                        hakchi.Shell.Execute("umount /newroot");
                        hakchi.Shell.Execute("cryptsetup close root-crypt");
                        hakchi.Shell.ExecuteSimple("cryptsetup open /dev/nandb root-crypt --type plain --cipher aes-xts-plain --key-file /key-file", 2000, true);

                        if (task == NandTasks.DumpNandB)
                            partitionSize = long.Parse(hakchi.Shell.ExecuteSimple("echo $((($(hexdump -e '1/4 \"%u\"' -s $((0x28)) -n 4 /dev/mapper/root-crypt)+0xfff)/0x1000))", throwOnNonZero: true).Trim()) * 4 * 1024;

                        if (task == NandTasks.FlashNandB)
                            partitionSize = long.Parse(hakchi.Shell.ExecuteSimple("blockdev --getsize64 /dev/mapper/root-crypt", throwOnNonZero: true));

                        break;

                    case NandTasks.DumpNandC:
                        hakchi.Shell.Execute("hakchi mount_base", null, null, null, 0, true);
                        partitionSize = long.Parse(hakchi.Shell.ExecuteSimple("df -B 1 | grep /newroot/var/lib | head -n 1 | awk -e '{print $3 }'", throwOnNonZero: true).Trim());
                        break;
                    case NandTasks.FlashNandC:
                        partitionSize = long.Parse(hakchi.Shell.ExecuteSimple("blockdev --getsize64 /dev/nandc", throwOnNonZero: true));
                        break;

                    case NandTasks.DumpNand:
                        partitionSize = 536870912;
                        break;
                    case NandTasks.FormatNandC:
                        hakchi.Shell.Execute("cat > /bin/mke2fs; chmod +x /bin/mke2fs", File.OpenRead(Shared.PathCombine(Program.BaseDirectoryInternal, "tools", "arm", "mke2fs.static")), null, null, 0, true);
                        hakchi.Shell.Execute("hakchi umount_base", null, splitStream, splitStream);
                        hakchi.Shell.Execute("yes | mke2fs -t ext4 -L data -b 4K -E stripe-width=32 -O ^huge_file,^metadata_csum /dev/nandc", null, splitStream, splitStream, 0, true);
                        hakchi.Shell.Execute("rm /bin/mke2fs");
                        return Conclusion.Success;
                }

                FileMode mode = FileMode.Create;

                if (task == NandTasks.FlashNandC || task == NandTasks.FlashNandB)
                    mode = FileMode.Open;

                tasker.SetStatus(mode == FileMode.Open ? Resources.FlashingNand : Resources.DumpingNand);
                using (var file = new TrackableFileStream(nandDump, mode))
                {
                    if (mode == FileMode.Open && file.Length > partitionSize)
                        throw new Exception(Resources.ImageTooLarge);

                    if (mode == FileMode.Create && task != NandTasks.DumpNandC)
                        file.SetLength(partitionSize);

                    if (task == NandTasks.DumpNandC)
                    {
                        file.OnProgress += (long position, long length) =>
                        {
                            tasker.OnProgress(Math.Min(position, partitionSize), partitionSize);
                        };
                    }
                    else
                    {
                        file.OnProgress += tasker.OnProgress;
                    }

                    switch (task)
                    {
                        case NandTasks.DumpNandB:
                            Shared.ShellPipe($"dd if=/dev/mapper/root-crypt bs=128K count={(partitionSize / 1024) / 4 }", null, file, throwOnNonZero: true);
                            break;

                        case NandTasks.FlashNandB:
                            Shared.ShellPipe("dd of=/dev/mapper/root-crypt bs=128K", file, throwOnNonZero: true);
                            hakchi.Shell.Execute("cryptsetup close root-crypt", throwOnNonZero: true);
                            break;

                        case NandTasks.DumpNandC:
                            Shared.ShellPipe($"tar -cvC /newroot/var/lib/ .", null, file, null, throwOnNonZero: true);
                            break;

                        case NandTasks.FlashNandC:
                            if (isTar)
                            {
                                hakchi.Shell.Execute("hakchi mount_base", null, null, null, 0, true);
                                hakchi.Shell.Execute("rm -rf /newroot/var/lib/*", null, null, null, 0, true);
                                hakchi.Shell.Execute("tar -xvC /newroot/var/lib/", file, throwOnNonZero: true);
                            }
                            else
                            {
                                Shared.ShellPipe("dd of=/dev/nandc bs=128K", file, throwOnNonZero: true);
                            }
                            break;

                        case NandTasks.DumpNand:
                            hakchi.Shell.Execute("hakchi umount_base", splitStream, splitStream, splitStream, 0, true);
                            Shared.ShellPipe("sntool sunxi_flash phy_read 0 1000", null, file, throwOnNonZero: true);
                            break;
                    }
                    file.Close();
                }

                tasker.SetStatus(Resources.Done);
                tasker.SetProgress(1, 1);
                return Conclusion.Success;
            };
        }
コード例 #9
0
 public BulkItem AddField(TemplateField field, string value, Func <Stream> blob = null, bool isBlob = false,
                          string language = null, int?version = null,
                          Action <BulkField> postProcessor = null)
 {
     return(AddField(field.ID.Guid, value, blob, isBlob, language, version, field.Name, postProcessor));
 }
コード例 #10
0
        public async Task PetCommand(string action = "view", int slot = 0, [Remainder] string arguments = null)
        {
            Player player = Context.Player;

            slot--;
            switch (action?.ToLower())
            {
            case "view":
                if (slot < 0 || slot >= player.PetList.Count)
                {
                    await player.PetList.BuildUI(player, Context.Channel);
                }
                else
                {
                    await player.PetList[slot].GetInfo(player, Context.Channel, slot, false);
                }
                break;

            case "name":
            case "rename":
                if (slot < 0 || slot >= player.PetList.Count)
                {
                    throw NeitsilliaError.ReplyError("Please enter a valid slot for the pet you wish to rename: `~pet rename 1 \"Mister Paw\"");
                }
                if (arguments == null || arguments.Length < 1)
                {
                    throw NeitsilliaError.ReplyError($"Please enter a name for the pet you wish to rename: `~pet rename {slot} \"Mister Paw\"");
                }
                if (player.PetList[slot].status != Pet.PetStatus.Idle)
                {
                    throw NeitsilliaError.ReplyError($"Pet must be [Idle] to do that");
                }

                player.PetList[slot].pet.displayName = string.Join(" ", arguments);
                await player.PetList[slot].GetInfo(player, Context.Channel, slot, false);
                break;

            case "upgrade":
                if (slot < 0 || slot >= player.PetList.Count)
                {
                    await ReplyAsync("Please enter a valid slot for the pet you wish to upgrade: `~pet upgrade 1`");
                }
                else if (player.PetList[slot].status != Pet.PetStatus.Idle)
                {
                    await ReplyAsync($"Pet must be [Idle] to do that");
                }
                else
                {
                    await player.PetList[slot].UpgradeOptionsUI(player, Context.Channel, slot, false);
                }
                break;

            case "evolve":
                if (slot < 0 || slot >= player.PetList.Count)
                {
                    await ReplyAsync("Please enter a valid slot for the pet you wish to evolve: `~pet upgrade 1`");
                }
                else if (player.PetList[slot].status != Pet.PetStatus.Idle)
                {
                    await ReplyAsync($"Pet must be [Idle] to do that");
                }
                else
                {
                    await player.PetList[slot].ViewEvolves(player, Context.Channel, slot, false);
                }
                break;

            default:
                await ReplyAsync("Invalid action. Please try: "
                                 + Environment.NewLine + $"{Context.Prefix}pet view"
                                 + Environment.NewLine + $"{Context.Prefix}pet rename"
                                 + Environment.NewLine + $"{Context.Prefix}pet upgrade"
                                 + Environment.NewLine + $"{Context.Prefix}pet evolve"
                                 );

                break;
            }
        }
 public Task <IEnumValue?> TryCreateEnumValueAsync(string userSuppliedValue)
 {
     return(TaskResult.Null <IEnumValue>());
 }
コード例 #12
0
 public void GetSecretQuestion(TcpClient prmClient, string prmPacket)
 {
     if (prmClient.account.game.server.serverState == ServerStates.ONLINE)
         prmClient.SendPacket("Ax", true);
 }
コード例 #13
0
 public void GetLoginQueue(TcpClient prmClient, string prmPacket) => prmClient.account.Logger.LogInfo("File d'attente", "Position " + prmPacket[2] + "/" + prmPacket[4]);
コード例 #14
0
 public void GetNickname(TcpClient prmClient, string prmPacket) => prmClient.account.nickname = prmPacket.Substring(2);
コード例 #15
0
 public void GetServerSelection(TcpClient prmClient, string prmPacket)
 {
     prmClient.account.gameTicket = prmPacket.Substring(14);
     prmClient.account.SwitchToGameServer(Hash.Decrypt_IP(prmPacket.Substring(3, 8)), Hash.Decrypt_Port(prmPacket.Substring(11, 3).ToCharArray()));
 }
コード例 #16
0
        public MembootTasks(MembootTaskType type, string[] hmodsInstall = null, string[] hmodsUninstall = null, string dumpPath = null)
        {
            userRecovery = (hakchi.Shell.IsOnline && hakchi.MinimalMemboot && hakchi.UserMinimalMemboot);

            fel = new Fel();
            List<TaskFunc> taskList = new List<TaskFunc>();
            if (!hakchi.MinimalMemboot)
            {
                taskList.Add(WaitForFelOrMembootableShell);
                taskList.Add(TaskIf(() => { return hakchi.Shell.IsOnline; }, Memboot, MembootFel));
                taskList.Add(WaitForShellCycle);
                taskList.Add(ShellTasks.ShowSplashScreen);
            }
            switch (type)
            {
                case MembootTaskType.InstallHakchi:
                    taskList.AddRange(new TaskFunc[]
                    {
                        HandleHakchi(HakchiTasks.Install),
                        ModTasks.TransferBaseHmods("/hakchi/transfer")
                    });
                    if (!userRecovery)
                        taskList.Add(BootHakchi);

                    break;

                case MembootTaskType.ResetHakchi:
                    taskList.AddRange(new TaskFunc[]
                    {
                        HandleHakchi(HakchiTasks.Reset),
                        ModTasks.TransferBaseHmods("/hakchi/transfer")
                    });
                    if (!userRecovery)
                        taskList.Add(BootHakchi);

                    break;

                case MembootTaskType.UninstallHakchi:
                    taskList.AddRange(new TaskFunc[] {
                        GetStockKernel,
                        FlashStockKernel,
                        HandleHakchi(HakchiTasks.Uninstall)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.FactoryReset:
                    taskList.AddRange(new TaskFunc[] {
                        GetStockKernel,
                        FlashStockKernel,
                        ProcessNand(null, NandTasks.FormatNandC)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.DumpNand:
                    taskList.AddRange(new TaskFunc[]
                    {
                        ProcessNand(dumpPath, NandTasks.DumpNand)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.DumpNandB:
                    taskList.AddRange(new TaskFunc[]
                    {
                        ProcessNand(dumpPath, NandTasks.DumpNandB)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.DumpNandC:
                    taskList.AddRange(new TaskFunc[]
                    {
                        ProcessNand(dumpPath, NandTasks.DumpNandC)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.FlashNandB:
                    taskList.AddRange(new TaskFunc[]
                    {
                        ProcessNand(dumpPath, NandTasks.FlashNandB)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.FlashNandC:
                    taskList.AddRange(new TaskFunc[]
                    {
                        ProcessNand(dumpPath, NandTasks.FlashNandC)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.FormatNandC:
                    taskList.AddRange(new TaskFunc[]
                    {
                        ProcessNand(dumpPath, NandTasks.FormatNandC),
                        HandleHakchi(HakchiTasks.Install),
                        ModTasks.TransferBaseHmods("/hakchi/transfer")
                    });
                    if (!userRecovery)
                        taskList.Add(BootHakchi);

                    break;

                case MembootTaskType.ProcessMods:
                    taskList.AddRange(new ModTasks(hmodsInstall, hmodsUninstall).Tasks);
                    break;

                case MembootTaskType.FlashNormalUboot:
                    taskList.AddRange(new TaskFunc[]
                    {
                        FlashUboot(Fel.UbootType.Normal)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.FlashSDUboot:
                    taskList.AddRange(new TaskFunc[]
                    {
                        FlashUboot(Fel.UbootType.SD)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;

                case MembootTaskType.Memboot:
                    taskList.Add(BootHakchi);
                    break;

                case MembootTaskType.MembootOriginal:
                    taskList.Add(BootBackup2);
                    break;

                case MembootTaskType.MembootRecovery:
                    break;

                case MembootTaskType.DumpStockKernel:
                    taskList.AddRange(new TaskFunc[]
                    {
                        DumpStockKernel(dumpPath)
                    });
                    if (!userRecovery)
                        taskList.Add(ShellTasks.Reboot);

                    break;
            }
            Tasks = taskList.ToArray();
        }
コード例 #17
0
 public BulkItem AddSharedField(Guid id, string value,
                                Func <Stream> blob = null, bool isBlob = false, string name = null,
                                Action <BulkField> postProcessor = null)
 {
     return(AddField(id, value, blob, isBlob, null, null, name, postProcessor));
 }
コード例 #18
0
        public GenResult Gen(params object[] sqlElements)
        {
            #region Init

            GenResult gr;
            Table t = (Table)sqlElements[0];

            List<Column> pks = Utils.GetPrimaryKeyColumns(t);

            if (pks.Count == 0)
            {
                gr = new GenResult(GenResultTypes.Message);
                gr.Message = "无法为没有主键字段的表生成该UI代码!";
                return gr;
            }

            List<Column> wcs = Utils.GetWriteableColumns(t);
            List<Column> socs = Utils.GetSortableColumns(t);
            List<Column> sacs = Utils.GetSearchableColumns(t);

            StringBuilder sb = new StringBuilder();

            #endregion

            #region Gen

            string tbn = t.Name;

            sb.Append(@"
	<asp:GridView ID=""_" + tbn + @"_GridView"" CssClass=""GridView"" runat=""server"" AllowPaging=""True"" AllowSorting=""True"" AutoGenerateColumns=""False"" DataKeyNames=""");
            for (int i = 0; i < pks.Count; i++)
            {
                if (i > 0) sb.Append(@", ");
                sb.Append(pks[i].Name);
            }
            sb.Append(@""">
		<Columns>
			<asp:CommandField ShowSelectButton=""True"" />");
            foreach (Column c in t.Columns)
            {
                string cn = c.Name;
                string caption = Utils.GetCaption(c);
                if (string.IsNullOrEmpty(caption) || caption.Trim().Length == 0) caption = c.Name;
                string rdonly = wcs.Contains(c) ? "" : @" ReadOnly=""True""";
                string sort = socs.Contains(c) ? (@" SortExpression=""" + cn + @"""") : "";

                sb.Append(@"
			<asp:BoundField DataField=""" + cn + @""" HeaderText=""" + caption + @"""" + rdonly + @"" + sort + @" />");
            }
            sb.Append(@"
		</Columns>
		<FooterStyle CssClass=""GridView_Footer"" />
		<EmptyDataRowStyle CssClass=""GridView_Empty"" />
		<RowStyle CssClass=""GridView_Row"" />
		<EditRowStyle CssClass=""GridView_EditRow"" />
		<SelectedRowStyle CssClass=""GridView_SelectedRow"" />
		<PagerStyle CssClass=""GridView_Pager"" />
		<HeaderStyle CssClass=""GridView_Header"" />
		<AlternatingRowStyle CssClass=""GridView_AlternatingRow"" />
	</asp:GridView>
");

            #endregion

            #region return

            gr = new GenResult(GenResultTypes.CodeSegment);
            gr.CodeSegment = new KeyValuePair<string, string>(this._properties[GenProperties.Tips].ToString(), sb.ToString());
            return gr;

            #endregion
        }
コード例 #19
0
 public BulkItem AddVersionedField(Guid id, string language, int version, string value,
                                   Func <Stream> blob = null, bool isBlob = false, string name = null,
                                   Action <BulkField> postProcessor = null)
 {
     return(AddField(id, value, blob, isBlob, language, version, name, postProcessor));
 }
コード例 #20
0
 public EntityRoute(string url, IRouteHandler routeHandler) : base(url, routeHandler) { }
コード例 #21
0
        public BulkField GetField(Guid id, string language, int?version)
        {
            BulkField field;

            return(_fields.TryGetValue(new BulkFieldKey(id, language, version), out field) ? field : null);
        }
コード例 #22
0
 public GridViewColumnButtonMenu(GridView view) : base(view)
 {
     this.PathXml = Application.StartupPath + @"\LayoutGrid";
 }
コード例 #23
0
        /// <summary>
        /// Statistics fields are necessary for correct working of Sitecore versions.
        /// If not correctly configured, publish might e.g not work.
        /// </summary>
        /// <param name="defaultLanguage">Default language will be added when no language version is present.</param>
        /// <param name="mandatoryLanguages">Language for which a version must be present.</param>
        /// <param name="timestampsOnly">Whether to only ensure created and updated fields.</param>
        /// <param name="forceUpdate">Forces modification date to always be set, not only when data is changed.</param>
        public void EnsureLanguageVersions(string defaultLanguage = null, IEnumerable <string> mandatoryLanguages = null,
                                           bool timestampsOnly    = false, bool forceUpdate = false)
        {
            var user = global::Sitecore.Context.User.Name;
            var now  = DateUtil.IsoNow;

            var versionsByLanguage = new Dictionary <string, HashSet <int> >(StringComparer.OrdinalIgnoreCase);

            // Detect versions by language from fields.
            foreach (var field in Fields.OfType <UnversionedBulkField>())
            {
                var versioned = field as VersionedBulkField;
                var version   = versioned?.Version ?? 1;

                HashSet <int> versions;
                if (versionsByLanguage.TryGetValue(field.Language, out versions))
                {
                    versions.Add(version);
                }
                else
                {
                    versionsByLanguage[field.Language] = new HashSet <int> {
                        version
                    }
                };
            }

            // Ensure mandatory languages.
            foreach (var language in mandatoryLanguages ?? Enumerable.Empty <string>())
            {
                HashSet <int> versions;
                if (!versionsByLanguage.TryGetValue(language, out versions))
                {
                    versionsByLanguage[language] = new HashSet <int> {
                        1
                    }
                }
                ;
            }

            // Add default version when no version is present.
            if (versionsByLanguage.Count == 0)
            {
                versionsByLanguage[defaultLanguage ?? LanguageManager.DefaultLanguage.Name] = new HashSet <int> {
                    1
                }
            }
            ;

            foreach (var languageVersion in versionsByLanguage
                     .SelectMany(pair => pair.Value.Select(x => new { Language = pair.Key, Version = x })))
            {
                TryAddField(FieldIDs.Created.Guid, now,
                            language: languageVersion.Language, version: languageVersion.Version,
                            name: "__Created", postProcessor: x => x.DependsOnCreate = true);

                TryAddField(FieldIDs.Updated.Guid, now,
                            language: languageVersion.Language, version: languageVersion.Version,
                            name: "__Updated", postProcessor: x =>
                {
                    if (!forceUpdate)
                    {
                        x.DependsOnCreate = x.DependsOnUpdate = true;
                    }
                });

                if (!timestampsOnly)
                {
                    TryAddField(FieldIDs.CreatedBy.Guid, user,
                                language: languageVersion.Language, version: languageVersion.Version,
                                name: "__Created by", postProcessor: x => x.DependsOnCreate = true);

                    TryAddField(FieldIDs.UpdatedBy.Guid, user,
                                language: languageVersion.Language, version: languageVersion.Version,
                                name: "__Updated by", postProcessor: x => x.DependsOnCreate = x.DependsOnUpdate = true);

                    TryAddField(FieldIDs.Revision.Guid, Guid.NewGuid().ToString("D"),
                                language: languageVersion.Language, version: languageVersion.Version,
                                name: "__Revision", postProcessor: x => x.DependsOnCreate = x.DependsOnUpdate = true);
                }
            }
        }
コード例 #24
0
 /// <summary>
 /// Construct a property with the given name and value
 /// </summary>
 /// <param name="InName">Name of the property</param>
 /// <param name="InValue">Value of the property</param>
 public ReceiptProperty(string InName, string InValue)
 {
     Name  = InName;
     Value = InValue;
 }
コード例 #25
0
 public BulkFieldKey(Guid fieldId, string language, int?version)
 {
     FieldId  = fieldId;
     Language = language;
     Version  = version;
 }
コード例 #26
0
 public Flyweight GetFlyweight(string key)
 {
     return((Flyweight)flyweights[key]);
 }
コード例 #27
0
        private void AddField(BulkFieldKey key, string value, Func <Stream> blob = null, bool isBlob = false, string name = null,
                              Action <BulkField> postProcessor = null)
        {
            if (value == null && !isBlob)
            {
                return;
            }

            BulkField field = null;

            if (key.Language == null && !key.Version.HasValue)
            {
                field = new SharedBulkField(this, key.FieldId, value, blob, isBlob, name);
                _fields.Add(key, field);
            }
            else if (key.Language != null && !key.Version.HasValue)
            {
                field = new UnversionedBulkField(this, key.FieldId, key.Language, value, blob, isBlob, name);
                _fields.Add(key, field);
            }
            else if (key.Language == null && key.Version.HasValue)
            {
                throw new ArgumentException("You cannot add a language specific field without a version.");
            }
            else
            {
                field = new VersionedBulkField(this, key.FieldId, key.Language, key.Version.Value, value, blob, isBlob, name);
                _fields.Add(key, field);
            }

            postProcessor?.Invoke(field);
        }
コード例 #28
0
 private bool HasVariable(string name)
 {
     lock (_storage) {
         return(_storage.ContainsKey(name));
     }
 }
コード例 #29
0
 private SourceText(string text)
 {
     _text = text;
     Lines = ParseLines(this, text);
 }
コード例 #30
0
 public static SourceText From(string text)
 {
     return(new SourceText(text));
 }
コード例 #31
0
		public FTSRequestGenerator(string baseAddres) : this(new Uri(baseAddres))
		{
		}