private void OnAsyncCompressed(object Sender, Archive.ArchiveEventArgs e) { this.Logger?.WriteLine("Compress end event."); // 圧縮に成功したならアップロードします。 if (!this.m_Zipper.IsCompressed) { return; } System.IO.FileStream Data = null; try { // アーカイブをファイルストリームで開きます。 Data = new System.IO.FileStream(e.Destnation, System.IO.FileMode.Open, System.IO.FileAccess.Read); // オブジェクトストレージの指定コンテナにアーカイブをアップロードします。 OpenStack.CreateObject(Options.UseContainerName, System.IO.Path.GetFileName(e.Destnation), Data, eContentType.CONTENTS_ARCHIVE_ZIP); this.Logger?.WriteLine("Archive file uploaded."); } catch (System.Exception ex) { this.Logger?.WriteLine(ex.Message, eLogLevel.ERROR); } finally{ // ストリームを必ず閉じます。 Data?.Close(); Data?.Dispose(); // 圧縮したファイルとテンポラリディレクトリを片付けます。 System.IO.File.Delete(this.TemporaryPath + "/" + e.Destnation); System.IO.Directory.Delete(this.TemporaryPath, true); } }
public void ClearOpenStack() { var target = UIInterfaceEnum.None;//根窗口 while (OpenStack.Count != 0 && OpenStack.Peek().name != target) { OpenStack.Pop(); } }
public void Clear() { EnteredEvent = null; OpenStack.Clear(); m_CurInterface = UIInterfaceEnum.None; m_LastInterface = UIInterfaceEnum.None; OpenLastInterface = UIInterfaceEnum.None; OpenningInterface = UIInterfaceEnum.None; OpenedInterface = UIInterfaceEnum.None; }
public void PushInOpenStack(UIInterfaceEnum name, string sceneName, string mapName, CtrlParams[] pars = null, List <int> specialreturnChain = null) { var item = new OpenStackItem(name, sceneName, mapName); item.pars = pars; if (name != UIInterfaceEnum.None) { if (UIInterfaceEnumUtil.IsRootUIInterfaceEnum(name)) { OpenStack.Clear(); } if (specialreturnChain != null && specialreturnChain.Count > 0 && UIInterfaceEnumUtil.IsRootUIInterfaceEnum((UIInterfaceEnum)specialreturnChain[specialreturnChain.Count - 1])) { OpenStack.Clear(); for (int i = specialreturnChain.Count - 1; i >= 0; i--) { UIInterfaceEnum specialName = (UIInterfaceEnum)specialreturnChain[i]; var specialItem = new OpenStackItem(specialName, UIInterfaceEnumUtil.IsRootUIInterfaceEnum(specialName) ? sceneName : sceneName, mapName); specialItem.pars = pars; OpenStack.Push(specialItem); } } if (OpenStack.Contains(item)) { while (!item.Equals(OpenStack.Pop())) { ; } } OpenStack.Push(item); } }
static void Main(string[] args) { schedInterface.auth _auth = new auth(); schedInterface.openstackEvents _events = new openstackEvents(); schedInterface.osettings _settings = new osettings(); schedInterface.events _eventsDB = new events(); functions _functions = new functions(); olocations _olocations = new olocations(); locations _locations = new locations(); osessions _osessions = new osessions(); sessions _sessions = new sessions(); speakers _speakers = new speakers(); event_types _types = new event_types(); Console.WriteLine("Begin Process..."); //Console.WriteLine("Getting Authorization..."); //Console.WriteLine(_auth.auth_justin(_settings.client_id(), _settings.client_secret())); //Console.ReadLine(); List <OpenStackEvent> evs = _events.push_events(); Console.WriteLine("Event Count:" + evs.Count.ToString()); foreach (OpenStackEvent ev in evs) { Console.WriteLine(ev.name); if (ev.active) { schedInterface.Event e = new Event(); e.event_end = _functions.ConvertUnixTimeStamp(ev.end_date.ToString()); e.event_start = _functions.ConvertUnixTimeStamp(ev.start_date.ToString()); e.interval = 5; e.last_update = DateTime.Now; e.openstack_id = ev.id; e.title = ev.name; if (e.event_start != null) { if (Convert.ToDateTime(e.event_end) > DateTime.Now) { e.offset = ev.time_zone.offset != null?Convert.ToInt32(ev.time_zone.offset) : 0; // check to see if it exists if (_eventsDB.find_by_openstack_id(Convert.ToInt32(e.openstack_id)).id > 0) { e.id = _eventsDB.find_by_openstack_id(Convert.ToInt32(e.openstack_id)).id; e = _eventsDB.appupdate(e); Console.WriteLine(" Updated..."); } else { e = _eventsDB.add(e); Console.WriteLine(" Added..."); } // Get Event TYpes and push them Console.WriteLine("Updating Event Types..."); Console.WriteLine(""); List <OpenStackEventType> oTypes = _events.push_event_types(Convert.ToInt32(e.openstack_id)); Console.WriteLine(oTypes.Count + " Types Found..."); Int32 tcnt = 0; foreach (OpenStackEventType oty in oTypes) { EventType ety = new EventType(); ety.title = oty.name; ety.event_type_id = oty.id; ety.event_id = e.id; //Console.WriteLine(ety.title + "..."); _types.addUpdate(ety); tcnt++; drawTextProgressBar(tcnt, oTypes.Count); } List <EventType> etypes = _types.by_event(e.id); // get locations and push them List <OpenStackLocation> locs = _olocations.get_by_event(Convert.ToInt32(e.openstack_id)); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(locs.Count + " Locations Found...."); Int32 lcnt = 0; foreach (OpenStackLocation l in locs) { Location lo = new Location(); //Console.WriteLine("Processing " + l.name); lo.title = l.name; lo.sched_id = l.id.ToString(); lo.event_id = e.id; _locations.add(lo); lcnt++; drawTextProgressBar(lcnt, locs.Count); } // now get the speakers Console.WriteLine(""); Console.WriteLine("Getting Speakers... (Processing Pages...)"); Console.WriteLine(""); OpenSpeaker openspeaker = new OpenSpeaker(); openspeaker = _speakers.refresh(Convert.ToInt32(e.openstack_id), "1"); drawTextProgressBar(0, openspeaker.last_page); foreach (Speaker speak in openspeaker.data) { speak.event_id = e.id; _speakers.add(speak); } Int32 cursp = 0; while (cursp <= openspeaker.last_page) { cursp++; drawTextProgressBar(cursp, openspeaker.last_page); openspeaker = _speakers.refresh(Convert.ToInt32(e.openstack_id), cursp.ToString()); foreach (Speaker speak in openspeaker.data) { speak.event_id = e.id; _speakers.add(speak); } } // now get the sessions Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Getting Sessions...."); Console.WriteLine(""); OpenStack op = new OpenStack(); Int32 total_count = 0; op = _osessions.refresh(Convert.ToInt32(e.openstack_id), "1"); Console.WriteLine("Processing Pages from API"); List <Session> fromAPI = new List <Session>(); List <OpenStackSession> allsessions = new List <OpenStackSession>(); allsessions.AddRange(op.data); drawTextProgressBar(0, op.last_page); Int32 cur = 1; while (cur <= op.last_page) { drawTextProgressBar(cur, op.last_page); // get the next records cur++; op = _osessions.refresh(Convert.ToInt32(e.openstack_id), cur.ToString()); allsessions.AddRange(op.data); } Int32 cursess = 0; Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Session Count:" + op.total.ToString()); Console.WriteLine("Processing Session Records..."); drawTextProgressBar(cursess, allsessions.Count); foreach (OpenStackSession sess in allsessions) { if (!string.IsNullOrEmpty(sess.title)) { fromAPI.Add(_sessions.add(_osessions.parse(sess, e, etypes), e.id)); } cursess++; drawTextProgressBar(cursess, allsessions.Count); } //Console.WriteLine(""); //Console.WriteLine(""); //Console.WriteLine("Finding Sessions to Remove..."); //// find sessions that have been removed and delete them from the database //List<Session> fromDB = _sessions.by_event(e.id); //Int32 dcnt = 0; //var result = fromDB.Where(p => !fromAPI.Any(p2 => p2.id == p.event_key)); //// iterate through them and delete them //foreach (var item in result) //{ // Console.WriteLine("Removing Session: " + item.event_key + " " + item.name); // //if (_sessions.remove(item.event_key)) // //{ // // drawTextProgressBar(dcnt, result.Count()); // //} // //dcnt++; //} } } } } }
/// <summary> /// Initializes a new instance of the <see cref="CloudNetworkService"/> class. /// </summary> /// <param name="authenticationProvider">The authentication provider.</param> /// <param name="region">The region.</param> public CloudNetworkService(OpenStack.Authentication.IAuthenticationProvider authenticationProvider, string region) { _networkingApiBuilder = new NetworkingApiBuilder(ServiceType.CloudNetworks, authenticationProvider, region); }
public void Execute() { // セーブデータディレクトリがあるかどうかチェックする。なければ作る。 if (!System.IO.Directory.Exists(Options.SavedataPath)) { System.IO.Directory.CreateDirectory(Options.SavedataPath); } // テンポラリ用ディレクトリのパスをチェック。 // 中身がなければ、 ./temp で初期化する。 if (String.IsNullOrEmpty(TemporaryPath)) { TemporaryPath = "./temp"; } // アプリケーションのパスを取得します。 this.UpdateBasePath(); // コンテナリスト System.Collections.Generic.IEnumerable <MyApplication.Objects.Container> ContainerList = OpenStack.GetContainers(); // オブジェクトリスト //System.Collections.Generic.IEnumerable<MyApplication.Objects.ContainerObject> ObjectList = null; // オブジェクトストレージ内の全体使用率をみる if (ContainerList.Count() > 0) { DataCapacityUnit Unit = new DataCapacityUnit() { Bytes = 0 }; // 全コンテナのサイズ計算 foreach (var entry in ContainerList) { Unit.Bytes += entry.Bytes; } // 全体で50GB以上使用してるなら、オブジェクトストレージ内を一掃する。 if (Unit.Giga > 50) { foreach (var entry in ContainerList) { OpenStack.DeleteContainer(entry.Name, true); } this.Logger.WriteLine("Object storage clean up executed."); } } // オブジェクトストレージ内に使用するコンテナ作成準備。 // 既に同名のコンテナがあれば作りません。 // 多重防止用汎用フラグ。存在するなら true, しないなら false bool IsExists = false; if (!OpenStack.SearchContainer(Options.UseContainerName)) { OpenStack.CreateContainer(Options.UseContainerName); } // ローカル内の最新セーブデータ日付 string LastDateInLocal = null; try { // セーブデータがあるディレクトリのサブディレクトリを列挙します。 string[] SubDirectories = System.IO.Directory.GetDirectories(Options.SavedataPath, "*", System.IO.SearchOption.TopDirectoryOnly); // サブディレクトリが1個もなければ、なにもしません。 if (SubDirectories.Length > 0) { // 関数に使用する整形したリストを作ります。 List <string> FormatList = new List <string>(SubDirectories.Length); foreach (var entry in SubDirectories) { FormatList.Add(System.IO.Path.GetFileName(entry)); } // ローカル内の最新日付を取得します。 LastDateInLocal = this.GetLastedDateTime(FormatList, Options.SavedataFormat); } } catch (System.Exception ex) { this.Logger.WriteLine(ex.Message, eLogLevel.ERROR); } // ローカルのセーブデータ名の取得に失敗してたならエラーなので、関数を抜けます。 if (string.IsNullOrEmpty(LastDateInLocal)) { this.Logger.WriteLine("Failed to get local save data name.", eLogLevel.ERROR); return; } // アップロード準備 // 日付の文字列形式をアップロード用に変化させます。 DateTime offset = DateTime.ParseExact(LastDateInLocal, Options.SavedataFormat, null); string ArchiveFileName = offset.ToString(Options.ArchiveFormat) + ".zip"; IsExists = false; ContainerList = OpenStack.GetContainers(); // コンテナの中身がなければ、確定でアップロードします。 if (ContainerList.Count() > 0) { // 既に同名のアーカイブがオブジェクトストレージ内にあるならアップロードしません。 if (OpenStack.SearchObject(Options.UseContainerName, ArchiveFileName)) { IsExists = true; this.Logger.WriteLine("The same file is in object storage."); } } // テンポラリディレクトリを新しく作ります。 if (!System.IO.Directory.Exists(this.TemporaryPath)) { System.IO.Directory.CreateDirectory(this.TemporaryPath); } // オブジェクトストレージに同一アーカイブがないなら圧縮しません。 if (!IsExists) { // ローカル内のセーブデータディレクトリをzip形式に圧縮します。 this.m_Zipper.Compress(Options.SavedataPath + "/" + LastDateInLocal, this.TemporaryPath + "/" + ArchiveFileName); } }
public void PopOutOpenStack() { OpenStack.Pop(); }