public static void UpdateRemoteValue(Production production, UpdateType type) { DateTime temp = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime(); TimeSpan span = (production.UpdateDate.ToLocalTime() - temp); Dictionary <string, string> param = new Dictionary <string, string> { { "productionID", production.ID.ToString() }, { "updateTime", Convert.ToInt64(span.TotalSeconds).ToString() }, { "rendermachine_id", GlobalValues.LocalRenderMachine.Id.ToString() } }; switch (type) { case UpdateType.Status: param["status"] = ((int)production.Status).ToString(); RemoteDataManager.UpdateProduction(param); break; case UpdateType.ErrorCode: param["error_code"] = ((int)production.ErrorStatus).ToString(); RemoteDataManager.UpdateProduction(param); break; case UpdateType.Priority: param["priority"] = production.Priority.ToString(); RemoteDataManager.UpdateProduction(param); break; } }
public static void UpdateJob(Job Job, UpdateType Type) { DateTime temp = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime(); TimeSpan span = (Job.UpdateDate.ToLocalTime() - temp); Dictionary <string, string> param = new Dictionary <string, string> { { "jobID", Job.ID.ToString() }, { "updateTime", Math.Max(0, span.TotalSeconds).ToString() } }; switch (Type) { case UpdateType.Status: param["status"] = ((int)Job.Status).ToString(); break; case UpdateType.ErrorCode: param["error_code"] = ((int)Job.ErrorStatus).ToString(); break; case UpdateType.OutputExtension: param["output_extension"] = Job.OutputExtension; break; case UpdateType.RenderID: param["render_id"] = Job.RenderID; break; } RemoteDataManager.UpdateJob(param); }
public static void DeleteProduction(Production Production) { Dictionary <string, string> param = new Dictionary <string, string> { { "productionID", Production.ID.ToString() } }; RemoteDataManager.DeleteProduction(param); }
public static void ReadProductions() { string productionListString = RemoteDataManager.ExecuteRequest("getOpenJobs"); List <Dictionary <string, string> > productionDict = JsonDeserializer.Deserialize(productionListString); if (productionDict.Count > 0) { ProductionParser.ParseList(productionDict); } }
public static void UpdateFilmDuration(Production production) { DateTime temp = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime(); TimeSpan span = (production.UpdateDate.ToLocalTime() - temp); Dictionary <string, string> param = new Dictionary <string, string> { { "productionID", production.ID.ToString() }, { "updateTime", Convert.ToInt64(span.TotalSeconds).ToString() } }; param["duration"] = production.TotalFrameCount.ToString(); param["size"] = IOHelper.GetFilmFileSizeString(production); RemoteDataManager.UpdateFilm(param); }
public static List <AnimatedMotif> ReadAnimatedMotifs() { List <AnimatedMotif> result = new List <AnimatedMotif>(); string animatedMotifListString = RemoteDataManager.ExecuteRequest("getOpenMotifList"); List <Dictionary <string, string> > motifDict = JsonDeserializer.Deserialize(animatedMotifListString); if (motifDict.Count > 0) { result = MotifParser.ParseAnimatedMotifList(motifDict); } return(result); }
public static void UpdateHistoryTable(Production production) { DateTime temp = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime(); TimeSpan span = (production.UpdateDate.ToLocalTime() - temp); Dictionary <string, string> param = new Dictionary <string, string> { { "productionID", production.ID.ToString() }, { "updateTime", Convert.ToInt64(span.TotalSeconds).ToString() }, }; int[] jobIdList = new int[production.JobList.Count]; string[] totalMotifIDList = new string[production.JobList.Count]; int[] isDicativeList = new int[production.JobList.Count]; for (int i = 0; i < production.JobList.Count; i++) { jobIdList[i] = production.JobList[i].ProductID; if (production.JobList[i].IsDicative) { isDicativeList[i] = 1; } else { isDicativeList[i] = 0; } int[] motifIDList = new int[production.JobList[i].MotifList.Count]; for (int j = 0; j < production.JobList[i].MotifList.Count; j++) { motifIDList[j] = production.JobList[i].MotifList[j].ID; } totalMotifIDList[i] = String.Join(".", motifIDList); } param["DicativeList"] = String.Join(",", isDicativeList); param["JobIDList"] = String.Join(",", jobIdList); param["MotifIDList"] = String.Join(",", totalMotifIDList); param["FilmID"] = Convert.ToString(production.Film.ID); param["AccountID"] = Convert.ToString(production.AccountID); param["FilmName"] = production.Name; RemoteDataManager.UpdateHistory(param); }
public static Dictionary <string, string> GetRemoteAudio(AudioData AudioData) { Dictionary <string, string> param = new Dictionary <string, string> { { "audioID", AudioData.ID.ToString() }, }; string audioResultString = RemoteDataManager.ExecuteRequest("getAudioById", param); List <Dictionary <string, string> > audioDictString = JsonDeserializer.Deserialize(audioResultString); if (audioDictString.Count == 0) { return(null); } else { //DEBUG: Check indexing return(audioDictString[audioDictString.Count - 1]); } }
public static List <Job> ReadJobs(Production production) { List <Job> result = new List <Job>(); Dictionary <string, string> param = new Dictionary <string, string> { { "productionID", production.ID.ToString() }, { "is_preview", Convert.ToInt32(production.IsPreview).ToString() } }; string productionListString = RemoteDataManager.ExecuteRequest("getJobsByProductionID", param); List <Dictionary <string, string> > jobDict = JsonDeserializer.Deserialize(productionListString); if (jobDict.Count > 0) { result = JobParser.ParseList(production, jobDict); } result = new List <Job>(result.OrderBy(item => item.Position)); return(result); }
public static void ManageHeartbeat() { Dictionary <string, string> param = new Dictionary <string, string> { { "MachineName", GlobalValues.LocalRenderMachine.Name }, { "CurrentTime", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") }, { "Message", "none" }, { "IsActive", GlobalValues.IsActive.ToString() }, { "LicenseKey", Settings.LicenseKey } }; string heartBeatString = RemoteDataManager.ExecuteRequest("sendHeartbeat", param); if (heartBeatString.Length == 0) { GlobalValues.ActiveRenderMachine.Name = GlobalValues.LocalRenderMachine.Name; GlobalValues.ActiveRenderMachine.Id = GlobalValues.LocalRenderMachine.Id; GlobalValues.HasLicense = false; } else { try { GlobalValues.HasLicense = heartBeatString.Split(new char[] { ':' })[1].Substring(0, 1) == "1"; } catch { GlobalValues.HasLicense = false; } List <Dictionary <string, string> > heartbeatDict = JsonDeserializer.Deserialize(heartBeatString); //set local machine data if (heartbeatDict.Any(item => item["machinename"] == GlobalValues.LocalRenderMachine.Name)) { if (heartbeatDict.First(item => item["machinename"] == GlobalValues.LocalRenderMachine.Name)["status"] == "offline") { GlobalValues.ActiveRenderMachine.Name = GlobalValues.LocalRenderMachine.Name; GlobalValues.ActiveRenderMachine.Id = GlobalValues.LocalRenderMachine.Id; return; } else { GlobalValues.LocalRenderMachine.Id = Convert.ToInt32(heartbeatDict.First(item => item["machinename"] == GlobalValues.LocalRenderMachine.Name)["id"]); } } Dictionary <string, string> activeMachineDict; if (heartbeatDict.Any(item => item["force_active"] == "1")) { activeMachineDict = heartbeatDict.Where(item => item["force_active"] == "1").OrderBy(item => item["priority"]).First(); } else { activeMachineDict = heartbeatDict.OrderBy(item => item["priority"]).First(); } GlobalValues.ActiveRenderMachine.Name = activeMachineDict["machinename"]; GlobalValues.ActiveRenderMachine.Id = Convert.ToInt32(activeMachineDict["id"]); } }
public static string UpdateProductStatistics(Dictionary <string, string> param) { string result = RemoteDataManager.ExecuteRequest("updateProductStatistics", param); return(result); }