Sample Program to Enable Future Data

Using C++

The following lines of code provide a sample program to enable the ihArchiverAllowFutureDataWrites option using C++:
void SetFutureDataWriteOptions(void)
{
	
	ihChar enable[50];
	printf("\n\n Please enter 1/0 for enable/disable future data write per data store: ");
	_getws(enable);	
	ihChar dataStoreName[50];
	printf("\n\n Please enter data store name to enable future data writes ");
	_getws(dataStoreName);

	ihAPIStatus Status;
	ihOptionEx option;
	option.Option = ihArchiverAllowFutureDataWrites;
	option.DataStoreName = dataStoreName;
	Status = ihArchiveSetOption(SrvHdl, &option,enable);
	
}

void GetFutureDataWriteOptions()
{
	ihChar dataStoreName[50];
	printf("\n\n Please enter the name of the data store Future Data write Option:  ");
	_getws(dataStoreName);

	ihAPIStatus	 Status;
	ihChar			*Value;
	ihOptionEx temp;

	temp.Option = ihArchiverAllowFutureDataWrites;
	temp.DataStoreName = dataStoreName;

	Status = ihArchiveGetOption(SrvHdl,&temp,&Value);
	
	printf("Archive Future Data Write Option ihArchiverAllowFutureDataWrites value is  - [%ls]  for the data store [%ls]\n", (Value ? Value : L"NULL"), dataStoreName);
	Pause();
}

Using C#

The following lines of code provide a sample program to enable the ihArchiverAllowFutureDataWrites option using C#:
static void Main(string[] args)
        {
            string swtValue = "0";
            string dsName = "";
            ConsoleKeyInfo kInfo;
            connection = ClientConnect.NewConnection;
            do
            {
                Console.WriteLine("1 Set/Enable Data Store Create Offline Archives Option Value");
                Console.WriteLine("2 Set/Enable Data Store Allow Future Data Writes Option Value");
                Console.WriteLine("3 Get Data Store Create Offline Archives Option Value");
                Console.WriteLine("4 Get Data Store Allow Future Data Writes Option Value");
                Console.WriteLine("Enter Option Value");
                swtValue = Console.ReadLine();
                switch (swtValue)
                {
                    case "1":
                        Console.WriteLine("Enter Data Store Name");
                        dsName = Console.ReadLine();
                        connection.IServer.SetOption(HistorianOption.ServerCreateOfflineArchives, "1", dsName);
                        Console.WriteLine("Option value set to " + connection.IServer.GetOption(HistorianOption.ServerCreateOfflineArchives, dsName));
                        Console.ReadKey();
                        break;
                    case "2":
                        Console.WriteLine("Enter Data Store Name");
                        dsName = Console.ReadLine();
                        connection.IServer.SetOption(HistorianOption.ArchiverAllowFutureDataWrites, "1", dsName);
                        Console.WriteLine("Option value set to " + connection.IServer.GetOption(HistorianOption.ArchiverAllowFutureDataWrites, dsName));
                        Console.ReadKey();
                        break;
                    case "3":
                        Console.WriteLine("Enter Data Store Name");
                        dsName = Console.ReadLine();
                        Console.WriteLine("Option value is: " + connection.IServer.GetOption(HistorianOption.ServerCreateOfflineArchives, dsName));
                        Console.ReadKey();
                        break;
                    case "4":
                        Console.WriteLine("Enter Data Store Name");
                        dsName = Console.ReadLine();
                        Console.WriteLine("Option value is: " + connection.IServer.GetOption(HistorianOption.ArchiverAllowFutureDataWrites, dsName));
                        Console.ReadKey();
                        break;
                    default:
                        Console.WriteLine("Please enter valid number");
                        Console.ReadKey();
                        break;
                }
                Console.WriteLine("Please Enter X to exit");
                kInfo = Console.ReadKey();

            } while (kInfo.Key != ConsoleKey.X);
        }
    }