コード例 #1
0
        public DC_Message Update_Scheduled_Logs(DC_SchedulerServicesLogs param)
        {
            DataContracts.DC_Message _msg = new DataContracts.DC_Message();

            bool IsExist = false;

            try
            {
                using (ConsumerEntities context = new ConsumerEntities())
                {
                    //To check dupicate state
                    DC_SchedulerServicesLogs RQ = new DC_SchedulerServicesLogs();
                    RQ.Log_Id    = param.Log_Id;
                    RQ.Operation = "LOGID";

                    var result = Get_Scheduled_Logs(RQ);

                    if (result != null)
                    {
                        if (result.Count > 0)
                        {
                            var search = context.Supplier_Scheduled_Task_Log.Find(param.Log_Id);

                            if (search != null)
                            {
                                search.Status_Message = param.Status_Message;
                                search.Log_Type       = param.Log_Type;
                                search.Remarks        = param.Remarks;
                                search.Edit_User      = param.Create_User;
                                search.Edit_Date      = DateTime.Now;
                                context.SaveChanges();
                            }
                            _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Success;
                            _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strUpdatedSuccessfully;
                            return(_msg);
                        }
                        else
                        {
                            _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Warning;
                            _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strnotExist;
                            return(_msg);
                        }
                    }
                    else
                    {
                        _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Warning;
                        _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strnotExist;
                        return(_msg);
                    }
                }
            }
            catch
            {
                throw new FaultException <DataContracts.DC_ErrorStatus>(new DataContracts.DC_ErrorStatus {
                    ErrorMessage = "Error while updating Supplier Scheduled Logs.", ErrorStatusCode = System.Net.HttpStatusCode.InternalServerError
                });
            }
        }
コード例 #2
0
ファイル: DL_Pentaho.cs プロジェクト: dilip07156/WCF
        public DC_Message Pentaho_SupplierApiCall_Remove(Guid PentahoCall_Id, string CalledBy)
        {
            try
            {
                DC_Message dc = new DataContracts.DC_Message();
                if (PentahoCall_Id != Guid.Empty)
                {
                    string endpointurl = "removeTrans?id=" + PentahoCall_Id.ToString();
                    object result;
                    DHSVCProxy.GetData(ProxyFor.Pentaho, endpointurl, typeof(void), out result);

                    using (ConsumerEntities context = new ConsumerEntities())
                    {
                        List <Supplier_ApiCallLog> results = (from p in context.Supplier_ApiCallLog
                                                              where p.PentahoCall_Id == PentahoCall_Id
                                                              select p).ToList();
                        foreach (Supplier_ApiCallLog p in results)
                        {
                            p.Status    = "REMOVED";
                            p.Edit_User = CalledBy;
                            p.Edit_Date = DateTime.Now;
                            p.Message   = "Transformation Queue has been removed from Server.";
                        }
                        context.SaveChanges();
                    }

                    dc.StatusMessage = "The transformation was removed successfully.";
                    dc.StatusCode    = ReadOnlyMessage.StatusCode.Success;
                }
                else
                {
                    dc.StatusMessage = "Invalid Transformation Call Id !";
                    dc.StatusCode    = ReadOnlyMessage.StatusCode.Danger;
                }
                return(dc);
            }
            catch (Exception e)
            {
                return(new DC_Message {
                    StatusCode = ReadOnlyMessage.StatusCode.Danger, StatusMessage = e.Message
                });
            }
        }
コード例 #3
0
        public DC_Message Delete_Scheduled_Tasks(DC_SchedulerServicesTasks param)
        {
            DataContracts.DC_Message _msg = new DataContracts.DC_Message();

            bool IsExist = false;

            try
            {
                using (ConsumerEntities context = new ConsumerEntities())
                {
                    //To check dupicate state
                    DC_SchedulerServicesTasks RQ = new DC_SchedulerServicesTasks();
                    RQ.Task_Id   = param.Task_Id;
                    RQ.Operation = "TASKID";

                    var result = Get_Scheduled_Tasks(RQ);

                    if (result != null)
                    {
                        if (result.Count > 0)
                        {
                            var search = context.Supplier_Scheduled_Task.Find(param.Task_Id);

                            if (search != null)
                            {
                                if (param.Operation.ToLower() == "softdelete")
                                {
                                    using (var trn = context.Database.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
                                    {
                                        search.Edit_User = param.Create_User;
                                        search.Edit_Date = DateTime.Now;
                                        search.IsActive  = param.IsActive;
                                        context.SaveChanges();
                                        trn.Commit();
                                    }
                                }
                                _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Success;
                                _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strDeleted.Replace("deleted", (param.IsActive ? "restored" : "deleted"));
                                return(_msg);
                            }
                            else
                            {
                                _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Warning;
                                _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strnotExist;
                                return(_msg);
                            }
                        }
                        else
                        {
                            _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Warning;
                            _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strnotExist;
                            return(_msg);
                        }
                    }
                    else
                    {
                        _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Warning;
                        _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strnotExist;
                        return(_msg);
                    }
                }
            }
            catch
            {
                throw new FaultException <DataContracts.DC_ErrorStatus>(new DataContracts.DC_ErrorStatus {
                    ErrorMessage = "Error while updating Supplier Scheduled Task.", ErrorStatusCode = System.Net.HttpStatusCode.InternalServerError
                });
            }
        }
コード例 #4
0
        public DC_Message Update_Scheduled_Tasks(DC_SchedulerServicesTasks param)
        {
            DataContracts.DC_Message _msg = new DataContracts.DC_Message();

            bool IsExist = false;

            try
            {
                using (ConsumerEntities context = new ConsumerEntities())
                {
                    //To check dupicate state
                    DC_SchedulerServicesTasks RQ = new DC_SchedulerServicesTasks();
                    RQ.Task_Id   = param.Task_Id;
                    RQ.Operation = "TASKID";

                    var result = Get_Scheduled_Tasks(RQ);

                    if (result != null)
                    {
                        if (result.Count > 0)
                        {
                            var search = context.Supplier_Scheduled_Task.Find(param.Task_Id);
                            if (search != null)
                            {
                                using (var trn = context.Database.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
                                {
                                    search.Status = param.Status;

                                    // Condition for Change Running Status to completed.
                                    if (param.Api_Call_Log_Id != null)
                                    {
                                        search.Api_Call_Log_Id = param.Api_Call_Log_Id;
                                    }

                                    search.Edit_User = param.Create_User;
                                    search.Edit_Date = DateTime.Now;
                                    context.SaveChanges();

                                    trn.Commit();
                                }
                            }
                            _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Success;
                            _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strUpdatedSuccessfully;
                            return(_msg);
                        }
                        else
                        {
                            _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Warning;
                            _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strnotExist;
                            return(_msg);
                        }
                    }
                    else
                    {
                        _msg.StatusCode    = DataContracts.ReadOnlyMessage.StatusCode.Warning;
                        _msg.StatusMessage = param.Task_Id + DataContracts.ReadOnlyMessage.strnotExist;
                        return(_msg);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new FaultException <DataContracts.DC_ErrorStatus>(new DataContracts.DC_ErrorStatus {
                    ErrorMessage = "Error while updating Supplier Scheduled Task.", ErrorStatusCode = System.Net.HttpStatusCode.InternalServerError
                });
            }
        }
コード例 #5
0
ファイル: DL_Pentaho.cs プロジェクト: dilip07156/WCF
        public DC_Message Pentaho_SupplierApi_Call(Guid ApiLocationId, string CalledBy)
        {
            DC_Message dc = new DataContracts.DC_Message();

            try
            {
                using (ConsumerEntities context = new ConsumerEntities())
                {
                    var iCount = (from dlr in context.Supplier_ApiCallLog
                                  where dlr.Status == "RUNNING" && dlr.SupplierApiCallLog_Id == ApiLocationId
                                  select true).Count();

                    if (iCount > 0)
                    {
                        return(new DC_Message {
                            StatusMessage = "Transformation for GeoCode is already running.", StatusCode = ReadOnlyMessage.StatusCode.Information
                        });
                    }

                    else
                    {
                        var apilocation = (from a in context.Supplier_APILocation
                                           where a.Supplier_APILocation_Id == ApiLocationId &&
                                           a.STATUS.ToUpper() == "ACTIVE"
                                           select a.API_Path).FirstOrDefault();

                        if (!string.IsNullOrWhiteSpace(apilocation))
                        {
                            var  ApiCallId     = Guid.NewGuid();
                            Guid PentahoCallId = Guid.Empty;

                            context.Supplier_ApiCallLog.Add(new Supplier_ApiCallLog
                            {
                                SupplierApiCallLog_Id  = ApiCallId,
                                SupplierApiLocation_Id = ApiLocationId,
                                PentahoCall_Id         = PentahoCallId,
                                Create_Date            = DateTime.Now,
                                Create_User            = CalledBy,
                                Message = "Transformation Called.",
                                Status  = "SENT TO CARTE"
                            });
                            context.SaveChanges();
                            var getInsertedRow = context.Supplier_ApiCallLog.Find(ApiCallId);

                            string endpointurl = "runTrans/?trans=" + apilocation + "&api_call_id=" + ApiCallId.ToString();
                            object result;
                            DHSVCProxy.GetData(ProxyFor.Pentaho, endpointurl, typeof(DataContracts.Pentaho.DC_PentahoApiCallResult), out result);
                            DataContracts.Pentaho.DC_PentahoApiCallResult callResult = result as DataContracts.Pentaho.DC_PentahoApiCallResult;

                            if (callResult != null)
                            {
                                if (callResult.result.ToUpper() == "OK")
                                {
                                    dc.StatusMessage = callResult.message;
                                    dc.StatusCode    = ReadOnlyMessage.StatusCode.Success;
                                }
                                else
                                {
                                    dc.StatusMessage = callResult.message;
                                    dc.StatusCode    = ReadOnlyMessage.StatusCode.Danger;
                                }


                                Guid.TryParse(callResult.id, out PentahoCallId);
                                getInsertedRow.PentahoCall_Id = PentahoCallId;
                                getInsertedRow.Message        = callResult.message;
                                if (PentahoCallId == Guid.Empty)
                                {
                                    getInsertedRow.Status = "ERROR";
                                }
                                context.SaveChanges();

                                return(dc);
                            }
                            else
                            {
                                getInsertedRow.PentahoCall_Id = Guid.Empty;
                                getInsertedRow.Message        = "Api Call failed.";
                                getInsertedRow.Status         = "FAILED";
                                context.SaveChanges();

                                return(new DC_Message {
                                    StatusMessage = "Api Call failed.", StatusCode = ReadOnlyMessage.StatusCode.Failed
                                });
                            }
                        }
                        else
                        {
                            context.Supplier_ApiCallLog.Add(new Supplier_ApiCallLog
                            {
                                SupplierApiCallLog_Id  = Guid.NewGuid(),
                                SupplierApiLocation_Id = ApiLocationId,
                                PentahoCall_Id         = null,
                                Create_Date            = DateTime.Now,
                                Create_User            = CalledBy,
                                Message = "Api Location is not found.",
                                Status  = "INVALID"
                            });
                            context.SaveChanges();
                            return(new DC_Message {
                                StatusMessage = "Api Location is not found.", StatusCode = ReadOnlyMessage.StatusCode.Warning
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(new DC_Message {
                    StatusMessage = ex.Message, StatusCode = ReadOnlyMessage.StatusCode.Danger
                });
            }
        }